[jboss-cvs] JBossAS SVN: r92520 - in branches/Branch_5_x: webservices and 11 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Aug 18 07:43:40 EDT 2009


Author: richard.opalka at jboss.com
Date: 2009-08-18 07:43:39 -0400 (Tue, 18 Aug 2009)
New Revision: 92520

Added:
   branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/WSAspectizedDeployersFactory.java
   branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/deployment/
   branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/deployment/AbstractDeploymentModelBuilder.java
   branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/deployment/DeploymentModelBuilder.java
   branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/deployment/JaxrpcEjbDeploymentModelBuilder.java
   branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/deployment/JaxrpcJseDeploymentModelBuilder.java
   branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/deployment/JaxwsEjbDeploymentModelBuilder.java
   branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/deployment/JaxwsJseDeploymentModelBuilder.java
   branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/deployment/WSDeploymentBuilder.java
   branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/deployment/WSVirtualFileFilter.java
   branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/invocation/AbstractInvocationHandlerJSE.java
   branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/invocation/ServiceEndpointInterceptorEJB21.java
   branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/metadata/AbstractMetaDataBuilderEJB.java
   branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/metadata/MetaDataBuilderEJB21.java
   branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/metadata/MetaDataBuilderEJB3.java
   branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/metadata/MetaDataBuilderJSE.java
   branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/metadata/PublishLocationAdapterImpl.java
   branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/security/SecurityAdapterFactoryImpl.java
   branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/security/SecurityAdapterImpl.java
   branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/tomcat/AbstractSecurityMetaDataAccessorEJB.java
   branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/tomcat/SecurityMetaDataAccessorEJB.java
   branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/tomcat/SecurityMetaDataAccessorEJB21.java
   branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/tomcat/SecurityMetaDataAccessorEJB3.java
   branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/tomcat/WebMetaDataCreatingDeploymentAspect.java
   branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/tomcat/WebMetaDataCreator.java
   branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/tomcat/WebMetaDataHelper.java
Removed:
   branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/WSDeployersFactory.java
   branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/WSVirtualFileFilter.java
   branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerJSE.java
   branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/invocation/SecurityAdapterFactoryImpl.java
   branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/invocation/SecurityAdaptorImpl.java
   branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/invocation/ServiceEndpointInterceptor.java
   branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/metadata/EJB21MetaDataBuilder.java
   branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/metadata/EJB3MetaDataBuilder.java
   branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/metadata/JSEMetaDataBuilder.java
   branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/tomcat/SecurityHandler.java
   branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/tomcat/SecurityHandlerEJB21.java
   branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/tomcat/SecurityHandlerEJB3.java
   branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/tomcat/WebAppGeneratorDeploymentAspect.java
Modified:
   branches/Branch_5_x/component-matrix/pom.xml
   branches/Branch_5_x/webservices/build.xml
   branches/Branch_5_x/webservices/pom.xml
   branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/config/ServerConfigImpl.java
   branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/WSDeploymentAspectDeployer.java
   branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/WSDeploymentDeployer.java
   branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/WSDescriptorDeployer.java
   branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/WSEJBAdapterDeployer.java
   branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/WSTypeDeployer.java
   branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/injection/EJBBeanReferenceResolver.java
   branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/injection/InjectionMetaDataDeploymentAspect.java
   branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/invocation/AbstractInvocationHandler.java
   branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerEJB21.java
   branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerEJB3.java
   branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerFactoryImpl.java
   branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerJAXRPC.java
   branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerJAXWS.java
   branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerMDB21.java
   branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerMDB3.java
   branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/metadata/ContainerMetaDataDeploymentAspect.java
   branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/security/JACCPermissionsDeploymentAspect.java
   branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/tomcat/WebMetaDataModifier.java
   branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/tomcat/WebMetaDataModifyingDeploymentAspect.java
   branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/util/ASHelper.java
   branches/Branch_5_x/webservices/src/resources/jbossws-jboss.deployer/META-INF/stack-agnostic-jboss-beans.xml
   branches/Branch_5_x/webservices/src/resources/jbossws-jboss.jar/META-INF/services/org.jboss.wsf.spi.invocation.SecurityAdaptorFactory
Log:
[JBAS-7138][JBWS-2332][JBWS-2699][JBWS-2630] update

Modified: branches/Branch_5_x/component-matrix/pom.xml
===================================================================
--- branches/Branch_5_x/component-matrix/pom.xml	2009-08-18 11:19:53 UTC (rev 92519)
+++ branches/Branch_5_x/component-matrix/pom.xml	2009-08-18 11:43:39 UTC (rev 92520)
@@ -36,9 +36,9 @@
     <version.javax.validation>1.0.CR3</version.javax.validation>
     <version.jboss.jaxr>2.0.1</version.jboss.jaxr>
     <version.jboss.jbossts>4.6.1.GA</version.jboss.jbossts>
-    <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-common>1.2.0.Beta3</version.jboss.jbossws-common>
+    <version.jboss.jbossws-framework>3.2.0.Beta3</version.jboss.jbossws-framework>
+    <version.jboss.jbossws-spi>1.2.0.Beta3</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>

Modified: branches/Branch_5_x/webservices/build.xml
===================================================================
--- branches/Branch_5_x/webservices/build.xml	2009-08-18 11:19:53 UTC (rev 92519)
+++ branches/Branch_5_x/webservices/build.xml	2009-08-18 11:43:39 UTC (rev 92520)
@@ -163,7 +163,7 @@
         <include name="META-INF/stack-agnostic-jboss-beans.xml"/>
       </fileset>
     </zip>
-    
+
   </target>
 
   <!-- ================================================================== -->
@@ -178,6 +178,6 @@
     <!-- Build jbossws.deployer -->
     <property name="jbossws.deployer.dir" value="../build/output/jboss-${specification.version}/server/default/deployers/jbossws.deployer"/>
     <unzip dest="${jbossws.deployer.dir}" src="${build.lib}/jbossws-jboss50-deployer.zip"/>
-    
+
   </target>
 </project>

Modified: branches/Branch_5_x/webservices/pom.xml
===================================================================
--- branches/Branch_5_x/webservices/pom.xml	2009-08-18 11:19:53 UTC (rev 92519)
+++ branches/Branch_5_x/webservices/pom.xml	2009-08-18 11:43:39 UTC (rev 92520)
@@ -12,7 +12,7 @@
   <name>JBoss Application Server Webservices</name>
   <url>http://www.jboss.org/jbossas</url>
   <description>JBoss Application Server (webservices module)</description>
-  
+
   <!-- Dependencies -->
   <dependencies>
     <!-- jbossws dependencies -->
@@ -125,7 +125,7 @@
       <artifactId>jboss-security-spi</artifactId>
     </dependency>
   </dependencies>
-  
+
   <!-- Plugins -->
   <build>
     <sourceDirectory>src/main</sourceDirectory>

Modified: branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/config/ServerConfigImpl.java
===================================================================
--- branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/config/ServerConfigImpl.java	2009-08-18 11:19:53 UTC (rev 92519)
+++ branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/config/ServerConfigImpl.java	2009-08-18 11:43:39 UTC (rev 92520)
@@ -32,39 +32,60 @@
 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
+ * AS specific ServerConfig.
  *
+ * @author <a href="mailto:asoldano at redhat.com">Alessio Soldano</a>
+ * @author <a href="mailto:ropalka at redhat.com">Richard Opalka</a>
+ * @author <a href="mailto:tdiesler at redhat.com">Thomas Diesler</a>
  */
-public class ServerConfigImpl extends AbstractServerConfig implements AbstractServerConfigMBean
+public final class ServerConfigImpl extends AbstractServerConfig implements AbstractServerConfigMBean
 {
 
+   /**
+    * Constructor.
+    */
+   public ServerConfigImpl()
+   {
+      super();
+   }
+
+   /**
+    * Gets server temp directory.
+    * 
+    * @return temp directory
+    */
    public File getServerTempDir()
    {
       return this.getDirFromServerConfig("ServerTempLocation");
    }
    
+   /**
+    * Gets server home directory.
+    * 
+    * @return home directory
+    */
    public File getHomeDir()
    {
       return this.getDirFromServerConfig("JBossHome");
    }
 
+   /**
+    * Gets server data directory.
+    * 
+    * @return data directory
+    */
    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
+    * Obtains the requested directory from the server configuration.
+    *
+    * @param attributeName directory attribute name
+    * @return requested directory
     */
-   protected File getDirFromServerConfig(final String attributeName)
+   private File getDirFromServerConfig(final String attributeName)
    {
       // Define the ON to invoke upon
       final ObjectName on = OBJECT_NAME_SERVER_CONFIG;
@@ -73,7 +94,7 @@
       URL location = null;
       try
       {
-         location = (URL) getMbeanServer().getAttribute(on, attributeName);
+         location = (URL) this.getMbeanServer().getAttribute(on, attributeName);
       }
       catch (final JMException e)
       {
@@ -91,7 +112,7 @@
          throw new RuntimeException("Could not desired directory from URL: " + location, urise);
       }
 
-      // Return
       return dir;
    }
+
 }

Added: branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/WSAspectizedDeployersFactory.java
===================================================================
--- branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/WSAspectizedDeployersFactory.java	                        (rev 0)
+++ branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/WSAspectizedDeployersFactory.java	2009-08-18 11:43:39 UTC (rev 92520)
@@ -0,0 +1,87 @@
+/*
+ * 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.HashMap;
+import java.util.Map;
+
+import org.jboss.deployers.plugins.deployers.DeployersImpl;
+import org.jboss.deployers.spi.deployer.Deployer;
+import org.jboss.logging.Logger;
+import org.jboss.wsf.spi.deployment.DeploymentAspect;
+
+/**
+ * WSDeploymentAspectDeployer factory.
+ *
+ * @author <a href="ropalka at redhat.com">Richard Opalka</a>
+ */
+public final class WSAspectizedDeployersFactory
+{
+
+   /** Logger. */
+   private static final Logger LOGGER = Logger.getLogger(WSAspectizedDeployersFactory.class);
+
+   /** Real deployers registry. */
+   private final DeployersImpl delegee;
+
+   /** Our deployers regitry. */
+   private final Map<DeploymentAspect, Deployer> deployersRegistry = new HashMap<DeploymentAspect, Deployer>();
+
+   /**
+    * Constructor.
+    * 
+    * @param realDeployers real deployers registry
+    */
+   public WSAspectizedDeployersFactory(final DeployersImpl realDeployers)
+   {
+      this.delegee = realDeployers;
+   }
+
+   /**
+    * MC incallback method. It will be called each time DeploymentAspect bean will be installed.
+    * 
+    * @param aspect to create real WS aspectized deployer for
+    */
+   public void addDeployer(final DeploymentAspect aspect)
+   {
+      WSAspectizedDeployersFactory.LOGGER.debug("Adding deployer for: " + aspect);
+      final Deployer wsAspectizedDeployer = new WSDeploymentAspectDeployer(aspect);
+
+      this.delegee.addDeployer(wsAspectizedDeployer);
+      this.deployersRegistry.put(aspect, wsAspectizedDeployer);
+   }
+
+   /**
+    * MC uncallback method. It will be called each time DeploymentAspect bean will be removed.
+    * 
+    * @param aspect to remove real WS aspectized deployer for
+    */
+   public void removeDeployer(final DeploymentAspect aspect)
+   {
+      WSAspectizedDeployersFactory.LOGGER.debug("Removing deployer for: " + aspect);
+      final Deployer wsAspectizedDeployer = this.deployersRegistry.get(aspect);
+
+      this.deployersRegistry.remove(aspect);
+      this.delegee.removeDeployer(wsAspectizedDeployer);
+   }
+
+}

Deleted: branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/WSDeployersFactory.java
===================================================================
--- branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/WSDeployersFactory.java	2009-08-18 11:19:53 UTC (rev 92519)
+++ branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/WSDeployersFactory.java	2009-08-18 11:43:39 UTC (rev 92520)
@@ -1,58 +0,0 @@
-/*
- * 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 ) );
-   }
-
-}

Modified: branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/WSDeploymentAspectDeployer.java
===================================================================
--- branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/WSDeploymentAspectDeployer.java	2009-08-18 11:19:53 UTC (rev 92519)
+++ branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/WSDeploymentAspectDeployer.java	2009-08-18 11:43:39 UTC (rev 92520)
@@ -34,15 +34,17 @@
 /**
  * A deployer that delegates to JBossWS deployment aspect.
  * 
- * @author <a href="ropalka at redhat.com">Richard Opalka</a>
+ * @author <a href="mailto:ropalka at redhat.com">Richard Opalka</a>
  */
-public final class WSDeploymentAspectDeployer extends AbstractRealDeployer
+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;
 
@@ -51,40 +53,40 @@
     * 
     * @param aspect deployment aspect
     */
-   public WSDeploymentAspectDeployer( final DeploymentAspect aspect )
+   WSDeploymentAspectDeployer(final DeploymentAspect aspect)
    {
       super();
-      
+
       // inputs
-      this.addInput( JBossWebMetaData.class );
-      this.addInput( Deployment.class );
-      if ( aspect.isLast() )
+      this.addInput(JBossWebMetaData.class);
+      this.addInput(Deployment.class);
+      if (aspect.isLast())
       {
-         this.addInput( WSDeploymentAspectDeployer.JBOSSWS_METADATA );
+         this.addInput(WSDeploymentAspectDeployer.JBOSSWS_METADATA);
       }
-      
+
       // propagate DA requirements and map them to deployer inputs
-      final Set< String > inputs = aspect.getRequiresAsSet();
-      for ( String input : inputs )
+      final Set<String> inputs = aspect.getRequiresAsSet();
+      for (String input : inputs)
       {
-         this.addInput( WSDeploymentAspectDeployer.JBOSSWS_ATTACHMENT_PREFIX + input );
+         this.addInput(WSDeploymentAspectDeployer.JBOSSWS_ATTACHMENT_PREFIX + input);
       }
-      
+
       // outputs
-      this.addOutput( JBossWebMetaData.class );
-      if ( !aspect.isLast() )
+      this.addOutput(JBossWebMetaData.class);
+      if (!aspect.isLast())
       {
-         this.addOutput( WSDeploymentAspectDeployer.JBOSSWS_METADATA );
+         this.addOutput(WSDeploymentAspectDeployer.JBOSSWS_METADATA);
       }
 
       // propagate DA provides and map them to deployer outputs
-      final Set< String > outputs = aspect.getProvidesAsSet();
-      for ( String output : outputs )
+      final Set<String> outputs = aspect.getProvidesAsSet();
+      for (String output : outputs)
       {
-         this.addOutput( WSDeploymentAspectDeployer.JBOSSWS_ATTACHMENT_PREFIX + output );
+         this.addOutput(WSDeploymentAspectDeployer.JBOSSWS_ATTACHMENT_PREFIX + output);
       }
 
-      this.setRelativeOrder( aspect.getRelativeOrder() );
+      this.setRelativeOrder(aspect.getRelativeOrder());
       this.aspect = aspect;
    }
 
@@ -96,13 +98,13 @@
     * @throws DeploymentException on deployment failure
     */
    @Override
-   public void internalDeploy( final DeploymentUnit unit ) throws DeploymentException
+   protected void internalDeploy(final DeploymentUnit unit) throws DeploymentException
    {
-      if ( ASHelper.isWebServiceDeployment( unit ) )
+      if (ASHelper.isWebServiceDeployment(unit))
       {
-         log.debug( this.aspect.getClass() + " deploy: " + unit.getName() );
-         final Deployment dep = ASHelper.getRequiredAttachment( unit, Deployment.class );
-         this.aspect.start( dep );
+         this.log.debug(this.aspect + " start: " + unit.getName());
+         final Deployment dep = ASHelper.getRequiredAttachment(unit, Deployment.class);
+         this.aspect.start(dep);
       }
    }
 
@@ -113,18 +115,18 @@
     * @param unit deployment unit
     */
    @Override
-   public void internalUndeploy( final DeploymentUnit unit )
+   protected void internalUndeploy(final DeploymentUnit unit)
    {
-      if ( ASHelper.isWebServiceDeployment( 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 );
+         this.log.debug(this.aspect + " stop: " + unit.getName());
+         final Deployment dep = ASHelper.getRequiredAttachment(unit, Deployment.class);
+         this.aspect.stop(dep);
       }
    }
-   
+
    /**
-    * Displays also WS deployment aspect being used.
+    * Displays also WS deployment aspect being wrapped.
     * 
     * @return deployer instance id including wrapped deployment aspect id.
     */
@@ -132,7 +134,7 @@
    public String toString()
    {
       final StringBuilder sb = new StringBuilder();
-      sb.append( super.toString() ).append( '(' ).append( this.aspect ).append( ')' );
+      sb.append(super.toString()).append('(').append(this.aspect).append(')');
       return sb.toString();
    }
 

Modified: branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/WSDeploymentDeployer.java
===================================================================
--- branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/WSDeploymentDeployer.java	2009-08-18 11:19:53 UTC (rev 92519)
+++ branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/WSDeploymentDeployer.java	2009-08-18 11:43:39 UTC (rev 92520)
@@ -21,52 +21,21 @@
  */
 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.webservices.integration.deployers.deployment.WSDeploymentBuilder;
 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>
+ * @author <a href="mailto: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.
@@ -74,249 +43,27 @@
    public WSDeploymentDeployer()
    {
       super();
-      
+
       // inputs
-      this.addInput( JBossWebMetaData.class );
-      this.addInput( DeploymentType.class );
-      
-      // outputs
-      this.addOutput( JBossWebMetaData.class );
-      this.addOutput( Deployment.class );
+      this.addInput(JBossWebMetaData.class);
+      this.addInput(DeploymentType.class);
 
-      // deployment factory
-      final SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
-      this.deploymentModelFactory = spiProvider.getSPI( DeploymentModelFactory.class );
+      // outputs
+      this.addOutput(JBossWebMetaData.class);
+      this.addOutput(Deployment.class);
    }
 
    /**
     * Creates new Web Service deployment and registers it with deployment unit.
     * 
     * @param unit deployment unit
-    * @throws DeploymentException if error occurs
+    * @throws DeploymentException if any error occurs
     */
    @Override
-   protected void internalDeploy( final DeploymentUnit unit ) throws DeploymentException
+   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 );
-      }
+      this.log.debug("Building JBoss agnostic webservices meta data model");
+      WSDeploymentBuilder.getInstance().build(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 );
-   }
-   
 }

Modified: branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/WSDescriptorDeployer.java
===================================================================
--- branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/WSDescriptorDeployer.java	2009-08-18 11:19:53 UTC (rev 92519)
+++ branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/WSDescriptorDeployer.java	2009-08-18 11:43:39 UTC (rev 92520)
@@ -29,9 +29,9 @@
 /**
  * webservices.xml deployer.
  *
- * @author <a href="ropalka at redhat.com">Richard Opalka</a>
+ * @author <a href="mailto:ropalka at redhat.com">Richard Opalka</a>
  */
-public final class WSDescriptorDeployer extends ObjectModelFactoryDeployer< WebservicesMetaData >
+public final class WSDescriptorDeployer extends ObjectModelFactoryDeployer<WebservicesMetaData>
 {
 
    /**
@@ -39,7 +39,7 @@
     */
    public WSDescriptorDeployer()
    {
-      super( WebservicesMetaData.class );
+      super(WebservicesMetaData.class);
    }
 
    /**
@@ -49,9 +49,10 @@
     * @return object model factory
     */
    @Override
-   protected ObjectModelFactory getObjectModelFactory( final WebservicesMetaData root )
+   protected ObjectModelFactory getObjectModelFactory(final WebservicesMetaData root)
    {
-      return new WebservicesFactory( null );
+      this.log.debug("Returning webservices descriptor factory");
+      return new WebservicesFactory(null);
    }
 
 }

Modified: branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/WSEJBAdapterDeployer.java
===================================================================
--- branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/WSEJBAdapterDeployer.java	2009-08-18 11:19:53 UTC (rev 92519)
+++ branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/WSEJBAdapterDeployer.java	2009-08-18 11:43:39 UTC (rev 92520)
@@ -23,7 +23,6 @@
 
 import java.lang.annotation.Annotation;
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
 
 import javax.management.MalformedObjectNameException;
@@ -47,7 +46,7 @@
 /**
  * WebServiceDeployment deployer processes EJB containers and its metadata and creates WS adapters wrapping it.
  *
- * @author <a href="ropalka at redhat.com">Richard Opalka</a>
+ * @author <a href="mailto:ropalka at redhat.com">Richard Opalka</a>
  */
 public final class WSEJBAdapterDeployer extends AbstractRealDeployer
 {
@@ -58,15 +57,15 @@
    public WSEJBAdapterDeployer()
    {
       super();
-      
+
       // inputs
-      this.addInput( MergedJBossMetaDataDeployer.EJB_MERGED_ATTACHMENT_NAME );   
-      this.addInput( EjbDeployment.class );
-      this.addInput( Ejb3Deployment.class );
-      this.addInput( WebservicesMetaData.class );
+      this.addInput(MergedJBossMetaDataDeployer.EJB_MERGED_ATTACHMENT_NAME);
+      this.addInput(EjbDeployment.class);
+      this.addInput(Ejb3Deployment.class);
+      this.addInput(WebservicesMetaData.class);
 
       // outputs
-      this.addOutput( WebServiceDeployment.class );
+      this.addOutput(WebServiceDeployment.class);
    }
 
    /**
@@ -76,36 +75,34 @@
     * @throws DeploymentException exception
     */
    @Override
-   protected void internalDeploy( final DeploymentUnit unit ) throws DeploymentException
+   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 );
+      final JBossMetaData mergedMD = (JBossMetaData) unit
+            .getAttachment(MergedJBossMetaDataDeployer.EJB_MERGED_ATTACHMENT_NAME);
+      final Ejb3Deployment ejb3Deployment = ASHelper.getOptionalAttachment(unit, Ejb3Deployment.class);
 
-      if ( mergedMD != null )
+      if (mergedMD != null)
       {
-         final WebServiceDeploymentAdapter wsDeploymentAdapter = new WebServiceDeploymentAdapter();   
-         final Iterator< JBossEnterpriseBeanMetaData > ejbIterator = mergedMD.getEnterpriseBeans().iterator();
+         final WebServiceDeploymentAdapter wsDeploymentAdapter = new WebServiceDeploymentAdapter();
+         final List<WebServiceDeclaration> endpoints = wsDeploymentAdapter.getServiceEndpoints();
 
-         while ( ejbIterator.hasNext() )
+         for (final JBossEnterpriseBeanMetaData ejbMD : mergedMD.getEnterpriseBeans())
          {
-            final JBossEnterpriseBeanMetaData ejbMD = ejbIterator.next();
-            final EJBContainer ejbContainer = this.getContainer( ejb3Deployment, ejbMD );
-            
-            if ( ejbMD.getEjbClass() != null )
+            final String ejbName = ejbMD.determineContainerName();
+
+            if (ejbMD.getEjbClass() != null)
             {
-               wsDeploymentAdapter.getServiceEndpoints().add(
-                  new WebServiceDeclarationAdapter( ejbMD, ejbContainer, unit.getClassLoader() )
-               );
+               this.log.debug("Creating webservice EJB adapter for: " + ejbName);
+               final EJBContainer ejbContainer = this.getContainer(ejb3Deployment, ejbMD);
+               endpoints.add(new WebServiceDeclarationAdapter(ejbMD, ejbContainer, unit.getClassLoader()));
             }
             else
             {
-               log.warn( "Ingoring ejb deployment with null classname: " + ejbMD );
+               this.log.warn("Ingoring EJB deployment with null classname: " + ejbName);
             }
          }
 
-         unit.addAttachment( WebServiceDeployment.class, wsDeploymentAdapter );
+         unit.addAttachment(WebServiceDeployment.class, wsDeploymentAdapter);
       }
    }
 
@@ -117,22 +114,22 @@
     * @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
+   private EJBContainer getContainer(final Ejb3Deployment ejb3Deployment, final JBossEnterpriseBeanMetaData ejbMD)
+         throws DeploymentException
    {
-      if ( ( ejb3Deployment != null ) && ( !ejbMD.isEntity() ) )
+      if ((ejb3Deployment != null) && (!ejbMD.isEntity()))
       {
          try
          {
-            final ObjectName objName = new ObjectName( ejbMD.determineContainerName() );
-            return ( EJBContainer ) ejb3Deployment.getContainer( objName );
+            final ObjectName objName = new ObjectName(ejbMD.determineContainerName());
+            return (EJBContainer) ejb3Deployment.getContainer(objName);
          }
-         catch ( MalformedObjectNameException e )
+         catch (MalformedObjectNameException e)
          {
-            throw new DeploymentException( e );
+            throw new DeploymentException(e);
          }
       }
-      
+
       return null;
    }
 
@@ -145,10 +142,12 @@
 
       /** EJB meta data. */
       private final JBossEnterpriseBeanMetaData ejbMetaData;
+
       /** EJB container. */
       private final EJBContainer ejbContainer;
+
       /** Class loader. */
-      private final ClassLoader loader;      
+      private final ClassLoader loader;
 
       /**
        * Constructor.
@@ -157,20 +156,16 @@
        * @param ejbContainer EJB container
        * @param loader class loader
        */
