use of org.apache.cxf.endpoint.ServerLifeCycleListener in project cxf by apache.
the class OSGIBusListener method registerServerLifecycleListeners.
private void registerServerLifecycleListeners() {
ServiceReference<?>[] refs = getServiceReferences(defaultContext, ServerLifeCycleListener.class);
ServerLifeCycleManager clcm = bus.getExtension(ServerLifeCycleManager.class);
for (ServiceReference<?> ref : refs) {
if (!isPrivate(ref) && !isExcluded(ref)) {
ServerLifeCycleListener listener = (ServerLifeCycleListener) defaultContext.getService(ref);
clcm.registerListener(listener);
}
}
}
use of org.apache.cxf.endpoint.ServerLifeCycleListener in project cxf by apache.
the class RMManager method registerListeners.
@PostConstruct
void registerListeners() {
if (null == bus) {
return;
}
ServerLifeCycleManager slm = bus.getExtension(ServerLifeCycleManager.class);
if (null != slm) {
slm.registerListener(new ServerLifeCycleListener() {
public void startServer(Server server) {
RMManager.this.startServer(server);
}
public void stopServer(Server server) {
RMManager.this.stopServer(server);
}
});
}
ClientLifeCycleManager clm = bus.getExtension(ClientLifeCycleManager.class);
if (null != clm) {
clm.registerListener(new ClientLifeCycleListener() {
public void clientCreated(Client client) {
RMManager.this.clientCreated(client);
}
public void clientDestroyed(Client client) {
RMManager.this.clientDestroyed(client);
}
});
}
}
use of org.apache.cxf.endpoint.ServerLifeCycleListener in project cxf by apache.
the class LifeCycleTest method testGetActiveFeatures.
@Test
public void testGetActiveFeatures() {
assertNotNull("unexpected non-null ServerLifeCycleManager", manager);
manager.registerListener(new ServerLifeCycleListener() {
public void startServer(Server server) {
org.apache.cxf.endpoint.Endpoint endpoint = server.getEndpoint();
updateMap(startNotificationMap, endpoint.getEndpointInfo().getAddress());
String portName = endpoint.getEndpointInfo().getName().getLocalPart();
if ("SoapPort".equals(portName)) {
List<Feature> active = endpoint.getActiveFeatures();
assertNotNull(active);
assertEquals(1, active.size());
assertTrue(active.get(0) instanceof WSAddressingFeature);
assertSame(active.get(0), AbstractFeature.getActive(active, WSAddressingFeature.class));
} else {
List<Feature> active = endpoint.getActiveFeatures();
assertNotNull(active);
assertEquals(0, active.size());
assertNull(AbstractFeature.getActive(active, WSAddressingFeature.class));
}
}
public void stopServer(Server server) {
updateMap(stopNotificationMap, server.getEndpoint().getEndpointInfo().getAddress());
}
});
Endpoint greeter = Endpoint.publish(ADDRESSES[0], new GreeterImpl());
Endpoint control = Endpoint.publish(ADDRESSES[1], new ControlImpl());
greeter.stop();
control.stop();
for (int i = 0; i < 2; i++) {
verifyNotification(startNotificationMap, ADDRESSES[i], 1);
verifyNotification(stopNotificationMap, ADDRESSES[i], 1);
}
}
use of org.apache.cxf.endpoint.ServerLifeCycleListener in project cxf by apache.
the class LifeCycleTest method testRecursive.
@Test
public void testRecursive() {
assertNotNull("unexpected non-null ServerLifeCycleManager", manager);
manager.registerListener(new ServerLifeCycleListener() {
public void startServer(Server server) {
String address = server.getEndpoint().getEndpointInfo().getAddress();
verifyNotification(startNotificationMap, address, 0);
updateMap(startNotificationMap, address);
if (recursiveCount < RECURSIVE_LIMIT) {
recursiveEndpoints[recursiveCount++] = Endpoint.publish(ADDRESSES[recursiveCount], new GreeterImpl());
}
}
public void stopServer(Server server) {
String address = server.getEndpoint().getEndpointInfo().getAddress();
verifyNotification(stopNotificationMap, address, 0);
updateMap(stopNotificationMap, address);
if (recursiveCount > 0) {
recursiveEndpoints[--recursiveCount].stop();
}
}
});
Endpoint.publish(ADDRESSES[0], new GreeterImpl()).stop();
for (int i = 0; i < ADDRESSES.length; i++) {
verifyNotification(startNotificationMap, ADDRESSES[i], 1);
verifyNotification(stopNotificationMap, ADDRESSES[i], 1);
}
}
use of org.apache.cxf.endpoint.ServerLifeCycleListener in project cxf by apache.
the class OSGiBusListenerTest method setUpServerLifeCycleListeners.
private void setUpServerLifeCycleListeners(String[] names, String[] restricted, String excludes) throws Exception {
ServiceReference<Object>[] svcrefs = createTestServiceReferences(names, restricted);
EasyMock.expect(bundleContext.getServiceReferences(ServerLifeCycleListener.class.getName(), null)).andReturn(svcrefs);
ServerLifeCycleManager lcmanager = control.createMock(ServerLifeCycleManager.class);
EasyMock.expect(bus.getExtension(ServerLifeCycleManager.class)).andReturn(lcmanager).anyTimes();
for (int i = 0; i < names.length; i++) {
ServerLifeCycleListener cl = control.createMock(ServerLifeCycleListener.class);
EasyMock.expect(bundleContext.getService(svcrefs[i])).andReturn(cl).anyTimes();
if (!isExcluded(BUNDLE_NAME, names[i], restricted[i], excludes)) {
lcmanager.registerListener(cl);
EasyMock.expectLastCall();
}
}
}
Aggregations