Author: alessio.soldano(a)jboss.com
Date: 2009-01-27 13:43:32 -0500 (Tue, 27 Jan 2009)
New Revision: 9131
Added:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/WebServiceContextEJB.java
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/WebServiceContextFactoryImpl.java
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/WebServiceContextJSE.java
stack/cxf/trunk/modules/server/src/main/resources/jbossws-cxf-server.jar/META-INF/services/org.jboss.wsf.spi.invocation.WebServiceContextFactory
Modified:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/InvokerEJB3.java
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/InvokerJSE.java
Log:
[JBWS-2491] Providing WebServiceContext CXF specific implementations
Modified:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/InvokerEJB3.java
===================================================================
---
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/InvokerEJB3.java 2009-01-27
18:41:22 UTC (rev 9130)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/InvokerEJB3.java 2009-01-27
18:43:32 UTC (rev 9131)
@@ -24,18 +24,24 @@
import javax.xml.ws.WebServiceContext;
import javax.xml.ws.handler.MessageContext;
-import org.jboss.wsf.spi.invocation.WebServiceContextEJB;
+import org.jboss.wsf.spi.SPIProvider;
+import org.jboss.wsf.spi.SPIProviderResolver;
+import org.jboss.wsf.spi.invocation.InvocationType;
+import org.jboss.wsf.spi.invocation.WebServiceContextFactory;
/**
* An XFire invoker for EJB3
*
* @author Thomas.Diesler(a)jboss.org
+ * @author alessio.soldano(a)jboss.com
* @since 21-May-2007
*/
public class InvokerEJB3 extends AbstractInvoker
{
protected WebServiceContext getWebServiceContext(MessageContext msgCtx)
{
- return new WebServiceContextEJB(msgCtx);
+ SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
+ WebServiceContextFactory contextFactory =
spiProvider.getSPI(WebServiceContextFactory.class);
+ return contextFactory.newWebServiceContext(InvocationType.JAXWS_EJB3, msgCtx);
}
}
Modified:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/InvokerJSE.java
===================================================================
---
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/InvokerJSE.java 2009-01-27
18:41:22 UTC (rev 9130)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/InvokerJSE.java 2009-01-27
18:43:32 UTC (rev 9131)
@@ -24,18 +24,24 @@
import javax.xml.ws.WebServiceContext;
import javax.xml.ws.handler.MessageContext;
-import org.jboss.wsf.spi.invocation.WebServiceContextJSE;
+import org.jboss.wsf.spi.SPIProvider;
+import org.jboss.wsf.spi.SPIProviderResolver;
+import org.jboss.wsf.spi.invocation.InvocationType;
+import org.jboss.wsf.spi.invocation.WebServiceContextFactory;
/**
* An CXF invoker for JSE
*
* @author Thomas.Diesler(a)jboss.org
+ * @author alessio.soldano(a)jboss.com
* @since 21-May-2007
*/
public class InvokerJSE extends AbstractInvoker
{
protected WebServiceContext getWebServiceContext(MessageContext msgCtx)
{
- return new WebServiceContextJSE(msgCtx);
+ SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
+ WebServiceContextFactory contextFactory =
spiProvider.getSPI(WebServiceContextFactory.class);
+ return contextFactory.newWebServiceContext(InvocationType.JAXWS_JSE, msgCtx);
}
}
Added:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/WebServiceContextEJB.java
===================================================================
---
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/WebServiceContextEJB.java
(rev 0)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/WebServiceContextEJB.java 2009-01-27
18:43:32 UTC (rev 9131)
@@ -0,0 +1,56 @@
+/*
+ * 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.cxf;
+
+import java.security.Principal;
+
+import javax.ejb.EJBContext;
+import javax.xml.ws.WebServiceContext;
+
+import org.jboss.wsf.spi.invocation.WebServiceContextDelegate;
+
+/**
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 27-Jan-2009
+ */
+public class WebServiceContextEJB extends WebServiceContextDelegate
+{
+ public WebServiceContextEJB(WebServiceContext ctx)
+ {
+ super(ctx);
+ }
+
+ 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/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/WebServiceContextEJB.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/WebServiceContextFactoryImpl.java
===================================================================
---
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/WebServiceContextFactoryImpl.java
(rev 0)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/WebServiceContextFactoryImpl.java 2009-01-27
18:43:32 UTC (rev 9131)
@@ -0,0 +1,49 @@
+/*
+ * 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.cxf;
+
+import javax.xml.ws.handler.MessageContext;
+
+import org.apache.cxf.jaxws.context.WebServiceContextImpl;
+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(new WebServiceContextImpl(messageContext));
+ else
+ context = new WebServiceContextJSE(new WebServiceContextImpl(messageContext));
+
+ return context;
+ }
+}
Property changes on:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/WebServiceContextFactoryImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/WebServiceContextJSE.java
===================================================================
---
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/WebServiceContextJSE.java
(rev 0)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/WebServiceContextJSE.java 2009-01-27
18:43:32 UTC (rev 9131)
@@ -0,0 +1,62 @@
+/*
+ * 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.cxf;
+
+import java.security.Principal;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.xml.ws.WebServiceContext;
+import javax.xml.ws.handler.MessageContext;
+
+import org.jboss.wsf.spi.invocation.WebServiceContextDelegate;
+
+/**
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 27-Jan-2009
+ */
+public class WebServiceContextJSE extends WebServiceContextDelegate
+{
+ private HttpServletRequest httpRequest;
+
+ public WebServiceContextJSE(WebServiceContext ctx)
+ {
+ super(ctx);
+ httpRequest =
(HttpServletRequest)ctx.getMessageContext().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/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/WebServiceContextJSE.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
stack/cxf/trunk/modules/server/src/main/resources/jbossws-cxf-server.jar/META-INF/services/org.jboss.wsf.spi.invocation.WebServiceContextFactory
===================================================================
---
stack/cxf/trunk/modules/server/src/main/resources/jbossws-cxf-server.jar/META-INF/services/org.jboss.wsf.spi.invocation.WebServiceContextFactory
(rev 0)
+++
stack/cxf/trunk/modules/server/src/main/resources/jbossws-cxf-server.jar/META-INF/services/org.jboss.wsf.spi.invocation.WebServiceContextFactory 2009-01-27
18:43:32 UTC (rev 9131)
@@ -0,0 +1 @@
+org.jboss.wsf.stack.cxf.WebServiceContextFactoryImpl
\ No newline at end of file