use of org.apache.cxf.transport.http.DestinationRegistry in project cxf by apache.
the class HTTPTransportActivator method start.
public void start(final BundleContext context) throws Exception {
ConfigAdminHttpConduitConfigurer conduitConfigurer = new ConfigAdminHttpConduitConfigurer();
registerService(context, ManagedServiceFactory.class, conduitConfigurer, ConfigAdminHttpConduitConfigurer.FACTORY_PID);
registerService(context, HTTPConduitConfigurer.class, conduitConfigurer, "org.apache.cxf.http.conduit-configurer");
if (PropertyUtils.isTrue(context.getProperty(DISABLE_DEFAULT_HTTP_TRANSPORT))) {
// directly in the CXF_CONFIG_SCOPE properties file
return;
}
DestinationRegistry destinationRegistry = new DestinationRegistryImpl();
HTTPTransportFactory transportFactory = new HTTPTransportFactory(destinationRegistry);
HttpServiceTrackerCust customizer = new HttpServiceTrackerCust(destinationRegistry, context);
httpServiceTracker = new ServiceTracker<>(context, HttpService.class, customizer);
httpServiceTracker.open();
context.registerService(DestinationRegistry.class.getName(), destinationRegistry, null);
context.registerService(HTTPTransportFactory.class.getName(), transportFactory, null);
BlueprintNameSpaceHandlerFactory factory = new BlueprintNameSpaceHandlerFactory() {
@Override
public Object createNamespaceHandler() {
return new HttpBPHandler();
}
};
NamespaceHandlerRegisterer.register(context, factory, "http://cxf.apache.org/transports/http/configuration");
}
use of org.apache.cxf.transport.http.DestinationRegistry in project cxf by apache.
the class AtmosphereWebSocketJettyDestinationTest method testUseCustomAtmoosphereInterceptors.
@Test
public void testUseCustomAtmoosphereInterceptors() throws Exception {
Bus bus = new ExtensionManagerBus();
bus.setProperty("atmosphere.interceptors", Arrays.asList(new CustomInterceptor1(), new CustomInterceptor2()));
DestinationRegistry registry = new HTTPTransportFactory().getRegistry();
EndpointInfo endpoint = new EndpointInfo();
endpoint.setAddress(ENDPOINT_ADDRESS);
endpoint.setName(ENDPOINT_NAME);
AtmosphereWebSocketServletDestination dest = new AtmosphereWebSocketServletDestination(bus, registry, endpoint, ENDPOINT_ADDRESS);
List<AtmosphereInterceptor> ais = dest.getAtmosphereFramework().interceptors();
int added = 0;
for (AtmosphereInterceptor a : ais) {
if (CustomInterceptor1.class.equals(a.getClass())) {
added++;
} else if (CustomInterceptor2.class.equals(a.getClass())) {
added++;
break;
}
}
assertEquals(2, added);
}
use of org.apache.cxf.transport.http.DestinationRegistry in project cxf by apache.
the class AtmosphereWebSocketServletDestinationTest method testUseCustomAtmoosphereInterceptors.
@Test
public void testUseCustomAtmoosphereInterceptors() throws Exception {
Bus bus = new ExtensionManagerBus();
bus.setProperty("atmosphere.interceptors", Arrays.asList(new CustomInterceptor1(), new CustomInterceptor2()));
DestinationRegistry registry = new HTTPTransportFactory().getRegistry();
EndpointInfo endpoint = new EndpointInfo();
endpoint.setAddress(ENDPOINT_ADDRESS);
endpoint.setName(ENDPOINT_NAME);
AtmosphereWebSocketServletDestination dest = new AtmosphereWebSocketServletDestination(bus, registry, endpoint, ENDPOINT_ADDRESS);
List<AtmosphereInterceptor> ais = dest.getAtmosphereFramework().interceptors();
int added = 0;
for (AtmosphereInterceptor a : ais) {
if (CustomInterceptor1.class.equals(a.getClass())) {
added++;
} else if (CustomInterceptor2.class.equals(a.getClass())) {
added++;
break;
}
}
assertEquals(2, added);
}
use of org.apache.cxf.transport.http.DestinationRegistry in project cxf by apache.
the class JettyWebSocketDestinationTest method testRegisteration.
@Test
public void testRegisteration() throws Exception {
Bus bus = new ExtensionManagerBus();
DestinationRegistry registry = new HTTPTransportFactory().getRegistry();
EndpointInfo endpoint = new EndpointInfo();
endpoint.setAddress(ENDPOINT_ADDRESS);
endpoint.setName(ENDPOINT_NAME);
JettyHTTPServerEngine engine = EasyMock.createMock(JettyHTTPServerEngine.class);
control.replay();
TestJettyWebSocketDestination dest = new TestJettyWebSocketDestination(bus, registry, endpoint, null, engine);
dest.activate();
assertNotNull(registry.getDestinationForPath(ENDPOINT_ADDRESS));
dest.deactivate();
assertNull(registry.getDestinationForPath(ENDPOINT_ADDRESS));
}
use of org.apache.cxf.transport.http.DestinationRegistry in project cxf by apache.
the class CXFNonSpringServlet method getDestinationRegistryFromBusOrDefault.
protected DestinationRegistry getDestinationRegistryFromBusOrDefault(final String transportId) {
DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
try {
String peferredTransportId = transportId;
// extension or customization).
if (StringUtils.isEmpty(peferredTransportId) && getBus() != null) {
peferredTransportId = (String) getBus().getProperty(AbstractTransportFactory.PREFERRED_TRANSPORT_ID);
}
if (StringUtils.isEmpty(peferredTransportId)) {
final Set<String> candidates = dfm.getRegisteredDestinationFactoryNames();
// consider other candidates
if (!candidates.contains(DEFAULT_TRANSPORT_ID)) {
peferredTransportId = candidates.stream().filter(name -> name.endsWith("/configuration")).findAny().orElse(DEFAULT_TRANSPORT_ID);
}
}
DestinationFactory df = StringUtils.isEmpty(peferredTransportId) ? dfm.getDestinationFactory(DEFAULT_TRANSPORT_ID) : dfm.getDestinationFactory(peferredTransportId);
if (df instanceof HTTPTransportFactory) {
HTTPTransportFactory transportFactory = (HTTPTransportFactory) df;
return transportFactory.getRegistry();
}
} catch (BusException e) {
// why are we throwing a busexception if the DF isn't found?
}
return null;
}
Aggregations