[jboss-cvs] JBossAS SVN: r59475 - trunk/ejb3/src/main/org/jboss/ejb3/deployers.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Jan 10 06:27:42 EST 2007
Author: alesj
Date: 2007-01-10 06:27:35 -0500 (Wed, 10 Jan 2007)
New Revision: 59475
Modified:
trunk/ejb3/src/main/org/jboss/ejb3/deployers/Ejb3ClientDeployer.java
Log:
introduction of VFSUtils readManifest
Modified: trunk/ejb3/src/main/org/jboss/ejb3/deployers/Ejb3ClientDeployer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/deployers/Ejb3ClientDeployer.java 2007-01-10 11:24:56 UTC (rev 59474)
+++ trunk/ejb3/src/main/org/jboss/ejb3/deployers/Ejb3ClientDeployer.java 2007-01-10 11:27:35 UTC (rev 59475)
@@ -21,17 +21,6 @@
*/
package org.jboss.ejb3.deployers;
-import java.io.InputStream;
-import java.util.jar.Attributes;
-import java.util.jar.JarFile;
-import java.util.jar.Manifest;
-
-import javax.management.MBeanServer;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NameNotFoundException;
-import javax.naming.NamingException;
-
import org.jboss.deployers.plugins.deployers.helpers.AbstractSimpleRealDeployer;
import org.jboss.deployers.spi.DeploymentException;
import org.jboss.deployers.spi.deployer.DeploymentUnit;
@@ -44,6 +33,15 @@
import org.jboss.naming.Util;
import org.jboss.virtual.VirtualFile;
+import javax.management.MBeanServer;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NameNotFoundException;
+import javax.naming.NamingException;
+import java.io.InputStream;
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
+
/**
* Deploys a client application jar.
*
@@ -53,37 +51,37 @@
public class Ejb3ClientDeployer extends AbstractSimpleRealDeployer<ApplicationClientDD>
{
private static final Logger log = Logger.getLogger(Ejb3ClientDeployer.class);
-
+
private Kernel kernel;
private MBeanServer server;
-
+
public Ejb3ClientDeployer()
{
super(ApplicationClientDD.class);
// make sure we run after EJB3 deployer
setRelativeOrder(COMPONENT_DEPLOYER + 1);
}
-
+
@Override
public void deploy(DeploymentUnit unit, ApplicationClientDD metaData) throws DeploymentException
{
log.debug("deploy " + unit.getName());
-
+
String appClientName = getJndiName(unit, metaData);
-
+
try
{
// I create the namespace here, because I destroy it in undeploy
InitialContext iniCtx = new InitialContext();
Context encCtx = Util.createSubcontext(iniCtx, appClientName);
log.debug("Creating client ENC binding under: " + appClientName);
-
+
String mainClassName = getMainClassName(unit, true);
-
+
Class<?> mainClass = loadClass(unit, mainClassName);
-
+
ClientENCInjectionContainer container = new ClientENCInjectionContainer(unit, metaData, mainClass, appClientName, unit.getClassLoader(), encCtx);
-
+
//di.deployedObject = container.getObjectName();
unit.addAttachment(ClientENCInjectionContainer.class, container);
getKernelAbstraction().install(container.getObjectName().getCanonicalName(), container.getDependencyPolicy(), container);
@@ -99,8 +97,8 @@
/**
* If there is no deployment descriptor, or it doesn't specify a JNDI name, then we make up one.
* We use the basename from di.shortName.
- *
- * @param di
+ *
+ * @param unit
* @param dd
* @return a good JNDI name
*/
@@ -109,7 +107,7 @@
String jndiName = dd.getJndiName();
if(jndiName != null)
return jndiName;
-
+
String shortName = unit.getDeploymentContext().getRoot().getName();
if(shortName.endsWith(".jar/"))
jndiName = shortName.substring(0, shortName.length() - 5);
@@ -117,20 +115,20 @@
jndiName = shortName.substring(0, shortName.length() - 4);
else
throw new IllegalStateException("Expected either '.jar' or '.jar/' at the end of " + shortName);
-
+
return jndiName;
}
-
+
// public Kernel getKernel()
// {
// return kernel;
// }
-
+
private KernelAbstraction getKernelAbstraction()
{
return new MCKernelAbstraction(kernel, server);
}
-
+
// TODO: move this method either to a utility class or to the scanning deployer
protected String getMainClassName(DeploymentUnit unit, boolean fail) throws Exception
{
@@ -139,38 +137,36 @@
// Default to the jboss client main
String mainClassName = "org.jboss.client.AppClientMain";
- if(file == null)
+ if (file != null)
{
- return mainClassName;
- }
-
- try
- {
- InputStream is = file.openStream();
- Manifest mf;
try
{
- mf = new Manifest(is);
+ // use VFSUtils.readManifest(VirtualFile) .. once VFS lib is updated
+ InputStream is = file.openStream();
+ Manifest mf;
+ try
+ {
+ mf = new Manifest(is);
+ }
+ finally
+ {
+ is.close();
+ }
+ Attributes attrs = mf.getMainAttributes();
+ String className = attrs.getValue(Attributes.Name.MAIN_CLASS);
+ if (className != null)
+ {
+ mainClassName = className;
+ }
}
finally
{
- is.close();
+ file.close();
}
- Attributes attrs = mf.getMainAttributes();
- String className = attrs.getValue(Attributes.Name.MAIN_CLASS);
- if(className != null)
- {
- mainClassName = className;
- }
-
- return mainClassName;
}
- finally
- {
- file.close();
- }
+ return mainClassName;
}
-
+
private Class<?> loadClass(DeploymentUnit unit, String className) throws ClassNotFoundException
{
ClassLoader old = Thread.currentThread().getContextClassLoader();
@@ -184,26 +180,26 @@
Thread.currentThread().setContextClassLoader(old);
}
}
-
+
public void setKernel(Kernel kernel)
{
this.kernel = kernel;
}
-
+
public void setMbeanServer(MBeanServer server)
{
this.server = server;
}
-
+
@Override
public void undeploy(DeploymentUnit unit, ApplicationClientDD metaData)
{
log.debug("undeploy " + unit.getName());
-
+
ClientENCInjectionContainer container = unit.getAttachment(ClientENCInjectionContainer.class);
if(container != null)
getKernelAbstraction().uninstall(container.getObjectName().getCanonicalName());
-
+
String jndiName = getJndiName(unit, metaData);
log.debug("Removing client ENC from: " + jndiName);
try
More information about the jboss-cvs-commits
mailing list