[jbossws-commits] JBossWS SVN: r10221 - in container/jboss50/branches/ropalka-jboss510/src/main: resources/jbossws-jboss50.deployer/META-INF and 1 other directory.
jbossws-commits at lists.jboss.org
jbossws-commits at lists.jboss.org
Tue Jun 23 08:12:15 EDT 2009
Author: richard.opalka at jboss.com
Date: 2009-06-23 08:12:15 -0400 (Tue, 23 Jun 2009)
New Revision: 10221
Added:
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/wsf/container/jboss50/deployer/WebServiceDeploymentDeployer.java
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/wsf/container/jboss50/deployer/WebServicesMetaDataDeployer.java
Removed:
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/wsf/container/jboss50/deployer/WebservicesMetaDataDeployer.java
Modified:
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/wsf/container/jboss50/deployer/WebServiceDeployerEJB.java
container/jboss50/branches/ropalka-jboss510/src/main/resources/jbossws-jboss50.deployer/META-INF/jbossws-deployer-jboss-beans.xml
Log:
[JBWS-2332][JBWS-2382] refactoring (WIP)
Modified: container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/wsf/container/jboss50/deployer/WebServiceDeployerEJB.java
===================================================================
--- container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/wsf/container/jboss50/deployer/WebServiceDeployerEJB.java 2009-06-23 10:41:19 UTC (rev 10220)
+++ container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/wsf/container/jboss50/deployer/WebServiceDeployerEJB.java 2009-06-23 12:12:15 UTC (rev 10221)
@@ -21,186 +21,35 @@
*/
package org.jboss.wsf.container.jboss50.deployer;
-import java.lang.annotation.Annotation;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.management.ObjectName;
-import javax.naming.Context;
-
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.ejb.deployers.EjbDeployment;
-import org.jboss.ejb.deployers.MergedJBossMetaDataDeployer;
-import org.jboss.ejb3.EJBContainer;
-import org.jboss.ejb3.Ejb3Deployment;
-import org.jboss.ejb3.javaee.JavaEEComponentHelper;
-import org.jboss.logging.Logger;
-import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
-import org.jboss.metadata.ejb.jboss.JBossMetaData;
import org.jboss.metadata.web.jboss.JBossWebMetaData;
-import org.jboss.wsf.spi.deployment.integration.WebServiceDeclaration;
import org.jboss.wsf.spi.deployment.integration.WebServiceDeployment;
-import org.jboss.wsf.spi.metadata.webservices.WebservicesMetaData;
/**
- * This it the web service deployer for EJB. Adopts EJB deployments to
+ * This it the web service deployer for EJB. It gets
* {@link org.jboss.wsf.spi.deployment.integration.WebServiceDeclaration} an passes it to a chain of
* {@link org.jboss.wsf.container.jboss50.deployer.DeployerHook}'s.
*
* @author Thomas.Diesler at jboss.org
* @author Heiko.Braun at jboss.com
- *
- * @since 24-Apr-2007
+ * @author <a href="ropalka at redhat.com">Richard Opalka</a>
*/
+ at SuppressWarnings("unchecked")
public class WebServiceDeployerEJB extends AbstractWebServiceDeployer
{
- private static final Logger log = Logger.getLogger(WebServiceDeployerEJB.class);
- public WebServiceDeployerEJB()
- {
- addInput(MergedJBossMetaDataDeployer.EJB_MERGED_ATTACHMENT_NAME);
-
- addInput(EjbDeployment.class);
-
- addInput(Ejb3Deployment.class);
-
- addInput(WebservicesMetaData.class);
-
- // Input for the TomcatDeployer
- addOutput(JBossWebMetaData.class);
-
- addOutput(WebServiceDeployment.class);
-
- }
-
- @Override
- public void internalDeploy(DeploymentUnit unit) throws DeploymentException
- {
- JBossMetaData beans = (JBossMetaData)unit.getAttachment(
- MergedJBossMetaDataDeployer.EJB_MERGED_ATTACHMENT_NAME
- );
- Ejb3Deployment ejb3Deployment = unit.getAttachment(Ejb3Deployment.class);
-
- if(beans!=null)
- {
- WebServiceDeploymentAdapter wsDeployment = new WebServiceDeploymentAdapter();
-
- Iterator<JBossEnterpriseBeanMetaData> iterator = beans.getEnterpriseBeans().iterator();
- while(iterator.hasNext())
- {
- JBossEnterpriseBeanMetaData ejb = iterator.next();
- EJBContainer ejbContainer = null;
- if (ejb3Deployment != null && !ejb.isEntity())
- {
- ObjectName objName = null;
- try
- {
- objName = new ObjectName(ejb.determineContainerName());
- }
- catch (Exception e)
- {
- throw new DeploymentException(e);
- }
- ejbContainer = (EJBContainer)ejb3Deployment.getContainer(objName);
- }
- if(ejb.getEjbClass()!=null)
- wsDeployment.getEndpoints().add( new WebServiceDeclarationAdapter(ejb, ejbContainer, unit.getClassLoader()) );
- else
- log.warn("Ingore ejb deployment with null classname: " + ejb);
- }
-
- unit.addAttachment(WebServiceDeployment.class, wsDeployment);
-
- super.internalDeploy(unit);
- }
- }
-
- @Override
- public void internalUndeploy(DeploymentUnit unit)
- {
- super.internalUndeploy(unit);
- }
-
/**
- * Adopts EJB3 bean meta data to a {@link org.jboss.wsf.spi.deployment.integration.WebServiceDeclaration}
+ * Constructor.
*/
- private class WebServiceDeclarationAdapter implements WebServiceDeclaration
+ public WebServiceDeployerEJB()
{
-
- private JBossEnterpriseBeanMetaData ejbMetaData;
- private EJBContainer ejbContainer;
- private ClassLoader loader;
-
- public WebServiceDeclarationAdapter(JBossEnterpriseBeanMetaData ejbMetaData, EJBContainer ejbContainer, ClassLoader loader)
- {
- this.ejbMetaData = ejbMetaData;
- this.ejbContainer = ejbContainer;
- this.loader = loader;
- }
-
- public String getContainerName()
- {
- return ejbMetaData.determineContainerName();
- }
+ super();
- public Context getContext()
- {
- return ejbContainer.getEnc();
- }
+ // inputs
+ addInput(JBossWebMetaData.class);
+ addInput(WebServiceDeployment.class);
- public String getComponentName()
- {
- return ejbMetaData.getName();
- }
-
- public String getComponentClassName()
- {
- return ejbMetaData.getEjbClass();
- }
-
- public <T extends Annotation> T getAnnotation(Class<T> annotation)
- {
- T result = ejbContainer != null ? ejbContainer.getAnnotation(annotation) : null;
- if (result == null)
- {
- Class bean = getComponentClass();
- if(bean.isAnnotationPresent(annotation))
- {
- result = (T)bean.getAnnotation(annotation);
- }
- }
- return result;
- }
-
- private Class getComponentClass()
- {
- try
- {
- return loader.loadClass(getComponentClassName());
- } catch (ClassNotFoundException e)
- {
- throw new RuntimeException("Failed to load component class "+ getComponentClassName()+". Loader:" + this.loader);
- }
- }
+ // outputs
+ addOutput( JBossWebMetaData.class );
}
- /**
- * Adopts an EJB deployment to a {@link org.jboss.wsf.spi.deployment.integration.WebServiceDeployment}
- */
- private class WebServiceDeploymentAdapter implements WebServiceDeployment
- {
- private List<WebServiceDeclaration> endpoints = new ArrayList<WebServiceDeclaration>();
-
- public List<WebServiceDeclaration> getServiceEndpoints()
- {
- return endpoints;
- }
-
- public List<WebServiceDeclaration> getEndpoints()
- {
- return endpoints;
- }
- }
}
Added: container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/wsf/container/jboss50/deployer/WebServiceDeploymentDeployer.java
===================================================================
--- container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/wsf/container/jboss50/deployer/WebServiceDeploymentDeployer.java (rev 0)
+++ container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/wsf/container/jboss50/deployer/WebServiceDeploymentDeployer.java 2009-06-23 12:12:15 UTC (rev 10221)
@@ -0,0 +1,269 @@
+/*
+ * 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.wsf.container.jboss50.deployer;
+
+import java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+import javax.naming.Context;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.ejb.deployers.EjbDeployment;
+import org.jboss.ejb.deployers.MergedJBossMetaDataDeployer;
+import org.jboss.ejb3.EJBContainer;
+import org.jboss.ejb3.Ejb3Deployment;
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+import org.jboss.wsf.spi.deployment.integration.WebServiceDeclaration;
+import org.jboss.wsf.spi.deployment.integration.WebServiceDeployment;
+import org.jboss.wsf.spi.metadata.webservices.WebservicesMetaData;
+
+/**
+ * WebServiceDeployment deployer processes EJB containers and its metadata and creates WS adapters wrapping it.
+ *
+ * @author <a href="ropalka at redhat.com">Richard Opalka</a>
+ */
+public final class WebServiceDeploymentDeployer extends AbstractRealDeployer
+{
+
+ /**
+ * Constructor.
+ */
+ public WebServiceDeploymentDeployer()
+ {
+ super();
+
+ // inputs
+ addInput( MergedJBossMetaDataDeployer.EJB_MERGED_ATTACHMENT_NAME );
+ addInput( EjbDeployment.class );
+ addInput( Ejb3Deployment.class );
+ addInput( WebservicesMetaData.class );
+
+ // outputs
+ addOutput( WebServiceDeployment.class );
+ }
+
+ /**
+ * Deploys WebServiceDeployment meta data.
+ */
+ @Override
+ protected void internalDeploy( final DeploymentUnit unit ) throws DeploymentException
+ {
+ final JBossMetaData mergedMD = ( JBossMetaData )unit.getAttachment(
+ MergedJBossMetaDataDeployer.EJB_MERGED_ATTACHMENT_NAME
+ );
+ final Ejb3Deployment ejb3Deployment = unit.getAttachment( Ejb3Deployment.class );
+
+ if( mergedMD != null )
+ {
+ final WebServiceDeploymentAdapter wsDeploymentAdapter = new WebServiceDeploymentAdapter();
+ final Iterator< JBossEnterpriseBeanMetaData > ejbIterator = mergedMD.getEnterpriseBeans().iterator();
+
+ while( ejbIterator.hasNext() )
+ {
+ final JBossEnterpriseBeanMetaData ejbMD = ejbIterator.next();
+ final EJBContainer ejbContainer = this.getContainer( ejb3Deployment, ejbMD );
+
+ if( ejbMD.getEjbClass() != null )
+ {
+ wsDeploymentAdapter.getServiceEndpoints().add(
+ new WebServiceDeclarationAdapter( ejbMD, ejbContainer, unit.getClassLoader() )
+ );
+ }
+ else
+ {
+ log.warn( "Ingoring ejb deployment with null classname: " + ejbMD );
+ }
+ }
+
+ unit.addAttachment( WebServiceDeployment.class, wsDeploymentAdapter );
+ }
+ }
+
+ /**
+ * Returns EJB container if EJB3 deployment is detected and EJB meta data does not represent entity bean.
+ *
+ * @param ejb3Deployment EJB3 deployment meta data
+ * @param ejbMD EJB meta data
+ * @return EJB container or null if not EJB3 stateless bean
+ * @throws DeploymentException if some error occurs
+ */
+ private EJBContainer getContainer( final Ejb3Deployment ejb3Deployment, final JBossEnterpriseBeanMetaData ejbMD )
+ throws DeploymentException
+ {
+ if ( ( ejb3Deployment != null ) && ( ejbMD.isEntity() == false ) )
+ {
+ try
+ {
+ final ObjectName objName = new ObjectName( ejbMD.determineContainerName() );
+ return ( EJBContainer ) ejb3Deployment.getContainer( objName );
+ }
+ catch ( MalformedObjectNameException e )
+ {
+ throw new DeploymentException( e );
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Adopts EJB3 bean meta data to a
+ * {@link org.jboss.wsf.spi.deployment.integration.WebServiceDeclaration}.
+ */
+ private static class WebServiceDeclarationAdapter implements WebServiceDeclaration
+ {
+
+ private final JBossEnterpriseBeanMetaData ejbMetaData;
+ private final EJBContainer ejbContainer;
+ private final ClassLoader loader;
+
+ /**
+ * Constructor.
+ *
+ * @param ejbMetaData EJB metadata
+ * @param ejbContainer EJB container
+ * @param loader class loader
+ */
+ private WebServiceDeclarationAdapter
+ (
+ final JBossEnterpriseBeanMetaData ejbMetaData,
+ final EJBContainer ejbContainer,
+ final ClassLoader loader
+ )
+ {
+ super();
+
+ this.ejbMetaData = ejbMetaData;
+ this.ejbContainer = ejbContainer;
+ this.loader = loader;
+ }
+
+ /**
+ * Returns EJB container name.
+ *
+ * @return container name
+ */
+ public String getContainerName()
+ {
+ return this.ejbMetaData.determineContainerName();
+ }
+
+ /**
+ * Returns JNDI context associated with EJB container.
+ *
+ * @return JNDI context
+ */
+ public Context getContext()
+ {
+ return this.ejbContainer.getEnc();
+ }
+
+ /**
+ * Returns EJB name.
+ *
+ * @returns name
+ */
+ public String getComponentName()
+ {
+ return this.ejbMetaData.getName();
+ }
+
+ /**
+ * Returns EJB class name.
+ *
+ * @return class name
+ */
+ public String getComponentClassName()
+ {
+ return this.ejbMetaData.getEjbClass();
+ }
+
+ /**
+ * Returns requested annotation associated with EJB container or EJB bean.
+ *
+ * @return requested annotation or null if not found
+ */
+ public < T extends Annotation > T getAnnotation( final Class<T> annotationType )
+ {
+ final boolean haveEjbContainer = this.ejbContainer != null;
+
+ if ( haveEjbContainer )
+ {
+ return this.ejbContainer.getAnnotation( annotationType );
+ }
+ else
+ {
+ final Class< ? > bean = this.getComponentClass();
+ return ( T ) bean.getAnnotation( annotationType );
+ }
+ }
+
+ /**
+ * Loads ejb class from associated loader.
+ *
+ * @return ejb class instance
+ */
+ private Class< ? > getComponentClass()
+ {
+ try
+ {
+ return this.loader.loadClass( this.getComponentClassName() );
+ }
+ catch ( ClassNotFoundException cnfe )
+ {
+ throw new RuntimeException( "Failed to load component class: " +
+ this.getComponentClassName() + " from loader: " + this.loader );
+ }
+ }
+
+ }
+
+ /**
+ * Adopts an EJB deployment to a
+ * {@link org.jboss.wsf.spi.deployment.integration.WebServiceDeployment}
+ */
+ private static class WebServiceDeploymentAdapter implements WebServiceDeployment
+ {
+
+ /** List of endpoints. */
+ private final List< WebServiceDeclaration > endpoints = new ArrayList< WebServiceDeclaration >();
+
+ /**
+ * Returns endpoints list.
+ *
+ * @return endpoints list
+ */
+ public List< WebServiceDeclaration > getServiceEndpoints()
+ {
+ return endpoints;
+ }
+
+ }
+
+}
Added: container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/wsf/container/jboss50/deployer/WebServicesMetaDataDeployer.java
===================================================================
--- container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/wsf/container/jboss50/deployer/WebServicesMetaDataDeployer.java (rev 0)
+++ container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/wsf/container/jboss50/deployer/WebServicesMetaDataDeployer.java 2009-06-23 12:12:15 UTC (rev 10221)
@@ -0,0 +1,55 @@
+/*
+ * 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.wsf.container.jboss50.deployer;
+
+import org.jboss.deployers.vfs.spi.deployer.ObjectModelFactoryDeployer;
+import org.jboss.wsf.spi.metadata.webservices.WebservicesFactory;
+import org.jboss.wsf.spi.metadata.webservices.WebservicesMetaData;
+import org.jboss.xb.binding.ObjectModelFactory;
+
+/**
+ * webservices.xml deployer.
+ *
+ * @author <a href="ropalka at redhat.com">Richard Opalka</a>
+ */
+public final class WebServicesMetaDataDeployer
+extends ObjectModelFactoryDeployer< WebservicesMetaData >
+{
+
+ /**
+ * Constructor.
+ */
+ public WebServicesMetaDataDeployer()
+ {
+ super(WebservicesMetaData.class);
+ }
+
+ /**
+ * Model factory generator.
+ */
+ @Override
+ protected ObjectModelFactory getObjectModelFactory( final WebservicesMetaData root )
+ {
+ return new WebservicesFactory( null );
+ }
+
+}
Deleted: container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/wsf/container/jboss50/deployer/WebservicesMetaDataDeployer.java
===================================================================
--- container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/wsf/container/jboss50/deployer/WebservicesMetaDataDeployer.java 2009-06-23 10:41:19 UTC (rev 10220)
+++ container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/wsf/container/jboss50/deployer/WebservicesMetaDataDeployer.java 2009-06-23 12:12:15 UTC (rev 10221)
@@ -1,55 +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.wsf.container.jboss50.deployer;
-
-import org.jboss.deployers.vfs.spi.deployer.ObjectModelFactoryDeployer;
-import org.jboss.wsf.spi.metadata.webservices.WebservicesFactory;
-import org.jboss.wsf.spi.metadata.webservices.WebservicesMetaData;
-import org.jboss.xb.binding.ObjectModelFactory;
-
-/**
- * webservices.xml deployer.
- *
- * @author <a href="ropalka at redhat.com">Richard Opalka</a>
- */
-public final class WebservicesMetaDataDeployer
-extends ObjectModelFactoryDeployer< WebservicesMetaData >
-{
-
- /**
- * Constructor.
- */
- public WebservicesMetaDataDeployer()
- {
- super(WebservicesMetaData.class);
- }
-
- /**
- * Model factory generator.
- */
- @Override
- protected ObjectModelFactory getObjectModelFactory( final WebservicesMetaData root )
- {
- return new WebservicesFactory( null );
- }
-
-}
Modified: container/jboss50/branches/ropalka-jboss510/src/main/resources/jbossws-jboss50.deployer/META-INF/jbossws-deployer-jboss-beans.xml
===================================================================
--- container/jboss50/branches/ropalka-jboss510/src/main/resources/jbossws-jboss50.deployer/META-INF/jbossws-deployer-jboss-beans.xml 2009-06-23 10:41:19 UTC (rev 10220)
+++ container/jboss50/branches/ropalka-jboss510/src/main/resources/jbossws-jboss50.deployer/META-INF/jbossws-deployer-jboss-beans.xml 2009-06-23 12:12:15 UTC (rev 10221)
@@ -79,11 +79,13 @@
<!--
A deployer that processes webservices.xml file
-->
- <bean name="WebservicesMetaDataDeployer" class="org.jboss.wsf.container.jboss50.deployer.WebservicesMetaDataDeployer">
+ <bean name="WebServicesMetaDataDeployer" class="org.jboss.wsf.container.jboss50.deployer.WebServicesMetaDataDeployer">
<property name="name">webservices.xml</property>
<property name="useSchemaValidation">true</property>
</bean>
+ <bean name="WebServiceDeploymentDeployer" class="org.jboss.wsf.container.jboss50.deployer.WebServiceDeploymentDeployer"/>
+
<!--
A web service deployer that hooks in after the EJB deployers
-->
More information about the jbossws-commits
mailing list