-      private WebServiceDeclarationAdapter
-      (
-         final JBossEnterpriseBeanMetaData ejbMetaData, 
-         final EJBContainer ejbContainer, 
-         final ClassLoader 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.
        *
@@ -218,18 +213,18 @@
        * @param <T> annotation class type
        * @return requested annotation or null if not found
        */
-      public < T extends Annotation > T getAnnotation( final Class<T> annotationType )
+      public <T extends Annotation> T getAnnotation(final Class<T> annotationType)
       {
-         final boolean haveEjbContainer = this.ejbContainer != null; 
+         final boolean haveEjbContainer = this.ejbContainer != null;
 
-         if ( haveEjbContainer )
+         if (haveEjbContainer)
          {
-            return this.ejbContainer.getAnnotation( annotationType );
+            return this.ejbContainer.getAnnotation(annotationType);
          }
          else
          {
-            final Class< ? > bean = this.getComponentClass();
-            return ( T ) bean.getAnnotation( annotationType );
+            final Class<?> bean = this.getComponentClass();
+            return (T) bean.getAnnotation(annotationType);
          }
       }
 
@@ -238,16 +233,16 @@
        *
        * @return ejb class instance
        */
-      private Class< ? > getComponentClass()
+      private Class<?> getComponentClass()
       {
          try
          {
-            return this.loader.loadClass( this.getComponentClassName() );
+            return this.loader.loadClass(this.getComponentClassName());
          }
-         catch ( ClassNotFoundException cnfe )
+         catch (ClassNotFoundException cnfe)
          {
-            throw new RuntimeException( "Failed to load component class: " + 
-               this.getComponentClassName() + " from loader: " + this.loader );
+            throw new RuntimeException("Failed to load component class: " + this.getComponentClassName()
+                  + " from loader: " + this.loader);
          }
       }
 
@@ -259,9 +254,9 @@
     */
    private static final class WebServiceDeploymentAdapter implements WebServiceDeployment
    {
-      
+
       /** List of endpoints. */
-      private final List< WebServiceDeclaration > endpoints = new ArrayList< WebServiceDeclaration >();
+      private final List<WebServiceDeclaration> endpoints = new ArrayList<WebServiceDeclaration>();
 
       /**
        * Constructor.
@@ -270,15 +265,15 @@
       {
          super();
       }
-      
+
       /**
        * Returns endpoints list.
        * 
        * @return endpoints list
        */
-      public List< WebServiceDeclaration > getServiceEndpoints()
+      public List<WebServiceDeclaration> getServiceEndpoints()
       {
-         return this.endpoints;  
+         return this.endpoints;
       }
 
    }

Modified: branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/WSTypeDeployer.java
===================================================================
--- branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/WSTypeDeployer.java	2009-08-18 11:19:53 UTC (rev 92519)
+++ branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/WSTypeDeployer.java	2009-08-18 11:43:39 UTC (rev 92520)
@@ -34,7 +34,7 @@
 /**
  * Detects Web Service deployment type.
  *
- * @author <a href="ropalka at redhat.com">Richard Opalka</a>
+ * @author <a href="mailto:ropalka at redhat.com">Richard Opalka</a>
  */
 public final class WSTypeDeployer extends AbstractRealDeployer
 {
@@ -45,15 +45,15 @@
    public WSTypeDeployer()
    {
       super();
-      
+
       // inputs
-      this.addInput( JBossWebMetaData.class );
-      this.addInput( WebservicesMetaData.class );
-      this.addInput( WebServiceDeployment.class );
-      
+      this.addInput(JBossWebMetaData.class);
+      this.addInput(WebservicesMetaData.class);
+      this.addInput(WebServiceDeployment.class);
+
       // outputs
-      this.addOutput( DeploymentType.class );
-      this.addOutput( JBossWebMetaData.class );
+      this.addOutput(DeploymentType.class);
+      this.addOutput(JBossWebMetaData.class);
    }
 
    /**
@@ -63,72 +63,76 @@
     * @throws DeploymentException on failure
     */
    @Override
-   protected void internalDeploy( final DeploymentUnit unit ) throws DeploymentException
+   protected void internalDeploy(final DeploymentUnit unit) throws DeploymentException
    {
-      if ( this.isJaxwsJseDeployment( unit ) )
+      if (this.isJaxwsJseDeployment(unit))
       {
-         unit.addAttachment( DeploymentType.class, DeploymentType.JAXWS_JSE );
+         this.log.debug("Detected JAXWS JSE deployment");
+         unit.addAttachment(DeploymentType.class, DeploymentType.JAXWS_JSE);
       }
-      else if ( this.isJaxwsEjbDeployment( unit ) )
+      else if (this.isJaxwsEjbDeployment(unit))
       {
-         unit.addAttachment( DeploymentType.class, DeploymentType.JAXWS_EJB3 );
+         this.log.debug("Detected JAXWS EJB3 deployment");
+         unit.addAttachment(DeploymentType.class, DeploymentType.JAXWS_EJB3);
       }
-      else if ( this.isJaxrpcJseDeployment( unit ) )
+      else if (this.isJaxrpcJseDeployment(unit))
       {
-         unit.addAttachment( DeploymentType.class, DeploymentType.JAXRPC_JSE );
+         this.log.debug("Detected JAXRPC JSE deployment");
+         unit.addAttachment(DeploymentType.class, DeploymentType.JAXRPC_JSE);
       }
-      else if ( this.isJaxrpcEjbDeployment( unit ) )
+      else if (this.isJaxrpcEjbDeployment(unit))
       {
-         unit.addAttachment( DeploymentType.class, DeploymentType.JAXRPC_EJB21 );
+         this.log.debug("Detected JAXRPC EJB21 deployment");
+         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 )
+   private boolean isJaxrpcEjbDeployment(final DeploymentUnit unit)
    {
-      final boolean hasWebservicesMD = ASHelper.hasAttachment( unit, WebservicesMetaData.class );
-      final boolean hasJBossMD = unit.getAllMetaData( JBossMetaData.class ).size() > 0;
-      
+      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 )
+   private boolean isJaxrpcJseDeployment(final DeploymentUnit unit)
    {
-      final boolean hasWebservicesMD = ASHelper.hasAttachment( unit, WebservicesMetaData.class );
-      final boolean hasJBossWebMD = ASHelper.hasAttachment( unit, JBossWebMetaData.class );
+      final boolean hasWebservicesMD = ASHelper.hasAttachment(unit, WebservicesMetaData.class);
+      final boolean hasJBossWebMD = ASHelper.hasAttachment(unit, JBossWebMetaData.class);
 
-      if ( hasWebservicesMD && hasJBossWebMD )
+      if (hasWebservicesMD && hasJBossWebMD)
       {
-         return ASHelper.getJaxrpcServlets( unit ).size() > 0;
+         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 )
+   private boolean isJaxwsEjbDeployment(final DeploymentUnit unit)
    {
-      final boolean hasWSDeployment = ASHelper.hasAttachment( unit, WebServiceDeployment.class );
+      final boolean hasWSDeployment = ASHelper.hasAttachment(unit, WebServiceDeployment.class);
 
-      if ( hasWSDeployment )
+      if (hasWSDeployment)
       {
-         return ASHelper.getJaxwsEjbs( unit ).size() > 0;
+         return ASHelper.getJaxwsEjbs(unit).size() > 0;
       }
 
       return false;
@@ -140,13 +144,13 @@
     * @param unit deployment unit
     * @return true if JAXWS JSE, false otherwise
     */
-   private boolean isJaxwsJseDeployment( final DeploymentUnit unit )
+   private boolean isJaxwsJseDeployment(final DeploymentUnit unit)
    {
-      final boolean hasJBossWebMD = ASHelper.hasAttachment( unit, JBossWebMetaData.class );
+      final boolean hasJBossWebMD = ASHelper.hasAttachment(unit, JBossWebMetaData.class);
 
-      if ( hasJBossWebMD )
+      if (hasJBossWebMD)
       {
-         return ASHelper.getJaxwsServlets( unit ).size() > 0;
+         return ASHelper.getJaxwsServlets(unit).size() > 0;
       }
 
       return false;

Deleted: branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/WSVirtualFileFilter.java
===================================================================
--- branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/WSVirtualFileFilter.java	2009-08-18 11:19:53 UTC (rev 92519)
+++ branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/WSVirtualFileFilter.java	2009-08-18 11:43:39 UTC (rev 92520)
@@ -1,89 +0,0 @@
-/*
- * 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/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/deployment/AbstractDeploymentModelBuilder.java
===================================================================
--- branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/deployment/AbstractDeploymentModelBuilder.java	                        (rev 0)
+++ branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/deployment/AbstractDeploymentModelBuilder.java	2009-08-18 11:43:39 UTC (rev 92520)
@@ -0,0 +1,190 @@
+package org.jboss.webservices.integration.deployers.deployment;
+
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.serviceref.VirtualFileAdaptor;
+import org.jboss.virtual.VirtualFile;
+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;
+
+/**
+ * Base class for all deployment model builders.
+ * 
+ * @author <a href="mailto:ropalka at redhat.com">Richard Opalka</a>
+ */
+abstract class AbstractDeploymentModelBuilder implements DeploymentModelBuilder
+{
+
+   /** WSDL, XSD and XML files filter. */
+   private static final WSVirtualFileFilter WS_FILE_FILTER = new WSVirtualFileFilter();
+
+   /** Logger. */
+   protected final Logger log = Logger.getLogger(this.getClass());
+
+   /** Deployment model factory. */
+   private final DeploymentModelFactory deploymentModelFactory;
+
+   /**
+    * Constructor.
+    */
+   protected AbstractDeploymentModelBuilder()
+   {
+      super();
+
+      // deployment factory
+      final SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
+      this.deploymentModelFactory = spiProvider.getSPI(DeploymentModelFactory.class);
+   }
+
+   /**
+    * @see org.jboss.webservices.integration.deployers.deployment.DeploymentModelBuilder#newDeploymentModel(DeploymentUnit)
+    * 
+    * @param unit deployment unit
+    */
+   public final void newDeploymentModel(final DeploymentUnit unit)
+   {
+      final ArchiveDeployment dep = this.newDeployment(unit);
+
+      this.build(dep, unit);
+
+      dep.addAttachment(DeploymentUnit.class, unit);
+      unit.addAttachment(Deployment.class, dep);
+   }
+
+   /**
+    * Template method for subclasses to implement.
+    * 
+    * @param dep webservice deployment
+    * @param unit deployment unit
+    */
+   protected abstract void build(Deployment dep, DeploymentUnit unit);
+
+   /**
+    * Creates new Web Service endpoint.
+    * 
+    * @param endpointClass endpoint class name
+    * @param endpointName endpoint name
+    * @param dep deployment
+    * @return WS endpoint
+    */
+   protected final Endpoint newEndpoint(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;
+   }
+
+   /**
+    * Creates new Web Service deployment.
+    * 
+    * @param unit deployment unit
+    * @return archive deployment
+    */
+   private ArchiveDeployment newDeployment(final DeploymentUnit unit)
+   {
+      this.log.debug("Creating new WS deployment model for: " + unit);
+      final ArchiveDeployment dep = this.newDeployment(unit.getSimpleName(), unit.getClassLoader());
+
+      if (unit instanceof VFSDeploymentUnit)
+      {
+         final VFSDeploymentUnit vfsUnit = (VFSDeploymentUnit) unit;
+         final List<VirtualFile> virtualFiles = vfsUnit.getMetaDataFiles(AbstractDeploymentModelBuilder.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 String parentDeploymentName = unit.getParent().getSimpleName();
+         final ClassLoader parentClassLoader = unit.getParent().getClassLoader();
+
+         this.log.debug("Creating new WS deployment model for parent: " + unit.getParent());
+         final ArchiveDeployment parentDep = this.newDeployment(parentDeploymentName, parentClassLoader);
+         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 archive deployment.
+    * 
+    * @param name deployment name
+    * @param loader deployment loader
+    * @return new archive deployment
+    */
+   private ArchiveDeployment newDeployment(final String name, final ClassLoader loader)
+   {
+      return (ArchiveDeployment) this.deploymentModelFactory.newDeployment(name, loader);
+   }
+
+   /**
+    * 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
+    */
+   protected final <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/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/deployment/DeploymentModelBuilder.java
===================================================================
--- branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/deployment/DeploymentModelBuilder.java	                        (rev 0)
+++ branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/deployment/DeploymentModelBuilder.java	2009-08-18 11:43:39 UTC (rev 92520)
@@ -0,0 +1,20 @@
+package org.jboss.webservices.integration.deployers.deployment;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+
+/**
+ * Deployment builder interface.
+ * 
+ * @author <a href="mailto:ropalka at redhat.com">Richard Opalka</a>
+ */
+interface DeploymentModelBuilder
+{
+
+   /**
+    * Creates Web Service deployment model and associates it with deployment.
+    * 
+    * @param unit deployment unit
+    */
+   void newDeploymentModel(DeploymentUnit unit);
+
+}

Added: branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/deployment/JaxrpcEjbDeploymentModelBuilder.java
===================================================================
--- branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/deployment/JaxrpcEjbDeploymentModelBuilder.java	                        (rev 0)
+++ branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/deployment/JaxrpcEjbDeploymentModelBuilder.java	2009-08-18 11:43:39 UTC (rev 92520)
@@ -0,0 +1,57 @@
+package org.jboss.webservices.integration.deployers.deployment;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+import org.jboss.wsf.spi.deployment.Deployment;
+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;
+
+/**
+ * Creates new JAXRPC EJB21 deployment.
+ * 
+ * @author <a href="mailto:ropalka at redhat.com">Richard Opalka</a>
+ */
+final class JaxrpcEjbDeploymentModelBuilder extends AbstractDeploymentModelBuilder
+{
+
+   /**
+    * Constructor.
+    */
+   JaxrpcEjbDeploymentModelBuilder()
+   {
+      super();
+   }
+
+   /**
+    * Creates new JAXRPC EJB21 deployment and registers it with deployment unit.
+    * 
+    * @param dep webservice deployment
+    * @param unit deployment unit
+    */
+   @Override
+   protected void build(final Deployment dep, final DeploymentUnit 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);
+
+      this.log.debug("Creating JAXRPC EJB21 endpoints meta data model");
+      for (final WebserviceDescriptionMetaData webserviceDescriptionMD : wsMetaData.getWebserviceDescriptions())
+      {
+         for (final PortComponentMetaData portComponentMD : webserviceDescriptionMD.getPortComponents())
+         {
+            final String ejbName = portComponentMD.getEjbLink();
+            this.log.debug("EJB21 name: " + ejbName);
+            final JBossEnterpriseBeanMetaData beanMetaData = jbmd.getEnterpriseBean(ejbName);
+            final String ejbClass = beanMetaData.getEjbClass();
+            this.log.debug("EJB21 class: " + ejbClass);
+
+            this.newEndpoint(ejbClass, ejbName, dep);
+         }
+      }
+   }
+
+}

Added: branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/deployment/JaxrpcJseDeploymentModelBuilder.java
===================================================================
--- branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/deployment/JaxrpcJseDeploymentModelBuilder.java	                        (rev 0)
+++ branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/deployment/JaxrpcJseDeploymentModelBuilder.java	2009-08-18 11:43:39 UTC (rev 92520)
@@ -0,0 +1,56 @@
+package org.jboss.webservices.integration.deployers.deployment;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+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.spi.deployment.Deployment;
+import org.jboss.wsf.spi.metadata.webservices.PortComponentMetaData;
+import org.jboss.wsf.spi.metadata.webservices.WebserviceDescriptionMetaData;
+import org.jboss.wsf.spi.metadata.webservices.WebservicesMetaData;
+
+/**
+ * Creates new JAXRPC JSE deployment.
+ * 
+ * @author <a href="mailto:ropalka at redhat.com">Richard Opalka</a>
+ */
+final class JaxrpcJseDeploymentModelBuilder extends AbstractDeploymentModelBuilder
+{
+
+   /**
+    * Constructor.
+    */
+   JaxrpcJseDeploymentModelBuilder()
+   {
+      super();
+   }
+
+   /**
+    * Creates new JAXRPC JSE deployment and registers it with deployment unit.
+    * 
+    * @param dep webservice deployment
+    * @param unit deployment unit
+    */
+   @Override
+   protected void build(final Deployment dep, final DeploymentUnit unit)
+   {
+      final JBossWebMetaData webMetaData = this.getAndPropagateAttachment(JBossWebMetaData.class, unit, dep);
+      final WebservicesMetaData wsMetaData = this.getAndPropagateAttachment(WebservicesMetaData.class, unit, dep);
+
+      this.log.debug("Creating JAXRPC JSE endpoints meta data model");
+      for (WebserviceDescriptionMetaData wsd : wsMetaData.getWebserviceDescriptions())
+      {
+         for (PortComponentMetaData pcmd : wsd.getPortComponents())
+         {
+            final String servletName = pcmd.getServletLink();
+            this.log.debug("JSE name: " + servletName);
+            final ServletMetaData servletMD = ASHelper.getServletForName(webMetaData, servletName);
+            final String servletClass = ASHelper.getEndpointName(servletMD);
+            this.log.debug("JSE class: " + servletClass);
+
+            this.newEndpoint(servletClass, servletName, dep);
+         }
+      }
+   }
+
+}

Added: branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/deployment/JaxwsEjbDeploymentModelBuilder.java
===================================================================
--- branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/deployment/JaxwsEjbDeploymentModelBuilder.java	                        (rev 0)
+++ branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/deployment/JaxwsEjbDeploymentModelBuilder.java	2009-08-18 11:43:39 UTC (rev 92520)
@@ -0,0 +1,52 @@
+package org.jboss.webservices.integration.deployers.deployment;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+import org.jboss.webservices.integration.util.ASHelper;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.deployment.integration.WebServiceDeclaration;
+import org.jboss.wsf.spi.deployment.integration.WebServiceDeployment;
+
+/**
+ * Creates new JAXWS EJB3 deployment.
+ * 
+ * @author <a href="mailto:ropalka at redhat.com">Richard Opalka</a>
+ */
+final class JaxwsEjbDeploymentModelBuilder extends AbstractDeploymentModelBuilder
+{
+
+   /**
+    * Constructor.
+    */
+   JaxwsEjbDeploymentModelBuilder()
+   {
+      super();
+   }
+
+   /**
+    * Creates new JAXWS EJB3 deployment and registers it with deployment unit.
+    * 
+    * @param dep webservice deployment
+    * @param unit deployment unit
+    */
+   @Override
+   protected void build(final Deployment dep, final DeploymentUnit unit)
+   {
+      this.getAndPropagateAttachment(WebServiceDeployment.class, unit, dep);
+      this.getAndPropagateAttachment(JBossMetaData.class, unit, dep);
+
+      this.log.debug("Creating JAXWS EJB3 endpoints meta data model");
+      for (final WebServiceDeclaration container : ASHelper.getJaxwsEjbs(unit))
+      {
+         final String ejbName = container.getComponentName();
+         this.log.debug("EJB3 name: " + ejbName);
+         final String ejbClass = container.getComponentClassName();
+         this.log.debug("EJB3 class: " + ejbClass);
+
+         final Endpoint ep = this.newEndpoint(ejbClass, ejbName, dep);
+         ep.setProperty(ASHelper.CONTAINER_NAME, container.getContainerName());
+      }
+   }
+
+}

Added: branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/deployment/JaxwsJseDeploymentModelBuilder.java
===================================================================
--- branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/deployment/JaxwsJseDeploymentModelBuilder.java	                        (rev 0)
+++ branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/deployment/JaxwsJseDeploymentModelBuilder.java	2009-08-18 11:43:39 UTC (rev 92520)
@@ -0,0 +1,51 @@
+package org.jboss.webservices.integration.deployers.deployment;
+
+import java.util.List;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+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.spi.deployment.Deployment;
+
+/**
+ * Creates new JAXWS JSE deployment.
+ * 
+ * @author <a href="mailto:ropalka at redhat.com">Richard Opalka</a>
+ */
+final class JaxwsJseDeploymentModelBuilder extends AbstractDeploymentModelBuilder
+{
+
+   /**
+    * Constructor.
+    */
+   JaxwsJseDeploymentModelBuilder()
+   {
+      super();
+   }
+
+   /**
+    * Creates new JAXWS JSE deployment and registers it with deployment unit.
+    * 
+    * @param dep webservice deployment
+    * @param unit deployment unit
+    */
+   @Override
+   protected void build(final Deployment dep, final DeploymentUnit unit)
+   {
+      this.getAndPropagateAttachment(JBossWebMetaData.class, unit, dep);
+
+      this.log.debug("Creating JAXWS JSE endpoints meta data model");
+      final List<ServletMetaData> servlets = ASHelper.getJaxwsServlets(unit);
+      for (ServletMetaData servlet : servlets)
+      {
+         final String servletName = servlet.getName();
+         this.log.debug("JSE name: " + servletName);
+         final String servletClass = ASHelper.getEndpointName(servlet);
+         this.log.debug("JSE class: " + servletClass);
+
+         this.newEndpoint(servletClass, servletName, dep);
+      }
+   }
+
+}

Added: branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/deployment/WSDeploymentBuilder.java
===================================================================
--- branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/deployment/WSDeploymentBuilder.java	                        (rev 0)
+++ branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/deployment/WSDeploymentBuilder.java	2009-08-18 11:43:39 UTC (rev 92520)
@@ -0,0 +1,86 @@
+/*
+ * 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.deployment;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.webservices.integration.util.ASHelper;
+import org.jboss.wsf.spi.deployment.Deployment.DeploymentType;
+
+/**
+ * JBossWS deployment model builder.
+ *
+ * @author <a href="mailto:ropalka at redhat.com">Richard Opalka</a>
+ */
+public final class WSDeploymentBuilder
+{
+
+   /** Builder instance. */
+   private static final WSDeploymentBuilder SINGLETON = new WSDeploymentBuilder();
+
+   /** Builders registry. */
+   private static final Map<DeploymentType, DeploymentModelBuilder> builders = new HashMap<DeploymentType, DeploymentModelBuilder>();;
+
+   static
+   {
+      WSDeploymentBuilder.builders.put(DeploymentType.JAXWS_JSE, new JaxwsJseDeploymentModelBuilder());
+      WSDeploymentBuilder.builders.put(DeploymentType.JAXRPC_JSE, new JaxrpcJseDeploymentModelBuilder());
+      WSDeploymentBuilder.builders.put(DeploymentType.JAXWS_EJB3, new JaxwsEjbDeploymentModelBuilder());
+      WSDeploymentBuilder.builders.put(DeploymentType.JAXRPC_EJB21, new JaxrpcEjbDeploymentModelBuilder());
+   }
+
+   /**
+    * Constructor.
+    */
+   private WSDeploymentBuilder()
+   {
+      super();
+   }
+
+   /**
+    * Factory method for obtaining builder instance. 
+    * 
+    * @return builder instance
+    */
+   public static WSDeploymentBuilder getInstance()
+   {
+      return WSDeploymentBuilder.SINGLETON;
+   }
+
+   /**
+    * Builds JBossWS deployment model if web service deployment is detected.
+    * 
+    * @param unit deployment unit
+    */
+   public void build(final DeploymentUnit unit)
+   {
+      final DeploymentType deploymentType = ASHelper.getOptionalAttachment(unit, DeploymentType.class);
+
+      if (deploymentType != null)
+      {
+         WSDeploymentBuilder.builders.get(deploymentType).newDeploymentModel(unit);
+      }
+   }
+
+}

Added: branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/deployment/WSVirtualFileFilter.java
===================================================================
--- branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/deployment/WSVirtualFileFilter.java	                        (rev 0)
+++ branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/deployers/deployment/WSVirtualFileFilter.java	2009-08-18 11:43:39 UTC (rev 92520)
@@ -0,0 +1,68 @@
+package org.jboss.webservices.integration.deployers.deployment;
+
+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="mailto:ropalka at redhat.com">Richard Opalka</a>
+ */
+final class WSVirtualFileFilter implements VirtualFileFilterWithAttributes
+{
+
+   /** The tree walking attributes. */
+   private VisitorAttributes attributes;
+
+   /**
+    * Constructor. 
+    */
+   WSVirtualFileFilter()
+   {
+      this(VisitorAttributes.RECURSE_LEAVES_ONLY);
+   }
+
+   /**
+    * Constructor.
+    * 
+    * @param attributes visit attributes
+    */
+   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;
+   }
+
+}

Modified: branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/injection/EJBBeanReferenceResolver.java
===================================================================
--- branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/injection/EJBBeanReferenceResolver.java	2009-08-18 11:19:53 UTC (rev 92519)
+++ branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/injection/EJBBeanReferenceResolver.java	2009-08-18 11:43:39 UTC (rev 92520)
@@ -43,6 +43,7 @@
     * Deployment unit used for resolving process.
     */
    private final DeploymentUnit unit;
+
    /**
     * Delegate used to resolve JNDI names.
     */
@@ -50,8 +51,11 @@
 
    /**
     * Constructor.
+    * 
+    * @param unit deployment unit
+    * @param delegate EJB reference resolver
     */
-   public EJBBeanReferenceResolver(final DeploymentUnit unit, final EjbReferenceResolver delegate)
+   EJBBeanReferenceResolver(final DeploymentUnit unit, final EjbReferenceResolver delegate)
    {
       super(EJB.class);
 
@@ -68,30 +72,36 @@
       this.delegate = delegate;
    }
 
-   /* (non-Javadoc)
+   /**
     * @see org.jboss.wsf.common.injection.resolvers.AbstractReferenceResolver#resolveField(java.lang.reflect.Field)
+    * 
+    * @param field to be resolved
+    * @return JNDI name of referenced EJB object
     */
    @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);
+      final EjbReference reference = this.getEjbReference(ejbAnnotation, type);
 
-      return this.delegate.resolveEjb(unit, reference);
+      return this.delegate.resolveEjb(this.unit, reference);
    }
 
-   /* (non-Javadoc)
+   /**
     * @see org.jboss.wsf.common.injection.resolvers.AbstractReferenceResolver#resolveMethod(java.lang.reflect.Method)
+    * 
+    * @param method to be resolved
+    * @return JNDI name of referenced EJB object
     */
    @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);
+      final Class<?> type = method.getParameterTypes()[0];
+      final EjbReference reference = this.getEjbReference(ejbAnnotation, type);
 
-      return this.delegate.resolveEjb(unit, reference);
+      return this.delegate.resolveEjb(this.unit, reference);
    }
 
    /**
@@ -101,7 +111,7 @@
     * @param type fall back type
     * @return ejb reference instance
     */
-   private EjbReference getEjbReference(EJB ejbAnnotation, Class<?> type)
+   private EjbReference getEjbReference(final EJB ejbAnnotation, final Class<?> type)
    {
       String beanInterface = ejbAnnotation.beanInterface().getName();
       if (java.lang.Object.class.getName().equals(beanInterface))

Modified: branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/injection/InjectionMetaDataDeploymentAspect.java
===================================================================
--- branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/injection/InjectionMetaDataDeploymentAspect.java	2009-08-18 11:19:53 UTC (rev 92519)
+++ branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/injection/InjectionMetaDataDeploymentAspect.java	2009-08-18 11:43:39 UTC (rev 92520)
@@ -24,7 +24,6 @@
 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;
@@ -32,10 +31,8 @@
 
 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;
@@ -65,55 +62,128 @@
 public final class InjectionMetaDataDeploymentAspect extends DeploymentAspect
 {
 
-   private static final ReferenceResolver RESOURCE_REFERENCE_RESOLVER = new ResourceReferenceResolver(); 
+   /** EJB 3 JNDI prefix. */
    private static final String EJB3_JNDI_PREFIX = "java:env/";
+
+   /** Resolver handling @Resource injections. */
+   private static final ReferenceResolver RESOURCE_RESOLVER = new ResourceReferenceResolver();
+
+   /** EJB 3 reference resolver. */
    private EjbReferenceResolver ejbReferenceResolver;
 
+   /**
+    * Constructor.
+    */
+   public InjectionMetaDataDeploymentAspect()
+   {
+      super();
+   }
+
+   /**
+    * 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;
+   }
+
+   /**
+    * Builds injection meta data for all endpoints in deployment.
+    * 
+    * @param dep webservice deployment
+    */
    @Override
-   public void start(Deployment dep)
+   public void start(final Deployment dep)
    {
-      super.start(dep);
+      final DeploymentUnit unit = WSHelper.getRequiredAttachment(dep, DeploymentUnit.class);
+      final JBossWebMetaData jbossWebMD = WSHelper.getRequiredAttachment(dep, JBossWebMetaData.class);
+      final Map<Class<? extends Annotation>, ReferenceResolver> resolvers = this.getResolvers(unit);
 
-      DeploymentUnit unit = WSHelper.getRequiredAttachment( dep, DeploymentUnit.class );
-      JBossWebMetaData webMD = WSHelper.getRequiredAttachment( dep, JBossWebMetaData.class );
+      if (WSHelper.isJaxwsJseDeployment(dep))
+      {
+         this.log.debug("Building injection meta data for JAXWS JSE webservice deployment: " + dep.getSimpleName());
+         final EnvironmentEntriesMetaData envEntriesMD = jbossWebMD.getEnvironmentEntries();
 
-      List<InjectionMetaData> injectionMD = new LinkedList<InjectionMetaData>();
-      Map<Class<? extends Annotation>, ReferenceResolver> resolvers = createResolvers(unit);
+         // iterate through all POJO endpoints
+         for (Endpoint endpoint : dep.getService().getEndpoints())
+         {
+            // build POJO injections meta data
+            final InjectionsMetaData injectionsMD = this.buildInjectionsMetaData(envEntriesMD, resolvers, null);
 
-      try
+            // associate injections meta data with POJO endpoint
+            endpoint.addAttachment(InjectionsMetaData.class, injectionsMD);
+         }
+      }
+      else if (WSHelper.isJaxwsEjbDeployment(dep))
       {
-         
-         if ( WSHelper.isJaxwsJseDeployment( dep ) )
+         this.log.debug("Building injection meta data for JAXWS EJB3 webservice deployment: " + dep.getSimpleName());
+         final WebServiceDeployment webServiceDeployment = ASHelper.getRequiredAttachment(unit,
+               WebServiceDeployment.class);
+
+         // iterate through all EJB3 endpoints
+         for (final WebServiceDeclaration container : webServiceDeployment.getServiceEndpoints())
          {
-            injectionMD.addAll(buildInjectionMetaData(webMD.getEnvironmentEntries()));
-            for (Endpoint endpoint : dep.getService().getEndpoints())
+            if (ASHelper.isWebServiceBean(container))
             {
-               InjectionsMetaData injectionsMD = new InjectionsMetaData(injectionMD, resolvers, null);
+               final String ejbName = container.getComponentName();
+
+               // build EJB 3 injections meta data
+               final EnvironmentEntriesMetaData ejbEnvEntries = this.getEnvironmentEntries(ejbName, unit);
+               final Context jndiContext = this.getJndiContext(container);
+               final InjectionsMetaData injectionsMD = this.buildInjectionsMetaData(ejbEnvEntries, resolvers,
+                     jndiContext);
+
+               // associate injections meta data with EJB 3 endpoint
+               final Endpoint endpoint = dep.getService().getEndpointByName(ejbName);
                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);
-               }
-            }
-         }
+   /**
+    * Returns environment entries meta data associated with specified EJB 3 bean.
+    * 
+    * @param ejbName EJB 3 bean to lookup environment entries for
+    * @param unit deployment unit
+    * @return environment entries meta data
+    */
+   private EnvironmentEntriesMetaData getEnvironmentEntries(final String ejbName, final DeploymentUnit unit)
+   {
+      final JBossMetaData jbossMD = ASHelper.getRequiredAttachment(unit, JBossMetaData.class);
+      final JBossEnterpriseBeansMetaData enterpriseBeansMDs = jbossMD.getEnterpriseBeans();
+
+      return enterpriseBeansMDs.get(ejbName).getEnvironmentEntries();
+   }
+
+   /**
+    * Returns JNDI context associated with EJB 3 container.
+    * 
+    * @param container EJB 3 container
+    * @return JNDI context
+    */
+   private Context getJndiContext(final WebServiceDeclaration container)
+   {
+      try
+      {
+         return (Context) container.getContext().lookup(InjectionMetaDataDeploymentAspect.EJB3_JNDI_PREFIX);
       }
       catch (NamingException ne)
       {
@@ -121,65 +191,86 @@
       }
    }
 
-   @Override
-   public void stop(Deployment dep)
-   {
-      dep.getService().removeAttachment(InjectionMetaData.class);
-
-      super.stop(dep);
-   }
-
    /**
-    * Builds reference resolvers container.
+    * Returns reference resolvers container.
     *
     * @param unit deployment unit
     * @return reference resolvers
     */
-   private Map<Class<? extends Annotation>, ReferenceResolver> createResolvers(DeploymentUnit unit)
+   private Map<Class<? extends Annotation>, ReferenceResolver> getResolvers(final 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()));
+
+      resolvers.put(Resource.class, InjectionMetaDataDeploymentAspect.RESOURCE_RESOLVER);
+      resolvers.put(EJB.class, new EJBBeanReferenceResolver(unit, this.getEjbReferenceResolver()));
+
       return resolvers;
    }
 
    /**
-    * Builds JBossWS specific injection metadata from JBoss metadata.
+    * Builds JBossWS specific injections meta data.
+    * 
+    * @param envEntriesMD environment entries meta data
+    * @param resolvers known annotation resolvers
+    * @param jndiContext JNDI context to be propagated
+    * @return injections meta data
+    */
+   private InjectionsMetaData buildInjectionsMetaData(final EnvironmentEntriesMetaData envEntriesMD,
+         final Map<Class<? extends Annotation>, ReferenceResolver> resolvers, final Context jndiContext)
+   {
+      final List<InjectionMetaData> injectionMD = new LinkedList<InjectionMetaData>();
+      injectionMD.addAll(this.buildInjectionMetaData(envEntriesMD));
+
+      return new InjectionsMetaData(injectionMD, resolvers, jndiContext);
+   }
+
+   /**
+    * Builds JBossWS specific injection meta data.
     *
-    * @param envEntries environment entries
-    * @return JBossWS specific injection metadata
+    * @param envEntriesMD environment entries meta data
+    * @return injection meta data
     */
-   private List<InjectionMetaData> buildInjectionMetaData(EnvironmentEntriesMetaData envEntries)
+   private List<InjectionMetaData> buildInjectionMetaData(final EnvironmentEntriesMetaData envEntriesMD)
    {
-      if ((envEntries == null) || (envEntries.size() == 0))
+      if ((envEntriesMD == null) || (envEntriesMD.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;
+      final LinkedList<InjectionMetaData> retVal = new LinkedList<InjectionMetaData>();
 
-      for (Iterator<EnvironmentEntryMetaData> i = envEntries.iterator(); i.hasNext();)
+      Set<ResourceInjectionTargetMetaData> injectionTargets;
+      String envEntryName;
+      String envEntryValue;
+      String targetClass;
+      String targetName;
+      String envEntryValueClass;
+      boolean hasInjectionTargets;
+
+      // iterate through defined environment entries
+      for (final EnvironmentEntryMetaData envEntryMD : envEntriesMD)
       {
-         eeMD = i.next();
-         envEntryName = eeMD.getEnvEntryName();
-         envEntryValue = eeMD.getValue();
-         valueClass = eeMD.getType();
+         injectionTargets = envEntryMD.getInjectionTargets();
+         hasInjectionTargets = (injectionTargets != null) && (injectionTargets.size() > 0);
 
-         Set<ResourceInjectionTargetMetaData> injectionTargets = eeMD.getInjectionTargets();
-         if ((injectionTargets != null) && (injectionTargets.size() > 0))
+         if (hasInjectionTargets)
          {
-            for (Iterator<ResourceInjectionTargetMetaData> j = injectionTargets.iterator(); j.hasNext(); )
+            // prepare env entry meta data
+            envEntryName = envEntryMD.getEnvEntryName();
+            envEntryValue = envEntryMD.getValue();
+            envEntryValueClass = envEntryMD.getType();
+
+            // env entry can specify multiple injection targets
+            for (final ResourceInjectionTargetMetaData resourceInjectionTargetMD : injectionTargets)
             {
-               ResourceInjectionTargetMetaData ritMD = j.next();
-               targetClass = ritMD.getInjectionTargetClass();
-               targetName = ritMD.getInjectionTargetName();
-               InjectionMetaData injectionMD = new InjectionMetaData(targetClass, targetName, valueClass, envEntryName, envEntryValue != null);
+               // prepare injection target meta data
+               targetClass = resourceInjectionTargetMD.getInjectionTargetClass();
+               targetName = resourceInjectionTargetMD.getInjectionTargetName();
+
+               // build injection meta data for injection target
+               final InjectionMetaData injectionMD = new InjectionMetaData(targetClass, targetName, envEntryValueClass,
+                     envEntryName, envEntryValue != null);
+               this.log.debug(injectionMD);
                retVal.add(injectionMD);
             }
          }
@@ -188,43 +279,4 @@
       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;
-   }
-
 }

Modified: branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/invocation/AbstractInvocationHandler.java
===================================================================
--- branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/invocation/AbstractInvocationHandler.java	2009-08-18 11:19:53 UTC (rev 92519)
+++ branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/invocation/AbstractInvocationHandler.java	2009-08-18 11:43:39 UTC (rev 92520)
@@ -23,30 +23,65 @@
 
 import java.lang.reflect.Method;
 
-import org.jboss.wsf.common.JavaUtils;
+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.InvocationHandler;
 
 /**
- * @author Thomas.Diesler at jboss.org
+ * Base class for all Web Service invocation handlers inside AS.
+ * 
+ * @author <a href="mailto:ropalka at redhat.com">Richard Opalka</a>
+ * @author <a href="mailto:tdiesler at redhat.com">Thomas Diesler</a>
  */
-public abstract class AbstractInvocationHandler extends InvocationHandler
+abstract class AbstractInvocationHandler extends InvocationHandler
 {
-   protected Method getImplMethod(Class implClass, Method seiMethod) throws ClassNotFoundException, NoSuchMethodException
+
+   /** Logger. */
+   protected final Logger log = Logger.getLogger(this.getClass());
+
+   /**
+    * Constructor.
+    */
+   protected AbstractInvocationHandler()
    {
-      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;
-         }
-      }
+      super();
+   }
 
-      Method implMethod = implClass.getMethod(methodName, paramTypes);
-      return implMethod;
+   /**
+    * Creates invocation.
+    * 
+    * @return invocation instance
+    */
+   public final Invocation createInvocation()
+   {
+      return new Invocation();
    }
+
+   /**
+    * Initialization method.
+    * 
+    * @param endpoint endpoint
+    */
+   public void init(final Endpoint endpoint)
+   {
+      // does nothing
+   }
+
+   /**
+    * Returns implementation method that will be used for invocation.
+    * 
+    * @param implClass implementation endpoint class
+    * @param seiMethod SEI interface method used for method finding algorithm
+    * @return implementation method
+    * @throws NoSuchMethodException if implementation method wasn't found
+    */
+   protected final Method getImplMethod(final Class<?> implClass, final Method seiMethod) throws NoSuchMethodException
+   {
+      final String methodName = seiMethod.getName();
+      final Class<?>[] paramTypes = seiMethod.getParameterTypes();
+
+      return implClass.getMethod(methodName, paramTypes);
+   }
+
 }

Added: branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/invocation/AbstractInvocationHandlerJSE.java
===================================================================
--- branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/invocation/AbstractInvocationHandlerJSE.java	                        (rev 0)
+++ branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/invocation/AbstractInvocationHandlerJSE.java	2009-08-18 11:43:39 UTC (rev 92520)
@@ -0,0 +1,181 @@
+/*
+ * 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.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.invocation.Invocation;
+import org.jboss.wsf.spi.invocation.InvocationContext;
+
+/**
+ * Handles invocations on JSE endpoints.
+ *
+ * @author <a href="mailto:ropalka at redhat.com">Richard Opalka</a>
+ * @author <a href="mailto:tdiesler at redhat.com">Thomas Diesler</a>
+ */
+abstract class AbstractInvocationHandlerJSE extends AbstractInvocationHandler
+{
+
+   /**
+    * Constructor.
+    */
+   protected AbstractInvocationHandlerJSE()
+   {
+      super();
+   }
+
+   /**
+    * Retrieves endpoint implementation bean that will be used in invocation process.
+    * 
+    * This method does the following steps:
+    * 
+    * <ul>
+    *   <li>tries to retrieve endpoint instance from invocation context,</li>
+    *   <li>if endpoint instance is not found it's created and instantiated (lazy initialization)</li>
+    *   <li>
+    *     if endpoint instance was created all subclasses will be notified about this event
+    *     (using {@link #onEndpointInstantiated(Endpoint, Invocation)} template method).  
+    *   </li>
+    * </ul>
+    * 
+    * @param endpoint to lookup implementation instance for
+    * @param invocation current invocation
+    * @return endpoint implementation
+    * @throws Exception if any error occurs
+    */
+   protected final Object getTargetBean(final Endpoint endpoint, final Invocation invocation) throws Exception
+   {
+      final InvocationContext invocationContext = invocation.getInvocationContext();
+      Object targetBean = invocationContext.getTargetBean();
+
+      if (targetBean == null)
+      {
+         try
+         {
+            // create endpoint instance
+            final Class<?> endpointImplClass = endpoint.getTargetBeanClass();
+            targetBean = endpointImplClass.newInstance();
+            invocationContext.setTargetBean(targetBean);
+
+            // notify subclasses
+            this.onEndpointInstantiated(endpoint, invocation);
+         }
+         catch (Exception ex)
+         {
+            throw new IllegalStateException("Cannot create endpoint instance: ", ex);
+         }
+      }
+
+      return targetBean;
+   }
+
+   /**
+    * Invokes method on endpoint implementation.
+    * 
+    * This method does the following steps:
+    * 
+    * <ul>
+    *   <li>lookups endpoint implementation method to be invoked,</li>
+    *   <li>
+    *     notifies all subclasses about endpoint method is going to be invoked<br/>
+    *     (using {@link #onBeforeInvocation(Invocation)} template method),  
+    *   </li>
+    *   <li>endpoint implementation method is invoked,</li>
+    *   <li>
+    *     notifies all subclasses about endpoint method invocation was completed<br/>
+    *     (using {@link #onAfterInvocation(Invocation)} template method).  
+    *   </li>
+    * </ul>
+    * 
+    * @param endpoint which method is going to be invoked
+    * @param invocation current invocation
+    * @throws Exception if any error occurs
+    */
+   public final void invoke(final Endpoint endpoint, final Invocation invocation) throws Exception
+   {
+      try
+      {
+         // prepare for invocation
+         final Object targetBean = this.getTargetBean(endpoint, invocation);
+         final Class<?> implClass = targetBean.getClass();
+         final Method seiMethod = invocation.getJavaMethod();
+         final Method implMethod = this.getImplMethod(implClass, seiMethod);
+         final Object[] args = invocation.getArgs();
+
+         // notify subclasses
+         this.onBeforeInvocation(invocation);
+
+         // invoke implementation method
+         final Object retObj = implMethod.invoke(targetBean, args);
+
+         // set invocation result
+         invocation.setReturnValue(retObj);
+      }
+      catch (Exception e)
+      {
+         this.log.error("Method invocation failed with exception: " + e.getMessage(), e);
+         // propagate exception
+         this.handleInvocationException(e);
+      }
+      finally
+      {
+         // notify subclasses
+         this.onAfterInvocation(invocation);
+      }
+   }
+
+   /**
+    * Template method for notifying subclasses that endpoint instance have been instantiated.
+    * 
+    * @param endpoint instantiated endpoint
+    * @param invocation current invocation
+    * @throws Exception subclasses have to throw exception on any failure
+    */
+   protected void onEndpointInstantiated(final Endpoint endpoint, final Invocation invocation) throws Exception
+   {
+      // does nothing
+   }
+
+   /**
+    * Template method for notifying subclasses that endpoint method is going to be invoked.
+    *  
+    * @param invocation current invocation
+    * @throws Exception subclasses have to throw exception on any failure
+    */
+   protected void onBeforeInvocation(final Invocation invocation) throws Exception
+   {
+      // does nothing
+   }
+
+   /**
+    * Template method for notifying subclasses that endpoint method invocation was completed.
+    *  
+    * @param invocation current invocation
+    * @throws Exception subclasses have to throw exception on any failure
+    */
+   protected void onAfterInvocation(final Invocation invocation) throws Exception
+   {
+      // does nothing
+   }
+
+}

Modified: branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerEJB21.java
===================================================================
--- branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerEJB21.java	2009-08-18 11:19:53 UTC (rev 92519)
+++ branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerEJB21.java	2009-08-18 11:43:39 UTC (rev 92520)
@@ -36,11 +36,7 @@
 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;
@@ -49,7 +45,6 @@
 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;
@@ -58,140 +53,195 @@
 /**
  * Handles invocations on EJB21 endpoints.
  *
- * @author Thomas.Diesler at jboss.org
+ * @author <a href="mailto:ropalka at redhat.com">Richard Opalka</a>
+ * @author <a href="mailto:tdiesler at redhat.com">Thomas Diesler</a>
  */
-public class InvocationHandlerEJB21 extends InvocationHandler
+final class InvocationHandlerEJB21 extends AbstractInvocationHandler
 {
-   // provide logging
-   private static final Logger log = Logger.getLogger(InvocationHandlerEJB21.class);
 
+   /** EJB21 JNDI name. */
    private String jndiName;
+
+   /** MBean server. */
    private MBeanServer server;
-   private ObjectName objectName;
 
+   /** Object name. */
+   private ObjectName ejb21ContainerName;
+
+   /**
+    * Consctructor.
+    */
    InvocationHandlerEJB21()
    {
+      super();
+
+      this.server = MBeanServerLocator.locateJBoss();
    }
 
-   public Invocation createInvocation()
+   /**
+    * Initializes EJB 21 endpoint.
+    * 
+    * @param endpoint web service endpoint
+    */
+   public void init(final Endpoint endpoint)
    {
-      return new Invocation();
-   }
+      final String ejbName = endpoint.getShortName();
+      final Deployment dep = endpoint.getService().getDeployment();
+      final EJBArchiveMetaData ejbArchiveMD = WSHelper.getRequiredAttachment(dep, EJBArchiveMetaData.class);
+      final EJBMetaData ejbMD = (EJBMetaData) ejbArchiveMD.getBeanByEjbName(ejbName);
 
-   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)
+      if (ejbMD == null)
+      {
          throw new WebServiceException("Cannot obtain ejb meta data for: " + ejbName);
+      }
 
-      // get the MBeanServer
-      server = MBeanServerLocator.locateJBoss();
+      // get the bean's JNDI name
+      this.jndiName = ejbMD.getContainerObjectNameJndiName();
 
-      // get the bean's JNDI name
-      jndiName = beanMetaData.getContainerObjectNameJndiName();
-      if (jndiName == null)
+      if (this.jndiName == null)
+      {
          throw new WebServiceException("Cannot obtain JNDI name for: " + ejbName);
+      }
    }
 
-   public void invoke(Endpoint ep, Invocation inv) throws Exception
+   /**
+    * Gets EJB 21 container name lazily.
+    * 
+    * @param endpoint webservice endpoint
+    * @return EJB21 container name
+    */
+   private synchronized ObjectName getEjb21ContainerName(final Endpoint endpoint)
    {
-      log.debug("Invoke: " + inv.getJavaMethod().getName());
+      final boolean ejb21ContainerNotInitialized = this.ejb21ContainerName == null;
 
-      if (objectName == null)
+      if (ejb21ContainerNotInitialized)
       {
-         objectName = ObjectNameFactory.create("jboss.j2ee:jndiName=" + jndiName + ",service=EJB");
-         if (server.isRegistered(objectName) == false)
-            throw new WebServiceException("Cannot find service endpoint target: " + objectName);
+         this.ejb21ContainerName = ObjectNameFactory.create("jboss.j2ee:jndiName=" + this.jndiName + ",service=EJB");
+         final boolean ejb21NotRegistered = !this.server.isRegistered(this.ejb21ContainerName);
+         if (ejb21NotRegistered)
+         {
+            throw new IllegalArgumentException("Cannot find service endpoint target: " + this.ejb21ContainerName);
+         }
 
          // Inject the Service endpoint interceptor
-         injectServiceEndpointInterceptor(objectName, ep.getShortName());
+         this.insertEJB21ServiceEndpointInterceptor(this.ejb21ContainerName, endpoint.getShortName());
       }
 
-      // invoke on the container
+      return this.ejb21ContainerName;
+   }
+
+   /**
+    * Invokes EJB 21 endpoint.
+    * 
+    * @param endpoint EJB 21 endpoint
+    * @param wsInvocation web service invocation
+    * @throws Exception if any error occurs
+    */
+   public void invoke(final Endpoint endpoint, final Invocation wsInvocation) throws Exception
+   {
+      final ObjectName ejb21Name = this.getEjb21ContainerName(endpoint);
+
       try
       {
-         // setup the invocation
-         org.jboss.invocation.Invocation jbInv = getMBeanInvocation(inv);
+         // prepare for invocation
+         final org.jboss.invocation.Invocation jbossInvocation = this.getMBeanInvocation(wsInvocation);
+         final String[] signature =
+         {org.jboss.invocation.Invocation.class.getName()};
+         final Object[] args = new Object[]
+         {jbossInvocation};
 
-         String[] sig = { org.jboss.invocation.Invocation.class.getName() };
-         Object retObj = server.invoke(objectName, "invoke", new Object[] { jbInv }, sig);
-         inv.setReturnValue(retObj);
+         // invoke method
+         final Object retObj = this.server.invoke(ejb21Name, "invoke", args, signature);
+         wsInvocation.setReturnValue(retObj);
       }
       catch (Exception e)
       {
-         handleInvocationException(e);
+         this.log.error("Method invocation failed with exception: " + e.getMessage(), e);
+         this.handleInvocationException(e);
       }
    }
 
-   private org.jboss.invocation.Invocation getMBeanInvocation(Invocation inv)
+   /**
+    * Returns configured EJB 21 JBoss MBean invocation.
+    * 
+    * @param wsInvocation webservice invocation
+    * @return configured JBoss invocation
+    */
+   private org.jboss.invocation.Invocation getMBeanInvocation(final Invocation wsInvocation)
    {
-      // EJB2.1 endpoints will only get an JAXRPC context 
-      MessageContext msgContext = inv.getInvocationContext().getAttachment(MessageContext.class);
+      // ensure preconditions
+      final MessageContext msgContext = wsInvocation.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();
+      final HandlerCallback callback = wsInvocation.getInvocationContext().getAttachment(HandlerCallback.class);
+      if (callback == null)
+      {
+         throw new IllegalStateException("Cannot obtain HandlerCallback");
+      }
 
-      if (principal == null && sc != null)
-         principal = sc.getUtil().getUserPrincipal();
+      // prepare security data
+      final SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
+      final SecurityAdaptor securityAdaptor = spiProvider.getSPI(SecurityAdaptorFactory.class).newSecurityAdapter();
+      final Principal principal = securityAdaptor.getPrincipal();
+      final Object credential = securityAdaptor.getCredential();
 
-      if (credential == null && sc != null)
-         credential = sc.getUtil().getCredential();
+      // prepare invocation data
+      final Method method = wsInvocation.getJavaMethod();
+      final Object[] args = wsInvocation.getArgs();
+      final org.jboss.invocation.Invocation jbossInvocation = new org.jboss.invocation.Invocation(null, method, args,
+            null, principal, credential);
 
-      Method method = inv.getJavaMethod();
-      Object[] args = inv.getArgs();
-      org.jboss.invocation.Invocation jbInv = new org.jboss.invocation.Invocation(null, method, args, null, principal, credential);
+      // propagate values to JBoss invocation
+      jbossInvocation.setValue(InvocationKey.SOAP_MESSAGE_CONTEXT, msgContext);
+      jbossInvocation.setValue(InvocationKey.SOAP_MESSAGE, ((SOAPMessageContext) msgContext).getMessage());
+      jbossInvocation.setType(InvocationType.SERVICE_ENDPOINT);
+      jbossInvocation.setValue(HandlerCallback.class.getName(), callback, PayloadKey.TRANSIENT);
+      jbossInvocation.setValue(Invocation.class.getName(), wsInvocation, PayloadKey.TRANSIENT);
 
-      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;
+      return jbossInvocation;
    }
 
-   private void injectServiceEndpointInterceptor(ObjectName objectName, String ejbName)
+   /**
+    * This method dynamically inserts EJB 21 webservice endpoint interceptor
+    * to the last but one position in EJB 21 processing chain. See [JBWS-756] for more info.
+    * 
+    * @param objectName EJB 21 object name
+    * @param ejbName EJB 21 short name
+    */
+   private void insertEJB21ServiceEndpointInterceptor(final ObjectName objectName, final 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);
+         final EjbModule ejbModule = (EjbModule) this.server.getAttribute(objectName, "EjbModule");
+         final StatelessSessionContainer container = (StatelessSessionContainer) ejbModule.getContainer(ejbName);
 
-         boolean injectionPointFound = false;
-         Interceptor prev = container.getInterceptor();
-         while (prev != null && prev.getNext() != null)
+         Interceptor currentInterceptor = container.getInterceptor();
+         while (currentInterceptor != null && currentInterceptor.getNext() != null)
          {
-            Interceptor next = prev.getNext();
-            if (next.getNext() == null)
+            final Interceptor nextInterceptor = currentInterceptor.getNext();
+
+            if (nextInterceptor.getNext() == null)
             {
-               log.debug("Inject service endpoint interceptor after: " + prev.getClass().getName());
-               ServiceEndpointInterceptor sepInterceptor = new ServiceEndpointInterceptor();
-               prev.setNext(sepInterceptor);
-               sepInterceptor.setNext(next);
-               injectionPointFound = true;
+               final ServiceEndpointInterceptorEJB21 sepInterceptor = new ServiceEndpointInterceptorEJB21();
+               currentInterceptor.setNext(sepInterceptor);
+               sepInterceptor.setNext(nextInterceptor);
+               this.log.debug("Injecting EJB 21 service endpoint interceptor after: "
+                     + currentInterceptor.getClass().getName());
+
+               return;
             }
-            prev = next;
+            currentInterceptor = nextInterceptor;
          }
-         if (injectionPointFound == false)
-            log.warn("Cannot service endpoint interceptor injection point");
+
+         this.log.warn("Cannot find EJB 21 service endpoint interceptor insert point");
       }
       catch (Exception ex)
       {
-         log.warn("Cannot add service endpoint interceptor", ex);
+         this.log.warn("Cannot register EJB 21 service endpoint interceptor: ", ex);
       }
    }
+
 }

