User: user57 Date: 02/01/02 20:00:57 Modified: src/main/org/jboss/deployment AutoDeployer.java DeployerMBeanSupport.java J2eeDeployer.java J2eeDeployerMBean.java ServiceDeployer.java ServiceDeployerMBean.java Log: o migrated all components to a new JMX domain name model. jboss.system is now where to core/spine components live. moved all components that were in JBOSS-SYSTEM that did not move into a jboss.* domain into jboss (where the server is now registered). The point was to limit the members of jboss.system to core bits only. o Created org.jboss.system.Server, which does the work of initialization that org.jboss.Main used to do. Main now only parses the command line, sets up basic legecy properties and creates a Server instance. o Moved functionality of Shutdown (component not cl tool) into Server ( which is bound as jboss.system:service=Server) o Moved more Runtime access from Info into Server. Exposed memory info as attributes. o Logging a WARN everywhere that uses System.getProperty("jboss.system.home") as that should go away soon/eventually. o Initialized the invokerMap in the harmi impl to avoid NPE o Made getopt.jar a member of the lib/* dir instead of adding it to the run.jar and shutdown.jars each time. o Minor cosmetic changes along the way. Revision Changes Path 1.9 +3 -9 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.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- AutoDeployer.java 2002/01/02 17:06:54 1.8 +++ AutoDeployer.java 2002/01/03 04:00:57 1.9 @@ -4,6 +4,7 @@ * Distributable under LGPL license. * See terms of license at gnu.org. */ + package org.jboss.deployment; import java.io.File; @@ -58,15 +59,12 @@ * @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.8 $ + * @version $Revision: 1.9 $ */ public class AutoDeployer extends ServiceMBeanSupport implements AutoDeployerMBean, NotificationListener, Runnable { - // Constants ----------------------------------------------------- - // Attributes ---------------------------------------------------- - /** * Callback to the JMX agent. */ @@ -143,7 +141,7 @@ */ public AutoDeployer(String urlList) { - this("J2EE:service=J2eeDeployer", urlList); + this("jboss.j2ee:service=J2eeDeployer", urlList); } /** @@ -592,8 +590,6 @@ } } - // Protected ----------------------------------------------------- - /** * Scan the watched directories list, add new deployement entires for each * that does not already exist in the watched urls map. @@ -729,8 +725,6 @@ throw e.getTargetError(); } } - - // Inner classes ------------------------------------------------- /** * This class holds info about a deployement, such as the URL and the last 1.16 +96 -101 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.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- DeployerMBeanSupport.java 2001/12/18 22:59:37 1.15 +++ DeployerMBeanSupport.java 2002/01/03 04:00:57 1.16 @@ -1,9 +1,10 @@ /* -* JBoss, the OpenSource J2EE webOS -* -* Distributable under LGPL license. -* See terms of license at gnu.org. -*/ + * JBoss, the OpenSource J2EE webOS + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ + package org.jboss.deployment; import java.io.File; @@ -30,35 +31,38 @@ import java.util.List; /** -* An abstract base class for deployer service implementations. -* -* @author <a href="mailto:[EMAIL PROTECTED]">Toby Allsopp</a> -* @author <a href="mailto:[EMAIL PROTECTED]">David Jencks</a> -* @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a> -* @version $Revision: 1.15 $ -* -* <p><b>Revisions:</b> -* -* <p><b>20010725 Toby Allsopp (patch from David Jencks)</b> -* <ul><li>Added <code>getDeployments</code> method so that subclasses -* can find out what has been deployed.</li></ul> -* <p><b>20011219 Marc Fleury</b> -* <ul><li>Factored out inner class for deployment info</li></ul> -*/ + * An abstract base class for deployer service implementations. + * + * @author <a href="mailto:[EMAIL PROTECTED]">Toby Allsopp</a> + * @author <a href="mailto:[EMAIL PROTECTED]">David Jencks</a> + * @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a> + * @version $Revision: 1.16 $ + * + * <p><b>Revisions:</b> + * + * <p><b>20010725 Toby Allsopp (patch from David Jencks)</b> + * <ul><li>Added <code>getDeployments</code> method so that subclasses + * can find out what has been deployed.</li></ul> + * <p><b>20011219 Marc Fleury</b> + * <ul><li>Factored out inner class for deployment info</li></ul> + */ public abstract class DeployerMBeanSupport -extends ServiceMBeanSupport -implements DeployerMBean + extends ServiceMBeanSupport + implements DeployerMBean { // Constants ----------------------------------------------------- - private static final String SERVICE_CONTROLLER_NAME = "JBOSS-SYSTEM:spine=ServiceController"; + private static final String SERVICE_CONTROLLER_NAME = + "jboss.system:service=ServiceController"; + // Attributes -------------------------------------------------------- + private ObjectName serviceControllerName; private Map deployments = new HashMap(); /** - * The directory that will contain local copies of deployed packages - */ + * The directory that will contain local copies of deployed packages + */ private File deployDir; // Static -------------------------------------------------------- @@ -82,7 +86,7 @@ // DeployerMBean implementation ---------------------------------- public void deploy (String url) - throws MalformedURLException, IOException, DeploymentException + throws MalformedURLException, IOException, DeploymentException { URL u = new URL(url); synchronized (deployments) @@ -113,7 +117,7 @@ } public void undeploy (String url) - throws MalformedURLException, IOException, DeploymentException + throws MalformedURLException, IOException, DeploymentException { URL u = new URL(url); synchronized (deployments) @@ -127,7 +131,7 @@ } public boolean isDeployed (String url) - throws MalformedURLException, DeploymentException + throws MalformedURLException, DeploymentException { URL u = new URL(url); synchronized (deployments) @@ -139,19 +143,17 @@ // ServiceMBeanSupport overrides --------------------------------- /** - * The <code>startService</code> method sets up a temporary directory - * to hold the copies of deployed packages and possibly inflations - * of those copies. The format is (jboss.system.home)/tmp/deploy/(deployername). - * - * @exception Exception if an error occurs - */ + * The <code>startService</code> method sets up a temporary directory + * to hold the copies of deployed packages and possibly inflations + * of those copies. The format is (jboss.system.home)/tmp/deploy/(deployername). + */ protected void startService() - throws Exception + throws Exception { - // FIXME MARCF I think we should keep the old code around (would speed up boot time) // Just delete on undeploy and if there is new stuff - + + log.warn("using jboss.system.home property"); deployDir = new File( // from the top of the jboss home distribution System.getProperty("jboss.system.home"), @@ -180,10 +182,9 @@ } /** - * The <code>stopService</code> method tries to remove the - * directory created in the createService method. - * - */ + * The <code>stopService</code> method tries to remove the + * directory created in the createService method. + */ protected void stopService() { // Remove our temp directory @@ -200,16 +201,16 @@ // Protected ----------------------------------------------------- /** - * Retrieves the object associated with a deployment. This - * association is made during deployment using the object returned - * from <code>deploy(URL)</code>. If there is no such deployment, - * null is returned. Note that this is distinguishable from the - * case of a deployment with an null information object only using - * <code>isDeployed(URL)</code>. - * - * @param url the deployment for which information is required - * @return an object, possibly null - */ + * Retrieves the object associated with a deployment. This + * association is made during deployment using the object returned + * from <code>deploy(URL)</code>. If there is no such deployment, + * null is returned. Note that this is distinguishable from the + * case of a deployment with an null information object only using + * <code>isDeployed(URL)</code>. + * + * @param url the deployment for which information is required + * @return an object, possibly null + */ protected Object getInfo(URL url) { synchronized (deployments) @@ -219,36 +220,36 @@ } /** - * Subclasses override to perform actual deployment. - * - * @param url the location to be deployed - * @return an object, possibly null, that will be passed back to - * <code>undeploy</code> and can be obtained using - * <code>getInfo(URL)</code> - */ + * Subclasses override to perform actual deployment. + * + * @param url the location to be deployed + * @return an object, possibly null, that will be passed back to + * <code>undeploy</code> and can be obtained using + * <code>getInfo(URL)</code> + */ protected abstract Object deploy(URL url) - throws IOException, DeploymentException; + throws IOException, DeploymentException; /** - * Subclasses override to perform any actions neccessary for - * undeployment. - * - * @param url the location to be undeployed - * @param info the object that was returned by the corresponding - * <code>deploy</code> - */ + * Subclasses override to perform any actions neccessary for + * undeployment. + * + * @param url the location to be undeployed + * @param info the object that was returned by the corresponding + * <code>deploy</code> + */ protected abstract void undeploy(URL url, Object info) - throws IOException, DeploymentException; + throws IOException, DeploymentException; /** - * Returns the deployments that have been deployed by this - * deployer. The <code>Map</code> returned from this method is a - * snapshot of the deployments at the time the method is called and - * will not reflect any subsequent deployments or undeployments. - * - * @return a mapping from <code>URL</code> to - * <code>DeploymentInfo</code> - */ + * Returns the deployments that have been deployed by this + * deployer. The <code>Map</code> returned from this method is a + * snapshot of the deployments at the time the method is called and + * will not reflect any subsequent deployments or undeployments. + * + * @return a mapping from <code>URL</code> to + * <code>DeploymentInfo</code> + */ protected Map getDeployments() { Map ret = new HashMap(); @@ -259,25 +260,25 @@ return ret; } - // Below here are helper methods to deal with copying packages, // unpacking packages recursively, finding things in packages, // and similar tasks needed for most deployment activities. - // + /** - * The <code>inflateJar</code> copies the jar entries - * from the jar url jarUrl to the directory destDir. - * It can be used on the whole jar, a directory, or - * a specific file in the jar. - * - * @param jarUrl the <code>URL</code> if the directory or entry to copy. - * @param destDir the <code>File</code> value of the directory in which to - * place the inflated copies. - * @exception DeploymentException if an error occurs - * @exception IOException if an error occurs - */ + * The <code>inflateJar</code> copies the jar entries + * from the jar url jarUrl to the directory destDir. + * It can be used on the whole jar, a directory, or + * a specific file in the jar. + * + * @param jarUrl the <code>URL</code> if the directory or entry to copy. + * @param destDir the <code>File</code> value of the directory in which to + * place the inflated copies. + * + * @throws DeploymentException if an error occurs + * @throws IOException if an error occurs + */ protected void inflateJar(URL url, File destDir, String path) - throws DeploymentException, IOException + throws DeploymentException, IOException { /* //Why doesn't this work???? Maybe in java 1.4? @@ -346,7 +347,7 @@ } protected void extractPackages(URL url, ServiceDeploymentInfo di) - throws DeploymentException, IOException + throws DeploymentException, IOException { if (url.getFile().endsWith(".xml")) { @@ -448,7 +449,7 @@ } protected void copy(InputStream in, OutputStream out) - throws IOException + throws IOException { byte[] buffer = new byte[1024]; int read; @@ -476,9 +477,8 @@ public File getDeployDir() { return deployDir; } - public File getLocalCopy(URL url, ServiceDeploymentInfo di) - throws IOException + throws IOException { // Create a directory into which we are going to put the bytes File localDir = new File(deployDir, generateUniqueDirName()+ File.separator); @@ -529,17 +529,12 @@ return serviceControllerName; } - // Private ------------------------------------------------------- - private File getUniqueDir(ServiceDeploymentInfo di) { - File dir = new File(deployDir, generateUniqueDirName() + File.separator); - di.addDir(dir); - return dir; + File dir = new File(deployDir, generateUniqueDirName() + File.separator); + di.addDir(dir); + return dir; } - - // Inner classes ------------------------------------------------- - } 1.52 +15 -11 jboss/src/main/org/jboss/deployment/J2eeDeployer.java Index: J2eeDeployer.java =================================================================== RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/deployment/J2eeDeployer.java,v retrieving revision 1.51 retrieving revision 1.52 diff -u -r1.51 -r1.52 --- J2eeDeployer.java 2001/12/20 16:55:03 1.51 +++ J2eeDeployer.java 2002/01/03 04:00:57 1.52 @@ -55,7 +55,7 @@ * @author <a href="mailto:[EMAIL PROTECTED]">Toby Allsopp</a> * @author <a href="mailto:[EMAIL PROTECTED]">Scott Stark</a>. * @author <a href="mailto:[EMAIL PROTECTED]">Christoph G. Jung</a>. - * @version $Revision: 1.51 $ + * @version $Revision: 1.52 $ */ public class J2eeDeployer extends ServiceMBeanSupport @@ -93,7 +93,6 @@ // <comment author="cgjung"> better be protected for subclassing </comment> protected InstallerFactory installer; - // Constructors -------------------------------------------------- public J2eeDeployer() @@ -169,16 +168,18 @@ }; } - /** Deploys the given URL independent if it is a EJB.jar, Web.war - * or Application.ear. In case of already deployed, it performes a - * redeploy. - * @param _url the url (file or http) to the archiv to deploy - * @throws MalformedURLException in case of a malformed url - * @throws J2eeDeploymentException if something went wrong... - * @throws IOException if trouble while file download occurs + /** + * Deploys the given URL independent if it is a EJB.jar, Web.war + * or Application.ear. In case of already deployed, it performes a + * redeploy. + * + * @param _url the url (file or http) to the archiv to deploy + * @throws MalformedURLException in case of a malformed url + * @throws J2eeDeploymentException if something went wrong... + * @throws IOException if trouble while file download occurs */ public void deploy(String _url) - throws MalformedURLException, IOException, J2eeDeploymentException + throws MalformedURLException, IOException, J2eeDeploymentException { URL url = new URL(_url); @@ -302,6 +303,8 @@ } protected File getTempDir() throws IOException { + log.warn("using jboss.system.home property"); + File dir = new File(System.getProperty("jboss.system.home")); dir = new File(dir, "tmp"); dir = new File(dir, "deploy"); @@ -376,7 +379,8 @@ * @throws IOException if the download fails * @throws J2eeDeploymentException if the given package is somehow inconsistent */ - protected Deployment installApplication(URL _downloadUrl) throws IOException, J2eeDeploymentException + protected Deployment installApplication(URL _downloadUrl) + throws IOException, J2eeDeploymentException { return installer.install(_downloadUrl); } 1.10 +17 -19 jboss/src/main/org/jboss/deployment/J2eeDeployerMBean.java Index: J2eeDeployerMBean.java =================================================================== RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/deployment/J2eeDeployerMBean.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- J2eeDeployerMBean.java 2001/11/12 06:52:16 1.9 +++ J2eeDeployerMBean.java 2002/01/03 04:00:57 1.10 @@ -4,8 +4,8 @@ * Distributable under LGPL license. * See terms of license at gnu.org. */ -package org.jboss.deployment; +package org.jboss.deployment; import java.io.IOException; import java.net.MalformedURLException; @@ -13,31 +13,29 @@ import org.jboss.system.ServiceMBean; /** - * @see - * @author <a href="mailto:[EMAIL PROTECTED]">Daniel Schulze</a> - * @author <a href="mailto:[EMAIL PROTECTED]">Toby Allsopp</a> - * @version $Revision: 1.9 $ + * ??? + * + * @author <a href="mailto:[EMAIL PROTECTED]">Daniel Schulze</a> + * @author <a href="mailto:[EMAIL PROTECTED]">Toby Allsopp</a> + * @version $Revision: 1.10 $ */ public interface J2eeDeployerMBean extends DeployerMBean { - // Constants ----------------------------------------------------- - public static final String OBJECT_NAME = "J2EE:service=J2eeDeployer"; + String OBJECT_NAME = "jboss.j2ee:service=J2eeDeployer"; - // Public -------------------------------------------------------- - public void setDeployerName(String name); - public String getDeployerName(); + void setDeployerName(String name); + String getDeployerName(); - public void setJarDeployer(ObjectName jarDeployer); - public ObjectName getJarDeployer(); + void setJarDeployer(ObjectName jarDeployer); + ObjectName getJarDeployer(); - public void setWarDeployer(ObjectName warDeployer); - public ObjectName getWarDeployer(); + void setWarDeployer(ObjectName warDeployer); + ObjectName getWarDeployer(); - public void setRarDeployer(ObjectName rarDeployer); - public ObjectName getRarDeployer(); + void setRarDeployer(ObjectName rarDeployer); + ObjectName getRarDeployer(); - public void setServiceDeployer(ObjectName javaDeployer); - public ObjectName getServiceDeployer(); - + void setServiceDeployer(ObjectName javaDeployer); + ObjectName getServiceDeployer(); } 1.22 +181 -200 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.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- ServiceDeployer.java 2001/12/29 21:57:20 1.21 +++ ServiceDeployer.java 2002/01/03 04:00:57 1.22 @@ -1,11 +1,11 @@ /* -* JBoss, the OpenSource J2EE webOS -* -* Distributable under LGPL license. -* See terms of license at gnu.org. -*/ -package org.jboss.deployment; + * JBoss, the OpenSource J2EE webOS + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package org.jboss.deployment; import java.io.File; import java.io.FilenameFilter; @@ -43,95 +43,93 @@ import org.xml.sax.SAXException; /** -* This is the main Service Deployer API. -* -* @see org.jboss.system.Service -* @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.21 $ <p> -* -* <b>20010830 marc fleury:</b> -* <ul>initial import -* <li> -* </ul> -* -* <p><b>20010905 david maplesden:</b> -* <ul> -* <li>Changed deployment procedure to deploy all listed mbeans, then -* initialise them all before finally starting them all. Changed services -* sets to lists to maintain ordering. -* </ul> -* -* <b>20010908 david jencks</b> -* <ol> -* <li> fixed tabs to spaces and log4j logging. Made the urlToServiceSet -* map actually use the url supplied to deploy. Made postRegister use -* deploy. Made undeploy work, and implemented sar dependency management -* and recursive deploy/undeploy. -* </ol> -* -* <p><b>20010907 david maplesden:</b> -* <ul> -* <li>Added support for "depends" tag -* </ul> -* -* <p><b>20011210 marc fleury:</b> -* <ul> -* <li>Removing the classpath dependency to explicit jars -* </ul> -* <p><b>20011211 marc fleury:</b> -* <ul> -* <li>rewrite -* </ul> -*/ + * This is the main Service Deployer API. + * + * @see org.jboss.system.Service + * @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.22 $ <p> + * + * <b>20010830 marc fleury:</b> + * <ul>initial import + * <li> + * </ul> + * + * <p><b>20010905 david maplesden:</b> + * <ul> + * <li>Changed deployment procedure to deploy all listed mbeans, then + * initialise them all before finally starting them all. Changed services + * sets to lists to maintain ordering. + * </ul> + * + * <b>20010908 david jencks</b> + * <ol> + * <li> fixed tabs to spaces and log4j logging. Made the urlToServiceSet + * map actually use the url supplied to deploy. Made postRegister use + * deploy. Made undeploy work, and implemented sar dependency management + * and recursive deploy/undeploy. + * </ol> + + * <p><b>20010907 david maplesden:</b> + * <ul> + * <li>Added support for "depends" tag + * </ul> + * + * <p><b>20011210 marc fleury:</b> + * <ul> + * <li>Removing the classpath dependency to explicit jars + * </ul> + * + * <p><b>20011211 marc fleury:</b> + * <ul> + * <li>rewrite + * </ul> + */ public class ServiceDeployer -extends DeployerMBeanSupport -implements ServiceDeployerMBean + extends DeployerMBeanSupport + implements ServiceDeployerMBean { // Attributes -------------------------------------------------------- private ObjectName objectName; - //Find all the deployment info for a url + // Find all the deployment info for a url private final Map urlToServiceDeploymentInfoMap = new HashMap(); - //Find what package an mbean came from. + // Find what package an mbean came from. private final Map objectNameToSupplyingPackageMap = new HashMap(); - - // Public -------------------------------------------------------- /** - * Gets the Name of the ServiceDeployer object - * - * @return returns "ServiceDeployer" - */ + * Gets the Name of the ServiceDeployer object + * + * @return returns "ServiceDeployer" + */ public String getName() { return "ServiceDeployer"; } /** - * Gets the FilenameFilter that the AutoDeployer uses to decide which files - * will be deployed by the ServiceDeployer. Currently .jsr, .sar, and files - * ending in service.xml are accepted. - * - * @return The FileNameFilter for use by the AutoDeployer. - */ + * Gets the FilenameFilter that the AutoDeployer uses to decide which files + * will be deployed by the ServiceDeployer. Currently .jsr, .sar, and files + * ending in service.xml are accepted. + * + * @return The FileNameFilter for use by the AutoDeployer. + */ public FilenameFilter getDeployableFilter() { - return - new FilenameFilter() + return new FilenameFilter() { /** - * Determines which files are accepted by the Deployer. - * - * @param dir Directory of candidate file. - * @param filename Filename of candidate file. - * @return Whether candidate file should be deployed by - * this deployer. - */ + * Determines which files are accepted by the Deployer. + * + * @param dir Directory of candidate file. + * @param filename Filename of candidate file. + * @return Whether candidate file should be deployed by + * this deployer. + */ public boolean accept(File dir, String filename) { filename = filename.toLowerCase(); @@ -141,29 +139,28 @@ }; } - /** - * Deploys a package identified by a url string. This stops if a previous - * version exists. The package can be a *service.xml file, a sar service - * archive, or a plain jar or zip file with no deployment descriptor. - * In any case, all classes found in the package or sar subpackages are - * added to the extensible classloader. If there are classpath elements - * in the configuration file, the named packages are loaded - * (in separate classloaders) unless they have been explicitly undeployed, - * in which case deployment of this package is suspended until they have been - * redeployed. Then the mbeans named in the configuration file are created - * using the ServiceController. Dependencies between mbeans are handled by - * the ServiceController. - * - * @param urlString The location of the package to deploy - * @exception MalformedURLException Thrown if a malformed url string is - * supplied. - * @exception IOException Thrown if some read operation failed. - * @exception DeploymentException Thrown if the package could not be - * deployed. - */ + * Deploys a package identified by a url string. This stops if a previous + * version exists. The package can be a *service.xml file, a sar service + * archive, or a plain jar or zip file with no deployment descriptor. + * In any case, all classes found in the package or sar subpackages are + * added to the extensible classloader. If there are classpath elements + * in the configuration file, the named packages are loaded + * (in separate classloaders) unless they have been explicitly undeployed, + * in which case deployment of this package is suspended until they have been + * redeployed. Then the mbeans named in the configuration file are created + * using the ServiceController. Dependencies between mbeans are handled by + * the ServiceController. + * + * @param urlString The location of the package to deploy + * @exception MalformedURLException Thrown if a malformed url string is + * supplied. + * @exception IOException Thrown if some read operation failed. + * @exception DeploymentException Thrown if the package could not be + * deployed. + */ public Object deploy(URL url) - throws MalformedURLException, IOException, DeploymentException + throws MalformedURLException, IOException, DeploymentException { ServiceDeploymentInfo sdi = getSdi(url, true); @@ -182,13 +179,13 @@ } // The deployment descriptor was loaded by deployLocalClasses - if(sdi.dd != null) + if (sdi.dd != null) { // In case there is a dependent classpath defined parse it // This creates parseXMLClasspath(url, sdi); - //Copy local directory if local-directory element is present + // Copy local directory if local-directory element is present try { NodeList lds = sdi.dd.getElementsByTagName("local-directory"); @@ -198,6 +195,7 @@ Element ld = (Element)lds.item(i); String path = ld.getAttribute("path"); log.debug("about to copy local directory at " + path); + log.warn("using jboss.system.home property"); 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. @@ -206,13 +204,12 @@ log.debug("copying to " + localBaseDir); inflateJar(localUrl, localBaseDir, path); - } // end of for () - - - } catch (Exception e) + } + } + catch (Exception e) { log.error("Problem copying local directory", e); - } // end of try-catch + } // install the MBeans in this descriptor log.debug("addMBeans: url " + url); @@ -224,7 +221,6 @@ for (int i = 0; i < nl.getLength(); i++) { - Element mbean = (Element)nl.item(i); log.debug("deploying with ServiceController mbean " + mbean); @@ -271,19 +267,16 @@ } return sdi; } - - private ServiceDeploymentInfo loadFiles(URL url) - throws DeploymentException + private ServiceDeploymentInfo loadFiles(URL url) throws DeploymentException { - ServiceDeploymentInfo sdi = getSdi(url, true); if (sdi.state == ServiceDeploymentInfo.EMPTY) { try { - log.debug("deploying document " + url); + log.info("deploying: " + url); // A service can be as simple as a directory from which to load classes if(url.toString().endsWith("/")) @@ -294,7 +287,6 @@ } else // That "service" is a file { - // Create a local copy of that File, the sdi keeps track of the copy directory File localFile = getLocalCopy(url, sdi); @@ -313,8 +305,8 @@ sdi.state = ServiceDeploymentInfo.CLASSESLOADED; } - //a service archive with classes, jars, and META-INF/jboss-service.xml - //configuration file + // a service archive with classes, jars, and META-INF/jboss-service.xml + // configuration file else if (localFile.getName().endsWith(".sar")) { sdi.createClassLoader(); @@ -325,20 +317,19 @@ URL docUrl = (URL)i.next(); if (docUrl.getFile().endsWith("META-INF/jboss-service.xml")) { - sdi.dd = getDocument(docUrl); break docfound; - } // end of if () + } + } - } // end of for () throw new DeploymentException("No META-INF/jboss-service.xml found in alleged sar!"); } //sdi.state = ServiceDeploymentInfo.CLASSESLOADED; log.debug("got document jboss-service.xml from cl"); } - //Or maybe its just a jar to be put in the extensible classloader. + // Or maybe its just a jar to be put in the extensible classloader. else if(localFile.getName().endsWith(".jar") || localFile.getName().endsWith(".zip")) { @@ -361,10 +352,10 @@ } // end of if (EMPTY) return sdi; - } - private void parseXMLClasspath(URL url, ServiceDeploymentInfo sdi) throws DeploymentException + private void parseXMLClasspath(URL url, ServiceDeploymentInfo sdi) + throws DeploymentException { Document dd = sdi.dd; @@ -430,12 +421,12 @@ new java.io.FileFilter() { /** - * filters for jar and zip files in the local directory. - * - * @param pathname Path to the candidate file. - * @return True if the file is a jar or zip - * file. - */ + * filters for jar and zip files in the local directory. + * + * @param pathname Path to the candidate file. + * @return True if the file is a jar or zip + * file. + */ public boolean accept(File pathname) { String name2 = pathname.getName(); @@ -458,7 +449,6 @@ // We have an archive whatever the codebase go ahead and load the libraries else if (!archives.equals("")) { - // We have a real codebase specified in xml // We add it to the classpath so we load files from it (http/file will work) if (!codebase.equals("")) @@ -472,7 +462,6 @@ { log.error("Couldn't create URL for codebase "+codebase, e2); throw new DeploymentException(e2.getMessage()); - } } @@ -482,7 +471,9 @@ if (archives.equals("*") || archives.equals("")) { // Safeguard - if (!codebase.startsWith("file:") && archives.equals("*")) throw new DeploymentException("No wildcard permitted in http deployment you must specify individual jars"); + if (!codebase.startsWith("file:") && archives.equals("*")) + throw new DeploymentException + ("No wildcard permitted in http deployment you must specify individual jars"); try { @@ -492,12 +483,11 @@ new java.io.FileFilter() { /** - * filters for jar and zip files in the local directory. - * - * @param pathname Path to the candidate file. - * @return True if the file is a jar or zip - * file. - */ + * filters for jar and zip files in the local directory. + * + * @param pathname Path to the candidate file. + * @return True if the file is a jar or zip file. + */ public boolean accept(File pathname) { String name2 = pathname.getName(); @@ -505,6 +495,7 @@ } } ); + for (int j = 0; jars != null && j < jars.length; j++) { classpath.add(jars[j].getCanonicalFile().toURL()); @@ -516,8 +507,6 @@ throw new DeploymentException(e.getMessage()); } } - - else // A real archive listing (as opposed to wildcard) { StringTokenizer jars = new StringTokenizer(archives, ","); @@ -531,14 +520,13 @@ } } } - else //codebase is empty and archives is empty but we did have a classpath entry { throw new DeploymentException("A classpath entry was declared but no codebase and no jars specified. Please fix jboss-service.xml in your configuration"); } } - //Ok, now we've found the list of urls we need... deploy their classes. + // Ok, now we've found the list of urls we need... deploy their classes. Iterator jars = classpath.iterator(); URL neededUrl = null; @@ -546,42 +534,39 @@ { try { - neededUrl = (URL)jars.next(); loadFiles(neededUrl); log.debug("deployed classes for " + neededUrl); - - - } catch (DeploymentException e) { + } + catch (DeploymentException e) { log.error("problem deploying classes for " + neededUrl, e); //put in list of failures TODO - } // end of try-catch - } // end of while () + } + } } - /** - * Undeploys the package at the url string specified. This will: Undeploy - * packages depending on this one. Stop, destroy, and unregister all the - * specified mbeans Unload this package and packages this package deployed - * via the classpath tag. Keep track of packages depending on this one that - * we undeployed so that they can be redeployed should this one be - * redeployed. - * - * @param urlString The location of the package to be - * undeployed (used to index the packages, not to read service.xml on - * undeploy! - * @exception MalformedURLException Thrown if the url string is not valid. - * @exception IOException Thrown if something could not be read. - * @exception DeploymentException Thrown if the package could not be - * undeployed - */ + * Undeploys the package at the url string specified. This will: Undeploy + * packages depending on this one. Stop, destroy, and unregister all the + * specified mbeans Unload this package and packages this package deployed + * via the classpath tag. Keep track of packages depending on this one that + * we undeployed so that they can be redeployed should this one be + * redeployed. + * + * @param urlString The location of the package to be + * undeployed (used to index the packages, + * not to read service.xml on undeploy! + * @exception MalformedURLException Thrown if the url string is not valid. + * @exception IOException Thrown if something could not be read. + * @exception DeploymentException Thrown if the package could not be + * undeployed + */ public void undeploy(URL url, Object localurlObject) - throws MalformedURLException, IOException, DeploymentException + throws MalformedURLException, IOException, DeploymentException { - log.debug("undeploying document " + url); + log.info("undeploying: " + url); ServiceDeploymentInfo sdi = getSdi(url, false); @@ -599,17 +584,16 @@ //Hey, man, we're all cleaned up! } - /** - * MBeanRegistration interface. Get the mbean server. - * - * @param server Our mbean server. - * @param name our proposed object name. - * @return our actual object name - * @exception java.lang.Exception Thrown if we are supplied an invalid name. - */ + * MBeanRegistration interface. Get the mbean server. + * + * @param server Our mbean server. + * @param name our proposed object name. + * @return our actual object name + * @exception java.lang.Exception Thrown if we are supplied an invalid name. + */ public ObjectName preRegister(MBeanServer server, ObjectName name) - throws java.lang.Exception + throws java.lang.Exception { super.preRegister(server, name); log.debug("ServiceDeployer preregistered with mbean server"); @@ -618,15 +602,14 @@ return objectName; } - /** - * PostRegister initialized the ServiceDeployed mbean and tries to load a - * spine package to set up basic jboss. At the moment the spine package - * should be jboss-service.xml or (deprecated) jboss.jcml. Soon we should - * have an actual sar with the code as well as configuration info. - * - * @param registrationDone Description of Parameter - */ + * PostRegister initialized the ServiceDeployed mbean and tries to load a + * spine package to set up basic jboss. At the moment the spine package + * should be jboss-service.xml or (deprecated) jboss.jcml. Soon we should + * have an actual sar with the code as well as configuration info. + * + * @param registrationDone Description of Parameter + */ public void postRegister(java.lang.Boolean registrationDone) { try @@ -651,7 +634,7 @@ } protected Document getDocument(URL url) - throws DeploymentException + throws DeploymentException { try { @@ -677,16 +660,15 @@ } // end of try-catch } - // Private -------------------------------------------------------- - - - private void removeMBeans(URL url, ServiceDeploymentInfo sdi) throws DeploymentException + private void removeMBeans(URL url, ServiceDeploymentInfo sdi) + throws DeploymentException { 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();) { @@ -697,6 +679,7 @@ new Object[] {name}, new String[] {"javax.management.ObjectName"}); } + for (ListIterator i = services.listIterator(lastService); i.hasPrevious();) { ObjectName name = (ObjectName)i.previous(); @@ -706,6 +689,7 @@ new Object[] {name}, new String[] {"javax.management.ObjectName"}); } + for (ListIterator i = services.listIterator(lastService); i.hasPrevious();) { ObjectName name = (ObjectName)i.previous(); @@ -717,23 +701,22 @@ //we don't supply it any more, maybe someone else will later. objectNameToSupplyingPackageMap.remove(name); } + sdi.state = ServiceDeploymentInfo.CLASSESLOADED; } - - /** - * Parse an object name from the given element attribute 'name'. - * - * @param element Element to parse name from. - * @return Object name. - * - * @throws ConfigurationException Missing attribute 'name' - * (thrown if 'name' is null or ""). - * @throws MalformedObjectNameException - */ + * Parse an object name from the given element attribute 'name'. + * + * @param element Element to parse name from. + * @return Object name. + * + * @throws ConfigurationException Missing attribute 'name' + * (thrown if 'name' is null or ""). + * @throws MalformedObjectNameException + */ private ObjectName parseObjectName(final Element element) - throws org.jboss.system.ConfigurationException, MalformedObjectNameException + throws org.jboss.system.ConfigurationException, MalformedObjectNameException { String name = ((org.w3c.dom.Text)element.getFirstChild()).getData().trim(); if (name == null || name.trim().equals("")) { @@ -742,10 +725,10 @@ } return new ObjectName(name); } - - /* Calls server.invoke, unwraps exceptions, and returns server output - */ + /** + * Calls server.invoke, unwraps exceptions, and returns server output + */ private Object invoke(ObjectName name, String method, Object[] args, String[] sig) { try @@ -778,9 +761,9 @@ } return null; } - - private ServiceDeploymentInfo getSdi(URL url, boolean createIfMissing) throws DeploymentException + private ServiceDeploymentInfo getSdi(URL url, boolean createIfMissing) + throws DeploymentException { ServiceDeploymentInfo sdi = (ServiceDeploymentInfo)urlToServiceDeploymentInfoMap.get(url); if (sdi == null) @@ -798,5 +781,3 @@ return sdi; } } - - 1.3 +23 -26 jboss/src/main/org/jboss/deployment/ServiceDeployerMBean.java Index: ServiceDeployerMBean.java =================================================================== RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/deployment/ServiceDeployerMBean.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ServiceDeployerMBean.java 2001/11/24 19:46:42 1.2 +++ ServiceDeployerMBean.java 2002/01/03 04:00:57 1.3 @@ -1,34 +1,31 @@ /* -* JBoss, the OpenSource J2EE server -* -* Distributable under LGPL license. -* See terms of license at gnu.org. -*/ -package org.jboss.deployment; - + * JBoss, the OpenSource J2EE server + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package org.jboss.deployment; import org.jboss.system.Service; + /** -* This is the main Service Deployer API. -* -* @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a> -* @see org.jboss.system.Service -* -* @version $Revision: 1.2 $ -* -* <p><b>20010830 marc fleury:</b> -* <ul> -* initial import -* <li> -* </ul> -*/ + * This is the main Service Deployer API. + * + * @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a> + * @see org.jboss.system.Service + * + * @version $Revision: 1.3 $ + * + * <p><b>20010830 marc fleury:</b> + * <ul> + * initial import + * <li> + * </ul> + */ public interface ServiceDeployerMBean -extends Service, DeployerMBean + extends Service, DeployerMBean { - // Public -------------------------------------------------------- - /** The default object name. */ - public static final String OBJECT_NAME = "JBOSS-SYSTEM:service=ServiceDeployer"; - -} + String OBJECT_NAME = "jboss.system:service=ServiceDeployer"; +} \ No newline at end of file
_______________________________________________ Jboss-development mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-development