use of org.atmosphere.cpr.AtmosphereInterceptor in project cxf by apache.
the class AtmosphereUtils method addInterceptors.
public static void addInterceptors(AtmosphereFramework framework, Bus bus) {
Object ais = bus.getProperty("atmosphere.interceptors");
// pre-install those atmosphere default interceptors before the custom interceptors.
framework.interceptor(new CacheHeadersInterceptor()).interceptor(new HeartbeatInterceptor()).interceptor(new SSEAtmosphereInterceptor()).interceptor(new JavaScriptProtocol());
if (ais == null || ais instanceof AtmosphereInterceptor) {
framework.interceptor(ais == null ? new DefaultProtocolInterceptor() : (AtmosphereInterceptor) ais);
return;
}
if (ais instanceof List<?>) {
List<AtmosphereInterceptor> icps = CastUtils.cast((List<?>) ais);
// add the custom interceptors
for (AtmosphereInterceptor icp : icps) {
framework.interceptor(icp);
}
}
}
use of org.atmosphere.cpr.AtmosphereInterceptor in project cxf by apache.
the class AtmosphereWebSocketJettyDestinationTest method testUseCXFDefaultAtmoosphereInterceptor.
@Test
public void testUseCXFDefaultAtmoosphereInterceptor() throws Exception {
Bus bus = new ExtensionManagerBus();
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 (DefaultProtocolInterceptor.class.equals(a.getClass())) {
added++;
break;
}
}
assertEquals(1, added);
}
use of org.atmosphere.cpr.AtmosphereInterceptor in project cxf by apache.
the class AtmosphereWebSocketJettyDestinationTest method testUseCustomAtmoosphereInterceptor.
@Test
public void testUseCustomAtmoosphereInterceptor() throws Exception {
Bus bus = new ExtensionManagerBus();
bus.setProperty("atmosphere.interceptors", new CustomInterceptor1());
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++;
break;
}
}
assertEquals(1, added);
}
use of org.atmosphere.cpr.AtmosphereInterceptor in project cxf by apache.
the class AtmosphereWebSocketServletDestinationTest method testUseCXFDefaultAtmoosphereInterceptor.
@Test
public void testUseCXFDefaultAtmoosphereInterceptor() throws Exception {
Bus bus = new ExtensionManagerBus();
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 (DefaultProtocolInterceptor.class.equals(a.getClass())) {
added++;
break;
}
}
assertEquals(1, added);
}
use of org.atmosphere.cpr.AtmosphereInterceptor in project cxf by apache.
the class AtmosphereWebSocketServletDestinationTest method testUseCustomAtmoosphereInterceptor.
@Test
public void testUseCustomAtmoosphereInterceptor() throws Exception {
Bus bus = new ExtensionManagerBus();
bus.setProperty("atmosphere.interceptors", new CustomInterceptor1());
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++;
break;
}
}
assertEquals(1, added);
}
Aggregations