Author: alessio.soldano(a)jboss.com
Date: 2009-01-27 13:41:22 -0500 (Tue, 27 Jan 2009)
New Revision: 9130
Added:
stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/NativeWebServiceContext.java
stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/WebServiceContextEJB.java
stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/WebServiceContextFactoryImpl.java
stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/WebServiceContextJSE.java
stack/native/trunk/modules/core/src/main/resources/META-INF/services/org.jboss.wsf.spi.invocation.WebServiceContextFactory
Log:
[JBWS-2491] Adding WebServiceContext Native specific implementations
Added:
stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/NativeWebServiceContext.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/NativeWebServiceContext.java
(rev 0)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/NativeWebServiceContext.java 2009-01-27
18:41:22 UTC (rev 9130)
@@ -0,0 +1,78 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.stack.jbws;
+
+import javax.xml.ws.EndpointReference;
+import javax.xml.ws.WebServiceException;
+import javax.xml.ws.handler.MessageContext;
+import javax.xml.ws.http.HTTPBinding;
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+import javax.xml.ws.wsaddressing.W3CEndpointReferenceBuilder;
+
+import org.jboss.ws.core.CommonMessageContext;
+import org.jboss.ws.core.jaxws.binding.EndpointReferenceUtil;
+import org.jboss.ws.metadata.umdm.EndpointMetaData;
+import org.jboss.wsf.spi.invocation.ExtensibleWebServiceContext;
+import org.w3c.dom.Element;
+
+/**
+ * An ExtensibileWebServiceContext implementing the getEndpointReference jaxws 2.1
methods
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 27-Jan-2009
+ */
+public abstract class NativeWebServiceContext extends ExtensibleWebServiceContext
+{
+ public NativeWebServiceContext(MessageContext messageContext)
+ {
+ super(messageContext);
+ }
+
+ public EndpointReference getEndpointReference(Element... referenceParameters)
+ {
+ return getEndpointReference(W3CEndpointReference.class, referenceParameters);
+ }
+
+ public <T extends EndpointReference> T getEndpointReference(Class<T>
clazz, Element... referenceParameters)
+ {
+ EndpointMetaData epMetaData =
((CommonMessageContext)getMessageContext()).getEndpointMetaData();
+ if (epMetaData == null)
+ {
+ throw new WebServiceException("Cannot get EndpointMetaData!");
+ }
+ if (HTTPBinding.HTTP_BINDING.equals(epMetaData.getBindingId()))
+ {
+ throw new UnsupportedOperationException("Cannot get epr when using the
XML/HTTP binding");
+ }
+ W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder();
+ String address = epMetaData.getEndpointAddress();
+ builder.address(address);
+ builder.wsdlDocumentLocation(address.toString() + "?wsdl");
+ //TODO set other parameters in the builder
+ if (referenceParameters != null &&
W3CEndpointReference.class.getName().equals(clazz.getName()))
+ {
+ for (Element el : referenceParameters)
+ builder.referenceParameter(el);
+ }
+ return EndpointReferenceUtil.transform(clazz, builder.build());
+ }
+}
Property changes on:
stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/NativeWebServiceContext.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/WebServiceContextEJB.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/WebServiceContextEJB.java
(rev 0)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/WebServiceContextEJB.java 2009-01-27
18:41:22 UTC (rev 9130)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.stack.jbws;
+
+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 NativeWebServiceContext
+{
+ 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:
stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/WebServiceContextEJB.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/WebServiceContextFactoryImpl.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/WebServiceContextFactoryImpl.java
(rev 0)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/WebServiceContextFactoryImpl.java 2009-01-27
18:41:22 UTC (rev 9130)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.stack.jbws;
+
+import javax.xml.ws.handler.MessageContext;
+
+import org.jboss.wsf.spi.invocation.ExtensibleWebServiceContext;
+import org.jboss.wsf.spi.invocation.InvocationType;
+import org.jboss.wsf.spi.invocation.WebServiceContextFactory;
+
+/**
+ *
+ * @author alessio.soldano(a)jboss.com
+ *
+ */
+public class WebServiceContextFactoryImpl extends WebServiceContextFactory
+{
+ public ExtensibleWebServiceContext newWebServiceContext(InvocationType type,
MessageContext messageContext)
+ {
+ ExtensibleWebServiceContext context = null;
+
+ if(type.toString().indexOf("EJB")!=-1 ||
type.toString().indexOf("MDB")!=-1)
+ context = new WebServiceContextEJB(messageContext);
+ else
+ context = new WebServiceContextJSE(messageContext);
+
+ return context;
+ }
+}
Property changes on:
stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/WebServiceContextFactoryImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/WebServiceContextJSE.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/WebServiceContextJSE.java
(rev 0)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/WebServiceContextJSE.java 2009-01-27
18:41:22 UTC (rev 9130)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.stack.jbws;
+
+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 NativeWebServiceContext
+{
+ 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:
stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/WebServiceContextJSE.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
stack/native/trunk/modules/core/src/main/resources/META-INF/services/org.jboss.wsf.spi.invocation.WebServiceContextFactory
===================================================================
---
stack/native/trunk/modules/core/src/main/resources/META-INF/services/org.jboss.wsf.spi.invocation.WebServiceContextFactory
(rev 0)
+++
stack/native/trunk/modules/core/src/main/resources/META-INF/services/org.jboss.wsf.spi.invocation.WebServiceContextFactory 2009-01-27
18:41:22 UTC (rev 9130)
@@ -0,0 +1 @@
+org.jboss.wsf.stack.jbws.WebServiceContextFactoryImpl
\ No newline at end of file