001/* -*- mode: Java; c-basic-offset: 2; indent-tabs-mode: nil; coding: utf-8-unix -*- 002 * 003 * Copyright © 2017 MicroBean. 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 014 * implied. See the License for the specific language governing 015 * permissions and limitations under the License. 016 */ 017package org.microbean.grizzly.http.server.cdi; 018 019import javax.enterprise.context.ApplicationScoped; 020import javax.enterprise.context.Dependent; 021 022import javax.enterprise.inject.Produces; 023 024import org.glassfish.grizzly.ssl.SSLContextConfigurator; 025import org.glassfish.grizzly.ssl.SSLEngineConfigurator; 026 027/** 028 * A class housing <a 029 * href="http://docs.jboss.org/cdi/spec/2.0-PFD/cdi-spec.html#producer_method">producer 030 * methods</a> that manufacture certain Grizzly-related objects. 031 * 032 * @author <a href="https://about.me/lairdnelson" 033 * target="_parent">Laird Nelson</a> 034 */ 035@ApplicationScoped 036class Producers { 037 038 /** 039 * Returns a new {@link SSLEngineConfigurator} {@linkplain 040 * SSLEngineConfigurator#SSLEngineConfigurator(SSLContextConfigurator) 041 * created with} the supplied {@link SSLContextConfigurator}. 042 * 043 * <p>This method never returns {@code null}.</p> 044 * 045 * @param sslContextConfigurator the {@link SSLContextConfigurator} 046 * to use {@linkplain 047 * SSLEngineConfigurator#SSLEngineConfigurator(SSLContextConfigurator) 048 * during construction}; must not be {@code null} 049 * 050 * @return a new {@link SSLEngineConfigurator}; never {@code null} 051 * 052 * @exception NullPointerException if {@code sslContextConfigurator} 053 * is {@code null} 054 */ 055 @Produces 056 @Dependent 057 private static final SSLEngineConfigurator produceSSLEngineConfigurator(final SSLContextConfigurator sslContextConfigurator) { 058 return new SSLEngineConfigurator(sslContextConfigurator); 059 } 060 061 /** 062 * Returns a new {@link SSLContextConfigurator} when invoked. 063 * 064 * <p>This method never returns {@code null}.</p> 065 * 066 * @return a new {@link SSLContextConfigurator}; never {@code null} 067 */ 068 @Produces 069 @Dependent 070 private static final SSLContextConfigurator produceSSLContextConfigurator() { 071 return new SSLContextConfigurator(true /* yes, read System properties */); 072 } 073 074}