JBossWS SVN: r13250 - in common/trunk/src/main/java/org/jboss/wsf/common: invocation and 1 other directory.
by jbossws-commits@lists.jboss.org
Author: richard.opalka(a)jboss.com
Date: 2010-11-10 08:55:06 -0500 (Wed, 10 Nov 2010)
New Revision: 13250
Added:
common/trunk/src/main/java/org/jboss/wsf/common/injection/ThreadLocalAwareWebServiceContext.java
Modified:
common/trunk/src/main/java/org/jboss/wsf/common/invocation/InvocationHandlerJAXWS.java
Log:
[JBWS-3156] extracting ThreadLocalAwareWebServiceContext to be public serializable class
Added: common/trunk/src/main/java/org/jboss/wsf/common/injection/ThreadLocalAwareWebServiceContext.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/common/injection/ThreadLocalAwareWebServiceContext.java (rev 0)
+++ common/trunk/src/main/java/org/jboss/wsf/common/injection/ThreadLocalAwareWebServiceContext.java 2010-11-10 13:55:06 UTC (rev 13250)
@@ -0,0 +1,88 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.wsf.common.injection;
+
+import java.io.Serializable;
+import java.security.Principal;
+
+import javax.xml.ws.EndpointReference;
+import javax.xml.ws.WebServiceContext;
+import javax.xml.ws.handler.MessageContext;
+
+import org.w3c.dom.Element;
+
+/**
+ * Web service context implementation that is thread local aware as required by JAX-WS spec.
+ *
+ * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
+ */
+public final class ThreadLocalAwareWebServiceContext implements WebServiceContext, Serializable
+{
+
+ private static final long serialVersionUID = 126557512266764152L;
+
+ private static final transient ThreadLocalAwareWebServiceContext SINGLETON = new ThreadLocalAwareWebServiceContext();
+
+ private final transient ThreadLocal<WebServiceContext> contexts = new InheritableThreadLocal<WebServiceContext>();
+
+ public static ThreadLocalAwareWebServiceContext getInstance()
+ {
+ return SINGLETON;
+ }
+
+ public void setMessageContext(final WebServiceContext ctx)
+ {
+ this.contexts.set(ctx);
+ }
+
+ public EndpointReference getEndpointReference(final Element... referenceParameters)
+ {
+ final WebServiceContext delegee = this.contexts.get();
+ return delegee == null ? null : delegee.getEndpointReference(referenceParameters);
+ }
+
+ public <T extends EndpointReference> T getEndpointReference(final Class<T> clazz,
+ final Element... referenceParameters)
+ {
+ final WebServiceContext delegee = this.contexts.get();
+ return delegee == null ? null : delegee.getEndpointReference(clazz, referenceParameters);
+ }
+
+ public MessageContext getMessageContext()
+ {
+ final WebServiceContext delegee = this.contexts.get();
+ return delegee == null ? null : delegee.getMessageContext();
+ }
+
+ public Principal getUserPrincipal()
+ {
+ final WebServiceContext delegee = this.contexts.get();
+ return delegee == null ? null : delegee.getUserPrincipal();
+ }
+
+ public boolean isUserInRole(String role)
+ {
+ final WebServiceContext delegee = this.contexts.get();
+ return delegee == null ? false : delegee.isUserInRole(role);
+ }
+
+}
Modified: common/trunk/src/main/java/org/jboss/wsf/common/invocation/InvocationHandlerJAXWS.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/common/invocation/InvocationHandlerJAXWS.java 2010-11-10 13:36:59 UTC (rev 13249)
+++ common/trunk/src/main/java/org/jboss/wsf/common/invocation/InvocationHandlerJAXWS.java 2010-11-10 13:55:06 UTC (rev 13250)
@@ -21,17 +21,14 @@
*/
package org.jboss.wsf.common.invocation;
-import java.security.Principal;
-
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
-import javax.xml.ws.EndpointReference;
import javax.xml.ws.WebServiceContext;
-import javax.xml.ws.handler.MessageContext;
import org.jboss.wsf.common.injection.InjectionHelper;
import org.jboss.wsf.common.injection.PreDestroyHolder;
+import org.jboss.wsf.common.injection.ThreadLocalAwareWebServiceContext;
import org.jboss.wsf.spi.SPIProvider;
import org.jboss.wsf.spi.SPIProviderResolver;
import org.jboss.wsf.spi.deployment.Endpoint;
@@ -40,7 +37,6 @@
import org.jboss.wsf.spi.invocation.ResourceInjector;
import org.jboss.wsf.spi.invocation.ResourceInjectorFactory;
import org.jboss.wsf.spi.metadata.injection.InjectionsMetaData;
-import org.w3c.dom.Element;
/**
* Handles invocations on JAXWS endpoints.
@@ -114,7 +110,7 @@
public Context getJNDIContext(final Endpoint ep) throws NamingException
{
- return (Context)new InitialContext().lookup(POJO_JNDI_PREFIX);
+ return (Context) new InitialContext().lookup(POJO_JNDI_PREFIX);
}
/**
@@ -143,50 +139,4 @@
return invocationContext.getTargetBean();
}
- private static final class ThreadLocalAwareWebServiceContext implements WebServiceContext
- {
- private static final ThreadLocalAwareWebServiceContext SINGLETON = new ThreadLocalAwareWebServiceContext();
- private final ThreadLocal<WebServiceContext> contexts = new InheritableThreadLocal<WebServiceContext>();
-
- private static ThreadLocalAwareWebServiceContext getInstance()
- {
- return SINGLETON;
- }
-
- private void setMessageContext(final WebServiceContext ctx)
- {
- this.contexts.set(ctx);
- }
-
- public EndpointReference getEndpointReference(Element... referenceParameters)
- {
- final WebServiceContext delegee = this.contexts.get();
- return delegee == null ? null : delegee.getEndpointReference(referenceParameters);
- }
-
- public <T extends EndpointReference> T getEndpointReference(Class<T> clazz, Element... referenceParameters)
- {
- final WebServiceContext delegee = this.contexts.get();
- return delegee == null ? null : delegee.getEndpointReference(clazz, referenceParameters);
- }
-
- public MessageContext getMessageContext()
- {
- final WebServiceContext delegee = this.contexts.get();
- return delegee == null ? null : delegee.getMessageContext();
- }
-
- public Principal getUserPrincipal()
- {
- final WebServiceContext delegee = this.contexts.get();
- return delegee == null ? null : delegee.getUserPrincipal();
- }
-
- public boolean isUserInRole(String role)
- {
- final WebServiceContext delegee = this.contexts.get();
- return delegee == null ? false : delegee.isUserInRole(role);
- }
- }
-
}