User: salborini
Date: 00/08/17 18:48:14
Modified: src/main/org/jboss/ejb AutoDeployer.java
ContainerFactory.java
Log:
Added auto-undeploy when removing jar files.
Revision Changes Path
1.5 +47 -3 jboss/src/main/org/jboss/ejb/AutoDeployer.java
Index: AutoDeployer.java
===================================================================
RCS file: /products/cvs/ejboss/jboss/src/main/org/jboss/ejb/AutoDeployer.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- AutoDeployer.java 2000/05/30 18:32:15 1.4
+++ AutoDeployer.java 2000/08/18 01:48:13 1.5
@@ -37,7 +37,7 @@
*
* @see ContainerFactory
* @author Rickard �berg ([EMAIL PROTECTED])
- * @version $Revision: 1.4 $
+ * @version $Revision: 1.5 $
*/
public class AutoDeployer
extends ServiceMBeanSupport
@@ -166,12 +166,39 @@
}
}
}
-
+
+
+ // undeploy removed jars
+ Iterator iterator = watchedURLs.iterator();
+
+ while (iterator.hasNext()) {
+ URL url = ((Deployment)iterator.next()).url;
+
+ // if the url is a file that doesn't exist
+ // TODO: real urls
+ if (url.getProtocol().startsWith("file") && ! new
File(url.getFile()).exists()) {
+
+ // the file does not exist anymore. undeploy
+ log.log("Auto undeploy of "+url);
+ try {
+ undeploy(url.toString());
+ } catch (Exception e) {
+ log.error("Undeployment failed");
+ log.exception(e);
+ }
+ deployedURLs.remove(url);
+
+ // this should be the safe way to call
watchedURLS.remove
+ iterator.remove();
+ }
+ }
+
+
// Check watched URLs
for (int i = 0; i < watchedURLs.size(); i++)
{
Deployment deployment = (Deployment)watchedURLs.get(i);
-
+
// Get last modified timestamp
long lm;
if (deployment.watch.getProtocol().startsWith("file"))
@@ -256,6 +283,23 @@
{
// Call the ContainerFactory that is loaded in the JMX server
server.invoke(factoryName, "deploy",
+ new Object[] { url }, new String[] { "java.lang.String" });
+ } catch (MBeanException e)
+ {
+ throw e.getTargetException();
+ } catch (RuntimeErrorException e)
+ {
+ throw e.getTargetError();
+ }
+ }
+
+ protected void undeploy(String url)
+ throws Exception
+ {
+ try
+ {
+ // Call the ContainerFactory that is loaded in the JMX server
+ server.invoke(factoryName, "undeploy",
new Object[] { url }, new String[] { "java.lang.String" });
} catch (MBeanException e)
{
1.31 +6 -3 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.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- ContainerFactory.java 2000/08/16 13:01:58 1.30
+++ ContainerFactory.java 2000/08/18 01:48:13 1.31
@@ -74,7 +74,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Juha Lindfors</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Sebastien Alborini</a>
*
-* @version $Revision: 1.30 $
+* @version $Revision: 1.31 $
*/
public class ContainerFactory
extends org.jboss.util.ServiceMBeanSupport
@@ -240,6 +240,9 @@
// URL's to put in classloader
URL[] urls;
+ // save the name of the jar before copying -> undeploy with
the same name
+ URL origUrl = url;
+
// copy the jar file to prevent locking - redeploy failure
if (url.getProtocol().startsWith("file"))
{
@@ -548,8 +551,8 @@
// Done
log.log("Deployed application: "+app.getName());
- // Register deployment
- deployments.put(url, app);
+ // Register deployment. Use the original name in the hashtable
+ deployments.put(origUrl, app);
} catch (Throwable e)
{
e.printStackTrace();