Modified: branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerEJB3.java
===================================================================
--- branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerEJB3.java	2009-08-18 11:19:53 UTC (rev 92519)
+++ branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerEJB3.java	2009-08-18 11:43:39 UTC (rev 92520)
@@ -21,98 +21,146 @@
  */
 package org.jboss.webservices.integration.invocation;
 
+import java.lang.reflect.Method;
+
+import javax.xml.ws.WebServiceException;
+
 import org.jboss.dependency.spi.ControllerContext;
 import org.jboss.kernel.spi.dependency.KernelController;
+import org.jboss.webservices.integration.util.ASHelper;
 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
+ * @author <a href="mailto:ropalka at redhat.com">Richard Opalka</a>
+ * @author <a href="mailto:tdiesler at redhat.com">Thomas Diesler</a>
  */
-public class InvocationHandlerEJB3 extends AbstractInvocationHandler
+final class InvocationHandlerEJB3 extends AbstractInvocationHandler
 {
 
-   public static final String CONTAINER_NAME = "org.jboss.wsf.spi.invocation.ContainerName";
+   /** MC kernel controller. */
+   private final KernelController controller;
 
+   /** EJB3 container name. */
    private String containerName;
-   private KernelController houston;
+
+   /** EJB3 container. */
    private ServiceEndpointContainer serviceEndpointContainer;
 
-
+   /**
+    * Constructor.
+    */
    InvocationHandlerEJB3()
    {
-      houston = KernelLocator.getKernel().getController();
-   }
+      super();
 
-   public Invocation createInvocation()
-   {
-      return new Invocation();
+      this.controller = KernelLocator.getKernel().getController();
    }
 
-   public void init(Endpoint ep)
+   /**
+    * Initializes EJB3 container name.
+    * 
+    * @param endpoint web service endpoint
+    */
+   public void init(final Endpoint endpoint)
    {
-      containerName = (String)ep.getProperty(InvocationHandlerEJB3.CONTAINER_NAME);
-      assert containerName!=null : "Target container name not set";
+      this.containerName = (String) endpoint.getProperty(ASHelper.CONTAINER_NAME);
 
+      if (this.containerName == null)
+      {
+         throw new IllegalArgumentException("Container name cannot be null");
+      }
    }
 
-   private ServiceEndpointContainer lazyInitializeInvocationTarget()
+   /**
+    * Gets EJB 3 container lazily.
+    * 
+    * @return EJB3 container
+    */
+   private synchronized ServiceEndpointContainer getEjb3Container()
    {
-      if(null==this.serviceEndpointContainer)
+      final boolean ejb3ContainerNotInitialized = this.serviceEndpointContainer == null;
+
+      if (ejb3ContainerNotInitialized)
       {
-         ControllerContext context = houston.getInstalledContext(containerName);
+         final ControllerContext context = this.controller.getInstalledContext(this.containerName);
          if (context == null)
-            throw new WebServiceException("Cannot find service endpoint target: " + containerName);
+         {
+            throw new WebServiceException("Cannot find service endpoint target: " + this.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
+   /**
+    * Invokes EJB 3 endpoint.
+    * 
+    * @param endpoint EJB 3 endpoint
+    * @param wsInvocation web service invocation
+    * @throws Exception if any error occurs
+    */
+   public void invoke(final Endpoint endpoint, final Invocation wsInvocation) 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);
+         // prepare for invocation
+         final ServiceEndpointContainer ejbContainer = this.getEjb3Container();
+         final InvocationContextCallback invocationCallback = new EJB3InvocationContextCallback(wsInvocation);
+         final Class<?> implClass = ejbContainer.getServiceImplementationClass();
+         final Method seiMethod = wsInvocation.getJavaMethod();
+         final Method implMethod = this.getImplMethod(implClass, seiMethod);
+         final Object[] args = wsInvocation.getArgs();
 
-         wsInv.setReturnValue(retObj);
+         // invoke method
+         final Object retObj = ejbContainer.invokeEndpoint(implMethod, args, invocationCallback);
+         wsInvocation.setReturnValue(retObj);
       }
-      catch (Throwable th)
+      catch (Throwable t)
       {
-         handleInvocationException(th);
+         this.log.error("Method invocation failed with exception: " + t.getMessage(), t);
+         this.handleInvocationException(t);
       }
    }
 
-   static class EJB3InvocationContextCallback implements InvocationContextCallback
+   /**
+    * EJB3 invocation callback allowing EJB 3 beans to access Web Service invocation properties.
+    */
+   private static final class EJB3InvocationContextCallback implements InvocationContextCallback
    {
-      private Invocation wsInv;
 
-      public EJB3InvocationContextCallback(Invocation wsInv)
+      /** WebService invocation. */
+      private Invocation wsInvocation;
+
+      /**
+       * Constructor.
+       * 
+       * @param wsInvocation delegee
+       */
+      public EJB3InvocationContextCallback(final Invocation wsInvocation)
       {
-         this.wsInv = wsInv;
+         this.wsInvocation = wsInvocation;
       }
 
-      public <T> T get(Class<T> propertyType)
+      /**
+       * Retrieves attachment type from Web Service invocation context attachments.
+       * 
+       * @param <T> attachment type
+       * @param attachmentType attachment class
+       * @return attachment value
+       */
+      public <T> T get(final Class<T> attachmentType)
       {
-         return wsInv.getInvocationContext().getAttachment(propertyType);               
+         return this.wsInvocation.getInvocationContext().getAttachment(attachmentType);
       }
+
    }
+
 }

Modified: branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerFactoryImpl.java
===================================================================
--- branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerFactoryImpl.java	2009-08-18 11:19:53 UTC (rev 92519)
+++ branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerFactoryImpl.java	2009-08-18 11:43:39 UTC (rev 92520)
@@ -21,44 +21,62 @@
  */
 package org.jboss.webservices.integration.invocation;
 
-import org.jboss.wsf.spi.invocation.*;
+import org.jboss.wsf.spi.invocation.InvocationHandler;
+import org.jboss.wsf.spi.invocation.InvocationHandlerFactory;
+import org.jboss.wsf.spi.invocation.InvocationType;
 
 /**
- * The default invocation model factory fro AS 5.0.
+ * The default invocation model factory for JBoss AS.
  *
- * @author Heiko.Braun at jboss.com
+ * @author <a href="mailto:ropalka at redhat.com">Richard Opalka</a>
+ * @author <a href="mailto:tdiesler at redhat.com">Thomas Diesler</a>
  */
-public class InvocationHandlerFactoryImpl extends InvocationHandlerFactory
+public final class InvocationHandlerFactoryImpl extends InvocationHandlerFactory
 {
-   public InvocationHandler newInvocationHandler(InvocationType type)
+
+   /**
+    * Constructor.
+    */
+   public InvocationHandlerFactoryImpl()
    {
+      super();
+   }
+
+   /**
+    * Returns invocation handler associated with invocation type.
+    * 
+    * @param type invocation type
+    * @return invocation handler
+    */
+   public InvocationHandler newInvocationHandler(final InvocationType type)
+   {
       InvocationHandler handler = null;
 
-      switch(type)
+      switch (type)
       {
-         case JAXRPC_JSE:
+         case JAXRPC_JSE :
             handler = new InvocationHandlerJAXRPC();
             break;
-         case JAXRPC_EJB21:
+         case JAXRPC_EJB21 :
             handler = new InvocationHandlerEJB21();
             break;
-         case JAXRPC_MDB21:
+         case JAXRPC_MDB21 :
             handler = new InvocationHandlerMDB21();
             break;
-         case JAXWS_JSE:
+         case JAXWS_JSE :
             handler = new InvocationHandlerJAXWS();
             break;
-         case JAXWS_EJB3:
+         case JAXWS_EJB3 :
             handler = new InvocationHandlerEJB3();
             break;
-         case JAXWS_MDB3:
+         case JAXWS_MDB3 :
             handler = new InvocationHandlerMDB3();
             break;
+         default :
+            throw new IllegalArgumentException("Unable to resolve spi.invocation.InvocationHandler for type " + type);
       }
 
-      if(null == handler)
-         throw new IllegalArgumentException("Unable to resolve spi.invocation.InvocationHandler for type " +type);
-
       return handler;
    }
+
 }

Modified: branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerJAXRPC.java
===================================================================
--- branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerJAXRPC.java	2009-08-18 11:19:53 UTC (rev 92519)
+++ branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerJAXRPC.java	2009-08-18 11:43:39 UTC (rev 92520)
@@ -24,46 +24,67 @@
 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.
+ * Handles invocations on JAXRPC endpoints.
  *
- * @author Thomas.Diesler at jboss.org
+ * @author <a href="mailto:ropalka at redhat.com">Richard Opalka</a>
+ * @author <a href="mailto:tdiesler at redhat.com">Thomas Diesler</a>
  */
-public class InvocationHandlerJAXRPC extends InvocationHandlerJSE
+final class InvocationHandlerJAXRPC extends AbstractInvocationHandlerJSE
 {
-   public void invoke(Endpoint ep, Invocation epInv) throws Exception
+
+   /**
+    * Constructor.
+    */
+   InvocationHandlerJAXRPC()
    {
-      try
+      super();
+   }
+
+   /**
+    * Calls {@link javax.xml.rpc.server.ServiceLifecycle#init(Object)}
+    * method on target bean if this bean implements 
+    * {@link javax.xml.rpc.server.ServiceLifecycle} interface.
+    * 
+    * @param invocation current invocation
+    * @throws Exception if any error occurs
+    */
+   @Override
+   protected void onBeforeInvocation(final Invocation invocation) throws Exception
+   {
+      final InvocationContext invocationContext = invocation.getInvocationContext();
+      final Object targetBean = invocationContext.getTargetBean();
+      final boolean isJaxrpcLifecycleBean = targetBean instanceof ServiceLifecycle;
+
+      if (isJaxrpcLifecycleBean)
       {
-         Object targetBean = getTargetBean(ep, epInv);
+         final ServletEndpointContext sepContext = invocationContext.getAttachment(ServletEndpointContext.class);
+         ((ServiceLifecycle) targetBean).init(sepContext);
+      }
+   }
 
-         InvocationContext invContext = epInv.getInvocationContext();
-         if (targetBean instanceof ServiceLifecycle)
-         {
-            ServletEndpointContext sepContext = invContext.getAttachment(ServletEndpointContext.class);
-            if (sepContext != null)
-               ((ServiceLifecycle)targetBean).init(sepContext);
-         }
+   /**
+    * Calls {@link javax.xml.rpc.server.ServiceLifecycle#destroy()}
+    * method on target bean if this bean implements 
+    * {@link javax.xml.rpc.server.ServiceLifecycle} interface.
+    * 
+    * @param invocation current invocation
+    * @throws Exception if any error occurs
+    */
+   @Override
+   protected void onAfterInvocation(final Invocation invocation) throws Exception
+   {
+      final InvocationContext invocationContext = invocation.getInvocationContext();
+      final Object targetBean = invocationContext.getTargetBean();
+      final boolean isJaxrpcLifecycleBean = targetBean instanceof ServiceLifecycle;
 
-         try
-         {
-            super.invoke(ep, epInv);
-         }
-         finally
-         {
-            if (targetBean instanceof ServiceLifecycle)
-            {
-               ((ServiceLifecycle)targetBean).destroy();
-            }
-         }
-      }
-      catch (Exception e)
+      if (isJaxrpcLifecycleBean)
       {
-         handleInvocationException(e);
+         ((ServiceLifecycle) targetBean).destroy();
       }
    }
+
 }

