User: dmaplesden
Date: 01/09/04 18:49:44
Modified: src/main/org/jboss/deployment ServiceDeployer.java
Log:
Change deploy code to create all mbeans, then initialise all mbeans and finally
start all mbeans referred to by an URL.
Also change undeploy to stop and destroy mbeans it is undeploying.
Fix deploy code to store mbean list against url.
Revision Changes Path
1.2 +141 -27 jboss/src/main/org/jboss/deployment/ServiceDeployer.java
Index: ServiceDeployer.java
===================================================================
RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/deployment/ServiceDeployer.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ServiceDeployer.java 2001/08/29 22:47:27 1.1
+++ ServiceDeployer.java 2001/09/05 01:49:44 1.2
@@ -21,6 +21,8 @@
import java.util.Map;
import java.util.HashSet;
import java.util.Set;
+import java.util.List;
+import java.util.ArrayList;
import java.util.Iterator;
import java.util.HashMap;
import java.util.Collections;
@@ -57,7 +59,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a>
* @see org.jboss.system.Service
*
-* @version $Revision: 1.1 $
+* @version $Revision: 1.2 $
*
* <p><b>20010830 marc fleury:</b>
* <ul>
@@ -74,8 +76,8 @@
// each url can spawn a series of MLet classloaders that are specific to it
and cycled
private Map urlToClassLoadersSetMap;
- // each url can describe many Services, we keep the ObjectNames in here
- private Map urlToServicesSetMap;
+ // each url can describe many Services, we keep the ObjectNames in here, order
is important so use list
+ private Map urlToServicesListMap;
// JMX
private MBeanServer server;
@@ -120,7 +122,7 @@
// Support for the new packaged format
try {
- if (url.endsWith(".jsr")) {
+ if (url.endsWith(".jsr") || url.endsWith(".sar")) {
URLClassLoader cl = new URLClassLoader(new URL[] {new
URL(url)});
@@ -207,6 +209,15 @@
// The libraries are loaded we can now load the mbeans
+ // marcf: I don't think we should keep track and undeploy...
+ List services = (List) urlToServicesListMap.get(url);
+
+ if (services == null)
+ {
+ services = Collections.synchronizedList(new ArrayList());
+ urlToServicesListMap.put(url, services);
+ }
+
NodeList nl = document.getElementsByTagName("mbean");
for (int i = 0 ; i < nl.getLength() ; i++)
{
@@ -221,15 +232,6 @@
new Object[] {mbean},
new String[] {"org.w3c.dom.Element"});
- // marcf: I don't think we should keep track and
undeploy...
- Set services = (Set)
urlToServicesSetMap.get(System.getProperty("jboss.system.configurationDirectory") +
"jboss-service.xml");
-
- if (services == null)
- {
- services = Collections.synchronizedSet(new
HashSet());
-
urlToServicesSetMap.put(System.getProperty("jboss.system.configurationDirectory") +
"jboss-service.xml", services);
- }
-
services.add(service);
}
catch (MBeanException mbe)
{mbe.getTargetException().printStackTrace();}
@@ -239,19 +241,90 @@
catch (InstanceNotFoundException re) {}
catch (Exception e) {e.printStackTrace();}
}
+
+ //iterate through services and init.
+ for(Iterator it = services.iterator();it.hasNext();)
+ {
+ ObjectName service = (ObjectName)it.next();
+
+ try {
+ server.invoke(
+ new
ObjectName("JBOSS-SYSTEM:spine=ServiceController"),
+ "init",
+ new Object[] {service},
+ new String[] {"javax.management.ObjectName"});
+ }
+ catch (MBeanException mbe)
{mbe.getTargetException().printStackTrace();}
+ catch (RuntimeMBeanException rbe)
{rbe.getTargetException().printStackTrace();}
+ catch (MalformedObjectNameException mone) {}
+ catch (ReflectionException re) {}
+ catch (InstanceNotFoundException re) {}
+ catch (Exception e) {e.printStackTrace();}
+ }
+
+ //iterate through services and start.
+ for(Iterator it = services.iterator();it.hasNext();)
+ {
+ ObjectName service = (ObjectName)it.next();
+
+ try {
+ server.invoke(
+ new
ObjectName("JBOSS-SYSTEM:spine=ServiceController"),
+ "start",
+ new Object[] {service},
+ new String[] {"javax.management.ObjectName"});
+ }
+ catch (MBeanException mbe)
{mbe.getTargetException().printStackTrace();}
+ catch (RuntimeMBeanException rbe)
{rbe.getTargetException().printStackTrace();}
+ catch (MalformedObjectNameException mone) {}
+ catch (ReflectionException re) {}
+ catch (InstanceNotFoundException re) {}
+ catch (Exception e) {e.printStackTrace();}
+ }
}
public void undeploy (String url)
throws MalformedURLException, IOException, DeploymentException {
- Set set = (Set) urlToServicesSetMap.remove(url);
+ List set = (List) urlToServicesListMap.remove(url);
if (set != null)
{
-
- Iterator iterator = set.iterator();
- while (iterator.hasNext())
+ //stop services
+ for(Iterator iterator = set.iterator();iterator.hasNext();)
+ {
+ ObjectName name = (ObjectName) iterator.next();
+
+ try
+ {
+ server.invoke(
+ new
ObjectName("JBOSS-SYSTEM:spine=ServiceController"),
+ "stop",
+ new Object[] {name},
+ new String[]
{"javax.management.ObjectName"});
+ }
+ catch (Exception e) { e.printStackTrace();}
+ }
+
+ //destroy services
+ for(Iterator iterator = set.iterator();iterator.hasNext();)
+ {
+ ObjectName name = (ObjectName) iterator.next();
+
+ try
+ {
+ server.invoke(
+ new
ObjectName("JBOSS-SYSTEM:spine=ServiceController"),
+ "destroy",
+ new Object[] {name},
+ new String[]
{"javax.management.ObjectName"});
+ }
+ catch (Exception e) { e.printStackTrace();}
+ }
+
+ //undeploy services
+ for(Iterator iterator = set.iterator();iterator.hasNext();)
{
ObjectName name = (ObjectName) iterator.next();
@@ -271,7 +344,7 @@
public boolean isDeployed (String url)
throws MalformedURLException, DeploymentException {
- return urlToClassLoadersSetMap.containsKey(url);
+ return urlToServicesListMap.containsKey(url);
};
@@ -298,7 +371,7 @@
//Encapsulate with a ServiceClassLoader
urlToClassLoadersSetMap = Collections.synchronizedMap(new
HashMap());
- urlToServicesSetMap = Collections.synchronizedMap(new
HashMap());
+ urlToServicesListMap = Collections.synchronizedMap(new
HashMap());
//Initialize the libraries for the server by default we add
the libraries in lib/services
// and client
@@ -394,6 +467,14 @@
// The libraries are loaded we can now load the mbeans
+ List services = (List)
urlToServicesListMap.get(System.getProperty("jboss.system.configurationDirectory") +
"jboss-service.xml");
+
+ if (services == null)
+ {
+ services = Collections.synchronizedList(new
ArrayList());
+
urlToServicesListMap.put(System.getProperty("jboss.system.configurationDirectory") +
"jboss-service.xml", services);
+ }
+
NodeList nl = document.getElementsByTagName("mbean");
for (int i = 0 ; i < nl.getLength() ; i++)
{
@@ -408,14 +489,6 @@
new Object[] {mbean},
new String[] {"org.w3c.dom.Element"});
- Set services = (Set)
urlToServicesSetMap.get(System.getProperty("jboss.system.configurationDirectory") +
"jboss-service.xml");
-
- if (services == null)
- {
- services =
Collections.synchronizedSet(new HashSet());
-
urlToServicesSetMap.put(System.getProperty("jboss.system.configurationDirectory") +
"jboss-service.xml", services);
- }
-
services.add(service);
}
catch (MBeanException mbe)
{mbe.getTargetException().printStackTrace();}
@@ -426,6 +499,47 @@
catch (Exception e) {e.printStackTrace();}
}
+
+ //iterate through services and init.
+ for(Iterator it = services.iterator();it.hasNext();)
+ {
+ ObjectName service = (ObjectName)it.next();
+
+ try {
+ server.invoke(
+ new
ObjectName("JBOSS-SYSTEM:spine=ServiceController"),
+ "init",
+ new Object[] {service},
+ new String[]
{"javax.management.ObjectName"});
+ }
+ catch (MBeanException mbe)
{mbe.getTargetException().printStackTrace();}
+ catch (RuntimeMBeanException rbe)
{rbe.getTargetException().printStackTrace();}
+ catch (MalformedObjectNameException mone) {}
+ catch (ReflectionException re) {}
+ catch (InstanceNotFoundException re) {}
+ catch (Exception e) {e.printStackTrace();}
+ }
+
+ //iterate through services and start.
+ for(Iterator it = services.iterator();it.hasNext();)
+ {
+ ObjectName service = (ObjectName)it.next();
+
+ try {
+ server.invoke(
+ new
ObjectName("JBOSS-SYSTEM:spine=ServiceController"),
+ "start",
+ new Object[] {service},
+ new String[]
{"javax.management.ObjectName"});
+ }
+ catch (MBeanException mbe)
{mbe.getTargetException().printStackTrace();}
+ catch (RuntimeMBeanException rbe)
{rbe.getTargetException().printStackTrace();}
+ catch (MalformedObjectNameException mone) {}
+ catch (ReflectionException re) {}
+ catch (InstanceNotFoundException re) {}
+ catch (Exception e) {e.printStackTrace();}
+ }
+
}
catch (Exception e) {e.printStackTrace();}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development