[jbossws-commits] JBossWS SVN: r10524 - container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/deployers.

jbossws-commits at lists.jboss.org jbossws-commits at lists.jboss.org
Wed Aug 12 08:51:46 EDT 2009


Author: richard.opalka at jboss.com
Date: 2009-08-12 08:51:45 -0400 (Wed, 12 Aug 2009)
New Revision: 10524

Added:
   container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/deployers/WSDeploymentBuilder.java
Removed:
   container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/deployers/WSVirtualFileFilter.java
Modified:
   container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/deployers/WSDeploymentDeployer.java
Log:
[JBWS-2320] refactoring + javadoc

Added: container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/deployers/WSDeploymentBuilder.java
===================================================================
--- container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/deployers/WSDeploymentBuilder.java	                        (rev 0)
+++ container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/deployers/WSDeploymentBuilder.java	2009-08-12 12:51:45 UTC (rev 10524)
@@ -0,0 +1,521 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.webservices.integration.deployers;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+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.virtual.VirtualFileFilterWithAttributes;
+import org.jboss.virtual.VisitorAttributes;
+import org.jboss.webservices.integration.util.ASHelper;
+import org.jboss.wsf.common.integration.WSConstants;
+import org.jboss.wsf.spi.SPIProvider;
+import org.jboss.wsf.spi.SPIProviderResolver;
+import org.jboss.wsf.spi.deployment.ArchiveDeployment;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.deployment.Deployment.DeploymentType;
+import org.jboss.wsf.spi.deployment.DeploymentModelFactory;
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
+import org.jboss.wsf.spi.deployment.WSFDeploymentException;
+import org.jboss.wsf.spi.deployment.integration.WebServiceDeclaration;
+import org.jboss.wsf.spi.deployment.integration.WebServiceDeployment;
+import org.jboss.wsf.spi.metadata.webservices.PortComponentMetaData;
+import org.jboss.wsf.spi.metadata.webservices.WebserviceDescriptionMetaData;
+import org.jboss.wsf.spi.metadata.webservices.WebservicesMetaData;
+
+/**
+ * JBossWS deployment model builder.
+ *
+ * @author <a href="mailto:ropalka at redhat.com">Richard Opalka</a>
+ */
+final class WSDeploymentBuilder
+{
+
+   /** Builder instance. */
+   private static final WSDeploymentBuilder SINGLETON = new WSDeploymentBuilder();
+
+   /** WSDL, XSD and XML files filter. */
+   private static final WSVirtualFileFilter WS_FILE_FILTER = new WSVirtualFileFilter();
+
+   /** Builders registry. */
+   private static Map<DeploymentType, DeploymentModelBuilder> builders;
+
+   static
+   {
+      WSDeploymentBuilder.builders = new HashMap<DeploymentType, DeploymentModelBuilder>();
+      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
+    */
+   static WSDeploymentBuilder getInstance()
+   {
+      return WSDeploymentBuilder.SINGLETON;
+   }
+
+   /**
+    * Builds JBossWS deployment model if web service deployment is detected.
+    * 
+    * @param unit deployment unit
+    */
+   void build(final DeploymentUnit unit)
+   {
+      final DeploymentType deploymentType = ASHelper.getOptionalAttachment(unit, DeploymentType.class);
+
+      if (deploymentType != null)
+      {
+         WSDeploymentBuilder.builders.get(deploymentType).newDeploymentModel(unit);
+      }
+   }
+
+   /**
+    * Deployment builder interface.
+    * 
+    * @author <a href="mailto:ropalka at redhat.com">Richard Opalka</a>
+    */
+   private static interface DeploymentModelBuilder
+   {
+
+      /**
+       * Creates Web Service deployment model and associates it with deployment.
+       * 
+       * @param unit deployment unit
+       */
+      void newDeploymentModel(DeploymentUnit unit);
+
+   }
+
+   /**
+    * Base class for all deployment model builders.
+    * 
+    * @author <a href="mailto:ropalka at redhat.com">Richard Opalka</a>
+    */
+   private abstract static class AbstractDeploymentModelBuilder implements WSDeploymentBuilder.DeploymentModelBuilder
+   {
+
+      /** Deployment model factory. */
+      private final DeploymentModelFactory deploymentModelFactory;
+
+      /**
+       * Constructor.
+       */
+      AbstractDeploymentModelBuilder()
+      {
+         super();
+
+         // deployment factory
+         final SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
+         this.deploymentModelFactory = spiProvider.getSPI(DeploymentModelFactory.class);
+      }
+
+      /**
+       * @see org.jboss.webservices.integration.deployers.WSDeploymentBuilder.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)
+      {
+         final ArchiveDeployment dep = this.newDeployment(unit.getSimpleName(), unit.getClassLoader());
+
+         if (unit instanceof VFSDeploymentUnit)
+         {
+            final VFSDeploymentUnit vfsUnit = (VFSDeploymentUnit)unit;
+            final List<VirtualFile> virtualFiles = vfsUnit.getMetaDataFiles(WSDeploymentBuilder.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();
+
+            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);
+      }
+
+   }
+
+   /**
+    * Creates new JAXWS JSE deployment.
+    * 
+    * @author <a href="mailto:ropalka at redhat.com">Richard Opalka</a>
+    */
+   private static final class JaxwsJseDeploymentModelBuilder extends WSDeploymentBuilder.AbstractDeploymentModelBuilder
+   {
+
+      /**
+       * Constructor.
+       */
+      private JaxwsJseDeploymentModelBuilder()
+      {
+         super();
+      }
+
+      /**
+       * Creates new JAXWS JSE deployment and registers it with deployment unit.
+       * 
+       * @param dep webservice deployment
+       * @param unit deployment unit
+       */
+      @Override
+      public void build(final Deployment dep, final DeploymentUnit 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.newEndpoint(servletClass, servletName, dep);
+         }
+      }
+
+   }
+
+   /**
+    * Creates new JAXRPC JSE deployment.
+    * 
+    * @author <a href="mailto:ropalka at redhat.com">Richard Opalka</a>
+    */
+   private static final class JaxrpcJseDeploymentModelBuilder extends WSDeploymentBuilder.AbstractDeploymentModelBuilder
+   {
+
+      /**
+       * Constructor.
+       */
+      private JaxrpcJseDeploymentModelBuilder()
+      {
+         super();
+      }
+
+      /**
+       * Creates new JAXRPC JSE deployment and registers it with deployment unit.
+       * 
+       * @param dep webservice deployment
+       * @param unit deployment unit
+       */
+      public 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);
+
+         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.newEndpoint(servletClass, servletName, dep);
+            }
+         }
+      }
+
+   }
+
+   /**
+    * Creates new JAXWS EJB3 deployment.
+    * 
+    * @author <a href="mailto:ropalka at redhat.com">Richard Opalka</a>
+    */
+   private static final class JaxwsEjbDeploymentModelBuilder extends WSDeploymentBuilder.AbstractDeploymentModelBuilder
+   {
+
+      /**
+       * Constructor.
+       */
+      private JaxwsEjbDeploymentModelBuilder()
+      {
+         super();
+      }
+
+      /**
+       * Creates new JAXWS EJB3 deployment and registers it with deployment unit.
+       * 
+       * @param dep webservice deployment
+       * @param unit deployment unit
+       */
+      public void build(final Deployment dep, final DeploymentUnit 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.newEndpoint(ejbClass, ejbName, dep);
+            ep.setProperty(WSConstants.CONTAINER_NAME, container.getContainerName());
+         }
+      }
+
+   }
+
+   /**
+    * Creates new JAXRPC EJB21 deployment.
+    * 
+    * @author <a href="mailto:ropalka at redhat.com">Richard Opalka</a>
+    */
+   private static final class JaxrpcEjbDeploymentModelBuilder extends WSDeploymentBuilder.AbstractDeploymentModelBuilder
+   {
+
+      /**
+       * Constructor.
+       */
+      private JaxrpcEjbDeploymentModelBuilder()
+      {
+         super();
+      }
+
+      /**
+       * Creates new JAXRPC EJB21 deployment and registers it with deployment unit.
+       * 
+       * @param dep webservice deployment
+       * @param unit deployment unit
+       */
+      public 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);
+
+         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.newEndpoint(ejbClass, ejbName, dep);
+            }
+         }
+      }
+
+   }
+
+   /**
+    * 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>
+    */
+   private static 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;
+      }
+
+   }
+
+}