Modified: branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerJAXWS.java
===================================================================
--- branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerJAXWS.java	2009-08-18 11:19:53 UTC (rev 92519)
+++ branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerJAXWS.java	2009-08-18 11:43:39 UTC (rev 92520)
@@ -21,11 +21,123 @@
  */
 package org.jboss.webservices.integration.invocation;
 
+import javax.xml.ws.WebServiceContext;
+
+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.ResourceInjector;
+import org.jboss.wsf.spi.invocation.ResourceInjectorFactory;
+import org.jboss.wsf.spi.metadata.injection.InjectionsMetaData;
+
 /**
- * Handles invocations on JSE endpoints.
+ * Handles invocations on JAXWS endpoints.
  *
- * @author Thomas.Diesler at jboss.org
+ * @author <a href="mailto:ropalka at redhat.com">Richard Opalka</a>
+ * @author <a href="mailto:tdiesler at redhat.com">Thomas Diesler</a>
  */
-public class InvocationHandlerJAXWS extends InvocationHandlerJSE
+final class InvocationHandlerJAXWS extends AbstractInvocationHandlerJSE
 {
+
+   /** WebServiceContext injector. */
+   private final ResourceInjector wsContextInjector;
+
+   /**
+    * Constructor.
+    */
+   InvocationHandlerJAXWS()
+   {
+      super();
+
+      final SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
+      final ResourceInjectorFactory resourceInjectorFactory = spiProvider.getSPI(ResourceInjectorFactory.class);
+      this.wsContextInjector = resourceInjectorFactory.newResourceInjector();
+   }
+
+   /**
+    * Injects resources on target bean and calls post construct method.
+    * Finally it registers target bean for predestroy phase.
+    * 
+    * @param endpoint used for predestroy phase registration process
+    * @param invocation current invocation
+    */
+   @Override
+   protected void onEndpointInstantiated(final Endpoint endpoint, final Invocation invocation)
+   {
+      final InjectionsMetaData injectionsMD = endpoint.getAttachment(InjectionsMetaData.class);
+      final Object targetBean = this.getTargetBean(invocation);
+
+      this.log.debug("Injecting resources on JAXWS JSE endpoint: " + targetBean);
+      InjectionHelper.injectResources(targetBean, injectionsMD);
+      this.log.debug("Calling postConstruct method on JAXWS JSE endpoint: " + targetBean);
+      InjectionHelper.callPostConstructMethod(targetBean);
+
+      endpoint.addAttachment(PreDestroyHolder.class, new PreDestroyHolder(targetBean));
+   }
+
+   /**
+    * Injects webservice context on target bean.
+    * 
+    *  @param invocation current invocation
+    */
+   @Override
+   protected void onBeforeInvocation(final Invocation invocation)
+   {
+      final WebServiceContext wsContext = this.getWebServiceContext(invocation);
+
+      if (wsContext != null)
+      {
+         final Object targetBean = this.getTargetBean(invocation);
+         this.wsContextInjector.inject(targetBean, wsContext);
+      }
+   }
+
+   /**
+    * Cleanups injected webservice context on target bean.
+    * 
+    * @param invocation current invocation
+    */
+   @Override
+   protected void onAfterInvocation(final Invocation invocation)
+   {
+      final WebServiceContext wsContext = this.getWebServiceContext(invocation);
+
+      if (wsContext != null)
+      {
+         final Object targetBean = this.getTargetBean(invocation);
+
+         this.wsContextInjector.inject(targetBean, null);
+      }
+   }
+
+   /**
+    * Returns WebServiceContext associated with this invocation.
+    * 
+    * @param invocation current invocation
+    * @return web service context or null if not available
+    */
+   private WebServiceContext getWebServiceContext(final Invocation invocation)
+   {
+      final InvocationContext invocationContext = invocation.getInvocationContext();
+
+      return invocationContext.getAttachment(WebServiceContext.class);
+   }
+
+   /**
+    * Returns endpoint instance associated with current invocation.
+    * 
+    * @param invocation current invocation
+    * @return target bean in invocation
+    */
+   private Object getTargetBean(final Invocation invocation)
+   {
+      final InvocationContext invocationContext = invocation.getInvocationContext();
+
+      return invocationContext.getTargetBean();
+   }
+
 }

Deleted: branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerJSE.java
===================================================================
--- branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerJSE.java	2009-08-18 11:19:53 UTC (rev 92519)
+++ branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerJSE.java	2009-08-18 11:43:39 UTC (rev 92520)
@@ -1,140 +0,0 @@
-/*
- * 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);
-         ResourceInjector  injector = null;
-         if (wsContext != null)
-         {
-            injector = resourceInjectorFactory.newResourceInjector();
-            injector.inject(targetBean, wsContext);
-         }
-
-         Method method = getImplMethod(targetBean.getClass(), epInv.getJavaMethod());
-         Object retObj = method.invoke(targetBean, epInv.getArgs());
-         epInv.setReturnValue(retObj);
-         
-         if (wsContext != null) //JBWS-2662
-         {
-            injector.inject(targetBean, null);
-         }
-      }
-      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;
-   }
-}

Modified: branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerMDB21.java
===================================================================
--- branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerMDB21.java	2009-08-18 11:19:53 UTC (rev 92519)
+++ branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerMDB21.java	2009-08-18 11:43:39 UTC (rev 92520)
@@ -21,65 +21,21 @@
  */
 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
+ * @author <a href="mailto:ropalka at redhat.com">Richard Opalka</a>
+ * @author <a href="mailto:tdiesler at redhat.com">Thomas Diesler</a>
  */
-public class InvocationHandlerMDB21 extends AbstractInvocationHandler
+final class InvocationHandlerMDB21 extends AbstractInvocationHandlerJSE
 {
-   // provide logging
-   private static final Logger log = Logger.getLogger(InvocationHandlerMDB21.class);
 
-   public Invocation createInvocation()
+   /**
+    * Constructor.
+    */
+   InvocationHandlerMDB21()
    {
-      return new Invocation();
+      super();
    }
 
-   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);
-      }
-   }
 }

Modified: branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerMDB3.java
===================================================================
--- branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerMDB3.java	2009-08-18 11:19:53 UTC (rev 92519)
+++ branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/invocation/InvocationHandlerMDB3.java	2009-08-18 11:43:39 UTC (rev 92520)
@@ -21,65 +21,21 @@
  */
 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
+ * @author <a href="mailto:ropalka at redhat.com">Richard Opalka</a>
+ * @author <a href="mailto:tdiesler at redhat.com">Thomas Diesler</a>
  */
-public class InvocationHandlerMDB3 extends AbstractInvocationHandler
+final class InvocationHandlerMDB3 extends AbstractInvocationHandlerJSE
 {
-   // provide logging
-   private static final Logger log = Logger.getLogger(InvocationHandlerMDB3.class);
 
-   public Invocation createInvocation()
+   /**
+    * Constructor.
+    */
+   InvocationHandlerMDB3()
    {
-      return new Invocation();
+      super();
    }
 
-   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);
-      }
-   }
 }

Deleted: branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/invocation/SecurityAdapterFactoryImpl.java
===================================================================
--- branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/invocation/SecurityAdapterFactoryImpl.java	2009-08-18 11:19:53 UTC (rev 92519)
+++ branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/invocation/SecurityAdapterFactoryImpl.java	2009-08-18 11:43:39 UTC (rev 92520)
@@ -1,36 +0,0 @@
-/*
- * 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();
-   }
-}

Deleted: branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/invocation/SecurityAdaptorImpl.java
===================================================================
--- branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/invocation/SecurityAdaptorImpl.java	2009-08-18 11:19:53 UTC (rev 92519)
+++ branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/invocation/SecurityAdaptorImpl.java	2009-08-18 11:43:39 UTC (rev 92520)
@@ -1,97 +0,0 @@
-/*
- * 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;
-         }
-      });
-   }
-
-
-}

Deleted: branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/invocation/ServiceEndpointInterceptor.java
===================================================================
--- branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/invocation/ServiceEndpointInterceptor.java	2009-08-18 11:19:53 UTC (rev 92519)
+++ branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/invocation/ServiceEndpointInterceptor.java	2009-08-18 11:43:39 UTC (rev 92520)
@@ -1,123 +0,0 @@
-/*
- * 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/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/invocation/ServiceEndpointInterceptorEJB21.java
===================================================================
--- branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/invocation/ServiceEndpointInterceptorEJB21.java	                        (rev 0)
+++ branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/invocation/ServiceEndpointInterceptorEJB21.java	2009-08-18 11:43:39 UTC (rev 92520)
@@ -0,0 +1,124 @@
+/*
+ * 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.handler.soap.SOAPMessageContext;
+
+import org.jboss.ejb.plugins.AbstractInterceptor;
+import org.jboss.invocation.InvocationKey;
+import org.jboss.wsf.spi.invocation.HandlerCallback;
+import org.jboss.wsf.spi.invocation.Invocation;
+import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedHandlerMetaData.HandlerType;
+
+/**
+ * This Interceptor does the ws4ee handler processing on EJB 21 endpoints.
+ * 
+ * According to the ws4ee spec the handler logic must be invoked after the container
+ * applied method level security to the invocation. 
+ *
+ * @author <a href="mailto:ropalka at redhat.com">Richard Opalka</a>
+ * @author <a href="mailto:tdiesler at redhat.com">Thomas Diesler</a>
+ */
+final class ServiceEndpointInterceptorEJB21 extends AbstractInterceptor
+{
+
+   /**
+    * Constructor.
+    */
+   ServiceEndpointInterceptorEJB21()
+   {
+      super();
+   }
+
+   /**
+    * Before and after we call the EJB 21 service endpoint bean, we process the handler chains.
+    * 
+    * @param jbossInvocation jboss invocation
+    * @return ws invocation return value
+    * @throws Exception if any error occurs
+    */
+   @Override
+   public Object invoke(final org.jboss.invocation.Invocation jbossInvocation) throws Exception
+   {
+      final SOAPMessageContext msgContext = (SOAPMessageContext) jbossInvocation
+            .getPayloadValue(InvocationKey.SOAP_MESSAGE_CONTEXT);
+      if (msgContext == null)
+      {
+         // not for us
+         return this.getNext().invoke(jbossInvocation);
+      }
+
+      final Invocation wsInvocation = (Invocation) jbossInvocation.getValue(Invocation.class.getName());
+      final HandlerCallback callback = (HandlerCallback) jbossInvocation.getValue(HandlerCallback.class.getName());
+
+      if (callback == null || wsInvocation == null)
+      {
+         log.warn("Handler callback not available");
+         return this.getNext().invoke(jbossInvocation);
+      }
+
+      // Handlers need to be Tx. Therefore we must invoke the handler chain after the TransactionInterceptor.
+      try
+      {
+         // call the request handlers
+         boolean handlersPass = callback.callRequestHandlerChain(wsInvocation, HandlerType.ENDPOINT);
+         handlersPass = handlersPass && callback.callRequestHandlerChain(wsInvocation, 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.
+            final Object[] reqParams = wsInvocation.getArgs();
+            jbossInvocation.setArguments(reqParams);
+            final Object resObj = this.getNext().invoke(jbossInvocation);
+
+            // Setting the message to null should trigger binding of the response message
+            msgContext.setMessage(null);
+            wsInvocation.setReturnValue(resObj);
+         }
+
+         // call the response handlers
+         handlersPass = callback.callResponseHandlerChain(wsInvocation, HandlerType.POST);
+         handlersPass = handlersPass && callback.callResponseHandlerChain(wsInvocation, HandlerType.ENDPOINT);
+
+         // update the return value after response handler processing
+         return wsInvocation.getReturnValue();
+      }
+      catch (Exception ex)
+      {
+         try
+         {
+            // call the fault handlers
+            boolean handlersPass = callback.callFaultHandlerChain(wsInvocation, HandlerType.POST, ex);
+            handlersPass = handlersPass && callback.callFaultHandlerChain(wsInvocation, HandlerType.ENDPOINT, ex);
+         }
+         catch (Exception e)
+         {
+            log.warn("Cannot process handlerChain.handleFault, ignoring: ", e);
+         }
+         throw ex;
+      }
+   }
+
+}

Added: branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/metadata/AbstractMetaDataBuilderEJB.java
===================================================================
--- branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/metadata/AbstractMetaDataBuilderEJB.java	                        (rev 0)
+++ branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/metadata/AbstractMetaDataBuilderEJB.java	2009-08-18 11:43:39 UTC (rev 92520)
@@ -0,0 +1,125 @@
+/*
+ * 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.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.metadata.j2ee.EJBArchiveMetaData;
+import org.jboss.wsf.spi.metadata.j2ee.PublishLocationAdapter;
+
+/**
+ * Common class for EJB meta data builders.
+ *
+ * @author <a href="mailto:ropalka at redhat.com">Richard Opalka</a>
+ * @author <a href="mailto:tdiesler at redhat.com">Thomas Diesler</a>
+ */
+abstract class AbstractMetaDataBuilderEJB
+{
+
+   protected final Logger log = Logger.getLogger(this.getClass());
+
+   /**
+    * Builds universal EJB meta data model that is AS agnostic.
+    * 
+    * @param dep webservice deployment
+    * @return universal EJB meta data model
+    */
+   final EJBArchiveMetaData create(final Deployment dep)
+   {
+      this.log.debug("Building JBoss agnostic meta data for EJB webservice deployment: " + dep.getSimpleName());
+
+      final EJBArchiveMetaData ejbArchiveMD = new EJBArchiveMetaData();
+
+      this.buildEnterpriseBeansMetaData(dep, ejbArchiveMD);
+      this.buildWebservicesMetaData(dep, ejbArchiveMD);
+
+      return ejbArchiveMD;
+   }
+
+   /**
+    * Template method for build enterprise beans meta data.
+    * 
+    * @param dep webservice deployment
+    * @param ejbMetaData universal EJB meta data model
+    */
+   protected abstract void buildEnterpriseBeansMetaData(Deployment dep, EJBArchiveMetaData ejbMetaData);
+
+   /**
+    * Builds webservices meta data. This methods sets:
+    * <ul>
+    *   <li>context root</li>
+    *   <li>wsdl location resolver</li>
+    *   <li>config name</li>
+    *   <li>config file</li>
+    * </ul>
+    * 
+    * @param dep webservice deployment
+    * @param ejbArchiveMD universal EJB meta data model
+    */
+   private void buildWebservicesMetaData(final Deployment dep, final EJBArchiveMetaData ejbArchiveMD)
+   {
+      final JBossMetaData jbossMD = WSHelper.getRequiredAttachment(dep, JBossMetaData.class);
+      final WebservicesMetaData webservicesMD = jbossMD.getWebservices();
+
+      if (webservicesMD == null)
+      {
+         return;
+      }
+
+      // set context root
+      final String contextRoot = webservicesMD.getContextRoot();
+      ejbArchiveMD.setWebServiceContextRoot(contextRoot);
+      this.log.debug("Setting context root: " + contextRoot);
+
+      final WebserviceDescriptionsMetaData wsDescriptionsMD = webservicesMD.getWebserviceDescriptions();
+
+      if (wsDescriptionsMD != null)
+      {
+         // set wsdl location resolver
+         final PublishLocationAdapter resolver = new PublishLocationAdapterImpl(wsDescriptionsMD);
+         ejbArchiveMD.setPublishLocationAdapter(resolver);
+
+         final WebserviceDescriptionMetaData wsDescriptionMD = ASHelper
+               .getWebserviceDescriptionMetaData(wsDescriptionsMD);
+         if (wsDescriptionMD != null)
+         {
+            final String configName = wsDescriptionMD.getConfigName();
+            final String configFile = wsDescriptionMD.getConfigFile();
+
+            // set config name
+            this.log.debug("Setting config name: " + configName);
+            ejbArchiveMD.setConfigName(wsDescriptionMD.getConfigName());
+
+            // set config file
+            this.log.debug("Setting config file: " + configFile);
+            ejbArchiveMD.setConfigFile(wsDescriptionMD.getConfigFile());
+         }
+      }
+   }
+
+}

