[jboss-cvs] JBossAS SVN: r91827 - in branches/ropalka-jbossws320-jboss520: component-matrix and 23 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Jul 30 08:23:04 EDT 2009


Author: richard.opalka at jboss.com
Date: 2009-07-30 08:23:04 -0400 (Thu, 30 Jul 2009)
New Revision: 91827

Added:
   branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/
   branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/
   branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/config/
   branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/config/ServerConfigImpl.java
   branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/deployers/
   branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/deployers/WSDeployersFactory.java
   branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/deployers/WSDeploymentAspectDeployer.java
   branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/deployers/WSDeploymentDeployer.java
   branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/deployers/WSDescriptorDeployer.java
   branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/deployers/WSEJBAdapterDeployer.java
   branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/deployers/WSTypeDeployer.java
   branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/deployers/WSVirtualFileFilter.java
   branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/injection/
   branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/injection/EJBBeanReferenceResolver.java
   branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/injection/InjectionMetaDataDeploymentAspect.java
   branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/invocation/
   branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/invocation/AbstractInvocationHandler.java
   branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerEJB21.java
   branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerEJB3.java
   branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerFactoryImpl.java
   branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerJAXRPC.java
   branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerJAXWS.java
   branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerJSE.java
   branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerMDB21.java
   branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerMDB3.java
   branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/invocation/SecurityAdapterFactoryImpl.java
   branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/invocation/SecurityAdaptorImpl.java
   branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/invocation/ServiceEndpointInterceptor.java
   branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/metadata/
   branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/metadata/ContainerMetaDataDeploymentAspect.java
   branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/metadata/EJB21MetaDataBuilder.java
   branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/metadata/EJB3MetaDataBuilder.java
   branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/metadata/JSEMetaDataBuilder.java
   branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/security/
   branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/security/JACCPermissionsDeploymentAspect.java
   branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/tomcat/
   branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/tomcat/SecurityHandler.java
   branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/tomcat/SecurityHandlerEJB21.java
   branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/tomcat/SecurityHandlerEJB3.java
   branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/tomcat/WebAppGeneratorDeploymentAspect.java
   branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/tomcat/WebMetaDataModifier.java
   branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/tomcat/WebMetaDataModifyingDeploymentAspect.java
   branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/util/
   branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/util/ASHelper.java
   branches/ropalka-jbossws320-jboss520/webservices/src/resources/jbossws-jboss.deployer/
   branches/ropalka-jbossws320-jboss520/webservices/src/resources/jbossws-jboss.deployer/META-INF/
   branches/ropalka-jbossws320-jboss520/webservices/src/resources/jbossws-jboss.deployer/META-INF/stack-agnostic-jboss-beans.xml
   branches/ropalka-jbossws320-jboss520/webservices/src/resources/jbossws-jboss.jar/
   branches/ropalka-jbossws320-jboss520/webservices/src/resources/jbossws-jboss.jar/META-INF/
   branches/ropalka-jbossws320-jboss520/webservices/src/resources/jbossws-jboss.jar/META-INF/services/
   branches/ropalka-jbossws320-jboss520/webservices/src/resources/jbossws-jboss.jar/META-INF/services/org.jboss.wsf.spi.deployment.DeploymentModelFactory
   branches/ropalka-jbossws320-jboss520/webservices/src/resources/jbossws-jboss.jar/META-INF/services/org.jboss.wsf.spi.invocation.InvocationHandlerFactory
   branches/ropalka-jbossws320-jboss520/webservices/src/resources/jbossws-jboss.jar/META-INF/services/org.jboss.wsf.spi.invocation.SecurityAdaptorFactory
   branches/ropalka-jbossws320-jboss520/webservices/src/resources/jbossws-jboss.jar/META-INF/services/org.jboss.wsf.spi.management.ServerConfigFactory
Removed:
   branches/ropalka-jbossws320-jboss520/testsuite/src/main/org/jboss/test/webservice/endpoint/
   branches/ropalka-jbossws320-jboss520/testsuite/src/resources/webservice/endpoint/
   branches/ropalka-jbossws320-jboss520/webservices/src/etc/component-info.xml
   branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/wsf/
   branches/ropalka-jbossws320-jboss520/webservices/src/resources/jbossws-jboss50.deployer/
   branches/ropalka-jbossws320-jboss520/webservices/src/resources/jbossws-jboss50.jar/
Modified:
   branches/ropalka-jbossws320-jboss520/build/build-distr.xml
   branches/ropalka-jbossws320-jboss520/component-matrix/pom.xml
   branches/ropalka-jbossws320-jboss520/testsuite/imports/sections/webservice.xml
   branches/ropalka-jbossws320-jboss520/webservices/build.xml
   branches/ropalka-jbossws320-jboss520/webservices/pom.xml
   branches/ropalka-jbossws320-jboss520/webservices/src/scripts/assembly-resources.xml
Log:
[JBWS-2332][JBWS-2382][JBWS-2702] refactoring

Modified: branches/ropalka-jbossws320-jboss520/build/build-distr.xml
===================================================================
--- branches/ropalka-jbossws320-jboss520/build/build-distr.xml	2009-07-30 11:11:40 UTC (rev 91826)
+++ branches/ropalka-jbossws320-jboss520/build/build-distr.xml	2009-07-30 12:23:04 UTC (rev 91827)
@@ -1678,6 +1678,9 @@
       <fileset dir="${org.codehaus.jettison.lib}">
         <include name="jettison.jar"/>
       </fileset>
+      <fileset dir="${org.jboss.netty.lib}">
+        <include name="netty.jar"/>
+      </fileset>
       <fileset dir="${sun.jaxb.lib}">
         <include name="jaxb-api.jar"/>
       </fileset>
@@ -1741,6 +1744,9 @@
       <fileset dir="${org.codehaus.jettison.lib}">
         <include name="jettison.jar"/>
       </fileset>
+      <fileset dir="${org.jboss.netty.lib}">
+        <include name="netty.jar"/>
+      </fileset>
       <fileset dir="${wscommons.policy.lib}">
         <include name="policy.jar"/>
       </fileset>

Modified: branches/ropalka-jbossws320-jboss520/component-matrix/pom.xml
===================================================================
--- branches/ropalka-jbossws320-jboss520/component-matrix/pom.xml	2009-07-30 11:11:40 UTC (rev 91826)
+++ branches/ropalka-jbossws320-jboss520/component-matrix/pom.xml	2009-07-30 12:23:04 UTC (rev 91827)
@@ -35,10 +35,10 @@
     <version.javax.faces>1.2_12</version.javax.faces>
     <version.jboss.jaxr>2.0.0</version.jboss.jaxr>
     <version.jboss.jbossts>4.6.1.GA</version.jboss.jbossts>
-    <version.jboss.jbossws-common>1.2.0.Beta1</version.jboss.jbossws-common>
-    <version.jboss.jbossws-framework>3.2.0.Beta1</version.jboss.jbossws-framework>
-    <version.jboss.jbossws-spi>1.2.0.Beta1</version.jboss.jbossws-spi>
-    <version.jboss.jbossws>3.2.0.Beta1</version.jboss.jbossws>
+    <version.jboss.jbossws-common>1.2.0.Beta2</version.jboss.jbossws-common>
+    <version.jboss.jbossws-framework>3.2.0.Beta2</version.jboss.jbossws-framework>
+    <version.jboss.jbossws-spi>1.2.0.Beta2</version.jboss.jbossws-spi>
+    <version.jboss.jbossws>3.2.0.Beta2</version.jboss.jbossws>
     <version.jboss.jms-integration-tests>1.0.1.GA</version.jboss.jms-integration-tests>
     <version.jboss.messaging>1.4.3.GA</version.jboss.messaging>
     <version.jboss.web>2.1.3.GA</version.jboss.web>

Modified: branches/ropalka-jbossws320-jboss520/testsuite/imports/sections/webservice.xml
===================================================================
--- branches/ropalka-jbossws320-jboss520/testsuite/imports/sections/webservice.xml	2009-07-30 11:11:40 UTC (rev 91826)
+++ branches/ropalka-jbossws320-jboss520/testsuite/imports/sections/webservice.xml	2009-07-30 12:23:04 UTC (rev 91827)
@@ -118,17 +118,6 @@
         <include name="jboss-app.xml"/>
       </metainf>
     </ear>
-    
-    <!-- jaxws-endpoint-servlet -->
-    <war warfile="${build.lib}/jaxws-endpoint-servlet.war" webxml="${build.resources}/webservice/endpoint/WEB-INF/web.xml">
-      <classes dir="${build.classes}">
-        <include name="org/jboss/test/webservice/endpoint/EndpointServlet.class"/>
-        <include name="org/jboss/test/webservice/endpoint/EndpointBean.class"/>
-        <include name="org/jboss/test/webservice/endpoint/EndpointInterface.class"/>
-      </classes>
-      <webinf dir="${build.resources}/webservice/endpoint/WEB-INF">
-        <include name="wsdl/**"/>
-      </webinf>
-    </war>
+
   </target>
 </project>
\ No newline at end of file

Modified: branches/ropalka-jbossws320-jboss520/webservices/build.xml
===================================================================
--- branches/ropalka-jbossws320-jboss520/webservices/build.xml	2009-07-30 11:11:40 UTC (rev 91826)
+++ branches/ropalka-jbossws320-jboss520/webservices/build.xml	2009-07-30 12:23:04 UTC (rev 91827)
@@ -145,7 +145,7 @@
     <!-- Build jbossws-jboss50.jar -->
     <jar jarfile="${build.lib}/jbossws-jboss50.jar" manifest="${build.etc}/default.mf">
       <fileset dir="${build.classes}" />
-      <metainf dir="${build.resources}/jbossws-jboss50.jar/META-INF"/>
+      <metainf dir="${build.resources}/jbossws-jboss.jar/META-INF"/>
     </jar>
 
     <!-- Build jbossws.deployer -->
@@ -159,8 +159,8 @@
       <fileset dir="${org.jboss.ws.lib}">
         <include name="jbossws-framework.jar"/>
       </fileset>
-      <fileset dir="${build.resources}/jbossws-jboss50.deployer">
-        <include name="META-INF/jbossws-deployer-jboss-beans.xml"/>
+      <fileset dir="${build.resources}/jbossws-jboss.deployer">
+        <include name="META-INF/stack-agnostic-jboss-beans.xml"/>
       </fileset>
     </zip>
     

Modified: branches/ropalka-jbossws320-jboss520/webservices/pom.xml
===================================================================
--- branches/ropalka-jbossws320-jboss520/webservices/pom.xml	2009-07-30 11:11:40 UTC (rev 91826)
+++ branches/ropalka-jbossws320-jboss520/webservices/pom.xml	2009-07-30 12:23:04 UTC (rev 91827)
@@ -131,7 +131,7 @@
     <sourceDirectory>src/main</sourceDirectory>
     <resources>
       <resource>
-        <directory>src/resources/jbossws-jboss50.jar</directory>
+        <directory>src/resources/jbossws-jboss.jar</directory>
       </resource>
     </resources>
     <plugins>

Deleted: branches/ropalka-jbossws320-jboss520/webservices/src/etc/component-info.xml
===================================================================
--- branches/ropalka-jbossws320-jboss520/webservices/src/etc/component-info.xml	2009-07-30 11:11:40 UTC (rev 91826)
+++ branches/ropalka-jbossws320-jboss520/webservices/src/etc/component-info.xml	2009-07-30 12:23:04 UTC (rev 91827)
@@ -1,26 +0,0 @@
-<project name="jboss/jbossws-jboss50">
-  
-  <component id="jboss/jbossws-jboss50"
-    description="JBossWS container integration layer" 
-    version="@repository.id@"
-    licenseType="lgpl">
-    
-    <artifact id="jbossws-jboss50.jar"/>
-    <artifact id="jbossws-jboss50-container.jar"/>
-    <artifact id="jbossws-jboss50-resources.zip"/>
-    <artifact id="jbossws-jboss50-src.zip"/>
-    
-    <import componentref="jboss/jbossws-common">
-      <compatible version="@jbossws-common@"/>
-    </import>
-    <import componentref="jboss/jbossws-spi">
-      <compatible version="@jbossws-spi@"/>
-    </import>
-    
-    <export>
-      <include input="jbossws-jboss50.jar"/>
-    </export>
-    
-  </component>
-  
-</project>

Added: branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/config/ServerConfigImpl.java
===================================================================
--- branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/config/ServerConfigImpl.java	                        (rev 0)
+++ branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/config/ServerConfigImpl.java	2009-07-30 12:23:04 UTC (rev 91827)
@@ -0,0 +1,97 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.webservices.integration.config;
+
+import java.io.File;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+import javax.management.JMException;
+import javax.management.ObjectName;
+
+import org.jboss.wsf.common.management.AbstractServerConfig;
+import org.jboss.wsf.common.management.AbstractServerConfigMBean;
+
+/**
+ * A ServerConfig for AS > 5.1.0 (5.1.0 excluded)
+ * 
+ * @author alessio.soldano at jboss.com
+ * @author ALR
+ *
+ */
+public class ServerConfigImpl extends AbstractServerConfig implements AbstractServerConfigMBean
+{
+
+   public File getServerTempDir()
+   {
+      return this.getDirFromServerConfig("ServerTempLocation");
+   }
+   
+   public File getHomeDir()
+   {
+      return this.getDirFromServerConfig("JBossHome");
+   }
+
+   public File getServerDataDir()
+   {
+      return this.getDirFromServerConfig("ServerDataLocation");
+   }
+   
+   /**
+    * Obtains the specified attribute from the server configuration,
+    * represented as a {@link File}.
+    *  
+    * @param attributeName
+    * @return
+    * @author ALR
+    */
+   protected File getDirFromServerConfig(final String attributeName)
+   {
+      // Define the ON to invoke upon
+      final ObjectName on = OBJECT_NAME_SERVER_CONFIG;
+
+      // Get the URL location
+      URL location = null;
+      try
+      {
+         location = (URL) getMbeanServer().getAttribute(on, attributeName);
+      }
+      catch (final JMException e)
+      {
+         throw new RuntimeException("Could not obtain attribute " + attributeName + " from " + on, e);
+      }
+
+      // Represent as a File
+      File dir = null;
+      try
+      {
+         dir = new File(location.toURI());
+      }
+      catch (final URISyntaxException urise)
+      {
+         throw new RuntimeException("Could not desired directory from URL: " + location, urise);
+      }
+
+      // Return
+      return dir;
+   }
+}

Added: branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/deployers/WSDeployersFactory.java
===================================================================
--- branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/deployers/WSDeployersFactory.java	                        (rev 0)
+++ branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/deployers/WSDeployersFactory.java	2009-07-30 12:23:04 UTC (rev 91827)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.webservices.integration.deployers;
+
+import org.jboss.deployers.plugins.deployers.DeployersImpl;
+import org.jboss.wsf.spi.deployment.DeploymentAspect;
+
+/**
+ * WSDeploymentAspectDeployer factory.
+ *
+ * @author <a href="ropalka at redhat.com">Richard Opalka</a>
+ */
+public final class WSDeployersFactory
+{
+   
+   /** Real deployers registry. */
+   private final DeployersImpl delegee;
+   
+   /**
+    * Constructor.
+    * 
+    * @param realDeployers real deployers registry
+    */
+   public WSDeployersFactory( final DeployersImpl realDeployers )
+   {
+      this.delegee = realDeployers;
+   }
+
+   /**
+    * MC incallback method. It will be called each time DeploymentAspect bean will reach INSTALLED state.
+    * 
+    * @param aspect to create real WS deployer for
+    */
+   public void newDeployer( final DeploymentAspect aspect )
+   {
+      this.delegee.addDeployer( new WSDeploymentAspectDeployer( aspect ) );
+   }
+
+}

Added: branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/deployers/WSDeploymentAspectDeployer.java
===================================================================
--- branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/deployers/WSDeploymentAspectDeployer.java	                        (rev 0)
+++ branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/deployers/WSDeploymentAspectDeployer.java	2009-07-30 12:23:04 UTC (rev 91827)
@@ -0,0 +1,139 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.webservices.integration.deployers;
+
+import java.util.Set;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.metadata.web.jboss.JBossWebMetaData;
+import org.jboss.webservices.integration.util.ASHelper;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.deployment.DeploymentAspect;
+
+/**
+ * A deployer that delegates to JBossWS deployment aspect.
+ * 
+ * @author <a href="ropalka at redhat.com">Richard Opalka</a>
+ */
+public final class WSDeploymentAspectDeployer extends AbstractRealDeployer
+{
+
+   /** JBossWS specific inputs/outputs prefix. */
+   private static final String JBOSSWS_ATTACHMENT_PREFIX = "jbossws.";
+   /** JBossWS specific metadata. */
+   private static final String JBOSSWS_METADATA = WSDeploymentAspectDeployer.JBOSSWS_ATTACHMENT_PREFIX + "metadata";
+   /** Delegee. */
+   private final DeploymentAspect aspect;
+
+   /**
+    * Constructor.
+    * 
+    * @param aspect deployment aspect
+    */
+   public WSDeploymentAspectDeployer( final DeploymentAspect aspect )
+   {
+      super();
+      
+      // inputs
+      this.addInput( JBossWebMetaData.class );
+      this.addInput( Deployment.class );
+      if ( aspect.isLast() )
+      {
+         this.addInput( WSDeploymentAspectDeployer.JBOSSWS_METADATA );
+      }
+      
+      // propagate DA requirements and map them to deployer inputs
+      final Set< String > inputs = aspect.getRequiresAsSet();
+      for ( String input : inputs )
+      {
+         this.addInput( WSDeploymentAspectDeployer.JBOSSWS_ATTACHMENT_PREFIX + input );
+      }
+      
+      // outputs
+      this.addOutput( JBossWebMetaData.class );
+      if ( !aspect.isLast() )
+      {
+         this.addOutput( WSDeploymentAspectDeployer.JBOSSWS_METADATA );
+      }
+
+      // propagate DA provides and map them to deployer outputs
+      final Set< String > outputs = aspect.getProvidesAsSet();
+      for ( String output : outputs )
+      {
+         this.addOutput( WSDeploymentAspectDeployer.JBOSSWS_ATTACHMENT_PREFIX + output );
+      }
+
+      this.setRelativeOrder( aspect.getRelativeOrder() );
+      this.aspect = aspect;
+   }
+
+   /**
+    * If deployed unit is related to web services this method delegates
+    * to deployment aspect and calls its create() and start() methods.
+    * 
+    * @param unit deployment unit
+    * @throws DeploymentException on deployment failure
+    */
+   @Override
+   public void internalDeploy( final DeploymentUnit unit ) throws DeploymentException
+   {
+      if ( ASHelper.isWebServiceDeployment( unit ) )
+      {
+         log.debug( this.aspect.getClass() + " deploy: " + unit.getName() );
+         final Deployment dep = ASHelper.getRequiredAttachment( unit, Deployment.class );
+         this.aspect.start( dep );
+      }
+   }
+
+   /**
+    * If undeployed unit is related to web services this method delegates
+    * to deployment aspect and calls its stop() and destroy() methods.
+    * 
+    * @param unit deployment unit
+    */
+   @Override
+   public void internalUndeploy( final DeploymentUnit unit )
+   {
+      if ( ASHelper.isWebServiceDeployment( unit ) )
+      {
+         log.debug( this.aspect.getClass() + " undeploy: " + unit.getName() );
+         final Deployment dep = ASHelper.getRequiredAttachment( unit, Deployment.class );
+         this.aspect.stop( dep );
+      }
+   }
+   
+   /**
+    * Displays also WS deployment aspect being used.
+    * 
+    * @return deployer instance id including wrapped deployment aspect id.
+    */
+   @Override
+   public String toString()
+   {
+      final StringBuilder sb = new StringBuilder();
+      sb.append( super.toString() ).append( '(' ).append( this.aspect ).append( ')' );
+      return sb.toString();
+   }
+
+}

