Author: heiko.braun(a)jboss.com
Date: 2008-05-06 15:02:34 -0400 (Tue, 06 May 2008)
New Revision: 6922
Removed:
container/jboss50/branches/jbossws-jboss501/src/main/java/org/jboss/wsf/container/jboss50/ejb3/ServiceEndpointContainerApiAdapter.java
container/jboss50/branches/jbossws-jboss501/src/main/java/org/jboss/wsf/container/jboss50/ejb3/WebServiceDeploymentApiAdapter.java
Modified:
container/jboss50/branches/jbossws-jboss501/pom.xml
container/jboss50/branches/jbossws-jboss501/src/main/java/org/jboss/wsf/container/jboss50/deployer/AbstractWebServiceDeployer.java
container/jboss50/branches/jbossws-jboss501/src/main/java/org/jboss/wsf/container/jboss50/deployer/JAXWSDeployerHookEJB3.java
container/jboss50/branches/jbossws-jboss501/src/main/java/org/jboss/wsf/container/jboss50/deployer/WebServiceDeployerEJB.java
container/jboss50/branches/jbossws-jboss501/src/main/java/org/jboss/wsf/container/jboss50/deployment/RuntimeLoaderDeploymentAspect.java
container/jboss50/branches/jbossws-jboss501/src/main/java/org/jboss/wsf/container/jboss50/deployment/metadata/ContainerMetaDataAdapter.java
container/jboss50/branches/jbossws-jboss501/src/main/java/org/jboss/wsf/container/jboss50/deployment/metadata/EJBArchiveMetaDataAdapterEJB3.java
container/jboss50/branches/jbossws-jboss501/src/main/java/org/jboss/wsf/container/jboss50/deployment/tomcat/SecurityHandlerEJB3.java
container/jboss50/branches/jbossws-jboss501/src/main/java/org/jboss/wsf/container/jboss50/invocation/InvocationHandlerEJB3.java
Log:
Remove EJB3 API adapter
Modified: container/jboss50/branches/jbossws-jboss501/pom.xml
===================================================================
--- container/jboss50/branches/jbossws-jboss501/pom.xml 2008-05-06 16:19:53 UTC (rev
6921)
+++ container/jboss50/branches/jbossws-jboss501/pom.xml 2008-05-06 19:02:34 UTC (rev
6922)
@@ -24,7 +24,7 @@
<jboss.version>5.0.0-SNAPSHOT</jboss.version>
<jboss.ejb3.version>0.1.0-SNAPSHOT</jboss.ejb3.version>
<jboss.deployers.version>2.0.0-SNAPSHOT</jboss.deployers.version>
- <jboss.metadata.version>1.0.0.Beta10</jboss.metadata.version>
+ <jboss.metadata.version>1.0.0.Beta11</jboss.metadata.version>
<jboss.security.version>2.0.2.Beta7</jboss.security.version>
<jboss.jbossxb.version>2.0.0.CR8</jboss.jbossxb.version>
<jbossws.common.version>3.0.0-SNAPSHOT</jbossws.common.version>
Modified:
container/jboss50/branches/jbossws-jboss501/src/main/java/org/jboss/wsf/container/jboss50/deployer/AbstractWebServiceDeployer.java
===================================================================
---
container/jboss50/branches/jbossws-jboss501/src/main/java/org/jboss/wsf/container/jboss50/deployer/AbstractWebServiceDeployer.java 2008-05-06
16:19:53 UTC (rev 6921)
+++
container/jboss50/branches/jbossws-jboss501/src/main/java/org/jboss/wsf/container/jboss50/deployer/AbstractWebServiceDeployer.java 2008-05-06
19:02:34 UTC (rev 6922)
@@ -23,15 +23,14 @@
// $Id$
-import java.util.LinkedList;
-import java.util.List;
-
import org.jboss.deployers.spi.DeploymentException;
import org.jboss.deployers.spi.deployer.helpers.AbstractComponentDeployer;
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.logging.Logger;
-import org.jboss.wsf.container.jboss50.deployer.DeployerHook;
+import java.util.LinkedList;
+import java.util.List;
+
/**
* This deployer that calls the registered DeployerHooks
*
@@ -43,7 +42,7 @@
// provide logging
private static final Logger log = Logger.getLogger(AbstractWebServiceDeployer.class);
- private List<DeployerHook> deployerHooks = new
LinkedList<DeployerHook>();
+ protected List<DeployerHook> deployerHooks = new
LinkedList<DeployerHook>();
public void addDeployerHook(DeployerHook deployer)
{
@@ -60,14 +59,12 @@
@Override
public void internalDeploy(DeploymentUnit unit) throws DeploymentException
{
- for (DeployerHook deployer : deployerHooks)
- deployer.deploy(unit);
+ for (DeployerHook deployer : deployerHooks) deployer.deploy(unit);
}
@Override
public void internalUndeploy(DeploymentUnit unit)
{
- for (DeployerHook deployer : deployerHooks)
- deployer.undeploy(unit);
+ for (DeployerHook deployer : deployerHooks) deployer.undeploy(unit);
}
}
Modified:
container/jboss50/branches/jbossws-jboss501/src/main/java/org/jboss/wsf/container/jboss50/deployer/JAXWSDeployerHookEJB3.java
===================================================================
---
container/jboss50/branches/jbossws-jboss501/src/main/java/org/jboss/wsf/container/jboss50/deployer/JAXWSDeployerHookEJB3.java 2008-05-06
16:19:53 UTC (rev 6921)
+++
container/jboss50/branches/jbossws-jboss501/src/main/java/org/jboss/wsf/container/jboss50/deployer/JAXWSDeployerHookEJB3.java 2008-05-06
19:02:34 UTC (rev 6922)
@@ -25,16 +25,15 @@
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
-import org.jboss.ejb3.Ejb3Deployment;
-import org.jboss.wsf.spi.deployment.integration.WebServiceDeclaration;
-import org.jboss.wsf.spi.deployment.integration.WebServiceDeployment;
import org.jboss.metadata.serviceref.VirtualFileAdaptor;
-import org.jboss.wsf.container.jboss50.ejb3.WebServiceDeploymentApiAdapter;
import org.jboss.wsf.spi.deployment.ArchiveDeployment;
import org.jboss.wsf.spi.deployment.Deployment;
import org.jboss.wsf.spi.deployment.Deployment.DeploymentType;
import org.jboss.wsf.spi.deployment.Endpoint;
import org.jboss.wsf.spi.deployment.Service;
+import org.jboss.wsf.spi.deployment.integration.WebServiceDeclaration;
+import org.jboss.wsf.spi.deployment.integration.WebServiceDeployment;
+import org.jboss.wsf.container.jboss50.invocation.InvocationHandlerEJB3;
import javax.jws.WebService;
import javax.xml.ws.WebServiceProvider;
@@ -65,15 +64,14 @@
Service service = dep.getService();
- Ejb3Deployment ejb3Deployment = unit.getAttachment(Ejb3Deployment.class);
- if (ejb3Deployment == null)
- throw new IllegalStateException("Deployment unit does not contain ejb3
deployment");
+ WebServiceDeployment webServiceDeployment =
unit.getAttachment(WebServiceDeployment.class);
+ if (webServiceDeployment == null)
+ throw new IllegalStateException("Deployment unit does not contain
webServiceDeployment");
// Copy the attachments
- dep.addAttachment(Ejb3Deployment.class, ejb3Deployment);
+ dep.addAttachment(WebServiceDeployment.class, webServiceDeployment);
- WebServiceDeployment apiAdapter =
WebServiceDeploymentApiAdapter.createInstance(ejb3Deployment);
- Iterator<WebServiceDeclaration> it =
apiAdapter.getServiceEndpoints().iterator();
+ Iterator<WebServiceDeclaration> it =
webServiceDeployment.getServiceEndpoints().iterator();
while (it.hasNext())
{
WebServiceDeclaration container = it.next();
@@ -85,6 +83,12 @@
// Create the endpoint
Endpoint ep = newEndpoint(epBean);
ep.setShortName(ejbName);
+
+ String containName = container.getContainerName();
+ if(null==containName)
+ throw new IllegalArgumentException("Target container name not
set");
+ ep.setProperty(InvocationHandlerEJB3.CONTAINER_NAME, containName);
+
service.addEndpoint(ep);
}
}
@@ -95,14 +99,13 @@
@Override
public boolean isWebServiceDeployment(DeploymentUnit unit)
{
- Ejb3Deployment ejb3Deployment = unit.getAttachment(Ejb3Deployment.class);
- if (ejb3Deployment == null)
+ WebServiceDeployment webServiceDeployment =
unit.getAttachment(WebServiceDeployment.class);
+ if (null == webServiceDeployment )
return false;
boolean isWebServiceDeployment = false;
- WebServiceDeployment apiAdapter =
WebServiceDeploymentApiAdapter.createInstance(ejb3Deployment);
- Iterator<WebServiceDeclaration> it =
apiAdapter.getServiceEndpoints().iterator();
+ Iterator<WebServiceDeclaration> it =
webServiceDeployment.getServiceEndpoints().iterator();
while (it.hasNext())
{
WebServiceDeclaration container = it.next();
Modified:
container/jboss50/branches/jbossws-jboss501/src/main/java/org/jboss/wsf/container/jboss50/deployer/WebServiceDeployerEJB.java
===================================================================
---
container/jboss50/branches/jbossws-jboss501/src/main/java/org/jboss/wsf/container/jboss50/deployer/WebServiceDeployerEJB.java 2008-05-06
16:19:53 UTC (rev 6921)
+++
container/jboss50/branches/jbossws-jboss501/src/main/java/org/jboss/wsf/container/jboss50/deployer/WebServiceDeployerEJB.java 2008-05-06
19:02:34 UTC (rev 6922)
@@ -21,27 +21,152 @@
*/
package org.jboss.wsf.container.jboss50.deployer;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.ejb.deployers.EjbDeployment;
-import org.jboss.ejb3.Ejb3Deployment;
+import org.jboss.ejb.deployers.MergedJBossMetaDataDeployer;
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
import org.jboss.metadata.web.jboss.JBossWebMetaData;
+import org.jboss.wsf.spi.deployment.integration.WebServiceDeclaration;
+import org.jboss.wsf.spi.deployment.integration.WebServiceDeployment;
+import org.jboss.logging.Logger;
+import java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
//$Id$
/**
- * This web service deployer for EJB
- *
+ * This web service deployer for EJB. Adopts EJB deployments to
+ * {@link org.jboss.wsf.spi.deployment.integration.WebServiceDeclaration} an passes it to
a chain of
+ * {@link org.jboss.wsf.container.jboss50.deployer.DeployerHook}'s.
+ *
* @author Thomas.Diesler(a)jboss.org
+ * @author Heiko.Braun(a)jboss.com
+ *
* @since 24-Apr-2007
*/
public class WebServiceDeployerEJB extends AbstractWebServiceDeployer
{
+ private static final Logger log = Logger.getLogger(WebServiceDeployerEJB.class);
+
public WebServiceDeployerEJB()
{
- // Output of the EJBDeployer
+ addInput(MergedJBossMetaDataDeployer.EJB_MERGED_ATTACHMENT_NAME);
+
addInput(EjbDeployment.class);
- // Output of the EJB3Deployer
- addInput(Ejb3Deployment.class);
+
// Input for the TomcatDeployer
addOutput(JBossWebMetaData.class);
+
+ addOutput(WebServiceDeployment.class);
+
}
+
+ @Override
+ public void internalDeploy(DeploymentUnit unit) throws DeploymentException
+ {
+ JBossMetaData beans = (JBossMetaData)unit.getAttachment(
+ MergedJBossMetaDataDeployer.EJB_MERGED_ATTACHMENT_NAME
+ );
+
+ if(beans!=null)
+ {
+ WebServiceDeploymentAdapter wsDeployment = new WebServiceDeploymentAdapter();
+ Iterator<JBossEnterpriseBeanMetaData> iterator =
beans.getEnterpriseBeans().iterator();
+ while(iterator.hasNext())
+ {
+ JBossEnterpriseBeanMetaData ejb = iterator.next();
+ if(ejb.getEjbClass()!=null)
+ wsDeployment.getEndpoints().add( new WebServiceDeclarationAdapter(ejb,
unit.getClassLoader()) );
+ else
+ log.warn("Ingore ejb deployment with null classname: " + ejb);
+ }
+
+ unit.addAttachment(WebServiceDeployment.class, wsDeployment);
+
+ super.internalDeploy(unit);
+ }
+ }
+
+ @Override
+ public void internalUndeploy(DeploymentUnit unit)
+ {
+ super.internalUndeploy(unit);
+ }
+
+ /**
+ * Adopts EJB3 bean meta data to a {@link
org.jboss.wsf.spi.deployment.integration.WebServiceDeclaration}
+ */
+ private class WebServiceDeclarationAdapter implements WebServiceDeclaration
+ {
+
+ private JBossEnterpriseBeanMetaData ejbMetaData;
+ private ClassLoader loader;
+
+ public WebServiceDeclarationAdapter(JBossEnterpriseBeanMetaData ejbMetaData,
ClassLoader loader)
+ {
+ this.ejbMetaData = ejbMetaData;
+ this.loader = loader;
+ }
+
+ public String getContainerName()
+ {
+ return ejbMetaData.determineContainerName();
+ }
+
+ public String getComponentName()
+ {
+ return ejbMetaData.getName();
+ }
+
+ public String getComponentClassName()
+ {
+ return ejbMetaData.getEjbClass();
+ }
+
+ public <T extends Annotation> T getAnnotation(Class<T> annotation)
+ {
+ Class bean = getComponentClass();
+ T result = null;
+ if(bean.isAnnotationPresent(annotation))
+ {
+ result = (T)bean.getAnnotation(annotation);
+ }
+
+ return result;
+ }
+
+ private Class getComponentClass()
+ {
+ try
+ {
+ return loader.loadClass(getComponentClassName());
+ } catch (ClassNotFoundException e)
+ {
+ throw new RuntimeException("Failed to load component class "+
getComponentClassName()+". Loader:" + this.loader);
+ }
+ }
+ }
+
+ /**
+ * Adopts an EJB deployment to a {@link
org.jboss.wsf.spi.deployment.integration.WebServiceDeployment}
+ */
+ private class WebServiceDeploymentAdapter implements WebServiceDeployment
+ {
+ private List<WebServiceDeclaration> endpoints = new
ArrayList<WebServiceDeclaration>();
+
+ public List<WebServiceDeclaration> getServiceEndpoints()
+ {
+ return endpoints;
+ }
+
+ public List<WebServiceDeclaration> getEndpoints()
+ {
+ return endpoints;
+ }
+ }
}
Modified:
container/jboss50/branches/jbossws-jboss501/src/main/java/org/jboss/wsf/container/jboss50/deployment/RuntimeLoaderDeploymentAspect.java
===================================================================
---
container/jboss50/branches/jbossws-jboss501/src/main/java/org/jboss/wsf/container/jboss50/deployment/RuntimeLoaderDeploymentAspect.java 2008-05-06
16:19:53 UTC (rev 6921)
+++
container/jboss50/branches/jbossws-jboss501/src/main/java/org/jboss/wsf/container/jboss50/deployment/RuntimeLoaderDeploymentAspect.java 2008-05-06
19:02:34 UTC (rev 6922)
@@ -25,10 +25,10 @@
import org.jboss.metadata.ejb.jboss.JBossMetaData;
import org.jboss.metadata.web.jboss.JBossWebMetaData;
+import org.jboss.wsf.spi.WSFRuntime;
import org.jboss.wsf.spi.deployment.Deployment;
import org.jboss.wsf.spi.deployment.DeploymentAspect;
-import org.jboss.wsf.spi.WSFRuntime;
-import org.jboss.ejb3.Ejb3Deployment;
+import org.jboss.wsf.spi.deployment.integration.WebServiceDeployment;
/**
* Determines the correct runtime loader for per deployment type
@@ -42,7 +42,7 @@
public void start(Deployment dep, WSFRuntime runtime)
{
// EJB3 endpoints
- if (dep.getAttachment(Ejb3Deployment.class) != null)
+ if (dep.getAttachment(WebServiceDeployment.class) != null)
{
dep.setRuntimeClassLoader(dep.getInitialClassLoader());
}
Modified:
container/jboss50/branches/jbossws-jboss501/src/main/java/org/jboss/wsf/container/jboss50/deployment/metadata/ContainerMetaDataAdapter.java
===================================================================
---
container/jboss50/branches/jbossws-jboss501/src/main/java/org/jboss/wsf/container/jboss50/deployment/metadata/ContainerMetaDataAdapter.java 2008-05-06
16:19:53 UTC (rev 6921)
+++
container/jboss50/branches/jbossws-jboss501/src/main/java/org/jboss/wsf/container/jboss50/deployment/metadata/ContainerMetaDataAdapter.java 2008-05-06
19:02:34 UTC (rev 6922)
@@ -24,12 +24,12 @@
//$Id$
import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.ejb3.Ejb3Deployment;
import org.jboss.logging.Logger;
import org.jboss.metadata.ejb.jboss.JBossMetaData;
import org.jboss.metadata.web.jboss.JBossWebMetaData;
import org.jboss.wsf.spi.deployment.ArchiveDeployment;
import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.deployment.integration.WebServiceDeployment;
import org.jboss.wsf.spi.metadata.j2ee.EJBArchiveMetaData;
import org.jboss.wsf.spi.metadata.j2ee.JSEArchiveMetaData;
import org.jboss.wsf.spi.transport.HttpSpec;
@@ -69,7 +69,7 @@
public void buildContainerMetaData(Deployment dep, DeploymentUnit unit)
{
dep.addAttachment(DeploymentUnit.class, unit);
-
+
try
{
// JSE endpoints
@@ -87,7 +87,7 @@
}
// EJB3 endpoints
- else if (unit.getAttachment(Ejb3Deployment.class) != null)
+ else if (unit.getAttachment(WebServiceDeployment.class) != null)
{
EJBArchiveMetaData ejbMetaData = ejbMetaDataAdapterEJB3.buildMetaData(dep,
unit);
if (ejbMetaData != null)
Modified:
container/jboss50/branches/jbossws-jboss501/src/main/java/org/jboss/wsf/container/jboss50/deployment/metadata/EJBArchiveMetaDataAdapterEJB3.java
===================================================================
---
container/jboss50/branches/jbossws-jboss501/src/main/java/org/jboss/wsf/container/jboss50/deployment/metadata/EJBArchiveMetaDataAdapterEJB3.java 2008-05-06
16:19:53 UTC (rev 6921)
+++
container/jboss50/branches/jbossws-jboss501/src/main/java/org/jboss/wsf/container/jboss50/deployment/metadata/EJBArchiveMetaDataAdapterEJB3.java 2008-05-06
19:02:34 UTC (rev 6922)
@@ -24,19 +24,16 @@
// $Id$
import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.wsf.spi.deployment.integration.WebServiceDeclaration;
-import org.jboss.wsf.spi.deployment.integration.WebServiceDeployment;
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.container.jboss50.ejb3.WebServiceDeploymentApiAdapter;
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 org.jboss.wsf.spi.metadata.j2ee.PortComponentSpec;
-import org.jboss.ejb3.Ejb3Deployment;
import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
@@ -59,10 +56,8 @@
{
EJBArchiveMetaData umd = new EJBArchiveMetaData();
- WebServiceDeployment apiAdapter = WebServiceDeploymentApiAdapter.createInstance(
- unit.getAttachment(Ejb3Deployment.class)
- );
- buildEnterpriseBeansMetaData(umd, apiAdapter);
+ WebServiceDeployment webServiceDeployment =
dep.getAttachment(WebServiceDeployment.class);
+ buildEnterpriseBeansMetaData(umd, webServiceDeployment);
JBossMetaData jbMetaData = unit.getAttachment(JBossMetaData.class);
if (jbMetaData != null)
Modified:
container/jboss50/branches/jbossws-jboss501/src/main/java/org/jboss/wsf/container/jboss50/deployment/tomcat/SecurityHandlerEJB3.java
===================================================================
---
container/jboss50/branches/jbossws-jboss501/src/main/java/org/jboss/wsf/container/jboss50/deployment/tomcat/SecurityHandlerEJB3.java 2008-05-06
16:19:53 UTC (rev 6921)
+++
container/jboss50/branches/jbossws-jboss501/src/main/java/org/jboss/wsf/container/jboss50/deployment/tomcat/SecurityHandlerEJB3.java 2008-05-06
19:02:34 UTC (rev 6922)
@@ -23,15 +23,13 @@
//$Id$
-import org.jboss.ejb3.Ejb3Deployment;
import org.jboss.ejb3.annotation.SecurityDomain;
-import org.jboss.wsf.spi.deployment.integration.WebServiceDeclaration;
-import org.jboss.wsf.spi.deployment.integration.WebServiceDeployment;
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.container.jboss50.ejb3.WebServiceDeploymentApiAdapter;
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;
@@ -48,11 +46,10 @@
{
String securityDomain = null;
- Ejb3Deployment ejb3Deployment = dep.getAttachment(Ejb3Deployment.class);
- if (ejb3Deployment != null)
+ WebServiceDeployment webServiceDeployment =
dep.getAttachment(WebServiceDeployment.class);
+ if (webServiceDeployment != null)
{
- WebServiceDeployment apiAdapter =
WebServiceDeploymentApiAdapter.createInstance(ejb3Deployment);
- Iterator<WebServiceDeclaration> it =
apiAdapter.getServiceEndpoints().iterator();
+ Iterator<WebServiceDeclaration> it =
webServiceDeployment.getServiceEndpoints().iterator();
while (it.hasNext())
{
WebServiceDeclaration container = it.next();
@@ -78,11 +75,10 @@
public void addSecurityRoles(JBossWebMetaData webApp, Deployment dep)
{
- Ejb3Deployment ejb3Deployment = dep.getAttachment(Ejb3Deployment.class);
- if (ejb3Deployment != null)
+ WebServiceDeployment webServiceDeployment =
dep.getAttachment(WebServiceDeployment.class);
+ if (webServiceDeployment != null)
{
- WebServiceDeployment apiAdapter =
WebServiceDeploymentApiAdapter.createInstance(ejb3Deployment);
- Iterator<WebServiceDeclaration> it =
apiAdapter.getServiceEndpoints().iterator();
+ Iterator<WebServiceDeclaration> it =
webServiceDeployment.getServiceEndpoints().iterator();
while (it.hasNext())
{
WebServiceDeclaration container = it.next();
Deleted:
container/jboss50/branches/jbossws-jboss501/src/main/java/org/jboss/wsf/container/jboss50/ejb3/ServiceEndpointContainerApiAdapter.java
===================================================================
---
container/jboss50/branches/jbossws-jboss501/src/main/java/org/jboss/wsf/container/jboss50/ejb3/ServiceEndpointContainerApiAdapter.java 2008-05-06
16:19:53 UTC (rev 6921)
+++
container/jboss50/branches/jbossws-jboss501/src/main/java/org/jboss/wsf/container/jboss50/ejb3/ServiceEndpointContainerApiAdapter.java 2008-05-06
19:02:34 UTC (rev 6922)
@@ -1,110 +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.wsf.container.jboss50.ejb3;
-
-import org.jboss.ejb3.BeanContext;
-import org.jboss.ejb3.BeanContextLifecycleCallback;
-import org.jboss.ejb3.stateless.StatelessBeanContext;
-import org.jboss.ejb3.stateless.StatelessContainer;
-import org.jboss.injection.lang.reflect.BeanProperty;
-import org.jboss.wsf.spi.invocation.integration.InvocationContextCallback;
-import org.jboss.wsf.spi.invocation.integration.ServiceEndpointContainer;
-import org.jboss.wsf.spi.SPIProvider;
-import org.jboss.wsf.spi.SPIProviderResolver;
-import org.jboss.wsf.spi.invocation.ExtensibleWebServiceContext;
-import org.jboss.wsf.spi.invocation.InvocationType;
-import org.jboss.wsf.spi.invocation.WebServiceContextFactory;
-
-import javax.ejb.EJBContext;
-import java.lang.reflect.Method;
-
-/**
- * @author Heiko.Braun <heiko.braun(a)jboss.com>
- */
-public class ServiceEndpointContainerApiAdapter implements ServiceEndpointContainer
-{
- private StatelessContainer ejb3Container;
-
- public static ServiceEndpointContainer createInstance(Object invocationTarget)
- {
- if(! (invocationTarget instanceof StatelessContainer) )
- throw new IllegalArgumentException("Unexpected invocation target: " +
invocationTarget);
-
- return new
ServiceEndpointContainerApiAdapter((StatelessContainer)invocationTarget);
- }
-
- ServiceEndpointContainerApiAdapter(StatelessContainer ejb3Container)
- {
- this.ejb3Container = ejb3Container;
- }
-
-
- public Class getServiceImplementationClass()
- {
- return ejb3Container.getBeanClass();
- }
-
- public Object invokeEndpoint(Method method, Object[] args, InvocationContextCallback
invocationContextCallback)
- throws Throwable
- {
- CallbackImpl callback = new CallbackImpl(invocationContextCallback);
- return ejb3Container.localInvoke(method, args, null, callback);
- }
-
- static class CallbackImpl implements BeanContextLifecycleCallback
- {
- private javax.xml.ws.handler.MessageContext jaxwsMessageContext;
- private javax.xml.rpc.handler.MessageContext jaxrpcMessageContext;
-
- public CallbackImpl(InvocationContextCallback epInv)
- {
- jaxrpcMessageContext = epInv.get( javax.xml.rpc.handler.MessageContext.class );
- jaxwsMessageContext = epInv.get( javax.xml.ws.handler.MessageContext.class );
- }
-
- public void attached(BeanContext beanCtx)
- {
- StatelessBeanContext sbc = (StatelessBeanContext)beanCtx;
- sbc.setMessageContextJAXRPC(jaxrpcMessageContext);
-
- BeanProperty beanProp = sbc.getWebServiceContextProperty();
- if (beanProp != null)
- {
- EJBContext ejbCtx = beanCtx.getEJBContext();
- SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
- ExtensibleWebServiceContext wsContext =
spiProvider.getSPI(WebServiceContextFactory.class).newWebServiceContext(InvocationType.JAXWS_EJB3,
jaxwsMessageContext);
- wsContext.addAttachment(EJBContext.class, ejbCtx);
- beanProp.set(beanCtx.getInstance(), wsContext);
- }
- }
-
- public void released(BeanContext beanCtx)
- {
- StatelessBeanContext sbc = (StatelessBeanContext)beanCtx;
- sbc.setMessageContextJAXRPC(null);
-
- BeanProperty beanProp = sbc.getWebServiceContextProperty();
- if (beanProp != null)
- beanProp.set(beanCtx.getInstance(), null);
- }
- }
-}
Deleted:
container/jboss50/branches/jbossws-jboss501/src/main/java/org/jboss/wsf/container/jboss50/ejb3/WebServiceDeploymentApiAdapter.java
===================================================================
---
container/jboss50/branches/jbossws-jboss501/src/main/java/org/jboss/wsf/container/jboss50/ejb3/WebServiceDeploymentApiAdapter.java 2008-05-06
16:19:53 UTC (rev 6921)
+++
container/jboss50/branches/jbossws-jboss501/src/main/java/org/jboss/wsf/container/jboss50/ejb3/WebServiceDeploymentApiAdapter.java 2008-05-06
19:02:34 UTC (rev 6922)
@@ -1,94 +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.wsf.container.jboss50.ejb3;
-
-import org.jboss.wsf.spi.deployment.integration.WebServiceDeployment;
-import org.jboss.wsf.spi.deployment.integration.WebServiceDeclaration;
-import org.jboss.ejb3.Ejb3Deployment;
-import org.jboss.ejb3.Container;
-import org.jboss.ejb3.EJBContainer;
-
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Iterator;
-
-/**
- * Adopts the new WS-EJB3 API to legacy EJB3 codebase while the
- * EJB3 hasn't updated to the new integration interfaces.
- *
- * <p/>
- * TODO: This should be implemented by {@link org.jboss.ejb3.Ejb3Deployment}
- *
- * @author Heiko.Braun <heiko.braun(a)jboss.com>
- */
-public class WebServiceDeploymentApiAdapter implements WebServiceDeployment
-{
- private Ejb3Deployment ejb3Deployment;
-
- public static WebServiceDeploymentApiAdapter createInstance(Ejb3Deployment
ejb3Deployment)
- {
- if(null==ejb3Deployment)
- throw new IllegalArgumentException("Ejb3Deployment.class cannot be
null");
-
- return new WebServiceDeploymentApiAdapter(ejb3Deployment);
- }
-
- private WebServiceDeploymentApiAdapter(Ejb3Deployment ejb3Deployment)
- {
- this.ejb3Deployment = ejb3Deployment;
- }
-
- public List<WebServiceDeclaration> getServiceEndpoints()
- {
- List<WebServiceDeclaration> container = new
ArrayList<WebServiceDeclaration>();
-
- Iterator<Container> it =
ejb3Deployment.getEjbContainers().values().iterator();
- while(it.hasNext())
- {
- final EJBContainer c = (EJBContainer)it.next();
- container.add(
- new WebServiceDeclaration()
- {
-
- public <T extends java.lang.annotation.Annotation> T
getAnnotation(Class<T> t)
- {
- return c.getAnnotation(t);
- }
-
-
- public String getComponentName()
- {
- return c.getEjbName();
- }
-
- public String getComponentClassName()
- {
- return c.getBeanClassName();
- }
- }
-
- );
- }
- return container;
-
- }
-}
\ No newline at end of file
Modified:
container/jboss50/branches/jbossws-jboss501/src/main/java/org/jboss/wsf/container/jboss50/invocation/InvocationHandlerEJB3.java
===================================================================
---
container/jboss50/branches/jbossws-jboss501/src/main/java/org/jboss/wsf/container/jboss50/invocation/InvocationHandlerEJB3.java 2008-05-06
16:19:53 UTC (rev 6921)
+++
container/jboss50/branches/jbossws-jboss501/src/main/java/org/jboss/wsf/container/jboss50/invocation/InvocationHandlerEJB3.java 2008-05-06
19:02:34 UTC (rev 6922)
@@ -24,17 +24,13 @@
// $Id$
import org.jboss.dependency.spi.ControllerContext;
-import org.jboss.wsf.spi.invocation.integration.InvocationContextCallback;
-import org.jboss.wsf.spi.invocation.integration.ServiceEndpointContainer;
import org.jboss.kernel.spi.dependency.KernelController;
-import org.jboss.wsf.common.ObjectNameFactory;
-import org.jboss.wsf.container.jboss50.ejb3.ServiceEndpointContainerApiAdapter;
-import org.jboss.wsf.spi.deployment.ArchiveDeployment;
import org.jboss.wsf.spi.deployment.Endpoint;
import org.jboss.wsf.spi.invocation.Invocation;
+import org.jboss.wsf.spi.invocation.integration.InvocationContextCallback;
+import org.jboss.wsf.spi.invocation.integration.ServiceEndpointContainer;
import org.jboss.wsf.spi.util.KernelLocator;
-import javax.management.ObjectName;
import javax.xml.ws.WebServiceException;
import java.lang.reflect.Method;
@@ -42,12 +38,18 @@
* Handles invocations on EJB3 endpoints.
*
* @author Thomas.Diesler(a)jboss.org
+ * @author Heiko.Braun(a)jboss.com
+ *
* @since 25-Apr-2007
*/
public class InvocationHandlerEJB3 extends AbstractInvocationHandler
{
- private ObjectName objectName;
+
+ public static final String CONTAINER_NAME =
"org.jboss.wsf.spi.invocation.ContainerName";
+
+ private String containerName;
private KernelController houston;
+ private ServiceEndpointContainer invocationTarget;
InvocationHandlerEJB3()
{
@@ -61,34 +63,28 @@
public void init(Endpoint ep)
{
- String ejbName = ep.getShortName();
- ArchiveDeployment dep = (ArchiveDeployment)ep.getService().getDeployment();
- String nameStr = "jboss.j2ee:name=" + ejbName +
",service=EJB3,jar=" + dep.getSimpleName();
- if (dep.getParent() != null)
- {
- nameStr += ",ear=" + dep.getParent().getSimpleName();
- }
-
- objectName = ObjectNameFactory.create(nameStr.toString());
-
- if (houston.getInstalledContext( objectName.getCanonicalName() ) == null)
- throw new WebServiceException("Cannot find service endpoint target: "
+ objectName);
+ containerName = (String)ep.getProperty(InvocationHandlerEJB3.CONTAINER_NAME);
+ assert containerName!=null : "Target container name not set";
+
+ ControllerContext context = houston.getInstalledContext(containerName);
+ if (context == null)
+ throw new WebServiceException("Cannot find service endpoint target: "
+ containerName);
+
+ assert (context.getTarget() instanceof ServiceEndpointContainer) : "Invocation
target mismatch";
+ this.invocationTarget = (ServiceEndpointContainer) context.getTarget();
}
public void invoke(Endpoint ep, Invocation wsInv) throws Exception
{
try
{
- ControllerContext context =
houston.getInstalledContext(objectName.getCanonicalName());
- ServiceEndpointContainer apiAdapter =
ServiceEndpointContainerApiAdapter.createInstance(context.getTarget());
-
- Class beanClass = apiAdapter.getServiceImplementationClass();
+ Class beanClass = invocationTarget.getServiceImplementationClass();
Method method = getImplMethod(beanClass, wsInv.getJavaMethod());
Object[] args = wsInv.getArgs();
InvocationContextCallback invProps = new EJB3InvocationContextCallback(wsInv);
+
+ Object retObj = invocationTarget.invokeEndpoint(method, args, invProps);
- Object retObj = apiAdapter.invokeEndpoint(method, args, invProps);
-
wsInv.setReturnValue(retObj);
}
catch (Throwable th)
@@ -111,4 +107,4 @@
return wsInv.getInvocationContext().getAttachment(propertyType);
}
}
-}
\ No newline at end of file
+}