Modified: branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/metadata/ContainerMetaDataDeploymentAspect.java
===================================================================
--- branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/metadata/ContainerMetaDataDeploymentAspect.java	2009-08-18 11:19:53 UTC (rev 92519)
+++ branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/metadata/ContainerMetaDataDeploymentAspect.java	2009-08-18 11:43:39 UTC (rev 92520)
@@ -21,8 +21,6 @@
  */
 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;
@@ -32,18 +30,20 @@
 /**
  * An aspect that builds container independent meta data. 
  *
- * @author Thomas.Diesler at jboss.org
- * @author <a href="ropalka at redhat.com">Richard Opalka</a>
+ * @author <a href="mailto:ropalka at redhat.com">Richard Opalka</a>
+ * @author <a href="mailto:tdiesler at redhat.com">Thomas Diesler</a>
  */
 public final class ContainerMetaDataDeploymentAspect extends DeploymentAspect
 {
-   
+
    /** JSE meta data builder. */
-   private JSEMetaDataBuilder jseMetaDataBuilder = new JSEMetaDataBuilder();
+   private final MetaDataBuilderJSE metaDataBuilderJSE = new MetaDataBuilderJSE();
+
    /** EJB3 meta data builder. */
-   private EJB3MetaDataBuilder ejb3MetaDataBuilder = new EJB3MetaDataBuilder();
+   private final MetaDataBuilderEJB3 metaDataBuilderEJB3 = new MetaDataBuilderEJB3();
+
    /** EJB21 meta data builder. */
-   private EJB21MetaDataBuilder ejb21MetaDataBuilder = new EJB21MetaDataBuilder();
+   private final MetaDataBuilderEJB21 metaDataBuilderEJB21 = new MetaDataBuilderEJB21();
 
    /**
     * Constructor.
@@ -52,32 +52,33 @@
    {
       super();
    }
-   
+
    /**
     * Build container independent meta data.
     * 
     * @param dep webservice deployment
     */
    @Override
-   public void start( final Deployment dep )
+   public void start(final Deployment dep)
    {
-      final DeploymentUnit unit = WSHelper.getRequiredAttachment( dep, DeploymentUnit.class );
-      
-      if ( ASHelper.isJseDeployment( unit ) )
+      if (WSHelper.isJseDeployment(dep))
       {
-         final JSEArchiveMetaData jseMetaData = this.jseMetaDataBuilder.create( dep, unit );
-         dep.addAttachment( JSEArchiveMetaData.class, jseMetaData );
+         this.log.debug("Creating JBoss agnostic JSE meta data for deployment: " + dep.getSimpleName());
+         final JSEArchiveMetaData jseMetaData = this.metaDataBuilderJSE.create(dep);
+         dep.addAttachment(JSEArchiveMetaData.class, jseMetaData);
       }
-      else if ( ASHelper.isJaxwsEjbDeployment( unit ) )
+      else if (WSHelper.isJaxwsEjbDeployment(dep))
       {
-         final EJBArchiveMetaData ejbMetaData = this.ejb3MetaDataBuilder.create( dep, unit );
-         dep.addAttachment( EJBArchiveMetaData.class, ejbMetaData );
+         this.log.debug("Creating JBoss agnostic EJB3 meta data for deployment: " + dep.getSimpleName());
+         final EJBArchiveMetaData ejbMetaData = this.metaDataBuilderEJB3.create(dep);
+         dep.addAttachment(EJBArchiveMetaData.class, ejbMetaData);
       }
-      else if ( ASHelper.isJaxrpcEjbDeployment( unit ) )
+      else if (WSHelper.isJaxrpcEjbDeployment(dep))
       {
-         final EJBArchiveMetaData ejbMetaData = this.ejb21MetaDataBuilder.create( dep, unit );
-         dep.addAttachment( EJBArchiveMetaData.class, ejbMetaData );
+         this.log.debug("Creating JBoss agnostic EJB21 meta data for deployment: " + dep.getSimpleName());
+         final EJBArchiveMetaData ejbMetaData = this.metaDataBuilderEJB21.create(dep);
+         dep.addAttachment(EJBArchiveMetaData.class, ejbMetaData);
       }
    }
-   
+
 }

Deleted: branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/metadata/EJB21MetaDataBuilder.java
===================================================================
--- branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/metadata/EJB21MetaDataBuilder.java	2009-08-18 11:19:53 UTC (rev 92519)
+++ branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/metadata/EJB21MetaDataBuilder.java	2009-08-18 11:43:39 UTC (rev 92520)
@@ -1,173 +0,0 @@
-/*
- * 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;
-   }
-
-}

Deleted: branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/metadata/EJB3MetaDataBuilder.java
===================================================================
--- branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/metadata/EJB3MetaDataBuilder.java	2009-08-18 11:19:53 UTC (rev 92519)
+++ branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/metadata/EJB3MetaDataBuilder.java	2009-08-18 11:43:39 UTC (rev 92520)
@@ -1,180 +0,0 @@
-/*
- * 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;
-         }
-      };
-   }
-
-}

Deleted: branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/metadata/JSEMetaDataBuilder.java
===================================================================
--- branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/metadata/JSEMetaDataBuilder.java	2009-08-18 11:19:53 UTC (rev 92519)
+++ branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/metadata/JSEMetaDataBuilder.java	2009-08-18 11:43:39 UTC (rev 92520)
@@ -1,204 +0,0 @@
-/*
- * 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/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/metadata/MetaDataBuilderEJB21.java
===================================================================
--- branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/metadata/MetaDataBuilderEJB21.java	                        (rev 0)
+++ branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/metadata/MetaDataBuilderEJB21.java	2009-08-18 11:43:39 UTC (rev 92520)
@@ -0,0 +1,158 @@
+/*
+ * 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.LinkedList;
+import java.util.List;
+
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
+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.javaee.spec.PortComponent;
+import org.jboss.wsf.common.integration.WSHelper;
+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;
+
+/**
+ * Builds container independent meta data from EJB21 container meta data. 
+ *
+ * @author <a href="mailto:ropalka at redhat.com">Richard Opalka</a>
+ * @author <a href="mailto:tdiesler at redhat.com">Thomas Diesler</a>
+ */
+final class MetaDataBuilderEJB21 extends AbstractMetaDataBuilderEJB
+{
+
+   /**
+    * Constructor.
+    */
+   MetaDataBuilderEJB21()
+   {
+      super();
+   }
+
+   /**
+    * @see AbstractMetaDataBuilderEJB#buildEnterpriseBeansMetaData(Deployment, EJBArchiveMetaData)
+    * 
+    * @param dep webservice deployment
+    * @param ejbArchiveMD EJB archive meta data
+    */
+   @Override
+   protected void buildEnterpriseBeansMetaData(final Deployment dep, final EJBArchiveMetaData ejbArchiveMD)
+   {
+      final JBossMetaData jbossMetaData = WSHelper.getRequiredAttachment(dep, JBossMetaData.class);
+      final List<EJBMetaData> wsEjbsMD = new LinkedList<EJBMetaData>();
+
+      for (final JBossEnterpriseBeanMetaData jbossEjbMD : jbossMetaData.getEnterpriseBeans())
+      {
+         this.buildEnterpriseBeanMetaData(wsEjbsMD, jbossEjbMD);
+      }
+
+      ejbArchiveMD.setEnterpriseBeans(wsEjbsMD);
+
+      final String securityDomain = jbossMetaData.getSecurityDomain();
+      this.log.debug("Setting security domain: " + securityDomain);
+      ejbArchiveMD.setSecurityDomain(securityDomain);
+   }
+
+   /**
+    * Builds JBoss agnostic EJB meta data.
+    * 
+    * @param wsEjbsMD jboss agnostic EJBs meta data
+    * @param jbossEjbMD jboss specific EJB meta data
+    */
+   private void buildEnterpriseBeanMetaData(final List<EJBMetaData> wsEjbsMD,
+         final JBossEnterpriseBeanMetaData jbossEjbMD)
+   {
+      final EJBMetaData wsEjbMD = this.newEjbMetaData(jbossEjbMD);
+
+      if (wsEjbMD != null)
+      {
+         // set EJB name and class
+         wsEjbMD.setEjbName(jbossEjbMD.getEjbName());
+         wsEjbMD.setEjbClass(jbossEjbMD.getEjbClass());
+
+         if (jbossEjbMD.isSession())
+         {
+            final JBossSessionBeanMetaData sessionEjbMD = (JBossSessionBeanMetaData) jbossEjbMD;
+
+            // set home interfaces
+            wsEjbMD.setServiceEndpointInterface(sessionEjbMD.getServiceEndpoint());
+            wsEjbMD.setHome(sessionEjbMD.getHome());
+            wsEjbMD.setLocalHome(sessionEjbMD.getLocalHome());
+
+            // set JNDI names
+            wsEjbMD.setJndiName(sessionEjbMD.determineJndiName());
+            wsEjbMD.setLocalJndiName(jbossEjbMD.determineLocalJndiName());
+
+            final PortComponent portComponentMD = sessionEjbMD.getPortComponent();
+            if (portComponentMD != null)
+            {
+               // set port component meta data
+               wsEjbMD.setPortComponentName(portComponentMD.getPortComponentName());
+               wsEjbMD.setPortComponentURI(portComponentMD.getPortComponentURI());
+
+               // set security meta data
+               final EJBSecurityMetaData smd = new EJBSecurityMetaData();
+               smd.setAuthMethod(portComponentMD.getAuthMethod());
+               smd.setTransportGuarantee(portComponentMD.getTransportGuarantee());
+               smd.setSecureWSDLAccess(portComponentMD.getSecureWSDLAccess());
+               wsEjbMD.setSecurityMetaData(smd);
+            }
+         }
+
+         wsEjbsMD.add(wsEjbMD);
+      }
+   }
+
+   /**
+    * Creates new JBoss agnostic EJB bean meta data model.
+    *
+    * @param jbossEjbMD jboss EJB meta data
+    * @return webservices EJB meta data
+    */
+   private EJBMetaData newEjbMetaData(final JBossEnterpriseBeanMetaData jbossEjbMD)
+   {
+      if (jbossEjbMD.isSession())
+      {
+         this.log.debug("Creating JBoss agnostic EJB21 meta data for session bean: " + jbossEjbMD.getEjbClass());
+         return new SLSBMetaData();
+      }
+      else if (jbossEjbMD.isMessageDriven())
+      {
+         this.log.debug("Creating JBoss agnostic EJB21 meta data for message driven bean: " + jbossEjbMD.getEjbClass());
+         final MDBMetaData mdbMD = new MDBMetaData();
+
+         final JBossMessageDrivenBeanMetaData jbossMessageBean = (JBossMessageDrivenBeanMetaData) jbossEjbMD;
+         ((MDBMetaData) mdbMD).setDestinationJndiName(jbossMessageBean.getDestinationJndiName());
+
+         return mdbMD;
+      }
+
+      return null;
+   }
+
+}

Added: branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/metadata/MetaDataBuilderEJB3.java
===================================================================
--- branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/metadata/MetaDataBuilderEJB3.java	                        (rev 0)
+++ branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/metadata/MetaDataBuilderEJB3.java	2009-08-18 11:43:39 UTC (rev 92520)
@@ -0,0 +1,166 @@
+/*
+ * 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.LinkedList;
+import java.util.List;
+
+import javax.ejb.ActivationConfigProperty;
+import javax.ejb.MessageDriven;
+
+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.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.PortComponentSpec;
+import org.jboss.wsf.spi.metadata.j2ee.SLSBMetaData;
+
+/**
+ * Builds container independent meta data from EJB3 container meta data. 
+ *
+ * @author <a href="mailto:ropalka at redhat.com">Richard Opalka</a>
+ * @author <a href="mailto:tdiesler at redhat.com">Thomas Diesler</a>
+ */
+final class MetaDataBuilderEJB3 extends AbstractMetaDataBuilderEJB
+{
+
+   /**
+    * Constructor.
+    */
+   MetaDataBuilderEJB3()
+   {
+      super();
+   }
+
+   /**
+    * @see AbstractMetaDataBuilderEJB#buildEnterpriseBeansMetaData(Deployment, EJBArchiveMetaData)
+    * 
+    * @param dep webservice deployment
+    * @param ejbArchiveMD EJB archive meta data
+    */
+   @Override
+   protected void buildEnterpriseBeansMetaData(final Deployment dep, final EJBArchiveMetaData ejbArchiveMD)
+   {
+      final WebServiceDeployment ejb3Deployment = WSHelper.getRequiredAttachment(dep, WebServiceDeployment.class);
+      final List<EJBMetaData> wsEjbsMD = new LinkedList<EJBMetaData>();
+
+      for (final WebServiceDeclaration jbossEjbMD : ejb3Deployment.getServiceEndpoints())
+      {
+         this.buildEnterpriseBeanMetaData(wsEjbsMD, jbossEjbMD);
+      }
+
+      ejbArchiveMD.setEnterpriseBeans(wsEjbsMD);
+   }
+
+   /**
+    * Builds JBoss agnostic EJB meta data.
+    * 
+    * @param wsEjbsMD jboss agnostic EJBs meta data
+    * @param jbossEjbMD jboss specific EJB meta data
+    */
+   private void buildEnterpriseBeanMetaData(final List<EJBMetaData> wsEjbsMD, final WebServiceDeclaration jbossEjbMD)
+   {
+      final EJBMetaData wsEjbMD = this.newEjbMetaData(jbossEjbMD);
+
+      if (wsEjbMD != null)
+      {
+         // set EJB name and class
+         wsEjbMD.setEjbName(jbossEjbMD.getComponentName());
+         wsEjbMD.setEjbClass(jbossEjbMD.getComponentClassName());
+
+         final PortComponentSpec portComponentAnnotation = jbossEjbMD.getAnnotation(PortComponentSpec.class);
+         if (portComponentAnnotation != null)
+         {
+            // set port component meta data
+            wsEjbMD.setPortComponentName(portComponentAnnotation.portComponentName());
+            wsEjbMD.setPortComponentURI(portComponentAnnotation.portComponentURI());
+
+            // set security meta data
+            final EJBSecurityMetaData wsEjbSecurityMD = new EJBSecurityMetaData();
+            wsEjbSecurityMD.setAuthMethod(portComponentAnnotation.authMethod());
+            wsEjbSecurityMD.setTransportGuarantee(portComponentAnnotation.transportGuarantee());
+            wsEjbSecurityMD.setSecureWSDLAccess(portComponentAnnotation.secureWSDLAccess());
+            wsEjbMD.setSecurityMetaData(wsEjbSecurityMD);
+         }
+
+         wsEjbsMD.add(wsEjbMD);
+      }
+
+   }
+
+   /**
+    * Creates new JBoss agnostic EJB bean meta data model.
+    *
+    * @param jbossEjbMD jboss EJB meta data
+    * @return webservices EJB meta data
+    */
+   private EJBMetaData newEjbMetaData(final WebServiceDeclaration jbossEjbMD)
+   {
+      final MessageDriven mdbAnnotation = jbossEjbMD.getAnnotation(MessageDriven.class);
+
+      if (mdbAnnotation == null)
+      {
+         this.log.debug("Creating JBoss agnostic EJB3 meta data for session bean: "
+               + jbossEjbMD.getComponentClassName());
+         return new SLSBMetaData();
+      }
+      else
+      {
+         this.log.debug("Creating JBoss agnostic EJB3 meta data for message driven bean: "
+               + jbossEjbMD.getComponentClassName());
+         final MDBMetaData mdbMD = new MDBMetaData();
+
+         final String destinationName = this.getActivationProperty("destination", mdbAnnotation.activationConfig());
+         mdbMD.setDestinationJndiName(destinationName);
+
+         return mdbMD;
+      }
+   }
+
+   /**
+    * Returns activation config property value or null if not found.
+    * 
+    * @param name activation property name
+    * @param activationConfigProperties activation config properties
+    * @return activation config property value
+    */
+   private String getActivationProperty(final String name, final ActivationConfigProperty[] activationConfigProperties)
+   {
+      if (activationConfigProperties != null)
+      {
+         for (final ActivationConfigProperty activationConfigProperty : activationConfigProperties)
+         {
+            if (activationConfigProperty.propertyName().equals(name))
+            {
+               return activationConfigProperty.propertyValue();
+            }
+         }
+      }
+
+      return null;
+   }
+
+}

Added: branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/metadata/MetaDataBuilderJSE.java
===================================================================
--- branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/metadata/MetaDataBuilderJSE.java	                        (rev 0)
+++ branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/metadata/MetaDataBuilderJSE.java	2009-08-18 11:43:39 UTC (rev 92520)
@@ -0,0 +1,288 @@
+/*
+ * 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.HashMap;
+import java.util.LinkedList;
+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.common.integration.WSConstants;
+import org.jboss.wsf.common.integration.WSHelper;
+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.JSESecurityMetaData.JSEResourceCollection;
+import org.jboss.wsf.spi.metadata.j2ee.PublishLocationAdapter;
+
+/**
+ * Builds container independent meta data from WEB container meta data. 
+ *
+ * @author <a href="mailto:ropalka at redhat.com">Richard Opalka</a>
+ * @author <a href="mailto:tdiesler at redhat.com">Thomas Diesler</a>
+ */
+final class MetaDataBuilderJSE
+{
+
+   /** Logger. */
+   private final Logger log = Logger.getLogger(MetaDataBuilderJSE.class);
+
+   /**
+    * Constructor.
+    */
+   MetaDataBuilderJSE()
+   {
+      super();
+   }
+
+   /**
+    * Builds universal JSE meta data model that is AS agnostic.
+    * 
+    * @param dep webservice deployment
+    * @return universal JSE meta data model
+    */
+   JSEArchiveMetaData create(final Deployment dep)
+   {
+      final JBossWebMetaData jbossWebMD = WSHelper.getRequiredAttachment(dep, JBossWebMetaData.class);
+      final JSEArchiveMetaData jseArchiveMD = new JSEArchiveMetaData();
+
+      // set context root
+      final String contextRoot = this.getContextRoot(dep, jbossWebMD);
+      jseArchiveMD.setContextRoot(contextRoot);
+
+      // set servlet url patterns mappings
+      final Map<String, String> servletMappings = this.getServletUrlPatternsMappings(jbossWebMD);
+      jseArchiveMD.setServletMappings(servletMappings);
+
+      // set servlet class names mappings
+      final Map<String, String> servletClassNamesMappings = this.getServletClassMappings(jbossWebMD);
+      jseArchiveMD.setServletClassNames(servletClassNamesMappings);
+
+      // set security domain
+      final String securityDomain = jbossWebMD.getSecurityDomain();
+      jseArchiveMD.setSecurityDomain(securityDomain);
+
+      // set wsdl location resolver
+      final PublishLocationAdapter resolver = new PublishLocationAdapterImpl(jbossWebMD.getWebserviceDescriptions());
+      jseArchiveMD.setPublishLocationAdapter(resolver);
+
+      // set security meta data
+      final List<JSESecurityMetaData> jseSecurityMDs = this.getSecurityMetaData(jbossWebMD.getSecurityContraints());
+      jseArchiveMD.setSecurityMetaData(jseSecurityMDs);
+
+      // set config name and file
+      this.setConfigNameAndFile(jseArchiveMD, jbossWebMD);
+
+      return jseArchiveMD;
+   }
+
+   /**
+    * Sets config name and config file.
+    *
+    * @param jseArchiveMD universal JSE meta data model
+    * @param jbossWebMD jboss web meta data
+    */
+   private void setConfigNameAndFile(final JSEArchiveMetaData jseArchiveMD, final JBossWebMetaData jbossWebMD)
+   {
+      final WebserviceDescriptionsMetaData wsDescriptionsMD = jbossWebMD.getWebserviceDescriptions();
+      final WebserviceDescriptionMetaData wsDescriptionMD = ASHelper.getWebserviceDescriptionMetaData(wsDescriptionsMD);
+      if (wsDescriptionMD != null)
+      {
+         if (wsDescriptionMD.getConfigName() != null)
+         {
+            jseArchiveMD.setConfigName(wsDescriptionMD.getConfigName());
+            jseArchiveMD.setConfigFile(wsDescriptionMD.getConfigFile());
+
+            // ensure higher priority against web.xml context parameters
+            return;
+         }
+      }
+
+      final List<ParamValueMetaData> contextParams = jbossWebMD.getContextParams();
+      if (contextParams != null)
+      {
+         for (final ParamValueMetaData contextParam : contextParams)
+         {
+            if (WSConstants.JBOSSWS_CONFIG_NAME.equals(contextParam.getParamName()))
+            {
+               jseArchiveMD.setConfigName(contextParam.getParamValue());
+            }
+            if (WSConstants.JBOSSWS_CONFIG_FILE.equals(contextParam.getParamName()))
+            {
+               jseArchiveMD.setConfigFile(contextParam.getParamValue());
+            }
+         }
+      }
+   }
+
+   /**
+    * Builds security meta data.
+    * 
+    * @param securityConstraintsMD security constraints meta data
+    * @return universal JSE security meta data model
+    */
+   private List<JSESecurityMetaData> getSecurityMetaData(final List<SecurityConstraintMetaData> securityConstraintsMD)
+   {
+      final List<JSESecurityMetaData> jseSecurityMDs = new LinkedList<JSESecurityMetaData>();
+
+      if (securityConstraintsMD != null)
+      {
+         for (final SecurityConstraintMetaData securityConstraintMD : securityConstraintsMD)
+         {
+            final JSESecurityMetaData jseSecurityMD = new JSESecurityMetaData();
+
+            // transport guarantee
+            jseSecurityMD.setTransportGuarantee(securityConstraintMD.getTransportGuarantee().name());
+
+            // web resources
+            this.setWebResources(jseSecurityMD, securityConstraintMD);
+
+            jseSecurityMDs.add(jseSecurityMD);
+         }
+      }
+
+      return jseSecurityMDs;
+   }
+
+   /**
+    * Sets web resources in universal meta data model.
+    * 
+    * @param jseSecurityMD universal JSE security meta data model
+    * @param securityConstraintMD security constraint meta data
+    */
+   private void setWebResources(final JSESecurityMetaData jseSecurityMD,
+         final SecurityConstraintMetaData securityConstraintMD)
+   {
+      final WebResourceCollectionsMetaData webResources = securityConstraintMD.getResourceCollections();
+
+      for (final WebResourceCollectionMetaData webResourceMD : webResources)
+      {
+         final JSEResourceCollection jseResource = jseSecurityMD.addWebResource(webResourceMD.getName());
+
+         for (final String webResourceUrlPatterns : webResourceMD.getUrlPatterns())
+         {
+            jseResource.addPattern(webResourceUrlPatterns);
+         }
+      }
+   }
+
+   /**
+    * Returns servlet name to url pattern mappings.
+    * 
+    * @param jbossWebMD jboss web meta data
+    * @return servlet name to url pattern mappings
+    */
+   private Map<String, String> getServletUrlPatternsMappings(final JBossWebMetaData jbossWebMD)
+   {
+      final Map<String, String> mappings = new HashMap<String, String>();
+      final List<ServletMappingMetaData> servletMappings = jbossWebMD.getServletMappings();
+
+      if (servletMappings != null)
+      {
+         for (final ServletMappingMetaData mapping : servletMappings)
+         {
+            mappings.put(mapping.getServletName(), mapping.getUrlPatterns().get(0));
+         }
+      }
+
+      return mappings;
+   }
+
+   /**
+    * Returns servlet name to servlet class mappings.
+    * 
+    * @param jbossWebMD jboss web meta data
+    * @return servlet name to servlet mappings
+    */
+   private Map<String, String> getServletClassMappings(final JBossWebMetaData jbossWebMD)
+   {
+      final Map<String, String> mappings = new HashMap<String, String>();
+      final JBossServletsMetaData servlets = jbossWebMD.getServlets();
+
+      if (servlets != null)
+      {
+         for (final ServletMetaData servlet : servlets)
+         {
+            if (servlet.getServletClass() == null || servlet.getServletClass().trim().length() == 0)
+            {
+               // Skip JSPs
+               continue;
+            }
+
+            this.log.debug("Creating JBoss agnostic JSE meta data for POJO bean: " + servlet.getServletClass());
+            mappings.put(servlet.getName(), servlet.getServletClass());
+         }
+      }
+
+      return mappings;
+   }
+
+   /**
+    * Returns context root associated with webservice deployment.
+    *
+    * If there's application.xml descriptor provided defining nested web module,
+    * then context root defined there will be returned. 
+    * Otherwise context root defined in jboss-web.xml will be returned.
+    * 
+    * @param dep webservice deployment
+    * @param jbossWebMD jboss web meta data
+    * @return context root
+    */
+   private String getContextRoot(final Deployment dep, final JBossWebMetaData jbossWebMD)
+   {
+      final DeploymentUnit unit = WSHelper.getRequiredAttachment(dep, DeploymentUnit.class);
+      final JBossAppMetaData jbossAppMD = unit.getParent() == null ? null : ASHelper.getOptionalAttachment(unit
+            .getParent(), JBossAppMetaData.class);
+
+      String contextRoot = null;
+
+      if (jbossAppMD != null)
+      {
+         final ModuleMetaData moduleMD = jbossAppMD.getModule(dep.getSimpleName());
+         if (moduleMD != null)
+         {
+            final WebModuleMetaData webModuleMD = (WebModuleMetaData) moduleMD.getValue();
+            contextRoot = webModuleMD.getContextRoot();
+         }
+      }
+
+      // prefer context root defined in application.xml over one defined in jboss-web.xml
+      return contextRoot != null ? contextRoot : jbossWebMD.getContextRoot();
+   }
+
+}

Added: branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/metadata/PublishLocationAdapterImpl.java
===================================================================
--- branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/metadata/PublishLocationAdapterImpl.java	                        (rev 0)
+++ branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/metadata/PublishLocationAdapterImpl.java	2009-08-18 11:43:39 UTC (rev 92520)
@@ -0,0 +1,73 @@
+/*
+ * 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.metadata.common.jboss.WebserviceDescriptionMetaData;
+import org.jboss.metadata.common.jboss.WebserviceDescriptionsMetaData;
+import org.jboss.wsf.spi.metadata.j2ee.PublishLocationAdapter;
+
+/**
+ * Publish location adapter implementation.
+ *
+ * @author <a href="mailto:ropalka at redhat.com">Richard Opalka</a>
+ * @author <a href="mailto:tdiesler at redhat.com">Thomas Diesler</a>
+ */
+final class PublishLocationAdapterImpl implements PublishLocationAdapter
+{
+
+   /** Webservice descriptions meta data. */
+   private final WebserviceDescriptionsMetaData wsDescriptionsMD;
+
+   /**
+    * Constructor.
+    * 
+    * @param wsDescriptionsMD webservice descriptions meta data
+    */
+   PublishLocationAdapterImpl(final WebserviceDescriptionsMetaData wsDescriptionsMD)
+   {
+      super();
+
+      this.wsDescriptionsMD = wsDescriptionsMD;
+   }
+
+   /**
+    * @see org.jboss.wsf.spi.metadata.j2ee.PublishLocationAdapter#getWsdlPublishLocationByName(String)
+    * 
+    * @param endpointName endpoint name
+    * @return publish location
+    */
+   public String getWsdlPublishLocationByName(final String endpointName)
+   {
+      if (this.wsDescriptionsMD != null)
+      {
+         final WebserviceDescriptionMetaData endpointMD = this.wsDescriptionsMD.get(endpointName);
+
+         if (endpointMD != null)
+         {
+            return endpointMD.getWsdlPublishLocation();
+         }
+      }
+
+      return null;
+   }
+
+}

