Repository: cxf Updated Branches: refs/heads/master c62ac164b -> c67b0119c
Make it easier to use a subclass of ServerImpl to create ManagedEndpoints with specific additional functionality Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/63dce485 Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/63dce485 Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/63dce485 Branch: refs/heads/master Commit: 63dce4850acf497e08cc692c5ad03d3d0788eae9 Parents: c62ac16 Author: Daniel Kulp <[email protected]> Authored: Thu Apr 3 10:41:18 2014 -0400 Committer: Daniel Kulp <[email protected]> Committed: Thu Apr 3 10:41:18 2014 -0400 ---------------------------------------------------------------------- .../apache/cxf/endpoint/ManagedEndpoint.java | 7 ++-- .../org/apache/cxf/endpoint/ServerImpl.java | 40 ++++++-------------- 2 files changed, 15 insertions(+), 32 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/63dce485/core/src/main/java/org/apache/cxf/endpoint/ManagedEndpoint.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/cxf/endpoint/ManagedEndpoint.java b/core/src/main/java/org/apache/cxf/endpoint/ManagedEndpoint.java index de53e8b..cd8fc28 100644 --- a/core/src/main/java/org/apache/cxf/endpoint/ManagedEndpoint.java +++ b/core/src/main/java/org/apache/cxf/endpoint/ManagedEndpoint.java @@ -37,9 +37,10 @@ public class ManagedEndpoint implements ManagedComponent, ServerLifeCycleListene public static final String ENDPOINT_NAME = "managed.endpoint.name"; public static final String SERVICE_NAME = "managed.service.name"; - private Bus bus; - private Endpoint endpoint; - private Server server; + protected final Bus bus; + protected final Endpoint endpoint; + protected final Server server; + private enum State { CREATED, STARTED, STOPPED }; private State state = State.CREATED; http://git-wip-us.apache.org/repos/asf/cxf/blob/63dce485/core/src/main/java/org/apache/cxf/endpoint/ServerImpl.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/cxf/endpoint/ServerImpl.java b/core/src/main/java/org/apache/cxf/endpoint/ServerImpl.java index 6bba8c5..bb9d7fc 100644 --- a/core/src/main/java/org/apache/cxf/endpoint/ServerImpl.java +++ b/core/src/main/java/org/apache/cxf/endpoint/ServerImpl.java @@ -40,31 +40,21 @@ import org.apache.cxf.transport.MultipleEndpointObserver; public class ServerImpl implements Server { private static final Logger LOG = LogUtils.getL7dLogger(ServerImpl.class); + + protected final Endpoint endpoint; + protected final Bus bus; + protected final BindingFactory bindingFactory; + private Destination destination; - private Endpoint endpoint; private ServerRegistry serverRegistry; - private Bus bus; private ServerLifeCycleManager slcMgr; private InstrumentationManager iMgr; - private BindingFactory bindingFactory; - private MessageObserver messageObserver; private ManagedEndpoint mep; private boolean stopped = true; public ServerImpl(Bus bus, Endpoint endpoint, DestinationFactory destinationFactory, - MessageObserver observer) throws BusException, IOException { - this.endpoint = endpoint; - this.bus = bus; - this.messageObserver = observer; - - initDestination(destinationFactory); - } - - public ServerImpl(Bus bus, - Endpoint endpoint, - DestinationFactory destinationFactory, BindingFactory bindingFactory) throws BusException, IOException { this.endpoint = endpoint; this.bus = bus; @@ -95,7 +85,7 @@ public class ServerImpl implements Server { LOG.info("Setting the server's publish address to be " + ei.getAddress()); serverRegistry = bus.getExtension(ServerRegistry.class); - mep = new ManagedEndpoint(bus, endpoint, this); + mep = createManagedEndpoint(); slcMgr = bus.getExtension(ServerLifeCycleManager.class); if (slcMgr != null) { @@ -111,6 +101,10 @@ public class ServerImpl implements Server { } } } + + protected ManagedEndpoint createManagedEndpoint() { + return new ManagedEndpoint(bus, endpoint, this); + } public Destination getDestination() { return destination; @@ -126,11 +120,7 @@ public class ServerImpl implements Server { } LOG.fine("Server is starting."); - if (messageObserver != null) { - destination.setMessageObserver(messageObserver); - } else { - bindingFactory.addListener(destination, endpoint); - } + bindingFactory.addListener(destination, endpoint); // register the active server to run if (null != serverRegistry) { @@ -209,13 +199,5 @@ public class ServerImpl implements Server { public Endpoint getEndpoint() { return endpoint; } - - public MessageObserver getMessageObserver() { - return messageObserver; - } - - public void setMessageObserver(MessageObserver messageObserver) { - this.messageObserver = messageObserver; - } }
