use of org.apache.felix.http.jetty.ConnectorFactory in project felix by apache.
the class HttpJettyConnectorTest method testRegisterConnectorFactoryOk.
@Test
public void testRegisterConnectorFactoryOk() throws Exception {
final CountDownLatch openLatch = new CountDownLatch(1);
final CountDownLatch closeLatch = new CountDownLatch(1);
ConnectorFactory factory = new ConnectorFactory() {
@Override
public Connector createConnector(Server server) {
return new LocalConnector(server) {
@Override
public void doStart() throws Exception {
openLatch.countDown();
super.doStart();
}
@Override
public void doStop() throws Exception {
closeLatch.countDown();
super.doStop();
}
};
}
};
ServiceRegistration reg = m_context.registerService(ConnectorFactory.class.getName(), factory, null);
// Should be opened automatically when picked up by the Jetty implementation...
assertTrue("Felix HTTP Jetty did not open the Connection or pick up the registered ConnectionFactory", openLatch.await(5, TimeUnit.SECONDS));
// Should close our connection...
reg.unregister();
assertTrue("Felix HTTP Jetty did not close the Connection", closeLatch.await(5, TimeUnit.SECONDS));
}
use of org.apache.felix.http.jetty.ConnectorFactory in project felix by apache.
the class ConnectorFactoryTracker method addingService.
@Override
public Connector addingService(ServiceReference<ConnectorFactory> reference) {
ConnectorFactory factory = (ConnectorFactory) super.addingService(reference);
Connector connector = factory.createConnector(server);
try {
this.server.addConnector(connector);
connector.start();
return connector;
} catch (Exception e) {
SystemLogger.error("Failed starting connector '" + connector + "' provided by " + reference, e);
}
// connector failed to start, don't continue tracking
return null;
}
Aggregations