User: user57
Date: 01/12/08 21:24:25
Modified: src/main/org/jboss/deployment AutoDeployer.java
DeployerMBeanSupport.java ServiceDeployer.java
Log:
o minor logging changes; trying to make the default configuration less
verbose on console, enable debug on console
Revision Changes Path
1.7 +86 -52 jboss/src/main/org/jboss/deployment/AutoDeployer.java
Index: AutoDeployer.java
===================================================================
RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/deployment/AutoDeployer.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- AutoDeployer.java 2001/11/24 19:46:41 1.6
+++ AutoDeployer.java 2001/12/09 05:24:25 1.7
@@ -49,19 +49,20 @@
* MBeanServer).
*
* If another Auto Deployer is deployed by an AutoDeployer then the initial
deployment
- * must be switched of to avoid the auto deployment to hang (see {@link
#setWithInitialRun
- * setWithInitialRun()}).
+ * must be switched of to avoid the auto deployment to hang (see
+ * {@link #setWithInitialRun()}).
*
* @see org.jboss.deployment.J2eeDeployer
+ *
* @author <a href="mailto:[EMAIL PROTECTED]">Rickard �berg</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Toby Allsopp</a>
* @author <a href="mailto:[EMAIL PROTECTED]">David Maplesden</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Andreas Schaefer</a>
- * @version $Revision: 1.6 $
+ * @version $Revision: 1.7 $
*/
public class AutoDeployer
extends ServiceMBeanSupport
- implements AutoDeployerMBean, NotificationListener,Runnable
+ implements AutoDeployerMBean, NotificationListener, Runnable
{
// Constants -----------------------------------------------------
// Attributes ----------------------------------------------------
@@ -280,16 +281,15 @@
// TODO: real urls
if (url.getProtocol().startsWith("file") && !new
File(url.getFile()).exists())
{
-
// the file does not exist anymore. undeploy
- log.info("Auto undeploy of " + url);
+ log.info("Auto undeploying: " + url);
try
{
undeploy(url.toString(), deployment.deployerName);
}
catch (Exception e)
{
- log.error("Undeployment failed", e);
+ log.error("Undeployment failed: " + url, e);
}
deployedURLs.remove(url);
@@ -319,7 +319,7 @@
// Check old timestamp -- always deploy if first check
if ((deployment.lastModified == 0) || (deployment.lastModified < lm))
{
- log.info("Auto deploy of " + deployment.url);
+ log.info("Auto deploying: " + deployment.url);
deployment.lastModified = lm;
try
{
@@ -327,8 +327,7 @@
}
catch (Throwable e)
{
- log.error("Deployment failed:" + deployment.url, e);
-
+ log.error("Deployment failed: " + deployment.url, e);
// Deployment failed - won't retry until updated
}
}
@@ -336,7 +335,8 @@
}
catch (Exception e)
{
- log.fatal("auto deployer failure; can not continue", e);
+ log.fatal("can not continue; exiting main loop", e);
+
// Stop auto deployer
running = false;
}
@@ -366,6 +366,8 @@
protected void startService()
throws Exception
{
+ boolean debug = log.isDebugEnabled();
+
// Save JMX names of configured deployers
StringTokenizer deployers = new StringTokenizer(deployerList, ";");
deployerNames = new ObjectName[deployers.countTokens()];
@@ -379,8 +381,7 @@
}
catch (MalformedObjectNameException mfone)
{
- log.warn("The string '" + deployerName + "'is not a valid " +
- "object name - ignoring it.");
+ log.warn("Ignoring invalid object name: " + deployerName);
continue;
}
@@ -393,18 +394,14 @@
}
catch (ReflectionException re)
{
- log.info("Deployer '" + deployerNames[i] + "' doesn't provide a " +
- "filter - will try to deploy all files");
- deployableFilters[i] =
- new FilenameFilter()
- {
- /**
- * #Description of the Method
- *
- * @param dir Description of Parameter
- * @param filename Description of Parameter
- * @return Description of the Returned Value
- */
+ if (debug) {
+ log.debug("Deployer '" + deployerNames[i] +
+ "' doesn't provide a " +
+ "filter - will try to deploy all files");
+ }
+
+ deployableFilters[i] = new FilenameFilter()
+ {
public boolean accept(File dir, String filename)
{
return true;
@@ -413,8 +410,12 @@
}
catch (InstanceNotFoundException e)
{
- log.info("Deployer '" + deployerNames[i] + "' isn't yet registered " +
- "files for this deployer will not be deployed until it is
deployed.");
+ if (debug) {
+ log.debug("Deployer '" + deployerNames[i] +
+ "' isn't yet registered " +
+ "files for this deployer will not be " +
+ "deployed until it is deployed.");
+ }
deployableFilters[i] = null;
}
}
@@ -434,27 +435,30 @@
if (metaFile.exists())
{
// It's unpackaged
-
try
{
watchedURLs.add(new Deployment(
urlFile.getCanonicalFile().toURL()));
- log.info("Auto-deploying " + urlFile.getCanonicalFile());
+ if (debug) {
+ log.debug("Watching url: " + urlFile.getCanonicalFile());
+ }
}
catch (Exception e)
{
- log.warn("Cannot auto-deploy " + urlFile);
+ log.warn("Failed add watched url: " + urlFile, e);
}
}
else
{
// This is a directory whose contents shall be checked
// for deployments
+ File dir = urlFile.getCanonicalFile();
try
{
- File dir = urlFile.getCanonicalFile();
watchedDirectories.add(dir);
- log.info("Watching " + dir);
+ if (debug) {
+ log.debug("Watching dir: " + dir);
+ }
// scan the directory now, so that the ordered deployments
// will work, when only a base directory is specified
@@ -462,7 +466,7 @@
}
catch (IOException e)
{
- log.warn("failed to add watched directory", e);
+ log.warn("Failed to add watched dir: " + dir, e);
}
}
}
@@ -474,11 +478,13 @@
{
watchedURLs.add(new Deployment(
urlFile.getCanonicalFile().toURL()));
- log.info("Auto-deploying " + urlFile.getCanonicalFile());
+ if (log.isDebugEnabled()) {
+ log.debug("Watching file: " + urlFile.getCanonicalFile());
+ }
}
catch (Exception e)
{
- log.warn("Cannot auto-deploy " + urlFile);
+ log.warn("Failed to add watched file: " + urlFile);
}
}
else
@@ -488,11 +494,13 @@
try
{
watchedURLs.add(new Deployment(new URL(url)));
+ if (debug) {
+ log.debug("Watching url: " + url);
+ }
}
catch (MalformedURLException e)
{
- // Didn't work
- log.warn("Cannot auto-deploy " + url);
+ log.warn("Failed to add watched url: " + url, e);
}
}
}
@@ -511,24 +519,30 @@
// Start auto deploy thread
running = true;
new Thread(this, "AutoDeployer").start();
-
}
public void handleNotification(Notification notification, Object handback)
{
+ boolean debug = log.isDebugEnabled();
+
String type = notification.getType();
- if(type.equals(MBeanServerNotification.REGISTRATION_NOTIFICATION))
+ if (type.equals(MBeanServerNotification.REGISTRATION_NOTIFICATION))
{
ObjectName mbean = ((MBeanServerNotification)notification).getMBeanName();
-
- log.debug("Received notification of mbean "+mbean+"'s deployment.");
-
+
+ if (debug) {
+ log.debug("Received notification of mbean "+mbean+"'s deployment.");
+ }
+
for(int i=0; i<deployerNames.length; i++)
{
if(deployerNames[i].equals(mbean))
{
- log.info("Deployer '" + deployerNames[i] + "' deployed, " +
- "now available for deployments.");
+ if (debug) {
+ log.debug("Deployer '" + deployerNames[i] + "' deployed, " +
+ "now available for deployments.");
+ }
+
try
{
deployableFilters[i] = (FilenameFilter) server.invoke(
@@ -537,8 +551,12 @@
}
catch (ReflectionException re)
{
- log.info("Deployer '" + deployerNames[i] + "' doesn't provide a "
+
- "filter - will try to deploy all files");
+ if (debug) {
+ log.debug("Deployer '" + deployerNames[i] +
+ "' doesn't provide a " +
+ "filter - will try to deploy all files");
+ }
+
deployableFilters[i] = new FilenameFilter()
{
public boolean accept(File dir, String filename)
@@ -547,9 +565,10 @@
}
};
}
- catch(Exception e)
+ catch (Exception e)
{
- log.error("Exception occurred accessing deployer '" +
deployerNames[i] + "'.",e);
+ log.error("Exception occurred accessing deployer: " +
+ deployerNames[i], e);
}
}
}
@@ -563,8 +582,10 @@
if(deployerNames[i].equals(mbean))
{
deployableFilters[i] = null;
- log.info("Deployer '" + deployerNames[i] + "' undeployed, " +
- "no longer available for deployments.");
+ if (debug) {
+ log.debug("Deployer '" + deployerNames[i] + "' undeployed, " +
+ "no longer available for deployments.");
+ }
}
}
}
@@ -581,6 +602,8 @@
protected void scanWatchedDirectories()
throws MalformedURLException
{
+ log.trace("Scanning watched directories");
+
for (int i = 0; i < watchedDirectories.size(); i++)
{
File dir = (File)watchedDirectories.get(i);
@@ -598,6 +621,11 @@
protected void scanDirectory(final File dir)
throws MalformedURLException
{
+ if (log.isTraceEnabled()) {
+ log.trace("Scanning directory: " + dir);
+ }
+ boolean debug = log.isDebugEnabled();
+
File[] files = dir.listFiles();
for (int idx = 0; idx < files.length; idx++)
{
@@ -617,7 +645,9 @@
// Add to list of files to deploy automatically
watchedURLs.add(new Deployment(fileUrl));
deployedURLs.put(fileUrl, fileUrl);
- log.info("Auto-deploying " + fileUrl);
+ if (debug) {
+ log.debug("Watching file: " + fileUrl);
+ }
}
}
}
@@ -677,7 +707,11 @@
protected void undeploy(String url, ObjectName deployerName)
throws Exception
{
- log.debug("undeploying url " + url + " using deployer " + deployerName);
+ if (log.isDebugEnabled()) {
+ log.debug("Undeploying url " + url +
+ " using deployer " + deployerName);
+ }
+
try
{
// Call the appropriate deployer through the JMX server
1.14 +16 -19 jboss/src/main/org/jboss/deployment/DeployerMBeanSupport.java
Index: DeployerMBeanSupport.java
===================================================================
RCS file:
/cvsroot/jboss/jboss/src/main/org/jboss/deployment/DeployerMBeanSupport.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- DeployerMBeanSupport.java 2001/11/26 20:10:02 1.13
+++ DeployerMBeanSupport.java 2001/12/09 05:24:25 1.14
@@ -6,7 +6,6 @@
*/
package org.jboss.deployment;
-
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -35,7 +34,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Toby Allsopp</a>
* @author <a href="mailto:[EMAIL PROTECTED]">David Jencks</a>
- * @version $Revision: 1.13 $
+ * @version $Revision: 1.14 $
*
* <p><b>Revisions:</b>
*
@@ -48,19 +47,16 @@
implements DeployerMBean
{
// Constants -----------------------------------------------------
- private static final String SERVICE_CONTROLLER_NAME =
"JBOSS-SYSTEM:spine=ServiceController";
+
+ private static final String SERVICE_CONTROLLER_NAME =
+ "JBOSS-SYSTEM:spine=ServiceController";
+
// Attributes --------------------------------------------------------
private ObjectName serviceControllerName;
-
private Map deployments = new HashMap();
- /*
- * log4j Category for logging
- */
- //protected Logger category;
-
/**
* The directory that will contain local copies of deployed packages
*/
@@ -162,22 +158,23 @@
deployDir = new File(deployTmpDir, getName());
if (deployDir.exists())
{
- getLog().info("Found a temp directory left over from a previous run - " +
- "deleting it.");
+ log.debug("Found a temp directory left over " +
+ "from a previous run; deleting it.");
+
// What could it mean?
if (!recursiveDelete(deployDir))
{
- getLog().warn("Unable to recursively delete temp directory '" +
- deployDir + "' that appears to be left over from " +
- "the previous run. This might cause problems.");
+ log.warn("Unable to recursively delete temp directory '" +
+ deployDir + "' that appears to be left over from " +
+ "the previous run. This might cause problems.");
}
}
if (!deployDir.exists() && !deployDir.mkdirs())
{
throw new DeploymentException("Can't create temp directory '" +
- deployDir + "'");
+ deployDir + "'");
}
- getLog().info("Temporary deploy directory is " + deployDir);
+ log.info("Temporary deploy directory is " + deployDir);
}
/**
@@ -190,9 +187,9 @@
// Remove our temp directory
if (!recursiveDelete(deployDir))
{
- getLog().warn("Unable to recursively delete the temp directory '" +
- deployDir + "' - it should be cleaned up when the " +
- "server is next restarted.");
+ log.warn("Unable to recursively delete the temp directory '" +
+ deployDir + "' - it should be cleaned up when the " +
+ "server is next restarted.");
}
}
1.17 +67 -29 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.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- ServiceDeployer.java 2001/11/26 19:47:19 1.16
+++ ServiceDeployer.java 2001/12/09 05:24:25 1.17
@@ -49,7 +49,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a>
* @author <a href="mailto:[EMAIL PROTECTED]">David Maplesden</a>
* @author <a href="mailto:[EMAIL PROTECTED]">David Jencks</a>
- * @version $Revision: 1.16 $ <p>
+ * @version $Revision: 1.17 $ <p>
*
* <b>20010830 marc fleury:</b>
* <ul>initial import
@@ -157,10 +157,16 @@
public Object deploy(URL url)
throws MalformedURLException, IOException, DeploymentException
{
+ boolean debug = log.isDebugEnabled();
+
SarDeploymentInfo sdi = getSdi(url, true);
if (sdi.state == MBEANSLOADED)
{
- log.debug("document " + url + " is already deployed, undeploy first if you
wish to redeploy");
+ if (debug) {
+ log.debug("document " + url + " is already deployed, undeploy " +
+ "first if you wish to redeploy");
+ }
+
return sdi;
}
@@ -179,18 +185,24 @@
try
{
NodeList lds = sdi.dd.getElementsByTagName("local-directory");
- log.debug("about to copy " + lds.getLength() + " local directories");
+ if (debug) {
+ log.debug("about to copy " + lds.getLength() + " local directories");
+ }
for (int i = 0; i< lds.getLength(); i++)
{
Element ld = (Element)lds.item(i);
String path = ld.getAttribute("path");
- log.debug("about to copy local directory at " + path);
+ if (debug) {
+ log.debug("about to copy local directory at " + path);
+ }
File jbossHomeDir = new
File(System.getProperty("jboss.system.home"));
File localBaseDir = new File(jbossHomeDir, "db"+File.separator);
//Get the url of the local copy from the classloader.
URL localUrl = (URL)sdi.getClassUrls().get(0);
- log.debug("copying from " + localUrl.toString() + path);
- log.debug("copying to " + localBaseDir);
+ if (debug) {
+ log.debug("copying from " + localUrl.toString() + path);
+ log.debug("copying to " + localBaseDir);
+ }
inflateJar(localUrl, localBaseDir, path);
} // end of for ()
@@ -251,13 +263,14 @@
private SarDeploymentInfo deployLocalClasses(URL url, URL needsme, boolean
reloadSuspended)
throws DeploymentException
{
+ boolean debug = log.isDebugEnabled();
SarDeploymentInfo sdi = getSdi(url, false);
-
+
if (reloadSuspended || sdi.state == EMPTY || sdi.state == GHOST)
{
try
{
- log.debug("deploying document " + url);
+ log.info("Deploying: " + url);
if(url.toString().endsWith("/")) //adding directory to classpath
{
@@ -272,8 +285,10 @@
URL localUrl = localCopy.toURL();
String localName = localCopy.getName();//just the filename, no path
extractPackages(localUrl, sdi);
- log.debug("jars from deployment: " + sdi.getClassUrls());
- log.debug("xml's from deployment: " + sdi.getXmlUrls());
+ if (debug) {
+ log.debug("jars from deployment: " + sdi.getClassUrls());
+ log.debug("xml's from deployment: " + sdi.getXmlUrls());
+ }
//OK, what are we trying to deploy?
//A plain xml file with mbean classpath elements and mbean config.
@@ -339,6 +354,7 @@
private boolean deployNeededPackages(URL url, SarDeploymentInfo sdi) throws
DeploymentException
{
+ boolean debug = log.isDebugEnabled();
Document dd = sdi.dd;
Collection weNeedClassesFrom = sdi.weNeedClassesFrom;
weNeedClassesFrom.clear();
@@ -346,14 +362,19 @@
for (int i = 0; i < classpaths.getLength(); i++)
{
Element classpath = (Element)classpaths.item(i);
- log.debug("found classpath " + classpath);
+ if (debug) {
+ log.debug("found classpath " + classpath);
+ }
String codebase = "";
String archives = "";
//Does it specify a codebase?
if (classpath != null)
{
- log.debug("setting up classpath " + classpath);
+ if (debug) {
+ log.debug("setting up classpath " + classpath);
+ }
+
// Load the codebase
codebase = classpath.getAttribute("codebase").trim();
@@ -372,11 +393,16 @@
else if (codebase.startsWith("http:") && !codebase.endsWith("/"))
{
codebase += "/";
+ }
+ if (debug) {
+ log.debug("codebase is " + codebase);
}
- log.debug("codebase is " + codebase);
+
//Load the archives
archives = classpath.getAttribute("archives").trim();
- log.debug("archives are " + archives);
+ if (debug) {
+ log.debug("archives are " + archives);
+ }
}
if (codebase.startsWith("file:") && archives.equals("*"))
@@ -437,7 +463,6 @@
// We have an archive whatever the codebase go ahead and load the
libraries
else if (!archives.equals(""))
{
-
// Still no codebase? get the system default
if (codebase.equals(""))
{
@@ -482,27 +507,29 @@
//find out if any of these were undeployed... if so we can't deploy
them nor our mbeans
if (jarSdi.state == GHOST) {
suspended = true;
- log.debug("did not deploy classes for " + neededUrl + ", it's a
ghost, we are suspended");
+ if (debug) {
+ log.debug("did not deploy classes for " + neededUrl + ", it's
a ghost, we are suspended");
+ }
} // end of if ()
else
{
deployLocalClasses(neededUrl, url, false);
- log.debug("deployed classes for " + neededUrl);
+ if (debug) {
+ log.debug("deployed classes for " + neededUrl);
+ }
} // end of else
} catch (DeploymentException e) {
log.error("problem deploying classes for " + neededUrl, e);
- //put in list of failures TODO
+ //put in list of failures TODO
} // end of try-catch
} // end of while ()
return suspended;
-
}
-
/**
* Undeploys the package at the url string specified. This will: Undeploy
* packages depending on this one. Stop, destroy, and unregister all the
@@ -522,7 +549,7 @@
public void undeploy(URL url, Object localurlObject)
throws MalformedURLException, IOException, DeploymentException
{
- log.debug("undeploying document " + url);
+ log.info("Undeploying: " + url);
SarDeploymentInfo sdi = getSdi(url, false);
@@ -639,7 +666,6 @@
{
log.error("Problem postregistering ServiceDeployer", e);
}
-
}
protected Document getDocument(URL url)
@@ -673,7 +699,11 @@
// Private --------------------------------------------------------
private void addMBeans(URL url, SarDeploymentInfo sdi) throws DeploymentException
{
- log.debug("addMBeans: url " + url);
+ boolean debug = log.isDebugEnabled();
+ if (debug) {
+ log.debug("addMBeans: url " + url);
+ }
+
List mbeans = sdi.mbeans;
mbeans.clear();
NodeList nl = sdi.dd.getElementsByTagName("mbean");
@@ -681,7 +711,9 @@
{
Element mbean = (Element)nl.item(i);
- log.debug("deploying with ServiceController mbean " + mbean);
+ if (debug) {
+ log.debug("deploying with ServiceController mbean " + mbean);
+ }
ObjectName service = (ObjectName)invoke(getServiceControllerName(),
"deploy",
new Object[]{mbean},
@@ -700,14 +732,21 @@
private void removeMBeans(URL url, SarDeploymentInfo sdi) throws
DeploymentException
{
- log.debug("removeMBeans: url " + url);
+ boolean debug = log.isDebugEnabled();
+ if (debug) {
+ log.debug("removeMBeans: url " + url);
+ }
+
List services = sdi.mbeans;
int lastService = services.size();
//stop services in reverse order.
for (ListIterator i = services.listIterator(lastService); i.hasPrevious();)
{
ObjectName name = (ObjectName)i.previous();
- log.debug("undeploying mbean " + name);
+ if (debug) {
+ log.debug("undeploying mbean " + name);
+ }
+
invoke(getServiceControllerName(),
"undeploy",
new Object[] {name},
@@ -802,7 +841,8 @@
private static final int GHOST = 5; //undeployed but packages are suspended on
us.
- protected static class SarDeploymentInfo extends
DeployerMBeanSupport.DeploymentInfo
+ protected static class SarDeploymentInfo
+ extends DeployerMBeanSupport.DeploymentInfo
{
Collection weNeedClassesFrom = new ArrayList();
Collection weSupplyClassesTo = new ArrayList();
@@ -815,8 +855,6 @@
super(key);
}
}
-
-
}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development