Added: branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/deployers/WSDeploymentDeployer.java
===================================================================
--- branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/deployers/WSDeploymentDeployer.java	                        (rev 0)
+++ branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/deployers/WSDeploymentDeployer.java	2009-07-30 12:23:04 UTC (rev 91827)
@@ -0,0 +1,322 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.webservices.integration.deployers;
+
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+import org.jboss.metadata.serviceref.VirtualFileAdaptor;
+import org.jboss.metadata.web.jboss.JBossWebMetaData;
+import org.jboss.metadata.web.spec.ServletMetaData;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.webservices.integration.invocation.InvocationHandlerEJB3;
+import org.jboss.webservices.integration.util.ASHelper;
+import org.jboss.wsf.spi.SPIProvider;
+import org.jboss.wsf.spi.SPIProviderResolver;
+import org.jboss.wsf.spi.deployment.ArchiveDeployment;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.deployment.Deployment.DeploymentType;
+import org.jboss.wsf.spi.deployment.DeploymentModelFactory;
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
+import org.jboss.wsf.spi.deployment.WSFDeploymentException;
+import org.jboss.wsf.spi.deployment.integration.WebServiceDeclaration;
+import org.jboss.wsf.spi.deployment.integration.WebServiceDeployment;
+import org.jboss.wsf.spi.metadata.webservices.PortComponentMetaData;
+import org.jboss.wsf.spi.metadata.webservices.WebserviceDescriptionMetaData;
+import org.jboss.wsf.spi.metadata.webservices.WebservicesMetaData;
+
+/**
+ * This deployer initializes JBossWS deployment meta data. 
+ *
+ * @author <a href="ropalka at redhat.com">Richard Opalka</a>
+ */
+public final class WSDeploymentDeployer extends AbstractRealDeployer
+{
+   
+   /** WSDL and XSD files filter. */
+   private static final WSVirtualFileFilter WS_FILE_FILTER = new WSVirtualFileFilter();
+   /** Deployment model factory. */
+   private final DeploymentModelFactory deploymentModelFactory;
+
+   /**
+    * Constructor.
+    */
+   public WSDeploymentDeployer()
+   {
+      super();
+      
+      // inputs
+      this.addInput( JBossWebMetaData.class );
+      this.addInput( DeploymentType.class );
+      
+      // outputs
+      this.addOutput( JBossWebMetaData.class );
+      this.addOutput( Deployment.class );
+
+      // deployment factory
+      final SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
+      this.deploymentModelFactory = spiProvider.getSPI( DeploymentModelFactory.class );
+   }
+
+   /**
+    * Creates new Web Service deployment and registers it with deployment unit.
+    * 
+    * @param unit deployment unit
+    * @throws DeploymentException if error occurs
+    */
+   @Override
+   protected void internalDeploy( final DeploymentUnit unit ) throws DeploymentException
+   {
+      if ( ASHelper.isJaxwsJseDeployment( unit ) )
+      {
+         this.newJaxwsJseDeployment( unit );
+      }
+      else if ( ASHelper.isJaxwsEjbDeployment( unit ) )
+      {
+         this.newJaxwsEjbDeployment( unit );
+      }
+      else if ( ASHelper.isJaxrpcJseDeployment( unit ) )
+      {
+         this.newJaxrpcJseDeployment( unit );
+      }
+      else if ( ASHelper.isJaxrpcEjbDeployment( unit ) )
+      {
+         this.newJaxrpcEjbDeployment( unit );
+      }
+   }
+
+   /**
+    * Creates new JAXRPC EJB21 deployment and registers it with deployment unit.
+    * 
+    * @param unit deployment unit
+    */
+   private void newJaxrpcEjbDeployment( final DeploymentUnit unit )
+   {
+      final ArchiveDeployment dep = this.newDeployment( unit );
+      final JBossMetaData jbmd = this.getAndPropagateAttachment( JBossMetaData.class, unit, dep );
+      final WebservicesMetaData wsMetaData = this.getAndPropagateAttachment( WebservicesMetaData.class, unit, dep );
+      this.getAndPropagateAttachment( WebServiceDeployment.class, unit, dep );
+      
+      for ( WebserviceDescriptionMetaData wsd : wsMetaData.getWebserviceDescriptions() )
+      {
+         for ( PortComponentMetaData pcmd : wsd.getPortComponents() )
+         {
+            final String ejbName = pcmd.getEjbLink();
+            final JBossEnterpriseBeanMetaData beanMetaData = jbmd.getEnterpriseBean( ejbName );
+            final String ejbClass = beanMetaData.getEjbClass();
+
+            this.createEndpoint( ejbClass, ejbName, dep );
+         }
+      }
+      
+      dep.addAttachment( DeploymentUnit.class, unit );
+      unit.addAttachment( Deployment.class, dep );
+   }
+   
+   /**
+    * Creates new JAXWS EJB3 deployment and registers it with deployment unit.
+    * 
+    * @param unit deployment unit
+    */
+   private void newJaxwsEjbDeployment( final DeploymentUnit unit )
+   {
+      final ArchiveDeployment dep = this.newDeployment( unit );
+      this.getAndPropagateAttachment( WebServiceDeployment.class, unit, dep );
+
+      final Iterator< WebServiceDeclaration > ejbIterator = ASHelper.getJaxwsEjbs( unit ).iterator();
+      while ( ejbIterator.hasNext() )
+      {
+         final WebServiceDeclaration container = ejbIterator.next();
+         final String ejbName = container.getComponentName();
+         final String ejbClass = container.getComponentClassName();
+
+         final Endpoint ep = this.createEndpoint( ejbClass, ejbName, dep );
+         ep.setProperty( InvocationHandlerEJB3.CONTAINER_NAME, container.getContainerName() );
+      }
+      
+      dep.addAttachment( DeploymentUnit.class, unit );
+      unit.addAttachment( Deployment.class, dep );
+   }
+   
+   /**
+    * Creates new JAXRPC JSE deployment and registers it with deployment unit.
+    * 
+    * @param unit deployment unit
+    */
+   private void newJaxrpcJseDeployment( final DeploymentUnit unit )
+   {
+      final ArchiveDeployment dep = this.newDeployment( unit );
+      final JBossWebMetaData webMetaData = this.getAndPropagateAttachment( JBossWebMetaData.class, unit, dep );
+      final WebservicesMetaData wsMetaData = this.getAndPropagateAttachment( WebservicesMetaData.class, unit, dep );
+
+      for ( WebserviceDescriptionMetaData wsd : wsMetaData.getWebserviceDescriptions() )
+      {
+         for ( PortComponentMetaData pcmd : wsd.getPortComponents() )
+         {
+            final String servletName = pcmd.getServletLink();
+            final ServletMetaData servletMD = ASHelper.getServletForName( webMetaData, servletName );
+            final String servletClass = ASHelper.getEndpointName( servletMD );
+
+            this.createEndpoint( servletClass, servletName, dep );
+         }
+      }
+
+      dep.addAttachment( DeploymentUnit.class, unit );
+      unit.addAttachment( Deployment.class, dep );
+   }
+   
+   /**
+    * Creates new JAXWS JSE deployment and registers it with deployment unit.
+    * 
+    * @param unit deployment unit
+    */
+   private void newJaxwsJseDeployment( final DeploymentUnit unit )
+   {
+      final ArchiveDeployment dep = this.newDeployment( unit );
+      this.getAndPropagateAttachment( JBossWebMetaData.class, unit, dep );
+
+      final List< ServletMetaData > servlets = ASHelper.getJaxwsServlets( unit );
+      for ( ServletMetaData servlet : servlets )
+      {
+         final String servletName = servlet.getName();
+         final String servletClass = ASHelper.getEndpointName( servlet );
+
+         this.createEndpoint( servletClass, servletName, dep );
+      }
+
+      dep.addAttachment( DeploymentUnit.class, unit );
+      unit.addAttachment( Deployment.class, dep );
+   }
+
+   /**
+    * Creates new Web Service deployment.
+    * 
+    * @param unit deployment unit
+    * @return archive deployment
+    */
+   private ArchiveDeployment newDeployment( final DeploymentUnit unit )
+   {
+      final ArchiveDeployment dep = ( ArchiveDeployment ) this.deploymentModelFactory.
+         newDeployment( unit.getSimpleName(), unit.getClassLoader() );
+
+      if ( unit instanceof VFSDeploymentUnit )
+      {
+         final VFSDeploymentUnit vfsUnit = ( VFSDeploymentUnit ) unit;
+         final List< VirtualFile > virtualFiles = vfsUnit.getMetaDataFiles( WSDeploymentDeployer.WS_FILE_FILTER );
+         final Set< UnifiedVirtualFile > uVirtualFiles = new HashSet< UnifiedVirtualFile >();
+         for ( VirtualFile vf : virtualFiles )
+         {
+            // Adding the roots of the virtual files.
+            try
+            {
+               uVirtualFiles.add( new VirtualFileAdaptor( vf.getVFS().getRoot() ) );
+            }
+            catch ( IOException ioe )
+            {
+               throw new WSFDeploymentException( ioe );
+            }
+         }
+         dep.setMetadataFiles( new LinkedList<UnifiedVirtualFile>( uVirtualFiles ) );
+      }
+
+      if ( unit.getParent() != null )
+      {
+         final DeploymentUnit parentUnit = unit.getParent();
+         final ArchiveDeployment parentDep = ( ArchiveDeployment ) this.deploymentModelFactory.
+            newDeployment( parentUnit.getSimpleName(), parentUnit.getClassLoader() );
+         dep.setParent( parentDep );
+      }
+
+      dep.setRootFile( new VirtualFileAdaptor( ( ( VFSDeploymentUnit ) unit ).getRoot() ) );
+      dep.setRuntimeClassLoader( unit.getClassLoader() );
+      final DeploymentType deploymentType = ASHelper.getRequiredAttachment( unit, DeploymentType.class );
+      dep.setType( deploymentType );
+
+      return dep;
+   }
+
+   /**
+    * Creates new Web Service endpoint.
+    * 
+    * @param endpointClass endpoint class name
+    * @param endpointName endpoint name
+    * @param dep deployment
+    * @return WS endpoint
+    */
+   private Endpoint createEndpoint( final String endpointClass, final String endpointName, final Deployment dep )
+   {
+      if ( endpointName == null )
+      {
+         throw new NullPointerException( "Null endpoint name" );
+      }
+
+      if ( endpointClass == null )
+      {
+         throw new NullPointerException( "Null endpoint class" );
+      }
+      
+      final Endpoint endpoint = this.deploymentModelFactory.newEndpoint( endpointClass );
+      endpoint.setShortName( endpointName );
+      dep.getService().addEndpoint( endpoint );
+      
+      return endpoint;
+   }
+   
+   /**
+    * Gets specified attachment from deployment unit. 
+    * Checks it's not null and then propagates it to <b>dep</b>
+    * attachments. Finally it returns attachment value.
+    * 
+    * @param <A> class type
+    * @param attachment attachment
+    * @param unit deployment unit
+    * @param dep deployment
+    * @return attachment value if found in unit
+    */
+   private <A> A getAndPropagateAttachment
+   (
+      final Class< A > attachment, final DeploymentUnit unit, final Deployment dep
+   )
+   {
+      final A attachmentValue = ASHelper.getOptionalAttachment( unit, attachment );
+      
+      if ( attachmentValue != null )
+      {
+         dep.addAttachment( attachment , attachmentValue );
+         return attachmentValue;
+      }
+
+      throw new IllegalStateException( "Deployment unit does not contain " + attachment );
+   }
+   
+}

Added: branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/deployers/WSDescriptorDeployer.java
===================================================================
--- branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/deployers/WSDescriptorDeployer.java	                        (rev 0)
+++ branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/deployers/WSDescriptorDeployer.java	2009-07-30 12:23:04 UTC (rev 91827)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.webservices.integration.deployers;
+
+import org.jboss.deployers.vfs.spi.deployer.ObjectModelFactoryDeployer;
+import org.jboss.wsf.spi.metadata.webservices.WebservicesFactory;
+import org.jboss.wsf.spi.metadata.webservices.WebservicesMetaData;
+import org.jboss.xb.binding.ObjectModelFactory;
+
+/**
+ * webservices.xml deployer.
+ *
+ * @author <a href="ropalka at redhat.com">Richard Opalka</a>
+ */
+public final class WSDescriptorDeployer extends ObjectModelFactoryDeployer< WebservicesMetaData >
+{
+
+   /**
+    * Constructor.
+    */
+   public WSDescriptorDeployer()
+   {
+      super( WebservicesMetaData.class );
+   }
+
+   /**
+    * Model factory generator.
+    * 
+    * @param root object tree root
+    * @return object model factory
+    */
+   @Override
+   protected ObjectModelFactory getObjectModelFactory( final WebservicesMetaData root )
+   {
+      return new WebservicesFactory( null );
+   }
+
+}

Added: branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/deployers/WSEJBAdapterDeployer.java
===================================================================
--- branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/deployers/WSEJBAdapterDeployer.java	                        (rev 0)
+++ branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/deployers/WSEJBAdapterDeployer.java	2009-07-30 12:23:04 UTC (rev 91827)
@@ -0,0 +1,286 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.webservices.integration.deployers;
+
+import java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+import javax.naming.Context;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.ejb.deployers.EjbDeployment;
+import org.jboss.ejb.deployers.MergedJBossMetaDataDeployer;
+import org.jboss.ejb3.EJBContainer;
+import org.jboss.ejb3.Ejb3Deployment;
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+import org.jboss.webservices.integration.util.ASHelper;
+import org.jboss.wsf.spi.deployment.integration.WebServiceDeclaration;
+import org.jboss.wsf.spi.deployment.integration.WebServiceDeployment;
+import org.jboss.wsf.spi.metadata.webservices.WebservicesMetaData;
+
+/**
+ * WebServiceDeployment deployer processes EJB containers and its metadata and creates WS adapters wrapping it.
+ *
+ * @author <a href="ropalka at redhat.com">Richard Opalka</a>
+ */
+public final class WSEJBAdapterDeployer extends AbstractRealDeployer
+{
+
+   /**
+    * Constructor.
+    */
+   public WSEJBAdapterDeployer()
+   {
+      super();
+      
+      // inputs
+      this.addInput( MergedJBossMetaDataDeployer.EJB_MERGED_ATTACHMENT_NAME );   
+      this.addInput( EjbDeployment.class );
+      this.addInput( Ejb3Deployment.class );
+      this.addInput( WebservicesMetaData.class );
+
+      // outputs
+      this.addOutput( WebServiceDeployment.class );
+   }
+
+   /**
+    * Deploys WebServiceDeployment meta data.
+    * 
+    * @param unit deployment unit
+    * @throws DeploymentException exception
+    */
+   @Override
+   protected void internalDeploy( final DeploymentUnit unit ) throws DeploymentException
+   {
+      final JBossMetaData mergedMD = ( JBossMetaData ) unit.getAttachment(
+         MergedJBossMetaDataDeployer.EJB_MERGED_ATTACHMENT_NAME
+      );
+      final Ejb3Deployment ejb3Deployment = ASHelper.getOptionalAttachment( unit, Ejb3Deployment.class );
+
+      if ( mergedMD != null )
+      {
+         final WebServiceDeploymentAdapter wsDeploymentAdapter = new WebServiceDeploymentAdapter();   
+         final Iterator< JBossEnterpriseBeanMetaData > ejbIterator = mergedMD.getEnterpriseBeans().iterator();
+
+         while ( ejbIterator.hasNext() )
+         {
+            final JBossEnterpriseBeanMetaData ejbMD = ejbIterator.next();
+            final EJBContainer ejbContainer = this.getContainer( ejb3Deployment, ejbMD );
+            
+            if ( ejbMD.getEjbClass() != null )
+            {
+               wsDeploymentAdapter.getServiceEndpoints().add(
+                  new WebServiceDeclarationAdapter( ejbMD, ejbContainer, unit.getClassLoader() )
+               );
+            }
+            else
+            {
+               log.warn( "Ingoring ejb deployment with null classname: " + ejbMD );
+            }
+         }
+
+         unit.addAttachment( WebServiceDeployment.class, wsDeploymentAdapter );
+      }
+   }
+
+   /**
+    * Returns EJB container if EJB3 deployment is detected and EJB meta data does not represent entity bean.
+    * 
+    * @param ejb3Deployment EJB3 deployment meta data
+    * @param ejbMD EJB meta data
+    * @return EJB container or null if not EJB3 stateless bean
+    * @throws DeploymentException if some error occurs
+    */
+   private EJBContainer getContainer( final Ejb3Deployment ejb3Deployment, final JBossEnterpriseBeanMetaData ejbMD )
+      throws DeploymentException
+   {
+      if ( ( ejb3Deployment != null ) && ( !ejbMD.isEntity() ) )
+      {
+         try
+         {
+            final ObjectName objName = new ObjectName( ejbMD.determineContainerName() );
+            return ( EJBContainer ) ejb3Deployment.getContainer( objName );
+         }
+         catch ( MalformedObjectNameException e )
+         {
+            throw new DeploymentException( e );
+         }
+      }
+      
+      return null;
+   }
+
+   /**
+    * Adopts EJB3 bean meta data to a
+    * {@link org.jboss.wsf.spi.deployment.integration.WebServiceDeclaration}.
+    */
+   private static final class WebServiceDeclarationAdapter implements WebServiceDeclaration
+   {
+
+      /** EJB meta data. */
+      private final JBossEnterpriseBeanMetaData ejbMetaData;
+      /** EJB container. */
+      private final EJBContainer ejbContainer;
+      /** Class loader. */
+      private final ClassLoader loader;      
+
+      /**
+       * Constructor.
+       * 
+       * @param ejbMetaData EJB metadata
+       * @param ejbContainer EJB container
+       * @param loader class loader
+       */
+      private WebServiceDeclarationAdapter
+      (
+         final JBossEnterpriseBeanMetaData ejbMetaData, 
+         final EJBContainer ejbContainer, 
+         final ClassLoader loader
+      )
+      {
+         super();
+         
+         this.ejbMetaData = ejbMetaData;
+         this.ejbContainer = ejbContainer;
+         this.loader = loader;
+      }
+      
+      /**
+       * Returns EJB container name.
+       *
+       * @return container name
+       */
+      public String getContainerName()
+      {
+         return this.ejbMetaData.determineContainerName();
+      }
+
+      /**
+       * Returns JNDI context associated with EJB container.
+       *
+       * @return JNDI context
+       */
+      public Context getContext()
+      {
+         return this.ejbContainer.getEnc();
+      }
+
+      /**
+       * Returns EJB name.
+       *
+       * @return name
+       */
+      public String getComponentName()
+      {
+         return this.ejbMetaData.getName();
+      }
+
+      /**
+       * Returns EJB class name.
+       *
+       * @return class name
+       */
+      public String getComponentClassName()
+      {
+         return this.ejbMetaData.getEjbClass();
+      }
+
+      /**
+       * Returns requested annotation associated with EJB container or EJB bean.
+       *
+       * @param annotationType annotation type
+       * @param <T> annotation class type
+       * @return requested annotation or null if not found
+       */
+      public < T extends Annotation > T getAnnotation( final Class<T> annotationType )
+      {
+         final boolean haveEjbContainer = this.ejbContainer != null; 
+
+         if ( haveEjbContainer )
+         {
+            return this.ejbContainer.getAnnotation( annotationType );
+         }
+         else
+         {
+            final Class< ? > bean = this.getComponentClass();
+            return ( T ) bean.getAnnotation( annotationType );
+         }
+      }
+
+      /**
+       * Loads ejb class from associated loader.
+       *
+       * @return ejb class instance
+       */
+      private Class< ? > getComponentClass()
+      {
+         try
+         {
+            return this.loader.loadClass( this.getComponentClassName() );
+         }
+         catch ( ClassNotFoundException cnfe )
+         {
+            throw new RuntimeException( "Failed to load component class: " + 
+               this.getComponentClassName() + " from loader: " + this.loader );
+         }
+      }
+
+   }
+
+   /**
+    * Adopts an EJB deployment to a 
+    * {@link org.jboss.wsf.spi.deployment.integration.WebServiceDeployment}. 
+    */
+   private static final class WebServiceDeploymentAdapter implements WebServiceDeployment
+   {
+      
+      /** List of endpoints. */
+      private final List< WebServiceDeclaration > endpoints = new ArrayList< WebServiceDeclaration >();
+
+      /**
+       * Constructor.
+       */
+      private WebServiceDeploymentAdapter()
+      {
+         super();
+      }
+      
+      /**
+       * Returns endpoints list.
+       * 
+       * @return endpoints list
+       */
+      public List< WebServiceDeclaration > getServiceEndpoints()
+      {
+         return this.endpoints;  
+      }
+
+   }
+
+}

