User: juha
Date: 00/07/06 13:36:46
Modified: src/main/org/jboss/ejb Application.java Container.java
ContainerFactory.java ContainerFactoryMBean.java
Log:
Well, I got bored so I started writing javadocs for the container. Nothing fancy,
and most of the stuff was done already, so kudos to the people who came before me.
This is actually starting to look like a readable code now. In fact, it's hardly
recognizable
from a couple of months back.
I still can't test this but I don't think I managed to break anything. If I did, I'm
sure
we will all appreciate the irony.
Revision Changes Path
1.5 +38 -11 jboss/src/main/org/jboss/ejb/Application.java
Index: Application.java
===================================================================
RCS file: /products/cvs/ejboss/jboss/src/main/org/jboss/ejb/Application.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Application.java 2000/06/16 13:10:19 1.4
+++ Application.java 2000/07/06 20:36:44 1.5
@@ -20,7 +20,7 @@
* @see Container
* @see ContainerFactory
* @author Rickard �berg ([EMAIL PROTECTED])
- * @version $Revision: 1.4 $
+ * @version $Revision: 1.5 $
*/
public class Application
implements Service
@@ -28,8 +28,14 @@
// Constants -----------------------------------------------------
// Attributes ----------------------------------------------------
+
+ // stores the containers for this application unit
HashMap containers = new HashMap();
+
+ // name of this application
String name = "";
+
+ // url where this application was deployed from
URL url;
// Static --------------------------------------------------------
@@ -38,19 +44,19 @@
/**
- * Add a container to this application. This is called by the
ContainerFactory
+ * Add a container to this application. This is called by the ContainerFactory.
*
* @param con
*/
public void addContainer(Container con)
{
- containers.put(con.getMetaData().getEjbName(), con);
+ containers.put(con.getMetaData().getEjbName(), con);
con.setApplication(this);
}
/**
- * Remove a container from this application
+ * Remove a container from this application.
*
* @param con
*/
@@ -61,10 +67,11 @@
/**
- * Get a container from this Application that corresponds to a given name
+ * Get a container from this Application that corresponds to a given name
*
- * @param name
- * @return
+ * @param name ejb-name name defined in ejb-jar.xml
+ *
+ * @return container for the named bean, or null if the container was not
found
*/
public Container getContainer(String name)
{
@@ -73,9 +80,10 @@
/**
- * Get all containers in this Application
+ * Get all containers in this Application.
*
- * @return
+ * @return a collection of containers for each enterprise bean in this
application
+ * unit.
*/
public Collection getContainers()
{
@@ -127,11 +135,19 @@
throw new IllegalArgumentException("Null URL");
this.url = url;
+
+ // if name hasn't been set yet, use the url
if (name.equals(""))
name = url.toString();
}
// Service implementation ----------------------------------------
+
+ /**
+ * Initializes all the containers of this application.
+ *
+ * @exception Exception
+ */
public void init()
throws Exception
{
@@ -143,6 +159,11 @@
}
}
+ /**
+ * Starts all the containers of this application.
+ *
+ * @exception Exception
+ */
public void start()
throws Exception
{
@@ -150,20 +171,26 @@
while (enum.hasNext())
{
Container con = (Container)enum.next();
- con.start();
+ con.start();
}
}
+ /**
+ * Stops all the containers of this application.
+ */
public void stop()
{
Iterator enum = containers.values().iterator();
while (enum.hasNext())
{
Container con = (Container)enum.next();
- con.stop();
+ con.stop();
}
}
+ /**
+ * Destroys all the containers of this application.
+ */
public void destroy()
{
Iterator enum = containers.values().iterator();
1.19 +106 -31 jboss/src/main/org/jboss/ejb/Container.java
Index: Container.java
===================================================================
RCS file: /products/cvs/ejboss/jboss/src/main/org/jboss/ejb/Container.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- Container.java 2000/07/04 00:18:10 1.18
+++ Container.java 2000/07/06 20:36:45 1.19
@@ -51,7 +51,7 @@
import org.jnp.server.NamingServer;
/**
- * This is the base class for all EJB-containers in jBoss. A Container
+ * This is the base class for all EJB-containers in jBoss. A Container
* functions as the central hub of all metadata and plugins. Through this
* the container plugins can get hold of the other plugins and any metadata they
need.
*
@@ -64,7 +64,7 @@
* @see ContainerFactory
* @author Rickard �berg ([EMAIL PROTECTED])
* @author <a href="[EMAIL PROTECTED]">Marc Fleury</a>
- * @version $Revision: 1.18 $
+ * @version $Revision: 1.19 $
*/
public abstract class Container
{
@@ -99,49 +99,97 @@
// Public --------------------------------------------------------
+ /**
+ * Sets a transaction manager for this container.
+ *
+ * @see javax.transaction.TransactionManager
+ *
+ * @param tm
+ */
public void setTransactionManager(TransactionManager tm)
{
this.tm = tm;
}
+ /**
+ * Returns this container's transaction manager.
+ *
+ * @return a concrete instance of javax.transaction.TransactionManager
+ */
public TransactionManager getTransactionManager()
{
return tm;
}
- public void setApplication(Application app)
- {
+ /**
+ * Sets the application deployment unit for this container. All the bean
+ * containers within the same application unit share the same instance.
+ *
+ * @param app application for this container
+ */
+ public void setApplication(Application app)
+ {
if (app == null)
throw new IllegalArgumentException("Null application");
- application = app;
- }
+ application = app;
+ }
- public Application getApplication()
- {
- return application;
- }
+ /**
+ * Returns the application for this container.
+ *
+ * @return
+ */
+ public Application getApplication()
+ {
+ return application;
+ }
- public void setClassLoader(ClassLoader cl)
- {
- this.classLoader = cl;
- }
+ /**
+ * Sets the class loader for this container. All the classes and resources
+ * used by the bean in this container will use this classloader.
+ *
+ * @param cl
+ */
+ public void setClassLoader(ClassLoader cl)
+ {
+ this.classLoader = cl;
+ }
- public ClassLoader getClassLoader()
+ /**
+ * Returns the classloader for this container.
+ *
+ * @return
+ */
+ public ClassLoader getClassLoader()
{
return classLoader;
}
- public void setMetaData(jBossEnterpriseBean metaData)
- {
- this.metaData = metaData;
- }
+ /**
+ * Sets the meta data for this container. The meta data consists of the
+ * properties found in the XML descriptors.
+ *
+ * @param metaData
+ */
+ public void setMetaData(jBossEnterpriseBean metaData)
+ {
+ this.metaData = metaData;
+ }
- public jBossEnterpriseBean getMetaData()
+ /**
+ * Returns the metadata of this container.
+ *
+ * @return metaData;
+ */
+ public jBossEnterpriseBean getMetaData()
{
return metaData;
}
+
+ // the following two methods use the new metadata structures from
+ // package org.jboss.metadata
public void setBeanMetaData(BeanMetaData metaData) {
newMetaData = metaData;
}
@@ -149,37 +197,62 @@
return newMetaData;
}
+ /**
+ * Returns the bean class instance of this container.
+ *
+ * @return instance of the Enterprise bean class
+ */
public Class getBeanClass()
{
return beanClass;
}
+
/**
* The ContainerFactory calls this method. The ContainerFactory has set all the
* plugins and interceptors that this bean requires and now proceeds to
initialize
* the chain. The method looks for the standard classes in the URL, sets up
- * the naming environment of the bean.
+ * the naming environment of the bean. The concrete container classes should
+ * override this method to introduce implementation specific initialization
behaviour.
*
- * @exception Exception
+ * @exception Exception if loading the bean class failed
(ClassNotFoundException)
+ * or setting up "java:" naming environment failed
(DeploymentException)
*/
public void init()
throws Exception
{
// Acquire classes from CL
- beanClass = classLoader.loadClass(metaData.getEjbClass());
+ beanClass = classLoader.loadClass(metaData.getEjbClass());
// Setup "java:" namespace
- setupEnvironment();
+ setupEnvironment();
}
+ /**
+ * A default implementation of starting the container service (no-op). The
concrete
+ * container classes should override this method to introduce implementation
specific
+ * start behaviour.
+ *
+ * @exception Exception an exception that occured during start
+ */
public void start()
throws Exception
{
}
+ /**
+ * A default implementation of stopping the container service (no-op). The
concrete
+ * container classes should override this method to introduce implementation
specific
+ * stop behaviour.
+ */
public void stop()
{
}
+ /**
+ * A default implementation of destroying the container service (no-op). The
concrete
+ * container classes should override this method to introduce implementation
specific
+ * destroy behaviour.
+ */
public void destroy()
{
}
@@ -189,8 +262,8 @@
*
* The Container forwards this call to the interceptor chain for further
processing.
*
- * @param mi the object holding all info about this invocation
- * @return the result of the home invocation
+ * @param mi the object holding all info about this invocation
+ * @return the result of the home invocation
* @exception Exception
*/
public abstract Object invokeHome(MethodInvocation mi)
@@ -201,10 +274,10 @@
*
* The Container forwards this call to the interceptor chain for further
processing.
*
- * @param id the id of the object being invoked. May be null if stateless
- * @param method the method being invoked
- * @param args the parameters
- * @return the result of the invocation
+ * @param id the id of the object being invoked. May be null if
stateless
+ * @param method the method being invoked
+ * @param args the parameters
+ * @return the result of the invocation
* @exception Exception
*/
public abstract Object invoke(MethodInvocation mi)
@@ -272,7 +345,7 @@
bind(ctx, entry.getName(), new Boolean(entry.getValue()));
} else
{
- // Unknown type
+ // Unknown type
// Default is string
bind(ctx, entry.getName(), entry.getValue());
}
@@ -323,6 +396,8 @@
// Bind resource references
{
Iterator enum = getMetaData().getResourceReferences();
+
+ // let's play guess the cast game ;) New metadata should fix this.
ResourceManagers rms =
((jBossEjbJar)getMetaData().getBeanContext().getBeanContext()).getResourceManagers();
while(enum.hasNext())
{
1.24 +67 -23 jboss/src/main/org/jboss/ejb/ContainerFactory.java
Index: ContainerFactory.java
===================================================================
RCS file: /products/cvs/ejboss/jboss/src/main/org/jboss/ejb/ContainerFactory.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- ContainerFactory.java 2000/07/04 00:18:10 1.23
+++ ContainerFactory.java 2000/07/06 20:36:45 1.24
@@ -58,15 +58,15 @@
/**
* A ContainerFactory is used to deploy EJB applications. It can be given a URL to
-* an EJB-jar or EJB-JAR XML file, which will be used to instantiate containers
and make
-* them available for invocation.
+* an EJB-jar or EJB-JAR XML file, which will be used to instantiate containers and
make
+* them available for invocation.
*
* @see Container
* @author Rickard �berg ([EMAIL PROTECTED])
* @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Juha Lindfors</a>
*
-* @version $Revision: 1.23 $
+* @version $Revision: 1.24 $
*/
public class ContainerFactory
extends org.jboss.util.ServiceMBeanSupport
@@ -90,17 +90,38 @@
boolean verifyDeployments = false;
// Public --------------------------------------------------------
+
+ /**
+ * Implements the abstract <code>getObjectName()</code> method in superclass
+ * to return this service's name.
+ *
+ * @param server
+ * @param name
+ *
+ * @exception MalformedObjectNameException
+ * @return
+ */
public ObjectName getObjectName(MBeanServer server, ObjectName name)
throws javax.management.MalformedObjectNameException
{
return new ObjectName(OBJECT_NAME);
}
+ /**
+ * Implements the abstract <code>getName()</code> method in superclass to
+ * return the name of this object.
+ *
+ * @return <tt>'Container factory'</code>
+ */
public String getName()
{
return "Container factory";
}
+ /**
+ * Implements the template method in superclass. This method stops all the
+ * applications in this server.
+ */
public void stopService()
{
Iterator apps = deployments.values().iterator();
@@ -111,6 +132,10 @@
}
}
+ /**
+ * Implements the template method in superclass. This method destroys all
+ * the applications in this server and clears the deployments list.
+ */
public void destroyService()
{
Iterator apps = deployments.values().iterator();
@@ -123,11 +148,21 @@
deployments.clear();
}
+ /**
+ * Enables/disables the application bean verification upon deployment.
+ *
+ * @param verify true to enable; false to disable
+ */
public void setVerifyDeployments(boolean verify)
{
verifyDeployments = verify;
}
+ /**
+ * Returns the state of bean verifier (on/off)
+ *
+ * @param true if enabled; false otherwise
+ */
public boolean getVerifyDeployments()
{
return verifyDeployments;
@@ -167,12 +202,12 @@
/**
* Deploy EJBs pointed to by an URL.
* The URL may point to an EJB-JAR, an EAR-JAR, or an codebase
- * whose structure resembles that of an EJB-JAR.
+ * whose structure resembles that of an EJB-JAR. <p>
*
- * The latter is useful for development since no packaging is required
+ * The latter is useful for development since no packaging is required.
*
- * @param url URL where EJB deployment information is contained
- * @return The created containers
+ * @param url URL where EJB deployment information is contained
+ *
* @exception DeploymentException
*/
public synchronized void deploy(URL url)
@@ -189,22 +224,30 @@
if (deployments.containsKey(url))
undeploy(url);
- // Check validity
- if (verifyDeployments)
- {
- BeanVerifier verifier = new BeanVerifier();
-
- verifier.addVerificationListener(new VerificationListener()
- {
- public void beanChecked(VerificationEvent event)
- {
- System.out.println(event.getMessage());
- }
- });
-
- verifier.verify(url);
- }
-
+ // Check validity
+ try {
+ // wrapping this into a try - catch block to prevent errors in
+ // verifier from stopping the deployment
+
+ if (verifyDeployments)
+ {
+ BeanVerifier verifier = new BeanVerifier();
+
+ verifier.addVerificationListener(new VerificationListener()
+ {
+ public void beanChecked(VerificationEvent event)
+ {
+ System.out.println("Got event: " + event.getMessage());
+ }
+ });
+
+ verifier.verify(url);
+ }
+ }
+ catch (Throwable t) {
+ System.out.println(t);
+ }
+
app.setURL(url);
log.log("Deploying:"+url);
@@ -259,6 +302,7 @@
// Set metadata
container.setMetaData(bean);
+ // use the new metadata classes in org.jboss.metadata
container.setBeanMetaData(efm.getMetaData().getBean(bean.getEjbName()));
// Set transaction manager
1.4 +11 -1 jboss/src/main/org/jboss/ejb/ContainerFactoryMBean.java
Index: ContainerFactoryMBean.java
===================================================================
RCS file:
/products/cvs/ejboss/jboss/src/main/org/jboss/ejb/ContainerFactoryMBean.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ContainerFactoryMBean.java 2000/06/16 13:10:19 1.3
+++ ContainerFactoryMBean.java 2000/07/06 20:36:45 1.4
@@ -13,7 +13,7 @@
*
* @see ContainerFactory
* @author Rickard �berg ([EMAIL PROTECTED])
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
*/
public interface ContainerFactoryMBean
extends org.jboss.util.ServiceMBean
@@ -44,8 +44,18 @@
public void undeploy(String url)
throws MalformedURLException, DeploymentException;
+ /**
+ * Enable/disable bean verification upon deployment.
+ *
+ * @param verify true to enable the verifier; false to disable
+ */
public void setVerifyDeployments(boolean verify);
+ /**
+ * Returns the state of the verifier (enabled/disabled)
+ *
+ * @return true if verifier is enabled; false otherwise
+ */
public boolean getVerifyDeployments();
}