[CXF-6907] Cache the EPR for performance
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/307cc3d7 Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/307cc3d7 Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/307cc3d7 Branch: refs/heads/master Commit: 307cc3d77312a832cad963ffa7079388b21bd859 Parents: 6e01fcf Author: Daniel Kulp <dk...@apache.org> Authored: Thu Mar 23 14:10:54 2017 -0400 Committer: Daniel Kulp <dk...@apache.org> Committed: Fri Mar 24 10:03:08 2017 -0400 ---------------------------------------------------------------------- .../java/org/apache/cxf/wsn/AbstractEndpoint.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/307cc3d7/services/wsn/wsn-core/src/main/java/org/apache/cxf/wsn/AbstractEndpoint.java ---------------------------------------------------------------------- diff --git a/services/wsn/wsn-core/src/main/java/org/apache/cxf/wsn/AbstractEndpoint.java b/services/wsn/wsn-core/src/main/java/org/apache/cxf/wsn/AbstractEndpoint.java index a613355..beb3a7f 100644 --- a/services/wsn/wsn-core/src/main/java/org/apache/cxf/wsn/AbstractEndpoint.java +++ b/services/wsn/wsn-core/src/main/java/org/apache/cxf/wsn/AbstractEndpoint.java @@ -35,6 +35,8 @@ public abstract class AbstractEndpoint implements EndpointMBean { protected EndpointManager manager; protected Endpoint endpoint; + + protected W3CEndpointReference endpointEpr; public AbstractEndpoint(String name) { this.name = name; @@ -59,19 +61,24 @@ public abstract class AbstractEndpoint implements EndpointMBean { public final URL getWSDLLocation() { return CreatePullPoint.class.getClassLoader().getResource("org/apache/cxf/wsn/wsdl/wsn.wsdl"); } - public void register() throws EndpointRegistrationException { + public synchronized void register() throws EndpointRegistrationException { endpoint = manager.register(getAddress(), this, getWSDLLocation()); + endpointEpr = null; } - public void unregister() throws EndpointRegistrationException { + public synchronized void unregister() throws EndpointRegistrationException { if (endpoint != null) { manager.unregister(endpoint, this); + endpointEpr = null; } } - public W3CEndpointReference getEpr() { + public synchronized W3CEndpointReference getEpr() { if (endpoint != null) { - return manager.getEpr(endpoint); + if (endpointEpr == null) { + endpointEpr = manager.getEpr(endpoint); + } + return endpointEpr; } return null; }