Added: branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/deployers/WSTypeDeployer.java
===================================================================
--- branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/deployers/WSTypeDeployer.java	                        (rev 0)
+++ branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/deployers/WSTypeDeployer.java	2009-07-30 12:23:04 UTC (rev 91827)
@@ -0,0 +1,155 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.webservices.integration.deployers;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+import org.jboss.metadata.web.jboss.JBossWebMetaData;
+import org.jboss.webservices.integration.util.ASHelper;
+import org.jboss.wsf.spi.deployment.Deployment.DeploymentType;
+import org.jboss.wsf.spi.deployment.integration.WebServiceDeployment;
+import org.jboss.wsf.spi.metadata.webservices.WebservicesMetaData;
+
+/**
+ * Detects Web Service deployment type.
+ *
+ * @author <a href="ropalka at redhat.com">Richard Opalka</a>
+ */
+public final class WSTypeDeployer extends AbstractRealDeployer
+{
+
+   /**
+    * Constructor.
+    */
+   public WSTypeDeployer()
+   {
+      super();
+      
+      // inputs
+      this.addInput( JBossWebMetaData.class );
+      this.addInput( WebservicesMetaData.class );
+      this.addInput( WebServiceDeployment.class );
+      
+      // outputs
+      this.addOutput( DeploymentType.class );
+      this.addOutput( JBossWebMetaData.class );
+   }
+
+   /**
+    * Detects WS deployment type and puts it to the deployment unit attachments.
+    * 
+    * @param unit deployment unit
+    * @throws DeploymentException on failure
+    */
+   @Override
+   protected void internalDeploy( final DeploymentUnit unit ) throws DeploymentException
+   {
+      if ( this.isJaxwsJseDeployment( unit ) )
+      {
+         unit.addAttachment( DeploymentType.class, DeploymentType.JAXWS_JSE );
+      }
+      else if ( this.isJaxwsEjbDeployment( unit ) )
+      {
+         unit.addAttachment( DeploymentType.class, DeploymentType.JAXWS_EJB3 );
+      }
+      else if ( this.isJaxrpcJseDeployment( unit ) )
+      {
+         unit.addAttachment( DeploymentType.class, DeploymentType.JAXRPC_JSE );
+      }
+      else if ( this.isJaxrpcEjbDeployment( unit ) )
+      {
+         unit.addAttachment( DeploymentType.class, DeploymentType.JAXRPC_EJB21 );
+      }
+   }
+   
+   /**
+    * Returns true if JAXRPC EJB deployment is detected.
+    * 
+    * @param unit deployment unit
+    * @return true if JAXRPC EJB, false otherwise
+    */
+   private boolean isJaxrpcEjbDeployment( final DeploymentUnit unit )
+   {
+      final boolean hasWebservicesMD = ASHelper.hasAttachment( unit, WebservicesMetaData.class );
+      final boolean hasJBossMD = unit.getAllMetaData( JBossMetaData.class ).size() > 0;
+      
+      return hasWebservicesMD && hasJBossMD;
+   }
+   
+   /**
+    * Returns true if JAXRPC JSE deployment is detected.
+    * 
+    * @param unit deployment unit
+    * @return true if JAXRPC JSE, false otherwise
+    */
+   private boolean isJaxrpcJseDeployment( final DeploymentUnit unit )
+   {
+      final boolean hasWebservicesMD = ASHelper.hasAttachment( unit, WebservicesMetaData.class );
+      final boolean hasJBossWebMD = ASHelper.hasAttachment( unit, JBossWebMetaData.class );
+
+      if ( hasWebservicesMD && hasJBossWebMD )
+      {
+         return ASHelper.getJaxrpcServlets( unit ).size() > 0;
+      }
+
+      return false;
+   }
+   
+   /**
+    * Returns true if JAXWS EJB deployment is detected.
+    * 
+    * @param unit deployment unit
+    * @return true if JAXWS EJB, false otherwise
+    */
+   private boolean isJaxwsEjbDeployment( final DeploymentUnit unit )
+   {
+      final boolean hasWSDeployment = ASHelper.hasAttachment( unit, WebServiceDeployment.class );
+
+      if ( hasWSDeployment )
+      {
+         return ASHelper.getJaxwsEjbs( unit ).size() > 0;
+      }
+
+      return false;
+   }
+
+   /**
+    * Returns true if JAXWS JSE deployment is detected.
+    * 
+    * @param unit deployment unit
+    * @return true if JAXWS JSE, false otherwise
+    */
+   private boolean isJaxwsJseDeployment( final DeploymentUnit unit )
+   {
+      final boolean hasJBossWebMD = ASHelper.hasAttachment( unit, JBossWebMetaData.class );
+
+      if ( hasJBossWebMD )
+      {
+         return ASHelper.getJaxwsServlets( unit ).size() > 0;
+      }
+
+      return false;
+   }
+
+}

Added: branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/deployers/WSVirtualFileFilter.java
===================================================================
--- branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/deployers/WSVirtualFileFilter.java	                        (rev 0)
+++ branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/deployers/WSVirtualFileFilter.java	2009-07-30 12:23:04 UTC (rev 91827)
@@ -0,0 +1,89 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.webservices.integration.deployers;
+
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.VirtualFileFilterWithAttributes;
+import org.jboss.virtual.VisitorAttributes;
+
+/**
+ * WS file filter for files with the '.wsdl', or '.xsd' or '.xml' suffix. 
+ * 
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ * @author <a href="ropalka at redhat.com">Richard Opalka</a>
+ */
+public final class WSVirtualFileFilter implements VirtualFileFilterWithAttributes
+{
+   
+   /** The tree walking attributes. */
+   private VisitorAttributes attributes;
+
+   /**
+    * Constructor. 
+    */
+   public WSVirtualFileFilter()
+   {
+      this( VisitorAttributes.RECURSE_LEAVES_ONLY );
+   }
+
+   /**
+    * Constructor.
+    * 
+    * @param attributes visit attributes
+    */
+   public WSVirtualFileFilter( final VisitorAttributes attributes )
+   {
+      this.attributes = attributes;
+   }
+
+   /**
+    * Gets VisitorAttributes for this instance.
+    * 
+    * @return visitor attributes
+    */
+   public VisitorAttributes getAttributes()
+   {
+      return this.attributes;
+   }
+
+   /**
+    * Accepts files that end with '.wsdl' or '.xsd' or '.xml'.
+    *
+    * @param file to analyze
+    * @return true if expected file extension, false otherwise
+    */
+   public boolean accepts( final VirtualFile file )
+   {
+      if ( file == null )
+      {
+         return false;
+      }
+
+      final String fileName = file.getName().toLowerCase();
+      final boolean hasWsdlSuffix = fileName.endsWith( ".wsdl" );
+      final boolean hasXsdSuffix = fileName.endsWith( ".xsd" );
+      final boolean hasXmlSuffix = fileName.endsWith( ".xml" );
+      
+      return hasWsdlSuffix || hasXsdSuffix || hasXmlSuffix;
+   }
+
+}

