Cache the EPR for performance
@@ -36,6 +36,8 @@ public abstract class AbstractEndpoint implements EndpointMBean {
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;
}
