Author: richard.opalka(a)jboss.com
Date: 2010-12-14 06:19:58 -0500 (Tue, 14 Dec 2010)
New Revision: 13487
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/server/ServiceEndpointInvoker.java
Log:
[JBWS-3184] refactoring endpoint instantiation out of invocation handler to allow proper
synchronization
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/server/ServiceEndpointInvoker.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/server/ServiceEndpointInvoker.java 2010-12-14
11:15:58 UTC (rev 13486)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/server/ServiceEndpointInvoker.java 2010-12-14
11:19:58 UTC (rev 13487)
@@ -246,14 +246,6 @@
Throwable targetEx = th.getTargetException();
throw (targetEx instanceof Exception ? (Exception)targetEx : new
UndeclaredThrowableException(targetEx));
}
- finally
- {
- // JBWS-2486
- if (endpoint.getAttachment(Object.class) == null)
- {
- endpoint.addAttachment(Object.class,
inv.getInvocationContext().getTargetBean());
- }
- }
// Handler processing might have replaced the endpoint invocation
sepInv =
inv.getInvocationContext().getAttachment(EndpointInvocation.class);
@@ -368,12 +360,36 @@
Invocation wsInv = new DelegatingInvocation();
wsInv.setInvocationContext(invContext);
wsInv.setJavaMethod(getImplMethod(endpoint, epInv));
- // JBWS-2486, see endpoint attachment initialization above
- wsInv.getInvocationContext().setTargetBean(endpoint.getAttachment(Object.class));
+ wsInv.getInvocationContext().setTargetBean(getEndpointInstance());
return wsInv;
}
+
+ // JBWS-2486 - Only one webservice endpoint instance can be created!
+ private Object getEndpointInstance()
+ {
+ synchronized(endpoint)
+ {
+ Object endpointImpl = endpoint.getAttachment(Object.class);
+ if (endpointImpl == null)
+ {
+ try
+ {
+ // create endpoint instance
+ final Class<?> endpointImplClass = endpoint.getTargetBeanClass();
+ endpointImpl = endpointImplClass.newInstance();
+ endpoint.addAttachment(Object.class, endpointImpl);
+ }
+ catch (Exception ex)
+ {
+ throw new IllegalStateException("Cannot create endpoint instance:
", ex);
+ }
+ }
+ return endpointImpl;
+ }
+ }
+
protected Method getImplMethod(Endpoint endpoint, EndpointInvocation sepInv) throws
ClassNotFoundException, NoSuchMethodException
{
Class implClass = endpoint.getTargetBeanClass();
Show replies by date