Author: heiko.braun(a)jboss.com
Date: 2007-07-19 10:32:24 -0400 (Thu, 19 Jul 2007)
New Revision: 3952
Added:
branches/hbraun/trunk/integration/spi/src/main/java/org/jboss/wsf/framework/invocation/WebServiceContextInjector.java
branches/hbraun/trunk/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/ExtendableWebServiceContext.java
branches/hbraun/trunk/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/ResourceInjector.java
branches/hbraun/trunk/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/WebServiceContextEJB.java
branches/hbraun/trunk/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/WebServiceContextJSE.java
Removed:
branches/hbraun/trunk/integration/spi/src/main/java/org/jboss/wsf/framework/invocation/WebServiceContextDummy.java
branches/hbraun/trunk/integration/spi/src/main/java/org/jboss/wsf/framework/invocation/WebServiceContextEJB.java
branches/hbraun/trunk/integration/spi/src/main/java/org/jboss/wsf/framework/invocation/WebServiceContextJSE.java
branches/hbraun/trunk/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/AbstractWebServiceContext.java
branches/hbraun/trunk/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/WebServiceContextInjector.java
Modified:
branches/hbraun/trunk/integration/spi/src/main/java/org/jboss/wsf/framework/DefaultSPIProviderResolver.java
branches/hbraun/trunk/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/DefaultInvocationHandlerJAXWS.java
branches/hbraun/trunk/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/InvocationModelFactory.java
Log:
Add WebServiceContext creation to InvocationModelFactory
Modified:
branches/hbraun/trunk/integration/spi/src/main/java/org/jboss/wsf/framework/DefaultSPIProviderResolver.java
===================================================================
---
branches/hbraun/trunk/integration/spi/src/main/java/org/jboss/wsf/framework/DefaultSPIProviderResolver.java 2007-07-19
14:21:55 UTC (rev 3951)
+++
branches/hbraun/trunk/integration/spi/src/main/java/org/jboss/wsf/framework/DefaultSPIProviderResolver.java 2007-07-19
14:32:24 UTC (rev 3952)
@@ -25,6 +25,8 @@
import org.jboss.wsf.spi.SPIProvider;
import org.jboss.wsf.spi.WSFException;
import org.jboss.wsf.spi.invocation.InvocationModelFactory;
+import org.jboss.wsf.spi.invocation.ResourceInjector;
+import org.jboss.wsf.framework.invocation.WebServiceContextInjector;
import org.jboss.wsf.spi.deployment.DeploymentModelFactory;
import org.jboss.wsf.framework.deployment.DeploymentModelFactoryImpl;
import org.jboss.wsf.common.ServiceLoader;
@@ -72,6 +74,10 @@
returnType = (T) factory;
}
+ else if (spiType.equals(ResourceInjector.class))
+ {
+ returnType = (T) new WebServiceContextInjector();
+ }
if(null == returnType)
log.debug("Failed to provide SPI
'"+spiType+"'");
Deleted:
branches/hbraun/trunk/integration/spi/src/main/java/org/jboss/wsf/framework/invocation/WebServiceContextDummy.java
===================================================================
---
branches/hbraun/trunk/integration/spi/src/main/java/org/jboss/wsf/framework/invocation/WebServiceContextDummy.java 2007-07-19
14:21:55 UTC (rev 3951)
+++
branches/hbraun/trunk/integration/spi/src/main/java/org/jboss/wsf/framework/invocation/WebServiceContextDummy.java 2007-07-19
14:32:24 UTC (rev 3952)
@@ -1,63 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt 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.framework.invocation;
-
-// $Id$
-
-import java.security.Principal;
-
-import javax.xml.ws.handler.MessageContext;
-
-import org.jboss.logging.Logger;
-import org.jboss.wsf.spi.invocation.AbstractWebServiceContext;
-
-/**
- * A WebServiceContext implementation that has no access to
- * a security context.
- *
- * @author Thomas.Diesler(a)jboss.org
- * @since 29-Jun-2007
- */
-public class WebServiceContextDummy extends AbstractWebServiceContext
-{
- // provide logging
- private static final Logger log = Logger.getLogger(WebServiceContextDummy.class);
-
- public WebServiceContextDummy(MessageContext msgContext)
- {
- super(msgContext);
- }
-
- @Override
- public Principal getUserPrincipal()
- {
- log.warn("No security context available");
- return null;
- }
-
- @Override
- public boolean isUserInRole(String role)
- {
- log.warn("No security context available");
- return false;
- }
-}
Deleted:
branches/hbraun/trunk/integration/spi/src/main/java/org/jboss/wsf/framework/invocation/WebServiceContextEJB.java
===================================================================
---
branches/hbraun/trunk/integration/spi/src/main/java/org/jboss/wsf/framework/invocation/WebServiceContextEJB.java 2007-07-19
14:21:55 UTC (rev 3951)
+++
branches/hbraun/trunk/integration/spi/src/main/java/org/jboss/wsf/framework/invocation/WebServiceContextEJB.java 2007-07-19
14:32:24 UTC (rev 3952)
@@ -1,60 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt 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.framework.invocation;
-
-// $Id$
-
-import org.jboss.wsf.spi.invocation.AbstractWebServiceContext;
-
-import java.security.Principal;
-
-import javax.ejb.EJBContext;
-import javax.xml.ws.handler.MessageContext;
-
-/**
- * A WebServiceContext implementation that delegates to the EJBContext.
- *
- * @author Thomas.Diesler(a)jboss.org
- * @since 23-Jan-2007
- */
-public class WebServiceContextEJB extends AbstractWebServiceContext
-{
- private EJBContext ejbContext;
-
- public WebServiceContextEJB(MessageContext msgContext, EJBContext ejbContext)
- {
- super(msgContext);
- this.ejbContext = ejbContext;
- }
-
- public Principal getUserPrincipal()
- {
- Principal principal = ejbContext.getCallerPrincipal();
- return principal;
- }
-
- public boolean isUserInRole(String role)
- {
- boolean isUserInRole = ejbContext.isCallerInRole(role);
- return isUserInRole;
- }
-}
Added:
branches/hbraun/trunk/integration/spi/src/main/java/org/jboss/wsf/framework/invocation/WebServiceContextInjector.java
===================================================================
---
branches/hbraun/trunk/integration/spi/src/main/java/org/jboss/wsf/framework/invocation/WebServiceContextInjector.java
(rev 0)
+++
branches/hbraun/trunk/integration/spi/src/main/java/org/jboss/wsf/framework/invocation/WebServiceContextInjector.java 2007-07-19
14:32:24 UTC (rev 3952)
@@ -0,0 +1,83 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.framework.invocation;
+
+// $Id$
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import javax.annotation.Resource;
+import javax.xml.ws.WebServiceContext;
+
+import org.jboss.logging.Logger;
+import org.jboss.wsf.spi.invocation.ResourceInjector;
+
+/**
+ * Inject the JAXWS WebServiceContext
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 04-Jan-2007
+ */
+public class WebServiceContextInjector extends ResourceInjector
+{
+ // provide logging
+ private static Logger log = Logger.getLogger(WebServiceContextInjector.class);
+
+ public void inject(Object instance, WebServiceContext context)
+ {
+ try
+ {
+ // scan fields that are marked with @Resource
+ Field[] fields = instance.getClass().getDeclaredFields();
+ for (Field field : fields)
+ {
+ Class type = field.getType();
+ if (type == WebServiceContext.class &&
field.isAnnotationPresent(Resource.class))
+ {
+ field.setAccessible(true);
+ field.set(instance, context);
+ }
+ }
+
+ // scan methods that are marked with @Resource
+ Method[] methods = instance.getClass().getDeclaredMethods();
+ for (Method method : methods)
+ {
+ Class[] paramTypes = method.getParameterTypes();
+ if (paramTypes.length == 1 && paramTypes[0] ==
WebServiceContext.class && method.isAnnotationPresent(Resource.class))
+ {
+ method.setAccessible(true);
+ method.invoke(instance, new Object[] { context });
+ }
+ }
+ }
+ catch (RuntimeException rte)
+ {
+ throw rte;
+ }
+ catch (Exception ex)
+ {
+ log.warn("Cannot inject WebServiceContext", ex);
+ }
+ }
+}
Property changes on:
branches/hbraun/trunk/integration/spi/src/main/java/org/jboss/wsf/framework/invocation/WebServiceContextInjector.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Deleted:
branches/hbraun/trunk/integration/spi/src/main/java/org/jboss/wsf/framework/invocation/WebServiceContextJSE.java
===================================================================
---
branches/hbraun/trunk/integration/spi/src/main/java/org/jboss/wsf/framework/invocation/WebServiceContextJSE.java 2007-07-19
14:21:55 UTC (rev 3951)
+++
branches/hbraun/trunk/integration/spi/src/main/java/org/jboss/wsf/framework/invocation/WebServiceContextJSE.java 2007-07-19
14:32:24 UTC (rev 3952)
@@ -1,64 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt 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.framework.invocation;
-
-// $Id$
-
-import org.jboss.wsf.spi.invocation.AbstractWebServiceContext;
-
-import java.security.Principal;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.xml.ws.handler.MessageContext;
-
-/**
- * A WebServiceContext implementation that delegates to the HttpServletRequest.
- *
- * @author Thomas.Diesler(a)jboss.org
- * @since 23-Jan-2007
- */
-public class WebServiceContextJSE extends AbstractWebServiceContext
-{
- private HttpServletRequest httpRequest;
-
- public WebServiceContextJSE(MessageContext msgContext)
- {
- super(msgContext);
- httpRequest = (HttpServletRequest)msgContext.get(MessageContext.SERVLET_REQUEST);
- if (httpRequest == null)
- throw new IllegalStateException("Cannot obtain HTTPServletRequest from
message context");
- }
-
- @Override
- public Principal getUserPrincipal()
- {
- Principal principal = httpRequest.getUserPrincipal();
- return principal;
- }
-
- @Override
- public boolean isUserInRole(String role)
- {
- boolean isUserInRole = httpRequest.isUserInRole(role);
- return isUserInRole;
- }
-}
Deleted:
branches/hbraun/trunk/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/AbstractWebServiceContext.java
===================================================================
---
branches/hbraun/trunk/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/AbstractWebServiceContext.java 2007-07-19
14:21:55 UTC (rev 3951)
+++
branches/hbraun/trunk/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/AbstractWebServiceContext.java 2007-07-19
14:32:24 UTC (rev 3952)
@@ -1,69 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt 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.spi.invocation;
-
-import java.security.Principal;
-
-import javax.xml.ws.EndpointReference;
-import javax.xml.ws.WebServiceContext;
-import javax.xml.ws.handler.MessageContext;
-
-import org.jboss.util.NotImplementedException;
-import org.w3c.dom.Element;
-
-/**
- * A WebServiceContext makes it possible for a web service endpoint implementation
- * class to access message context and security information relative to a request
- * being served. Typically a WebServiceContext is injected into an endpoint
implementation
- * class using the Resource annotation.
- *
- * @author Thomas.Diesler(a)jboss.com
- * @since 03-May-2006
- */
-public abstract class AbstractWebServiceContext implements WebServiceContext
-{
- private MessageContext messageContext;
-
- public AbstractWebServiceContext(MessageContext messageContext)
- {
- this.messageContext = messageContext;
- }
-
- public MessageContext getMessageContext()
- {
- return messageContext;
- }
-
- public abstract Principal getUserPrincipal();
-
- public abstract boolean isUserInRole(String role);
-
- public EndpointReference getEndpointReference(Element... referenceParameters)
- {
- throw new NotImplementedException();
- }
-
- public <T extends EndpointReference> T getEndpointReference(Class<T>
clazz, Element... referenceParameters)
- {
- throw new NotImplementedException();
- }
-}
\ No newline at end of file
Modified:
branches/hbraun/trunk/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/DefaultInvocationHandlerJAXWS.java
===================================================================
---
branches/hbraun/trunk/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/DefaultInvocationHandlerJAXWS.java 2007-07-19
14:21:55 UTC (rev 3951)
+++
branches/hbraun/trunk/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/DefaultInvocationHandlerJAXWS.java 2007-07-19
14:32:24 UTC (rev 3952)
@@ -24,6 +24,8 @@
// $Id$
import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.SPIProvider;
+import org.jboss.wsf.spi.SPIProviderResolver;
import javax.xml.ws.WebServiceContext;
import java.lang.reflect.Method;
@@ -76,7 +78,9 @@
WebServiceContext wsContext =
invContext.getAttachment(WebServiceContext.class);
if (wsContext != null)
{
- new WebServiceContextInjector().injectContext(targetBean,
(WebServiceContext)wsContext);
+ SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
+ ResourceInjector injector = spiProvider.getSPI(ResourceInjector.class);
+ injector.inject(targetBean, wsContext);
}
Method method = getImplMethod(targetBean.getClass(), epInv.getJavaMethod());
Added:
branches/hbraun/trunk/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/ExtendableWebServiceContext.java
===================================================================
---
branches/hbraun/trunk/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/ExtendableWebServiceContext.java
(rev 0)
+++
branches/hbraun/trunk/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/ExtendableWebServiceContext.java 2007-07-19
14:32:24 UTC (rev 3952)
@@ -0,0 +1,88 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.spi.invocation;
+
+import java.security.Principal;
+import java.util.Map;
+import java.util.HashMap;
+
+import javax.xml.ws.EndpointReference;
+import javax.xml.ws.WebServiceContext;
+import javax.xml.ws.handler.MessageContext;
+
+import org.jboss.util.NotImplementedException;
+import org.w3c.dom.Element;
+
+/**
+ * A WebServiceContext makes it possible for a web service endpoint implementation
+ * class to access message context and security information relative to a request
+ * being served. Typically a WebServiceContext is injected into an endpoint
implementation
+ * class using the Resource annotation.
+ *
+ * @author Thomas.Diesler(a)jboss.com
+ * @since 03-May-2006
+ */
+public abstract class ExtendableWebServiceContext implements WebServiceContext
+{
+ private MessageContext messageContext;
+
+ private Map<Class, Object> attachments = new HashMap<Class, Object>();
+
+ public ExtendableWebServiceContext(MessageContext messageContext)
+ {
+ this.messageContext = messageContext;
+ }
+
+ public MessageContext getMessageContext()
+ {
+ return messageContext;
+ }
+
+ public abstract Principal getUserPrincipal();
+
+ public abstract boolean isUserInRole(String role);
+
+ public EndpointReference getEndpointReference(Element... referenceParameters)
+ {
+ throw new NotImplementedException();
+ }
+
+ public <T extends EndpointReference> T getEndpointReference(Class<T>
clazz, Element... referenceParameters)
+ {
+ throw new NotImplementedException();
+ }
+
+ public <T> T addAttachment(Class<T> key, Object value)
+ {
+ return (T)attachments.put(key, value);
+ }
+
+ public <T> T getAttachment(Class<T> key)
+ {
+ return (T)attachments.get(key);
+ }
+
+ public <T> T removeAttachment(Class<T> key)
+ {
+ return (T)attachments.get(key);
+ }
+}
\ No newline at end of file
Property changes on:
branches/hbraun/trunk/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/ExtendableWebServiceContext.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified:
branches/hbraun/trunk/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/InvocationModelFactory.java
===================================================================
---
branches/hbraun/trunk/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/InvocationModelFactory.java 2007-07-19
14:21:55 UTC (rev 3951)
+++
branches/hbraun/trunk/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/InvocationModelFactory.java 2007-07-19
14:32:24 UTC (rev 3952)
@@ -23,6 +23,8 @@
import org.jboss.wsf.spi.SPIView;
+import javax.xml.ws.handler.MessageContext;
+
/**
* Creates invocation related artefacts.
*
@@ -33,4 +35,5 @@
{
public abstract InvocationHandler createInvocationHandler(InvocationType type);
public abstract InvocationContext createInvocationContext(InvocationType type);
+ public abstract ExtendableWebServiceContext createWebServiceContext(InvocationType
type, MessageContext messageContext);
}
Added:
branches/hbraun/trunk/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/ResourceInjector.java
===================================================================
---
branches/hbraun/trunk/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/ResourceInjector.java
(rev 0)
+++
branches/hbraun/trunk/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/ResourceInjector.java 2007-07-19
14:32:24 UTC (rev 3952)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.spi.invocation;
+
+import org.jboss.wsf.spi.SPIView;
+
+import javax.xml.ws.WebServiceContext;
+
+/**
+ * @author Heiko.Braun(a)jboss.com
+ * Created: Jul 19, 2007
+ */
+public abstract class ResourceInjector implements SPIView
+{
+ public abstract void inject(Object instance, WebServiceContext context);
+}
Property changes on:
branches/hbraun/trunk/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/ResourceInjector.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
branches/hbraun/trunk/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/WebServiceContextEJB.java
===================================================================
---
branches/hbraun/trunk/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/WebServiceContextEJB.java
(rev 0)
+++
branches/hbraun/trunk/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/WebServiceContextEJB.java 2007-07-19
14:32:24 UTC (rev 3952)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.spi.invocation;
+
+// $Id$
+
+import org.jboss.wsf.spi.invocation.ExtendableWebServiceContext;
+
+import java.security.Principal;
+
+import javax.ejb.EJBContext;
+import javax.xml.ws.handler.MessageContext;
+
+/**
+ * A WebServiceContext implementation that delegates to the EJBContext.
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 23-Jan-2007
+ */
+public class WebServiceContextEJB extends ExtendableWebServiceContext
+{
+ public WebServiceContextEJB(MessageContext msgContext)
+ {
+ super(msgContext);
+ }
+
+ public Principal getUserPrincipal()
+ {
+ EJBContext ejbContext = getAttachment(EJBContext.class);
+ Principal principal = ejbContext.getCallerPrincipal();
+ return principal;
+ }
+
+ public boolean isUserInRole(String role)
+ {
+ EJBContext ejbContext = getAttachment(EJBContext.class);
+ boolean isUserInRole = ejbContext.isCallerInRole(role);
+ return isUserInRole;
+ }
+}
Property changes on:
branches/hbraun/trunk/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/WebServiceContextEJB.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Deleted:
branches/hbraun/trunk/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/WebServiceContextInjector.java
===================================================================
---
branches/hbraun/trunk/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/WebServiceContextInjector.java 2007-07-19
14:21:55 UTC (rev 3951)
+++
branches/hbraun/trunk/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/WebServiceContextInjector.java 2007-07-19
14:32:24 UTC (rev 3952)
@@ -1,86 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt 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.spi.invocation;
-
-// $Id$
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-
-import javax.annotation.Resource;
-import javax.xml.ws.WebServiceContext;
-
-import org.jboss.logging.Logger;
-
-/**
- * Inject the JAXWS WebServiceContext
- *
- * @author Thomas.Diesler(a)jboss.org
- * @since 04-Jan-2007
- */
-public class WebServiceContextInjector
-{
- // provide logging
- private static Logger log = Logger.getLogger(WebServiceContextInjector.class);
-
- WebServiceContextInjector()
- {
- }
-
- public void injectContext(Object epInstance, WebServiceContext wsContext)
- {
- try
- {
- // scan fields that are marked with @Resource
- Field[] fields = epInstance.getClass().getDeclaredFields();
- for (Field field : fields)
- {
- Class type = field.getType();
- if (type == WebServiceContext.class &&
field.isAnnotationPresent(Resource.class))
- {
- field.setAccessible(true);
- field.set(epInstance, wsContext);
- }
- }
-
- // scan methods that are marked with @Resource
- Method[] methods = epInstance.getClass().getDeclaredMethods();
- for (Method method : methods)
- {
- Class[] paramTypes = method.getParameterTypes();
- if (paramTypes.length == 1 && paramTypes[0] ==
WebServiceContext.class && method.isAnnotationPresent(Resource.class))
- {
- method.setAccessible(true);
- method.invoke(epInstance, new Object[] { wsContext });
- }
- }
- }
- catch (RuntimeException rte)
- {
- throw rte;
- }
- catch (Exception ex)
- {
- log.warn("Cannot inject WebServiceContext", ex);
- }
- }
-}
Added:
branches/hbraun/trunk/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/WebServiceContextJSE.java
===================================================================
---
branches/hbraun/trunk/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/WebServiceContextJSE.java
(rev 0)
+++
branches/hbraun/trunk/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/WebServiceContextJSE.java 2007-07-19
14:32:24 UTC (rev 3952)
@@ -0,0 +1,64 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.spi.invocation;
+
+// $Id$
+
+import org.jboss.wsf.spi.invocation.ExtendableWebServiceContext;
+
+import java.security.Principal;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.xml.ws.handler.MessageContext;
+
+/**
+ * A WebServiceContext implementation that delegates to the HttpServletRequest.
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 23-Jan-2007
+ */
+public class WebServiceContextJSE extends ExtendableWebServiceContext
+{
+ private HttpServletRequest httpRequest;
+
+ public WebServiceContextJSE(MessageContext msgContext)
+ {
+ super(msgContext);
+ httpRequest = (HttpServletRequest)msgContext.get(MessageContext.SERVLET_REQUEST);
+ if (httpRequest == null)
+ throw new IllegalStateException("Cannot obtain HTTPServletRequest from
message context");
+ }
+
+ @Override
+ public Principal getUserPrincipal()
+ {
+ Principal principal = httpRequest.getUserPrincipal();
+ return principal;
+ }
+
+ @Override
+ public boolean isUserInRole(String role)
+ {
+ boolean isUserInRole = httpRequest.isUserInRole(role);
+ return isUserInRole;
+ }
+}
Property changes on:
branches/hbraun/trunk/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/WebServiceContextJSE.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF