[jboss-cvs] system2/src/main/org/jboss/deployers/plugins/bean ...
Scott Stark
scott.stark at jboss.com
Wed Jul 12 05:12:38 EDT 2006
User: starksm
Date: 06/07/12 05:12:38
Modified: src/main/org/jboss/deployers/plugins/bean BeanDeployer.java
Log:
Initialize the kernel deployer from the kernel context
Revision Changes Path
1.6 +73 -11 system2/src/main/org/jboss/deployers/plugins/bean/BeanDeployer.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: BeanDeployer.java
===================================================================
RCS file: /cvsroot/jboss/system2/src/main/org/jboss/deployers/plugins/bean/BeanDeployer.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- BeanDeployer.java 11 Jul 2006 13:34:38 -0000 1.5
+++ BeanDeployer.java 12 Jul 2006 09:12:38 -0000 1.6
@@ -22,6 +22,7 @@
package org.jboss.deployers.plugins.bean;
import java.io.IOException;
+import java.io.InputStream;
import org.jboss.deployers.plugins.AbstractAspectDeployer;
import org.jboss.deployers.plugins.DeployerConstants;
@@ -35,7 +36,7 @@
*
* @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
* @author Scott.Stark at jboss.org
- * @version $Revision: 1.5 $
+ * @version $Revision: 1.6 $
*/
public class BeanDeployer extends AbstractAspectDeployer
{
@@ -44,6 +45,7 @@
/** The suffixes this deployer handles */
public static String[] ENHANCED_SUFFIXES =
{ DeployerConstants.BEAN_ENHANCED_SUFFIX, DeployerConstants.BEAN_XML_ENHANCED_SUFFIX };
+ /** The archive META-INF descriptor that identifies a bean deployment */
public static String JAR_DESCRIPTOR = "META-INF/jboss-beans.xml";
// Private -------------------------------------------------------
@@ -64,7 +66,40 @@
public String getType()
{
- return "bean";
+ return "beans";
+ }
+
+ /** Overriden to initialize the BasicXMLDeployer
+ */
+ @Override
+ public void start() throws Exception
+ {
+ try
+ {
+ kernelDeployer = new BasicXMLDeployer(context.getKernel());
+ }
+ catch(Error e)
+ {
+ throw e;
+ }
+ catch(Exception e)
+ {
+ throw e;
+ }
+ catch(Throwable e)
+ {
+ throw new Exception("Failed to create BasicXMLDeployer", e);
+ }
+ super.start();
+ }
+
+ /** Overriden to shutdown the BasicXMLDeployer
+ */
+ @Override
+ public void stop()
+ {
+ super.stop();
+ kernelDeployer.shutdown();
}
/**
@@ -82,6 +117,7 @@
try
{
// If the context contains a META-INF/jboss-beans.xml its a beans archive
+ @SuppressWarnings("unused")
VirtualFile descriptor = vf.findChild(JAR_DESCRIPTOR);
ctx.getContextData().put(JAR_DESCRIPTOR, Boolean.TRUE);
// add deployment base to the classpath
@@ -93,9 +129,10 @@
}
}
+ // Mark this as a bean deployment context
if( isBeanDeployment )
ctx.addDeploymentType(getType());
- // not a .bean, -bean.xml deployment
+
return isBeanDeployment;
}
@@ -104,26 +141,51 @@
return null;
}
+ /**
+ * Called if this is a "beans" context.
+ */
public void deploy(DeploymentContext ctx) throws DeploymentException
{
+ boolean trace = log.isTraceEnabled();
+ if( trace )
+ log.trace("Processing beans deployment: "+ctx);
+ VirtualFile descriptor = ctx.getFile();
Boolean jarType = (Boolean) ctx.getContextData().get(JAR_DESCRIPTOR);
+ try
+ {
if( jarType == Boolean.TRUE )
{
+ descriptor = ctx.getFile().findChild(JAR_DESCRIPTOR);
+ }
+ String name = ctx.toShortString();
+ InputStream is = descriptor.openStream();
+ kernelDeployer.deploy(name, is);
+ is.close();
}
- else
+ catch (Throwable e)
{
-
+ throw new DeploymentException("Failed deploy beans", e);
}
}
- public void redeploy(DeploymentContext comp) throws DeploymentException
+ /**
+ * TODO: This is just an undeploy/deploy cycle currently.
+ */
+ public void redeploy(DeploymentContext ctx) throws DeploymentException
{
-
+ undeploy(ctx);
+ deploy(ctx);
}
- public void undeploy(DeploymentContext comp) throws DeploymentException
+ /**
+ * Undeploy the ctx using the ctx name({@link DeploymentContext#toShortString(StringBuffer)}.
+ * TODO: Undeployment by name requires consistent and unique names for
+ * the DeploymentContext here and {@link #undeploy(DeploymentContext)}.
+ */
+ public void undeploy(DeploymentContext ctx) throws DeploymentException
{
-
+ String name = ctx.toShortString();
+ kernelDeployer.undeploy(name);
}
}
More information about the jboss-cvs-commits
mailing list