Added: branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/injection/EJBBeanReferenceResolver.java
===================================================================
--- branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/injection/EJBBeanReferenceResolver.java	                        (rev 0)
+++ branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/injection/EJBBeanReferenceResolver.java	2009-07-30 12:23:04 UTC (rev 91827)
@@ -0,0 +1,114 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.webservices.integration.injection;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import javax.ejb.EJB;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.ejb3.common.resolvers.spi.EjbReference;
+import org.jboss.ejb3.common.resolvers.spi.EjbReferenceResolver;
+import org.jboss.wsf.common.injection.resolvers.AbstractReferenceResolver;
+
+/**
+ * EJB reference resolver.
+ *
+ * @author <a href="mailto:richard.opalka at jboss.org">Richard Opalka</a>
+ */
+final class EJBBeanReferenceResolver extends AbstractReferenceResolver<EJB>
+{
+
+   /**
+    * Deployment unit used for resolving process.
+    */
+   private final DeploymentUnit unit;
+   /**
+    * Delegate used to resolve JNDI names.
+    */
+   private final EjbReferenceResolver delegate;
+
+   /**
+    * Constructor.
+    */
+   public EJBBeanReferenceResolver(final DeploymentUnit unit, final EjbReferenceResolver delegate)
+   {
+      super(EJB.class);
+
+      if (unit == null)
+      {
+         throw new IllegalArgumentException("Deployment unit cannot be null");
+      }
+      if (delegate == null)
+      {
+         throw new IllegalArgumentException("Ejb reference resolver cannot be null");
+      }
+
+      this.unit = unit;
+      this.delegate = delegate;
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.wsf.common.injection.resolvers.AbstractReferenceResolver#resolveField(java.lang.reflect.Field)
+    */
+   @Override
+   protected String resolveField(final Field field)
+   {
+      final EJB ejbAnnotation = field.getAnnotation(EJB.class);
+      final Class<?> type = field.getType();
+      final EjbReference reference = getEjbReference(ejbAnnotation, type);
+
+      return this.delegate.resolveEjb(unit, reference);
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.wsf.common.injection.resolvers.AbstractReferenceResolver#resolveMethod(java.lang.reflect.Method)
+    */
+   @Override
+   protected String resolveMethod(final Method method)
+   {
+      final EJB ejbAnnotation = method.getAnnotation(EJB.class);
+      final Class<?> type =  method.getParameterTypes()[0];
+      final EjbReference reference = getEjbReference(ejbAnnotation, type);
+
+      return this.delegate.resolveEjb(unit, reference);
+   }
+
+   /**
+    * Constructs EjbReference.
+    *
+    * @param ejbAnnotation ejb annotation
+    * @param type fall back type
+    * @return ejb reference instance
+    */
+   private EjbReference getEjbReference(EJB ejbAnnotation, Class<?> type)
+   {
+      String beanInterface = ejbAnnotation.beanInterface().getName();
+      if (java.lang.Object.class.getName().equals(beanInterface))
+      {
+         beanInterface = type.getName();
+      }
+      return new EjbReference(ejbAnnotation.beanName(), beanInterface, ejbAnnotation.mappedName());
+   }
+
+}

Added: branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/injection/InjectionMetaDataDeploymentAspect.java
===================================================================
--- branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/injection/InjectionMetaDataDeploymentAspect.java	                        (rev 0)
+++ branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/injection/InjectionMetaDataDeploymentAspect.java	2009-07-30 12:23:04 UTC (rev 91827)
@@ -0,0 +1,230 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.webservices.integration.injection;
+
+import java.lang.annotation.Annotation;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.annotation.Resource;
+import javax.ejb.EJB;
+import javax.jws.WebService;
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.xml.ws.WebServiceProvider;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.ejb3.common.resolvers.spi.EjbReferenceResolver;
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeansMetaData;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+import org.jboss.metadata.javaee.spec.EnvironmentEntriesMetaData;
+import org.jboss.metadata.javaee.spec.EnvironmentEntryMetaData;
+import org.jboss.metadata.javaee.spec.ResourceInjectionTargetMetaData;
+import org.jboss.metadata.web.jboss.JBossWebMetaData;
+import org.jboss.webservices.integration.util.ASHelper;
+import org.jboss.wsf.common.injection.resolvers.ResourceReferenceResolver;
+import org.jboss.wsf.common.integration.WSHelper;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.deployment.DeploymentAspect;
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.deployment.integration.WebServiceDeclaration;
+import org.jboss.wsf.spi.deployment.integration.WebServiceDeployment;
+import org.jboss.wsf.spi.metadata.injection.InjectionMetaData;
+import org.jboss.wsf.spi.metadata.injection.InjectionsMetaData;
+import org.jboss.wsf.spi.metadata.injection.ReferenceResolver;
+
+/**
+ * Deployment aspect that builds injection meta data.
+ *
+ * @author <a href="mailto:richard.opalka at jboss.org">Richard Opalka</a>
+ */
+public final class InjectionMetaDataDeploymentAspect extends DeploymentAspect
+{
+
+   private static final ReferenceResolver RESOURCE_REFERENCE_RESOLVER = new ResourceReferenceResolver(); 
+   private static final String EJB3_JNDI_PREFIX = "java:env/";
+   private EjbReferenceResolver ejbReferenceResolver;
+
+   @Override
+   public void start(Deployment dep)
+   {
+      super.start(dep);
+
+      DeploymentUnit unit = WSHelper.getRequiredAttachment( dep, DeploymentUnit.class );
+      JBossWebMetaData webMD = WSHelper.getRequiredAttachment( dep, JBossWebMetaData.class );
+
+      List<InjectionMetaData> injectionMD = new LinkedList<InjectionMetaData>();
+      Map<Class<? extends Annotation>, ReferenceResolver> resolvers = createResolvers(unit);
+
+      try
+      {
+         
+         if ( WSHelper.isJaxwsJseDeployment( dep ) )
+         {
+            injectionMD.addAll(buildInjectionMetaData(webMD.getEnvironmentEntries()));
+            for (Endpoint endpoint : dep.getService().getEndpoints())
+            {
+               InjectionsMetaData injectionsMD = new InjectionsMetaData(injectionMD, resolvers, null);
+               endpoint.addAttachment(InjectionsMetaData.class, injectionsMD);
+            }
+         }
+         else if ( WSHelper.isJaxwsEjbDeployment( dep ) )
+         {
+            WebServiceDeployment webServiceDeployment = ASHelper.getRequiredAttachment( unit, WebServiceDeployment.class );
+            JBossMetaData jbossMD = ASHelper.getRequiredAttachment( unit, JBossMetaData.class );
+            JBossEnterpriseBeansMetaData jebMDs = jbossMD.getEnterpriseBeans();
+
+            Iterator<WebServiceDeclaration> it = webServiceDeployment.getServiceEndpoints().iterator();
+            while (it.hasNext())
+            {
+               WebServiceDeclaration container = it.next();
+               if (isWebServiceBean(container))
+               {
+                  final Context ctx = (Context)container.getContext().lookup(EJB3_JNDI_PREFIX);
+                  String ejbName = container.getComponentName();
+                  EnvironmentEntriesMetaData ejbEnvEntries = jebMDs.get(ejbName).getEnvironmentEntries(); 
+                  injectionMD.addAll(buildInjectionMetaData(ejbEnvEntries));
+                  Endpoint endpoint = dep.getService().getEndpointByName(ejbName);
+                  InjectionsMetaData injectionsMD = new InjectionsMetaData(injectionMD, resolvers, ctx);
+                  endpoint.addAttachment(InjectionsMetaData.class, injectionsMD);
+               }
+            }
+         }
+      }
+      catch (NamingException ne)
+      {
+         throw new RuntimeException(ne);
+      }
+   }
+
+   @Override
+   public void stop(Deployment dep)
+   {
+      dep.getService().removeAttachment(InjectionMetaData.class);
+
+      super.stop(dep);
+   }
+
+   /**
+    * Builds reference resolvers container.
+    *
+    * @param unit deployment unit
+    * @return reference resolvers
+    */
+   private Map<Class<? extends Annotation>, ReferenceResolver> createResolvers(DeploymentUnit unit)
+   {
+      final Map<Class<? extends Annotation>, ReferenceResolver> resolvers = new HashMap<Class<? extends Annotation>, ReferenceResolver>();
+      resolvers.put(Resource.class, RESOURCE_REFERENCE_RESOLVER);
+      resolvers.put(EJB.class, new EJBBeanReferenceResolver(unit, getEjbReferenceResolver()));
+      return resolvers;
+   }
+
+   /**
+    * Builds JBossWS specific injection metadata from JBoss metadata.
+    *
+    * @param envEntries environment entries
+    * @return JBossWS specific injection metadata
+    */
+   private List<InjectionMetaData> buildInjectionMetaData(EnvironmentEntriesMetaData envEntries)
+   {
+      if ((envEntries == null) || (envEntries.size() == 0))
+      {
+         return Collections.emptyList();
+      }
+
+      EnvironmentEntryMetaData eeMD = null;
+      LinkedList<InjectionMetaData> retVal = new LinkedList<InjectionMetaData>();
+      String envEntryName = null;
+      String envEntryValue = null;
+      String targetClass = null;
+      String targetName = null;
+      String valueClass = null;
+
+      for (Iterator<EnvironmentEntryMetaData> i = envEntries.iterator(); i.hasNext();)
+      {
+         eeMD = i.next();
+         envEntryName = eeMD.getEnvEntryName();
+         envEntryValue = eeMD.getValue();
+         valueClass = eeMD.getType();
+
+         Set<ResourceInjectionTargetMetaData> injectionTargets = eeMD.getInjectionTargets();
+         if ((injectionTargets != null) && (injectionTargets.size() > 0))
+         {
+            for (Iterator<ResourceInjectionTargetMetaData> j = injectionTargets.iterator(); j.hasNext(); )
+            {
+               ResourceInjectionTargetMetaData ritMD = j.next();
+               targetClass = ritMD.getInjectionTargetClass();
+               targetName = ritMD.getInjectionTargetName();
+               InjectionMetaData injectionMD = new InjectionMetaData(targetClass, targetName, valueClass, envEntryName, envEntryValue != null);
+               retVal.add(injectionMD);
+            }
+         }
+      }
+
+      return retVal;
+   }
+
+   /**
+    * Returns true if EJB represents webservice endpoint, false otherwise.
+    *
+    * @param container to analyze
+    * @return true if webservice endpoint, false otherwise
+    */
+   private boolean isWebServiceBean(WebServiceDeclaration container)
+   {
+      boolean isWebService = container.getAnnotation(WebService.class) != null;
+      boolean isWebServiceProvider = container.getAnnotation(WebServiceProvider.class) != null;
+
+      return isWebService || isWebServiceProvider;
+   }
+
+   /**
+    * Sets ejb reference resolver. This method is invoked by MC.
+    *
+    * @param resolver ejb reference resolver
+    */
+   public void setEjbReferenceResolver(final EjbReferenceResolver resolver)
+   {
+      this.ejbReferenceResolver = resolver;
+   }
+
+   /**
+    * Gets ejb reference resolver.
+    *
+    * @return ejb reference resolver
+    */
+   public EjbReferenceResolver getEjbReferenceResolver()
+   {
+      if (this.ejbReferenceResolver == null)
+      {
+         throw new IllegalStateException("No EjbReferenceResolver set by MC");
+      }
+
+      return this.ejbReferenceResolver;
+   }
+
+}

Added: branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/invocation/AbstractInvocationHandler.java
===================================================================
--- branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/invocation/AbstractInvocationHandler.java	                        (rev 0)
+++ branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/invocation/AbstractInvocationHandler.java	2009-07-30 12:23:04 UTC (rev 91827)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.webservices.integration.invocation;
+
+import java.lang.reflect.Method;
+
+import org.jboss.wsf.common.JavaUtils;
+import org.jboss.wsf.spi.invocation.InvocationHandler;
+
+/**
+ * @author Thomas.Diesler at jboss.org
+ */
+public abstract class AbstractInvocationHandler extends InvocationHandler
+{
+   protected Method getImplMethod(Class implClass, Method seiMethod) throws ClassNotFoundException, NoSuchMethodException
+   {
+      String methodName = seiMethod.getName();
+      Class[] paramTypes = seiMethod.getParameterTypes();
+      for (int i = 0; i < paramTypes.length; i++)
+      {
+         Class paramType = paramTypes[i];
+         if (JavaUtils.isPrimitive(paramType) == false)
+         {
+            String paramTypeName = paramType.getName();
+            paramType = JavaUtils.loadJavaType(paramTypeName);
+            paramTypes[i] = paramType;
+         }
+      }
+
+      Method implMethod = implClass.getMethod(methodName, paramTypes);
+      return implMethod;
+   }
+}

Added: branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerEJB21.java
===================================================================
--- branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerEJB21.java	                        (rev 0)
+++ branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerEJB21.java	2009-07-30 12:23:04 UTC (rev 91827)
@@ -0,0 +1,197 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.webservices.integration.invocation;
+
+import java.lang.reflect.Method;
+import java.security.Principal;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import javax.xml.rpc.handler.MessageContext;
+import javax.xml.rpc.handler.soap.SOAPMessageContext;
+import javax.xml.ws.WebServiceException;
+
+import org.jboss.ejb.EjbModule;
+import org.jboss.ejb.Interceptor;
+import org.jboss.ejb.StatelessSessionContainer;
+import org.jboss.invocation.InvocationKey;
+import org.jboss.invocation.InvocationType;
+import org.jboss.invocation.PayloadKey;
+import org.jboss.logging.Logger;
+import org.jboss.mx.util.MBeanServerLocator;
+import org.jboss.security.SecurityContext;
+import org.jboss.security.SecurityContextAssociation;
+import org.jboss.webservices.integration.invocation.ServiceEndpointInterceptor;
+import org.jboss.wsf.common.ObjectNameFactory;
+import org.jboss.wsf.common.integration.WSHelper;
+import org.jboss.wsf.spi.SPIProvider;
+import org.jboss.wsf.spi.SPIProviderResolver;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.invocation.HandlerCallback;
+import org.jboss.wsf.spi.invocation.Invocation;
+import org.jboss.wsf.spi.invocation.InvocationHandler;
+import org.jboss.wsf.spi.invocation.SecurityAdaptor;
+import org.jboss.wsf.spi.invocation.SecurityAdaptorFactory;
+import org.jboss.wsf.spi.metadata.j2ee.EJBArchiveMetaData;
+import org.jboss.wsf.spi.metadata.j2ee.EJBMetaData;
+
+/**
+ * Handles invocations on EJB21 endpoints.
+ *
+ * @author Thomas.Diesler at jboss.org
+ */
+public class InvocationHandlerEJB21 extends InvocationHandler
+{
+   // provide logging
+   private static final Logger log = Logger.getLogger(InvocationHandlerEJB21.class);
+
+   private String jndiName;
+   private MBeanServer server;
+   private ObjectName objectName;
+
+   InvocationHandlerEJB21()
+   {
+   }
+
+   public Invocation createInvocation()
+   {
+      return new Invocation();
+   }
+
+   public void init(Endpoint ep)
+   {
+      String ejbName = ep.getShortName();
+      Deployment dep = ep.getService().getDeployment();
+      EJBArchiveMetaData apMetaData = WSHelper.getRequiredAttachment( dep, EJBArchiveMetaData.class );
+      EJBMetaData beanMetaData = (EJBMetaData)apMetaData.getBeanByEjbName(ejbName);
+      if (beanMetaData == null)
+         throw new WebServiceException("Cannot obtain ejb meta data for: " + ejbName);
+
+      // get the MBeanServer
+      server = MBeanServerLocator.locateJBoss();
+
+      // get the bean's JNDI name
+      jndiName = beanMetaData.getContainerObjectNameJndiName();
+      if (jndiName == null)
+         throw new WebServiceException("Cannot obtain JNDI name for: " + ejbName);
+   }
+
+   public void invoke(Endpoint ep, Invocation inv) throws Exception
+   {
+      log.debug("Invoke: " + inv.getJavaMethod().getName());
+
+      if (objectName == null)
+      {
+         objectName = ObjectNameFactory.create("jboss.j2ee:jndiName=" + jndiName + ",service=EJB");
+         if (server.isRegistered(objectName) == false)
+            throw new WebServiceException("Cannot find service endpoint target: " + objectName);
+
+         // Inject the Service endpoint interceptor
+         injectServiceEndpointInterceptor(objectName, ep.getShortName());
+      }
+
+      // invoke on the container
+      try
+      {
+         // setup the invocation
+         org.jboss.invocation.Invocation jbInv = getMBeanInvocation(inv);
+
+         String[] sig = { org.jboss.invocation.Invocation.class.getName() };
+         Object retObj = server.invoke(objectName, "invoke", new Object[] { jbInv }, sig);
+         inv.setReturnValue(retObj);
+      }
+      catch (Exception e)
+      {
+         handleInvocationException(e);
+      }
+   }
+
+   private org.jboss.invocation.Invocation getMBeanInvocation(Invocation inv)
+   {
+      // EJB2.1 endpoints will only get an JAXRPC context 
+      MessageContext msgContext = inv.getInvocationContext().getAttachment(MessageContext.class);
+      if (msgContext == null)
+         throw new IllegalStateException("Cannot obtain MessageContext");
+
+      SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
+      SecurityAdaptor securityAdaptor = spiProvider.getSPI(SecurityAdaptorFactory.class).newSecurityAdapter();
+      SecurityContext sc = SecurityContextAssociation.getSecurityContext();
+      Principal principal = securityAdaptor.getPrincipal();
+      Object credential = securityAdaptor.getCredential();
+
+      if (principal == null && sc != null)
+         principal = sc.getUtil().getUserPrincipal();
+
+      if (credential == null && sc != null)
+         credential = sc.getUtil().getCredential();
+
+      Method method = inv.getJavaMethod();
+      Object[] args = inv.getArgs();
+      org.jboss.invocation.Invocation jbInv = new org.jboss.invocation.Invocation(null, method, args, null, principal, credential);
+
+      HandlerCallback callback = inv.getInvocationContext().getAttachment(HandlerCallback.class);
+      if (callback == null)
+         throw new IllegalStateException("Cannot obtain HandlerCallback");
+
+      jbInv.setValue(InvocationKey.SOAP_MESSAGE_CONTEXT, msgContext);
+      jbInv.setValue(InvocationKey.SOAP_MESSAGE, ((SOAPMessageContext)msgContext).getMessage());
+      jbInv.setType(InvocationType.SERVICE_ENDPOINT);
+      jbInv.setValue(HandlerCallback.class.getName(), callback, PayloadKey.TRANSIENT);
+      jbInv.setValue(Invocation.class.getName(), inv, PayloadKey.TRANSIENT);
+
+      return jbInv;
+   }
+
+   private void injectServiceEndpointInterceptor(ObjectName objectName, String ejbName)
+   {
+      // Dynamically add the service endpoint interceptor
+      // http://jira.jboss.org/jira/browse/JBWS-758
+      try
+      {
+         EjbModule ejbModule = (EjbModule)server.getAttribute(objectName, "EjbModule");
+         StatelessSessionContainer container = (StatelessSessionContainer)ejbModule.getContainer(ejbName);
+
+         boolean injectionPointFound = false;
+         Interceptor prev = container.getInterceptor();
+         while (prev != null && prev.getNext() != null)
+         {
+            Interceptor next = prev.getNext();
+            if (next.getNext() == null)
+            {
+               log.debug("Inject service endpoint interceptor after: " + prev.getClass().getName());
+               ServiceEndpointInterceptor sepInterceptor = new ServiceEndpointInterceptor();
+               prev.setNext(sepInterceptor);
+               sepInterceptor.setNext(next);
+               injectionPointFound = true;
+            }
+            prev = next;
+         }
+         if (injectionPointFound == false)
+            log.warn("Cannot service endpoint interceptor injection point");
+      }
+      catch (Exception ex)
+      {
+         log.warn("Cannot add service endpoint interceptor", ex);
+      }
+   }
+}

Added: branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerEJB3.java
===================================================================
--- branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerEJB3.java	                        (rev 0)
+++ branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerEJB3.java	2009-07-30 12:23:04 UTC (rev 91827)
@@ -0,0 +1,118 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.webservices.integration.invocation;
+
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.kernel.spi.dependency.KernelController;
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.invocation.Invocation;
+import org.jboss.wsf.spi.invocation.integration.InvocationContextCallback;
+import org.jboss.wsf.spi.invocation.integration.ServiceEndpointContainer;
+import org.jboss.wsf.spi.util.KernelLocator;
+
+import javax.xml.ws.WebServiceException;
+import java.lang.reflect.Method;
+
+/**
+ * Handles invocations on EJB3 endpoints.
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @author Heiko.Braun at jboss.com
+ */
+public class InvocationHandlerEJB3 extends AbstractInvocationHandler
+{
+
+   public static final String CONTAINER_NAME = "org.jboss.wsf.spi.invocation.ContainerName";
+
+   private String containerName;
+   private KernelController houston;
+   private ServiceEndpointContainer serviceEndpointContainer;
+
+
+   InvocationHandlerEJB3()
+   {
+      houston = KernelLocator.getKernel().getController();
+   }
+
+   public Invocation createInvocation()
+   {
+      return new Invocation();
+   }
+
+   public void init(Endpoint ep)
+   {
+      containerName = (String)ep.getProperty(InvocationHandlerEJB3.CONTAINER_NAME);
+      assert containerName!=null : "Target container name not set";
+
+   }
+
+   private ServiceEndpointContainer lazyInitializeInvocationTarget()
+   {
+      if(null==this.serviceEndpointContainer)
+      {
+         ControllerContext context = houston.getInstalledContext(containerName);
+         if (context == null)
+            throw new WebServiceException("Cannot find service endpoint target: " + containerName);
+
+         assert (context.getTarget() instanceof ServiceEndpointContainer) : "Invocation target mismatch";
+         this.serviceEndpointContainer = (ServiceEndpointContainer) context.getTarget();
+      }
+
+      return this.serviceEndpointContainer;
+   }
+
+   public void invoke(Endpoint ep, Invocation wsInv) throws Exception
+   {
+      try
+      {
+         ServiceEndpointContainer invocationTarget = lazyInitializeInvocationTarget();
+         
+         Class beanClass = invocationTarget.getServiceImplementationClass();
+         Method method = getImplMethod(beanClass, wsInv.getJavaMethod());
+         Object[] args = wsInv.getArgs();
+         InvocationContextCallback invProps = new EJB3InvocationContextCallback(wsInv);
+         
+         Object retObj = invocationTarget.invokeEndpoint(method, args, invProps);
+
+         wsInv.setReturnValue(retObj);
+      }
+      catch (Throwable th)
+      {
+         handleInvocationException(th);
+      }
+   }
+
+   static class EJB3InvocationContextCallback implements InvocationContextCallback
+   {
+      private Invocation wsInv;
+
+      public EJB3InvocationContextCallback(Invocation wsInv)
+      {
+         this.wsInv = wsInv;
+      }
+
+      public <T> T get(Class<T> propertyType)
+      {
+         return wsInv.getInvocationContext().getAttachment(propertyType);               
+      }
+   }
+}

Added: branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerFactoryImpl.java
===================================================================
--- branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerFactoryImpl.java	                        (rev 0)
+++ branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerFactoryImpl.java	2009-07-30 12:23:04 UTC (rev 91827)
@@ -0,0 +1,64 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.webservices.integration.invocation;
+
+import org.jboss.wsf.spi.invocation.*;
+
+/**
+ * The default invocation model factory fro AS 5.0.
+ *
+ * @author Heiko.Braun at jboss.com
+ */
+public class InvocationHandlerFactoryImpl extends InvocationHandlerFactory
+{
+   public InvocationHandler newInvocationHandler(InvocationType type)
+   {
+      InvocationHandler handler = null;
+
+      switch(type)
+      {
+         case JAXRPC_JSE:
+            handler = new InvocationHandlerJAXRPC();
+            break;
+         case JAXRPC_EJB21:
+            handler = new InvocationHandlerEJB21();
+            break;
+         case JAXRPC_MDB21:
+            handler = new InvocationHandlerMDB21();
+            break;
+         case JAXWS_JSE:
+            handler = new InvocationHandlerJAXWS();
+            break;
+         case JAXWS_EJB3:
+            handler = new InvocationHandlerEJB3();
+            break;
+         case JAXWS_MDB3:
+            handler = new InvocationHandlerMDB3();
+            break;
+      }
+
+      if(null == handler)
+         throw new IllegalArgumentException("Unable to resolve spi.invocation.InvocationHandler for type " +type);
+
+      return handler;
+   }
+}

Added: branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerJAXRPC.java
===================================================================
--- branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerJAXRPC.java	                        (rev 0)
+++ branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerJAXRPC.java	2009-07-30 12:23:04 UTC (rev 91827)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.webservices.integration.invocation;
+
+import javax.xml.rpc.server.ServiceLifecycle;
+import javax.xml.rpc.server.ServletEndpointContext;
+
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.invocation.Invocation;
+import org.jboss.wsf.spi.invocation.InvocationContext;
+
+/**
+ * Handles invocations on JSE endpoints.
+ *
+ * @author Thomas.Diesler at jboss.org
+ */
+public class InvocationHandlerJAXRPC extends InvocationHandlerJSE
+{
+   public void invoke(Endpoint ep, Invocation epInv) throws Exception
+   {
+      try
+      {
+         Object targetBean = getTargetBean(ep, epInv);
+
+         InvocationContext invContext = epInv.getInvocationContext();
+         if (targetBean instanceof ServiceLifecycle)
+         {
+            ServletEndpointContext sepContext = invContext.getAttachment(ServletEndpointContext.class);
+            if (sepContext != null)
+               ((ServiceLifecycle)targetBean).init(sepContext);
+         }
+
+         try
+         {
+            super.invoke(ep, epInv);
+         }
+         finally
+         {
+            if (targetBean instanceof ServiceLifecycle)
+            {
+               ((ServiceLifecycle)targetBean).destroy();
+            }
+         }
+      }
+      catch (Exception e)
+      {
+         handleInvocationException(e);
+      }
+   }
+}

Added: branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerJAXWS.java
===================================================================
--- branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerJAXWS.java	                        (rev 0)
+++ branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerJAXWS.java	2009-07-30 12:23:04 UTC (rev 91827)
@@ -0,0 +1,31 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.webservices.integration.invocation;
+
+/**
+ * Handles invocations on JSE endpoints.
+ *
+ * @author Thomas.Diesler at jboss.org
+ */
+public class InvocationHandlerJAXWS extends InvocationHandlerJSE
+{
+}

Added: branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerJSE.java
===================================================================
--- branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerJSE.java	                        (rev 0)
+++ branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerJSE.java	2009-07-30 12:23:04 UTC (rev 91827)
@@ -0,0 +1,134 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.webservices.integration.invocation;
+
+import java.lang.reflect.Method;
+
+import javax.xml.ws.WebServiceContext;
+
+import org.jboss.wsf.common.JavaUtils;
+import org.jboss.wsf.common.injection.InjectionHelper;
+import org.jboss.wsf.common.injection.PreDestroyHolder;
+import org.jboss.wsf.spi.SPIProvider;
+import org.jboss.wsf.spi.SPIProviderResolver;
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.invocation.Invocation;
+import org.jboss.wsf.spi.invocation.InvocationContext;
+import org.jboss.wsf.spi.invocation.InvocationHandler;
+import org.jboss.wsf.spi.invocation.ResourceInjector;
+import org.jboss.wsf.spi.invocation.ResourceInjectorFactory;
+import org.jboss.wsf.spi.metadata.injection.InjectionsMetaData;
+
+/**
+ * Handles invocations on JSE endpoints.
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @author richard.opalka at jboss.com
+ */
+public class InvocationHandlerJSE extends InvocationHandler
+{
+   private SPIProvider spiProvider;
+   private ResourceInjectorFactory resourceInjectorFactory;
+
+   public InvocationHandlerJSE()
+   {
+      spiProvider = SPIProviderResolver.getInstance().getProvider();
+      resourceInjectorFactory = spiProvider.getSPI(ResourceInjectorFactory.class);
+   }
+
+   public Invocation createInvocation()
+   {
+      return new Invocation();
+   }
+
+   public void init(Endpoint ep)
+   {
+   }
+
+   protected Object getTargetBean(Endpoint ep, Invocation epInv) throws Exception
+   {
+      InvocationContext invCtx = epInv.getInvocationContext();
+      Object targetBean = invCtx.getTargetBean();
+      if (targetBean == null)
+      {
+         try
+         {
+            Class<?> epImpl = ep.getTargetBeanClass();
+            targetBean = epImpl.newInstance();
+            invCtx.setTargetBean(targetBean);
+         }
+         catch (Exception ex)
+         {
+            throw new IllegalStateException("Cannot get target bean instance", ex);
+         }
+
+         InjectionHelper.injectResources(targetBean, ep.getAttachment(InjectionsMetaData.class));
+         InjectionHelper.callPostConstructMethod(targetBean);
+         ep.addAttachment(PreDestroyHolder.class, new PreDestroyHolder(targetBean));
+      }
+
+      return targetBean;
+   }
+
+   public void invoke(Endpoint ep, Invocation epInv) throws Exception
+   {
+      try
+      {
+         Object targetBean = getTargetBean(ep, epInv);
+
+         InvocationContext invContext = epInv.getInvocationContext();
+         WebServiceContext wsContext = invContext.getAttachment(WebServiceContext.class);
+         if (wsContext != null)
+         {
+            ResourceInjector injector = resourceInjectorFactory.newResourceInjector();
+            injector.inject(targetBean, wsContext);
+         }
+
+         Method method = getImplMethod(targetBean.getClass(), epInv.getJavaMethod());
+         Object retObj = method.invoke(targetBean, epInv.getArgs());
+         epInv.setReturnValue(retObj);
+      }
+      catch (Exception e)
+      {
+         handleInvocationException(e);
+      }
+   }
+
+   protected Method getImplMethod(Class<?> implClass, Method seiMethod) throws ClassNotFoundException, NoSuchMethodException
+   {
+      String methodName = seiMethod.getName();
+      Class<?>[] paramTypes = seiMethod.getParameterTypes();
+      for (int i = 0; i < paramTypes.length; i++)
+      {
+         Class<?> paramType = paramTypes[i];
+         if (JavaUtils.isPrimitive(paramType) == false)
+         {
+            String paramTypeName = paramType.getName();
+            paramType = JavaUtils.loadJavaType(paramTypeName);
+            paramTypes[i] = paramType;
+         }
+      }
+
+      Method implMethod = implClass.getMethod(methodName, paramTypes);
+      return implMethod;
+   }
+}

Added: branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerMDB21.java
===================================================================
--- branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerMDB21.java	                        (rev 0)
+++ branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerMDB21.java	2009-07-30 12:23:04 UTC (rev 91827)
@@ -0,0 +1,85 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.webservices.integration.invocation;
+
+import java.lang.reflect.Method;
+
+import org.jboss.logging.Logger;
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.invocation.Invocation;
+import org.jboss.wsf.spi.invocation.InvocationContext;
+
+/**
+ * Handles invocations on MDB EJB21 endpoints.
+ *
+ * @author Thomas.Diesler at jboss.org
+ */
+public class InvocationHandlerMDB21 extends AbstractInvocationHandler
+{
+   // provide logging
+   private static final Logger log = Logger.getLogger(InvocationHandlerMDB21.class);
+
+   public Invocation createInvocation()
+   {
+      return new Invocation();
+   }
+
+   public void init(Endpoint ep)
+   {
+
+   }
+
+   public void invoke(Endpoint ep, Invocation epInv) throws Exception
+   {
+      log.debug("Invoke: " + epInv.getJavaMethod().getName());
+
+      try
+      {
+         InvocationContext invCtx = epInv.getInvocationContext();
+         Object targetBean = invCtx.getTargetBean();
+         if (targetBean == null)
+         {
+            try
+            {
+               Class epImpl = ep.getTargetBeanClass();
+               targetBean = epImpl.newInstance();
+               invCtx.setTargetBean(targetBean);
+            }
+            catch (Exception ex)
+            {
+               throw new IllegalStateException("Canot get target bean instance", ex);
+            }
+         }
+         Class implClass = targetBean.getClass();
+         Method seiMethod = epInv.getJavaMethod();
+         Method implMethod = getImplMethod(implClass, seiMethod);
+
+         Object[] args = epInv.getArgs();
+         Object retObj = implMethod.invoke(targetBean, args);
+         epInv.setReturnValue(retObj);
+      }
+      catch (Exception e)
+      {
+         handleInvocationException(e);
+      }
+   }
+}

Added: branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerMDB3.java
===================================================================
--- branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerMDB3.java	                        (rev 0)
+++ branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerMDB3.java	2009-07-30 12:23:04 UTC (rev 91827)
@@ -0,0 +1,85 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.webservices.integration.invocation;
+
+import java.lang.reflect.Method;
+
+import org.jboss.logging.Logger;
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.invocation.Invocation;
+import org.jboss.wsf.spi.invocation.InvocationContext;
+
+/**
+ * Handles invocations on MDB EJB3 endpoints.
+ *
+ * @author Thomas.Diesler at jboss.org
+ */
+public class InvocationHandlerMDB3 extends AbstractInvocationHandler
+{
+   // provide logging
+   private static final Logger log = Logger.getLogger(InvocationHandlerMDB3.class);
+
+   public Invocation createInvocation()
+   {
+      return new Invocation();
+   }
+
+   public void init(Endpoint ep)
+   {
+
+   }
+
+   public void invoke(Endpoint ep, Invocation epInv) throws Exception
+   {
+      log.debug("Invoke: " + epInv.getJavaMethod().getName());
+
+      try
+      {
+         InvocationContext invCtx = epInv.getInvocationContext();
+         Object targetBean = invCtx.getTargetBean();
+         if (targetBean == null)
+         {
+            try
+            {
+               Class epImpl = ep.getTargetBeanClass();
+               targetBean = epImpl.newInstance();
+               invCtx.setTargetBean(targetBean);
+            }
+            catch (Exception ex)
+            {
+               throw new IllegalStateException("Canot get target bean instance", ex);
+            }
+         }
+         Class implClass = targetBean.getClass();
+         Method seiMethod = epInv.getJavaMethod();
+         Method implMethod = getImplMethod(implClass, seiMethod);
+
+         Object[] args = epInv.getArgs();
+         Object retObj = implMethod.invoke(targetBean, args);
+         epInv.setReturnValue(retObj);
+      }
+      catch (Exception e)
+      {
+         handleInvocationException(e);
+      }
+   }
+}

Added: branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/invocation/SecurityAdapterFactoryImpl.java
===================================================================
--- branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/invocation/SecurityAdapterFactoryImpl.java	                        (rev 0)
+++ branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/invocation/SecurityAdapterFactoryImpl.java	2009-07-30 12:23:04 UTC (rev 91827)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.webservices.integration.invocation;
+
+import org.jboss.wsf.spi.invocation.SecurityAdaptorFactory;
+import org.jboss.wsf.spi.invocation.SecurityAdaptor;
+
+/**
+ * @author Heiko.Braun at jboss.com
+ */
+public class SecurityAdapterFactoryImpl extends SecurityAdaptorFactory
+{
+   public SecurityAdaptor newSecurityAdapter()
+   {
+      return new SecurityAdaptorImpl();
+   }
+}

Added: branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/invocation/SecurityAdaptorImpl.java
===================================================================
--- branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/invocation/SecurityAdaptorImpl.java	                        (rev 0)
+++ branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/invocation/SecurityAdaptorImpl.java	2009-07-30 12:23:04 UTC (rev 91827)
@@ -0,0 +1,97 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.webservices.integration.invocation;
+
+import org.jboss.security.SecurityAssociation;
+import org.jboss.security.SecurityContext;
+import org.jboss.security.SecurityContextAssociation;
+import org.jboss.wsf.spi.invocation.SecurityAdaptor;
+
+import java.security.AccessController;
+import java.security.Principal;
+import java.security.PrivilegedAction;
+
+import javax.security.auth.Subject;
+
+/**
+ * A JBoss specific SecurityAssociationAdaptor 
+ *
+ * @author Thomas.Diesler at jboss.org
+ */
+public class SecurityAdaptorImpl implements SecurityAdaptor
+{
+   SecurityAdaptorImpl()
+   {
+   }
+
+   public Principal getPrincipal()
+   {
+      return SecurityAssociation.getPrincipal();
+   }
+   
+   public void setPrincipal(Principal pricipal)
+   {
+      SecurityAssociation.setPrincipal(pricipal);
+   }
+
+   public Object getCredential()
+   {
+      return SecurityAssociation.getCredential();
+   }
+
+   public void setCredential(Object credential)
+   {
+      SecurityAssociation.setCredential(credential);
+   }
+
+   public void pushSubjectContext(Subject subject, Principal principal, Object credential)
+   {
+      SecurityAdaptorImpl.pushSubjectContext(principal, credential, subject);
+   }
+
+   private static SecurityContext getSecurityContext()
+   {
+      return (SecurityContext)AccessController.doPrivileged(new PrivilegedAction() {
+         public Object run()
+         {
+            return SecurityContextAssociation.getSecurityContext();
+         }
+      });
+   }
+
+   private static void pushSubjectContext(final Principal p, final Object cred, final Subject s)
+   {
+      AccessController.doPrivileged(new PrivilegedAction() {
+
+         public Object run()
+         {
+            SecurityContext sc = getSecurityContext();
+            if (sc == null)
+               throw new IllegalStateException("Security Context is null");
+            sc.getUtil().createSubjectInfo(p, cred, s);
+            return null;
+         }
+      });
+   }
+
+
+}

Added: branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/invocation/ServiceEndpointInterceptor.java
===================================================================
--- branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/invocation/ServiceEndpointInterceptor.java	                        (rev 0)
+++ branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/invocation/ServiceEndpointInterceptor.java	2009-07-30 12:23:04 UTC (rev 91827)
@@ -0,0 +1,123 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.webservices.integration.invocation;
+
+import org.jboss.ejb.plugins.AbstractInterceptor;
+import org.jboss.invocation.InvocationKey;
+import org.jboss.logging.Logger;
+import org.jboss.wsf.spi.invocation.HandlerCallback;
+import org.jboss.wsf.spi.invocation.Invocation;
+import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedHandlerMetaData.HandlerType;
+
+import javax.xml.rpc.handler.soap.SOAPMessageContext;
+
+/**
+ * This Interceptor does the ws4ee handler processing.
+ * 
+ * According to the ws4ee spec the handler logic must be invoked after the container
+ * applied method level security to the invocation. 
+ *
+ * @author Thomas.Diesler at jboss.org
+ */
+public class ServiceEndpointInterceptor extends AbstractInterceptor
+{
+   // provide logging
+   private static Logger log = Logger.getLogger(ServiceEndpointInterceptor.class);
+
+   // Interceptor implementation --------------------------------------
+
+   /** Before and after we call the service endpoint bean, we process the handler chains.
+    */
+   public Object invoke(final org.jboss.invocation.Invocation jbInv) throws Exception
+   {
+      // If no msgContext, it's not for us
+      SOAPMessageContext msgContext = (SOAPMessageContext)jbInv.getPayloadValue(InvocationKey.SOAP_MESSAGE_CONTEXT);
+      if (msgContext == null)
+      {
+         return getNext().invoke(jbInv);
+      }
+
+      // Get the endpoint invocation 
+      Invocation wsInv = (Invocation)jbInv.getValue(Invocation.class.getName());
+
+      // Get the handler callback 
+      HandlerCallback callback = (HandlerCallback)jbInv.getValue(HandlerCallback.class.getName());
+
+      // Handlers need to be Tx. Therefore we must invoke the handler chain after the TransactionInterceptor.
+      if (callback != null && wsInv != null)
+      {
+         try
+         {
+            // call the request handlers
+            boolean handlersPass = callback.callRequestHandlerChain(wsInv, HandlerType.ENDPOINT);
+            handlersPass = handlersPass && callback.callRequestHandlerChain(wsInv, HandlerType.POST);
+
+            // Call the next interceptor in the chain
+            if (handlersPass)
+            {
+               // The SOAPContentElements stored in the EndpointInvocation might have changed after
+               // handler processing. Get the updated request payload. This should be a noop if request
+               // handlers did not modify the incomming SOAP message.
+               Object[] reqParams = wsInv.getArgs();
+               jbInv.setArguments(reqParams);
+               Object resObj = getNext().invoke(jbInv);
+
+               // Setting the message to null should trigger binding of the response message
+               msgContext.setMessage(null);
+               wsInv.setReturnValue(resObj);
+            }
+
+            // call the response handlers
+            handlersPass = callback.callResponseHandlerChain(wsInv, HandlerType.POST);
+            handlersPass = handlersPass && callback.callResponseHandlerChain(wsInv, HandlerType.ENDPOINT);
+
+            // update the return value after response handler processing
+            Object resObj = wsInv.getReturnValue();
+
+            return resObj;
+         }
+         catch (Exception ex)
+         {
+            try
+            {
+               // call the fault handlers
+               boolean handlersPass = callback.callFaultHandlerChain(wsInv, HandlerType.POST, ex);
+               handlersPass = handlersPass && callback.callFaultHandlerChain(wsInv, HandlerType.ENDPOINT, ex);
+            }
+            catch (Exception subEx)
+            {
+               log.warn("Cannot process handlerChain.handleFault, ignoring: ", subEx);
+            }
+            throw ex;
+         }
+         finally
+         {
+            // do nothing
+         }
+      }
+      else
+      {
+         log.warn("Handler callback not available");
+         return getNext().invoke(jbInv);
+      }
+   }
+}

Added: branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/metadata/ContainerMetaDataDeploymentAspect.java
===================================================================
--- branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/metadata/ContainerMetaDataDeploymentAspect.java	                        (rev 0)
+++ branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/metadata/ContainerMetaDataDeploymentAspect.java	2009-07-30 12:23:04 UTC (rev 91827)
@@ -0,0 +1,83 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.webservices.integration.metadata;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.webservices.integration.util.ASHelper;
+import org.jboss.wsf.common.integration.WSHelper;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.deployment.DeploymentAspect;
+import org.jboss.wsf.spi.metadata.j2ee.EJBArchiveMetaData;
+import org.jboss.wsf.spi.metadata.j2ee.JSEArchiveMetaData;
+
+/**
+ * An aspect that builds container independent meta data. 
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @author <a href="ropalka at redhat.com">Richard Opalka</a>
+ */
+public final class ContainerMetaDataDeploymentAspect extends DeploymentAspect
+{
+   
+   /** JSE meta data builder. */
+   private JSEMetaDataBuilder jseMetaDataBuilder = new JSEMetaDataBuilder();
+   /** EJB3 meta data builder. */
+   private EJB3MetaDataBuilder ejb3MetaDataBuilder = new EJB3MetaDataBuilder();
+   /** EJB21 meta data builder. */
+   private EJB21MetaDataBuilder ejb21MetaDataBuilder = new EJB21MetaDataBuilder();
+
+   /**
+    * Constructor.
+    */
+   public ContainerMetaDataDeploymentAspect()
+   {
+      super();
+   }
+   
+   /**
+    * Build container independent meta data.
+    * 
+    * @param dep webservice deployment
+    */
+   @Override
+   public void start( final Deployment dep )
+   {
+      final DeploymentUnit unit = WSHelper.getRequiredAttachment( dep, DeploymentUnit.class );
+      
+      if ( ASHelper.isJseDeployment( unit ) )
+      {
+         final JSEArchiveMetaData jseMetaData = this.jseMetaDataBuilder.create( dep, unit );
+         dep.addAttachment( JSEArchiveMetaData.class, jseMetaData );
+      }
+      else if ( ASHelper.isJaxwsEjbDeployment( unit ) )
+      {
+         final EJBArchiveMetaData ejbMetaData = this.ejb3MetaDataBuilder.create( dep, unit );
+         dep.addAttachment( EJBArchiveMetaData.class, ejbMetaData );
+      }
+      else if ( ASHelper.isJaxrpcEjbDeployment( unit ) )
+      {
+         final EJBArchiveMetaData ejbMetaData = this.ejb21MetaDataBuilder.create( dep, unit );
+         dep.addAttachment( EJBArchiveMetaData.class, ejbMetaData );
+      }
+   }
+   
+}

Added: branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/metadata/EJB21MetaDataBuilder.java
===================================================================
--- branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/metadata/EJB21MetaDataBuilder.java	                        (rev 0)
+++ branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/metadata/EJB21MetaDataBuilder.java	2009-07-30 12:23:04 UTC (rev 91827)
@@ -0,0 +1,173 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.webservices.integration.metadata;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.common.jboss.WebserviceDescriptionMetaData;
+import org.jboss.metadata.common.jboss.WebserviceDescriptionsMetaData;
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeansMetaData;
+import org.jboss.metadata.ejb.jboss.JBossMessageDrivenBeanMetaData;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+import org.jboss.metadata.ejb.jboss.WebservicesMetaData;
+import org.jboss.metadata.javaee.spec.PortComponent;
+import org.jboss.webservices.integration.util.ASHelper;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.metadata.j2ee.EJBArchiveMetaData;
+import org.jboss.wsf.spi.metadata.j2ee.EJBMetaData;
+import org.jboss.wsf.spi.metadata.j2ee.EJBSecurityMetaData;
+import org.jboss.wsf.spi.metadata.j2ee.MDBMetaData;
+import org.jboss.wsf.spi.metadata.j2ee.SLSBMetaData;
+import org.jboss.wsf.spi.metadata.j2ee.EJBArchiveMetaData.PublishLocationAdapter;
+
+/**
+ * Builds container independent meta data from EJB21 container meta data. 
+ *
+ * @author Thomas.Diesler at jboss.org
+ */
+final class EJB21MetaDataBuilder
+{
+
+   private static Logger log = Logger.getLogger(EJB21MetaDataBuilder.class);
+
+   EJBArchiveMetaData create(Deployment dep, DeploymentUnit unit)
+   {
+      JBossMetaData jbossMetaData = ASHelper.getRequiredAttachment( unit, JBossMetaData.class );
+      dep.addAttachment(JBossMetaData.class, jbossMetaData);
+      
+      EJBArchiveMetaData ejbMetaData = new EJBArchiveMetaData();
+      buildEnterpriseBeansMetaData(ejbMetaData, jbossMetaData);
+      buildWebservicesMetaData(ejbMetaData, jbossMetaData);
+      ejbMetaData.setSecurityDomain(jbossMetaData.getSecurityDomain());
+      
+      return ejbMetaData;
+   }
+
+   private void buildEnterpriseBeansMetaData(EJBArchiveMetaData ejbMetaData, JBossMetaData jbossMetaData)
+   {
+      List<EJBMetaData> targetBeans = new ArrayList<EJBMetaData>();
+      JBossEnterpriseBeansMetaData sourceBeans = jbossMetaData.getEnterpriseBeans();
+      Iterator<JBossEnterpriseBeanMetaData> it = sourceBeans.iterator();
+      while (it.hasNext())
+      {
+         JBossEnterpriseBeanMetaData bmd = it.next();
+         buildBeanMetaData(targetBeans, bmd);
+      }
+      ejbMetaData.setEnterpriseBeans(targetBeans);
+   }
+
+   private void buildWebservicesMetaData(EJBArchiveMetaData ejbMetaData, JBossMetaData jbossMetaData)
+   {
+      WebservicesMetaData webservices = jbossMetaData.getWebservices();
+      if (webservices != null)
+      {
+         String contextRoot = webservices.getContextRoot();
+         ejbMetaData.setWebServiceContextRoot(contextRoot);
+         
+         ejbMetaData.setPublishLocationAdapter(getPublishLocationAdpater(webservices));
+
+         WebserviceDescriptionsMetaData wsDescriptions = webservices.getWebserviceDescriptions();
+         if (wsDescriptions != null)
+         {
+            if (wsDescriptions.size() > 1)
+               log.warn("Multiple <webservice-description> elements not supported");
+
+            if (wsDescriptions.size() > 0)
+            {
+               WebserviceDescriptionMetaData wsd = wsDescriptions.iterator().next();
+               ejbMetaData.setConfigName(wsd.getConfigName());
+               ejbMetaData.setConfigFile(wsd.getConfigFile());
+            }
+         }
+      }
+   }
+
+   private PublishLocationAdapter getPublishLocationAdpater(final WebservicesMetaData wsMetaData)
+   {
+      return new PublishLocationAdapter()
+      {
+         public String getWsdlPublishLocationByName(String name)
+         {
+            String wsdlPublishLocation = null;
+            WebserviceDescriptionsMetaData wsDescriptions = wsMetaData.getWebserviceDescriptions();
+            if (wsDescriptions != null && wsDescriptions.get(name) != null)
+            {
+               WebserviceDescriptionMetaData wsdMetaData = wsDescriptions.get(name);
+               wsdlPublishLocation = wsdMetaData.getWsdlPublishLocation();
+            }
+            return wsdlPublishLocation;
+         }
+      };
+   }
+
+   private EJBMetaData buildBeanMetaData(List<EJBMetaData> ejbBeans, JBossEnterpriseBeanMetaData jbossBeansMetaData)
+   {
+      EJBMetaData targetBean = null;
+      if (jbossBeansMetaData.isSession())
+      {
+         targetBean = new SLSBMetaData();
+         JBossSessionBeanMetaData jbossSessionBean = (JBossSessionBeanMetaData)jbossBeansMetaData;
+         
+         targetBean.setEjbName(jbossSessionBean.getEjbName());
+         targetBean.setEjbClass(jbossSessionBean.getEjbClass());
+         targetBean.setServiceEndpointInterface(jbossSessionBean.getServiceEndpoint());
+         targetBean.setHome(jbossSessionBean.getHome());
+         targetBean.setLocalHome(jbossSessionBean.getLocalHome());
+         targetBean.setJndiName(jbossSessionBean.determineJndiName());
+         targetBean.setLocalJndiName(jbossBeansMetaData.determineLocalJndiName());
+         
+         PortComponent pcmd = jbossSessionBean.getPortComponent();
+         if (pcmd != null)
+         {
+            targetBean.setPortComponentName(pcmd.getPortComponentName());
+            targetBean.setPortComponentURI(pcmd.getPortComponentURI());
+            EJBSecurityMetaData smd = new EJBSecurityMetaData();
+            smd.setAuthMethod(pcmd.getAuthMethod());
+            smd.setTransportGuarantee(pcmd.getTransportGuarantee());
+            smd.setSecureWSDLAccess(pcmd.getSecureWSDLAccess());
+            targetBean.setSecurityMetaData(smd);
+         }
+      }
+      else if (jbossBeansMetaData.isMessageDriven())
+      {
+         targetBean = new MDBMetaData();
+         JBossMessageDrivenBeanMetaData jbossMessageBean = (JBossMessageDrivenBeanMetaData)jbossBeansMetaData;
+         
+         targetBean.setEjbName(jbossMessageBean.getEjbName());
+         targetBean.setEjbClass(jbossMessageBean.getEjbClass());
+         targetBean.setLocalJndiName(jbossBeansMetaData.getLocalJndiName());
+         ((MDBMetaData)targetBean).setDestinationJndiName(jbossMessageBean.getDestinationJndiName());
+      }
+
+      if (targetBean != null)
+         ejbBeans.add(targetBean);
+      
+      return targetBean;
+   }
+
+}

Added: branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/metadata/EJB3MetaDataBuilder.java
===================================================================
--- branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/metadata/EJB3MetaDataBuilder.java	                        (rev 0)
+++ branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/metadata/EJB3MetaDataBuilder.java	2009-07-30 12:23:04 UTC (rev 91827)
@@ -0,0 +1,180 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.webservices.integration.metadata;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.common.jboss.WebserviceDescriptionMetaData;
+import org.jboss.metadata.common.jboss.WebserviceDescriptionsMetaData;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+import org.jboss.metadata.ejb.jboss.WebservicesMetaData;
+import org.jboss.webservices.integration.util.ASHelper;
+import org.jboss.wsf.common.integration.WSHelper;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.deployment.integration.WebServiceDeclaration;
+import org.jboss.wsf.spi.deployment.integration.WebServiceDeployment;
+import org.jboss.wsf.spi.metadata.j2ee.*;
+import org.jboss.wsf.spi.metadata.j2ee.EJBArchiveMetaData.PublishLocationAdapter;
+
+import javax.ejb.ActivationConfigProperty;
+import javax.ejb.MessageDriven;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * Builds container independent meta data from EJB3 container meta data. 
+ *
+ * @author Thomas.Diesler at jboss.org
+ */
+final class EJB3MetaDataBuilder
+{
+
+   private static Logger log = Logger.getLogger(EJB3MetaDataBuilder.class);
+
+   EJBArchiveMetaData create(Deployment dep, DeploymentUnit unit)
+   {     
+      EJBArchiveMetaData umd = new EJBArchiveMetaData();
+
+      WebServiceDeployment webServiceDeployment = WSHelper.getRequiredAttachment( dep, WebServiceDeployment.class );
+      buildEnterpriseBeansMetaData(umd, webServiceDeployment);
+
+      JBossMetaData jbMetaData = ASHelper.getRequiredAttachment( unit, JBossMetaData.class );
+      buildWebservicesMetaData(umd, jbMetaData);
+
+      return umd;
+   }
+
+   private void buildWebservicesMetaData(EJBArchiveMetaData ejbMetaData, JBossMetaData jbMetaData)
+   {
+      WebservicesMetaData wsMetaData = jbMetaData.getWebservices();
+      if (wsMetaData != null)
+      {
+         String contextRoot = wsMetaData.getContextRoot();
+         ejbMetaData.setWebServiceContextRoot(contextRoot);
+
+         ejbMetaData.setPublishLocationAdapter(getPublishLocationAdpater(wsMetaData));
+
+         WebserviceDescriptionsMetaData wsDescriptions = wsMetaData.getWebserviceDescriptions();
+         if (wsDescriptions != null)
+         {
+            if (wsDescriptions.size() > 1)
+               log.warn("Multiple <webservice-description> elements not supported");
+
+            if (wsDescriptions.size() > 0)
+            {
+               WebserviceDescriptionMetaData wsd = wsDescriptions.iterator().next();
+               ejbMetaData.setConfigName(wsd.getConfigName());
+               ejbMetaData.setConfigFile(wsd.getConfigFile());
+            }
+         }
+      }
+   }
+
+   private void buildEnterpriseBeansMetaData(EJBArchiveMetaData jarMetaData, WebServiceDeployment ejb3Deployment)
+   {
+      List<EJBMetaData> ejbMetaDataList = new ArrayList<EJBMetaData>();
+      Iterator<WebServiceDeclaration> it = ejb3Deployment.getServiceEndpoints().iterator();
+      while (it.hasNext())
+      {
+         WebServiceDeclaration container = it.next();
+
+         PortComponentSpec pcMetaData = container.getAnnotation(PortComponentSpec.class);
+         MessageDriven mdbMetaData = container.getAnnotation(MessageDriven.class);
+
+         EJBMetaData ejbMetaData = null;
+
+         if(mdbMetaData!=null)
+         {
+            ejbMetaData = new MDBMetaData();
+
+            ActivationConfigProperty[] props = mdbMetaData.activationConfig();
+            if (props != null)
+            {
+               String destination = getActivationProperty("destination", props);
+               if (destination != null)
+               {                  
+                  ((MDBMetaData)ejbMetaData).setDestinationJndiName(destination);
+               }
+            }
+         }
+         else
+         {
+            ejbMetaData = new SLSBMetaData();
+         }
+
+         if (ejbMetaData != null)
+         {
+            ejbMetaData.setEjbName(container.getComponentName());
+            ejbMetaData.setEjbClass(container.getComponentClassName());
+
+            if (pcMetaData != null)
+            {
+               ejbMetaData.setPortComponentName(pcMetaData.portComponentName());
+               ejbMetaData.setPortComponentURI(pcMetaData.portComponentURI());
+               EJBSecurityMetaData smd = new EJBSecurityMetaData();
+               smd.setAuthMethod(pcMetaData.authMethod());
+               smd.setTransportGuarantee(pcMetaData.transportGuarantee());
+               smd.setSecureWSDLAccess(pcMetaData.secureWSDLAccess());
+               ejbMetaData.setSecurityMetaData(smd);
+            }
+            
+            ejbMetaDataList.add(ejbMetaData);
+         }
+      }
+      
+      jarMetaData.setEnterpriseBeans(ejbMetaDataList);
+   }
+
+   private String getActivationProperty(String name, ActivationConfigProperty[] props)
+   {
+      String result = null;
+      for(ActivationConfigProperty p : props)
+      {
+         if(p.propertyName().equals(name))
+         {
+            result = p.propertyValue();
+            break;
+         }
+      }
+
+      return result;
+   }
+
+   private PublishLocationAdapter getPublishLocationAdpater(final WebservicesMetaData wsMetaData)
+   {
+      return new PublishLocationAdapter() {
+         public String getWsdlPublishLocationByName(String name)
+         {
+            String wsdlPublishLocation = null;
+            WebserviceDescriptionsMetaData wsDescriptions = wsMetaData.getWebserviceDescriptions();
+            if (wsDescriptions != null && wsDescriptions.get(name) != null)
+            {
+               WebserviceDescriptionMetaData wsdMetaData = wsDescriptions.get(name);
+               wsdlPublishLocation = wsdMetaData.getWsdlPublishLocation();
+            }
+            return wsdlPublishLocation;
+         }
+      };
+   }
+
+}

Added: branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/metadata/JSEMetaDataBuilder.java
===================================================================
--- branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/metadata/JSEMetaDataBuilder.java	                        (rev 0)
+++ branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/metadata/JSEMetaDataBuilder.java	2009-07-30 12:23:04 UTC (rev 91827)
@@ -0,0 +1,204 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.webservices.integration.metadata;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.common.jboss.WebserviceDescriptionMetaData;
+import org.jboss.metadata.common.jboss.WebserviceDescriptionsMetaData;
+import org.jboss.metadata.ear.jboss.JBossAppMetaData;
+import org.jboss.metadata.ear.spec.ModuleMetaData;
+import org.jboss.metadata.ear.spec.WebModuleMetaData;
+import org.jboss.metadata.javaee.spec.ParamValueMetaData;
+import org.jboss.metadata.web.jboss.JBossServletsMetaData;
+import org.jboss.metadata.web.jboss.JBossWebMetaData;
+import org.jboss.metadata.web.spec.SecurityConstraintMetaData;
+import org.jboss.metadata.web.spec.ServletMappingMetaData;
+import org.jboss.metadata.web.spec.ServletMetaData;
+import org.jboss.metadata.web.spec.WebResourceCollectionMetaData;
+import org.jboss.metadata.web.spec.WebResourceCollectionsMetaData;
+import org.jboss.webservices.integration.util.ASHelper;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.metadata.j2ee.JSEArchiveMetaData;
+import org.jboss.wsf.spi.metadata.j2ee.JSESecurityMetaData;
+import org.jboss.wsf.spi.metadata.j2ee.JSEArchiveMetaData.PublishLocationAdapter;
+import org.jboss.wsf.spi.metadata.j2ee.JSESecurityMetaData.JSEResourceCollection;
+
+/**
+ * Builds container independent meta data from WEB container meta data. 
+ *
+ * @author Thomas.Diesler at jboss.org
+ */
+final class JSEMetaDataBuilder
+{
+
+   private static Logger log = Logger.getLogger(JSEMetaDataBuilder.class);
+   
+   JSEArchiveMetaData create(Deployment dep, DeploymentUnit unit)
+   {
+      String contextRoot = null;
+      
+      JBossWebMetaData jbossWebMetaData = ASHelper.getRequiredAttachment( unit, JBossWebMetaData.class );
+
+      if (unit.getParent() != null)
+      {
+         JBossAppMetaData appmd = ASHelper.getOptionalAttachment( unit.getParent(), JBossAppMetaData.class );
+         if (appmd != null)
+         {
+            ModuleMetaData module = appmd.getModule(dep.getSimpleName());
+            if (module != null)
+            {
+               WebModuleMetaData web = (WebModuleMetaData) module.getValue();
+               contextRoot = web.getContextRoot();
+            }
+         }
+      }
+      
+      if (contextRoot == null)
+         contextRoot = jbossWebMetaData.getContextRoot();
+      
+      JSEArchiveMetaData umd = new JSEArchiveMetaData();
+      umd.setContextRoot(contextRoot);
+      umd.setServletMappings(getServletMappings(jbossWebMetaData));
+      umd.setServletClassNames(getServletClassMap(jbossWebMetaData));
+      umd.setSecurityDomain(jbossWebMetaData.getSecurityDomain());
+      umd.setPublishLocationAdapter(getPublishLocationAdpater(jbossWebMetaData));
+      umd.setSecurityMetaData(getSecurityMetaData(jbossWebMetaData.getSecurityContraints()));
+
+      setConfigNameAndFile(umd, jbossWebMetaData);
+      
+      return umd;
+   }
+
+   private void setConfigNameAndFile(JSEArchiveMetaData umd, JBossWebMetaData jbossWebMetaData)
+   {
+      String configName = null;
+      String configFile = null;
+      
+      WebserviceDescriptionsMetaData wsDescriptions = jbossWebMetaData.getWebserviceDescriptions();
+      if (wsDescriptions != null && wsDescriptions.size() > 1)
+         log.warn("Multiple <webservice-description> elements not supported");
+
+      if (wsDescriptions != null && wsDescriptions.size() > 0)
+      {
+         WebserviceDescriptionMetaData wsd = wsDescriptions.iterator().next();
+         configName = wsd.getConfigName();
+         configFile = wsd.getConfigFile();
+      }
+
+      List<ParamValueMetaData> contextParams = jbossWebMetaData.getContextParams();
+      if (contextParams != null)
+      {
+         for (ParamValueMetaData ctxParam : contextParams)
+         {
+            if (ctxParam.getParamName().equals("jbossws-config-name"))
+               configName = ctxParam.getParamValue();
+            if (ctxParam.getParamName().equals("jbossws-config-file"))
+               configFile = ctxParam.getParamValue();
+         }
+      }
+      
+      umd.setConfigName(configName);
+      umd.setConfigFile(configFile);
+   }
+
+   private PublishLocationAdapter getPublishLocationAdpater(final JBossWebMetaData wmd)
+   {
+      return new PublishLocationAdapter()
+      {
+         public String getWsdlPublishLocationByName(String name)
+         {
+            WebserviceDescriptionsMetaData wsdmd = wmd.getWebserviceDescriptions();
+            WebserviceDescriptionMetaData wsmd = wsdmd.get(name);
+            String location = null;
+            if (wsmd != null)
+               location = wsmd.getWsdlPublishLocation();
+            return location;
+         }
+      };
+   }
+
+   private List<JSESecurityMetaData> getSecurityMetaData(final List<SecurityConstraintMetaData> securityConstraints)
+   {
+      ArrayList<JSESecurityMetaData> unifiedsecurityMetaData = new ArrayList<JSESecurityMetaData>();
+      if (securityConstraints != null)
+      {
+         for (SecurityConstraintMetaData securityMetaData : securityConstraints)
+         {
+            JSESecurityMetaData current = new JSESecurityMetaData();
+            unifiedsecurityMetaData.add(current);
+
+            current.setTransportGuarantee(securityMetaData.getTransportGuarantee().name());
+
+            WebResourceCollectionsMetaData resources = securityMetaData.getResourceCollections();
+            for (WebResourceCollectionMetaData webResource : resources)
+            {
+               JSEResourceCollection currentResource = current.addWebResource(webResource.getName());
+               for (String currentPattern : webResource.getUrlPatterns())
+               {
+                  currentResource.addPattern(currentPattern);
+               }
+            }
+         }
+      }
+      return unifiedsecurityMetaData;
+   }
+
+   private Map<String, String> getServletMappings(JBossWebMetaData wmd)
+   {
+      Map<String, String> mappings = new HashMap<String, String>();
+      List<ServletMappingMetaData> smappings = wmd.getServletMappings();
+      if (smappings != null)
+      {
+         for(ServletMappingMetaData mapping : smappings)
+         {
+            // FIXME - Add support for multiple mappings
+            mappings.put(mapping.getServletName(), mapping.getUrlPatterns().get(0));
+         }
+      }
+      return mappings;
+   }
+
+   private Map<String, String> getServletClassMap(JBossWebMetaData wmd)
+   {
+      Map<String, String> mappings = new HashMap<String, String>();
+      JBossServletsMetaData servlets = wmd.getServlets();
+      if (servlets != null)
+      {
+         for (ServletMetaData servlet : servlets)
+         {
+            // Skip JSPs
+            if (servlet.getServletClass() == null || servlet.getServletClass().length() == 0)
+               continue;
+   
+            mappings.put(servlet.getName(), servlet.getServletClass());
+         }
+      }
+      return mappings;
+   }
+
+}

Added: branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/security/JACCPermissionsDeploymentAspect.java
===================================================================
--- branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/security/JACCPermissionsDeploymentAspect.java	                        (rev 0)
+++ branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/security/JACCPermissionsDeploymentAspect.java	2009-07-30 12:23:04 UTC (rev 91827)
@@ -0,0 +1,81 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.webservices.integration.security;
+
+import javax.security.jacc.PolicyConfiguration;
+import javax.security.jacc.PolicyConfigurationFactory;
+
+import org.jboss.metadata.web.jboss.JBossWebMetaData;
+import org.jboss.web.WebPermissionMapping;
+import org.jboss.wsf.common.integration.WSHelper;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.deployment.DeploymentAspect;
+
+/**
+ * Generates JACC permissions. (This is temporary and really hacky solution). 
+ * 
+ * TODO: remove this deployment aspect and update 
+ * particular JACC deployer to execute after 
+ * JBossWS has modified web meta data. 
+ *
+ * @author <a href="mailto:ropalka at redhat.com">Richard Opalka</a>
+ */
+public final class JACCPermissionsDeploymentAspect extends DeploymentAspect
+{
+
+   /**
+    * Constructor.
+    */
+   public JACCPermissionsDeploymentAspect()
+   {
+      super();
+   }
+   
+   /**
+    * JBAS-5935: The dynamic web application generated by the JBossWS
+    * does not go through the war security deployer. Hence the JACC
+    * permissions are not created. There is a need to explicitly create
+    * the war jacc permissions.
+    * 
+    * @param dep webservice deployment
+    */
+   public void start( final Deployment dep )
+   {
+      final JBossWebMetaData jbossWebMD = WSHelper.getRequiredAttachment( dep, JBossWebMetaData.class );
+      
+      try
+      {
+         final PolicyConfigurationFactory policyConfigurationFactory = 
+            PolicyConfigurationFactory.getPolicyConfigurationFactory();
+         final PolicyConfiguration policyConfiguration = 
+            policyConfigurationFactory.getPolicyConfiguration( dep.getSimpleName(), false );
+
+         WebPermissionMapping.createPermissions( jbossWebMD, policyConfiguration );
+         policyConfiguration.commit();
+      }
+      catch ( Exception e )
+      {
+         throw new RuntimeException( "Exception generating JACC perms: ", e );
+      }
+   }
+
+}

Added: branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/tomcat/SecurityHandler.java
===================================================================
--- branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/tomcat/SecurityHandler.java	                        (rev 0)
+++ branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/tomcat/SecurityHandler.java	2009-07-30 12:23:04 UTC (rev 91827)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.webservices.integration.tomcat;
+
+import org.jboss.metadata.web.jboss.JBossWebMetaData;
+import org.jboss.wsf.spi.deployment.Deployment;
+
+/**
+ * Handle web app security meta data 
+ * 
+ * @author Thomas.Diesler at jboss.org
+ */
+public interface SecurityHandler
+{
+   /** Add the security domain to jboss-web.xml */
+   void addSecurityDomain(JBossWebMetaData jbossWeb, Deployment dep);
+   
+   /** Add the security roles to web.xml */
+   void addSecurityRoles(JBossWebMetaData webApp, Deployment dep);
+}

Added: branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/tomcat/SecurityHandlerEJB21.java
===================================================================
--- branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/tomcat/SecurityHandlerEJB21.java	                        (rev 0)
+++ branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/tomcat/SecurityHandlerEJB21.java	2009-07-30 12:23:04 UTC (rev 91827)
@@ -0,0 +1,65 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.webservices.integration.tomcat;
+
+import org.jboss.metadata.common.ejb.IAssemblyDescriptorMetaData;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+import org.jboss.metadata.javaee.spec.SecurityRolesMetaData;
+import org.jboss.metadata.web.jboss.JBossWebMetaData;
+import org.jboss.wsf.common.integration.WSHelper;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.metadata.j2ee.EJBArchiveMetaData;
+
+/**
+ * Handle web app security meta data for EJB21 
+ * 
+ * @author Thomas.Diesler at jboss.org
+ * @author <a href="ropalka at redhat.com">Richard Opalka</a>
+ */
+public class SecurityHandlerEJB21 implements SecurityHandler
+{
+   public void addSecurityDomain(JBossWebMetaData jbossWeb, Deployment dep)
+   {
+      EJBArchiveMetaData ejbMetaData = WSHelper.getRequiredAttachment( dep, EJBArchiveMetaData.class );
+
+      String securityDomain = ejbMetaData.getSecurityDomain();
+      if (securityDomain != null)
+      {
+         if (securityDomain.startsWith("java:/jaas/") == false)
+            securityDomain = "java:/jaas/" + securityDomain;
+
+         jbossWeb.setSecurityDomain(securityDomain);
+      }
+   }
+
+   public void addSecurityRoles(JBossWebMetaData webApp, Deployment dep)
+   {
+      JBossMetaData jbmd = WSHelper.getRequiredAttachment( dep, JBossMetaData.class );
+      IAssemblyDescriptorMetaData assemblyDescriptor = jbmd.getAssemblyDescriptor();
+      if (assemblyDescriptor != null)
+      {
+         SecurityRolesMetaData securityRoles = assemblyDescriptor.getSecurityRoles();
+         if (securityRoles != null)
+            webApp.setSecurityRoles(securityRoles);
+      }
+   }
+}

Added: branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/tomcat/SecurityHandlerEJB3.java
===================================================================
--- branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/tomcat/SecurityHandlerEJB3.java	                        (rev 0)
+++ branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/tomcat/SecurityHandlerEJB3.java	2009-07-30 12:23:04 UTC (rev 91827)
@@ -0,0 +1,94 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.webservices.integration.tomcat;
+
+import org.jboss.ejb3.annotation.SecurityDomain;
+import org.jboss.metadata.javaee.spec.SecurityRoleMetaData;
+import org.jboss.metadata.javaee.spec.SecurityRolesMetaData;
+import org.jboss.metadata.web.jboss.JBossWebMetaData;
+import org.jboss.wsf.common.integration.WSHelper;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.deployment.integration.WebServiceDeclaration;
+import org.jboss.wsf.spi.deployment.integration.WebServiceDeployment;
+
+import javax.annotation.security.RolesAllowed;
+import java.util.Iterator;
+
+/**
+ * Handle web app security meta data for EJB3 
+ * 
+ * @author Thomas.Diesler at jboss.org
+ * @author <a href="ropalka at redhat.com">Richard Opalka</a>
+ */
+public class SecurityHandlerEJB3 implements SecurityHandler
+{
+   public void addSecurityDomain(JBossWebMetaData jbossWeb, Deployment dep)
+   {
+      WebServiceDeployment webServiceDeployment = WSHelper.getRequiredAttachment( dep, WebServiceDeployment.class );
+      String securityDomain = null;
+      Iterator<WebServiceDeclaration> it = webServiceDeployment.getServiceEndpoints().iterator();
+
+      while (it.hasNext())
+      {
+         WebServiceDeclaration container = it.next();
+         SecurityDomain anSecurityDomain = container.getAnnotation(SecurityDomain.class);
+         if (anSecurityDomain != null)
+         {
+            if (securityDomain != null && !securityDomain.equals(anSecurityDomain.value()))
+               throw new IllegalStateException("Multiple security domains not supported");
+
+            securityDomain = anSecurityDomain.value();
+         }
+      }
+
+      if (securityDomain != null)
+      {
+         if (securityDomain.startsWith("java:/jaas/") == false)
+            securityDomain = "java:/jaas/" + securityDomain;
+
+         jbossWeb.setSecurityDomain(securityDomain);
+      }
+   }
+
+   public void addSecurityRoles(JBossWebMetaData webApp, Deployment dep)
+   {
+      WebServiceDeployment webServiceDeployment = WSHelper.getRequiredAttachment( dep, WebServiceDeployment.class );
+
+      Iterator<WebServiceDeclaration> it = webServiceDeployment.getServiceEndpoints().iterator();
+      while (it.hasNext())
+      {
+         WebServiceDeclaration container = it.next();
+         RolesAllowed anRolesAllowed = container.getAnnotation(RolesAllowed.class);
+         if (anRolesAllowed != null)
+         {
+            SecurityRolesMetaData securityRoles = webApp.getSecurityRoles();
+            for (String roleName : anRolesAllowed.value())
+            {
+               SecurityRoleMetaData role = new SecurityRoleMetaData();
+               role.setRoleName(roleName);
+               securityRoles.add(role);
+            }
+         }
+      }
+   }
+
+}

Added: branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/tomcat/WebAppGeneratorDeploymentAspect.java
===================================================================
--- branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/tomcat/WebAppGeneratorDeploymentAspect.java	                        (rev 0)
+++ branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/tomcat/WebAppGeneratorDeploymentAspect.java	2009-07-30 12:23:04 UTC (rev 91827)
@@ -0,0 +1,285 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.webservices.integration.tomcat;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.metadata.web.jboss.JBossServletMetaData;
+import org.jboss.metadata.web.jboss.JBossServletsMetaData;
+import org.jboss.metadata.web.jboss.JBossWebMetaData;
+import org.jboss.metadata.web.spec.AuthConstraintMetaData;
+import org.jboss.metadata.web.spec.LoginConfigMetaData;
+import org.jboss.metadata.web.spec.SecurityConstraintMetaData;
+import org.jboss.metadata.web.spec.ServletMappingMetaData;
+import org.jboss.metadata.web.spec.TransportGuaranteeType;
+import org.jboss.metadata.web.spec.UserDataConstraintMetaData;
+import org.jboss.metadata.web.spec.WebResourceCollectionMetaData;
+import org.jboss.metadata.web.spec.WebResourceCollectionsMetaData;
+import org.jboss.wsf.common.integration.WSHelper;
+import org.jboss.wsf.spi.annotation.WebContext;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.deployment.DeploymentAspect;
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.metadata.j2ee.EJBArchiveMetaData;
+import org.jboss.wsf.spi.metadata.j2ee.EJBMetaData;
+import org.jboss.wsf.spi.metadata.j2ee.EJBSecurityMetaData;
+
+/**
+ * A deployment aspect that generates a webapp for an EJB endpoint 
+ * 
+ * @author Thomas.Diesler at jboss.org
+ */
+public class WebAppGeneratorDeploymentAspect extends DeploymentAspect
+{
+   private SecurityHandler securityHandlerEJB21;
+   private SecurityHandler securityHandlerEJB3;
+
+   public void setSecurityHandlerEJB21(SecurityHandler handler)
+   {
+      this.securityHandlerEJB21 = handler;
+   }
+
+   public void setSecurityHandlerEJB3(SecurityHandler handler)
+   {
+      this.securityHandlerEJB3 = handler;
+   }
+
+   @Override
+   public void start(Deployment dep)
+   {
+      final DeploymentUnit unit = WSHelper.getRequiredAttachment( dep, DeploymentUnit.class );
+      
+      if ( WSHelper.isJaxrpcEjbDeployment( dep ) )
+      {
+         JBossWebMetaData jbwmd = generateWebDeployment(dep, securityHandlerEJB21);
+         dep.addAttachment(JBossWebMetaData.class, jbwmd);
+         unit.addAttachment(JBossWebMetaData.class, jbwmd);
+      }
+      else if ( WSHelper.isJaxwsEjbDeployment( dep ) )
+      {
+         JBossWebMetaData jbwmd = generateWebDeployment(dep, securityHandlerEJB3);
+         dep.addAttachment(JBossWebMetaData.class, jbwmd);
+         unit.addAttachment(JBossWebMetaData.class, jbwmd);
+      }
+   }
+
+   protected JBossWebMetaData generateWebDeployment(Deployment dep, SecurityHandler securityHandler)
+   {
+      JBossWebMetaData jbwmd = new JBossWebMetaData();
+      createWebAppDescriptor(dep, jbwmd, securityHandler);
+      createJBossWebAppDescriptor(dep, jbwmd, securityHandler);
+      return jbwmd;
+   }
+
+   protected void createWebAppDescriptor(Deployment dep, JBossWebMetaData jbwmd, SecurityHandler securityHandler)
+   {
+      /*
+       <servlet>
+       <servlet-name>
+       <servlet-class>
+       </servlet>
+       */
+      JBossServletsMetaData servlets = jbwmd.getServlets();
+      for (Endpoint ep : dep.getService().getEndpoints())
+      {
+         JBossServletMetaData servlet = new JBossServletMetaData();
+         servlet.setServletName(ep.getShortName());
+         servlet.setServletClass(ep.getTargetBeanName());
+         servlets.add(servlet);
+      }
+
+      /*
+       <servlet-mapping>
+       <servlet-name>
+       <url-pattern>
+       </servlet-mapping>
+       */
+      for (Endpoint ep : dep.getService().getEndpoints())
+      {
+         List<ServletMappingMetaData> servletMappings = jbwmd.getServletMappings();
+         if (servletMappings == null)
+         {
+            servletMappings = new ArrayList<ServletMappingMetaData>();
+            jbwmd.setServletMappings(servletMappings);
+         }
+         ServletMappingMetaData servletMapping = new ServletMappingMetaData();
+         servletMapping.setServletName(ep.getShortName());
+         servletMapping.setUrlPatterns(Arrays.asList(new String[] { ep.getURLPattern() }));
+         servletMappings.add(servletMapping);
+      }
+
+      String authMethod = null;
+
+      // Add web-app/security-constraint for each port component
+      for (Endpoint ep : dep.getService().getEndpoints())
+      {
+         String ejbName = ep.getShortName();
+
+         Boolean secureWSDLAccess = null;
+         String transportGuarantee = null;
+         String beanAuthMethod = null;
+
+         WebContext anWebContext = (WebContext)ep.getTargetBeanClass().getAnnotation(WebContext.class);
+         if (anWebContext != null)
+         {
+            if (anWebContext.authMethod().length() > 0)
+               beanAuthMethod = anWebContext.authMethod();
+            if (anWebContext.transportGuarantee().length() > 0)
+               transportGuarantee = anWebContext.transportGuarantee();
+            if (anWebContext.secureWSDLAccess())
+               secureWSDLAccess = anWebContext.secureWSDLAccess();
+         }
+
+         EJBArchiveMetaData appMetaData = WSHelper.getOptionalAttachment( dep, EJBArchiveMetaData.class );
+         if (appMetaData != null && appMetaData.getBeanByEjbName(ejbName) != null)
+         {
+            EJBMetaData bmd = appMetaData.getBeanByEjbName(ejbName);
+            EJBSecurityMetaData smd = bmd.getSecurityMetaData();
+            if (smd != null)
+            {
+               beanAuthMethod = smd.getAuthMethod();
+               transportGuarantee = smd.getTransportGuarantee();
+               secureWSDLAccess = smd.getSecureWSDLAccess();
+            }
+         }
+
+         if (beanAuthMethod != null || transportGuarantee != null)
+         {
+            /*
+             <security-constraint>
+             <web-resource-collection>
+             <web-resource-name>TestUnAuthPort</web-resource-name>
+             <url-pattern>/HSTestRoot/TestUnAuth/*</url-pattern>
+             </web-resource-collection>
+             <auth-constraint>
+             <role-name>*</role-name>
+             </auth-constraint>
+             <user-data-constraint>
+             <transport-guarantee>NONE</transport-guarantee>
+             </user-data-constraint>
+             </security-constraint>
+             */
+            List<SecurityConstraintMetaData> securityContraints = jbwmd.getSecurityContraints();
+            if (securityContraints == null)
+            {
+               securityContraints = new ArrayList<SecurityConstraintMetaData>();
+               jbwmd.setSecurityContraints(securityContraints);
+            }
+            SecurityConstraintMetaData securityConstraint = new SecurityConstraintMetaData();
+            securityContraints.add(securityConstraint);
+            
+            WebResourceCollectionsMetaData resourceCollections = securityConstraint.getResourceCollections();
+            if (resourceCollections == null)
+            {
+               resourceCollections = new WebResourceCollectionsMetaData();
+               securityConstraint.setResourceCollections(resourceCollections);
+            }
+            WebResourceCollectionMetaData resourceCollection = new WebResourceCollectionMetaData();
+            resourceCollections.add(resourceCollection);
+            
+            resourceCollection.setWebResourceName(ejbName);
+            resourceCollection.setUrlPatterns(Arrays.asList(new String[] { ep.getURLPattern() }));
+            ArrayList<String> httpMethods = new ArrayList<String>();
+            resourceCollection.setHttpMethods(httpMethods);
+            if (Boolean.TRUE.equals(secureWSDLAccess))
+            {
+               httpMethods.add("GET");
+            }
+            httpMethods.add("POST");
+
+            // Optional auth-constraint
+            if (beanAuthMethod != null)
+            {
+               // Only the first auth-method gives the war login-config/auth-method
+               if (authMethod == null)
+                  authMethod = beanAuthMethod;
+
+               AuthConstraintMetaData authConstraint = new AuthConstraintMetaData();
+               authConstraint.setRoleNames(Arrays.asList(new String[] { "*" }));
+               securityConstraint.setAuthConstraint(authConstraint);
+            }
+            // Optional user-data-constraint
+            if (transportGuarantee != null)
+            {
+               UserDataConstraintMetaData userDataConstraint = new UserDataConstraintMetaData();
+               userDataConstraint.setTransportGuarantee(TransportGuaranteeType.valueOf(transportGuarantee));
+               securityConstraint.setUserDataConstraint(userDataConstraint);
+            }
+         }
+      }
+
+      // Optional login-config/auth-method
+      if (authMethod != null && securityHandler != null)
+      {
+         LoginConfigMetaData loginConfig = jbwmd.getLoginConfig();
+         if (loginConfig == null)
+         {
+            loginConfig = new LoginConfigMetaData();
+            jbwmd.setLoginConfig(loginConfig);
+         }
+         loginConfig.setAuthMethod(authMethod);
+         loginConfig.setRealmName("EJBServiceEndpointServlet Realm");
+
+         securityHandler.addSecurityRoles(jbwmd, dep);
+      }
+   }
+
+   /**
+    * Creates jboss-web meta data.
+    * 
+    * <jboss-web>
+    *   <security-domain>java:/jaas/custom-security-domain</security-domain>
+    *   <context-root>/custom-context-root</context-root>
+    *   <virtual-host>custom-virtual-host</virtual-host>
+    * </jboss-web>
+    *
+    * @param dep 
+    * @param jbwmd
+    * @param securityHandler
+    */
+   protected void createJBossWebAppDescriptor
+   ( 
+      final Deployment dep, final JBossWebMetaData jbossWebMD, final SecurityHandler securityHandler
+   )
+   {
+      // Set security domain
+      if (securityHandler != null)
+      {
+         securityHandler.addSecurityDomain(jbossWebMD, dep);
+      }
+
+      // Set context root
+      String contextRoot = dep.getService().getContextRoot();
+      jbossWebMD.setContextRoot(contextRoot);
+
+      // Set virtual hosts
+      String[] virtualHosts = dep.getService().getVirtualHosts();
+      if (virtualHosts != null && virtualHosts.length > 0)
+      {
+         jbossWebMD.setVirtualHosts(Arrays.asList(virtualHosts));
+      }
+   }
+
+}

Added: branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/tomcat/WebMetaDataModifier.java
===================================================================
--- branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/tomcat/WebMetaDataModifier.java	                        (rev 0)
+++ branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/tomcat/WebMetaDataModifier.java	2009-07-30 12:23:04 UTC (rev 91827)
@@ -0,0 +1,199 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.webservices.integration.tomcat;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.metadata.javaee.spec.ParamValueMetaData;
+import org.jboss.metadata.web.jboss.JBossServletMetaData;
+import org.jboss.metadata.web.jboss.JBossWebMetaData;
+import org.jboss.metadata.web.spec.ServletMetaData;
+import org.jboss.webservices.integration.util.ASHelper;
+import org.jboss.wsf.common.integration.WSConstants;
+import org.jboss.wsf.common.integration.WSHelper;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.deployment.Endpoint;
+
+/**
+ * The modifier of jboss web meta data. 
+ * It configures WS transport for every webservice endpoint
+ * plus propagates WS stack specific context parameters if required.
+ *
+ * @author <a href="mailto:ropalka at redhat.com">Richard Opalka</a>
+ */
+public final class WebMetaDataModifier
+{
+
+   /**
+    * Constructor.
+    */
+   public WebMetaDataModifier()
+   {
+      super();
+   }
+
+   /**
+    * Modifies web meta data to configure webservice stack transport and properties.
+    * 
+    * @param dep webservice deployment
+    */
+   public void modify( final Deployment dep )
+   {
+      final JBossWebMetaData jbossWebMD = WSHelper.getRequiredAttachment( dep, JBossWebMetaData.class );
+
+      this.propagateContextProps( dep, jbossWebMD );
+      this.configureEndpoints( dep, jbossWebMD );
+   }
+
+   /**
+    * Propagates stack specific context parameters if specified. 
+    * 
+    * @param dep webservice deployment
+    * @param jbossWebMD web meta data
+    */
+   @SuppressWarnings( "unchecked" )
+   private void propagateContextProps( final Deployment dep, final JBossWebMetaData jbossWebMD )
+   {
+      final Map< String, String > stackContextParams = ( Map< String, String > )
+          dep.getProperty( WSConstants.STACK_CONTEXT_PARAMS );
+      
+      if ( stackContextParams != null )
+      {
+         final List< ParamValueMetaData > contextParams = this.getContextParams( jbossWebMD );
+
+         for ( Map.Entry< String, String > entry : stackContextParams.entrySet() )
+         {
+            final ParamValueMetaData newParam = this.newParameter( entry.getKey(), entry.getValue() );
+            contextParams.add( newParam );
+         }
+      }
+   }
+
+   /**
+    * Configures transport servlet class for every found webservice endpoint. 
+    * 
+    * @param dep webservice deployment
+    * @param jbossWebMD web meta data
+    */
+   private void configureEndpoints( final Deployment dep, final JBossWebMetaData jbossWebMD )
+   {
+      final Iterator< JBossServletMetaData > servlets = jbossWebMD.getServlets().iterator();
+      
+      while ( servlets.hasNext() )
+      {
+         final ServletMetaData servletMD = servlets.next();
+         final ClassLoader loader = dep.getInitialClassLoader();
+         final boolean isWebserviceEndpoint = ASHelper.getEndpointClass( servletMD, loader ) != null;
+
+         if ( isWebserviceEndpoint )
+         {
+            // set transport servlet
+            servletMD.setServletClass( this.getTransportClassName( dep ) );
+
+            // configure webservice endpoint
+            final String endpointClassName = servletMD.getServletClass();
+            final List< ParamValueMetaData > initParams = this.getServletInitParams( servletMD );
+            final ParamValueMetaData endpointParam = this.newParameter( 
+               Endpoint.SEPID_DOMAIN_ENDPOINT, endpointClassName ); 
+            
+            initParams.add( endpointParam );
+         }
+      }
+   }
+   
+   /**
+    * Returns stack specific transport class name.
+    * 
+    * @param dep webservice deployment
+    * @return stack specific transport class name
+    * @throws IllegalStateException if transport class name is not found in deployment properties map
+    */
+   private String getTransportClassName( final Deployment dep )
+   {
+      final String transportClassName = ( String ) dep.getProperty( WSConstants.STACK_TRANSPORT_CLASS );
+      
+      if ( transportClassName == null )
+      {
+         throw new IllegalStateException( "Cannot obtain deployment property: " + WSConstants.STACK_TRANSPORT_CLASS );
+      }
+      
+      return transportClassName;
+   }
+   
+   /**
+    * Creates new parameter with specified key and value.
+    * 
+    * @param key the key
+    * @param value the value
+    * @return new parameter
+    */
+   private ParamValueMetaData newParameter( final String key, final String value )
+   {
+      final ParamValueMetaData paramMD = new ParamValueMetaData();
+      paramMD.setParamName( key );
+      paramMD.setParamValue( value );
+      
+      return paramMD;
+   }
+   
+   /**
+    * Gets servlet init params list. Constructs new init params list if it does not exist yet.
+    * 
+    * @param servletMD servlet meta data
+    * @return servlet init params list
+    */
+   private List< ParamValueMetaData > getServletInitParams( final ServletMetaData servletMD )
+   {
+      List< ParamValueMetaData > initParams = servletMD.getInitParam();
+
+      if ( initParams == null )
+      {
+         initParams = new ArrayList< ParamValueMetaData >();
+         servletMD.setInitParam( initParams );
+      }
+      
+      return initParams;
+   }
+
+   /**
+    * Gets context params list. Constructs new context params list if it does not exist yet.
+    * 
+    * @param jbossWebMD web meta data
+    * @return context params list
+    */
+   private List< ParamValueMetaData > getContextParams( final JBossWebMetaData jbossWebMD )
+   {
+      List< ParamValueMetaData > contextParams = jbossWebMD.getContextParams();
+      
+      if ( contextParams == null )
+      {
+         contextParams = new ArrayList< ParamValueMetaData >();
+         jbossWebMD.setContextParams( contextParams );
+      }
+      
+      return contextParams;
+   }
+
+}

Added: branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/tomcat/WebMetaDataModifyingDeploymentAspect.java
===================================================================
--- branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/tomcat/WebMetaDataModifyingDeploymentAspect.java	                        (rev 0)
+++ branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/tomcat/WebMetaDataModifyingDeploymentAspect.java	2009-07-30 12:23:04 UTC (rev 91827)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.webservices.integration.tomcat;
+
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.deployment.DeploymentAspect;
+
+/**
+ * Modifies web meta data to configure webservice stack endpoints and properties.
+ * 
+ * @author <a href="mailto:ropalka at redhat.com">Richard Opalka</a>
+ */
+public final class WebMetaDataModifyingDeploymentAspect extends DeploymentAspect
+{
+   
+   /** Web meta data modifier. */
+   private WebMetaDataModifier webMetaDataModifier;
+
+   /**
+    * Constructor.
+    */
+   public WebMetaDataModifyingDeploymentAspect()
+   {
+      super();
+   }
+
+   /**
+    * Sets Web meta data modifier. This method is called using MC injection.
+    * 
+    * @param webMDModifier web meta data modifier
+    */
+   public void setWebMetaDataModifier( final WebMetaDataModifier webMDModifier )
+   {
+      this.webMetaDataModifier = webMDModifier;
+   }
+
+   /**
+    * Modifies web meta data.
+    * 
+    * @param dep webservice deployment
+    */
+   public void start( final Deployment dep )
+   {
+      this.webMetaDataModifier.modify( dep );
+   }
+   
+}

Added: branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/util/ASHelper.java
===================================================================
--- branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/util/ASHelper.java	                        (rev 0)
+++ branches/ropalka-jbossws320-jboss520/webservices/src/main/org/jboss/webservices/integration/util/ASHelper.java	2009-07-30 12:23:04 UTC (rev 91827)
@@ -0,0 +1,387 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.webservices.integration.util;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.jws.WebService;
+import javax.servlet.Servlet;
+import javax.xml.ws.WebServiceProvider;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.web.jboss.JBossServletMetaData;
+import org.jboss.metadata.web.jboss.JBossWebMetaData;
+import org.jboss.metadata.web.spec.ServletMetaData;
+import org.jboss.wsf.spi.deployment.Deployment.DeploymentType;
+import org.jboss.wsf.spi.deployment.integration.WebServiceDeclaration;
+import org.jboss.wsf.spi.deployment.integration.WebServiceDeployment;
+
+/**
+ * JBoss AS integration helper class.
+ *
+ * @author <a href="ropalka at redhat.com">Richard Opalka</a>
+ */
+public final class ASHelper
+{
+
+   /** Logger. */
+   private static final Logger LOG = Logger.getLogger( ASHelper.class );
+
+   /**
+    * Forbidden constructor.
+    */
+   private ASHelper()
+   {
+      super();
+   }
+
+   /**
+    * Returns true if unit contains JAXWS JSE, JAXRPC JSE, JAXWS EJB or JAXRPC EJB deployment.
+    *
+    * @param unit deployment unit
+    * @return true if JAXWS JSE, JAXRPC JSE, JAXWS EJB or JAXRPC EJB deployment, false otherwise.
+    */
+   public static boolean isWebServiceDeployment( final DeploymentUnit unit )
+   {
+      return ASHelper.getOptionalAttachment( unit, DeploymentType.class ) != null;
+   }
+
+   /**
+    * Returns true if unit contains JAXRPC EJB deployment.
+    *
+    * @param unit deployment unit
+    * @return true if JAXRPC EJB deployment, false otherwise
+    */
+   public static boolean isJaxrpcEjbDeployment( final DeploymentUnit unit )
+   {
+      final DeploymentType deploymentType = ASHelper.getOptionalAttachment( unit, DeploymentType.class );
+
+      return DeploymentType.JAXRPC_EJB21.equals( deploymentType );
+   }
+
+   /**
+    * Returns true if unit contains JAXRPC JSE deployment.
+    *
+    * @param unit deployment unit
+    * @return true if JAXRPC JSE deployment, false otherwise
+    */
+   public static boolean isJaxrpcJseDeployment( final DeploymentUnit unit )
+   {
+      final DeploymentType deploymentType = ASHelper.getOptionalAttachment( unit, DeploymentType.class );
+
+      return DeploymentType.JAXRPC_JSE.equals( deploymentType );
+   }
+
+   /**
+    * Returns true if unit contains JAXWS EJB deployment.
+    *
+    * @param unit deployment unit
+    * @return true if JAXWS EJB deployment, false otherwise
+    */
+   public static boolean isJaxwsEjbDeployment( final DeploymentUnit unit )
+   {
+      final DeploymentType deploymentType = ASHelper.getOptionalAttachment( unit, DeploymentType.class );
+
+      return DeploymentType.JAXWS_EJB3.equals( deploymentType );
+   }
+
+   /**
+    * Returns true if unit contains JAXWS JSE deployment.
+    *
+    * @param unit deployment unit
+    * @return true if JAXWS JSE deployment, false otherwise
+    */
+   public static boolean isJaxwsJseDeployment( final DeploymentUnit unit )
+   {
+      final DeploymentType deploymentType = ASHelper.getOptionalAttachment( unit, DeploymentType.class );
+
+      return DeploymentType.JAXWS_JSE.equals( deploymentType );
+   }
+
+   /**
+    * Returns true if unit contains either JAXWS JSE or JAXRPC JSE deployment.
+    *
+    * @param unit deployment unit
+    * @return true if either JAXWS JSE or JAXRPC JSE deployment, false otherwise.
+    */
+   public static boolean isJseDeployment( final DeploymentUnit unit )
+   {
+      final boolean isJaxwsJse = ASHelper.isJaxwsJseDeployment( unit );
+      final boolean isJaxrpcJse = ASHelper.isJaxrpcJseDeployment( unit );
+
+      return isJaxwsJse || isJaxrpcJse;
+   }
+
+   /**
+    * Returns true if unit contains either JAXWS EJB or JAXRPC EJB deployment.
+    *
+    * @param unit deployment unit
+    * @return true if either JAXWS EJB or JAXRPC EJB deployment, false otherwise
+    */
+   public static boolean isEjbDeployment( final DeploymentUnit unit )
+   {
+      final boolean isJaxwsEjb = ASHelper.isJaxwsEjbDeployment( unit );
+      final boolean isJaxrpcEjb = ASHelper.isJaxrpcEjbDeployment( unit );
+
+      return isJaxwsEjb || isJaxrpcEjb;
+   }
+
+   /**
+    * Returns true if unit contains either JAXWS EJB or JAXWS JSE deployment.
+    *
+    * @param unit deployment unit
+    * @return true if either JAXWS EJB or JAXWS JSE deployment, false otherwise
+    */
+   public static boolean isJaxwsDeployment( final DeploymentUnit unit )
+   {
+      final boolean isJaxwsEjb = ASHelper.isJaxwsEjbDeployment( unit );
+      final boolean isJaxwsJse = ASHelper.isJaxwsJseDeployment( unit );
+
+      return isJaxwsEjb || isJaxwsJse;
+   }
+
+   /**
+    * Returns true if unit contains either JAXRPC EJB or JAXRPC JSE deployment.
+    *
+    * @param unit deployment unit
+    * @return true if either JAXRPC EJB or JAXRPC JSE deployment, false otherwise
+    */
+   public static boolean isJaxrpcDeployment( final DeploymentUnit unit )
+   {
+      final boolean isJaxrpcEjb = ASHelper.isJaxrpcEjbDeployment( unit );
+      final boolean isJaxrpcJse = ASHelper.isJaxrpcJseDeployment( unit );
+
+      return isJaxrpcEjb || isJaxrpcJse;
+   }
+
+   /**
+    * Gets list of JAXWS servlets meta data.
+    *
+    * @param unit deployment unit
+    * @return list of JAXWS servlets meta data
+    */
+   public static List< ServletMetaData > getJaxwsServlets( final DeploymentUnit unit )
+   {
+      return ASHelper.getWebServiceServlets( unit, true );
+   }
+
+   /**
+    * Gets list of JAXRPC servlets meta data.
+    *
+    * @param unit deployment unit
+    * @return list of JAXRPC servlets meta data
+    */
+   public static List< ServletMetaData > getJaxrpcServlets( final DeploymentUnit unit )
+   {
+      return ASHelper.getWebServiceServlets( unit, false );
+   }
+
+   /**
+    * Gets list of JAXWS EJBs meta data.
+    *
+    * @param unit deployment unit
+    * @return list of JAXWS EJBs meta data
+    */
+   public static List< WebServiceDeclaration > getJaxwsEjbs( final DeploymentUnit unit )
+   {
+      final WebServiceDeployment wsDeployment = ASHelper.getRequiredAttachment( unit, WebServiceDeployment.class );
+      final List< WebServiceDeclaration > endpoints = new ArrayList< WebServiceDeclaration >();
+
+      final Iterator< WebServiceDeclaration > ejbIterator = wsDeployment.getServiceEndpoints().iterator();
+      while ( ejbIterator.hasNext() )
+      {
+         final WebServiceDeclaration ejbContainer = ejbIterator.next();
+         if ( ASHelper.isWebServiceBean( ejbContainer ) )
+         {
+            endpoints.add( ejbContainer );
+         }
+      }
+
+      return endpoints;
+   }
+
+   /**
+    * Returns true if EJB container is webservice endpoint.
+    * 
+    * @param ejbContainerAdapter EJB container adapter
+    * @return true if EJB container is webservice endpoint, false otherwise
+    */
+   public static boolean isWebServiceBean( final WebServiceDeclaration ejbContainerAdapter )
+   {
+      final boolean isWebService = ejbContainerAdapter.getAnnotation( WebService.class ) != null;
+      final boolean isWebServiceProvider = ejbContainerAdapter.getAnnotation( WebServiceProvider.class ) != null;
+
+      return isWebService || isWebServiceProvider;
+   }
+
+   /**
+    * Returns endpoint class name.
+    *
+    * @param servletMD servlet meta data
+    * @return endpoint class name
+    */
+   public static String getEndpointName( final ServletMetaData servletMD )
+   {
+      final String endpointClass = servletMD.getServletClass();
+
+      return endpointClass != null ? endpointClass.trim() : null;
+   }
+
+   /**
+    * Returns servlet meta data for requested servlet name.
+    * 
+    * @param jbossWebMD jboss web meta data
+    * @param servletName servlet name
+    * @return servlet meta data
+    */
+   public static ServletMetaData getServletForName( final JBossWebMetaData jbossWebMD, final String servletName )
+   {
+      for ( JBossServletMetaData servlet : jbossWebMD.getServlets() )
+      {
+         if ( servlet.getName().equals( servletName ) )
+         {
+            return servlet;
+         }
+      }
+
+      throw new IllegalStateException( "Cannot find servlet for link: " + servletName );
+   }
+
+   /**
+    * Returns webservice endpoint class or null if passed servlet meta data belong to either JSP or servlet instance.
+    *
+    * @param servletMD servlet meta data
+    * @param loader class loader
+    * @return webservice endpoint class or null
+    */
+   public static Class< ? > getEndpointClass( final ServletMetaData servletMD, final ClassLoader loader )
+   {
+      final String endpointClassName = ASHelper.getEndpointName( servletMD );
+      final boolean notJSP = endpointClassName != null && endpointClassName.length() > 0; 
+
+      if ( notJSP )
+      {
+         try
+         {
+            final Class< ? > endpointClass = loader.loadClass( endpointClassName );
+            final boolean notServlet = !Servlet.class.isAssignableFrom( endpointClass );
+
+            if ( notServlet )
+            {
+               return endpointClass;
+            }
+         }
+         catch ( ClassNotFoundException cnfe )
+         {
+            ASHelper.LOG.warn( "Cannot load servlet class: " + endpointClassName, cnfe );
+         }
+      }
+
+      return null;
+   }
+
+   /**
+    * Returns required attachment value from deployment unit. 
+    * 
+    * @param <A> expected value
+    * @param unit deployment unit
+    * @param key attachment key
+    * @return required attachment 
+    * @throws IllegalStateException if attachment value is null
+    */
+   public static <A> A getRequiredAttachment( final DeploymentUnit unit, final Class< A > key )
+   {
+      final A value = unit.getAttachment( key );
+      if ( value == null )
+      {
+         ASHelper.LOG.error( "Cannot find attachment in deployment unit: " + key );
+         throw new IllegalStateException();
+      }
+      
+      return value;
+   }
+   
+   /**
+    * Returns optional attachment value from deployment unit or null if not bound.
+    * 
+    * @param <A> expected value
+    * @param unit deployment unit
+    * @param key attachment key
+    * @return optional attachment value or null 
+    */
+   public static <A> A getOptionalAttachment( final DeploymentUnit unit, final Class< A > key )
+   {
+      return unit.getAttachment( key );
+   }
+   
+   /**
+    * Returns true if deployment unit have attachment value associated with the <b>key</b>.
+    *  
+    * @param unit deployment unit
+    * @param key attachment key
+    * @return true if contains attachment, false otherwise
+    */
+   public static boolean hasAttachment( final DeploymentUnit unit, final Class< ? > key )
+   {
+      return ASHelper.getOptionalAttachment( unit, key ) != null;
+   }
+
+   /**
+    * Gets list of JAXRPC or JAXWS servlets meta data.
+    *
+    * @param unit deployment unit
+    * @param jaxws if passed value is <b>true</b> JAXWS servlets list will be returned, otherwise JAXRPC servlets list
+    * @return either JAXRPC or JAXWS servlets list
+    */
+   private static List< ServletMetaData > getWebServiceServlets( final DeploymentUnit unit, final boolean jaxws )
+   {
+      final JBossWebMetaData jbossWebMD = ASHelper.getRequiredAttachment( unit, JBossWebMetaData.class );
+      final ClassLoader loader = unit.getClassLoader();
+      final List< ServletMetaData > endpoints = new ArrayList< ServletMetaData >();
+
+      for ( ServletMetaData servletMD : jbossWebMD.getServlets() )
+      {
+         final Class< ? > endpointClass = ASHelper.getEndpointClass( servletMD, loader );
+
+         if ( endpointClass != null )
+         {
+            // check webservice annotations
+            final boolean isWebService = endpointClass.isAnnotationPresent( WebService.class );
+            final boolean isWebServiceProvider = endpointClass.isAnnotationPresent( WebServiceProvider.class );
+            // detect webservice type
+            final boolean isJaxwsEndpoint = jaxws && ( isWebService || isWebServiceProvider );
+            final boolean isJaxrpcEndpoint = !jaxws && ( !isWebService && !isWebServiceProvider );
+
+            if ( isJaxwsEndpoint || isJaxrpcEndpoint )
+            {
+               endpoints.add( servletMD );
+            }
+         }
+      }
+
+      return endpoints;
+   }
+
+}

Added: branches/ropalka-jbossws320-jboss520/webservices/src/resources/jbossws-jboss.deployer/META-INF/stack-agnostic-jboss-beans.xml
===================================================================
--- branches/ropalka-jbossws320-jboss520/webservices/src/resources/jbossws-jboss.deployer/META-INF/stack-agnostic-jboss-beans.xml	                        (rev 0)
+++ branches/ropalka-jbossws320-jboss520/webservices/src/resources/jbossws-jboss.deployer/META-INF/stack-agnostic-jboss-beans.xml	2009-07-30 12:23:04 UTC (rev 91827)
@@ -0,0 +1,153 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+  <!-- Locate the single instance of the kernel -->
+  <bean name="WSKernelLocator" class="org.jboss.wsf.spi.util.KernelLocator">
+    <property name="kernel"><inject bean="jboss.kernel:service=Kernel"/></property>
+  </bean>
+
+  <!-- Locate the single instance of the MBeanServer -->
+  <bean name="WSMBeanServerLocator" class="org.jboss.wsf.framework.management.MBeanServerLocator">
+    <property name="mbeanServer"><inject bean="JMXKernel" property="mbeanServer"/></property>
+  </bean>
+
+  <!-- An abstraction of server configuration aspects. -->
+  <bean name="WSServerConfig" class="org.jboss.webservices.integration.config.ServerConfigImpl">
+    <property name="mbeanServer"><inject bean="WSMBeanServerLocator" property="mbeanServer"/></property>
+
+    <!--
+      The WSDL, that is a required deployment artifact for an endpoint, has a <soap:address>
+      element which points to the location of the endpoint. JBoss supports rewriting of that SOAP address.
+
+      If the content of <soap:address> is a valid URL, JBossWS will not rewrite it unless 'modifySOAPAddress' is true.
+      If the content of <soap:address> is not a valid URL, JBossWS will rewrite it using the attribute values given below.
+
+      If 'webServiceHost' is not set, JBossWS uses requesters protocol host when rewriting the <soap:address>.
+    -->
+    <property name="webServiceHost">${jboss.bind.address}</property>
+    <property name="modifySOAPAddress">true</property>
+
+    <!--
+      Set these properties to explicitly define the ports that will be used for rewriting the SOAP address.
+      Otherwise the ports will be identified by querying the list of installed connectors.
+      If multiple connectors are found the port of the first connector is used.
+      <property name="webServiceSecurePort">8443</property>
+      <property name="webServicePort">8080</property>
+    -->
+  </bean>
+
+  <!-- deployers -->
+  <bean name="WSDescriptorDeployer" class="org.jboss.webservices.integration.deployers.WSDescriptorDeployer">
+    <property name="name">webservices.xml</property>
+    <property name="useSchemaValidation">true</property>
+  </bean>
+
+  <bean name="WSEJBAdapterDeployer" class="org.jboss.webservices.integration.deployers.WSEJBAdapterDeployer"/>
+
+  <bean name="WSTypeDeployer" class="org.jboss.webservices.integration.deployers.WSTypeDeployer">
+    <property name="relativeOrder">1</property> <!-- [JBDEPLOY-201] workaround -->
+  </bean>
+
+  <bean name="WSDeploymentDeployer" class="org.jboss.webservices.integration.deployers.WSDeploymentDeployer">
+    <property name="relativeOrder">2</property> <!-- [JBDEPLOY-201] workaround -->
+  </bean>
+
+  <!-- WSDeploymentAspectDeployers factory -->
+  <bean name="WSDeployersFactory" class="org.jboss.webservices.integration.deployers.WSDeployersFactory">
+    <constructor>
+      <parameter>
+        <inject bean="Deployers"/>
+      </parameter>
+    </constructor>
+    <incallback method="newDeployer"/>
+  </bean>
+
+  <!-- Deployment aspect helper beans -->
+  <bean name="WSSecurityHandlerEJB21" class="org.jboss.webservices.integration.tomcat.SecurityHandlerEJB21"/>
+  <bean name="WSSecurityHandlerEJB3" class="org.jboss.webservices.integration.tomcat.SecurityHandlerEJB3"/>
+  <bean name="WSWebMetaDataModifier" class="org.jboss.webservices.integration.tomcat.WebMetaDataModifier"/>
+
+  <!-- The AS specific deployment aspects -->
+  <bean name="WSContainerMetaDataDeploymentAspect" class="org.jboss.webservices.integration.metadata.ContainerMetaDataDeploymentAspect">
+    <property name="provides">ContainerMetaData, VFSRoot</property>
+    <property name="relativeOrder">12</property> <!-- [JBDEPLOY-201] workaround -->
+  </bean>
+
+  <bean name="WSInjectionMetaDataDeploymentAspect" class="org.jboss.webservices.integration.injection.InjectionMetaDataDeploymentAspect">
+    <property name="requires">WebMetaData</property>
+    <property name="provides">InjectionMetaData</property>
+    <property name="ejbReferenceResolver"><inject bean="org.jboss.ejb3.EjbReferenceResolver"/></property>
+    <property name="relativeOrder">34</property> <!-- [JBDEPLOY-201] workaround -->
+  </bean>
+
+  <!-- TODO: remove this hacky aspect in AS trunk -->
+  <bean name="WSJACCPermissionsDeploymentAspect" class="org.jboss.webservices.integration.security.JACCPermissionsDeploymentAspect">
+    <property name="requires">WebMetaData</property>
+    <property name="provides">JACCPermisions</property>
+    <property name="relativeOrder">34</property> <!-- [JBDEPLOY-201] workaround -->
+  </bean>
+
+  <bean name="WSContextRootDeploymentAspect" class="org.jboss.wsf.framework.deployment.BackwardCompatibleContextRootDeploymentAspect">
+    <property name="requires">ContainerMetaData</property>
+    <property name="provides">ContextRoot</property>
+    <property name="relativeOrder">14</property> <!-- [JBDEPLOY-201] workaround -->
+  </bean>
+
+  <bean name="WSVirtualHostDeploymentAspect" class="org.jboss.wsf.framework.deployment.VirtualHostDeploymentAspect">
+    <property name="requires">ContainerMetaData</property>
+    <property name="provides">VirtualHosts</property>
+    <property name="relativeOrder">18</property> <!-- [JBDEPLOY-201] workaround -->
+  </bean>
+
+  <bean name="WSEndpointAddressDeploymentAspect" class="org.jboss.wsf.framework.deployment.EndpointAddressDeploymentAspect">
+    <property name="requires">URLPattern</property>
+    <property name="provides">EndpointAddress</property>
+    <property name="relativeOrder">16</property> <!-- [JBDEPLOY-201] workaround -->
+  </bean>
+
+  <bean name="WSEndpointLifecycleDeploymentAspect" class="org.jboss.wsf.framework.deployment.EndpointLifecycleDeploymentAspect">
+    <property name="provides">LifecycleHandler</property>
+    <property name="last">true</property>
+    <property name="relativeOrder">37</property> <!-- [JBDEPLOY-201] workaround -->
+  </bean>
+
+  <bean name="WSEndpointMetricsDeploymentAspect" class="org.jboss.wsf.framework.deployment.EndpointMetricsDeploymentAspect">
+    <property name="provides">EndpointMetrics</property>
+    <property name="relativeOrder">11</property> <!-- [JBDEPLOY-201] workaround -->
+  </bean>
+
+  <bean name="WSEndpointNameDeploymentAspect" class="org.jboss.wsf.framework.deployment.EndpointNameDeploymentAspect">
+    <property name="requires">URLPattern</property>
+    <property name="provides">EndpointName</property>
+    <property name="relativeOrder">17</property> <!-- [JBDEPLOY-201] workaround -->
+  </bean>
+
+  <bean name="WSEndpointRegistryDeploymentAspect" class="org.jboss.wsf.framework.deployment.EndpointRegistryDeploymentAspect">
+    <property name="requires">EndpointName</property>
+    <property name="provides">RegisteredEndpoint</property>
+    <property name="relativeOrder">35</property> <!-- [JBDEPLOY-201] workaround -->
+  </bean>
+
+  <bean name="WSURLPatternDeploymentAspect" class="org.jboss.wsf.framework.deployment.URLPatternDeploymentAspect">
+    <property name="requires">ContextRoot, ContainerMetaData</property>
+    <property name="provides">URLPattern</property>
+    <property name="relativeOrder">15</property> <!-- [JBDEPLOY-201] workaround -->
+  </bean>
+
+  <bean name="WSWebMetaDataModifyingDeploymentAspect" class="org.jboss.webservices.integration.tomcat.WebMetaDataModifyingDeploymentAspect">
+    <property name="requires">WebMetaData, ContextProperties, StackDescriptor</property>
+    <property name="provides">WebMetaData</property>
+    <property name="webMetaDataModifier"><inject bean="WSWebMetaDataModifier"/></property>
+    <property name="relativeOrder">33</property> <!-- [JBDEPLOY-201] workaround -->
+  </bean>
+
+  <bean name="WSWebAppGeneratorDeploymentAspect" class="org.jboss.webservices.integration.tomcat.WebAppGeneratorDeploymentAspect">
+    <property name="requires">VirtualHosts,URLPattern</property>
+    <property name="provides">WebMetaData</property>
+    <property name="securityHandlerEJB21"><inject bean="WSSecurityHandlerEJB21"/></property>
+    <property name="securityHandlerEJB3"><inject bean="WSSecurityHandlerEJB3"/></property>
+    <property name="relativeOrder">32</property> <!-- [JBDEPLOY-201] workaround -->
+  </bean>
+
+</deployment>

Added: branches/ropalka-jbossws320-jboss520/webservices/src/resources/jbossws-jboss.jar/META-INF/services/org.jboss.wsf.spi.deployment.DeploymentModelFactory
===================================================================
--- branches/ropalka-jbossws320-jboss520/webservices/src/resources/jbossws-jboss.jar/META-INF/services/org.jboss.wsf.spi.deployment.DeploymentModelFactory	                        (rev 0)
+++ branches/ropalka-jbossws320-jboss520/webservices/src/resources/jbossws-jboss.jar/META-INF/services/org.jboss.wsf.spi.deployment.DeploymentModelFactory	2009-07-30 12:23:04 UTC (rev 91827)
@@ -0,0 +1 @@
+org.jboss.wsf.framework.deployment.ArchiveDeploymentModelFactory
\ No newline at end of file

Added: branches/ropalka-jbossws320-jboss520/webservices/src/resources/jbossws-jboss.jar/META-INF/services/org.jboss.wsf.spi.invocation.InvocationHandlerFactory
===================================================================
--- branches/ropalka-jbossws320-jboss520/webservices/src/resources/jbossws-jboss.jar/META-INF/services/org.jboss.wsf.spi.invocation.InvocationHandlerFactory	                        (rev 0)
+++ branches/ropalka-jbossws320-jboss520/webservices/src/resources/jbossws-jboss.jar/META-INF/services/org.jboss.wsf.spi.invocation.InvocationHandlerFactory	2009-07-30 12:23:04 UTC (rev 91827)
@@ -0,0 +1 @@
+org.jboss.webservices.integration.invocation.InvocationHandlerFactoryImpl
\ No newline at end of file

Added: branches/ropalka-jbossws320-jboss520/webservices/src/resources/jbossws-jboss.jar/META-INF/services/org.jboss.wsf.spi.invocation.SecurityAdaptorFactory
===================================================================
--- branches/ropalka-jbossws320-jboss520/webservices/src/resources/jbossws-jboss.jar/META-INF/services/org.jboss.wsf.spi.invocation.SecurityAdaptorFactory	                        (rev 0)
+++ branches/ropalka-jbossws320-jboss520/webservices/src/resources/jbossws-jboss.jar/META-INF/services/org.jboss.wsf.spi.invocation.SecurityAdaptorFactory	2009-07-30 12:23:04 UTC (rev 91827)
@@ -0,0 +1 @@
+org.jboss.webservices.integration.invocation.SecurityAdapterFactoryImpl
\ No newline at end of file

Added: branches/ropalka-jbossws320-jboss520/webservices/src/resources/jbossws-jboss.jar/META-INF/services/org.jboss.wsf.spi.management.ServerConfigFactory
===================================================================
--- branches/ropalka-jbossws320-jboss520/webservices/src/resources/jbossws-jboss.jar/META-INF/services/org.jboss.wsf.spi.management.ServerConfigFactory	                        (rev 0)
+++ branches/ropalka-jbossws320-jboss520/webservices/src/resources/jbossws-jboss.jar/META-INF/services/org.jboss.wsf.spi.management.ServerConfigFactory	2009-07-30 12:23:04 UTC (rev 91827)
@@ -0,0 +1 @@
+org.jboss.wsf.framework.management.ServerConfigFactoryImpl
\ No newline at end of file

Modified: branches/ropalka-jbossws320-jboss520/webservices/src/scripts/assembly-resources.xml
===================================================================
--- branches/ropalka-jbossws320-jboss520/webservices/src/scripts/assembly-resources.xml	2009-07-30 11:11:40 UTC (rev 91826)
+++ branches/ropalka-jbossws320-jboss520/webservices/src/scripts/assembly-resources.xml	2009-07-30 12:23:04 UTC (rev 91827)
@@ -10,8 +10,8 @@
       <directory>src/resources</directory>
       <outputDirectory>/</outputDirectory>
       <includes>
-        <include>jbossws-jboss50.deployer/**</include>
-        <include>jbossws-jboss50.jar/**</include>
+        <include>jbossws-jboss.deployer/**</include>
+        <include>jbossws-jboss.jar/**</include>
       </includes>
     </fileSet>
   </fileSets>




More information about the jboss-cvs-commits mailing list