Author: alessio.soldano(a)jboss.com
Date: 2008-11-18 03:27:15 -0500 (Tue, 18 Nov 2008)
New Revision: 8742
Added:
stack/metro/branches/asoldano/modules/server/src/main/java/org/jboss/wsf/stack/metro/JAXRPCDelegateDeploymentAspect.java
stack/metro/branches/asoldano/modules/server/src/main/java/org/jboss/wsf/stack/metro/MixEndpointHandlerDeploymentAspect.java
Log:
Add deployment aspect for adapting native stuff to metro
Added:
stack/metro/branches/asoldano/modules/server/src/main/java/org/jboss/wsf/stack/metro/JAXRPCDelegateDeploymentAspect.java
===================================================================
---
stack/metro/branches/asoldano/modules/server/src/main/java/org/jboss/wsf/stack/metro/JAXRPCDelegateDeploymentAspect.java
(rev 0)
+++
stack/metro/branches/asoldano/modules/server/src/main/java/org/jboss/wsf/stack/metro/JAXRPCDelegateDeploymentAspect.java 2008-11-18
08:27:15 UTC (rev 8742)
@@ -0,0 +1,83 @@
+package org.jboss.wsf.stack.metro;
+
+import java.util.Set;
+
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.deployment.DeploymentAspect;
+import org.jboss.wsf.spi.deployment.Deployment.DeploymentType;
+
+public class JAXRPCDelegateDeploymentAspect extends DeploymentAspect
+{
+ private DeploymentAspect delegate;
+
+ private boolean canRun(Deployment dep)
+ {
+ DeploymentType dt = dep.getType();
+ return (!DeploymentType.JAXWS_JSE.equals(dt) &&
!DeploymentType.JAXWS_EJB3.equals(dt));
+ }
+
+ public String getProvides()
+ {
+ return delegate.getProvides();
+ }
+
+ public void setProvides(String provides)
+ {
+ delegate.setProvides(provides);
+ }
+
+ public String getRequires()
+ {
+ return delegate.getRequires();
+ }
+
+ public void setRequires(String requires)
+ {
+ delegate.setRequires(requires);
+ }
+
+ public void create(Deployment dep)
+ {
+ if (canRun(dep))
+ delegate.create(dep);
+ }
+
+ public void destroy(Deployment dep)
+ {
+ if (canRun(dep))
+ delegate.destroy(dep);
+ }
+
+ public void start(Deployment dep)
+ {
+ if (canRun(dep))
+ delegate.start(dep);
+ }
+
+ public void stop(Deployment dep)
+ {
+ if (canRun(dep))
+ delegate.stop(dep);
+ }
+
+ public Set<String> getProvidesAsSet()
+ {
+ return delegate.getProvidesAsSet();
+ }
+
+ public Set<String> getRequiresAsSet()
+ {
+ return delegate.getRequiresAsSet();
+ }
+
+ public DeploymentAspect getDelegate()
+ {
+ return delegate;
+ }
+
+ public void setDelegate(DeploymentAspect delegate)
+ {
+ this.delegate = delegate;
+ }
+
+}
Property changes on:
stack/metro/branches/asoldano/modules/server/src/main/java/org/jboss/wsf/stack/metro/JAXRPCDelegateDeploymentAspect.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
stack/metro/branches/asoldano/modules/server/src/main/java/org/jboss/wsf/stack/metro/MixEndpointHandlerDeploymentAspect.java
===================================================================
---
stack/metro/branches/asoldano/modules/server/src/main/java/org/jboss/wsf/stack/metro/MixEndpointHandlerDeploymentAspect.java
(rev 0)
+++
stack/metro/branches/asoldano/modules/server/src/main/java/org/jboss/wsf/stack/metro/MixEndpointHandlerDeploymentAspect.java 2008-11-18
08:27:15 UTC (rev 8742)
@@ -0,0 +1,124 @@
+package org.jboss.wsf.stack.metro;
+
+import java.io.File;
+import java.net.URL;
+import java.net.URLClassLoader;
+
+import javax.xml.rpc.Stub;
+
+import org.jboss.wsf.spi.SPIProvider;
+import org.jboss.wsf.spi.SPIProviderResolver;
+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.LifecycleHandler;
+import org.jboss.wsf.spi.deployment.LifecycleHandlerFactory;
+import org.jboss.wsf.spi.deployment.Deployment.DeploymentType;
+import org.jboss.wsf.spi.invocation.InvocationHandler;
+import org.jboss.wsf.spi.invocation.InvocationHandlerFactory;
+import org.jboss.wsf.spi.invocation.InvocationType;
+import org.jboss.wsf.spi.invocation.RequestHandler;
+import org.jboss.wsf.spi.invocation.RequestHandlerFactory;
+import org.jboss.wsf.spi.metadata.j2ee.EJBArchiveMetaData;
+import org.jboss.wsf.spi.metadata.j2ee.EJBMetaData;
+import org.jboss.wsf.spi.metadata.j2ee.MDBMetaData;
+
+public class MixEndpointHandlerDeploymentAspect extends DeploymentAspect
+{
+ private SPIProvider spiProvider;
+
+ public MixEndpointHandlerDeploymentAspect()
+ {
+ spiProvider = SPIProviderResolver.getInstance().getProvider();
+ }
+
+ @Override
+ public void create(Deployment dep)
+ {
+ ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+ try
+ {
+ DeploymentType dt = dep.getType();
+ if (!DeploymentType.JAXWS_JSE.equals(dt) &&
!DeploymentType.JAXWS_EJB3.equals(dt))
+ {
+ //TODO!!!! do this better
+
+ for (Endpoint ep : dep.getService().getEndpoints())
+ {
+ // Associate a request handler
+ Class clazz =
Class.forName("org.jboss.wsf.stack.jbws.RequestHandlerImpl");
+ ep.setRequestHandler((RequestHandler)clazz.newInstance());
+
+ // Associate a lifecycle handler
+ ep.setLifecycleHandler(getLifecycleHandler(dep));
+
+ // Associate an invocation handler
+ // Invocation handlers are assigned per container or per stack
+ InvocationHandler invocationHandler = getInvocationHandler(ep);
+ if (invocationHandler != null)
+ ep.setInvocationHandler(invocationHandler);
+
+ }
+
+ } else {
+
+ for (Endpoint ep : dep.getService().getEndpoints())
+ {
+ // Associate a request handler
+ ep.setRequestHandler(getRequestHandler(dep));
+
+ // Associate a lifecycle handler
+ ep.setLifecycleHandler(getLifecycleHandler(dep));
+
+ // Associate an invocation handler
+ // Invocation handlers are assigned per container or per stack
+ InvocationHandler invocationHandler = getInvocationHandler(ep);
+ if (invocationHandler != null)
+ ep.setInvocationHandler(invocationHandler);
+
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ private RequestHandler getRequestHandler(Deployment dep)
+ {
+ return spiProvider.getSPI(RequestHandlerFactory.class).newRequestHandler();
+ }
+
+ private LifecycleHandler getLifecycleHandler(Deployment dep)
+ {
+ return spiProvider.getSPI(LifecycleHandlerFactory.class).newLifecycleHandler();
+ }
+
+ private InvocationHandler getInvocationHandler(Endpoint ep)
+ {
+ Deployment dep = ep.getService().getDeployment();
+ DeploymentType depType = dep.getType();
+
+ String key = depType.toString();
+
+ // Use a special key for MDB endpoints
+ EJBArchiveMetaData uapp = dep.getAttachment(EJBArchiveMetaData.class);
+ if (uapp != null)
+ {
+ EJBMetaData bmd = uapp.getBeanByEjbName(ep.getShortName());
+ if (depType == DeploymentType.JAXRPC_EJB21 && bmd instanceof
MDBMetaData)
+ {
+ key = InvocationType.JAXRPC_MDB21.toString();
+ }
+ else if (depType == DeploymentType.JAXWS_EJB3 && bmd instanceof
MDBMetaData)
+ {
+ key = InvocationType.JAXWS_MDB3.toString();
+ }
+ }
+
+ InvocationType type = InvocationType.valueOf(key);
+ InvocationHandler invocationHandler =
spiProvider.getSPI(InvocationHandlerFactory.class).newInvocationHandler(type);
+ return invocationHandler;
+ }
+}
Property changes on:
stack/metro/branches/asoldano/modules/server/src/main/java/org/jboss/wsf/stack/metro/MixEndpointHandlerDeploymentAspect.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Show replies by date