public TomcatEventHandlerAdapter(ContainerEventHandler eventHandler, ServerProvider serverProvider, ProxyConnectorProvider connectorProvider) { this(eventHandler, serverProvider, new ServiceLoaderTomcatFactory(connectorProvider)); }
public ServiceLoaderTomcatFactory(ProxyConnectorProvider provider) { this.serverFactory = load(ServerFactory.class, TomcatServerFactory.class); this.engineFactory = load(EngineFactory.class, TomcatEngineFactory.class); this.hostFactory = load(HostFactory.class, TomcatHostFactory.class); this.contextFactory = load(ContextFactory.class, TomcatContextFactory.class); this.connectorFactory = load(ConnectorFactory.class, TomcatConnectorFactory.class); this.provider = provider; }
@Test public void testCatalinaFactories() throws Exception { ServiceLoaderTomcatFactory factory = new ServiceLoaderTomcatFactory(this.serverFactory, this.engineFactory, this.hostFactory, this.contextFactory, this.connectorFactory, this.provider); org.apache.catalina.Server catalinaServer = mock(org.apache.catalina.Server.class); Server server = mock(Server.class); when(this.serverFactory.createServer(same(factory), same(catalinaServer))).thenReturn(server); assertSame(server, factory.createServer(catalinaServer)); org.apache.catalina.Service service = mock(org.apache.catalina.Service.class); org.apache.catalina.Engine catalinaEngine = mock(org.apache.catalina.Engine.class); Engine engine = mock(Engine.class); when(catalinaEngine.getService()).thenReturn(service); when(service.getServer()).thenReturn(catalinaServer); when(this.engineFactory.createEngine(same(factory), same(catalinaEngine), same(server))).thenReturn(engine); assertSame(engine, factory.createEngine(catalinaEngine)); org.apache.catalina.Host catalinaHost = mock(org.apache.catalina.Host.class); Host host = mock(Host.class); when(catalinaHost.getParent()).thenReturn(catalinaEngine); when(this.hostFactory.createHost(same(factory), same(catalinaHost), same(engine))).thenReturn(host); assertSame(host, factory.createHost(catalinaHost)); org.apache.catalina.Context catalinaContext = mock(org.apache.catalina.Context.class); Context context = mock(Context.class); when(catalinaContext.getParent()).thenReturn(catalinaHost); when(this.contextFactory.createContext(same(catalinaContext), same(host))).thenReturn(context); assertSame(context, factory.createContext(catalinaContext)); }
@Override public Host createHost(org.apache.catalina.Host host) { return this.hostFactory.createHost(this, host, this.createEngine((org.apache.catalina.Engine) host.getParent())); }
@Override public Context createContext(org.apache.catalina.Context context) { return this.contextFactory.createContext(context, this.createHost((org.apache.catalina.Host) context.getParent())); }
@Override public Engine createEngine(org.apache.catalina.Engine engine) { return this.engineFactory.createEngine(this, engine, this.createServer(engine.getService().getServer())); }
@Test public void testServiceLoader() { this.verifyCatalinaFactoryTypes(new ServiceLoaderTomcatFactory(this.provider)); }
public ModClusterListener() { ModClusterService service = new ModClusterService(this, this); this.service = service; this.listener = ServiceLoaderTomcatFactory.load(LifecycleListenerFactory.class, TomcatEventHandlerAdapterFactory.class).createListener(service, this); }
@Test public void testCatalinaFactoryRegistry() { TomcatFactoryRegistry registry = new ServiceLoaderTomcatFactory(this.serverFactory, this.engineFactory, this.hostFactory, this.contextFactory, this.connectorFactory, this.provider); assertSame(this.serverFactory, registry.getServerFactory()); assertSame(this.engineFactory, registry.getEngineFactory()); assertSame(this.hostFactory, registry.getHostFactory()); assertSame(this.contextFactory, registry.getContextFactory()); assertSame(this.connectorFactory, registry.getConnectorFactory()); assertSame(this.provider, registry.getProxyConnectorProvider()); }