Modified: branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/security/JACCPermissionsDeploymentAspect.java
===================================================================
--- branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/security/JACCPermissionsDeploymentAspect.java	2009-08-18 11:19:53 UTC (rev 92519)
+++ branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/security/JACCPermissionsDeploymentAspect.java	2009-08-18 11:43:39 UTC (rev 92520)
@@ -49,7 +49,7 @@
    {
       super();
    }
-   
+
    /**
     * JBAS-5935: The dynamic web application generated by the JBossWS
     * does not go through the war security deployer. Hence the JACC
@@ -58,23 +58,24 @@
     * 
     * @param dep webservice deployment
     */
-   public void start( final Deployment dep )
+   @Override
+   public void start(final Deployment dep)
    {
-      final JBossWebMetaData jbossWebMD = WSHelper.getRequiredAttachment( dep, JBossWebMetaData.class );
-      
+      final JBossWebMetaData jbossWebMD = WSHelper.getRequiredAttachment(dep, JBossWebMetaData.class);
+
       try
       {
-         final PolicyConfigurationFactory policyConfigurationFactory = 
-            PolicyConfigurationFactory.getPolicyConfigurationFactory();
-         final PolicyConfiguration policyConfiguration = 
-            policyConfigurationFactory.getPolicyConfiguration( dep.getSimpleName(), false );
+         final PolicyConfigurationFactory policyConfigurationFactory = PolicyConfigurationFactory
+               .getPolicyConfigurationFactory();
+         final PolicyConfiguration policyConfiguration = policyConfigurationFactory.getPolicyConfiguration(dep
+               .getSimpleName(), false);
 
-         WebPermissionMapping.createPermissions( jbossWebMD, policyConfiguration );
+         WebPermissionMapping.createPermissions(jbossWebMD, policyConfiguration);
          policyConfiguration.commit();
       }
-      catch ( Exception e )
+      catch (Exception e)
       {
-         throw new RuntimeException( "Exception generating JACC perms: ", e );
+         throw new RuntimeException("Exception generating JACC perms: ", e);
       }
    }
 

Added: branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/security/SecurityAdapterFactoryImpl.java
===================================================================
--- branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/security/SecurityAdapterFactoryImpl.java	                        (rev 0)
+++ branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/security/SecurityAdapterFactoryImpl.java	2009-08-18 11:43:39 UTC (rev 92520)
@@ -0,0 +1,54 @@
+/*
+ * 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 org.jboss.wsf.spi.invocation.SecurityAdaptor;
+import org.jboss.wsf.spi.invocation.SecurityAdaptorFactory;
+
+/**
+ * Security adapters factory.
+ * 
+ * @author <a href="mailto:ropalka at redhat.com">Richard Opalka</a>
+ * @author <a href="mailto:tdiesler at redhat.com">Thomas Diesler</a>
+ */
+public final class SecurityAdapterFactoryImpl extends SecurityAdaptorFactory
+{
+
+   /**
+    * Constructor.
+    */
+   public SecurityAdapterFactoryImpl()
+   {
+      super();
+   }
+
+   /**
+    * Creates new security adapter instance.
+    * 
+    * @return security adapter
+    */
+   public SecurityAdaptor newSecurityAdapter()
+   {
+      return new SecurityAdapterImpl();
+   }
+
+}

Added: branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/security/SecurityAdapterImpl.java
===================================================================
--- branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/security/SecurityAdapterImpl.java	                        (rev 0)
+++ branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/security/SecurityAdapterImpl.java	2009-08-18 11:43:39 UTC (rev 92520)
@@ -0,0 +1,119 @@
+/*
+ * 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 java.security.AccessController;
+import java.security.Principal;
+import java.security.PrivilegedAction;
+
+import javax.security.auth.Subject;
+
+import org.jboss.security.SecurityAssociation;
+import org.jboss.security.SecurityContext;
+import org.jboss.security.SecurityContextAssociation;
+import org.jboss.wsf.spi.invocation.SecurityAdaptor;
+
+/**
+ * The JBoss AS specific SecurityAssociation adapter.
+ *
+ * @author <a href="mailto:ropalka at redhat.com">Richard Opalka</a>
+ * @author <a href="mailto:tdiesler at redhat.com">Thomas Diesler</a>
+ */
+final class SecurityAdapterImpl implements SecurityAdaptor
+{
+
+   /**
+    * Constructor.
+    */
+   SecurityAdapterImpl()
+   {
+      super();
+   }
+
+   /**
+    * @see org.jboss.wsf.spi.invocation.SecurityAdaptor#getPrincipal()
+    * 
+    * @return principal
+    */
+   public Principal getPrincipal()
+   {
+      return SecurityAssociation.getPrincipal();
+   }
+
+   /**
+    * @see org.jboss.wsf.spi.invocation.SecurityAdaptor#setPrincipal(Principal)
+    * 
+    * @param principal principal
+    */
+   public void setPrincipal(final Principal principal)
+   {
+      SecurityAssociation.setPrincipal(principal);
+   }
+
+   /**
+    * @see org.jboss.wsf.spi.invocation.SecurityAdaptor#getCredential()
+    * 
+    * @return credential
+    */
+   public Object getCredential()
+   {
+      return SecurityAssociation.getCredential();
+   }
+
+   /**
+    * @see org.jboss.wsf.spi.invocation.SecurityAdaptor#setCredential(Object)
+    *  
+    * @param credential credential
+    */
+   public void setCredential(final Object credential)
+   {
+      SecurityAssociation.setCredential(credential);
+   }
+
+   /**
+    * @see org.jboss.wsf.spi.invocation.SecurityAdaptor#pushSubjectContext(Subject, Principal, Object)
+    * 
+    * @param subject subject
+    * @param principal principal
+    * @param credential credential
+    */
+   public void pushSubjectContext(final Subject subject, final Principal principal, final Object credential)
+   {
+      AccessController.doPrivileged(new PrivilegedAction<Void>()
+      {
+
+         public Void run()
+         {
+            final SecurityContext securityContext = SecurityContextAssociation.getSecurityContext();
+            if (securityContext == null)
+            {
+               throw new IllegalStateException("Security Context is null");
+            }
+
+            securityContext.getUtil().createSubjectInfo(principal, credential, subject);
+
+            return null;
+         }
+      });
+   }
+
+}

Added: branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/tomcat/AbstractSecurityMetaDataAccessorEJB.java
===================================================================
--- branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/tomcat/AbstractSecurityMetaDataAccessorEJB.java	                        (rev 0)
+++ branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/tomcat/AbstractSecurityMetaDataAccessorEJB.java	2009-08-18 11:43:39 UTC (rev 92520)
@@ -0,0 +1,130 @@
+/*
+ * 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.common.integration.WSHelper;
+import org.jboss.wsf.spi.deployment.Deployment;
+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;
+
+/**
+ * Creates web app security meta data for EJB deployment.
+ *
+ * @author <a href="mailto:ropalka at redhat.com">Richard Opalka</a>
+ * @author <a href="mailto:tdiesler at redhat.com">Thomas Diesler</a>
+ */
+abstract class AbstractSecurityMetaDataAccessorEJB implements SecurityMetaDataAccessorEJB
+{
+
+   /** JAAS JNDI prefix. */
+   private static final String JAAS_JNDI_PREFIX = "java:/jaas/";
+
+   /**
+    * Constructor.
+    */
+   protected AbstractSecurityMetaDataAccessorEJB()
+   {
+      super();
+   }
+
+   /**
+    * Appends 'java:/jaas/' prefix to security domain if it's not prefixed with it.
+    *
+    * @param securityDomain security domain to be prefixed
+    * @return security domain prefixed with jaas JNDI prefix
+    */
+   protected final String appendJaasPrefix(final String securityDomain)
+   {
+      if (securityDomain != null)
+      {
+         final boolean hasJaasPrefix = securityDomain.startsWith(AbstractSecurityMetaDataAccessorEJB.JAAS_JNDI_PREFIX);
+
+         if (!hasJaasPrefix)
+         {
+            return AbstractSecurityMetaDataAccessorEJB.JAAS_JNDI_PREFIX + securityDomain;
+         }
+      }
+
+      return securityDomain;
+   }
+
+   /**
+    * @see org.jboss.webservices.integration.tomcat.SecurityMetaDataAccessorEJB#getAuthMethod(Endpoint)
+    *
+    * @param endpoint EJB webservice endpoint
+    * @return authentication method or null if not specified
+    */
+   public String getAuthMethod(final Endpoint endpoint)
+   {
+      final EJBSecurityMetaData ejbSecurityMD = this.getEjbSecurityMetaData(endpoint);
+      final boolean hasEjbSecurityMD = ejbSecurityMD != null;
+
+      return hasEjbSecurityMD ? ejbSecurityMD.getAuthMethod() : null;
+   }
+
+   /**
+    * @see org.jboss.webservices.integration.tomcat.SecurityMetaDataAccessorEJB#isSecureWsdlAccess(Endpoint)
+    *
+    * @param endpoint EJB webservice endpoint
+    * @return whether WSDL access have to be secured
+    */
+   public boolean isSecureWsdlAccess(final Endpoint endpoint)
+   {
+      final EJBSecurityMetaData ejbSecurityMD = this.getEjbSecurityMetaData(endpoint);
+      final boolean hasEjbSecurityMD = ejbSecurityMD != null;
+
+      return hasEjbSecurityMD ? ejbSecurityMD.getSecureWSDLAccess() : false;
+   }
+
+   /**
+    * @see org.jboss.webservices.integration.tomcat.SecurityMetaDataAccessorEJB#getTransportGuarantee(Endpoint)
+    *
+    * @param endpoint EJB webservice endpoint
+    * @return transport guarantee or null if not specified
+    */
+   public String getTransportGuarantee(final Endpoint endpoint)
+   {
+      final EJBSecurityMetaData ejbSecurityMD = this.getEjbSecurityMetaData(endpoint);
+      final boolean hasEjbSecurityMD = ejbSecurityMD != null;
+
+      return hasEjbSecurityMD ? ejbSecurityMD.getTransportGuarantee() : null;
+   }
+
+   /**
+    * Gets EJB security meta data if associated with EJB endpoint.
+    *
+    * @param endpoint EJB webservice endpoint
+    * @return EJB security meta data or null
+    */
+   private EJBSecurityMetaData getEjbSecurityMetaData(final Endpoint endpoint)
+   {
+      final String ejbName = endpoint.getShortName();
+      final Deployment dep = endpoint.getService().getDeployment();
+      final EJBArchiveMetaData ejbArchiveMD = WSHelper.getOptionalAttachment(dep, EJBArchiveMetaData.class);
+      final EJBMetaData ejbMD = ejbArchiveMD != null ? ejbArchiveMD.getBeanByEjbName(ejbName) : null;
+
+      return ejbMD != null ? ejbMD.getSecurityMetaData() : null;
+   }
+
+}

Deleted: branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/tomcat/SecurityHandler.java
===================================================================
--- branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/tomcat/SecurityHandler.java	2009-08-18 11:19:53 UTC (rev 92519)
+++ branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/tomcat/SecurityHandler.java	2009-08-18 11:43:39 UTC (rev 92520)
@@ -1,39 +0,0 @@
-/*
- * 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);
-}

Deleted: branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/tomcat/SecurityHandlerEJB21.java
===================================================================
--- branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/tomcat/SecurityHandlerEJB21.java	2009-08-18 11:19:53 UTC (rev 92519)
+++ branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/tomcat/SecurityHandlerEJB21.java	2009-08-18 11:43:39 UTC (rev 92520)
@@ -1,65 +0,0 @@
-/*
- * 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);
-      }
-   }
-}

Deleted: branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/tomcat/SecurityHandlerEJB3.java
===================================================================
--- branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/tomcat/SecurityHandlerEJB3.java	2009-08-18 11:19:53 UTC (rev 92519)
+++ branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/tomcat/SecurityHandlerEJB3.java	2009-08-18 11:43:39 UTC (rev 92520)
@@ -1,94 +0,0 @@
-/*
- * 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/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/tomcat/SecurityMetaDataAccessorEJB.java
===================================================================
--- branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/tomcat/SecurityMetaDataAccessorEJB.java	                        (rev 0)
+++ branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/tomcat/SecurityMetaDataAccessorEJB.java	2009-08-18 11:43:39 UTC (rev 92520)
@@ -0,0 +1,77 @@
+/*
+ * 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.javaee.spec.SecurityRolesMetaData;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.deployment.Endpoint;
+
+/**
+ * Creates web app security meta data for EJB deployments.
+ *
+ * @author <a href="mailto:ropalka at redhat.com">Richard Opalka</a>
+ * @author <a href="mailto:tdiesler at redhat.com">Thomas Diesler</a>
+ */
+interface SecurityMetaDataAccessorEJB
+{
+
+   /**
+    * Obtains security domain from EJB deployment.
+    *
+    * @param dep webservice deployment
+    * @return security domain associated with EJB deployment
+    */
+   String getSecurityDomain(Deployment dep);
+
+   /**
+    * Obtains security roles from EJB deployment.
+    *
+    * @param dep webservice deployment
+    * @return security roles associated with EJB deployment
+    */
+   SecurityRolesMetaData getSecurityRoles(Deployment dep);
+
+   /**
+    * Whether WSDL access have to be secured.
+    *
+    * @param endpoint webservice EJB endpoint
+    * @return authentication method or null if not specified
+    */
+   boolean isSecureWsdlAccess(Endpoint endpoint);
+
+   /**
+    * Gets EJB authentication method.
+    *
+    * @param endpoint webservice EJB endpoint
+    * @return authentication method or null if not specified
+    */
+   String getAuthMethod(Endpoint endpoint);
+
+   /**
+    * Gets EJB transport guarantee.
+    *
+    * @param endpoint webservice EJB endpoint
+    * @return transport guarantee or null if not specified
+    */
+   String getTransportGuarantee(Endpoint endpoint);
+
+}

Added: branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/tomcat/SecurityMetaDataAccessorEJB21.java
===================================================================
--- branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/tomcat/SecurityMetaDataAccessorEJB21.java	                        (rev 0)
+++ branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/tomcat/SecurityMetaDataAccessorEJB21.java	2009-08-18 11:43:39 UTC (rev 92520)
@@ -0,0 +1,75 @@
+/*
+ * 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.wsf.common.integration.WSHelper;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.metadata.j2ee.EJBArchiveMetaData;
+
+/**
+ * Creates web app security meta data for EJB 21 deployment. 
+ *
+ * @author <a href="mailto:ropalka at redhat.com">Richard Opalka</a>
+ * @author <a href="mailto:tdiesler at redhat.com">Thomas Diesler</a>
+ */
+final class SecurityMetaDataAccessorEJB21 extends AbstractSecurityMetaDataAccessorEJB
+{
+
+   /**
+    * Constructor.
+    */
+   SecurityMetaDataAccessorEJB21()
+   {
+      super();
+   }
+
+   /**
+    * @see org.jboss.webservices.integration.tomcat.AbstractSecurityMetaDataAccessorEJB#getSecurityDomain(Deployment)
+    *
+    * @param dep webservice deployment
+    * @return security domain associated with EJB 21 deployment
+    */
+   public String getSecurityDomain(final Deployment dep)
+   {
+      final EJBArchiveMetaData ejbMetaData = WSHelper.getRequiredAttachment(dep, EJBArchiveMetaData.class);
+
+      return super.appendJaasPrefix(ejbMetaData.getSecurityDomain());
+   }
+
+   /**
+    * @see org.jboss.webservices.integration.tomcat.AbstractSecurityMetaDataAccessorEJB#getSecurityRoles(Deployment)
+    *
+    * @param dep webservice deployment
+    * @return security roles associated with EJB 21 deployment
+    */
+   public SecurityRolesMetaData getSecurityRoles(final Deployment dep)
+   {
+      final JBossMetaData jbossWebMD = WSHelper.getRequiredAttachment(dep, JBossMetaData.class);
+      final IAssemblyDescriptorMetaData assemblyDescriptorMD = jbossWebMD.getAssemblyDescriptor();
+
+      return (assemblyDescriptorMD != null) ? assemblyDescriptorMD.getSecurityRoles() : null;
+   }
+
+}

Added: branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/tomcat/SecurityMetaDataAccessorEJB3.java
===================================================================
--- branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/tomcat/SecurityMetaDataAccessorEJB3.java	                        (rev 0)
+++ branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/tomcat/SecurityMetaDataAccessorEJB3.java	2009-08-18 11:43:39 UTC (rev 92520)
@@ -0,0 +1,212 @@
+/*
+ * 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.Iterator;
+
+import javax.annotation.security.RolesAllowed;
+
+import org.jboss.ejb3.annotation.SecurityDomain;
+import org.jboss.metadata.javaee.spec.SecurityRoleMetaData;
+import org.jboss.metadata.javaee.spec.SecurityRolesMetaData;
+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.Endpoint;
+import org.jboss.wsf.spi.deployment.integration.WebServiceDeclaration;
+import org.jboss.wsf.spi.deployment.integration.WebServiceDeployment;
+
+/**
+ * Creates web app security meta data for EJB 3 deployment.
+ *
+ * @author <a href="mailto:ropalka at redhat.com">Richard Opalka</a>
+ * @author <a href="mailto:tdiesler at redhat.com">Thomas Diesler</a>
+ */
+final class SecurityMetaDataAccessorEJB3 extends AbstractSecurityMetaDataAccessorEJB
+{
+
+   /**
+    * Constructor.
+    */
+   SecurityMetaDataAccessorEJB3()
+   {
+      super();
+   }
+
+   /**
+    * @see org.jboss.webservices.integration.tomcat.AbstractSecurityMetaDataAccessorEJB#getSecurityDomain(Deployment)
+    *
+    * @param dep webservice deployment
+    * @return security domain associated with EJB 3 deployment
+    */
+   public String getSecurityDomain(final Deployment dep)
+   {
+      final WebServiceDeployment wsDeployment = WSHelper.getRequiredAttachment(dep, WebServiceDeployment.class);
+      String securityDomain = null;
+      final Iterator<WebServiceDeclaration> ejbContainers = wsDeployment.getServiceEndpoints().iterator();
+
+      while (ejbContainers.hasNext())
+      {
+         final WebServiceDeclaration ejbContainer = ejbContainers.next();
+         final SecurityDomain nextSecurityDomain = ejbContainer.getAnnotation(SecurityDomain.class);
+
+         securityDomain = this.getDomain(securityDomain, nextSecurityDomain);
+      }
+
+      return super.appendJaasPrefix(securityDomain);
+   }
+
+   /**
+    * @see org.jboss.webservices.integration.tomcat.AbstractSecurityMetaDataAccessorEJB#getSecurityRoles(Deployment)
+    *
+    * @param dep webservice deployment
+    * @return security roles associated with EJB 21 deployment
+    */
+   public SecurityRolesMetaData getSecurityRoles(final Deployment dep)
+   {
+      final WebServiceDeployment wsDeployment = WSHelper.getRequiredAttachment(dep, WebServiceDeployment.class);
+      final SecurityRolesMetaData securityRolesMD = new SecurityRolesMetaData();
+      final Iterator<WebServiceDeclaration> ejbContainers = wsDeployment.getServiceEndpoints().iterator();
+
+      while (ejbContainers.hasNext())
+      {
+         final WebServiceDeclaration ejbContainer = ejbContainers.next();
+         final RolesAllowed allowedRoles = ejbContainer.getAnnotation(RolesAllowed.class);
+         final boolean hasAllowedRoles = allowedRoles != null;
+
+         if (hasAllowedRoles)
+         {
+            for (final String roleName : allowedRoles.value())
+            {
+               final SecurityRoleMetaData securityRoleMD = new SecurityRoleMetaData();
+
+               securityRoleMD.setRoleName(roleName);
+               securityRolesMD.add(securityRoleMD);
+            }
+         }
+      }
+
+      return securityRolesMD;
+   }
+
+   /**
+    * @see org.jboss.webservices.integration.tomcat.SecurityMetaDataAccessorEJB#getAuthMethod(Endpoint)
+    *
+    * @param endpoint EJB webservice endpoint
+    * @return authentication method or null if not specified
+    */
+   public String getAuthMethod(final Endpoint endpoint)
+   {
+      final WebContext webContext = this.getWebContextAnnotation(endpoint);
+      final boolean hasAuthMethod = (webContext != null) && (webContext.authMethod().length() > 0);
+
+      return hasAuthMethod ? webContext.authMethod() : super.getAuthMethod(endpoint);
+   }
+
+   /**
+    * @see org.jboss.webservices.integration.tomcat.SecurityMetaDataAccessorEJB#isSecureWsdlAccess(Endpoint)
+    *
+    * @param endpoint EJB webservice endpoint
+    * @return whether WSDL access have to be secured
+    */
+   public boolean isSecureWsdlAccess(final Endpoint endpoint)
+   {
+      final WebContext webContext = this.getWebContextAnnotation(endpoint);
+      final boolean hasSecureWsdlAccess = (webContext != null) && (webContext.secureWSDLAccess());
+
+      return hasSecureWsdlAccess ? true : super.isSecureWsdlAccess(endpoint);
+   }
+
+   /**
+    * @see org.jboss.webservices.integration.tomcat.SecurityMetaDataAccessorEJB#getTransportGuarantee(Endpoint)
+    *
+    * @param endpoint EJB webservice endpoint
+    * @return transport guarantee or null if not specified
+    */
+   public String getTransportGuarantee(final Endpoint endpoint)
+   {
+      final WebContext webContext = this.getWebContextAnnotation(endpoint);
+      final boolean hasTransportGuarantee = (webContext != null) && (webContext.transportGuarantee().length() > 0);
+
+      return hasTransportGuarantee ? webContext.transportGuarantee() : super.getTransportGuarantee(endpoint);
+   }
+
+   /**
+    * Gets <b>WebContext</b> if associated with EJB endpoint.
+    * 
+    * @param endpoint EJB webservice endpoint 
+    * @return web context associated with EJB or null
+    */
+   @SuppressWarnings(
+   {"unchecked"})
+   private WebContext getWebContextAnnotation(final Endpoint endpoint)
+   {
+      return (WebContext) endpoint.getTargetBeanClass().getAnnotation(WebContext.class);
+   }
+
+   /**
+    * Returns security domain value. This method checks domain is the same for every EJB 3 endpoint.
+    *
+    * @param oldSecurityDomain our security domain
+    * @param nextSecurityDomain next security domain
+    * @return security domain value
+    * @throws IllegalStateException if domains have different values
+    */
+   private String getDomain(final String oldSecurityDomain, final SecurityDomain nextSecurityDomain)
+   {
+      if (nextSecurityDomain == null)
+      {
+         return oldSecurityDomain;
+      }
+
+      if (oldSecurityDomain == null)
+      {
+         return nextSecurityDomain.value();
+      }
+
+      this.ensureSameDomains(oldSecurityDomain, nextSecurityDomain.value());
+
+      return oldSecurityDomain;
+   }
+
+   /**
+    * This method ensures both passed domains contain the same value.
+    *
+    * @param oldSecurityDomain our security domain
+    * @param newSecurityDomain next security domain
+    * @throws IllegalStateException if domains have different values
+    */
+   private void ensureSameDomains(final String oldSecurityDomain, final String newSecurityDomain)
+   {
+      final boolean domainsDiffer = !oldSecurityDomain.equals(newSecurityDomain);
+
+      if (domainsDiffer)
+      {
+         final String errorMessage = "Multiple security domains not supported. ";
+         final String firstDomain = "First domain: '" + oldSecurityDomain + "' ";
+         final String secondDomain = "second domain: '" + newSecurityDomain + "'";
+
+         throw new IllegalStateException(errorMessage + firstDomain + secondDomain);
+      }
+   }
+
+}

Deleted: branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/tomcat/WebAppGeneratorDeploymentAspect.java
===================================================================
--- branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/tomcat/WebAppGeneratorDeploymentAspect.java	2009-08-18 11:19:53 UTC (rev 92519)
+++ branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/tomcat/WebAppGeneratorDeploymentAspect.java	2009-08-18 11:43:39 UTC (rev 92520)
@@ -1,285 +0,0 @@
-/*
- * 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/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/tomcat/WebMetaDataCreatingDeploymentAspect.java
===================================================================
--- branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/tomcat/WebMetaDataCreatingDeploymentAspect.java	                        (rev 0)
+++ branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/tomcat/WebMetaDataCreatingDeploymentAspect.java	2009-08-18 11:43:39 UTC (rev 92520)
@@ -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.wsf.common.integration.WSHelper;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.deployment.DeploymentAspect;
+
+/**
+ * A deployment aspect that generates web app meta data for EJB endpoints. 
+ *
+ * @author <a href="mailto:ropalka at redhat.com">Richard Opalka</a>
+ * @author <a href="mailto:tdiesler at redhat.com">Thomas Diesler</a>
+ */
+public final class WebMetaDataCreatingDeploymentAspect extends DeploymentAspect
+{
+
+   /** Web meta data creator. */
+   private WebMetaDataCreator webMetaDataCreator = new WebMetaDataCreator();
+
+   /**
+    * Constructor.
+    */
+   public WebMetaDataCreatingDeploymentAspect()
+   {
+      super();
+   }
+
+   /**
+    * Creates web meta data for EJB deployments.
+    *
+    * @param dep webservice deployment
+    */
+   @Override
+   public void start(final Deployment dep)
+   {
+      final boolean isEjbDeployment = WSHelper.isEjbDeployment(dep);
+
+      if (isEjbDeployment)
+      {
+         this.log.debug("Creating web meta data for EJB webservice deployment: " + dep.getSimpleName());
+         this.webMetaDataCreator.create(dep);
+      }
+   }
+
+}