Modified: container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/deployers/WSDeploymentDeployer.java
===================================================================
--- container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/deployers/WSDeploymentDeployer.java	2009-08-12 10:29:29 UTC (rev 10523)
+++ container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/deployers/WSDeploymentDeployer.java	2009-08-12 12:51:45 UTC (rev 10524)
@@ -21,39 +21,12 @@
  */
 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.util.ASHelper;
-import org.jboss.wsf.common.integration.WSConstants;
-import org.jboss.wsf.spi.SPIProvider;
-import org.jboss.wsf.spi.SPIProviderResolver;
-import org.jboss.wsf.spi.deployment.ArchiveDeployment;
 import org.jboss.wsf.spi.deployment.Deployment;
 import org.jboss.wsf.spi.deployment.Deployment.DeploymentType;
-import org.jboss.wsf.spi.deployment.DeploymentModelFactory;
-import org.jboss.wsf.spi.deployment.Endpoint;
-import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
-import org.jboss.wsf.spi.deployment.WSFDeploymentException;
-import org.jboss.wsf.spi.deployment.integration.WebServiceDeclaration;
-import org.jboss.wsf.spi.deployment.integration.WebServiceDeployment;
-import org.jboss.wsf.spi.metadata.webservices.PortComponentMetaData;
-import org.jboss.wsf.spi.metadata.webservices.WebserviceDescriptionMetaData;
-import org.jboss.wsf.spi.metadata.webservices.WebservicesMetaData;
 
 /**
  * This deployer initializes JBossWS deployment meta data. 
@@ -63,11 +36,6 @@
 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.
     */
