Author: richard.opalka(a)jboss.com
Date: 2009-07-23 05:54:16 -0400 (Thu, 23 Jul 2009)
New Revision: 10371
Added:
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/config/
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/config/ServerConfigImpl.java
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/injection/
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/injection/EJBBeanReferenceResolver.java
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/injection/InjectionMetaDataDeploymentAspect.java
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/metadata/ContainerMetaDataBuilder.java
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/metadata/ContainerMetaDataDeploymentAspect.java
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/metadata/EJB21MetaDataBuilder.java
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/metadata/EJB3MetaDataBuilder.java
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/metadata/JSEMetaDataBuilder.java
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/ejb/
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/ejb/SecurityHandler.java
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/ejb/SecurityHandlerEJB21.java
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/ejb/SecurityHandlerEJB3.java
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/ejb/WebAppGeneratorDeploymentAspect.java
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/jse/
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/jse/WebAppDeploymentAspect.java
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/jse/WebMetaDataModifier.java
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/jse/WebMetaDataModifierImpl.java
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/util/
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/util/Helper.java
Removed:
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/ASIntegrationHelper.java
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/aspects/
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/deployers/DeployerUtils.java
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/deployers/ServerConfigImpl.java
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/metadata/ContainerMetaDataAdapter.java
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/metadata/EJBArchiveMetaDataAdapterEJB21.java
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/metadata/EJBArchiveMetaDataAdapterEJB3.java
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/metadata/EJBBeanReferenceResolver.java
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/metadata/JSEArchiveMetaDataAdapter.java
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/SecurityHandler.java
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/SecurityHandlerEJB21.java
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/SecurityHandlerEJB3.java
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/WebMetaDataModifier.java
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/WebMetaDataModifierImpl.java
Modified:
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/deployers/WSDeploymentAspectDeployer.java
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/WSTypeDeployer.java
container/jboss50/branches/ropalka-jboss510/src/main/resources/jbossws-jboss50.deployer/META-INF/stack-agnostic-jboss-beans.xml
Log:
[JBWS-2332] refactoring
Deleted:
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/ASIntegrationHelper.java
===================================================================
---
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/ASIntegrationHelper.java 2009-07-22
09:40:52 UTC (rev 10370)
+++
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/ASIntegrationHelper.java 2009-07-23
09:54:16 UTC (rev 10371)
@@ -1,136 +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;
-
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.wsf.spi.deployment.Deployment.DeploymentType;
-
-/**
- * JBoss AS integration helper class.
- *
- * @author <a href="ropalka(a)redhat.com">Richard Opalka</a>
- */
-public final class ASIntegrationHelper
-{
-
- /**
- * Forbidden constructor.
- */
- private ASIntegrationHelper()
- {
- super();
- }
-
- public static boolean isWebServiceDeployment( final DeploymentUnit unit )
- {
- return unit.getAttachment( DeploymentType.class ) != null;
- }
-
- public static boolean isPojoDeployment( final DeploymentUnit unit )
- {
- if ( ASIntegrationHelper.isWebServiceDeployment( unit ) )
- {
- final DeploymentType deploymentType = unit.getAttachment( DeploymentType.class
);
- final boolean isJaxrpcPojo = DeploymentType.JAXRPC_JSE.equals( deploymentType
);
- final boolean isJaxwsPojo = DeploymentType.JAXWS_JSE.equals( deploymentType );
-
- return isJaxwsPojo || isJaxrpcPojo;
- }
-
- return false;
- }
-
- public static boolean isEjbDeployment( final DeploymentUnit unit )
- {
- if ( ASIntegrationHelper.isWebServiceDeployment( unit ) )
- {
- final DeploymentType deploymentType = unit.getAttachment( DeploymentType.class
);
- final boolean isJaxwsEjb3 = DeploymentType.JAXWS_EJB3.equals( deploymentType );
- final boolean isJaxrpcEjb21 = DeploymentType.JAXRPC_EJB21.equals( deploymentType
);
-
- return isJaxwsEjb3 || isJaxrpcEjb21;
- }
-
- return false;
- }
-
- public static boolean isJaxwsDeployment( final DeploymentUnit unit )
- {
- if ( ASIntegrationHelper.isWebServiceDeployment( unit ) )
- {
- final DeploymentType deploymentType = unit.getAttachment( DeploymentType.class
);
- final boolean isJaxwsEjb3 = DeploymentType.JAXWS_EJB3.equals( deploymentType );
- final boolean isJaxwsPojo = DeploymentType.JAXWS_JSE.equals( deploymentType );
-
- return isJaxwsEjb3 || isJaxwsPojo;
- }
-
- return false;
- }
-
- public static boolean isJaxrpcDeployment( final DeploymentUnit unit )
- {
- if ( ASIntegrationHelper.isWebServiceDeployment( unit ) )
- {
- final DeploymentType deploymentType = unit.getAttachment( DeploymentType.class
);
- final boolean isJaxrpcEjb21 = DeploymentType.JAXRPC_EJB21.equals( deploymentType
);
- final boolean isJaxrpcPojo = DeploymentType.JAXRPC_JSE.equals( deploymentType
);
-
- return isJaxrpcEjb21 || isJaxrpcPojo;
- }
-
- return false;
- }
-
- public static boolean isJaxrpcPojoDeployment( final DeploymentUnit unit )
- {
- final boolean isJaxrpc = ASIntegrationHelper.isJaxrpcDeployment( unit );
- final boolean isPojo = ASIntegrationHelper.isPojoDeployment( unit );
-
- return isPojo && isJaxrpc;
- }
-
- public static boolean isJaxwsPojoDeployment( final DeploymentUnit unit )
- {
- final boolean isJaxws = ASIntegrationHelper.isJaxwsDeployment( unit );
- final boolean isPojo = ASIntegrationHelper.isPojoDeployment( unit );
-
- return isPojo && isJaxws;
- }
-
- public static boolean isJaxrpcEjbDeployment( final DeploymentUnit unit )
- {
- final boolean isJaxrpc = ASIntegrationHelper.isJaxrpcDeployment( unit );
- final boolean isEjb = ASIntegrationHelper.isEjbDeployment( unit );
-
- return isEjb && isJaxrpc;
- }
-
- public static boolean isJaxwsEjbDeployment( final DeploymentUnit unit )
- {
- final boolean isJaxws = ASIntegrationHelper.isJaxwsDeployment( unit );
- final boolean isEjb = ASIntegrationHelper.isEjbDeployment( unit );
-
- return isEjb && isJaxws;
- }
-
-}
Added:
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/config/ServerConfigImpl.java
===================================================================
---
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/config/ServerConfigImpl.java
(rev 0)
+++
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/config/ServerConfigImpl.java 2009-07-23
09:54:16 UTC (rev 10371)
@@ -0,0 +1,83 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.webservices.integration.config;
+
+import java.io.File;
+
+import javax.management.JMException;
+import javax.management.ObjectName;
+
+import org.jboss.wsf.common.management.AbstractServerConfig;
+import org.jboss.wsf.common.management.AbstractServerConfigMBean;
+
+/**
+ * A ServerConfig for AS <= 5.1.0
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @author Thomas.Diesler(a)jboss.org
+ *
+ */
+public class ServerConfigImpl extends AbstractServerConfig implements
AbstractServerConfigMBean
+{
+
+ public File getServerTempDir()
+ {
+ return this.getDirFromServerConfig("ServerTempDir");
+ }
+
+ public File getHomeDir()
+ {
+ return this.getDirFromServerConfig("HomeDir");
+ }
+
+ public File getServerDataDir()
+ {
+ return this.getDirFromServerConfig("ServerDataDir");
+ }
+
+ /**
+ * Obtains the specified attribute from the server configuration,
+ * represented as a {@link File}.
+ *
+ * @param attributeName
+ * @return
+ * @author ALR
+ */
+ protected File getDirFromServerConfig(final String attributeName)
+ {
+ // Define the ON to invoke upon
+ final ObjectName on = OBJECT_NAME_SERVER_CONFIG;
+
+ // Get the URL location
+ File location = null;
+ try
+ {
+ location = (File) getMbeanServer().getAttribute(on, attributeName);
+ }
+ catch (final JMException e)
+ {
+ throw new RuntimeException("Could not obtain attribute " +
attributeName + " from " + on, e);
+ }
+ return location;
+ }
+
+}
Deleted:
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/deployers/DeployerUtils.java
===================================================================
---
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/deployers/DeployerUtils.java 2009-07-22
09:40:52 UTC (rev 10370)
+++
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/deployers/DeployerUtils.java 2009-07-23
09:54:16 UTC (rev 10371)
@@ -1,186 +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 java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.jws.WebService;
-import javax.servlet.Servlet;
-import javax.xml.ws.WebServiceProvider;
-
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.logging.Logger;
-import org.jboss.metadata.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.wsf.spi.deployment.Endpoint;
-import org.jboss.wsf.spi.deployment.integration.WebServiceDeclaration;
-import org.jboss.wsf.spi.deployment.integration.WebServiceDeployment;
-
-/**
- * TODO: javadoc
- *
- * @author <a href="ropalka(a)redhat.com">Richard Opalka</a>
- */
-final class DeployerUtils
-{
-
- /** Logger. */
- private static final Logger log = Logger.getLogger( DeployerUtils.class );
-
- /**
- * Forbidden constructor.
- */
- private DeployerUtils()
- {
- super();
- }
-
- static final boolean isWebServiceBean( final WebServiceDeclaration ejbContainerAdapter
)
- {
- boolean isWebServiceBean = false;
- boolean isWebService = ejbContainerAdapter.getAnnotation(WebService.class) !=
null;
- boolean isWebServiceProvider =
ejbContainerAdapter.getAnnotation(WebServiceProvider.class) != null;
- isWebServiceBean = isWebService || isWebServiceProvider;
-
- return isWebServiceBean;
- }
-
- static final boolean isEjb3Deployment( final DeploymentUnit unit )
- {
- final WebServiceDeployment wsDeployment = unit.getAttachment(
WebServiceDeployment.class );
-
- Iterator<WebServiceDeclaration> it =
wsDeployment.getServiceEndpoints().iterator();
- while (it.hasNext())
- {
- WebServiceDeclaration container = it.next();
- if (DeployerUtils.isWebServiceBean(container))
- {
- return true;
- }
- }
-
- return false;
- }
-
- static final List<ServletMetaData> getJaxwsServlets( final DeploymentUnit unit
)
- {
- return DeployerUtils.getRelevantServlets( unit, true );
- }
-
- static List<ServletMetaData> getJaxrpcServlets( final DeploymentUnit unit )
- {
- return DeployerUtils.getRelevantServlets( unit, false );
- }
-
- private static final List< ServletMetaData > getRelevantServlets( final
DeploymentUnit unit, final boolean jaxws )
- {
- try
- {
- final JBossWebMetaData jbossWebMD = unit.getAttachment(JBossWebMetaData.class);
- final ClassLoader loader = unit.getClassLoader();
-
- List<ServletMetaData> endpoints = new ArrayList<ServletMetaData>();
- for (ServletMetaData servlet : jbossWebMD.getServlets())
- {
- String servletClassName = getTargetBean(servlet);
-
- // Skip JSPs
- if (servletClassName == null || servletClassName.length() == 0)
- continue;
-
- try
- {
- Class<?> servletClass = loader.loadClass(servletClassName.trim());
- boolean isServlet = servletClass.isAssignableFrom(Servlet.class);
- if (false == isServlet)
- {
- boolean isWebService =
servletClass.isAnnotationPresent(WebService.class);
- boolean isWebServiceProvider =
servletClass.isAnnotationPresent(WebServiceProvider.class);
- if ( jaxws )
- {
- if (isWebService || isWebServiceProvider)
- {
- endpoints.add(servlet); // jaxws endpoint
- }
- }
- else
- {
- if (!isWebService && !isWebServiceProvider)
- {
- endpoints.add(servlet); // jaxrpc endpoint
- }
- }
- }
- }
- catch (ClassNotFoundException ex)
- {
- log.warn("Cannot load servlet class: " + servletClassName);
- continue;
- }
- }
-
- return endpoints;
- }
- catch (Exception ex)
- {
- log.error("Cannot process web deployment", ex);
- return Collections.emptyList();
- }
- }
-
- static String getTargetBean(ServletMetaData servlet)
- {
- String endpointClass = servlet.getServletClass();
- List<ParamValueMetaData> initParams = servlet.getInitParam();
- if (initParams != null)
- {
- for (ParamValueMetaData param : initParams)
- {
- if (Endpoint.SEPID_DOMAIN_ENDPOINT.equals(param.getParamName()))
- {
- endpointClass = param.getParamValue();
- break;
- }
- }
- }
- return endpointClass;
- }
-
- static ServletMetaData getServletForName( final JBossWebMetaData jbossWebMD, final
String servletName )
- {
- for ( JBossServletMetaData servlet : jbossWebMD.getServlets() )
- {
- if ( servlet.getName().equals( servletName ) )
- {
- return servlet;
- }
- }
-
- throw new IllegalStateException( "Cannot find servlet for link: " +
servletName );
- }
-
-}
Deleted:
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/deployers/ServerConfigImpl.java
===================================================================
---
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/deployers/ServerConfigImpl.java 2009-07-22
09:40:52 UTC (rev 10370)
+++
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/deployers/ServerConfigImpl.java 2009-07-23
09:54:16 UTC (rev 10371)
@@ -1,82 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.webservices.integration.deployers;
-
-import java.io.File;
-
-import javax.management.JMException;
-import javax.management.ObjectName;
-
-import org.jboss.wsf.common.management.AbstractServerConfig;
-import org.jboss.wsf.common.management.AbstractServerConfigMBean;
-
-/**
- * A ServerConfig for AS <= 5.1.0
- *
- * @author alessio.soldano(a)jboss.com
- * @author Thomas.Diesler(a)jboss.org
- *
- */
-public class ServerConfigImpl extends AbstractServerConfig implements
AbstractServerConfigMBean
-{
-
- public File getServerTempDir()
- {
- return this.getDirFromServerConfig("ServerTempDir");
- }
-
- public File getHomeDir()
- {
- return this.getDirFromServerConfig("HomeDir");
- }
-
- public File getServerDataDir()
- {
- return this.getDirFromServerConfig("ServerDataDir");
- }
-
- /**
- * Obtains the specified attribute from the server configuration,
- * represented as a {@link File}.
- *
- * @param attributeName
- * @return
- * @author ALR
- */
- protected File getDirFromServerConfig(final String attributeName)
- {
- // Define the ON to invoke upon
- final ObjectName on = OBJECT_NAME_SERVER_CONFIG;
-
- // Get the URL location
- File location = null;
- try
- {
- location = (File) getMbeanServer().getAttribute(on, attributeName);
- }
- catch (final JMException e)
- {
- throw new RuntimeException("Could not obtain attribute " +
attributeName + " from " + on, e);
- }
- return location;
- }
-}
Modified:
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/deployers/WSDeploymentAspectDeployer.java
===================================================================
---
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/deployers/WSDeploymentAspectDeployer.java 2009-07-22
09:40:52 UTC (rev 10370)
+++
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/deployers/WSDeploymentAspectDeployer.java 2009-07-23
09:54:16 UTC (rev 10371)
@@ -27,7 +27,7 @@
import org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer;
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.metadata.web.jboss.JBossWebMetaData;
-import org.jboss.webservices.integration.ASIntegrationHelper;
+import org.jboss.webservices.integration.util.Helper;
import org.jboss.wsf.spi.deployment.Deployment;
import org.jboss.wsf.spi.deployment.DeploymentAspect;
@@ -98,7 +98,7 @@
@Override
public void internalDeploy( final DeploymentUnit unit ) throws DeploymentException
{
- if ( ASIntegrationHelper.isWebServiceDeployment( unit ) )
+ if ( Helper.isWebServiceDeployment( unit ) )
{
log.debug( this.aspect.getClass() + " deploy: " + unit.getName() );
final Deployment dep = unit.getAttachment( Deployment.class );
@@ -115,7 +115,7 @@
@Override
public void internalUndeploy( final DeploymentUnit unit )
{
- if ( ASIntegrationHelper.isWebServiceDeployment( unit ) )
+ if ( Helper.isWebServiceDeployment( unit ) )
{
log.debug( this.aspect.getClass() + " undeploy: " + unit.getName() );
final Deployment dep = unit.getAttachment( Deployment.class );
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-07-22
09:40:52 UTC (rev 10370)
+++
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/deployers/WSDeploymentDeployer.java 2009-07-23
09:54:16 UTC (rev 10371)
@@ -38,8 +38,8 @@
import org.jboss.metadata.web.jboss.JBossWebMetaData;
import org.jboss.metadata.web.spec.ServletMetaData;
import org.jboss.virtual.VirtualFile;
-import org.jboss.webservices.integration.ASIntegrationHelper;
import org.jboss.webservices.integration.invocation.InvocationHandlerEJB3;
+import org.jboss.webservices.integration.util.Helper;
import org.jboss.wsf.spi.SPIProvider;
import org.jboss.wsf.spi.SPIProviderResolver;
import org.jboss.wsf.spi.deployment.ArchiveDeployment;
@@ -96,19 +96,19 @@
@Override
protected void internalDeploy( final DeploymentUnit unit ) throws DeploymentException
{
- if ( ASIntegrationHelper.isJaxwsPojoDeployment( unit ) )
+ if ( Helper.isJaxwsJseDeployment( unit ) )
{
- this.newJaxwsPojoDeployment( unit );
+ this.newJaxwsJseDeployment( unit );
}
- else if ( ASIntegrationHelper.isJaxwsEjbDeployment( unit ) )
+ else if ( Helper.isJaxwsEjbDeployment( unit ) )
{
this.newJaxwsEjbDeployment( unit );
}
- else if ( ASIntegrationHelper.isJaxrpcPojoDeployment( unit ) )
+ else if ( Helper.isJaxrpcJseDeployment( unit ) )
{
- this.newJaxrpcPojoDeployment( unit );
+ this.newJaxrpcJseDeployment( unit );
}
- else if ( ASIntegrationHelper.isJaxrpcEjbDeployment( unit ) )
+ else if ( Helper.isJaxrpcEjbDeployment( unit ) )
{
this.newJaxrpcEjbDeployment( unit );
}
@@ -157,7 +157,7 @@
{
final WebServiceDeclaration container = it.next();
- if ( DeployerUtils.isWebServiceBean( container ) )
+ if ( Helper.isWebServiceBean( container ) )
{
final String ejbName = container.getComponentName();
final String ejbClass = container.getComponentClassName();
@@ -172,11 +172,11 @@
}
/**
- * Creates new JAXRPC POJO deployment and registers it with deployment unit.
+ * Creates new JAXRPC JSE deployment and registers it with deployment unit.
*
* @param unit deployment unit
*/
- private void newJaxrpcPojoDeployment( final DeploymentUnit unit )
+ private void newJaxrpcJseDeployment( final DeploymentUnit unit )
{
final ArchiveDeployment dep = this.newDeployment( unit );
final JBossWebMetaData webMetaData = this.getAttachment( JBossWebMetaData.class,
unit, dep );
@@ -186,11 +186,11 @@
{
for ( PortComponentMetaData pcmd : wsd.getPortComponents() )
{
- final String pojoName = pcmd.getServletLink();
- final ServletMetaData servlet = DeployerUtils.getServletForName( webMetaData,
pojoName );
- final String pojoClass = DeployerUtils.getTargetBean( servlet );
+ final String servletName = pcmd.getServletLink();
+ final ServletMetaData servletMD = Helper.getServletForName( webMetaData,
servletName );
+ final String servletClass = Helper.getTargetBean( servletMD );
- this.createEndpoint( pojoClass, pojoName, dep );
+ this.createEndpoint( servletClass, servletName, dep );
}
}
@@ -199,22 +199,22 @@
}
/**
- * Creates new JAXWS POJO deployment and registers it with deployment unit.
+ * Creates new JAXWS JSE deployment and registers it with deployment unit.
*
* @param unit deployment unit
*/
- private void newJaxwsPojoDeployment( final DeploymentUnit unit )
+ private void newJaxwsJseDeployment( final DeploymentUnit unit )
{
final ArchiveDeployment dep = this.newDeployment( unit );
this.getAttachment( JBossWebMetaData.class, unit, dep );
- final List< ServletMetaData > servlets = DeployerUtils.getJaxwsServlets( unit
);
+ final List< ServletMetaData > servlets = Helper.getJaxwsServlets( unit );
for ( ServletMetaData servlet : servlets )
{
- final String pojoName = servlet.getName();
- final String pojoClass = DeployerUtils.getTargetBean( servlet );
+ final String servletName = servlet.getName();
+ final String servletClass = Helper.getTargetBean( servlet );
- this.createEndpoint( pojoClass, pojoName, dep );
+ this.createEndpoint( servletClass, servletName, dep );
}
dep.addAttachment( DeploymentUnit.class, unit );
Modified:
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/deployers/WSTypeDeployer.java
===================================================================
---
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/deployers/WSTypeDeployer.java 2009-07-22
09:40:52 UTC (rev 10370)
+++
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/deployers/WSTypeDeployer.java 2009-07-23
09:54:16 UTC (rev 10371)
@@ -26,6 +26,7 @@
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.metadata.ejb.jboss.JBossMetaData;
import org.jboss.metadata.web.jboss.JBossWebMetaData;
+import org.jboss.webservices.integration.util.Helper;
import org.jboss.wsf.spi.deployment.Deployment.DeploymentType;
import org.jboss.wsf.spi.deployment.integration.WebServiceDeployment;
import org.jboss.wsf.spi.metadata.webservices.WebservicesMetaData;
@@ -64,21 +65,21 @@
@Override
protected void internalDeploy( final DeploymentUnit unit ) throws DeploymentException
{
- if ( this.isJaxrpcEjbDeployment( unit ) )
+ if ( this.isJaxwsJseDeployment( unit ) )
{
- unit.addAttachment( DeploymentType.class, DeploymentType.JAXRPC_EJB21 );
+ unit.addAttachment( DeploymentType.class, DeploymentType.JAXWS_JSE );
}
else if ( this.isJaxwsEjbDeployment( unit ) )
{
unit.addAttachment( DeploymentType.class, DeploymentType.JAXWS_EJB3 );
}
- else if ( this.isJaxrpcPojoDeployment( unit ) )
+ else if ( this.isJaxrpcJseDeployment( unit ) )
{
unit.addAttachment( DeploymentType.class, DeploymentType.JAXRPC_JSE );
}
- else if ( this.isJaxwsPojoDeployment( unit ) )
+ else if ( this.isJaxrpcEjbDeployment( unit ) )
{
- unit.addAttachment( DeploymentType.class, DeploymentType.JAXWS_JSE );
+ unit.addAttachment( DeploymentType.class, DeploymentType.JAXRPC_EJB21 );
}
}
@@ -97,24 +98,22 @@
}
/**
- * Returns true if JAXRPC POJO deployment is detected.
+ * Returns true if JAXRPC JSE deployment is detected.
*
* @param unit deployment unit
- * @return true if JAXRPC POJO, false otherwise
+ * @return true if JAXRPC JSE, false otherwise
*/
- private boolean isJaxrpcPojoDeployment( final DeploymentUnit unit )
+ private boolean isJaxrpcJseDeployment( final DeploymentUnit unit )
{
final boolean isJaxrpc = unit.getAttachment( WebservicesMetaData.class ) != null;
final boolean hasJBossWebMD = unit.getAttachment( JBossWebMetaData.class ) !=
null;
if ( isJaxrpc && hasJBossWebMD )
{
- return DeployerUtils.getJaxrpcServlets( unit ).size() > 0;
+ return Helper.getJaxrpcServlets( unit ).size() > 0;
}
- else
- {
- return false;
- }
+
+ return false;
}
/**
@@ -129,32 +128,28 @@
if ( hasWSDeployment )
{
- return DeployerUtils.isEjb3Deployment( unit );
+ return Helper.isEjb3Deployment( unit );
}
- else
- {
- return false;
- }
+
+ return false;
}
/**
- * Returns true if JAXWS POJO deployment is detected.
+ * Returns true if JAXWS JSE deployment is detected.
*
* @param unit deployment unit
- * @return true if JAXWS POJO, false otherwise
+ * @return true if JAXWS JSE, false otherwise
*/
- private boolean isJaxwsPojoDeployment( final DeploymentUnit unit )
+ private boolean isJaxwsJseDeployment( final DeploymentUnit unit )
{
final boolean hasJBossWebMD = unit.getAttachment( JBossWebMetaData.class ) !=
null;
if ( hasJBossWebMD )
{
- return DeployerUtils.getJaxwsServlets( unit ).size() > 0;
+ return Helper.getJaxwsServlets( unit ).size() > 0;
}
- else
- {
- return false;
- }
+
+ return false;
}
}
Added:
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/injection/EJBBeanReferenceResolver.java
===================================================================
---
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/injection/EJBBeanReferenceResolver.java
(rev 0)
+++
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/injection/EJBBeanReferenceResolver.java 2009-07-23
09:54:16 UTC (rev 10371)
@@ -0,0 +1,114 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.webservices.integration.injection;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import javax.ejb.EJB;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.ejb3.common.resolvers.spi.EjbReference;
+import org.jboss.ejb3.common.resolvers.spi.EjbReferenceResolver;
+import org.jboss.wsf.common.injection.resolvers.AbstractReferenceResolver;
+
+/**
+ * EJB reference resolver.
+ *
+ * @author <a href="mailto:richard.opalka@jboss.org">Richard
Opalka</a>
+ */
+final class EJBBeanReferenceResolver extends AbstractReferenceResolver<EJB>
+{
+
+ /**
+ * Deployment unit used for resolving process.
+ */
+ private final DeploymentUnit unit;
+ /**
+ * Delegate used to resolve JNDI names.
+ */
+ private final EjbReferenceResolver delegate;
+
+ /**
+ * Constructor.
+ */
+ public EJBBeanReferenceResolver(final DeploymentUnit unit, final EjbReferenceResolver
delegate)
+ {
+ super(EJB.class);
+
+ if (unit == null)
+ {
+ throw new IllegalArgumentException("Deployment unit cannot be null");
+ }
+ if (delegate == null)
+ {
+ throw new IllegalArgumentException("Ejb reference resolver cannot be
null");
+ }
+
+ this.unit = unit;
+ this.delegate = delegate;
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.wsf.common.injection.resolvers.AbstractReferenceResolver#resolveField(java.lang.reflect.Field)
+ */
+ @Override
+ protected String resolveField(final Field field)
+ {
+ final EJB ejbAnnotation = field.getAnnotation(EJB.class);
+ final Class<?> type = field.getType();
+ final EjbReference reference = getEjbReference(ejbAnnotation, type);
+
+ return this.delegate.resolveEjb(unit, reference);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.wsf.common.injection.resolvers.AbstractReferenceResolver#resolveMethod(java.lang.reflect.Method)
+ */
+ @Override
+ protected String resolveMethod(final Method method)
+ {
+ final EJB ejbAnnotation = method.getAnnotation(EJB.class);
+ final Class<?> type = method.getParameterTypes()[0];
+ final EjbReference reference = getEjbReference(ejbAnnotation, type);
+
+ return this.delegate.resolveEjb(unit, reference);
+ }
+
+ /**
+ * Constructs EjbReference.
+ *
+ * @param ejbAnnotation ejb annotation
+ * @param type fall back type
+ * @return ejb reference instance
+ */
+ private EjbReference getEjbReference(EJB ejbAnnotation, Class<?> type)
+ {
+ String beanInterface = ejbAnnotation.beanInterface().getName();
+ if (java.lang.Object.class.getName().equals(beanInterface))
+ {
+ beanInterface = type.getName();
+ }
+ return new EjbReference(ejbAnnotation.beanName(), beanInterface,
ejbAnnotation.mappedName());
+ }
+
+}
Added:
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/injection/InjectionMetaDataDeploymentAspect.java
===================================================================
---
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/injection/InjectionMetaDataDeploymentAspect.java
(rev 0)
+++
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/injection/InjectionMetaDataDeploymentAspect.java 2009-07-23
09:54:16 UTC (rev 10371)
@@ -0,0 +1,235 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.webservices.integration.injection;
+
+import java.lang.annotation.Annotation;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.annotation.Resource;
+import javax.ejb.EJB;
+import javax.jws.WebService;
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.xml.ws.WebServiceProvider;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.ejb3.common.resolvers.spi.EjbReferenceResolver;
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeansMetaData;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+import org.jboss.metadata.javaee.spec.EnvironmentEntriesMetaData;
+import org.jboss.metadata.javaee.spec.EnvironmentEntryMetaData;
+import org.jboss.metadata.javaee.spec.ResourceInjectionTargetMetaData;
+import org.jboss.metadata.web.jboss.JBossWebMetaData;
+import org.jboss.webservices.integration.util.Helper;
+import org.jboss.wsf.common.injection.resolvers.ResourceReferenceResolver;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.deployment.DeploymentAspect;
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.deployment.integration.WebServiceDeclaration;
+import org.jboss.wsf.spi.deployment.integration.WebServiceDeployment;
+import org.jboss.wsf.spi.metadata.injection.InjectionMetaData;
+import org.jboss.wsf.spi.metadata.injection.InjectionsMetaData;
+import org.jboss.wsf.spi.metadata.injection.ReferenceResolver;
+
+/**
+ * Deployment aspect that builds injection meta data.
+ *
+ * @author <a href="mailto:richard.opalka@jboss.org">Richard
Opalka</a>
+ */
+public final class InjectionMetaDataDeploymentAspect extends DeploymentAspect
+{
+
+ private static final ReferenceResolver RESOURCE_REFERENCE_RESOLVER = new
ResourceReferenceResolver();
+ private static final String EJB3_JNDI_PREFIX = "java:env/";
+ private EjbReferenceResolver ejbReferenceResolver;
+
+ @Override
+ public void start(Deployment dep)
+ {
+ super.start(dep);
+
+ DeploymentUnit unit = dep.getAttachment(DeploymentUnit.class);
+ if (unit == null)
+ throw new IllegalStateException("DeploymentUnit not found");
+
+ JBossWebMetaData webMD = dep.getAttachment(JBossWebMetaData.class);
+ if (webMD == null)
+ throw new IllegalStateException("JBossWebMetaData not found");
+
+ List<InjectionMetaData> injectionMD = new
LinkedList<InjectionMetaData>();
+ Map<Class<? extends Annotation>, ReferenceResolver> resolvers =
createResolvers(unit);
+
+ try
+ {
+
+ if ( Helper.isJaxwsJseDeployment( unit ) )
+ {
+ injectionMD.addAll(buildInjectionMetaData(webMD.getEnvironmentEntries()));
+ for (Endpoint endpoint : dep.getService().getEndpoints())
+ {
+ InjectionsMetaData injectionsMD = new InjectionsMetaData(injectionMD,
resolvers, null);
+ endpoint.addAttachment(InjectionsMetaData.class, injectionsMD);
+ }
+ }
+ else if ( Helper.isJaxwsEjbDeployment( unit ) )
+ {
+ JBossMetaData jbossMD = unit.getAttachment(JBossMetaData.class);
+ JBossEnterpriseBeansMetaData jebMDs = jbossMD.getEnterpriseBeans();
+
+ WebServiceDeployment webServiceDeployment =
unit.getAttachment(WebServiceDeployment.class);
+
+ Iterator<WebServiceDeclaration> it =
webServiceDeployment.getServiceEndpoints().iterator();
+ while (it.hasNext())
+ {
+ WebServiceDeclaration container = it.next();
+ if (isWebServiceBean(container))
+ {
+ final Context ctx =
(Context)container.getContext().lookup(EJB3_JNDI_PREFIX);
+ String ejbName = container.getComponentName();
+ EnvironmentEntriesMetaData ejbEnvEntries =
jebMDs.get(ejbName).getEnvironmentEntries();
+ injectionMD.addAll(buildInjectionMetaData(ejbEnvEntries));
+ Endpoint endpoint = dep.getService().getEndpointByName(ejbName);
+ InjectionsMetaData injectionsMD = new InjectionsMetaData(injectionMD,
resolvers, ctx);
+ endpoint.addAttachment(InjectionsMetaData.class, injectionsMD);
+ }
+ }
+ }
+ }
+ catch (NamingException ne)
+ {
+ throw new RuntimeException(ne);
+ }
+ }
+
+ @Override
+ public void stop(Deployment dep)
+ {
+ dep.getService().removeAttachment(InjectionMetaData.class);
+
+ super.stop(dep);
+ }
+
+ /**
+ * Builds reference resolvers container.
+ *
+ * @param unit deployment unit
+ * @return reference resolvers
+ */
+ private Map<Class<? extends Annotation>, ReferenceResolver>
createResolvers(DeploymentUnit unit)
+ {
+ final Map<Class<? extends Annotation>, ReferenceResolver> resolvers =
new HashMap<Class<? extends Annotation>, ReferenceResolver>();
+ resolvers.put(Resource.class, RESOURCE_REFERENCE_RESOLVER);
+ resolvers.put(EJB.class, new EJBBeanReferenceResolver(unit,
getEjbReferenceResolver()));
+ return resolvers;
+ }
+
+ /**
+ * Builds JBossWS specific injection metadata from JBoss metadata.
+ *
+ * @param envEntries environment entries
+ * @return JBossWS specific injection metadata
+ */
+ private List<InjectionMetaData>
buildInjectionMetaData(EnvironmentEntriesMetaData envEntries)
+ {
+ if ((envEntries == null) || (envEntries.size() == 0))
+ {
+ return Collections.emptyList();
+ }
+
+ EnvironmentEntryMetaData eeMD = null;
+ LinkedList<InjectionMetaData> retVal = new
LinkedList<InjectionMetaData>();
+ String envEntryName = null;
+ String envEntryValue = null;
+ String targetClass = null;
+ String targetName = null;
+ String valueClass = null;
+
+ for (Iterator<EnvironmentEntryMetaData> i = envEntries.iterator();
i.hasNext();)
+ {
+ eeMD = i.next();
+ envEntryName = eeMD.getEnvEntryName();
+ envEntryValue = eeMD.getValue();
+ valueClass = eeMD.getType();
+
+ Set<ResourceInjectionTargetMetaData> injectionTargets =
eeMD.getInjectionTargets();
+ if ((injectionTargets != null) && (injectionTargets.size() > 0))
+ {
+ for (Iterator<ResourceInjectionTargetMetaData> j =
injectionTargets.iterator(); j.hasNext(); )
+ {
+ ResourceInjectionTargetMetaData ritMD = j.next();
+ targetClass = ritMD.getInjectionTargetClass();
+ targetName = ritMD.getInjectionTargetName();
+ InjectionMetaData injectionMD = new InjectionMetaData(targetClass,
targetName, valueClass, envEntryName, envEntryValue != null);
+ retVal.add(injectionMD);
+ }
+ }
+ }
+
+ return retVal;
+ }
+
+ /**
+ * Returns true if EJB represents webservice endpoint, false otherwise.
+ *
+ * @param container to analyze
+ * @return true if webservice endpoint, false otherwise
+ */
+ private boolean isWebServiceBean(WebServiceDeclaration container)
+ {
+ boolean isWebService = container.getAnnotation(WebService.class) != null;
+ boolean isWebServiceProvider = container.getAnnotation(WebServiceProvider.class) !=
null;
+
+ return isWebService || isWebServiceProvider;
+ }
+
+ /**
+ * Sets ejb reference resolver. This method is invoked by MC.
+ *
+ * @param resolver ejb reference resolver
+ */
+ public void setEjbReferenceResolver(final EjbReferenceResolver resolver)
+ {
+ this.ejbReferenceResolver = resolver;
+ }
+
+ /**
+ * Gets ejb reference resolver.
+ *
+ * @return ejb reference resolver
+ */
+ public EjbReferenceResolver getEjbReferenceResolver()
+ {
+ if (this.ejbReferenceResolver == null)
+ {
+ throw new IllegalStateException("No EjbReferenceResolver set by MC");
+ }
+
+ return this.ejbReferenceResolver;
+ }
+
+}
Deleted:
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/metadata/ContainerMetaDataAdapter.java
===================================================================
---
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/metadata/ContainerMetaDataAdapter.java 2009-07-22
09:40:52 UTC (rev 10370)
+++
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/metadata/ContainerMetaDataAdapter.java 2009-07-23
09:54:16 UTC (rev 10371)
@@ -1,88 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.webservices.integration.metadata;
-
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.webservices.integration.ASIntegrationHelper;
-import org.jboss.wsf.spi.deployment.Deployment;
-import org.jboss.wsf.spi.metadata.j2ee.EJBArchiveMetaData;
-import org.jboss.wsf.spi.metadata.j2ee.JSEArchiveMetaData;
-
-/**
- * Build container independent deployment info.
- *
- * @author Thomas.Diesler(a)jboss.org
- * @author <a href="ropalka(a)redhat.com">Richard Opalka</a>
- */
-public class ContainerMetaDataAdapter
-{
-
- private EJBArchiveMetaDataAdapterEJB3 ejbMetaDataAdapterEJB3 = new
EJBArchiveMetaDataAdapterEJB3();
- private EJBArchiveMetaDataAdapterEJB21 ejbMetaDataAdapterEJB21 = new
EJBArchiveMetaDataAdapterEJB21();
- private JSEArchiveMetaDataAdapter webMetaDataAdapter = new
JSEArchiveMetaDataAdapter();
-
- public void setEjbMetaDataAdapterEJB21(EJBArchiveMetaDataAdapterEJB21 adapter)
- {
- this.ejbMetaDataAdapterEJB21 = adapter;
- }
-
- public void setEjbMetaDataAdapterEJB3(EJBArchiveMetaDataAdapterEJB3 adapter)
- {
- this.ejbMetaDataAdapterEJB3 = adapter;
- }
-
- public void setWebMetaDataAdapter(JSEArchiveMetaDataAdapter adapter)
- {
- this.webMetaDataAdapter = adapter;
- }
-
- public void buildContainerMetaData(Deployment dep, DeploymentUnit unit)
- {
- try
- {
- if ( ASIntegrationHelper.isPojoDeployment( unit ) )
- {
- JSEArchiveMetaData webMetaData = webMetaDataAdapter.buildMetaData(dep,
unit);
- dep.addAttachment(JSEArchiveMetaData.class, webMetaData);
- }
- else if ( ASIntegrationHelper.isJaxwsEjbDeployment(unit) )
- {
- EJBArchiveMetaData ejbMetaData = ejbMetaDataAdapterEJB3.buildMetaData(dep,
unit);
- dep.addAttachment(EJBArchiveMetaData.class, ejbMetaData);
- }
- else if ( ASIntegrationHelper.isJaxrpcEjbDeployment(unit) )
- {
- EJBArchiveMetaData ejbMetaData = ejbMetaDataAdapterEJB21.buildMetaData(dep,
unit);
- dep.addAttachment(EJBArchiveMetaData.class, ejbMetaData);
- }
- }
- catch (RuntimeException rte)
- {
- throw rte;
- }
- catch (Exception ex)
- {
- throw new IllegalStateException(ex);
- }
- }
-
-}
Added:
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/metadata/ContainerMetaDataBuilder.java
===================================================================
---
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/metadata/ContainerMetaDataBuilder.java
(rev 0)
+++
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/metadata/ContainerMetaDataBuilder.java 2009-07-23
09:54:16 UTC (rev 10371)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.webservices.integration.metadata;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.webservices.integration.util.Helper;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.metadata.j2ee.EJBArchiveMetaData;
+import org.jboss.wsf.spi.metadata.j2ee.JSEArchiveMetaData;
+
+/**
+ * Builds container independent deployment meta data.
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @author <a href="ropalka(a)redhat.com">Richard Opalka</a>
+ */
+public final class ContainerMetaDataBuilder
+{
+
+ private JSEMetaDataBuilder jseMetaDataBuilder = new JSEMetaDataBuilder();
+ private EJB3MetaDataBuilder ejb3MetaDataBuilder = new EJB3MetaDataBuilder();
+ private EJB21MetaDataBuilder ejb21MetaDataBuilder = new EJB21MetaDataBuilder();
+
+ public void create( final Deployment dep, final DeploymentUnit unit )
+ {
+ if ( Helper.isJseDeployment( unit ) )
+ {
+ final JSEArchiveMetaData jseMetaData = jseMetaDataBuilder.create( dep, unit );
+ dep.addAttachment( JSEArchiveMetaData.class, jseMetaData );
+ }
+ else if ( Helper.isJaxwsEjbDeployment( unit ) )
+ {
+ final EJBArchiveMetaData ejbMetaData = ejb3MetaDataBuilder.create( dep, unit );
+ dep.addAttachment( EJBArchiveMetaData.class, ejbMetaData );
+ }
+ else if ( Helper.isJaxrpcEjbDeployment( unit ) )
+ {
+ final EJBArchiveMetaData ejbMetaData = ejb21MetaDataBuilder.create( dep, unit
);
+ dep.addAttachment( EJBArchiveMetaData.class, ejbMetaData );
+ }
+ }
+
+}
Added:
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/metadata/ContainerMetaDataDeploymentAspect.java
===================================================================
---
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/metadata/ContainerMetaDataDeploymentAspect.java
(rev 0)
+++
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/metadata/ContainerMetaDataDeploymentAspect.java 2009-07-23
09:54:16 UTC (rev 10371)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.webservices.integration.metadata;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.deployment.DeploymentAspect;
+
+/**
+ * An aspect that builds container independent meta data.
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @author <a href="ropalka(a)redhat.com">Richard Opalka</a>
+ */
+public final class ContainerMetaDataDeploymentAspect extends DeploymentAspect
+{
+
+ private ContainerMetaDataBuilder metaDataBuilder;
+
+ public void setMetaDataBuilder( final ContainerMetaDataBuilder builder )
+ {
+ this.metaDataBuilder = builder;
+ }
+
+ @Override
+ public void start( final Deployment dep )
+ {
+ final DeploymentUnit unit = dep.getAttachment( DeploymentUnit.class );
+
+ this.metaDataBuilder.create( dep, unit );
+ }
+
+}
Added:
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/metadata/EJB21MetaDataBuilder.java
===================================================================
---
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/metadata/EJB21MetaDataBuilder.java
(rev 0)
+++
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/metadata/EJB21MetaDataBuilder.java 2009-07-23
09:54:16 UTC (rev 10371)
@@ -0,0 +1,174 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.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.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(a)jboss.org
+ * @author <a href="ropalka(a)redhat.com">Richard Opalka</a>
+ */
+final class EJB21MetaDataBuilder
+{
+
+ private static Logger log = Logger.getLogger(EJB21MetaDataBuilder.class);
+
+ EJBArchiveMetaData create(Deployment dep, DeploymentUnit unit)
+ {
+ JBossMetaData jbossMetaData = unit.getAttachment(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.setServiceEndpointInterface(???);
+ //targetBean.setJndiName(???);
+ targetBean.setLocalJndiName(jbossBeansMetaData.getLocalJndiName());
+
((MDBMetaData)targetBean).setDestinationJndiName(jbossMessageBean.getDestinationJndiName());
+ }
+
+ if (targetBean != null)
+ ejbBeans.add(targetBean);
+
+ return targetBean;
+ }
+}
Added:
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/metadata/EJB3MetaDataBuilder.java
===================================================================
---
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/metadata/EJB3MetaDataBuilder.java
(rev 0)
+++
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/metadata/EJB3MetaDataBuilder.java 2009-07-23
09:54:16 UTC (rev 10371)
@@ -0,0 +1,180 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.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.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(a)jboss.org
+ * @author <a href="ropalka(a)redhat.com">Richard Opalka</a>
+ */
+final class EJB3MetaDataBuilder
+{
+
+ private static Logger log = Logger.getLogger(EJB3MetaDataBuilder.class);
+
+ EJBArchiveMetaData create(Deployment dep, DeploymentUnit unit)
+ {
+ EJBArchiveMetaData umd = new EJBArchiveMetaData();
+
+ WebServiceDeployment webServiceDeployment =
dep.getAttachment(WebServiceDeployment.class);
+ buildEnterpriseBeansMetaData(umd, webServiceDeployment);
+
+ JBossMetaData jbMetaData = unit.getAttachment(JBossMetaData.class);
+ if (jbMetaData != null)
+ 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:
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/metadata/EJBArchiveMetaDataAdapterEJB21.java
===================================================================
---
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/metadata/EJBArchiveMetaDataAdapterEJB21.java 2009-07-22
09:40:52 UTC (rev 10370)
+++
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/metadata/EJBArchiveMetaDataAdapterEJB21.java 2009-07-23
09:54:16 UTC (rev 10371)
@@ -1,174 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.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.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;
-
-/**
- * Build container independent application meta data
- *
- * @author Thomas.Diesler(a)jboss.org
- * @since 05-May-2006
- */
-public class EJBArchiveMetaDataAdapterEJB21
-{
- // logging support
- private static Logger log = Logger.getLogger(EJBArchiveMetaDataAdapterEJB21.class);
-
- public EJBArchiveMetaData buildMetaData(Deployment dep, DeploymentUnit unit)
- {
- JBossMetaData jbossMetaData = unit.getAttachment(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.setServiceEndpointInterface(???);
- //targetBean.setJndiName(???);
- targetBean.setLocalJndiName(jbossBeansMetaData.getLocalJndiName());
-
((MDBMetaData)targetBean).setDestinationJndiName(jbossMessageBean.getDestinationJndiName());
- }
-
- if (targetBean != null)
- ejbBeans.add(targetBean);
-
- return targetBean;
- }
-}
Deleted:
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/metadata/EJBArchiveMetaDataAdapterEJB3.java
===================================================================
---
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/metadata/EJBArchiveMetaDataAdapterEJB3.java 2009-07-22
09:40:52 UTC (rev 10370)
+++
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/metadata/EJBArchiveMetaDataAdapterEJB3.java 2009-07-23
09:54:16 UTC (rev 10371)
@@ -1,180 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.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.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;
-
-/**
- * Build container independent application meta data
- *
- * @author Thomas.Diesler(a)jboss.org
- * @since 14-Apr-2007
- */
-public class EJBArchiveMetaDataAdapterEJB3
-{
- // logging support
- private static Logger log = Logger.getLogger(EJBArchiveMetaDataAdapterEJB3.class);
-
- public EJBArchiveMetaData buildMetaData(Deployment dep, DeploymentUnit unit)
- {
- EJBArchiveMetaData umd = new EJBArchiveMetaData();
-
- WebServiceDeployment webServiceDeployment =
dep.getAttachment(WebServiceDeployment.class);
- buildEnterpriseBeansMetaData(umd, webServiceDeployment);
-
- JBossMetaData jbMetaData = unit.getAttachment(JBossMetaData.class);
- if (jbMetaData != null)
- 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:
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/metadata/EJBBeanReferenceResolver.java
===================================================================
---
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/metadata/EJBBeanReferenceResolver.java 2009-07-22
09:40:52 UTC (rev 10370)
+++
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/metadata/EJBBeanReferenceResolver.java 2009-07-23
09:54:16 UTC (rev 10371)
@@ -1,114 +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.lang.reflect.Field;
-import java.lang.reflect.Method;
-
-import javax.ejb.EJB;
-
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.ejb3.common.resolvers.spi.EjbReference;
-import org.jboss.ejb3.common.resolvers.spi.EjbReferenceResolver;
-import org.jboss.wsf.common.injection.resolvers.AbstractReferenceResolver;
-
-/**
- * EJB reference resolver.
- *
- * @author <a href="mailto:richard.opalka@jboss.org">Richard
Opalka</a>
- */
-public final class EJBBeanReferenceResolver extends AbstractReferenceResolver<EJB>
-{
-
- /**
- * Deployment unit used for resolving process.
- */
- private final DeploymentUnit unit;
- /**
- * Delegate used to resolve JNDI names.
- */
- private final EjbReferenceResolver delegate;
-
- /**
- * Constructor.
- */
- public EJBBeanReferenceResolver(final DeploymentUnit unit, final EjbReferenceResolver
delegate)
- {
- super(EJB.class);
-
- if (unit == null)
- {
- throw new IllegalArgumentException("Deployment unit cannot be null");
- }
- if (delegate == null)
- {
- throw new IllegalArgumentException("Ejb reference resolver cannot be
null");
- }
-
- this.unit = unit;
- this.delegate = delegate;
- }
-
- /* (non-Javadoc)
- * @see
org.jboss.wsf.common.injection.resolvers.AbstractReferenceResolver#resolveField(java.lang.reflect.Field)
- */
- @Override
- protected String resolveField(final Field field)
- {
- final EJB ejbAnnotation = field.getAnnotation(EJB.class);
- final Class<?> type = field.getType();
- final EjbReference reference = getEjbReference(ejbAnnotation, type);
-
- return this.delegate.resolveEjb(unit, reference);
- }
-
- /* (non-Javadoc)
- * @see
org.jboss.wsf.common.injection.resolvers.AbstractReferenceResolver#resolveMethod(java.lang.reflect.Method)
- */
- @Override
- protected String resolveMethod(final Method method)
- {
- final EJB ejbAnnotation = method.getAnnotation(EJB.class);
- final Class<?> type = method.getParameterTypes()[0];
- final EjbReference reference = getEjbReference(ejbAnnotation, type);
-
- return this.delegate.resolveEjb(unit, reference);
- }
-
- /**
- * Constructs EjbReference.
- *
- * @param ejbAnnotation ejb annotation
- * @param type fall back type
- * @return ejb reference instance
- */
- private EjbReference getEjbReference(EJB ejbAnnotation, Class<?> type)
- {
- String beanInterface = ejbAnnotation.beanInterface().getName();
- if (java.lang.Object.class.getName().equals(beanInterface))
- {
- beanInterface = type.getName();
- }
- return new EjbReference(ejbAnnotation.beanName(), beanInterface,
ejbAnnotation.mappedName());
- }
-
-}
Deleted:
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/metadata/JSEArchiveMetaDataAdapter.java
===================================================================
---
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/metadata/JSEArchiveMetaDataAdapter.java 2009-07-22
09:40:52 UTC (rev 10370)
+++
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/metadata/JSEArchiveMetaDataAdapter.java 2009-07-23
09:54:16 UTC (rev 10371)
@@ -1,204 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.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.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;
-
-/**
- * Build container independent web meta data
- *
- * @author Thomas.Diesler(a)jboss.org
- * @since 05-May-2006
- */
-public class JSEArchiveMetaDataAdapter
-{
- // logging support
- private static Logger log = Logger.getLogger(JSEArchiveMetaDataAdapter.class);
-
- public JSEArchiveMetaData buildMetaData(Deployment dep, DeploymentUnit unit)
- {
- String contextRoot = null;
-
- JBossWebMetaData jbossWebMetaData = unit.getAttachment(JBossWebMetaData.class);
- dep.addAttachment(JBossWebMetaData.class, jbossWebMetaData);
-
- if (unit.getParent() != null)
- {
- JBossAppMetaData appmd =
unit.getParent().getAttachment(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;
- }
- };
- }
-
- protected 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:
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/metadata/JSEMetaDataBuilder.java
===================================================================
---
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/metadata/JSEMetaDataBuilder.java
(rev 0)
+++
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/metadata/JSEMetaDataBuilder.java 2009-07-23
09:54:16 UTC (rev 10371)
@@ -0,0 +1,205 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.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.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(a)jboss.org
+ * @author <a href="ropalka(a)redhat.com">Richard Opalka</a>
+ */
+final class JSEMetaDataBuilder
+{
+
+ private static Logger log = Logger.getLogger(JSEMetaDataBuilder.class);
+
+ JSEArchiveMetaData create(Deployment dep, DeploymentUnit unit)
+ {
+ String contextRoot = null;
+
+ JBossWebMetaData jbossWebMetaData = unit.getAttachment(JBossWebMetaData.class);
+ dep.addAttachment(JBossWebMetaData.class, jbossWebMetaData);
+
+ if (unit.getParent() != null)
+ {
+ JBossAppMetaData appmd =
unit.getParent().getAttachment(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;
+ }
+
+}
Deleted:
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/SecurityHandler.java
===================================================================
---
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/SecurityHandler.java 2009-07-22
09:40:52 UTC (rev 10370)
+++
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/SecurityHandler.java 2009-07-23
09:54:16 UTC (rev 10371)
@@ -1,40 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.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(a)jboss.org
- * @since 12-May-2006
- */
-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:
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/SecurityHandlerEJB21.java
===================================================================
---
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/SecurityHandlerEJB21.java 2009-07-22
09:40:52 UTC (rev 10370)
+++
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/SecurityHandlerEJB21.java 2009-07-23
09:54:16 UTC (rev 10371)
@@ -1,66 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.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.spi.deployment.Deployment;
-import org.jboss.wsf.spi.metadata.j2ee.EJBArchiveMetaData;
-
-/**
- * Handle web app security meta data for EJB21
- *
- * @author Thomas.Diesler(a)jboss.org
- * @since 12-May-2006
- */
-public class SecurityHandlerEJB21 implements SecurityHandler
-{
- public void addSecurityDomain(JBossWebMetaData jbossWeb, Deployment dep)
- {
- EJBArchiveMetaData ejbMetaData = dep.getAttachment(EJBArchiveMetaData.class);
- if (ejbMetaData == null)
- throw new IllegalStateException("Cannot obtain application meta
data");
-
- 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 = dep.getAttachment(JBossMetaData.class);
- IAssemblyDescriptorMetaData assemblyDescriptor = jbmd.getAssemblyDescriptor();
- if (assemblyDescriptor != null)
- {
- SecurityRolesMetaData securityRoles = assemblyDescriptor.getSecurityRoles();
- if (securityRoles != null)
- webApp.setSecurityRoles(securityRoles);
- }
- }
-}
Deleted:
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/SecurityHandlerEJB3.java
===================================================================
---
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/SecurityHandlerEJB3.java 2009-07-22
09:40:52 UTC (rev 10370)
+++
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/SecurityHandlerEJB3.java 2009-07-23
09:54:16 UTC (rev 10371)
@@ -1,97 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.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.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(a)jboss.org
- * @since 12-May-2006
- */
-public class SecurityHandlerEJB3 implements SecurityHandler
-{
- public void addSecurityDomain(JBossWebMetaData jbossWeb, Deployment dep)
- {
- String securityDomain = null;
-
- WebServiceDeployment webServiceDeployment =
dep.getAttachment(WebServiceDeployment.class);
- if (webServiceDeployment != 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 =
dep.getAttachment(WebServiceDeployment.class);
- if (webServiceDeployment != null)
- {
- 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);
- }
- }
- }
- }
- }
-}
Deleted:
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/WebMetaDataModifier.java
===================================================================
---
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/WebMetaDataModifier.java 2009-07-22
09:40:52 UTC (rev 10370)
+++
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/WebMetaDataModifier.java 2009-07-23
09:54:16 UTC (rev 10371)
@@ -1,38 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.webservices.integration.tomcat;
-
-import org.jboss.wsf.spi.deployment.Deployment;
-
-/**
- * Modifies the web app according to the stack requirements.
- *
- * @author Thomas.Diesler(a)jboss.org
- * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
- */
-public interface WebMetaDataModifier
-{
- static String PROPERTY_WEBAPP_CONTEXT_PARAMETERS =
"org.jboss.ws.webapp.ContextParameterMap";
- static String PROPERTY_WEBAPP_SERVLET_CLASS =
"org.jboss.ws.webapp.ServletClass";
-
- void modifyMetaData( Deployment dep );
-}
Deleted:
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/WebMetaDataModifierImpl.java
===================================================================
---
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/WebMetaDataModifierImpl.java 2009-07-22
09:40:52 UTC (rev 10370)
+++
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/WebMetaDataModifierImpl.java 2009-07-23
09:54:16 UTC (rev 10371)
@@ -1,178 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.webservices.integration.tomcat;
-
-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.ListenerMetaData;
-import org.jboss.wsf.spi.deployment.Deployment;
-import org.jboss.wsf.spi.deployment.Endpoint;
-
-import javax.xml.ws.WebServiceException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-/**
- * The rewriter for web.xml
- *
- * @author Thomas.Diesler(a)jboss.org
- * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
- */
-public class WebMetaDataModifierImpl implements WebMetaDataModifier
-{
- // logging support
- private static Logger log = Logger.getLogger(WebMetaDataModifierImpl.class);
-
- public void modifyMetaData(Deployment dep)
- {
- JBossWebMetaData jbwmd = dep.getAttachment(JBossWebMetaData.class);
- if (jbwmd == null)
- throw new WebServiceException("Cannot find web meta data");
-
- try
- {
- modifyMetaData(dep, jbwmd);
- }
- catch (RuntimeException rte)
- {
- throw rte;
- }
- catch (Exception e)
- {
- throw new WebServiceException(e);
- }
- }
-
- private void modifyMetaData(Deployment dep, JBossWebMetaData jbwmd) throws
ClassNotFoundException
- {
- String servletClass = (String)dep.getProperty(PROPERTY_WEBAPP_SERVLET_CLASS);
- if (servletClass == null)
- throw new IllegalStateException("Cannot obtain context property: " +
PROPERTY_WEBAPP_SERVLET_CLASS);
-
- Map<String, String> depCtxParams = (Map<String,
String>)dep.getProperty(PROPERTY_WEBAPP_CONTEXT_PARAMETERS);
- if (depCtxParams != null)
- {
- List<ParamValueMetaData> contextParams = jbwmd.getContextParams();
- if (contextParams == null)
- {
- contextParams = new ArrayList<ParamValueMetaData>();
- jbwmd.setContextParams(contextParams);
- }
-
- for (Map.Entry<String, String> entry : depCtxParams.entrySet())
- {
- ParamValueMetaData param = new ParamValueMetaData();
- param.setParamName(entry.getKey());
- param.setParamValue(entry.getValue());
- contextParams.add(param);
- }
- }
-
- for (Iterator it = jbwmd.getServlets().iterator(); it.hasNext();)
- {
- JBossServletMetaData servlet = (JBossServletMetaData)it.next();
- List<ParamValueMetaData> initParams = servlet.getInitParam();
- if (initParams == null)
- {
- initParams = new ArrayList<ParamValueMetaData>();
- servlet.setInitParam(initParams);
- }
-
- String linkName = servlet.getServletName();
-
- // find the servlet-class
- String orgServletClassName = servlet.getServletClass();
-
- // JSP
- if (orgServletClassName == null)
- continue;
-
- // Get the servlet class
- Class orgServletClass = null;
- try
- {
- ClassLoader loader = dep.getInitialClassLoader();
- orgServletClass = loader.loadClass(orgServletClassName);
- }
- catch (ClassNotFoundException ex)
- {
- log.warn("Cannot load servlet class: " + orgServletClassName);
- }
-
- String targetBeanName = null;
-
- // Nothing to do if we have an <init-param>
- if (isAlreadyModified(servlet))
- {
- for (ParamValueMetaData initParam : initParams)
- {
- String paramName = initParam.getParamName();
- String paramValue = initParam.getParamValue();
- if (Endpoint.SEPID_DOMAIN_ENDPOINT.equals(paramName))
- {
- targetBeanName = paramValue;
- }
- }
- }
- else
- {
- // Check if it is a real servlet that we can ignore
- if (orgServletClass != null &&
javax.servlet.Servlet.class.isAssignableFrom(orgServletClass))
- {
- log.info("Ignore servlet: " + orgServletClassName);
- continue;
- }
-
- servlet.setServletClass(servletClass);
-
- // add additional init params
- if (orgServletClassName.equals(servletClass) == false)
- {
- targetBeanName = orgServletClassName;
- ParamValueMetaData initParam = new ParamValueMetaData();
- initParam.setParamName(Endpoint.SEPID_DOMAIN_ENDPOINT);
- initParam.setParamValue(targetBeanName);
- initParams.add(initParam);
- }
- }
-
- if (targetBeanName == null)
- throw new IllegalStateException("Cannot obtain service endpoint bean
for: " + linkName);
- }
- }
-
- // Return true if the web.xml is already modified
- private boolean isAlreadyModified(JBossServletMetaData servlet)
- {
- for (ParamValueMetaData initParam : servlet.getInitParam())
- {
- String paramName = initParam.getParamName();
- if (Endpoint.SEPID_DOMAIN_ENDPOINT.equals(paramName))
- return true;
- }
- return false;
- }
-}
Added:
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/ejb/SecurityHandler.java
===================================================================
---
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/ejb/SecurityHandler.java
(rev 0)
+++
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/ejb/SecurityHandler.java 2009-07-23
09:54:16 UTC (rev 10371)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.webservices.integration.tomcat.ejb;
+
+import org.jboss.metadata.web.jboss.JBossWebMetaData;
+import org.jboss.wsf.spi.deployment.Deployment;
+
+/**
+ * Handle web app security meta data
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 12-May-2006
+ */
+public interface SecurityHandler
+{
+ /** Add the security domain to jboss-web.xml */
+ void addSecurityDomain(JBossWebMetaData jbossWeb, Deployment dep);
+
+ /** Add the security roles to web.xml */
+ void addSecurityRoles(JBossWebMetaData webApp, Deployment dep);
+}
Added:
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/ejb/SecurityHandlerEJB21.java
===================================================================
---
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/ejb/SecurityHandlerEJB21.java
(rev 0)
+++
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/ejb/SecurityHandlerEJB21.java 2009-07-23
09:54:16 UTC (rev 10371)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.webservices.integration.tomcat.ejb;
+
+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.spi.deployment.Deployment;
+import org.jboss.wsf.spi.metadata.j2ee.EJBArchiveMetaData;
+
+/**
+ * Handle web app security meta data for EJB21
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 12-May-2006
+ */
+public class SecurityHandlerEJB21 implements SecurityHandler
+{
+ public void addSecurityDomain(JBossWebMetaData jbossWeb, Deployment dep)
+ {
+ EJBArchiveMetaData ejbMetaData = dep.getAttachment(EJBArchiveMetaData.class);
+ if (ejbMetaData == null)
+ throw new IllegalStateException("Cannot obtain application meta
data");
+
+ 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 = dep.getAttachment(JBossMetaData.class);
+ IAssemblyDescriptorMetaData assemblyDescriptor = jbmd.getAssemblyDescriptor();
+ if (assemblyDescriptor != null)
+ {
+ SecurityRolesMetaData securityRoles = assemblyDescriptor.getSecurityRoles();
+ if (securityRoles != null)
+ webApp.setSecurityRoles(securityRoles);
+ }
+ }
+}
Added:
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/ejb/SecurityHandlerEJB3.java
===================================================================
---
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/ejb/SecurityHandlerEJB3.java
(rev 0)
+++
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/ejb/SecurityHandlerEJB3.java 2009-07-23
09:54:16 UTC (rev 10371)
@@ -0,0 +1,97 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.webservices.integration.tomcat.ejb;
+
+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.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(a)jboss.org
+ * @since 12-May-2006
+ */
+public class SecurityHandlerEJB3 implements SecurityHandler
+{
+ public void addSecurityDomain(JBossWebMetaData jbossWeb, Deployment dep)
+ {
+ String securityDomain = null;
+
+ WebServiceDeployment webServiceDeployment =
dep.getAttachment(WebServiceDeployment.class);
+ if (webServiceDeployment != 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 =
dep.getAttachment(WebServiceDeployment.class);
+ if (webServiceDeployment != null)
+ {
+ 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:
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/ejb/WebAppGeneratorDeploymentAspect.java
===================================================================
---
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/ejb/WebAppGeneratorDeploymentAspect.java
(rev 0)
+++
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/ejb/WebAppGeneratorDeploymentAspect.java 2009-07-23
09:54:16 UTC (rev 10371)
@@ -0,0 +1,285 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.webservices.integration.tomcat.ejb;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+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.spi.annotation.WebContext;
+import org.jboss.wsf.spi.deployment.ArchiveDeployment;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.deployment.DeploymentAspect;
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.deployment.WSFDeploymentException;
+import org.jboss.wsf.spi.deployment.Deployment.DeploymentType;
+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(a)jboss.org
+ * @since 13-Oct-2007
+ */
+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 DeploymentType deploymentType = dep.getType();
+
+ if (DeploymentType.JAXRPC_EJB21.equals(deploymentType))
+ {
+ JBossWebMetaData jbwmd = generateWebDeployment(dep, securityHandlerEJB21);
+ dep.addAttachment(JBossWebMetaData.class, jbwmd);
+ }
+ else if (DeploymentType.JAXWS_EJB3.equals(deploymentType))
+ {
+ JBossWebMetaData jbwmd = generateWebDeployment(dep, securityHandlerEJB3);
+ dep.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 = dep.getAttachment(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:
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/jse/WebAppDeploymentAspect.java
===================================================================
---
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/jse/WebAppDeploymentAspect.java
(rev 0)
+++
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/jse/WebAppDeploymentAspect.java 2009-07-23
09:54:16 UTC (rev 10371)
@@ -0,0 +1,106 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.webservices.integration.tomcat.jse;
+
+import javax.security.jacc.PolicyConfiguration;
+import javax.security.jacc.PolicyConfigurationFactory;
+import org.jboss.web.WebPermissionMapping;
+
+import javax.xml.ws.WebServiceException;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.metadata.web.jboss.JBossWebMetaData;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.deployment.DeploymentAspect;
+import org.jboss.wsf.spi.deployment.WSFDeploymentException;
+
+/**
+ * Deploy the generated webapp to JBoss
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @author Anil.Saldhana(a)jboss.com
+ * @since 12-May-2006
+ */
+public class WebAppDeploymentAspect extends DeploymentAspect
+{
+ private WebMetaDataModifier webMetaDataModifier;
+
+ public void setWebMetaDataModifier(WebMetaDataModifier webMetaDataModifier)
+ {
+ this.webMetaDataModifier = webMetaDataModifier;
+ }
+
+ public void start(Deployment dep)
+ {
+ JBossWebMetaData jbwmd = dep.getAttachment(JBossWebMetaData.class);
+ if (jbwmd == null)
+ throw new WebServiceException("Cannot find web meta data");
+
+ DeploymentUnit unit = dep.getAttachment(DeploymentUnit.class);
+ if (unit != null)
+ {
+ try
+ {
+ webMetaDataModifier.modifyMetaData(dep);
+
+ try
+ {
+ generateJACCPermissions(dep.getSimpleName(), jbwmd); // TODO: make it
another deployment aspect
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Exception generating JACC
perms:",e);
+ }
+
+ // Attaching it to the DeploymentUnit will cause a new webapp deployment
+ unit.addAttachment(JBossWebMetaData.class, jbwmd);
+ }
+ catch (Exception ex)
+ {
+ WSFDeploymentException.rethrow(ex);
+ }
+ }
+ else
+ {
+ throw new IllegalStateException("Cannot obtain deployment unit");
+ }
+ }
+
+ /**
+ * JBAS-5935: The dynamic web application generated by the JBossWS
+ * does not go through the war security deployer. Hence the JACC
+ * permissions are not created. There is a need to explicitly create
+ * the war jacc permissions.
+ * @param depName
+ * @param jbwmd
+ * @throws Exception
+ */
+ protected void generateJACCPermissions(String depName, JBossWebMetaData jbwmd)
+ throws Exception
+ {
+ PolicyConfigurationFactory policyConfigurationFactory =
+ PolicyConfigurationFactory.getPolicyConfigurationFactory();
+ PolicyConfiguration policyConfiguration =
+ policyConfigurationFactory.getPolicyConfiguration(depName, false);
+ WebPermissionMapping.createPermissions(jbwmd, policyConfiguration);
+ policyConfiguration.commit();
+ }
+}
Added:
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/jse/WebMetaDataModifier.java
===================================================================
---
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/jse/WebMetaDataModifier.java
(rev 0)
+++
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/jse/WebMetaDataModifier.java 2009-07-23
09:54:16 UTC (rev 10371)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.webservices.integration.tomcat.jse;
+
+import org.jboss.wsf.spi.deployment.Deployment;
+
+/**
+ * Modifies the web app according to the stack requirements.
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
+ */
+public interface WebMetaDataModifier
+{
+ static String PROPERTY_WEBAPP_CONTEXT_PARAMETERS =
"org.jboss.ws.webapp.ContextParameterMap";
+ static String PROPERTY_WEBAPP_SERVLET_CLASS =
"org.jboss.ws.webapp.ServletClass";
+
+ void modifyMetaData( Deployment dep );
+}
Added:
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/jse/WebMetaDataModifierImpl.java
===================================================================
---
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/jse/WebMetaDataModifierImpl.java
(rev 0)
+++
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/tomcat/jse/WebMetaDataModifierImpl.java 2009-07-23
09:54:16 UTC (rev 10371)
@@ -0,0 +1,178 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.webservices.integration.tomcat.jse;
+
+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.ListenerMetaData;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.deployment.Endpoint;
+
+import javax.xml.ws.WebServiceException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * The rewriter for web.xml
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
+ */
+public class WebMetaDataModifierImpl implements WebMetaDataModifier
+{
+ // logging support
+ private static Logger log = Logger.getLogger(WebMetaDataModifierImpl.class);
+
+ public void modifyMetaData(Deployment dep)
+ {
+ JBossWebMetaData jbwmd = dep.getAttachment(JBossWebMetaData.class);
+ if (jbwmd == null)
+ throw new WebServiceException("Cannot find web meta data");
+
+ try
+ {
+ modifyMetaData(dep, jbwmd);
+ }
+ catch (RuntimeException rte)
+ {
+ throw rte;
+ }
+ catch (Exception e)
+ {
+ throw new WebServiceException(e);
+ }
+ }
+
+ private void modifyMetaData(Deployment dep, JBossWebMetaData jbwmd) throws
ClassNotFoundException
+ {
+ String servletClass = (String)dep.getProperty(PROPERTY_WEBAPP_SERVLET_CLASS);
+ if (servletClass == null)
+ throw new IllegalStateException("Cannot obtain context property: " +
PROPERTY_WEBAPP_SERVLET_CLASS);
+
+ Map<String, String> depCtxParams = (Map<String,
String>)dep.getProperty(PROPERTY_WEBAPP_CONTEXT_PARAMETERS);
+ if (depCtxParams != null)
+ {
+ List<ParamValueMetaData> contextParams = jbwmd.getContextParams();
+ if (contextParams == null)
+ {
+ contextParams = new ArrayList<ParamValueMetaData>();
+ jbwmd.setContextParams(contextParams);
+ }
+
+ for (Map.Entry<String, String> entry : depCtxParams.entrySet())
+ {
+ ParamValueMetaData param = new ParamValueMetaData();
+ param.setParamName(entry.getKey());
+ param.setParamValue(entry.getValue());
+ contextParams.add(param);
+ }
+ }
+
+ for (Iterator it = jbwmd.getServlets().iterator(); it.hasNext();)
+ {
+ JBossServletMetaData servlet = (JBossServletMetaData)it.next();
+ List<ParamValueMetaData> initParams = servlet.getInitParam();
+ if (initParams == null)
+ {
+ initParams = new ArrayList<ParamValueMetaData>();
+ servlet.setInitParam(initParams);
+ }
+
+ String linkName = servlet.getServletName();
+
+ // find the servlet-class
+ String orgServletClassName = servlet.getServletClass();
+
+ // JSP
+ if (orgServletClassName == null)
+ continue;
+
+ // Get the servlet class
+ Class orgServletClass = null;
+ try
+ {
+ ClassLoader loader = dep.getInitialClassLoader();
+ orgServletClass = loader.loadClass(orgServletClassName);
+ }
+ catch (ClassNotFoundException ex)
+ {
+ log.warn("Cannot load servlet class: " + orgServletClassName);
+ }
+
+ String targetBeanName = null;
+
+ // Nothing to do if we have an <init-param>
+ if (isAlreadyModified(servlet))
+ {
+ for (ParamValueMetaData initParam : initParams)
+ {
+ String paramName = initParam.getParamName();
+ String paramValue = initParam.getParamValue();
+ if (Endpoint.SEPID_DOMAIN_ENDPOINT.equals(paramName))
+ {
+ targetBeanName = paramValue;
+ }
+ }
+ }
+ else
+ {
+ // Check if it is a real servlet that we can ignore
+ if (orgServletClass != null &&
javax.servlet.Servlet.class.isAssignableFrom(orgServletClass))
+ {
+ log.info("Ignore servlet: " + orgServletClassName);
+ continue;
+ }
+
+ servlet.setServletClass(servletClass);
+
+ // add additional init params
+ if (orgServletClassName.equals(servletClass) == false)
+ {
+ targetBeanName = orgServletClassName;
+ ParamValueMetaData initParam = new ParamValueMetaData();
+ initParam.setParamName(Endpoint.SEPID_DOMAIN_ENDPOINT);
+ initParam.setParamValue(targetBeanName);
+ initParams.add(initParam);
+ }
+ }
+
+ if (targetBeanName == null)
+ throw new IllegalStateException("Cannot obtain service endpoint bean
for: " + linkName);
+ }
+ }
+
+ // Return true if the web.xml is already modified
+ private boolean isAlreadyModified(JBossServletMetaData servlet)
+ {
+ for (ParamValueMetaData initParam : servlet.getInitParam())
+ {
+ String paramName = initParam.getParamName();
+ if (Endpoint.SEPID_DOMAIN_ENDPOINT.equals(paramName))
+ return true;
+ }
+ return false;
+ }
+}
Added:
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/util/Helper.java
===================================================================
---
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/util/Helper.java
(rev 0)
+++
container/jboss50/branches/ropalka-jboss510/src/main/java/org/jboss/webservices/integration/util/Helper.java 2009-07-23
09:54:16 UTC (rev 10371)
@@ -0,0 +1,290 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.webservices.integration.util;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.jws.WebService;
+import javax.servlet.Servlet;
+import javax.xml.ws.WebServiceProvider;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.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.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.deployment.Deployment.DeploymentType;
+import org.jboss.wsf.spi.deployment.integration.WebServiceDeclaration;
+import org.jboss.wsf.spi.deployment.integration.WebServiceDeployment;
+
+/**
+ * JBoss AS integration helper class.
+ *
+ * @author <a href="ropalka(a)redhat.com">Richard Opalka</a>
+ */
+public final class Helper
+{
+
+ /*
+ * TODO: implement methods
+ * * getRequiredAttachment( DeploymentUnit unit, Class<?> attachmentType )
+ * * getRequiredAttachment( Deployment dep, Class<?> attachmentType )
+ * both methods should throw exception if attachment not found
+ * * getOptionalAttachment( DeploymentUnit unit, Class<?> attachmentType )
+ * * getOptionalAttachment( Deployment dep, Class<?> attachmentType )
+ * both methods will return null if attachment will not be found.
+ */
+
+ /** Logger. */
+ private static final Logger log = Logger.getLogger( Helper.class );
+
+ /**
+ * Forbidden constructor.
+ */
+ private Helper()
+ {
+ super();
+ }
+
+ public static boolean isWebServiceDeployment( final DeploymentUnit unit )
+ {
+ return unit.getAttachment( DeploymentType.class ) != null;
+ }
+
+ public static boolean isJseDeployment( final DeploymentUnit unit )
+ {
+ if ( Helper.isWebServiceDeployment( unit ) )
+ {
+ final DeploymentType deploymentType = unit.getAttachment( DeploymentType.class
);
+ final boolean isJaxrpcJse = DeploymentType.JAXRPC_JSE.equals( deploymentType );
+ final boolean isJaxwsJse = DeploymentType.JAXWS_JSE.equals( deploymentType );
+
+ return isJaxwsJse || isJaxrpcJse;
+ }
+
+ return false;
+ }
+
+ public static boolean isEjbDeployment( final DeploymentUnit unit )
+ {
+ if ( Helper.isWebServiceDeployment( unit ) )
+ {
+ final DeploymentType deploymentType = unit.getAttachment( DeploymentType.class
);
+ final boolean isJaxwsEjb3 = DeploymentType.JAXWS_EJB3.equals( deploymentType );
+ final boolean isJaxrpcEjb21 = DeploymentType.JAXRPC_EJB21.equals( deploymentType
);
+
+ return isJaxwsEjb3 || isJaxrpcEjb21;
+ }
+
+ return false;
+ }
+
+ public static boolean isJaxwsDeployment( final DeploymentUnit unit )
+ {
+ if ( Helper.isWebServiceDeployment( unit ) )
+ {
+ final DeploymentType deploymentType = unit.getAttachment( DeploymentType.class
);
+ final boolean isJaxwsEjb3 = DeploymentType.JAXWS_EJB3.equals( deploymentType );
+ final boolean isJaxwsJse = DeploymentType.JAXWS_JSE.equals( deploymentType );
+
+ return isJaxwsEjb3 || isJaxwsJse;
+ }
+
+ return false;
+ }
+
+ public static boolean isJaxrpcDeployment( final DeploymentUnit unit )
+ {
+ if ( Helper.isWebServiceDeployment( unit ) )
+ {
+ final DeploymentType deploymentType = unit.getAttachment( DeploymentType.class
);
+ final boolean isJaxrpcEjb21 = DeploymentType.JAXRPC_EJB21.equals( deploymentType
);
+ final boolean isJaxrpcJse = DeploymentType.JAXRPC_JSE.equals( deploymentType );
+
+ return isJaxrpcEjb21 || isJaxrpcJse;
+ }
+
+ return false;
+ }
+
+ public static boolean isJaxrpcJseDeployment( final DeploymentUnit unit )
+ {
+ final boolean isJaxrpc = Helper.isJaxrpcDeployment( unit );
+ final boolean isJse = Helper.isJseDeployment( unit );
+
+ return isJse && isJaxrpc;
+ }
+
+ public static boolean isJaxwsJseDeployment( final DeploymentUnit unit )
+ {
+ final boolean isJaxws = Helper.isJaxwsDeployment( unit );
+ final boolean isJse = Helper.isJseDeployment( unit );
+
+ return isJse && isJaxws;
+ }
+
+ public static boolean isJaxrpcEjbDeployment( final DeploymentUnit unit )
+ {
+ final boolean isJaxrpc = Helper.isJaxrpcDeployment( unit );
+ final boolean isEjb = Helper.isEjbDeployment( unit );
+
+ return isEjb && isJaxrpc;
+ }
+
+ public static boolean isJaxwsEjbDeployment( final DeploymentUnit unit )
+ {
+ final boolean isJaxws = Helper.isJaxwsDeployment( unit );
+ final boolean isEjb = Helper.isEjbDeployment( unit );
+
+ return isEjb && isJaxws;
+ }
+
+ public static final boolean isWebServiceBean( final WebServiceDeclaration
ejbContainerAdapter )
+ {
+ boolean isWebServiceBean = false;
+ boolean isWebService = ejbContainerAdapter.getAnnotation(WebService.class) !=
null;
+ boolean isWebServiceProvider =
ejbContainerAdapter.getAnnotation(WebServiceProvider.class) != null;
+ isWebServiceBean = isWebService || isWebServiceProvider;
+
+ return isWebServiceBean;
+ }
+
+ public static final boolean isEjb3Deployment( final DeploymentUnit unit )
+ {
+ final WebServiceDeployment wsDeployment = unit.getAttachment(
WebServiceDeployment.class );
+
+ Iterator<WebServiceDeclaration> it =
wsDeployment.getServiceEndpoints().iterator();
+ while (it.hasNext())
+ {
+ WebServiceDeclaration container = it.next();
+ if (Helper.isWebServiceBean(container))
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ public static final List<ServletMetaData> getJaxwsServlets( final DeploymentUnit
unit )
+ {
+ return Helper.getRelevantServlets( unit, true );
+ }
+
+ public static List<ServletMetaData> getJaxrpcServlets( final DeploymentUnit unit
)
+ {
+ return Helper.getRelevantServlets( unit, false );
+ }
+
+ private static final List< ServletMetaData > getRelevantServlets( final
DeploymentUnit unit, final boolean jaxws )
+ {
+ try
+ {
+ final JBossWebMetaData jbossWebMD = unit.getAttachment(JBossWebMetaData.class);
+ final ClassLoader loader = unit.getClassLoader();
+
+ List<ServletMetaData> endpoints = new ArrayList<ServletMetaData>();
+ for (ServletMetaData servlet : jbossWebMD.getServlets())
+ {
+ String servletClassName = getTargetBean(servlet);
+
+ // Skip JSPs
+ if (servletClassName == null || servletClassName.length() == 0)
+ continue;
+
+ try
+ {
+ Class<?> servletClass = loader.loadClass(servletClassName.trim());
+ boolean isServlet = servletClass.isAssignableFrom(Servlet.class);
+ if (false == isServlet)
+ {
+ boolean isWebService =
servletClass.isAnnotationPresent(WebService.class);
+ boolean isWebServiceProvider =
servletClass.isAnnotationPresent(WebServiceProvider.class);
+ if ( jaxws )
+ {
+ if (isWebService || isWebServiceProvider)
+ {
+ endpoints.add(servlet); // jaxws endpoint
+ }
+ }
+ else
+ {
+ if (!isWebService && !isWebServiceProvider)
+ {
+ endpoints.add(servlet); // jaxrpc endpoint
+ }
+ }
+ }
+ }
+ catch (ClassNotFoundException ex)
+ {
+ log.warn("Cannot load servlet class: " + servletClassName);
+ continue;
+ }
+ }
+
+ return endpoints;
+ }
+ catch (Exception ex)
+ {
+ log.error("Cannot process web deployment", ex);
+ return Collections.emptyList();
+ }
+ }
+
+ public static String getTargetBean(ServletMetaData servlet)
+ {
+ String endpointClass = servlet.getServletClass();
+ List<ParamValueMetaData> initParams = servlet.getInitParam();
+ if (initParams != null)
+ {
+ for (ParamValueMetaData param : initParams)
+ {
+ if (Endpoint.SEPID_DOMAIN_ENDPOINT.equals(param.getParamName()))
+ {
+ endpointClass = param.getParamValue();
+ break;
+ }
+ }
+ }
+ return endpointClass;
+ }
+
+ public static ServletMetaData getServletForName( final JBossWebMetaData jbossWebMD,
final String servletName )
+ {
+ for ( JBossServletMetaData servlet : jbossWebMD.getServlets() )
+ {
+ if ( servlet.getName().equals( servletName ) )
+ {
+ return servlet;
+ }
+ }
+
+ throw new IllegalStateException( "Cannot find servlet for link: " +
servletName );
+ }
+
+}
Modified:
container/jboss50/branches/ropalka-jboss510/src/main/resources/jbossws-jboss50.deployer/META-INF/stack-agnostic-jboss-beans.xml
===================================================================
---
container/jboss50/branches/ropalka-jboss510/src/main/resources/jbossws-jboss50.deployer/META-INF/stack-agnostic-jboss-beans.xml 2009-07-22
09:40:52 UTC (rev 10370)
+++
container/jboss50/branches/ropalka-jboss510/src/main/resources/jbossws-jboss50.deployer/META-INF/stack-agnostic-jboss-beans.xml 2009-07-23
09:54:16 UTC (rev 10371)
@@ -13,7 +13,7 @@
</bean>
<!-- An abstraction of server configuration aspects. -->
- <bean name="WSServerConfig"
class="org.jboss.webservices.integration.deployers.ServerConfigImpl">
+ <bean name="WSServerConfig"
class="org.jboss.webservices.integration.config.ServerConfigImpl">
<property name="mbeanServer"><inject
bean="WSMBeanServerLocator"
property="mbeanServer"/></property>
<!--
@@ -53,13 +53,30 @@
<property name="relativeOrder">2</property> <!--
[JBDEPLOY-201] workaround -->
</bean>
+ <!-- WSDeploymentAspectDeployers factory -->
+ <bean name="WSDeployersFactory"
class="org.jboss.webservices.integration.deployers.WSDeployersFactory">
+ <constructor>
+ <parameter>
+ <inject bean="Deployers"/>
+ </parameter>
+ </constructor>
+ <incallback method="newDeployer"/>
+ </bean>
+
+ <!-- Deployment aspect helper beans -->
+ <bean name="WSSecurityHandlerEJB21"
class="org.jboss.webservices.integration.tomcat.ejb.SecurityHandlerEJB21"/>
+ <bean name="WSSecurityHandlerEJB3"
class="org.jboss.webservices.integration.tomcat.ejb.SecurityHandlerEJB3"/>
+ <bean name="WSWebMetaDataModifier"
class="org.jboss.webservices.integration.tomcat.jse.WebMetaDataModifierImpl"/>
+ <bean name="WSContainerMetaDataBuilder"
class="org.jboss.webservices.integration.metadata.ContainerMetaDataBuilder"/>
+
<!-- The AS specific deployment aspects -->
- <bean name="WSContainerMetaDataDeploymentAspect"
class="org.jboss.webservices.integration.aspects.ContainerMetaDataDeploymentAspect">
+ <bean name="WSContainerMetaDataDeploymentAspect"
class="org.jboss.webservices.integration.metadata.ContainerMetaDataDeploymentAspect">
<property name="provides">ContainerMetaData,
VFSRoot</property>
+ <property name="metaDataBuilder"><inject
bean="WSContainerMetaDataBuilder"/></property>
<property name="relativeOrder">12</property> <!--
[JBDEPLOY-201] workaround -->
</bean>
- <bean name="WSInjectionMetaDataDeploymentAspect"
class="org.jboss.webservices.integration.aspects.InjectionMetaDataDeploymentAspect">
+ <bean name="WSInjectionMetaDataDeploymentAspect"
class="org.jboss.webservices.integration.injection.InjectionMetaDataDeploymentAspect">
<property name="requires">WebMetaData</property>
<property name="provides">InjectionMetaData</property>
<property name="ejbReferenceResolver"><inject
bean="org.jboss.ejb3.EjbReferenceResolver"/></property>
@@ -86,8 +103,8 @@
<bean name="WSEndpointLifecycleDeploymentAspect"
class="org.jboss.wsf.framework.deployment.EndpointLifecycleDeploymentAspect">
<property name="provides">LifecycleHandler</property>
+ <property name="last">true</property>
<property name="relativeOrder">37</property> <!--
[JBDEPLOY-201] workaround -->
- <property name="last">true</property>
</bean>
<bean name="WSEndpointMetricsDeploymentAspect"
class="org.jboss.wsf.framework.deployment.EndpointMetricsDeploymentAspect">
@@ -113,14 +130,14 @@
<property name="relativeOrder">15</property> <!--
[JBDEPLOY-201] workaround -->
</bean>
- <bean name="WSWebAppDeploymentAspect"
class="org.jboss.webservices.integration.aspects.WebAppDeploymentAspect">
+ <bean name="WSWebAppDeploymentAspect"
class="org.jboss.webservices.integration.tomcat.jse.WebAppDeploymentAspect">
<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.aspects.WebAppGeneratorDeploymentAspect">
+ <bean name="WSWebAppGeneratorDeploymentAspect"
class="org.jboss.webservices.integration.tomcat.ejb.WebAppGeneratorDeploymentAspect">
<property name="requires">VirtualHosts,URLPattern</property>
<property name="provides">WebMetaData</property>
<property name="securityHandlerEJB21"><inject
bean="WSSecurityHandlerEJB21"/></property>
@@ -128,19 +145,4 @@
<property name="relativeOrder">32</property> <!--
[JBDEPLOY-201] workaround -->
</bean>
- <!-- WSDeploymentAspectDeployers factory -->
- <bean name="WSDeployersFactory"
class="org.jboss.webservices.integration.deployers.WSDeployersFactory">
- <constructor>
- <parameter
class="org.jboss.deployers.plugins.deployers.DeployersImpl">
- <inject bean="Deployers"/>
- </parameter>
- </constructor>
- <incallback method="newDeployer"/>
- </bean>
-
- <!-- Deployment aspect helper beans -->
- <bean name="WSSecurityHandlerEJB21"
class="org.jboss.webservices.integration.tomcat.SecurityHandlerEJB21"/>
- <bean name="WSSecurityHandlerEJB3"
class="org.jboss.webservices.integration.tomcat.SecurityHandlerEJB3"/>
- <bean name="WSWebMetaDataModifier"
class="org.jboss.webservices.integration.tomcat.WebMetaDataModifierImpl"/>
-
</deployment>