Added: branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/tomcat/WebMetaDataCreator.java
===================================================================
--- branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/tomcat/WebMetaDataCreator.java	                        (rev 0)
+++ branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/tomcat/WebMetaDataCreator.java	2009-08-18 11:43:39 UTC (rev 92520)
@@ -0,0 +1,366 @@
+/*
+ * 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.List;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.javaee.spec.SecurityRolesMetaData;
+import org.jboss.metadata.web.jboss.JBossServletsMetaData;
+import org.jboss.metadata.web.jboss.JBossWebMetaData;
+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.WebResourceCollectionsMetaData;
+import org.jboss.wsf.common.integration.WSHelper;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.deployment.Endpoint;
+
+/**
+ * Creator of web app meta data for EJB endpoints.
+ *
+ * @author <a href="mailto:ropalka at redhat.com">Richard Opalka</a>
+ * @author <a href="mailto:tdiesler at redhat.com">Thomas Diesler</a>
+ */
+final class WebMetaDataCreator
+{
+
+   /** Our Realm. */
+   private static final String EJB_WEBSERVICE_REALM = "EJBWebServiceEndpointServlet Realm";
+
+   /** EJB 21 security meta data builder. */
+   private final SecurityMetaDataAccessorEJB ejb21SecurityAccessor = new SecurityMetaDataAccessorEJB21();
+
+   /** EJB 3 security meta data builder. */
+   private final SecurityMetaDataAccessorEJB ejb3SecurityAccessor = new SecurityMetaDataAccessorEJB3();
+
+   /** Logger. */
+   private final Logger log = Logger.getLogger(WebMetaDataCreator.class);
+
+   /**
+    * Constructor.
+    */
+   WebMetaDataCreator()
+   {
+      super();
+   }
+
+   /**
+    * Creates web meta data for EJB deployments.
+    *
+    * @param dep webservice deployment
+    */
+   void create(final Deployment dep)
+   {
+      final DeploymentUnit unit = WSHelper.getRequiredAttachment(dep, DeploymentUnit.class);
+      final JBossWebMetaData jbossWebMD = new JBossWebMetaData();
+
+      this.createWebAppDescriptor(dep, jbossWebMD);
+      this.createJBossWebAppDescriptor(dep, jbossWebMD);
+
+      dep.addAttachment(JBossWebMetaData.class, jbossWebMD);
+      unit.addAttachment(JBossWebMetaData.class, jbossWebMD);
+   }
+
+   /**
+    * Creates web.xml descriptor meta data.
+    *
+    * @param dep webservice deployment
+    * @param jbossWebMD jboss web meta data
+    */
+   private void createWebAppDescriptor(final Deployment dep, final JBossWebMetaData jbossWebMD)
+   {
+      this.log.debug("Creating web descriptor");
+      this.createServlets(dep, jbossWebMD);
+      this.createServletMappings(dep, jbossWebMD);
+      this.createSecurityConstraints(dep, jbossWebMD);
+      this.createLoginConfig(dep, jbossWebMD);
+      this.createSecurityRoles(dep, jbossWebMD);
+   }
+
+   /**
+    * Creates jboss-web.xml descriptor meta data.
+    *
+    * <pre>
+    * &lt;jboss-web&gt;
+    *   &lt;security-domain&gt;java:/jaas/custom-security-domain&lt;/security-domain&gt;
+    *   &lt;context-root&gt;/custom-context-root&lt;/context-root&gt;
+    *   &lt;virtual-host&gt;host1&lt;/virtual-host&gt;
+    *   ...
+    *   &lt;virtual-host&gt;hostN&lt;/virtual-host&gt;
+    * &lt;/jboss-web&gt;
+    * </pre>
+    *
+    * @param dep webservice deployment
+    * @param jbossWebMD jboss web meta data
+    */
+   private void createJBossWebAppDescriptor(final Deployment dep, final JBossWebMetaData jbossWebMD)
+   {
+      this.log.debug("Creating jboss web descriptor");
+      final SecurityMetaDataAccessorEJB ejbMDAccessor = this.getEjbSecurityMetaDataAccessor(dep);
+
+      // Set security domain
+      final String securityDomain = ejbMDAccessor.getSecurityDomain(dep);
+      final boolean hasSecurityDomain = securityDomain != null;
+
+      if (hasSecurityDomain)
+      {
+         this.log.debug("Setting security domain: " + securityDomain);
+         jbossWebMD.setSecurityDomain(securityDomain);
+      }
+
+      // Set virtual hosts
+      final List<String> virtualHosts = dep.getService().getVirtualHosts();
+      this.log.debug("Setting virtual hosts: " + virtualHosts);
+      jbossWebMD.setVirtualHosts(virtualHosts);
+   }
+
+   /**
+    * Creates servlets part of web.xml descriptor.
+    *
+    * <pre>
+    * &lt;servlet&gt;
+    *   &lt;servlet-name&gt;EJBEndpointShortName&lt;/servlet-name&gt;
+    *   &lt;servlet-class&gt;EJBEndpointTargetBeanName&lt;/servlet-class&gt;
+    * &lt;/servlet&gt;
+    * </pre>
+    *
+    * @param dep webservice deployment
+    * @param jbossWebMD jboss web meta data
+    */
+   private void createServlets(final Deployment dep, final JBossWebMetaData jbossWebMD)
+   {
+      this.log.debug("Creating servlets");
+      final JBossServletsMetaData servlets = WebMetaDataHelper.getServlets(jbossWebMD);
+
+      for (final Endpoint endpoint : dep.getService().getEndpoints())
+      {
+         final String endpointName = endpoint.getShortName();
+         final String endpointClassName = endpoint.getTargetBeanName();
+
+         this.log.debug("Servlet name: " + endpointName + ", servlet class: " + endpointClassName);
+         WebMetaDataHelper.newServlet(endpointName, endpointClassName, servlets);
+      }
+   }
+
+   /**
+    * Creates servlet-mapping part of web.xml descriptor.
+    *
+    * <pre>
+    * &lt;servlet-mapping&gt;
+    *   &lt;servlet-name&gt;EJBEndpointShortName&lt;/servlet-name&gt;
+    *   &lt;url-pattern&gt;EJBEndpointURLPattern&lt;/url-pattern&gt;
+    * &lt;/servlet-mapping&gt;
+    * </pre>
+    *
+    * @param dep webservice deployment
+    * @param jbossWebMD jboss web meta data
+    */
+   private void createServletMappings(final Deployment dep, final JBossWebMetaData jbossWebMD)
+   {
+      this.log.debug("Creating servlet mappings");
+      final List<ServletMappingMetaData> servletMappings = WebMetaDataHelper.getServletMappings(jbossWebMD);
+
+      for (final Endpoint ep : dep.getService().getEndpoints())
+      {
+         final String endpointName = ep.getShortName();
+         final List<String> urlPatterns = WebMetaDataHelper.getUrlPatterns(ep.getURLPattern());
+
+         this.log.debug("Servlet name: " + endpointName + ", URL patterns: " + urlPatterns);
+         WebMetaDataHelper.newServletMapping(endpointName, urlPatterns, servletMappings);
+      }
+   }
+
+   /**
+    * Creates security constraints part of web.xml descriptor.
+    *
+    * <pre>
+    * &lt;security-constraint&gt;
+    *   &lt;web-resource-collection&gt;
+    *     &lt;web-resource-name&gt;EJBEndpointShortName&lt;/web-resource-name&gt;
+    *     &lt;url-pattern&gt;EJBEndpointURLPattern&lt;/url-pattern&gt;
+    *     &lt;http-method&gt;GET&lt;/http-method&gt;
+    *     &lt;http-method&gt;POST&lt;/http-method&gt;
+    *   &lt;/web-resource-collection&gt;
+    *   &lt;auth-constraint&gt;
+    *     &lt;role-name&gt;*&lt;/role-name&gt;
+    *   &lt;/auth-constraint&gt;
+    *   &lt;user-data-constraint&gt;
+    *     &lt;transport-guarantee&gt;EjbTransportGuarantee&lt;/transport-guarantee&gt;
+    *   &lt;/user-data-constraint&gt;
+    * &lt;/security-constraint&gt;
+    * </pre>
+    *
+    * @param dep webservice deployemnt
+    * @param jbossWebMD jboss web meta data
+    */
+   private void createSecurityConstraints(final Deployment dep, final JBossWebMetaData jbossWebMD)
+   {
+      this.log.debug("Creating security constraints");
+      final SecurityMetaDataAccessorEJB ejbMDAccessor = this.getEjbSecurityMetaDataAccessor(dep);
+
+      for (final Endpoint ejbEndpoint : dep.getService().getEndpoints())
+      {
+         final boolean secureWsdlAccess = ejbMDAccessor.isSecureWsdlAccess(ejbEndpoint);
+         final String transportGuarantee = ejbMDAccessor.getTransportGuarantee(ejbEndpoint);
+         final boolean hasTransportGuarantee = transportGuarantee != null;
+         final String authMethod = ejbMDAccessor.getAuthMethod(ejbEndpoint);
+         final boolean hasAuthMethod = authMethod != null;
+
+         if (hasAuthMethod || hasTransportGuarantee)
+         {
+            final List<SecurityConstraintMetaData> securityConstraints = WebMetaDataHelper
+                  .getSecurityConstraints(jbossWebMD);
+
+            // security-constraint
+            final SecurityConstraintMetaData securityConstraint = WebMetaDataHelper
+                  .newSecurityConstraint(securityConstraints);
+
+            // web-resource-collection
+            final WebResourceCollectionsMetaData webResourceCollections = WebMetaDataHelper
+                  .getWebResourceCollections(securityConstraint);
+            final String endpointName = ejbEndpoint.getShortName();
+            final String urlPattern = ejbEndpoint.getURLPattern();
+            this.log.debug("Creating web resource collection for endpoint: " + endpointName + ", URL pattern: "
+                  + urlPattern);
+            WebMetaDataHelper.newWebResourceCollection(endpointName, urlPattern, secureWsdlAccess,
+                  webResourceCollections);
+
+            // auth-constraint
+            if (hasAuthMethod)
+            {
+               this.log.debug("Creating auth constraint for endpoint: " + endpointName);
+               WebMetaDataHelper.newAuthConstraint(WebMetaDataHelper.getAllRoles(), securityConstraint);
+            }
+
+            // user-data-constraint
+            if (hasTransportGuarantee)
+            {
+               this.log.debug("Creating new user data constraint for endpoint: " + endpointName
+                     + ", transport guarantee: " + transportGuarantee);
+               WebMetaDataHelper.newUserDataConstraint(transportGuarantee, securityConstraint);
+            }
+         }
+      }
+   }
+
+   /**
+    * Creates login-config part of web.xml descriptor.
+    * 
+    * <pre>
+    * &lt;login-config&gt;
+    *   &lt;auth-method&gt;EjbDeploymentAuthMethod&lt;/auth-method&gt;
+    *   &lt;realm-name&gt;EJBWebServiceEndpointServlet Realm&lt;/realm-name&gt;
+    * &lt;/login-config&gt;
+    * </pre>
+    *
+    * @param dep webservice deployment
+    * @param jbossWebMD jboss web meta data
+    */
+   private void createLoginConfig(final Deployment dep, final JBossWebMetaData jbossWebMD)
+   {
+      final String authMethod = this.getAuthMethod(dep);
+      final boolean hasAuthMethod = authMethod != null;
+
+      if (hasAuthMethod)
+      {
+         this.log.debug("Creating new login config: " + WebMetaDataCreator.EJB_WEBSERVICE_REALM + ", auth method: "
+               + authMethod);
+         final LoginConfigMetaData loginConfig = WebMetaDataHelper.getLoginConfig(jbossWebMD);
+         loginConfig.setRealmName(WebMetaDataCreator.EJB_WEBSERVICE_REALM);
+         loginConfig.setAuthMethod(authMethod);
+      }
+   }
+
+   /**
+    * Creates security roles part of web.xml descriptor.
+    *
+    * <pre>
+    * &lt;security-role&gt;
+    *   &lt;role-name&gt;role1&lt;/role-name&gt;
+    *   ...
+    *   &lt;role-name&gt;roleN&lt;/role-name&gt;
+    * &lt;/security-role&gt;
+    * </pre>
+    *
+    * @param dep webservice deployment
+    * @param jbossWebMD jboss web meta data
+    */
+   private void createSecurityRoles(final Deployment dep, final JBossWebMetaData jbossWebMD)
+   {
+      final String authMethod = this.getAuthMethod(dep);
+      final boolean hasAuthMethod = authMethod != null;
+
+      if (hasAuthMethod)
+      {
+         final SecurityMetaDataAccessorEJB ejbMDAccessor = this.getEjbSecurityMetaDataAccessor(dep);
+         final SecurityRolesMetaData securityRolesMD = ejbMDAccessor.getSecurityRoles(dep);
+         final boolean hasSecurityRolesMD = securityRolesMD != null;
+
+         if (hasSecurityRolesMD)
+         {
+            this.log.debug("Setting security roles: " + securityRolesMD);
+            jbossWebMD.setSecurityRoles(securityRolesMD);
+         }
+      }
+   }
+
+   /**
+    * Returns deployment authentication method.
+    *
+    * @param dep webservice deployment
+    * @return deployment authentication method
+    */
+   private String getAuthMethod(final Deployment dep)
+   {
+      final SecurityMetaDataAccessorEJB ejbMDAccessor = this.getEjbSecurityMetaDataAccessor(dep);
+
+      for (final Endpoint ejbEndpoint : dep.getService().getEndpoints())
+      {
+         final String beanAuthMethod = ejbMDAccessor.getAuthMethod(ejbEndpoint);
+         final boolean hasBeanAuthMethod = beanAuthMethod != null;
+
+         if (hasBeanAuthMethod)
+         {
+            // First found auth-method defines war login-config/auth-method
+            return beanAuthMethod;
+         }
+      }
+
+      return null;
+   }
+
+   /**
+    * Returns security builder associated with EJB deployment.
+    *
+    * @param dep webservice EJB deployment
+    * @return security builder for EJB deployment
+    */
+   private SecurityMetaDataAccessorEJB getEjbSecurityMetaDataAccessor(final Deployment dep)
+   {
+      final boolean isJaxws = WSHelper.isJaxwsDeployment(dep);
+
+      return isJaxws ? this.ejb3SecurityAccessor : this.ejb21SecurityAccessor;
+   }
+
+}

Added: branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/tomcat/WebMetaDataHelper.java
===================================================================
--- branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/tomcat/WebMetaDataHelper.java	                        (rev 0)
+++ branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/tomcat/WebMetaDataHelper.java	2009-08-18 11:43:39 UTC (rev 92520)
@@ -0,0 +1,424 @@
+/*
+ * 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.Collections;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.jboss.metadata.javaee.spec.ParamValueMetaData;
+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.ServletMetaData;
+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;
+
+/**
+ * Utility class that simplifies work with JBossWebMetaData object structure.
+ *
+ * @author <a href="mailto:ropalka at redhat.com">Richard Opalka</a>
+ * @author <a href="mailto:tdiesler at redhat.com">Thomas Diesler</a>
+ */
+final class WebMetaDataHelper
+{
+
+   /** Star utility string. */
+   private static final String STAR_STRING = "*";
+
+   /** GET http method utility string. */
+   private static final String GET_STRING = "GET";
+
+   /** POST http method utility string. */
+   private static final String POST_STRING = "POST";
+
+   /** GET and POST methods utility list. */
+   private static List<String> getAndPostMethods;
+
+   /** POST method utility list. */
+   private static List<String> onlyPostMethod;
+
+   /** All roles utility list. */
+   private static List<String> allRoles;
+
+   static
+   {
+      final List<String> getAndPostList = new LinkedList<String>();
+      getAndPostList.add(WebMetaDataHelper.GET_STRING);
+      getAndPostList.add(WebMetaDataHelper.POST_STRING);
+      WebMetaDataHelper.getAndPostMethods = Collections.unmodifiableList(getAndPostList);
+
+      final List<String> onlyPostList = new LinkedList<String>();
+      onlyPostList.add(WebMetaDataHelper.POST_STRING);
+      WebMetaDataHelper.onlyPostMethod = Collections.unmodifiableList(onlyPostList);
+
+      final List<String> roleNamesList = new LinkedList<String>();
+      roleNamesList.add(WebMetaDataHelper.STAR_STRING);
+      WebMetaDataHelper.allRoles = Collections.unmodifiableList(roleNamesList);
+   }
+
+   /**
+    * Constructor.
+    */
+   private WebMetaDataHelper()
+   {
+      super();
+   }
+
+   /**
+    * Creates URL pattern list from passed string.
+    *
+    * @param urlPattern URL pattern
+    * @return list wrapping passed parameter
+    */
+   static List<String> getUrlPatterns(final String urlPattern)
+   {
+      final List<String> linkedList = new LinkedList<String>();
+
+      linkedList.add(urlPattern);
+
+      return linkedList;
+   }
+
+   /**
+    * If WSDL access is secured, it returns both POST and GET methods, otherwise only POST method.
+    *
+    * @param secureWsdlAccess whether WSDL is secured
+    * @return web access methods
+    */
+   static List<String> getHttpMethods(final boolean secureWsdlAccess)
+   {
+      return secureWsdlAccess ? WebMetaDataHelper.getAndPostMethods : WebMetaDataHelper.onlyPostMethod;
+   }
+
+   /**
+    * Returns all role list.
+    *
+    * @return all role list
+    */
+   static List<String> getAllRoles()
+   {
+      return WebMetaDataHelper.allRoles;
+   }
+
+   /**
+    * Gests servlets meta data from jboss web meta data.
+    * If not found it creates new servlets meta data
+    * and associates them with jboss web meta data.
+    *
+    * @param jbossWebMD jboss web meta data
+    * @return servlets meta data
+    */
+   static JBossServletsMetaData getServlets(final JBossWebMetaData jbossWebMD)
+   {
+      JBossServletsMetaData servletsMD = jbossWebMD.getServlets();
+
+      if (servletsMD == null)
+      {
+         servletsMD = new JBossServletsMetaData();
+         jbossWebMD.setServlets(servletsMD);
+      }
+
+      return servletsMD;
+   }
+
+   /**
+    * Gests servlet mappings meta data from jboss web meta data.
+    * If not found it creates new servlet mappings meta data
+    * and associates them with jboss web meta data.
+    *
+    * @param jbossWebMD jboss web meta data
+    * @return servlet mappings meta data
+    */
+   static List<ServletMappingMetaData> getServletMappings(final JBossWebMetaData jbossWebMD)
+   {
+      List<ServletMappingMetaData> servletMappingsMD = jbossWebMD.getServletMappings();
+
+      if (servletMappingsMD == null)
+      {
+         servletMappingsMD = new LinkedList<ServletMappingMetaData>();
+         jbossWebMD.setServletMappings(servletMappingsMD);
+      }
+
+      return servletMappingsMD;
+   }
+
+   /**
+    * Gests security constraints meta data from jboss web meta data.
+    * If not found it creates new security constraints meta data
+    * and associates them with jboss web meta data.
+    *
+    * @param jbossWebMD jboss web meta data
+    * @return security constraints meta data
+    */
+   static List<SecurityConstraintMetaData> getSecurityConstraints(final JBossWebMetaData jbossWebMD)
+   {
+      List<SecurityConstraintMetaData> securityConstraintsMD = jbossWebMD.getSecurityContraints();
+
+      if (securityConstraintsMD == null)
+      {
+         securityConstraintsMD = new LinkedList<SecurityConstraintMetaData>();
+         jbossWebMD.setSecurityContraints(securityConstraintsMD);
+      }
+
+      return securityConstraintsMD;
+   }
+
+   /**
+    * Gests login config meta data from jboss web meta data.
+    * If not found it creates new login config meta data
+    * and associates them with jboss web meta data.
+    *
+    * @param jbossWebMD jboss web meta data
+    * @return login config meta data
+    */
+   static LoginConfigMetaData getLoginConfig(final JBossWebMetaData jbossWebMD)
+   {
+      LoginConfigMetaData loginConfigMD = jbossWebMD.getLoginConfig();
+
+      if (loginConfigMD == null)
+      {
+         loginConfigMD = new LoginConfigMetaData();
+         jbossWebMD.setLoginConfig(loginConfigMD);
+      }
+
+      return loginConfigMD;
+   }
+
+   /**
+    * Gests context parameters meta data from jboss web meta data.
+    * If not found it creates new context parameters meta data
+    * and associates them with jboss web meta data.
+    *
+    * @param jbossWebMD jboss web meta data
+    * @return context parameters meta data
+    */
+   static List<ParamValueMetaData> getContextParams(final JBossWebMetaData jbossWebMD)
+   {
+      List<ParamValueMetaData> contextParamsMD = jbossWebMD.getContextParams();
+
+      if (contextParamsMD == null)
+      {
+         contextParamsMD = new LinkedList<ParamValueMetaData>();
+         jbossWebMD.setContextParams(contextParamsMD);
+      }
+
+      return contextParamsMD;
+   }
+
+   /**
+    * Gests web resource collections meta data from security constraint meta data.
+    * If not found it creates new web resource collections meta data
+    * and associates them with security constraint meta data.
+    *
+    * @param securityConstraintMD security constraint meta data
+    * @return web resource collections meta data
+    */
+   static WebResourceCollectionsMetaData getWebResourceCollections(final SecurityConstraintMetaData securityConstraintMD)
+   {
+      WebResourceCollectionsMetaData webResourceCollectionsMD = securityConstraintMD.getResourceCollections();
+
+      if (webResourceCollectionsMD == null)
+      {
+         webResourceCollectionsMD = new WebResourceCollectionsMetaData();
+         securityConstraintMD.setResourceCollections(webResourceCollectionsMD);
+      }
+
+      return webResourceCollectionsMD;
+   }
+
+   /**
+    * Gests init parameters meta data from servlet meta data.
+    * If not found it creates new init parameters meta data
+    * and associates them with servlet meta data.
+    *
+    * @param servletMD servlet meta data
+    * @return init parameters meta data
+    */
+   static List<ParamValueMetaData> getServletInitParams(final ServletMetaData servletMD)
+   {
+      List<ParamValueMetaData> initParamsMD = servletMD.getInitParam();
+
+      if (initParamsMD == null)
+      {
+         initParamsMD = new LinkedList<ParamValueMetaData>();
+         servletMD.setInitParam(initParamsMD);
+      }
+
+      return initParamsMD;
+   }
+
+   /**
+    * Creates new security constraint meta data and associates them with security constraints meta data.
+    *
+    * @param securityConstraintsMD security constraints meta data
+    * @return new security constraing meta data
+    */
+   static SecurityConstraintMetaData newSecurityConstraint(final List<SecurityConstraintMetaData> securityConstraintsMD)
+   {
+      final SecurityConstraintMetaData securityConstraintMD = new SecurityConstraintMetaData();
+
+      securityConstraintsMD.add(securityConstraintMD);
+
+      return securityConstraintMD;
+   }
+
+   /**
+    * Creates new web resource collection meta data and associates them with web resource collections meta data.
+    *
+    * @param servletName servlet name
+    * @param urlPattern URL pattern
+    * @param securedWsdl whether WSDL access is secured
+    * @param webResourceCollectionsMD web resource collections meta data
+    * @return new web resource collection meta data
+    */
+   static WebResourceCollectionMetaData newWebResourceCollection(final String servletName, final String urlPattern,
+         final boolean securedWsdl, final WebResourceCollectionsMetaData webResourceCollectionsMD)
+   {
+      final WebResourceCollectionMetaData webResourceCollectionMD = new WebResourceCollectionMetaData();
+
+      webResourceCollectionMD.setWebResourceName(servletName);
+      webResourceCollectionMD.setUrlPatterns(WebMetaDataHelper.getUrlPatterns(urlPattern));
+      webResourceCollectionMD.setHttpMethods(WebMetaDataHelper.getHttpMethods(securedWsdl));
+      webResourceCollectionsMD.add(webResourceCollectionMD);
+
+      return webResourceCollectionMD;
+   }
+
+   /**
+    * Creates new servlet meta data and associates them with servlets meta data.
+    *
+    * @param servletName servlet name
+    * @param servletClass servlet class name
+    * @param servletsMD servlets meta data
+    * @return new servlet meta data
+    */
+   static JBossServletMetaData newServlet(final String servletName, final String servletClass,
+         final JBossServletsMetaData servletsMD)
+   {
+      final JBossServletMetaData servletMD = new JBossServletMetaData();
+
+      servletMD.setServletName(servletName);
+      servletMD.setServletClass(servletClass);
+      servletsMD.add(servletMD);
+
+      return servletMD;
+   }
+
+   /**
+    * Creates new servlet mapping meta data and associates them with servlet mappings meta data.
+    *
+    * @param servletName servlet name
+    * @param urlPatterns URL patterns
+    * @param servletMappingsMD servlet mapping meta data
+    * @return new servlet mapping meta data
+    */
+   static ServletMappingMetaData newServletMapping(final String servletName, final List<String> urlPatterns,
+         final List<ServletMappingMetaData> servletMappingsMD)
+   {
+      final ServletMappingMetaData servletMappingMD = new ServletMappingMetaData();
+
+      servletMappingMD.setServletName(servletName);
+      servletMappingMD.setUrlPatterns(urlPatterns);
+      servletMappingsMD.add(servletMappingMD);
+
+      return servletMappingMD;
+   }
+
+   /**
+    * Creates new authentication constraint and associates it with security constraint meta data.
+    *
+    * @param roleNames roles
+    * @param securityConstraintMD security constraint meta data
+    * @return new authentication constraint meta data
+    */
+   static AuthConstraintMetaData newAuthConstraint(final List<String> roleNames,
+         final SecurityConstraintMetaData securityConstraintMD)
+   {
+      final AuthConstraintMetaData authConstraintMD = new AuthConstraintMetaData();
+
+      authConstraintMD.setRoleNames(roleNames);
+      securityConstraintMD.setAuthConstraint(authConstraintMD);
+
+      return authConstraintMD;
+   }
+
+   /**
+    * Creates new user constraint meta data and associates it with security constraint meta data.
+    *
+    * @param transportGuarantee transport guarantee value
+    * @param securityConstraintMD security constraint meta data
+    * @return new user data constraint meta data
+    */
+   static UserDataConstraintMetaData newUserDataConstraint(final String transportGuarantee,
+         final SecurityConstraintMetaData securityConstraintMD)
+   {
+      final UserDataConstraintMetaData userDataConstraintMD = new UserDataConstraintMetaData();
+      final TransportGuaranteeType transportGuaranteeValue = TransportGuaranteeType.valueOf(transportGuarantee);
+
+      userDataConstraintMD.setTransportGuarantee(transportGuaranteeValue);
+      securityConstraintMD.setUserDataConstraint(userDataConstraintMD);
+
+      return userDataConstraintMD;
+   }
+
+   /**
+    * Creates new parameter meta data and associates it with parameters meta data.
+    *
+    * @param key parameter key
+    * @param value parameter value
+    * @param paramsMD parameters meta data
+    * @return new parameter meta data
+    */
+   static ParamValueMetaData newParamValue(final String key, final String value, final List<ParamValueMetaData> paramsMD)
+   {
+      final ParamValueMetaData paramValueMD = WebMetaDataHelper.newParamValue(key, value);
+
+      paramsMD.add(paramValueMD);
+
+      return paramValueMD;
+   }
+
+   /**
+    * Creates new parameter with specified key and value.
+    *
+    * @param key the key
+    * @param value the value
+    * @return new parameter
+    */
+   private static ParamValueMetaData newParamValue(final String key, final String value)
+   {
+      final ParamValueMetaData paramMD = new ParamValueMetaData();
+
+      paramMD.setParamName(key);
+      paramMD.setParamValue(value);
+
+      return paramMD;
+   }
+
+}