@@ -82,250 +50,18 @@
       // outputs
       this.addOutput(JBossWebMetaData.class);
       this.addOutput(Deployment.class);
-
-      // deployment factory
-      final SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
-      this.deploymentModelFactory = spiProvider.getSPI(DeploymentModelFactory.class);
    }
 
    /**
     * Creates new Web Service deployment and registers it with deployment unit.
     * 
     * @param unit deployment unit
-    * @throws DeploymentException if error occurs
+    * @throws DeploymentException if any error occurs
     */
    @Override
    protected void internalDeploy(final DeploymentUnit unit) throws DeploymentException
    {
-      if (ASHelper.isJaxwsJseDeployment(unit))
-      {
-         this.newJaxwsJseDeployment(unit);
-      }
-      else if (ASHelper.isJaxwsEjbDeployment(unit))
-      {
-         this.newJaxwsEjbDeployment(unit);
-      }
-      else if (ASHelper.isJaxrpcJseDeployment(unit))
-      {
-         this.newJaxrpcJseDeployment(unit);
-      }
-      else if (ASHelper.isJaxrpcEjbDeployment(unit))
-      {
-         this.newJaxrpcEjbDeployment(unit);
-      }
+      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(WSConstants.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 = this.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 String parentDeploymentName = unit.getParent().getSimpleName();
-         final ClassLoader parentClassLoader = unit.getParent().getClassLoader();
-
-         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);
-   }
-
-   /**
-    * 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);
-   }
-
 }

Deleted: container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/deployers/WSVirtualFileFilter.java
===================================================================
--- container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/deployers/WSVirtualFileFilter.java	2009-08-12 10:29:29 UTC (rev 10523)
+++ container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/deployers/WSVirtualFileFilter.java	2009-08-12 12:51:45 UTC (rev 10524)
@@ -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="mailto: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;
-   }
-
-}



More information about the jbossws-commits mailing list