Modified: branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/tomcat/WebMetaDataModifier.java
===================================================================
--- branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/tomcat/WebMetaDataModifier.java	2009-08-18 11:19:53 UTC (rev 92519)
+++ branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/tomcat/WebMetaDataModifier.java	2009-08-18 11:43:39 UTC (rev 92520)
@@ -21,13 +21,11 @@
  */
 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.logging.Logger;
 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;
@@ -37,163 +35,129 @@
 import org.jboss.wsf.spi.deployment.Endpoint;
 
 /**
- * The modifier of jboss web meta data. 
+ * 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>
+ * @author <a href="mailto:tdiesler at redhat.com">Thomas Diesler</a>
  */
-public final class WebMetaDataModifier
+final class WebMetaDataModifier
 {
 
+   /** Logger. */
+   private final Logger log = Logger.getLogger(WebMetaDataModifier.class);
+
    /**
     * Constructor.
     */
-   public WebMetaDataModifier()
+   WebMetaDataModifier()
    {
       super();
    }
 
    /**
     * Modifies web meta data to configure webservice stack transport and properties.
-    * 
+    *
     * @param dep webservice deployment
     */
-   public void modify( final Deployment dep )
+   void modify(final Deployment dep)
    {
-      final JBossWebMetaData jbossWebMD = WSHelper.getRequiredAttachment( dep, JBossWebMetaData.class );
+      final JBossWebMetaData jbossWebMD = WSHelper.getRequiredAttachment(dep, JBossWebMetaData.class);
 
-      this.propagateContextProps( dep, jbossWebMD );
-      this.configureEndpoints( dep, jbossWebMD );
+      this.propagateContextProps(dep, jbossWebMD);
+      this.configureEndpoints(dep, jbossWebMD);
+      this.modifyContextRoot(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 )
+   @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 Map<String, String> stackContextParams = (Map<String, String>) dep
+            .getProperty(WSConstants.STACK_CONTEXT_PARAMS);
+
+      if (stackContextParams != null)
       {
-         final List< ParamValueMetaData > contextParams = this.getContextParams( jbossWebMD );
+         this.log.debug("Creating context parameters");
+         final List<ParamValueMetaData> contextParams = WebMetaDataHelper.getContextParams(jbossWebMD);
 
-         for ( Map.Entry< String, String > entry : stackContextParams.entrySet() )
+         for (Map.Entry<String, String> entry : stackContextParams.entrySet())
          {
-            final ParamValueMetaData newParam = this.newParameter( entry.getKey(), entry.getValue() );
-            contextParams.add( newParam );
+            final String paramName = entry.getKey();
+            final String paramValue = entry.getValue();
+
+            this.log.debug("Setting context parameter name: " + paramName + " value: " + paramValue);
+            WebMetaDataHelper.newParamValue(paramName, paramValue, contextParams);
          }
       }
    }
 
    /**
     * 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 )
+   private void configureEndpoints(final Deployment dep, final JBossWebMetaData jbossWebMD)
    {
-      final Iterator< JBossServletMetaData > servlets = jbossWebMD.getServlets().iterator();
-      
-      while ( servlets.hasNext() )
+      final String transportClassName = this.getTransportClassName(dep);
+      final ClassLoader loader = dep.getInitialClassLoader();
+      this.log.debug("Modifying servlets");
+
+      for (final ServletMetaData servletMD : jbossWebMD.getServlets())
       {
-         final ServletMetaData servletMD = servlets.next();
-         final ClassLoader loader = dep.getInitialClassLoader();
-         final boolean isWebserviceEndpoint = ASHelper.getEndpointClass( servletMD, loader ) != null;
+         final boolean isWebserviceEndpoint = ASHelper.getEndpointClass(servletMD, loader) != null;
 
-         if ( isWebserviceEndpoint )
+         if (isWebserviceEndpoint)
          {
             // set transport servlet
-            servletMD.setServletClass( this.getTransportClassName( dep ) );
+            servletMD.setServletClass(transportClassName);
 
             // 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 );
+            this.log.debug("Setting transport class: " + transportClassName + " for servlet: " + endpointClassName);
+            final List<ParamValueMetaData> initParams = WebMetaDataHelper.getServletInitParams(servletMD);
+            WebMetaDataHelper.newParamValue(Endpoint.SEPID_DOMAIN_ENDPOINT, endpointClassName, initParams);
          }
       }
    }
-   
+
    /**
-    * Returns stack specific transport class name.
-    * 
+    * Modifies context root. 
+    *
     * @param dep webservice deployment
-    * @return stack specific transport class name
-    * @throws IllegalStateException if transport class name is not found in deployment properties map
+    * @param jbossWebMD web meta data
     */
-   private String getTransportClassName( final Deployment dep )
+   private void modifyContextRoot(final Deployment dep, final JBossWebMetaData jbossWebMD)
    {
-      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;
+      final String contextRoot = dep.getService().getContextRoot();
+      this.log.debug("Setting context root: " + contextRoot + " for deployment: " + dep.getSimpleName());
+      jbossWebMD.setContextRoot(contextRoot);
    }
-   
+
    /**
-    * Creates new parameter with specified key and value.
-    * 
-    * @param key the key
-    * @param value the value
-    * @return new parameter
+    * 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 ParamValueMetaData newParameter( final String key, final String value )
+   private String getTransportClassName(final Deployment dep)
    {
-      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();
+      final String transportClassName = (String) dep.getProperty(WSConstants.STACK_TRANSPORT_CLASS);
 
-      if ( initParams == null )
+      if (transportClassName == null)
       {
-         initParams = new ArrayList< ParamValueMetaData >();
-         servletMD.setInitParam( initParams );
+         throw new IllegalStateException("Cannot obtain deployment property: " + WSConstants.STACK_TRANSPORT_CLASS);
       }
-      
-      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;
+      return transportClassName;
    }
 
 }

Modified: branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/tomcat/WebMetaDataModifyingDeploymentAspect.java
===================================================================
--- branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/tomcat/WebMetaDataModifyingDeploymentAspect.java	2009-08-18 11:19:53 UTC (rev 92519)
+++ branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/tomcat/WebMetaDataModifyingDeploymentAspect.java	2009-08-18 11:43:39 UTC (rev 92520)
@@ -26,14 +26,15 @@
 
 /**
  * Modifies web meta data to configure webservice stack endpoints and properties.
- * 
+ *
  * @author <a href="mailto:ropalka at redhat.com">Richard Opalka</a>
+ * @author <a href="mailto:tdiesler at redhat.com">Thomas Diesler</a>
  */
 public final class WebMetaDataModifyingDeploymentAspect extends DeploymentAspect
 {
-   
+
    /** Web meta data modifier. */
-   private WebMetaDataModifier webMetaDataModifier;
+   private WebMetaDataModifier webMetaDataModifier = new WebMetaDataModifier();
 
    /**
     * Constructor.
@@ -44,23 +45,15 @@
    }
 
    /**
-    * 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 )
+   @Override
+   public void start(final Deployment dep)
    {
-      this.webMetaDataModifier.modify( dep );
+      this.log.debug("Modifying web meta data for webservice deployment: " + dep.getSimpleName());
+      this.webMetaDataModifier.modify(dep);
    }
-   
+
 }

Modified: branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/util/ASHelper.java
===================================================================
--- branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/util/ASHelper.java	2009-08-18 11:19:53 UTC (rev 92519)
+++ branches/Branch_5_x/webservices/src/main/org/jboss/webservices/integration/util/ASHelper.java	2009-08-18 11:43:39 UTC (rev 92520)
@@ -31,6 +31,8 @@
 
 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.web.jboss.JBossServletMetaData;
 import org.jboss.metadata.web.jboss.JBossWebMetaData;
 import org.jboss.metadata.web.spec.ServletMetaData;
@@ -46,8 +48,13 @@
 public final class ASHelper
 {
 
+   /** 
+    * EJB invocation property.
+    */
+   public static final String CONTAINER_NAME = "org.jboss.wsf.spi.invocation.ContainerName";
+
    /** Logger. */
-   private static final Logger LOG = Logger.getLogger( ASHelper.class );
+   private static final Logger LOGGER = Logger.getLogger(ASHelper.class);
 
    /**
     * Forbidden constructor.
@@ -63,9 +70,9 @@
     * @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 )
+   public static boolean isWebServiceDeployment(final DeploymentUnit unit)
    {
-      return ASHelper.getOptionalAttachment( unit, DeploymentType.class ) != null;
+      return ASHelper.getOptionalAttachment(unit, DeploymentType.class) != null;
    }
 
    /**
@@ -74,11 +81,11 @@
     * @param unit deployment unit
     * @return true if JAXRPC EJB deployment, false otherwise
     */
-   public static boolean isJaxrpcEjbDeployment( final DeploymentUnit unit )
+   public static boolean isJaxrpcEjbDeployment(final DeploymentUnit unit)
    {
-      final DeploymentType deploymentType = ASHelper.getOptionalAttachment( unit, DeploymentType.class );
+      final DeploymentType deploymentType = ASHelper.getOptionalAttachment(unit, DeploymentType.class);
 
-      return DeploymentType.JAXRPC_EJB21.equals( deploymentType );
+      return DeploymentType.JAXRPC_EJB21.equals(deploymentType);
    }
 
    /**
@@ -87,11 +94,11 @@
     * @param unit deployment unit
     * @return true if JAXRPC JSE deployment, false otherwise
     */
-   public static boolean isJaxrpcJseDeployment( final DeploymentUnit unit )
+   public static boolean isJaxrpcJseDeployment(final DeploymentUnit unit)
    {
-      final DeploymentType deploymentType = ASHelper.getOptionalAttachment( unit, DeploymentType.class );
+      final DeploymentType deploymentType = ASHelper.getOptionalAttachment(unit, DeploymentType.class);
 
-      return DeploymentType.JAXRPC_JSE.equals( deploymentType );
+      return DeploymentType.JAXRPC_JSE.equals(deploymentType);
    }
 
    /**
@@ -100,11 +107,11 @@
     * @param unit deployment unit
     * @return true if JAXWS EJB deployment, false otherwise
     */
-   public static boolean isJaxwsEjbDeployment( final DeploymentUnit unit )
+   public static boolean isJaxwsEjbDeployment(final DeploymentUnit unit)
    {
-      final DeploymentType deploymentType = ASHelper.getOptionalAttachment( unit, DeploymentType.class );
+      final DeploymentType deploymentType = ASHelper.getOptionalAttachment(unit, DeploymentType.class);
 
-      return DeploymentType.JAXWS_EJB3.equals( deploymentType );
+      return DeploymentType.JAXWS_EJB3.equals(deploymentType);
    }
 
    /**
@@ -113,11 +120,11 @@
     * @param unit deployment unit
     * @return true if JAXWS JSE deployment, false otherwise
     */
-   public static boolean isJaxwsJseDeployment( final DeploymentUnit unit )
+   public static boolean isJaxwsJseDeployment(final DeploymentUnit unit)
    {
-      final DeploymentType deploymentType = ASHelper.getOptionalAttachment( unit, DeploymentType.class );
+      final DeploymentType deploymentType = ASHelper.getOptionalAttachment(unit, DeploymentType.class);
 
-      return DeploymentType.JAXWS_JSE.equals( deploymentType );
+      return DeploymentType.JAXWS_JSE.equals(deploymentType);
    }
 
    /**
@@ -126,10 +133,10 @@
     * @param unit deployment unit
     * @return true if either JAXWS JSE or JAXRPC JSE deployment, false otherwise.
     */
-   public static boolean isJseDeployment( final DeploymentUnit unit )
+   public static boolean isJseDeployment(final DeploymentUnit unit)
    {
-      final boolean isJaxwsJse = ASHelper.isJaxwsJseDeployment( unit );
-      final boolean isJaxrpcJse = ASHelper.isJaxrpcJseDeployment( unit );
+      final boolean isJaxwsJse = ASHelper.isJaxwsJseDeployment(unit);
+      final boolean isJaxrpcJse = ASHelper.isJaxrpcJseDeployment(unit);
 
       return isJaxwsJse || isJaxrpcJse;
    }
@@ -140,10 +147,10 @@
     * @param unit deployment unit
     * @return true if either JAXWS EJB or JAXRPC EJB deployment, false otherwise
     */
-   public static boolean isEjbDeployment( final DeploymentUnit unit )
+   public static boolean isEjbDeployment(final DeploymentUnit unit)
    {
-      final boolean isJaxwsEjb = ASHelper.isJaxwsEjbDeployment( unit );
-      final boolean isJaxrpcEjb = ASHelper.isJaxrpcEjbDeployment( unit );
+      final boolean isJaxwsEjb = ASHelper.isJaxwsEjbDeployment(unit);
+      final boolean isJaxrpcEjb = ASHelper.isJaxrpcEjbDeployment(unit);
 
       return isJaxwsEjb || isJaxrpcEjb;
    }
@@ -154,10 +161,10 @@
     * @param unit deployment unit
     * @return true if either JAXWS EJB or JAXWS JSE deployment, false otherwise
     */
-   public static boolean isJaxwsDeployment( final DeploymentUnit unit )
+   public static boolean isJaxwsDeployment(final DeploymentUnit unit)
    {
-      final boolean isJaxwsEjb = ASHelper.isJaxwsEjbDeployment( unit );
-      final boolean isJaxwsJse = ASHelper.isJaxwsJseDeployment( unit );
+      final boolean isJaxwsEjb = ASHelper.isJaxwsEjbDeployment(unit);
+      final boolean isJaxwsJse = ASHelper.isJaxwsJseDeployment(unit);
 
       return isJaxwsEjb || isJaxwsJse;
    }
@@ -168,10 +175,10 @@
     * @param unit deployment unit
     * @return true if either JAXRPC EJB or JAXRPC JSE deployment, false otherwise
     */
-   public static boolean isJaxrpcDeployment( final DeploymentUnit unit )
+   public static boolean isJaxrpcDeployment(final DeploymentUnit unit)
    {
-      final boolean isJaxrpcEjb = ASHelper.isJaxrpcEjbDeployment( unit );
-      final boolean isJaxrpcJse = ASHelper.isJaxrpcJseDeployment( unit );
+      final boolean isJaxrpcEjb = ASHelper.isJaxrpcEjbDeployment(unit);
+      final boolean isJaxrpcJse = ASHelper.isJaxrpcJseDeployment(unit);
 
       return isJaxrpcEjb || isJaxrpcJse;
    }
@@ -182,9 +189,9 @@
     * @param unit deployment unit
     * @return list of JAXWS servlets meta data
     */
-   public static List< ServletMetaData > getJaxwsServlets( final DeploymentUnit unit )
+   public static List<ServletMetaData> getJaxwsServlets(final DeploymentUnit unit)
    {
-      return ASHelper.getWebServiceServlets( unit, true );
+      return ASHelper.getWebServiceServlets(unit, true);
    }
 
    /**
@@ -193,9 +200,9 @@
     * @param unit deployment unit
     * @return list of JAXRPC servlets meta data
     */
-   public static List< ServletMetaData > getJaxrpcServlets( final DeploymentUnit unit )
+   public static List<ServletMetaData> getJaxrpcServlets(final DeploymentUnit unit)
    {
-      return ASHelper.getWebServiceServlets( unit, false );
+      return ASHelper.getWebServiceServlets(unit, false);
    }
 
    /**
@@ -204,18 +211,18 @@
     * @param unit deployment unit
     * @return list of JAXWS EJBs meta data
     */
-   public static List< WebServiceDeclaration > getJaxwsEjbs( final DeploymentUnit unit )
+   public static List<WebServiceDeclaration> getJaxwsEjbs(final DeploymentUnit unit)
    {
-      final WebServiceDeployment wsDeployment = ASHelper.getRequiredAttachment( unit, WebServiceDeployment.class );
-      final List< WebServiceDeclaration > endpoints = new ArrayList< WebServiceDeclaration >();
+      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 Iterator<WebServiceDeclaration> ejbIterator = wsDeployment.getServiceEndpoints().iterator();
+      while (ejbIterator.hasNext())
       {
          final WebServiceDeclaration ejbContainer = ejbIterator.next();
-         if ( ASHelper.isWebServiceBean( ejbContainer ) )
+         if (ASHelper.isWebServiceBean(ejbContainer))
          {
-            endpoints.add( ejbContainer );
+            endpoints.add(ejbContainer);
          }
       }
 
@@ -228,10 +235,10 @@
     * @param ejbContainerAdapter EJB container adapter
     * @return true if EJB container is webservice endpoint, false otherwise
     */
-   public static boolean isWebServiceBean( final WebServiceDeclaration ejbContainerAdapter )
+   public static boolean isWebServiceBean(final WebServiceDeclaration ejbContainerAdapter)
    {
-      final boolean isWebService = ejbContainerAdapter.getAnnotation( WebService.class ) != null;
-      final boolean isWebServiceProvider = ejbContainerAdapter.getAnnotation( WebServiceProvider.class ) != null;
+      final boolean isWebService = ejbContainerAdapter.getAnnotation(WebService.class) != null;
+      final boolean isWebServiceProvider = ejbContainerAdapter.getAnnotation(WebServiceProvider.class) != null;
 
       return isWebService || isWebServiceProvider;
    }
@@ -242,7 +249,7 @@
     * @param servletMD servlet meta data
     * @return endpoint class name
     */
-   public static String getEndpointName( final ServletMetaData servletMD )
+   public static String getEndpointName(final ServletMetaData servletMD)
    {
       final String endpointClass = servletMD.getServletClass();
 
@@ -256,17 +263,17 @@
     * @param servletName servlet name
     * @return servlet meta data
     */
-   public static ServletMetaData getServletForName( final JBossWebMetaData jbossWebMD, final String servletName )
+   public static ServletMetaData getServletForName(final JBossWebMetaData jbossWebMD, final String servletName)
    {
-      for ( JBossServletMetaData servlet : jbossWebMD.getServlets() )
+      for (JBossServletMetaData servlet : jbossWebMD.getServlets())
       {
-         if ( servlet.getName().equals( servletName ) )
+         if (servlet.getName().equals(servletName))
          {
             return servlet;
          }
       }
 
-      throw new IllegalStateException( "Cannot find servlet for link: " + servletName );
+      throw new IllegalStateException("Cannot find servlet for link: " + servletName);
    }
 
    /**
@@ -276,26 +283,26 @@
     * @param loader class loader
     * @return webservice endpoint class or null
     */
-   public static Class< ? > getEndpointClass( final ServletMetaData servletMD, final ClassLoader loader )
+   public static Class<?> getEndpointClass(final ServletMetaData servletMD, final ClassLoader loader)
    {
-      final String endpointClassName = ASHelper.getEndpointName( servletMD );
-      final boolean notJSP = endpointClassName != null && endpointClassName.length() > 0; 
+      final String endpointClassName = ASHelper.getEndpointName(servletMD);
+      final boolean notJSP = endpointClassName != null && endpointClassName.length() > 0;
 
-      if ( notJSP )
+      if (notJSP)
       {
          try
          {
-            final Class< ? > endpointClass = loader.loadClass( endpointClassName );
-            final boolean notServlet = !Servlet.class.isAssignableFrom( endpointClass );
+            final Class<?> endpointClass = loader.loadClass(endpointClassName);
+            final boolean notServlet = !Servlet.class.isAssignableFrom(endpointClass);
 
-            if ( notServlet )
+            if (notServlet)
             {
                return endpointClass;
             }
          }
-         catch ( ClassNotFoundException cnfe )
+         catch (ClassNotFoundException cnfe)
          {
-            ASHelper.LOG.warn( "Cannot load servlet class: " + endpointClassName, cnfe );
+            ASHelper.LOGGER.warn("Cannot load servlet class: " + endpointClassName, cnfe);
          }
       }
 
@@ -311,18 +318,18 @@
     * @return required attachment 
     * @throws IllegalStateException if attachment value is null
     */
-   public static <A> A getRequiredAttachment( final DeploymentUnit unit, final Class< A > key )
+   public static <A> A getRequiredAttachment(final DeploymentUnit unit, final Class<A> key)
    {
-      final A value = unit.getAttachment( key );
-      if ( value == null )
+      final A value = unit.getAttachment(key);
+      if (value == null)
       {
-         ASHelper.LOG.error( "Cannot find attachment in deployment unit: " + key );
+         ASHelper.LOGGER.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.
     * 
@@ -331,11 +338,11 @@
     * @param key attachment key
     * @return optional attachment value or null 
     */
-   public static <A> A getOptionalAttachment( final DeploymentUnit unit, final Class< A > key )
+   public static <A> A getOptionalAttachment(final DeploymentUnit unit, final Class<A> key)
    {
-      return unit.getAttachment( key );
+      return unit.getAttachment(key);
    }
-   
+
    /**
     * Returns true if deployment unit have attachment value associated with the <b>key</b>.
     *  
@@ -343,40 +350,65 @@
     * @param key attachment key
     * @return true if contains attachment, false otherwise
     */
-   public static boolean hasAttachment( final DeploymentUnit unit, final Class< ? > key )
+   public static boolean hasAttachment(final DeploymentUnit unit, final Class<?> key)
    {
-      return ASHelper.getOptionalAttachment( unit, key ) != null;
+      return ASHelper.getOptionalAttachment(unit, key) != null;
    }
 
    /**
+    * Returns first webservice description meta data or null if not found.
+    *
+    * @param wsDescriptionsMD webservice descriptions
+    * @return webservice description
+    */
+   public static WebserviceDescriptionMetaData getWebserviceDescriptionMetaData(
+         final WebserviceDescriptionsMetaData wsDescriptionsMD)
+   {
+      if (wsDescriptionsMD != null)
+      {
+         if (wsDescriptionsMD.size() > 1)
+         {
+            ASHelper.LOGGER.warn("Multiple <webservice-description> elements not supported");
+         }
+
+         if (wsDescriptionsMD.size() > 0)
+         {
+            return wsDescriptionsMD.iterator().next();
+         }
+      }
+
+      return 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 )
+   private static List<ServletMetaData> getWebServiceServlets(final DeploymentUnit unit, final boolean jaxws)
    {
-      final JBossWebMetaData jbossWebMD = ASHelper.getRequiredAttachment( unit, JBossWebMetaData.class );
+      final JBossWebMetaData jbossWebMD = ASHelper.getRequiredAttachment(unit, JBossWebMetaData.class);
       final ClassLoader loader = unit.getClassLoader();
-      final List< ServletMetaData > endpoints = new ArrayList< ServletMetaData >();
+      final List<ServletMetaData> endpoints = new ArrayList<ServletMetaData>();
 
-      for ( ServletMetaData servletMD : jbossWebMD.getServlets() )
+      for (ServletMetaData servletMD : jbossWebMD.getServlets())
       {
-         final Class< ? > endpointClass = ASHelper.getEndpointClass( servletMD, loader );
+         final Class<?> endpointClass = ASHelper.getEndpointClass(servletMD, loader);
 
-         if ( endpointClass != null )
+         if (endpointClass != null)
          {
             // check webservice annotations
-            final boolean isWebService = endpointClass.isAnnotationPresent( WebService.class );
-            final boolean isWebServiceProvider = endpointClass.isAnnotationPresent( WebServiceProvider.class );
+            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 );
+            final boolean isJaxwsEndpoint = jaxws && (isWebService || isWebServiceProvider);
+            final boolean isJaxrpcEndpoint = !jaxws && (!isWebService && !isWebServiceProvider);
 
-            if ( isJaxwsEndpoint || isJaxrpcEndpoint )
+            if (isJaxwsEndpoint || isJaxrpcEndpoint)
             {
-               endpoints.add( servletMD );
+               endpoints.add(servletMD);
             }
          }
       }

Modified: branches/Branch_5_x/webservices/src/resources/jbossws-jboss.deployer/META-INF/stack-agnostic-jboss-beans.xml
===================================================================
--- branches/Branch_5_x/webservices/src/resources/jbossws-jboss.deployer/META-INF/stack-agnostic-jboss-beans.xml	2009-08-18 11:19:53 UTC (rev 92519)
+++ branches/Branch_5_x/webservices/src/resources/jbossws-jboss.deployer/META-INF/stack-agnostic-jboss-beans.xml	2009-08-18 11:43:39 UTC (rev 92520)
@@ -23,7 +23,7 @@
       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 set to 'jbossws.undefined.host', JBossWS uses requesters protocol host when rewriting the <soap:address>.
+      If 'webServiceHost' is set to 'jbossws.undefined.host', JBossWS uses requesters host when rewriting the <soap:address>
     -->
     <property name="webServiceHost">${jboss.bind.address}</property>
     <property name="modifySOAPAddress">true</property>
@@ -54,20 +54,16 @@
   </bean>
 
   <!-- WSDeploymentAspectDeployers factory -->
-  <bean name="WSDeployersFactory" class="org.jboss.webservices.integration.deployers.WSDeployersFactory">
+  <bean name="WSAspectizedDeployersFactory" class="org.jboss.webservices.integration.deployers.WSAspectizedDeployersFactory">
     <constructor>
       <parameter>
         <inject bean="Deployers"/>
       </parameter>
     </constructor>
-    <incallback method="newDeployer"/>
+    <incallback method="addDeployer"/>
+    <uncallback method="removeDeployer"/>
   </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>
@@ -138,15 +134,12 @@
   <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">
+  <bean name="WSWebMetaDataCreatingDeploymentAspect" class="org.jboss.webservices.integration.tomcat.WebMetaDataCreatingDeploymentAspect">
     <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>
 

Modified: branches/Branch_5_x/webservices/src/resources/jbossws-jboss.jar/META-INF/services/org.jboss.wsf.spi.invocation.SecurityAdaptorFactory
===================================================================
--- branches/Branch_5_x/webservices/src/resources/jbossws-jboss.jar/META-INF/services/org.jboss.wsf.spi.invocation.SecurityAdaptorFactory	2009-08-18 11:19:53 UTC (rev 92519)
+++ branches/Branch_5_x/webservices/src/resources/jbossws-jboss.jar/META-INF/services/org.jboss.wsf.spi.invocation.SecurityAdaptorFactory	2009-08-18 11:43:39 UTC (rev 92520)
@@ -1 +1 @@
-org.jboss.webservices.integration.invocation.SecurityAdapterFactoryImpl
\ No newline at end of file
+org.jboss.webservices.integration.security.SecurityAdapterFactoryImpl
\ No newline at end of file




More information about the jboss-cvs-commits mailing list