[Jboss-cvs] JBossAS SVN: r55203 - in branches/MC_VDF_WORK/system/src/main/org/jboss/deployment: . scanner
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Aug 4 12:40:27 EDT 2006
Author: scott.stark at jboss.org
Date: 2006-08-04 12:40:12 -0400 (Fri, 04 Aug 2006)
New Revision: 55203
Removed:
branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/ClasspathExtension.java
branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/ClasspathExtensionMBean.java
branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/DefaultDeploymentSorter.java
branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/Deployer.java
branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/DeployerMBean.java
branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/DeploymentException.java
branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/DeploymentInfo.java
branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/DeploymentInfoComparator.java
branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/DeploymentSorter.java
branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/DeploymentState.java
branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/IncompleteDeploymentException.java
branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/JARDeployer.java
branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/JARDeployerMBean.java
branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/MainDeployer.java
branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/MainDeployerConstants.java
branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/MainDeployerMBean.java
branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/ObjectModelFactorySimpleSubDeployerSupport.java
branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/SARDeployer.java
branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/SARDeployerMBean.java
branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/SchemaBindingSimpleSubDeployerSupport.java
branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/SchemaResolverSimpleSubDeployerSupport.java
branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/SerializableDeploymentInfo.java
branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/SimpleSubDeployerSupport.java
branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/SubDeployer.java
branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/SubDeployerExt.java
branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/SubDeployerExtMBean.java
branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/SubDeployerInterceptor.java
branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/SubDeployerInterceptorMBean.java
branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/SubDeployerInterceptorSupport.java
branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/SubDeployerMBean.java
branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/SubDeployerSupport.java
branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/SuffixOrderHelper.java
branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/XSLSubDeployer.java
branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/XSLSubDeployerMBean.java
branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/package.html
branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/scanner/AbstractDeploymentScanner.java
branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/scanner/AlphaNumericDeploymentSorter.java
branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/scanner/DeploymentFilter.java
branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/scanner/DeploymentScanner.java
branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/scanner/DeploymentScannerMBean.java
branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/scanner/PrefixDeploymentSorter.java
branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/scanner/URLDeploymentScanner.java
branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/scanner/URLDeploymentScannerMBean.java
branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/scanner/package.html
Log:
Move jmx related code to the system-jmx module
Deleted: branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/ClasspathExtension.java
===================================================================
--- branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/ClasspathExtension.java 2006-08-04 16:27:06 UTC (rev 55202)
+++ branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/ClasspathExtension.java 2006-08-04 16:40:12 UTC (rev 55203)
@@ -1,121 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.deployment;
-
-import java.net.URL;
-import javax.management.ObjectName;
-import org.jboss.mx.loading.LoaderRepositoryFactory;
-import org.jboss.mx.loading.RepositoryClassLoader;
-import org.jboss.system.ServiceMBeanSupport;
-
-
-/** A service that allows one to add an arbitrary URL to a named LoaderRepository.
- *
- * Created: Sun Jun 30 13:17:22 2002
- *
- * @author <a href="mailto:d_jencks at users.sourceforge.net">David Jencks</a>
- * @version $Revision$
- *
- * @jmx:mbean name="jboss:type=Service,service=ClasspathExtension"
- * extends="org.jboss.system.ServiceMBean"
- */
-public class ClasspathExtension
- extends ServiceMBeanSupport
- implements ClasspathExtensionMBean
-{
- private String metadataURL;
- private ObjectName loaderRepository;
- private RepositoryClassLoader ucl;
-
- public ClasspathExtension()
- {
-
- }
-
- /**
- * mbean get-set pair for field metadataURL
- * Get the value of metadataURL
- * @return value of metadataURL
- *
- * @jmx:managed-attribute
- */
- public String getMetadataURL()
- {
- return metadataURL;
- }
-
- /**
- * Set the value of metadataURL
- * @param metadataURL Value to assign to metadataURL
- *
- * @jmx:managed-attribute
- */
- public void setMetadataURL(String metadataURL)
- {
- this.metadataURL = metadataURL;
- }
-
- /**
- * mbean get-set pair for field loaderRepository
- * Get the value of loaderRepository
- * @return value of loaderRepository
- *
- * @jmx:managed-attribute
- */
- public ObjectName getLoaderRepository()
- {
- return loaderRepository;
- }
-
-
- /**
- * Set the value of loaderRepository
- * @param loaderRepository Value to assign to loaderRepository
- *
- * @jmx:managed-attribute
- */
- public void setLoaderRepository(ObjectName loaderRepository)
- {
- this.loaderRepository = loaderRepository;
- }
-
- protected void createService() throws Exception
- {
- if (metadataURL != null)
- {
- URL url = new URL(metadataURL);
- if( loaderRepository == null )
- loaderRepository = LoaderRepositoryFactory.DEFAULT_LOADER_REPOSITORY;
- Object[] args = {url, url, Boolean.TRUE};
- String[] sig = {"java.net.URL", "java.net.URL", "boolean"};
- ucl = (RepositoryClassLoader) server.invoke(loaderRepository,
- "newClassLoader",args, sig);
- } // end of if ()
- }
-
- protected void destroyService() throws Exception
- {
- if (ucl != null)
- ucl.unregister();
- }
-
-}// ClasspathExtension
Deleted: branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/ClasspathExtensionMBean.java
===================================================================
--- branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/ClasspathExtensionMBean.java 2006-08-04 16:27:06 UTC (rev 55202)
+++ branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/ClasspathExtensionMBean.java 2006-08-04 16:40:12 UTC (rev 55203)
@@ -1,56 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.deployment;
-
-/**
- * MBean interface.
- */
-public interface ClasspathExtensionMBean extends org.jboss.system.ServiceMBean {
-
- //default object name
- public static final javax.management.ObjectName OBJECT_NAME = org.jboss.mx.util.ObjectNameFactory.create("jboss:type=Service,service=ClasspathExtension");
-
- /**
- * mbean get-set pair for field metadataURL Get the value of metadataURL
- * @return value of metadataURL
- */
- java.lang.String getMetadataURL() ;
-
- /**
- * Set the value of metadataURL
- * @param metadataURL Value to assign to metadataURL
- */
- void setMetadataURL(java.lang.String metadataURL) ;
-
- /**
- * mbean get-set pair for field loaderRepository Get the value of loaderRepository
- * @return value of loaderRepository
- */
- javax.management.ObjectName getLoaderRepository() ;
-
- /**
- * Set the value of loaderRepository
- * @param loaderRepository Value to assign to loaderRepository
- */
- void setLoaderRepository(javax.management.ObjectName loaderRepository) ;
-
-}
Deleted: branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/DefaultDeploymentSorter.java
===================================================================
--- branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/DefaultDeploymentSorter.java 2006-08-04 16:27:06 UTC (rev 55202)
+++ branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/DefaultDeploymentSorter.java 2006-08-04 16:40:12 UTC (rev 55203)
@@ -1,35 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.deployment;
-
-/**
- * Comment
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
-public interface DefaultDeploymentSorter
-{
- String[] getSuffixOrder();
-
- void setSuffixOrder(String[] suffixOrder);
-}
Deleted: branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/Deployer.java
===================================================================
--- branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/Deployer.java 2006-08-04 16:27:06 UTC (rev 55202)
+++ branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/Deployer.java 2006-08-04 16:40:12 UTC (rev 55203)
@@ -1,69 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.deployment;
-
-import java.net.URL;
-
-/**
- * The interface which a deployer must implement.
- *
- * <p>Clients should use the MainDeployer to deploy URLs.
- *
- * @jmx:mbean
- *
- * @version <tt>$Revision$</tt>
- * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
- */
-public interface Deployer
-{
- /**
- * Deploys a package identified by a URL
- *
- * @param url an <code>URL</code> value
- *
- * @throws DeploymentException Failed to deploy URL.
- *
- * @jmx:managed-operation
- */
- void deploy(URL url) throws DeploymentException;
-
- /**
- * Undeploys a package identified by a URL
- *
- * @param url an <code>URL</code> value
- *
- * @throws DeploymentException Failed to undeploy URL.
- *
- * @jmx:managed-operation
- */
- void undeploy(URL url) throws DeploymentException;
-
- /**
- * Tells you if a packaged identified by a URL is deployed.
- *
- * @param url an <code>URL</code> value
- * @return a <code>boolean</code> value
- *
- * @jmx:managed-operation
- */
- boolean isDeployed(URL url);
-}
Deleted: branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/DeployerMBean.java
===================================================================
--- branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/DeployerMBean.java 2006-08-04 16:27:06 UTC (rev 55202)
+++ branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/DeployerMBean.java 2006-08-04 16:40:12 UTC (rev 55203)
@@ -1,50 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.deployment;
-
-/**
- * MBean interface.
- */
-public interface DeployerMBean {
-
- /**
- * Deploys a package identified by a URL
- * @param url an <code>URL</code> value
- * @throws DeploymentException Failed to deploy URL.
- */
- void deploy(java.net.URL url) throws org.jboss.deployment.DeploymentException;
-
- /**
- * Undeploys a package identified by a URL
- * @param url an <code>URL</code> value
- * @throws DeploymentException Failed to undeploy URL.
- */
- void undeploy(java.net.URL url) throws org.jboss.deployment.DeploymentException;
-
- /**
- * Tells you if a packaged identified by a URL is deployed.
- * @param url an <code>URL</code> value
- * @return a <code>boolean</code> value
- */
- boolean isDeployed(java.net.URL url) ;
-
-}
Deleted: branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/DeploymentException.java
===================================================================
--- branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/DeploymentException.java 2006-08-04 16:27:06 UTC (rev 55202)
+++ branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/DeploymentException.java 2006-08-04 16:40:12 UTC (rev 55203)
@@ -1,97 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.deployment;
-
-import org.jboss.util.NestedException;
-
-/**
- * Thrown by a deployer if an application component could not be
- * deployed.
- *
- * @see DeployerMBean
- *
- * @author <a href="mailto:toby.allsopp at peace.com">Toby Allsopp</a>
- * @version $Revision$
- */
-public class DeploymentException extends NestedException
-{
- /** @since 4.0.2 */
- private static final long serialVersionUID = 1416258464473965574L;
-
- /**
- * Rethrow a throwable as a deployment exception if it isn't already.
- *
- * @param message the message
- * @param t the throwable
- * @throws a DeploymentException
- */
- public static void rethrowAsDeploymentException(String message, Throwable t)
- throws DeploymentException
- {
- if (t instanceof DeploymentException)
- throw (DeploymentException) t;
- else
- throw new DeploymentException(message, t);
- }
-
- /**
- * Construct a <tt>DeploymentException</tt> with the specified detail
- * message.
- *
- * @param msg Detail message.
- */
- public DeploymentException(String msg)
- {
- super(msg);
- }
-
- /**
- * Construct a <tt>DeploymentException</tt> with the specified detail
- * message and nested <tt>Throwable</tt>.
- *
- * @param msg Detail message.
- * @param nested Nested <tt>Throwable</tt>.
- */
- public DeploymentException(String msg, Throwable nested)
- {
- super(msg, nested);
- }
-
- /**
- * Construct a <tt>DeploymentException</tt> with the specified
- * nested <tt>Throwable</tt>.
- *
- * @param nested Nested <tt>Throwable</tt>.
- */
- public DeploymentException(Throwable nested)
- {
- super(nested);
- }
-
- /**
- * Construct a <tt>DeploymentException</tt> with no detail.
- */
- public DeploymentException()
- {
- super();
- }
-}
Deleted: branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/DeploymentInfo.java
===================================================================
--- branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/DeploymentInfo.java 2006-08-04 16:27:06 UTC (rev 55202)
+++ branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/DeploymentInfo.java 2006-08-04 16:40:12 UTC (rev 55203)
@@ -1,501 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.deployment;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.Serializable;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-import java.util.jar.JarFile;
-import java.util.jar.Manifest;
-
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-
-import org.jboss.logging.Logger;
-import org.jboss.mx.loading.LoaderRepositoryFactory;
-import org.jboss.mx.loading.RepositoryClassLoader;
-import org.jboss.mx.loading.LoaderRepositoryFactory.LoaderRepositoryConfig;
-import org.jboss.util.collection.ListSet;
-import org.jboss.util.file.Files;
-import org.w3c.dom.Document;
-
-/**
- * Service Deployment Info .
- *
- * Every deployment (even the J2EE ones) should be seen at some point as
- * Service Deployment info
- *
- * @see org.jboss.system.Service
- *
- * @author <a href="mailto:marc.fleury at jboss.org">Marc Fleury</a>
- * @author <a href="mailto:David.Maplesden at orion.co.nz">David Maplesden</a>
- * @author <a href="mailto:d_jencks at users.sourceforge.net">David Jencks</a>
- * @author <a href="mailto:daniel.schulze at telkel.com">Daniel Schulze</a>
- * @author <a href="mailto:Christoph.Jung at infor.de">Christoph G. Jung</a>
- * @author <a href="mailto:scott.stark at jboss.org">Scott Stark</a>
- * @version $Revision$ <p>
- */
-public class DeploymentInfo implements Serializable
-{
- /** @since 4.0.1 */
- private static final long serialVersionUID = 1131841473723490707L;
-
- private static final Logger log = Logger.getLogger(DeploymentInfo.class);
-
- // Variables ------------------------------------------------------------
-
- /** The initial construction timestamp */
- public Date date = new Date();
-
- /** the URL identifing this SDI **/
- public URL url;
-
- /** An optional URL to a local copy of the deployment */
- public URL localUrl;
-
- /** The URL used to watch for changes when the deployment is unpacked */
- public URL watch;
-
- /** The suffix of the deployment url */
- public String shortName;
-
- /** The last system time the deployment inited by the MainDeployer */
- public long lastDeployed = 0;
-
- /** use for "should we redeploy failed" */
- public long lastModified = 0;
-
- /** A free form status for the "state" can be Deployed/failed etc etc */
- public String status;
-
- /** The current state of the deployment */
- public DeploymentState state = DeploymentState.CONSTRUCTED;
-
- /** The subdeployer that handles the deployment */
- public transient SubDeployer deployer;
-
- /** Unified CL is a global scope class loader **/
- public transient RepositoryClassLoader ucl;
-
- /** local Cl is a CL that is used for metadata loading, if ejb-jar.xml is
- left in the parent CL through old deployments, this makes sure that we
- use the local version. You must use the URLClassLoader.findResource method
- to restrict loading to the deployment URL.
- */
- public transient URLClassLoader localCl;
-
- /** A CL for preloading annotations, it should be made available
- * in the deployment create step.
- */
- public transient URLClassLoader annotationsCl;
-
- /** The classpath declared by this xml descriptor, needs <classpath> entry **/
- public final Collection classpath = new ArrayList();
-
- /** The mbeans deployed */
- public final List<ObjectName> mbeans = new ArrayList<ObjectName>();
-
- /** Anyone can have subdeployments */
- public final Set subDeployments = new ListSet();
-
- /** And the subDeployments have a parent */
- public DeploymentInfo parent = null;
-
- /** the web root context in case of war file */
- public String webContext;
-
- /** the manifest entry of the deployment (if any)
- * manifest is not serializable ... is only needed
- * at deployment time, so we mark it transient
- */
- public transient Manifest manifest;
-
- /**
- * Each Deployment is really mapping one to one to a XML document, here in
- * its parsed form. A xerces document (org.apache.xerces.dom.DocumentImpl)
- * is serializable.
- */
- public Document document;
-
- /** An optional URL to the URL of the document loaded */
- public URL documentUrl;
-
- /** We can hold "typed" metadata, really an interpretation of the bare XML document */
- public transient Object metaData;
-
- /** If this deployed as part of an EAR, there may be an alernative DD */
- public String alternativeDD;
-
- /** An arbitrary map of state associated with the deployment */
- public transient HashMap context = new HashMap();
-
- /** Is this a stand-alone service descriptor */
- public boolean isXML;
-
- /** Is this a stand-alone script */
- public boolean isScript;
-
- /** Does the deployment url point to a directory */
- public boolean isDirectory;
-
- /**
- * The variable <code>deployedObject</code> can contain the MBean that
- * is created through the deployment. for instance, deploying an ejb-jar
- * results in an EjbModule mbean, which is stored here.
- */
- public ObjectName deployedObject;
-
- /** The configuration of the loader repository for this deployment */
- public LoaderRepositoryConfig repositoryConfig;
-
- /** The MBeanServer associated with the deployment */
- private transient MBeanServer server;
-
- /**
- * CTOR
- */
- public DeploymentInfo(final URL url, final DeploymentInfo parent, final MBeanServer server)
- throws DeploymentException
- {
- this.server = server;
- // The key url the deployment comes from
- this.url = url;
-
- // this may be changed by deployers in case of directory and xml file following
- this.watch = url;
-
- // Whether we are part of a subdeployment or not
- this.parent = parent;
-
- // Is it a directory?
- if (url.getProtocol().startsWith("file") && new File(url.getFile()).isDirectory())
- this.isDirectory = true;
-
- // Does it even exist?
- if (!isDirectory)
- {
- try
- {
- url.openStream().close();
- }
- catch (Exception e)
- {
- throw new DeploymentException("url " + url + " could not be opened, does it exist?");
- }
- }
-
- if (parent != null)
- {
- parent.subDeployments.add(this);
- // Use the repository of our topmost parent
- repositoryConfig = getTopRepositoryConfig();
- }
-
- // The "short name" for the deployment http://myserver/mybean.ear should yield "mybean.ear"
- shortName = getShortName(url.getPath());
-
- // Do we have an XML descriptor only deployment?
- isXML = shortName.toLowerCase().endsWith(".xml");
-
- // Do we have a stand-olone script deployment?
- isScript = shortName.toLowerCase().endsWith(".bsh");
- }
-
- public MBeanServer getServer()
- {
- return server;
- }
-
- public void setServer(MBeanServer server)
- {
- this.server = server;
- }
-
- /** Create a UnifiedClassLoader for the deployment that loads from
- the localUrl and uses its parent deployments url as its orignal
- url. Previously xml descriptors simply used the TCL but since the UCLs
- are now registered as mbeans each must be unique.
- */
- public void createClassLoaders() throws Exception
- {
- // create a local classloader for local files, don't go with the UCL for ejb-jar.xml
- if( localCl == null )
- localCl = new URLClassLoader(new URL[] {localUrl});
-
- /* Walk the deployment tree to find the parent deployment and obtain its
- url to use as our URL from which this deployment unit originated. This
- is used to determine permissions using the original URL namespace.
- Also pick up the LoaderRepository from the topmost ancestor.
- */
- URL origUrl = url;
- DeploymentInfo current = this;
- while (current.parent != null)
- {
- current = current.parent;
- }
- origUrl = current.url;
- repositoryConfig = current.repositoryConfig;
- if( parent == null )
- {
- if( repositoryConfig == null )
- repositoryConfig = new LoaderRepositoryConfig();
- // Make sure the specified LoaderRepository exists.
- LoaderRepositoryFactory.createLoaderRepository(server, repositoryConfig);
- log.debug("createLoaderRepository from config: "+repositoryConfig);
- // the classes are passed to a UCL that will share the classes with the whole base
-
- Object[] args = { isXML ? null : localUrl, origUrl, Boolean.TRUE };
- String[] sig = { "java.net.URL", "java.net.URL", "boolean" };
- ucl = (RepositoryClassLoader) server.invoke(repositoryConfig.repositoryName,
- "newClassLoader",args, sig);
- }
- else
- {
- // Add a reference to the LoaderRepository
- LoaderRepositoryFactory.createLoaderRepository(server, repositoryConfig);
- // Add the deployment URL to the parent UCL
- ucl = parent.ucl;
- ucl.addURL(localUrl);
- }
- // Add any library jars seen before the UCL was created
- if( classpath.size() > 0 )
- {
- Iterator jars = classpath.iterator();
- while( jars.hasNext() )
- {
- URL jar = (URL) jars.next();
- ucl.addURL(jar);
- }
- }
- }
-
- /** Set the UnifiedLoaderRepository info for the deployment. This can only
- * be called for the parent deployment, and must be done early in the
- * Subdeployer init(DeploymentInfo) method prior to any class loading.
- * @throws Exception
- */
- public void setRepositoryInfo(LoaderRepositoryConfig config)
- throws Exception
- {
- if( parent != null )
- {
- log.warn("Only the root deployment can set the loader repository, "
- + "ignoring config="+config);
- return;
- }
-
- this.repositoryConfig = config;
- // Recreate the ucl if it exists
- if( ucl != null )
- {
- ucl.unregister();
- // Make sure the specified LoaderRepository exists.
- LoaderRepositoryFactory.createLoaderRepository(server, repositoryConfig);
- log.debug("createLoaderRepository from config: "+repositoryConfig);
- // the classes are passed to a UCL that will share the classes with the whole base
-
- Object[] args = { isXML ? null : localUrl, url, Boolean.TRUE };
- String[] sig = { "java.net.URL", "java.net.URL", "boolean" };
- ucl = (RepositoryClassLoader) server.invoke(repositoryConfig.repositoryName,
- "newClassLoader",args, sig);
- }
- }
-
- /** All library jars referenced through either the manifest references
- * or sar classpaths are added to the root DeploymentInfo class loader. This
- * is neccessary to avoid IllegalAccessErrors due to classes in a pkg
- * being split across jars
- */
- public void addLibraryJar(URL libJar)
- {
- DeploymentInfo current = this;
- while (current.parent != null)
- {
- current = current.parent;
- }
- /* If the UCL exists add the jar to it else use the classpath to
- indicate that the jars need to be added when the ucl is created.
- */
- if( current.ucl != null )
- current.ucl.addURL(libJar);
- else
- classpath.add(libJar);
- }
-
- /** The the class loader repository name of the top most DeploymentInfo
- */
- public LoaderRepositoryConfig getTopRepositoryConfig()
- {
- LoaderRepositoryConfig topConfig = repositoryConfig;
- DeploymentInfo info = this;
- while( info.parent != null )
- {
- info = info.parent;
- topConfig = info.repositoryConfig;
- }
- return topConfig;
- }
-
- /**
- * getManifest returns (if present) the deployment's manifest
- * it is lazy loaded to work from the localURL
- */
- public Manifest getManifest()
- {
- try
- {
- if (manifest == null)
- {
- File file = new File(localUrl.getFile());
-
- if (file.isDirectory())
- {
- FileInputStream fis = new FileInputStream(new File(file, "META-INF/MANIFEST.MF"));
- manifest = new Manifest(fis);
- fis.close();
- }
- else if(isXML == false)// a jar
- manifest = new JarFile(file).getManifest();
- }
-
- return manifest;
- }
- // It is ok to barf at any time in the above, means no manifest
- catch (Exception ignored) { return null;}
- }
-
- public void cleanup()
- {
- // Remove the deployment UCL
- if( parent == null && ucl != null )
- ucl.unregister();
- ucl = null;
-
- // Remove any deployment specific repository
- if ( repositoryConfig != null )
- {
- LoaderRepositoryFactory.destroyLoaderRepository(server,
- repositoryConfig.repositoryName);
- }
-
- subDeployments.clear();
- mbeans.clear();
- context.clear();
- if (localUrl == null || localUrl.equals(url))
- {
- log.debug("Not deleting localUrl, it is null or not a copy: " + localUrl);
- }
- else if (Files.delete(localUrl.getFile()))
- {
- log.debug("Cleaned Deployment: " + localUrl);
- }
- else
- {
- log.debug("Could not delete " + localUrl + " restart will delete it");
- }
-
- // Clean up references to other objects
- localCl = null;
- annotationsCl = null;
- localUrl = null;
- repositoryConfig = null;
- watch = null;
- parent = null;
- manifest = null;
- document = null;
- metaData = null;
- server = null;
- classpath.clear();
- state = DeploymentState.DESTROYED;
- // Who is using this after clear?
- // deployer = null;
- }
-
- /** The sortName concatenated with the canonical names of all parents. */
- public String getCanonicalName()
- {
- String name = shortName;
- if (parent != null)
- name = parent.getCanonicalName() + "/" + name;
- return name;
- }
-
- private String getShortName(String name)
- {
- if (name.endsWith("/")) name = name.substring(0, name.length() - 1);
- name = name.substring(name.lastIndexOf("/") + 1);
- return name;
- }
-
- public int hashCode()
- {
- return url.hashCode();
- }
-
- public boolean equals(Object other)
- {
- if (other instanceof DeploymentInfo)
- {
- return ((DeploymentInfo) other).url.equals(this.url);
- }
- return false;
- }
-
- public String toString()
- {
- StringBuffer s = new StringBuffer(super.toString());
- s.append(" { url=" + url + " }\n");
- s.append(" deployer: " + deployer + "\n");
- s.append(" status: " + status + "\n");
- s.append(" state: " + state + "\n");
- s.append(" watch: " + watch + "\n");
- s.append(" altDD: " + alternativeDD + "\n");
- s.append(" lastDeployed: " + lastDeployed + "\n");
- s.append(" lastModified: " + lastModified + "\n");
- s.append(" mbeans:\n");
- for (Iterator i = mbeans.iterator(); i.hasNext(); )
- {
- ObjectName o = (ObjectName)i.next();
- try
- {
- String state = (String)server.getAttribute(o, "StateString");
- s.append(" " + o + " state: " + state + "\n");
- }
- catch (Exception e)
- {
- s.append(" " + o + " (state not available)\n");
- } // end of try-catch
-
- } // end of for ()
-
- return s.toString();
- }
-}
Deleted: branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/DeploymentInfoComparator.java
===================================================================
--- branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/DeploymentInfoComparator.java 2006-08-04 16:27:06 UTC (rev 55202)
+++ branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/DeploymentInfoComparator.java 2006-08-04 16:40:12 UTC (rev 55203)
@@ -1,42 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.deployment;
-
-import java.util.Comparator;
-
-/**
- * This comparator takes a delegate comparator that can compare URLs, and
- * applies that to DeploymentInfo objects
- */
-public class DeploymentInfoComparator implements Comparator {
-
- /** the delegate URL comparator */
- private Comparator urlComparator;
-
- public DeploymentInfoComparator(Comparator comp) {
- this.urlComparator = comp;
- }
-
- public int compare(Object o1, Object o2) {
- return urlComparator.compare(((DeploymentInfo)o1).url, ((DeploymentInfo)o2).url);
- }
-}
Deleted: branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/DeploymentSorter.java
===================================================================
--- branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/DeploymentSorter.java 2006-08-04 16:27:06 UTC (rev 55202)
+++ branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/DeploymentSorter.java 2006-08-04 16:40:12 UTC (rev 55203)
@@ -1,106 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.deployment;
-
-import java.net.URL;
-import java.util.Comparator;
-
-import org.jboss.util.NullArgumentException;
-
-/**
- * A helper class for sorting deployments.
- *
- * @version <tt>$Revision$</tt>
- * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
- * @author Scott.Stark at jboss.org
- */
-public class DeploymentSorter implements Comparator, DefaultDeploymentSorter
-{
- /**
- * The default order for sorting deployments; this has been deprecated,
- * order is really defined in SuffixOrderHelper class and/or individualy
- * within each subdeployer.
- *
- * @deprecated
- */
- public static final String[] DEFAULT_SUFFIX_ORDER = {
- ".deployer", "-deployer.xml", ".sar", "-service.xml", ".rar", "-ds.xml",
- ".har", ".jar", ".war", ".wsr", ".ear", ".zip", ".bsh", ".last"
- };
-
- protected String[] suffixOrder;
-
- public DeploymentSorter(String[] suffixOrder)
- {
- if (suffixOrder == null)
- throw new NullArgumentException("suffixOrder");
-
- this.suffixOrder = suffixOrder;
- }
-
- public DeploymentSorter()
- {
- this(DEFAULT_SUFFIX_ORDER);
- }
-
- public String[] getSuffixOrder()
- {
- return suffixOrder;
- }
- public void setSuffixOrder(String[] suffixOrder)
- {
- this.suffixOrder = suffixOrder;
- }
-
- /**
- * Return a negative number if o1 appears lower in the the suffix order than
- * o2.
- * If the suffixes are indentical, then sorts based on name.
- * This is so that deployment order of components is always identical.
- */
- public int compare(Object o1, Object o2)
- {
- URL u1 = (URL)o1;
- URL u2 = (URL)o2;
- int order = getExtensionIndex(u1) - getExtensionIndex(u2);
- if (order != 0)
- return order;
- return u1.getFile().compareTo(u2.getFile());
- }
-
- /**
- * Return the index that matches this url
- */
- public int getExtensionIndex(URL url)
- {
- String path = url.getPath();
- if (path.endsWith("/"))
- path = path.substring(0, path.length() - 1);
- int i = 0;
- for (; i < suffixOrder.length; i++)
- {
- if (path.endsWith(suffixOrder[i]))
- break;
- }
- return i;
- }
-}
Deleted: branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/DeploymentState.java
===================================================================
--- branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/DeploymentState.java 2006-08-04 16:27:06 UTC (rev 55202)
+++ branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/DeploymentState.java 2006-08-04 16:40:12 UTC (rev 55203)
@@ -1,116 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.deployment;
-
-import java.io.ObjectStreamException;
-import java.io.Serializable;
-
-/**
- * A type-safe enumeration for the status a DeploymentInfo may be in
- *
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public class DeploymentState implements Serializable
-{
- /** @since 4.0.2 */
- private static final long serialVersionUID = -2319062412502366783L;
-
- public static final DeploymentState CONSTRUCTED = new DeploymentState("CONSTRUCTED");
- public static final DeploymentState INIT_WAITING_DEPLOYER = new DeploymentState("INIT_WAITING_DEPLOYER");
- public static final DeploymentState INIT_HAS_DEPLOYER = new DeploymentState("INIT_HAS_DEPLOYER");
- public static final DeploymentState INIT_DEPLOYER = new DeploymentState("INIT_DEPLOYER");
- public static final DeploymentState INITIALIZED = new DeploymentState("INITIALIZED");
-
- public static final DeploymentState CREATE_SUBDEPLOYMENTS = new DeploymentState("CREATE_SUBDEPLOYMENTS");
- public static final DeploymentState CREATE_DEPLOYER = new DeploymentState("CREATE_DEPLOYER");
- public static final DeploymentState CREATED = new DeploymentState("CREATED");
-
- public static final DeploymentState START_SUBDEPLOYMENTS = new DeploymentState("START_SUBDEPLOYMENTS");
- public static final DeploymentState START_DEPLOYER = new DeploymentState("START_DEPLOYER");
- public static final DeploymentState STARTED = new DeploymentState("STARTED");
-
- public static final DeploymentState STOPPED = new DeploymentState("STOPPED");
- public static final DeploymentState DESTROYED = new DeploymentState("DESTROYED");
- public static final DeploymentState FAILED = new DeploymentState("FAILED");
-
- private String state;
-
- /** Private CTOR to disable direct object construction
- */
- private DeploymentState(String state)
- {
- this.state = state;
- }
-
- /** A factory to translate a string into the corresponding DeploymentState.
- */
- public static DeploymentState getDeploymentState(String state)
- {
- DeploymentState theState = null;
- state = state.toUpperCase();
- if( state.equals("CONSTRUCTED") )
- theState = CONSTRUCTED;
- else if( state.equals("INIT_WAITING_DEPLOYER") )
- theState = INIT_WAITING_DEPLOYER;
- else if( state.equals("INIT_HAS_DEPLOYER") )
- theState = INIT_HAS_DEPLOYER;
- else if( state.equals("INIT_DEPLOYER") )
- theState = INIT_DEPLOYER;
- else if( state.equals("INITIALIZED") )
- theState = INITIALIZED;
- else if( state.equals("CREATE_SUBDEPLOYMENTS") )
- theState = CREATE_SUBDEPLOYMENTS;
- else if( state.equals("CREATE_DEPLOYER") )
- theState = CREATE_DEPLOYER;
- else if( state.equals("CREATED") )
- theState = CREATED;
- else if( state.equals("START_SUBDEPLOYMENTS") )
- theState = START_SUBDEPLOYMENTS;
- else if( state.equals("START_DEPLOYER") )
- theState = START_DEPLOYER;
- else if( state.equals("STARTED") )
- theState = STARTED;
- else if( state.equals("STOPPED") )
- theState = STOPPED;
- else if( state.equals("DESTROYED") )
- theState = DESTROYED;
- else if( state.equals("FAILED") )
- theState = FAILED;
-
- return theState;
- }
-
- public String toString()
- {
- return state;
- }
-
- /** Resolve objects on deserialization to one of the identity objects.
- */
- private Object readResolve() throws ObjectStreamException
- {
- Object identity = getDeploymentState(state);
- return identity;
- }
-
-}
Deleted: branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/IncompleteDeploymentException.java
===================================================================
--- branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/IncompleteDeploymentException.java 2006-08-04 16:27:06 UTC (rev 55202)
+++ branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/IncompleteDeploymentException.java 2006-08-04 16:40:12 UTC (rev 55203)
@@ -1,199 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.deployment;
-
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.util.Collection;
-import java.util.Iterator;
-
-/**
- * IncompleteDeploymentException
- *
- * @author <a href="mailto:d_jencks at users.sourceforge.net">David Jencks</a>
- * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
- * @version $Revision$
- */
-public class IncompleteDeploymentException extends DeploymentException
-{
- /** @since 4.0.2 */
- private static final long serialVersionUID = 1428860525880893167L;
-
- /** non-serializable info */
- private transient final Collection mbeansWaitingForClasses;
- private transient final Collection mbeansWaitingForDepends;
- private transient final Collection rootCause;
- private transient final Collection incompletePackages;
- private transient final Collection waitingForDeployer;
-
- /** only serializable info */
- private String string;
-
- /**
- * CTOR
- *
- * @param mbeansWaitingForClasses
- * @param mbeansWaitingForDepends
- * @param rootCause
- * @param incompletePackages
- * @param waitingForDeployer
- */
- public IncompleteDeploymentException(final Collection mbeansWaitingForClasses,
- final Collection mbeansWaitingForDepends,
- final Collection rootCause,
- final Collection incompletePackages,
- final Collection waitingForDeployer)
- {
- if (mbeansWaitingForClasses == null
- || mbeansWaitingForDepends == null
- || rootCause == null
- ||incompletePackages == null
- || waitingForDeployer == null)
- {
- throw new IllegalArgumentException("All lists in IncompleteDeploymentException constructor must be supplied");
- } // end of if ()
-
- this.mbeansWaitingForClasses = mbeansWaitingForClasses;
- this.mbeansWaitingForDepends = mbeansWaitingForDepends;
- this.rootCause = rootCause;
- this.incompletePackages = incompletePackages;
- this.waitingForDeployer = waitingForDeployer;
- }
-
- /**
- * Get the MbeansWaitingForClasses value.
- * @return the MbeansWaitingForClasses value.
- */
- public Collection getMbeansWaitingForClasses()
- {
- return mbeansWaitingForClasses;
- }
-
- /**
- * Get the MbeansWaitingForDepends value.
- * @return the MbeansWaitingForDepends value.
- */
- public Collection getMbeansWaitingForDepends()
- {
- return mbeansWaitingForDepends;
- }
-
- /**
- * Get the IncompletePackages value.
- * @return the IncompletePackages value.
- */
- public Collection getIncompletePackages()
- {
- return incompletePackages;
- }
-
- /**
- * Get the WaitingForDeployer value.
- * @return the WaitingForDeployer value.
- */
- public Collection getWaitingForDeployer()
- {
- return waitingForDeployer;
- }
-
- /**
- * @return true is no information is contained at all
- */
- public boolean isEmpty()
- {
- return mbeansWaitingForClasses.size() == 0
- && mbeansWaitingForDepends.size() == 0
- && rootCause.size() == 0
- && incompletePackages.size() == 0
- && waitingForDeployer.size() == 0;
- }
-
- /**
- * Convert to String and cache the deployment information
- */
- public String toString()
- {
- if (string != null)
- {
- return string;
- }
-
- StringBuffer result = new StringBuffer("Incomplete Deployment listing:\n\n");
- if (waitingForDeployer.size() != 0)
- {
- result.append("--- Packages waiting for a deployer ---\n");
- appendCollection(result, waitingForDeployer);
- }
-
- if (incompletePackages.size() != 0)
- {
- result.append("--- Incompletely deployed packages ---\n");
- appendCollection(result, incompletePackages);
- }
-
- if (mbeansWaitingForClasses.size() != 0)
- {
- result.append("--- MBeans waiting for classes ---\n");
- appendCollection(result, mbeansWaitingForClasses);
- }
-
- if (mbeansWaitingForDepends.size() != 0)
- {
- result.append("--- MBeans waiting for other MBeans ---\n");
- appendCollection(result, mbeansWaitingForDepends);
- }
-
- if (rootCause.size() != 0)
- {
- result.append("--- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---\n");
- appendCollection(result, rootCause);
- }
-
- string = result.toString();
- return string;
- }
-
- private void appendCollection(StringBuffer result, Collection c)
- {
- for (Iterator i = c.iterator(); i.hasNext();)
- result.append(i.next().toString()).append('\n');
- }
-
- /**
- * Read-in the string-fied information produced by writeObject()
- */
- private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException
- {
- s.defaultReadObject();
- }
-
- /**
- * String-ify the contained information when serializing
- */
- private void writeObject(ObjectOutputStream s) throws IOException
- {
- toString();
- s.defaultWriteObject();
- }
-
-}
Deleted: branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/JARDeployer.java
===================================================================
--- branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/JARDeployer.java 2006-08-04 16:27:06 UTC (rev 55202)
+++ branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/JARDeployer.java 2006-08-04 16:40:12 UTC (rev 55203)
@@ -1,251 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.deployment;
-
-import java.io.File;
-import java.io.FileFilter;
-import java.net.JarURLConnection;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.Arrays;
-import java.util.Enumeration;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
-
-import org.jboss.util.Strings;
-
-/**
- * This deployer exists to prevent deployment of packages whose deployers are not yet
- * deployed. It will accept only jar/zip format files or directories that don't
- * have a META-INF directory, or if they do, don't have any .xml files there. It
- * assumes any package with a META-INF/*.xml file needs a specialized deployer.
- *
- * @todo find a way to scan just the META-INF files, not the whole jar.
- *
- * @author <a href="mailto:scott.stark at jboss.org">Scott Stark</a>
- * @author <a href="mailto:d_jencks at users.sourceforge.net">David Jencks</a>
- * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
- * @version $Revision$
- */
-public class JARDeployer extends SubDeployerSupport
- implements JARDeployerMBean
-{
- /**
- * The suffixes we accept, along with their relative order.
- *
- * For JARDeployer, this is only used to populate the MainDeployer's
- * SuffixOrder list, it is not used to actually match deployment suffixes
- */
- private static final String[] DEFAULT_ENHANCED_SUFFIXES = new String[] {
- "700:.jar", // normal .jar
- "750:.zip", // normal .zip
- "900:.last" // make content of .last dirs/archives deploy last
- };
-
- private String[] descriptorNames = {
- ".xml"
- };
-
- /**
- * Default CTOR
- */
- public JARDeployer()
- {
- super.setEnhancedSuffixes(DEFAULT_ENHANCED_SUFFIXES);
- }
-
- public String[] getDescriptorNames()
- {
- return descriptorNames;
- }
-
- public void setDescriptorNames(String[] descriptorNames)
- {
- this.descriptorNames = descriptorNames;
- }
-
- // ServiceMBeanSupport methods
-
- protected void stopService()
- {
- // This can't be run right now since the JARDeployer is started before the MainDeployer,
- // so the MainDeployer is stopped first... so the JARDeployer can't unregister.
-
- // super.stopService();
- }
-
- // SubDeployer implementation
-
- /**
- * The <code>accepts</code> method is called by MainDeployer to
- * determine which deployer is suitable for a DeploymentInfo.
- *
- * @todo find a way to scan just the META-INF files, not the whole jar.
- *
- * @param di a <code>DeploymentInfo</code> value
- * @return a <code>boolean</code> value
- */
- public boolean accepts(DeploymentInfo di)
- {
- boolean trace = log.isTraceEnabled();
-
- try
- {
- // Reject extensions not configured in this subdeployer
- // but do consider accepting non-dotted deployments,
- // like deploy-hasingleton
- if (di.shortName.indexOf('.') != -1 && super.accepts(di) == false)
- {
- return false;
- }
-
- // Reject deployments with a WEB-INF/ directory
- URL wdDir = di.localCl.findResource("WEB-INF/");
- if (wdDir != null)
- {
- return false;
- }
-
- // Since a META-INF directory exists within rt.jar, we can't just do a
- // getResource (it will always return rt.jar's version).
- // The method we want is findResource, but it is marked protected in
- // ClassLoader. Fortunately, URLClassLoader exposes it which makes
- // this hack possible. Anybody have a better way to check a URL
- // for the existance of a META-INF??
- URL ddDir;
- try
- {
- ddDir = di.localCl.findResource("META-INF/");
- if (ddDir == null)
- {
- log.debug("No META-INF or WEB-INF resource found, assuming it if for us");
- return true;
- }
- }
- catch (ClassCastException e)
- {
- // assume there is a META-INF...
- ddDir = new URL(di.url, "META-INF/");
- }
-
- if (ddDir.getProtocol().equals("file"))
- {
- log.trace("File protocol: "+ddDir);
- File file = new File(ddDir.getFile());
- if (!file.exists())
- {
- log.warn("File not found: " + file);
- return true;
- }
-
- // Scan for any xml files in the META-INF dir
- File[] entries = file.listFiles(
- new FileFilter()
- {
- public boolean accept(File pathname)
- {
- boolean accept = false;
- String name = pathname.getName();
- for(int n = 0; accept == false && n < descriptorNames.length; n ++)
- {
- String d = descriptorNames[n];
- accept = name.endsWith(d);
- }
- return accept;
- }
- }
- );
- log.debug("XML entries found: " + entries.length);
- return entries.length == 0;
- } // end of if ()
- else if (ddDir.getProtocol().equals("jar") == true)
- {
- log.trace("jar protocol: " + ddDir);
- JarFile jarFile = null;
-
- try
- {
- URLConnection con = ddDir.openConnection();
- JarURLConnection jarConn = (JarURLConnection) con;
- /* Need to set caching to false otherwise closing the jarfile
- ends up conflicting with other users of the cached jar.
- */
- jarConn.setUseCaches(false);
- jarFile = jarConn.getJarFile();
-
- // Scan for any xml files in the META-INF dir
- if (trace)
- log.trace("Descriptor names=" + Arrays.asList(descriptorNames));
- for (Enumeration e = jarFile.entries(); e.hasMoreElements();)
- {
- JarEntry entry = (JarEntry)e.nextElement();
- String name = entry.getName();
- if (trace)
- log.trace("Looking at entry: '" + name + "'");
-
- // JBAS-2949 - Look for xml descriptors directly
- // under META-INF/, not in META-INF/ subdirectories
- if (name.startsWith("META-INF/") && Strings.count(name, "/") == 1)
- {
- for (int n = 0; n < descriptorNames.length; n ++)
- {
- if (name.endsWith(descriptorNames[n]))
- {
- log.debug("Found entry: '" + name + "', matching: '"
- + descriptorNames[n] + "', rejecting jar");
-
- // Do not accept this as jar file
- return false;
- }
- }
- }
- }
- }
- catch (Exception e)
- {
- log.warn("Looking inside jar failed; ignoring", e);
- return false;
- }
- finally
- {
- if (jarFile != null)
- jarFile.close();
- jarFile = null;
- }
-
- log.debug("No xml files found");
- return true;
- }
- else
- {
- log.debug("Unrecognized protocol: " + ddDir.getProtocol());
- }
-
- return false;
- }
- catch (Exception e)
- {
- log.trace("Ignored error", e);
- return false;
- }
- }
-}
Deleted: branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/JARDeployerMBean.java
===================================================================
--- branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/JARDeployerMBean.java 2006-08-04 16:27:06 UTC (rev 55202)
+++ branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/JARDeployerMBean.java 2006-08-04 16:40:12 UTC (rev 55203)
@@ -1,46 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.deployment;
-
-import javax.management.ObjectName;
-
-import org.jboss.mx.util.ObjectNameFactory;
-
-/**
- * MBean interface.
- *
- * @version $Revision$
- */
-public interface JARDeployerMBean extends SubDeployerMBean
-{
- /** The default ObjectName */
- ObjectName OBJECT_NAME = ObjectNameFactory.create("jboss.system:service=JARDeployer");
-
- /**
- * The list of suffixes that define deployment descriptors which if
- * found in an archive META-INF directory indicate non-jar deployments
- * that should be ignored by the JARDeployer.
- */
- void setDescriptorNames(String[] descriptorNames);
- String[] getDescriptorNames();
-
-}
Deleted: branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/MainDeployer.java
===================================================================
--- branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/MainDeployer.java 2006-08-04 16:27:06 UTC (rev 55202)
+++ branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/MainDeployer.java 2006-08-04 16:40:12 UTC (rev 55203)
@@ -1,1415 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.deployment;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Map;
-import java.util.Set;
-import java.util.StringTokenizer;
-import java.util.jar.Attributes;
-import java.util.jar.Manifest;
-
-import javax.management.JMException;
-import javax.management.MBeanServer;
-import javax.management.MalformedObjectNameException;
-import javax.management.Notification;
-import javax.management.ObjectName;
-
-import org.jboss.mx.util.JMXExceptionDecoder;
-import org.jboss.system.ServiceContext;
-import org.jboss.system.ServiceMBeanSupport;
-import org.jboss.system.server.ServerConfig;
-import org.jboss.system.server.ServerConfigLocator;
-import org.jboss.util.file.Files;
-import org.jboss.util.file.JarUtils;
-import org.jboss.util.stream.Streams;
-
-/**
- * The main/primary component for deployment.
- *
- * <p>MainDeployerMBean is generated by xdoclet.
- *
- * @deprecated see org.jboss.deployers.spi.MainDeployer
- *
- * @author <a href="mailto:marc.fleury at jboss.org">Marc Fleury</a>
- * @author <a href="mailto:scott.stark at jboss.org">Scott Stark</a>
- * @author <a href="mailto:d_jencks at users.sourceforge.net">David Jencks</a>
- * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
- * @version $Revision$
- */
-public class MainDeployer extends ServiceMBeanSupport
- implements Deployer, MainDeployerMBean
-{
- /**
- * The variable <code>serviceController</code> is used by the
- * checkIncompleteDeployments method to ask for lists of mbeans
- * with deployment problems.
- */
- private ObjectName serviceController;
-
- /** Deployers **/
- private final LinkedList deployers = new LinkedList();
-
- /** A Map of URL -> DeploymentInfo */
- private final Map deploymentMap = Collections.synchronizedMap(new HashMap());
-
- /** A list of all deployments that have deployers. */
- private final List deploymentList = new ArrayList();
-
- /** A list of all deployments that do not have deployers. */
- private final List waitingDeployments = new ArrayList();
-
- /** A helper for sorting deployment URLs. */
- private final DeploymentSorter sorter = new DeploymentSorter();
-
- /** A helper for sorting deploymentInfos */
- private final Comparator infoSorter = new DeploymentInfoComparator(sorter);
-
- /** Helper class handling the SuffixOrder and EnhancedSuffixOrder attributes */
- private final SuffixOrderHelper suffixOrderHelper = new SuffixOrderHelper(sorter);
-
- /** Should local copies be made of resources on the local file system */
- private boolean copyFiles = true;
-
- /** The temporary directory for deployments. */
- private File tempDir;
-
- /** The string naming the tempDir **/
- private String tempDirString;
-
- /**
- * Explict no-args contsructor for JMX.
- */
- public MainDeployer()
- {
- // Is there a better place to obtain startup information?
- String localCopy = System.getProperty("jboss.deploy.localcopy");
- if (localCopy != null && (
- localCopy.equalsIgnoreCase("false") ||
- localCopy.equalsIgnoreCase("no") ||
- localCopy.equalsIgnoreCase("off")))
- {
- log.debug("Disabling local copies of file: urls");
- copyFiles = false;
- }
- }
-
-
- /** Get the flag indicating whether directory content will be deployed
- *
- * @return the file copy flag
- * @jmx.managed-attribute
- */
- public boolean getCopyFiles()
- {
- return copyFiles;
- }
- /** Set the flag indicating whether directory content will be deployed. The
- * default value is taken from the jboss.deploy.localcopy system
- * property.
- *
- * @param copyFiles the local copy flag value
- * @jmx.managed-attribute
- */
- public void setCopyFiles(boolean copyFiles)
- {
- this.copyFiles = copyFiles;
- }
-
- /** Get the temp directory
- *
- * @return the path to the local tmp directory
- * @jmx.managed-attribute
- */
- public File getTempDir()
- {
- return tempDir;
- }
- /** Set the temp directory
- *
- * @param tempDir the path to the local tmp directory
- * @jmx.managed-attribute
- */
- public void setTempDir(File tempDir)
- {
- this.tempDir = tempDir;
- }
-
- /** Get the temp directory
- *
- * @return the path to the local tmp directory
- * @jmx.managed-attribute
- */
- public String getTempDirString()
- {
- return tempDirString;
- }
-
- /** Get the ordering of the deployment suffixes
- *
- * @return the ordering of the deployment suffixes
- * @jmx.managed-attribute
- */
- public String[] getSuffixOrder()
- {
- return suffixOrderHelper.getSuffixOrder();
- }
-
- /** Get the enhanced suffix order
- *
- * @return the enhanced suffix order
- * @jmx.managed-attribute
- */
- public String[] getEnhancedSuffixOrder()
- {
- return suffixOrderHelper.getEnhancedSuffixes();
- }
-
- /** Set the enhanced suffix order
- *
- * @param enhancedSuffixOrder the enhanced suffix order
- * @jmx.managed-attribute
- */
- public void setEnhancedSuffixOrder(String[] enhancedSuffixOrder)
- {
- suffixOrderHelper.setEnhancedSuffixes(enhancedSuffixOrder);
- }
-
- /**
- * Describe <code>setServiceController</code> method here.
- *
- * @param serviceController an <code>ObjectName</code> value
- * @jmx.managed-attribute
- */
- public void setServiceController(final ObjectName serviceController)
- {
- this.serviceController = serviceController;
- }
-
- /**
- * The <code>listDeployed</code> method returns a collection of DeploymemtInfo
- * objects for the currently deployed packages.
- *
- * @return a <code>Collection</code> value
- * @jmx.managed-operation
- */
- public Collection listDeployed()
- {
- synchronized (deploymentList)
- {
- log.debug("deployment list string: " + deploymentList);
- return new ArrayList(deploymentList);
- }
- }
-
- /**
- * The <code>listDeployedModules</code> method returns a collection of
- * SerializableDeploymentInfo objects for the currently deployed packages.
- *
- * @return a <code>Collection</code> value
- * @jmx.managed-operation
- */
- public Collection listDeployedModules()
- {
- log.debug("listDeployedModules");
-
- HashMap map = new HashMap();
- synchronized (deploymentList)
- {
- Collection col = new ArrayList(deploymentList);
-
- // create a map entry for each deployment
- for (Iterator it = col.iterator(); it.hasNext();)
- {
- DeploymentInfo info = (DeploymentInfo) it.next();
- map.put(info.url, new SerializableDeploymentInfo(info));
- // assign parent and sub deployments
- fillParentAndChildrenSDI(info, map);
- }
- }
-
- // map.values is not serializable, so we copy
- return new ArrayList(map.values());
- }
-
- /**
- * Describe <code>listDeployedAsString</code> method here.
- *
- * @return a <code>String</code> value
- * @jmx.managed-operation
- */
- public String listDeployedAsString()
- {
- return "<pre>" + listDeployed() + "</pre>";
- }
-
- /**
- * The <code>listIncompletelyDeployed</code> method returns a list of packages that have
- * not deployed completely. The toString method will include any exception in the status
- * field.
- *
- * @return a <code>Collection</code> value
- * @jmx.managed-operation
- */
- public Collection listIncompletelyDeployed()
- {
- List id = new ArrayList();
- List copy;
- synchronized (deploymentList)
- {
- copy = new ArrayList(deploymentList);
- }
- for (Iterator i = copy.iterator(); i.hasNext();)
- {
- DeploymentInfo di = (DeploymentInfo)i.next();
- if (!"Deployed".equals(di.status) && !"Starting".equals(di.status))
- {
- id.add(di);
- } // end of if ()
-
- } // end of for ()
- return id;
- }
-
- /**
- * The <code>listWaitingForDeployer</code> method returns a collection
- * of the packages that currently have no identified deployer.
- *
- * @return a <code>Collection</code> value
- * @jmx.managed-operation
- */
- public Collection listWaitingForDeployer()
- {
- synchronized (waitingDeployments)
- {
- return new ArrayList(waitingDeployments);
- }
- }
-
- /**
- * The <code>addDeployer</code> method registers a deployer with the main deployer.
- * Any waiting packages are tested to see if the new deployer will deploy them.
- *
- * @param deployer a <code>SubDeployer</code> value
- * @jmx.managed-operation
- */
- public void addDeployer(final SubDeployer deployer)
- {
- log.debug("Adding deployer: " + deployer);
- ObjectName deployerName = deployer.getServiceName();
-
- synchronized(deployers)
- {
- deployers.addFirst(deployer);
- try
- {
- String[] suffixes = (String[]) server.getAttribute(deployerName, "EnhancedSuffixes");
- suffixOrderHelper.addEnhancedSuffixes(suffixes);
- }
- catch(Exception e)
- {
- log.debug(deployerName + " does not support EnhancedSuffixes");
- suffixOrderHelper.addSuffixes(deployer.getSuffixes(), deployer.getRelativeOrder());
- }
- }
-
- // Send a notification about the deployer addition
- Notification msg = new Notification(ADD_DEPLOYER, this, getNextNotificationSequenceNumber());
- msg.setUserData(deployerName);
- sendNotification(msg);
-
- synchronized (waitingDeployments)
- {
- List copy = new ArrayList(waitingDeployments);
- waitingDeployments.clear();
- for (Iterator i = copy.iterator(); i.hasNext();)
- {
- DeploymentInfo di = (DeploymentInfo)i.next();
- log.debug("trying to deploy with new deployer: " + di.shortName);
- try
- {
- di.setServer(server);
- deploy(di);
- }
- catch (DeploymentException e)
- {
- log.error("DeploymentException while trying to deploy a package with a new deployer", e);
- } // end of try-catch
- } // end of for ()
- }
- }
-
- /**
- * The <code>removeDeployer</code> method unregisters a deployer with the MainDeployer.
- * Deployed packages deployed with this deployer are undeployed.
- *
- * @param deployer a <code>SubDeployer</code> value
- * @jmx.managed-operation
- */
- public void removeDeployer(final SubDeployer deployer)
- {
- log.debug("Removing deployer: " + deployer);
- ObjectName deployerName = deployer.getServiceName();
- boolean removed = false;
-
- synchronized(deployers)
- {
- removed = deployers.remove(deployer);
- try
- {
- String[] suffixes = (String[]) server.getAttribute(deployerName, "EnhancedSuffixes");
- suffixOrderHelper.removeEnhancedSuffixes(suffixes);
- }
- catch(Exception e)
- {
- log.debug(deployerName + " does not support EnhancedSuffixes");
- suffixOrderHelper.removeSuffixes(deployer.getSuffixes(), deployer.getRelativeOrder());
- }
- }
-
- // Send a notification about the deployer removal
- if (removed)
- {
- Notification msg = new Notification(REMOVE_DEPLOYER, this, getNextNotificationSequenceNumber());
- msg.setUserData(deployerName);
- sendNotification(msg);
- }
-
- List copy;
- synchronized (deploymentList)
- {
- copy = new ArrayList(deploymentList);
- }
- for (Iterator i = copy.iterator(); i.hasNext(); )
- {
- DeploymentInfo di = (DeploymentInfo)i.next();
- if (di.deployer == deployer)
- {
- undeploy(di);
- di.deployer = null;
- synchronized (waitingDeployments)
- {
- waitingDeployments.add(di);
- }
- }
- }
- }
-
- /**
- * The <code>listDeployers</code> method returns a collection of ObjectNames of
- * deployers registered with the MainDeployer.
- *
- * @return a <code>Collection<ObjectName></code> value
- * @jmx.managed-operation
- */
- public Collection listDeployers()
- {
- ArrayList deployerNames = new ArrayList();
- synchronized(deployers)
- {
- for(int n = 0; n < deployers.size(); n ++)
- {
- SubDeployer deployer = (SubDeployer) deployers.get(n);
- ObjectName name = deployer.getServiceName();
- deployerNames.add(name);
- }
- }
- return deployerNames;
- }
-
- // ServiceMBeanSupport overrides ---------------------------------
-
- protected ObjectName getObjectName(MBeanServer server, ObjectName name)
- throws MalformedObjectNameException
- {
- return name == null ? OBJECT_NAME : name;
- }
-
- /**
- * The <code>createService</code> method is one of the ServiceMBean lifecyle operations.
- * (no jmx tag needed from superinterface)
- * @exception Exception if an error occurs
- */
- protected void createService() throws Exception
- {
- ServerConfig config = ServerConfigLocator.locate();
- // Get the temp directory location
- File basedir = config.getServerTempDir();
- // Set the local copy temp dir to tmp/deploy
- tempDir = new File(basedir, "deploy");
- // Delete any existing content
- Files.delete(tempDir);
- // Make sure the directory exists
- tempDir.mkdirs();
-
- // used in inLocalCopyDir
- tempDirString = tempDir.toURL().toString();
-
- // handles SuffixOrder & RelativeSuffixOrder attributes
- suffixOrderHelper.initialize();
- }
-
- /**
- * The <code>shutdown</code> method undeploys all deployed packages in
- * reverse order of their deployement.
- *
- * @jmx.managed-operation
- */
- public void shutdown()
- {
- // if we shutdown in the middle of a scan, it still might be possible that we try to redeploy
- // things we are busy killing...
- int deployCounter = 0;
-
- // undeploy everything in sight
- List copy;
- synchronized (deploymentList)
- {
- copy = new ArrayList(deploymentList);
- }
- for (ListIterator i = copy.listIterator(copy.size()); i.hasPrevious(); )
- {
- try
- {
- undeploy((DeploymentInfo)i.previous(), true);
- deployCounter++;
- }
- catch (Exception e)
- {
- log.info("exception trying to undeploy during shutdown", e);
- }
-
- }
- // Help GC
- this.deployers.clear();
- this.deploymentMap.clear();
- this.deploymentList.clear();
- this.waitingDeployments.clear();
- this.tempDir = null;
-
- log.debug("Undeployed " + deployCounter + " deployed packages");
- }
-
-
- /**
- * Describe <code>redeploy</code> method here.
- *
- * @param urlspec a <code>String</code> value
- * @exception DeploymentException if an error occurs
- * @exception MalformedURLException if an error occurs
- * @jmx.managed-operation
- */
- public void redeploy(String urlspec)
- throws DeploymentException, MalformedURLException
- {
- redeploy(new URL(urlspec));
- }
-
- /**
- * Describe <code>redeploy</code> method here.
- *
- * @param url an <code>URL</code> value
- * @exception DeploymentException if an error occurs
- * @jmx.managed-operation
- */
- public void redeploy(URL url) throws DeploymentException
- {
- DeploymentInfo sdi = getDeployment(url);
- if (sdi!= null)
- {
- redeploy(sdi);
- }
- else
- {
- deploy(url);
- } // end of else
- }
-
- /**
- * Describe <code>redeploy</code> method here.
- *
- * @param sdi a <code>DeploymentInfo</code> value
- * @exception DeploymentException if an error occurs
- * @jmx.managed-operation
- */
- public void redeploy(DeploymentInfo sdi) throws DeploymentException
- {
- try
- {
- undeploy(sdi);
- }
- catch (Throwable t)
- {
- log.info("Throwable from undeployment attempt: ", t);
- } // end of try-catch
- sdi.setServer(server);
- deploy(sdi);
- }
-
- /**
- * The <code>undeploy</code> method undeploys a package identified by a string
- * representation of a URL.
- *
- * @param urlspec the stringfied url to undeploy
- * @jmx.managed-operation
- */
- public void undeploy(String urlspec)
- throws DeploymentException, MalformedURLException
- {
- undeploy(new URL(urlspec));
- }
-
- /**
- * The <code>undeploy</code> method undeploys a package identified by a URL
- *
- * @param url the url to undeploy
- * @jmx.managed-operation
- */
- public void undeploy(URL url) throws DeploymentException
- {
- DeploymentInfo sdi = getDeployment(url);
- if (sdi != null)
- {
- undeploy(sdi);
- }
- else
- {
- log.warn("undeploy '" + url + "' : package not deployed");
- }
- }
-
- /**
- * The <code>undeploy</code> method undeploys a package represented by a
- * DeploymentInfo object.
- *
- * @param di a <code>DeploymentInfo</code> value
- * @jmx.managed-operation
- */
- public void undeploy(DeploymentInfo di)
- {
- undeploy(di, false);
- }
- protected void undeploy(DeploymentInfo di, boolean isShutdown)
- {
- log.debug("Undeploying "+di.url);
- stop(di);
- destroy(di);
- }
-
- /**
- * The <code>stop</code> method is the first internal step of undeployment
- *
- * @param di a <code>DeploymentInfo</code> value
- */
- private void stop(DeploymentInfo di)
- {
- // Stop all sub-deployments
- ArrayList reverseSortedSubs = new ArrayList(di.subDeployments);
- Collections.sort(reverseSortedSubs, infoSorter);
- Collections.reverse(reverseSortedSubs);
- for (Iterator subs = reverseSortedSubs.iterator(); subs.hasNext();)
- {
- DeploymentInfo sub = (DeploymentInfo) subs.next();
- log.debug("Stopping sub deployment: "+sub.url);
- stop(sub);
- }
- // Lastly stop this deployment itself
- try
- {
- // Tell the respective deployer to undeploy this one
- if (di.deployer != null)
- {
- di.deployer.stop(di);
- di.status="Stopped";
- di.state = DeploymentState.STOPPED;
- }
- }
- catch (Throwable t)
- {
- log.error("Deployer stop failed for: " + di.url, t);
- }
-
- }
-
- /**
- * The <code>destroy</code> method is the second and final internal undeployment step.
- *
- * @param di a <code>DeploymentInfo</code> value
- */
- private void destroy(DeploymentInfo di)
- {
- // Destroy all sub-deployments
- ArrayList reverseSortedSubs = new ArrayList(di.subDeployments);
- Collections.sort(reverseSortedSubs, infoSorter);
- Collections.reverse(reverseSortedSubs);
- for (Iterator subs = reverseSortedSubs.iterator(); subs.hasNext();)
- {
- DeploymentInfo sub = (DeploymentInfo) subs.next();
- log.debug("Destroying sub deployment: "+sub.url);
- destroy(sub);
- }
- // Lastly destroy the deployment itself
- try
- {
- // Tell the respective deployer to undeploy this one
- if (di.deployer != null)
- {
- di.deployer.destroy(di);
- di.status="Destroyed";
- di.state = DeploymentState.DESTROYED;
- }
- }
- catch (Throwable t)
- {
- log.error("Deployer destroy failed for: " + di.url, t);
- di.state = DeploymentState.FAILED;
- }
-
- try
- {
- // remove from local maps
- synchronized (deploymentList)
- {
- deploymentMap.remove(di.url);
- if (deploymentList.lastIndexOf(di) != -1)
- {
- deploymentList.remove(deploymentList.lastIndexOf(di));
- }
- }
- synchronized (waitingDeployments)
- {
- waitingDeployments.remove(di);
- }
- // Nuke my stuff, this includes the class loader
- di.cleanup();
-
- log.debug("Undeployed "+di.url);
- }
- catch (Throwable t)
- {
- log.error("Undeployment cleanup failed: " + di.url, t);
- }
- }
-
- /**
- * The <code>deploy</code> method deploys a package identified by a
- * string representation of a URL.
- *
- * @param urlspec a <code>String</code> value
- * @exception MalformedURLException if an error occurs
- * @jmx.managed-operation
- */
- public void deploy(String urlspec)
- throws DeploymentException, MalformedURLException
- {
- if( server == null )
- throw new DeploymentException("The MainDeployer has been unregistered");
-
- URL url;
- try
- {
- url = new URL(urlspec);
- }
- catch (MalformedURLException e)
- {
- File file = new File(urlspec);
- url = file.toURL();
- }
-
- deploy(url);
- }
-
- /**
- * The <code>deploy</code> method deploys a package identified by a URL
- *
- * @param url an <code>URL</code> value
- * @jmx.managed-operation
- */
- public void deploy(URL url) throws DeploymentException
- {
- DeploymentInfo sdi = getDeployment(url);
- // if it does not exist create a new deployment
- if (sdi == null)
- {
- sdi = new DeploymentInfo(url, null, getServer());
- deploy(sdi);
- }
- if( sdi.state != DeploymentState.STARTED )
- checkIncompleteDeployments();
- }
-
- /**
- * The <code>deploy</code> method deploys a package represented by a DeploymentInfo object.
- *
- * @param deployment a <code>DeploymentInfo</code> value
- * @exception DeploymentException if an error occurs
- * @jmx.managed-operation
- */
- public void deploy(DeploymentInfo deployment)
- throws DeploymentException
- {
- // If we are already deployed return
- if (isDeployed(deployment.url))
- {
- log.info("Package: " + deployment.url + " is already deployed");
- return;
- }
- log.debug("Starting deployment of package: " + deployment.url);
-
- boolean inited = false;
- try
- {
- inited = init(deployment);
- }
- catch (Throwable t)
- {
- log.error("Could not initialise deployment: " + deployment.url, t);
- DeploymentException.rethrowAsDeploymentException("Could not initialise deployment: " + deployment.url, t);
- }
- if ( inited )
- {
- create(deployment);
- start(deployment);
- log.debug("Deployed package: " + deployment.url);
- } // end of if ()
- else
- {
- log.debug("Deployment of package: " + deployment.url + " is waiting for an appropriate deployer.");
- } // end of else
- }
-
-
- /**
- * The <code>init</code> method is the first internal deployment step.
- * The tasks are to copy the code if necessary,
- * set up classloaders, and identify the deployer for the package.
- *
- * @param deployment a <code>DeploymentInfo</code> value
- * @throws DeploymentException if an error occurs
- */
- private boolean init(DeploymentInfo deployment) throws DeploymentException
- {
- // If we are already deployed return
- if (isDeployed(deployment.url))
- {
- log.info("Package: " + deployment.url + " is already deployed");
- return false;
- }
- log.debug("Starting deployment (init step) of package at: " + deployment.url);
- try
- {
- // Create a local copy of that File, the sdi keeps track of the copy directory
- if (deployment.localUrl == null)
- {
- makeLocalCopy(deployment);
- URL[] localCl = new URL[]{deployment.localUrl};
- deployment.localCl = new URLClassLoader(localCl);
- }
-
- // What deployer is able to deploy this file
- findDeployer(deployment);
-
- if(deployment.deployer == null)
- {
- deployment.state = DeploymentState.INIT_WAITING_DEPLOYER;
- log.debug("deployment waiting for deployer: " + deployment.url);
- synchronized (waitingDeployments)
- {
- if (waitingDeployments.contains(deployment) == false)
- waitingDeployments.add(deployment);
- }
- return false;
- }
- deployment.state = DeploymentState.INIT_DEPLOYER;
- //we have the deployer, continue deployment.
- deployment.deployer.init(deployment);
- // initialize the unified classloaders for this deployment
- deployment.createClassLoaders();
- deployment.state = DeploymentState.INITIALIZED;
-
- // Add the deployment to the map so we can detect circular deployments
- synchronized (deploymentList)
- {
- deploymentMap.put(deployment.url, deployment);
- }
-
- // create subdeployments as needed
- parseManifestLibraries(deployment);
-
- log.debug("found " + deployment.subDeployments.size() + " subpackages of " + deployment.url);
- // get sorted subDeployments
- ArrayList sortedSubs = new ArrayList(deployment.subDeployments);
- Collections.sort(sortedSubs, infoSorter);
- for (Iterator lt = sortedSubs.listIterator(); lt.hasNext();)
- {
- init((DeploymentInfo) lt.next());
- }
- }
- catch (Exception e)
- {
- deployment.state = DeploymentState.FAILED;
- DeploymentException.rethrowAsDeploymentException("exception in init of " + deployment.url, e);
- }
- finally
- {
- // whether you do it or not, for the autodeployer
- try
- {
- URL url = deployment.localUrl == null ? deployment.url : deployment.localUrl;
-
- long lastModified = -1;
-
- if (url.getProtocol().equals("file"))
- lastModified = new File(url.getFile()).lastModified();
- else
- lastModified = url.openConnection().getLastModified();
-
- deployment.lastModified=lastModified;
- deployment.lastDeployed=System.currentTimeMillis();
- }
- catch (IOException ignore)
- {
- deployment.lastModified=System.currentTimeMillis();
- deployment.lastDeployed=System.currentTimeMillis();
- }
-
- synchronized (deploymentList)
- {
- // Do we watch it? Watch only urls outside our copy directory.
- if (!inLocalCopyDir(deployment.url) && deploymentList.contains(deployment) == false)
- {
- deploymentList.add(deployment);
- log.debug("Watching new file: " + deployment.url);
- }
- }
- }
- return true;
- }
-
- /**
- * The <code>create</code> method is the second internal deployment step.
- * It should set up all information not
- * requiring other components. for instance, the ejb Container is created,
- * and the proxy bound into jndi.
- *
- * @param deployment a <code>DeploymentInfo</code> value
- * @throws DeploymentException if an error occurs
- */
- private void create(DeploymentInfo deployment) throws DeploymentException
- {
- log.debug("create step for deployment " + deployment.url);
- try
- {
- ArrayList sortedSubs = new ArrayList(deployment.subDeployments);
- Collections.sort(sortedSubs, infoSorter);
- for (Iterator lt = sortedSubs.listIterator(); lt.hasNext();)
- {
- create((DeploymentInfo) lt.next());
- }
- deployment.state = DeploymentState.CREATE_SUBDEPLOYMENTS;
-
- // Deploy this SDI, if it is a deployable type
- if (deployment.deployer != null)
- {
- try
- {
- deployment.state = DeploymentState.CREATE_DEPLOYER;
- deployment.deployer.create(deployment);
- // See if all mbeans are created...
- deployment.state = DeploymentState.CREATED;
- deployment.status="Created";
- log.debug("Done with create step of deploying " + deployment.shortName);
- }
- catch (Throwable t)
- {
- log.error("Could not create deployment: " + deployment.url, t);
- throw t;
- }
- }
- else
- {
- log.debug("Still no deployer for package in create step: " + deployment.shortName);
- } // end of else
- }
- catch (Throwable t)
- {
- log.trace("could not create deployment: " + deployment.url, t);
- deployment.status = "Deployment FAILED reason: " + t.getMessage();
- deployment.state = DeploymentState.FAILED;
- DeploymentException.rethrowAsDeploymentException("Could not create deployment: " + deployment.url, t);
- }
- }
-
- /**
- * The <code>start</code> method is the third and final internal deployment step.
- * The purpose is to set up relationships between components.
- * for instance, ejb links are set up here.
- *
- * @param deployment a <code>DeploymentInfo</code> value
- * @throws DeploymentException if an error occurs
- */
- private void start(DeploymentInfo deployment) throws DeploymentException
- {
- deployment.status = "Starting";
- log.debug("Begin deployment start " + deployment.url);
- try
- {
- ArrayList sortedSubs = new ArrayList(deployment.subDeployments);
- Collections.sort(sortedSubs, infoSorter);
- for (Iterator lt = sortedSubs.listIterator(); lt.hasNext();)
- {
- start((DeploymentInfo) lt.next());
- }
- deployment.state = DeploymentState.START_SUBDEPLOYMENTS;
-
- // Deploy this SDI, if it is a deployable type
- if (deployment.deployer != null)
- {
- try
- {
- deployment.state = DeploymentState.START_DEPLOYER;
- deployment.deployer.start(deployment);
- // See if all mbeans are started...
- Object[] args = {deployment, DeploymentState.STARTED};
- String[] sig = {"org.jboss.deployment.DeploymentInfo",
- "org.jboss.deployment.DeploymentState"};
- server.invoke(serviceController, "validateDeploymentState",args, sig);
- deployment.status = "Deployed";
- log.debug("End deployment start on package: "+ deployment.shortName);
- }
- catch (Throwable t)
- {
- log.error("Could not start deployment: " + deployment.url, t);
- throw t;
- }
- }
- else
- {
- log.debug("Still no deployer for package in start step: " + deployment.shortName);
- } // end of else
- }
- catch (Throwable t)
- {
- log.trace("could not start deployment: " + deployment.url, t);
- deployment.state = DeploymentState.FAILED;
- deployment.status = "Deployment FAILED reason: " + t.getMessage();
- DeploymentException.rethrowAsDeploymentException("Could not create deployment: " + deployment.url, t);
- }
- }
-
- /**
- * The <code>findDeployer</code> method attempts to find a deployer for the DeploymentInfo
- * supplied as a parameter.
- *
- * @param sdi a <code>DeploymentInfo</code> value
- */
- private void findDeployer(DeploymentInfo sdi)
- {
- // If there is already a deployer use it
- if( sdi.deployer != null )
- {
- log.debug("using existing deployer "+sdi.deployer);
- return;
- }
-
- //
- // To deploy directories of beans one should just name the directory
- // mybean.ear/bla...bla, so that the directory gets picked up by the right deployer
- //
- synchronized(deployers)
- {
- for (Iterator iterator = deployers.iterator(); iterator.hasNext(); )
- {
- SubDeployer deployer = (SubDeployer) iterator.next();
- if (deployer.accepts(sdi))
- {
- sdi.deployer = deployer;
- log.debug("using deployer "+deployer);
- return;
- }
- }
- }
- log.debug("No deployer found for url: " + sdi.url);
- }
-
- /**
- * The <code>parseManifestLibraries</code> method looks into the manifest for classpath
- * goo, and tries to deploy referenced packages.
- *
- * @param sdi a <code>DeploymentInfo</code> value
- */
- private void parseManifestLibraries(DeploymentInfo sdi)
- {
- String classPath = null;
-
- Manifest mf = sdi.getManifest();
-
- if( mf != null )
- {
- Attributes mainAttributes = mf.getMainAttributes();
- classPath = mainAttributes.getValue(Attributes.Name.CLASS_PATH);
- }
-
- if (classPath != null)
- {
- StringTokenizer st = new StringTokenizer(classPath);
- log.debug("resolveLibraries: "+classPath);
-
- while (st.hasMoreTokens())
- {
- URL lib = null;
- String tk = st.nextToken();
- log.debug("new manifest entry for sdi at "+sdi.shortName+" entry is "+tk);
-
- try
- {
- if (sdi.isDirectory)
- {
- File parentDir = new File(sdi.url.getPath()).getParentFile();
- lib = new File(parentDir, tk).toURL();
- }
- else
- {
- lib = new URL(sdi.url, tk);
- }
-
- // Only deploy this if it is not already being deployed
- if ( deploymentMap.containsKey(lib) == false )
- {
- /* Test that the only deployer for this is the JARDeployer.
- Any other type of deployment cannot be initiated through
- a manifest reference.
- */
- DeploymentInfo mfRef = new DeploymentInfo(lib, null, getServer());
- makeLocalCopy(mfRef);
- URL[] localURL = {mfRef.localUrl};
- mfRef.localCl = new java.net.URLClassLoader(localURL);
- findDeployer(mfRef);
- SubDeployer deployer = mfRef.deployer;
- if(deployer != null && (deployer instanceof JARDeployer) == false)
- {
- // Its a non-jar deployment that must be deployed seperately
- log.warn("Found non-jar deployer for " + tk + ": " + deployer);
- }
-
- // add the library
- sdi.addLibraryJar(lib);
- }
- }
- catch (Exception ignore)
- {
- log.debug("The manifest entry in "+sdi.url+" references URL "+lib+
- " which could not be opened, entry ignored", ignore);
- }
- }
- }
- }
-
- /**
- * Downloads the jar file or directory the src URL points to.
- * In case of directory it becomes packed to a jar file.
- */
- private void makeLocalCopy(DeploymentInfo sdi)
- {
- try
- {
- if (sdi.url.getProtocol().equals("file") && (!copyFiles || sdi.isDirectory))
- {
- // If local copies have been disabled, do nothing
- sdi.localUrl = sdi.url;
- return;
- }
- // Are we already in the localCopyDir?
- else if (inLocalCopyDir(sdi.url))
- {
- sdi.localUrl = sdi.url;
- return;
- }
- else
- {
- String shortName = sdi.shortName;
- File localFile = File.createTempFile("tmp", shortName, tempDir);
- sdi.localUrl = localFile.toURL();
- copy(sdi.url, localFile);
- }
- }
- catch (Exception e)
- {
- log.error("Could not make local copy for " + sdi.url, e);
- }
- }
-
- private boolean inLocalCopyDir(URL url)
- {
- int i = 0;
- String urlTest = url.toString();
- if( urlTest.startsWith("jar:") )
- i = 4;
-
- return urlTest.startsWith(tempDirString, i);
- }
-
- protected void copy(URL src, File dest) throws IOException
- {
- log.debug("Copying " + src + " -> " + dest);
-
- // Validate that the dest parent directory structure exists
- File dir = dest.getParentFile();
- if (!dir.exists())
- {
- boolean created = dir.mkdirs();
- if( created == false )
- throw new IOException("mkdirs failed for: "+dir.getAbsolutePath());
- }
-
- // Remove any existing dest content
- if( dest.exists() == true )
- {
- boolean deleted = Files.delete(dest);
- if( deleted == false )
- throw new IOException("delete of previous content failed for: "+dest.getAbsolutePath());
- }
-
- if (src.getProtocol().equals("file"))
- {
- File srcFile = new File(src.getFile());
- if (srcFile.isDirectory())
- {
- log.debug("Making zip copy of: " + srcFile);
- // make a jar archive of the directory
- OutputStream out = new BufferedOutputStream(new FileOutputStream(dest));
- JarUtils.jar(out, srcFile.listFiles());
- out.close();
- return;
- }
- }
-
- InputStream in = new BufferedInputStream(src.openStream());
- OutputStream out = new BufferedOutputStream(new FileOutputStream(dest));
- Streams.copy(in, out);
- out.flush();
- out.close();
- in.close();
- }
-
- /**
- * The <code>start</code> method starts a package identified by a URL
- *
- * @param urlspec an <code>URL</code> value
- * @jmx.managed-operation
- */
- public void start(String urlspec)
- throws DeploymentException, MalformedURLException
- {
- DeploymentInfo sdi = getDeployment(new URL(urlspec));
- if (sdi!= null)
- {
- start(sdi);
- }
- }
-
- /**
- * The <code>stop</code> method stops a package identified by a URL
- *
- * @param urlspec an <code>URL</code> value
- * @jmx.managed-operation
- */
- public void stop(String urlspec)
- throws DeploymentException, MalformedURLException
- {
- DeploymentInfo sdi = getDeployment(new URL(urlspec));
- if (sdi!= null)
- {
- stop(sdi);
- }
- }
-
- /**
- * The <code>isDeployed</code> method tells you if a package identified by a string
- * representation of a URL is currently deployed.
- *
- * @param url a <code>String</code> value
- * @return a <code>boolean</code> value
- * @exception MalformedURLException if an error occurs
- * @jmx.managed-operation
- */
- public boolean isDeployed(String url)
- throws MalformedURLException
- {
- return isDeployed(new URL(url));
- }
-
- /**
- * The <code>isDeployed</code> method tells you if a packaged identified by
- * a URL is deployed.
- * @param url an <code>URL</code> value
- * @return a <code>boolean</code> value
- * @jmx.managed-operation
- */
- public boolean isDeployed(URL url)
- {
- DeploymentInfo di = getDeployment(url);
- if (di == null)
- {
- return false;
- } // end of if ()
- return di.state == DeploymentState.STARTED;
- }
-
- /**
- * The <code>getDeployment</code> method returns the DeploymentInfo
- * object for the URL supplied.
- *
- * @param url an <code>URL</code> value
- * @return a <code>DeploymentInfo</code> value
- * @jmx.managed-operation
- */
- public DeploymentInfo getDeployment(URL url)
- {
- synchronized (deploymentList)
- {
- return (DeploymentInfo) deploymentMap.get(url);
- }
- }
-
- /**
- * The <code>getWatchUrl</code> method returns the URL that, when modified,
- * indicates that a redeploy is needed.
- *
- * @param url an <code>URL</code> value
- * @return a <code>URL</code> value
- * @jmx.managed-operation
- */
- public URL getWatchUrl(URL url)
- {
- DeploymentInfo info = getDeployment(url);
- return info == null ? null : info.watch;
- }
-
- /** Check the current deployment states and generate a IncompleteDeploymentException
- * if there are mbeans waiting for depedencies.
- * @exception IncompleteDeploymentException
- * @jmx.managed-operation
- */
- public void checkIncompleteDeployments() throws DeploymentException
- {
- try
- {
- Collection waitingForClasses = new HashSet();
- Collection waitingForDepends = (Collection)server.invoke(serviceController,
- "listIncompletelyDeployed",
- new Object[] {},
- new String[] {});
- Collection allServices = (Collection) server.invoke(serviceController,
- "listDeployed",
- new Object[] {},
- new String[] {});
-
- // Weed services that are waiting for other deployments
- Collection rootCause = new HashSet(waitingForDepends);
- Collection missing = new HashSet();
- for (Iterator i = rootCause.iterator(); i.hasNext();)
- {
- ServiceContext ctx = (ServiceContext) i.next();
- for (Iterator j = ctx.iDependOn.iterator(); j.hasNext(); )
- {
- ServiceContext dependee = (ServiceContext) j.next();
- if (dependee.state != ServiceContext.RUNNING)
- {
- // Add missing mbean
- if (allServices.contains(dependee) == false)
- missing.add(dependee);
- // We are not a root cause
- i.remove();
- break;
- }
- }
- }
- // Add missing mbeans to the root cause
- rootCause.addAll(missing);
-
- IncompleteDeploymentException ide = new IncompleteDeploymentException(
- waitingForClasses,
- waitingForDepends,
- rootCause,
- listIncompletelyDeployed(),
- listWaitingForDeployer());
- if (!ide.isEmpty())
- {
- throw ide;
- } // end of if ()
- }
- catch (JMException jme)
- {
- throw new DeploymentException(JMXExceptionDecoder.decode(jme));
- } // end of try-catch
- }
-
- /**
- * @param parent
- * @param map
- */
- private void fillParentAndChildrenSDI(DeploymentInfo parent, Map map)
- {
- Set subDeployments = parent.subDeployments;
- Iterator it = subDeployments.iterator();
- while (it.hasNext())
- {
- DeploymentInfo child = (DeploymentInfo) it.next();
- SerializableDeploymentInfo sdichild = returnSDI(child, map);
- sdichild.parent = returnSDI(parent, map);
- sdichild.parent.subDeployments.add(sdichild);
- fillParentAndChildrenSDI(child, map);
- }
- }
-
- private SerializableDeploymentInfo returnSDI(DeploymentInfo di, Map map)
- {
- SerializableDeploymentInfo sdi = (SerializableDeploymentInfo) map.get(di.url);
- if( sdi == null )
- {
- sdi = new SerializableDeploymentInfo(di);
- map.put(di.url, sdi);
- }
- return sdi;
- }
-
-}
Deleted: branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/MainDeployerConstants.java
===================================================================
--- branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/MainDeployerConstants.java 2006-08-04 16:27:06 UTC (rev 55202)
+++ branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/MainDeployerConstants.java 2006-08-04 16:40:12 UTC (rev 55203)
@@ -1,35 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.deployment;
-
-/** Constants for MainDeployers
- *
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public interface MainDeployerConstants
-{
- /** The JMX notification type sent when a deployer is added */
- public static final String ADD_DEPLOYER = "org.jboss.deployment.MainDeployer.addDeployer";
- /** The JMX notification type sent when a deployer is removed */
- public static final String REMOVE_DEPLOYER = "org.jboss.deployment.MainDeployer.removeDeployer";
-}
Deleted: branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/MainDeployerMBean.java
===================================================================
--- branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/MainDeployerMBean.java 2006-08-04 16:27:06 UTC (rev 55202)
+++ branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/MainDeployerMBean.java 2006-08-04 16:40:12 UTC (rev 55203)
@@ -1,250 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.deployment;
-
-import java.io.File;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Collection;
-
-import javax.management.ObjectName;
-
-import org.jboss.mx.util.ObjectNameFactory;
-import org.jboss.system.ServiceMBean;
-
-/**
- * MainDeployer MBean interface
- *
- * @version $Revision$
- */
-public interface MainDeployerMBean extends
- ServiceMBean, DeployerMBean, MainDeployerConstants
-{
- /** The default ObjectName */
- ObjectName OBJECT_NAME = ObjectNameFactory.create("jboss.system:service=MainDeployer");
-
- // Attributes ----------------------------------------------------
-
- /** Flag indicating whether directory content will be deployed.
- * The default value is taken from the jboss.deploy.localcopy system property. */
- boolean getCopyFiles();
- void setCopyFiles(boolean copyFiles);
-
- /** The path to the local tmp directory */
- File getTempDir();
- void setTempDir(File tempDir);
-
- /** The enhanced suffix order */
- String[] getEnhancedSuffixOrder();
- void setEnhancedSuffixOrder(String[] enhancedSuffixOrder);
-
- /** The ObjectName of the ServiceController */
- void setServiceController(ObjectName serviceController);
-
- /** The path to the local tmp directory in String form */
- String getTempDirString();
-
- /** The ordering of the deployment suffixes */
- String[] getSuffixOrder();
-
- // Operations ----------------------------------------------------
-
- /**
- * The <code>listDeployed</code> method returns a collection of
- * DeploymemtInfo objects for the currently deployed packages.
- * @return a <code>Collection</code> value
- */
- Collection listDeployed();
-
- /**
- * The <code>listDeployedModules</code> method returns a collection of
- * SerializableDeploymentInfo objects for the currently deployed packages.
- * @return a <code>Collection</code> value
- */
- Collection listDeployedModules();
-
- /**
- * Describe <code>listDeployedAsString</code> method here.
- * @return a <code>String</code> value
- */
- String listDeployedAsString();
-
- /**
- * The <code>listIncompletelyDeployed</code> method returns a list of
- * packages that have not deployed completely. The toString method will
- * include any exception in the status field.
- * @return a <code>Collection</code> value
- */
- Collection listIncompletelyDeployed();
-
- /**
- * The <code>listWaitingForDeployer</code> method returns a collection of
- * the packages that currently have no identified deployer.
- * @return a <code>Collection</code> value
- */
- Collection listWaitingForDeployer();
-
- /**
- * The <code>addDeployer</code> method registers a deployer with the
- * main deployer. Any waiting packages are tested to see if the new
- * deployer will deploy them.
- * @param deployer a <code>SubDeployer</code> value
- */
- void addDeployer(SubDeployer deployer);
-
- /**
- * The <code>removeDeployer</code> method unregisters a deployer with the
- * MainDeployer. Deployed packages deployed with this deployer are undeployed.
- * @param deployer a <code>SubDeployer</code> value
- */
- void removeDeployer(SubDeployer deployer);
-
- /**
- * The <code>listDeployers</code> method returns a collection of ObjectNames
- * of deployers registered with the MainDeployer.
- * @return a <code>Collection<ObjectName></code> value
- */
- Collection listDeployers();
-
- /**
- * The <code>shutdown</code> method undeploys all deployed packages
- * in reverse order of their deployement.
- */
- void shutdown();
-
- /**
- * Describe <code>redeploy</code> method here.
- * @param urlspec a <code>String</code> value
- * @exception DeploymentException if an error occurs
- * @exception java.net.MalformedURLException if an error occurs
- */
- void redeploy(String urlspec) throws DeploymentException, MalformedURLException;
-
- /**
- * Describe <code>redeploy</code> method here.
- * @param url an <code>URL</code> value
- * @exception DeploymentException if an error occurs
- */
- void redeploy(URL url) throws DeploymentException;
-
- /**
- * Describe <code>redeploy</code> method here.
- * @param sdi a <code>DeploymentInfo</code> value
- * @exception DeploymentException if an error occurs
- */
- void redeploy(DeploymentInfo sdi) throws DeploymentException;
-
- /**
- * The <code>undeploy</code> method undeploys a package identified by a URL
- * @param url an <code>URL</code> value
- */
- void undeploy(URL url) throws DeploymentException;
-
- /**
- * The <code>undeploy</code> method undeploys a package identified by a string representation of a URL.
- * @param urlspec a <code>String</code> value
- * @exception java.net.MalformedURLException if an error occurs
- */
- void undeploy(String urlspec) throws DeploymentException, MalformedURLException;
-
- /**
- * The <code>undeploy</code> method undeploys a package represented by a DeploymentInfo object.
- * @param di a <code>DeploymentInfo</code> value
- */
- void undeploy(DeploymentInfo di);
-
- /**
- * The <code>deploy</code> method deploys a package identified by a string representation of a URL.
- * @param urlspec a <code>String</code> value
- * @exception java.net.MalformedURLException if an error occurs
- */
- void deploy(String urlspec) throws DeploymentException, MalformedURLException;
-
- /**
- * The <code>deploy</code> method deploys a package identified by a URL
- * @param url an <code>URL</code> value
- */
- void deploy(URL url) throws DeploymentException;
-
- /**
- * The <code>deploy</code> method deploys a package represented by a DeploymentInfo object.
- * @param deployment a <code>DeploymentInfo</code> value
- * @exception DeploymentException if an error occurs
- */
- void deploy(DeploymentInfo deployment) throws DeploymentException;
-
- /**
- * The <code>start</code> method starts a package identified by a URL
- * @param urlspec an URL string value
- * @jmx.managed-operation
- */
- public void start(String urlspec) throws DeploymentException, MalformedURLException;
-
- /**
- * The <code>stop</code> method stop a package identified by a URL
- * @param urlspec an URL string value
- * @jmx.managed-operation
- */
- public void stop(String urlspec) throws DeploymentException, MalformedURLException;
-
- /**
- * The <code>isDeployed</code> method tells you if a package identified
- * by a string representation of a URL is currently deployed.
- * @param url a <code>String</code> value
- * @return a <code>boolean</code> value
- * @exception java.net.MalformedURLException if an error occurs
- */
- boolean isDeployed(String url) throws MalformedURLException;
-
- /**
- * The <code>isDeployed</code> method tells you if a packaged identified
- * by a URL is deployed.
- * @param url an <code>URL</code> value
- * @return a <code>boolean</code> value
- */
- boolean isDeployed(URL url);
-
- /**
- * The <code>getDeployment</code> method returns the DeploymentInfo object
- * for the URL supplied.
- * @param url an <code>URL</code> value
- * @return a <code>DeploymentInfo</code> value
- */
- DeploymentInfo getDeployment(URL url);
-
- /**
- * The <code>getWatchUrl</code> method returns the URL that,
- * when modified, indicates that a redeploy is needed.
- * @param url an <code>URL</code> value
- * @return a <code>URL</code> value
- */
- URL getWatchUrl(URL url);
-
- /**
- * Check the current deployment states and generate an
- * IncompleteDeploymentException if there are mbeans
- * waiting for depedencies.
- * @exception IncompleteDeploymentException
- */
- void checkIncompleteDeployments() throws DeploymentException;
-
-}
Deleted: branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/ObjectModelFactorySimpleSubDeployerSupport.java
===================================================================
--- branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/ObjectModelFactorySimpleSubDeployerSupport.java 2006-08-04 16:27:06 UTC (rev 55202)
+++ branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/ObjectModelFactorySimpleSubDeployerSupport.java 2006-08-04 16:40:12 UTC (rev 55203)
@@ -1,60 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.deployment;
-
-import java.net.URL;
-
-import org.jboss.xb.binding.ObjectModelFactory;
-import org.jboss.xb.binding.Unmarshaller;
-import org.jboss.xb.binding.UnmarshallerFactory;
-
-/**
- * A simple subdeployer that deploys a managed object after parsing the
- * deployment's xml file using an ObjectModelFactory.
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision$
- */
-public abstract class ObjectModelFactorySimpleSubDeployerSupport extends SimpleSubDeployerSupport
-{
- /**
- * Get the object model factory
- *
- * @return the object model factory
- */
- public abstract ObjectModelFactory getObjectModelFactory();
-
- protected void parseMetaData(DeploymentInfo di, URL url) throws DeploymentException
- {
- try
- {
- Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
- ObjectModelFactory factory = getObjectModelFactory();
- Object root = null;
- di.metaData = unmarshaller.unmarshal(url.toString(), factory, root);
- }
- catch (Throwable t)
- {
- DeploymentException.rethrowAsDeploymentException("Error parsing meta data " + url, t);
- }
- }
-}
Deleted: branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/SARDeployer.java
===================================================================
--- branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/SARDeployer.java 2006-08-04 16:27:06 UTC (rev 55202)
+++ branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/SARDeployer.java 2006-08-04 16:40:12 UTC (rev 55203)
@@ -1,621 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.deployment;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Serializable;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.jboss.deployers.plugins.AbstractAspectDeployer;
-import org.jboss.deployers.spi.DeploymentContext;
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.mx.loading.LoaderRepositoryFactory;
-import org.jboss.mx.loading.RepositoryClassLoader;
-import org.jboss.mx.loading.LoaderRepositoryFactory.LoaderRepositoryConfig;
-import org.jboss.mx.util.MBeanProxyExt;
-import org.jboss.mx.util.MBeanServerLocator;
-import org.jboss.net.protocol.URLLister;
-import org.jboss.net.protocol.URLListerFactory;
-import org.jboss.system.ServiceController;
-import org.jboss.system.ServiceControllerMBean;
-import org.jboss.util.StringPropertyReplacer;
-import org.jboss.util.xml.JBossEntityResolver;
-import org.jboss.vfs.spi.VirtualFile;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.InputSource;
-
-/**
- * This is the main Service Deployer API. This is a compatibility deployer that
- * bridges between the old mbean service(*-service.xml) deployments and the
- * MC BeanDeployer.
- *
- * @see org.jboss.system.Service
- *
- * @author <a href="mailto:marc.fleury at jboss.org">Marc Fleury</a>
- * @author <a href="mailto:David.Maplesden at orion.co.nz">David Maplesden</a>
- * @author <a href="mailto:d_jencks at users.sourceforge.net">David Jencks</a>
- * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
- * @author <a href="mailto:sacha.labourey at cogito-info.ch">Sacha Labourey</a>
- * @author <a href="mailto:scott.stark at jboss.org">Scott Stark</a>
- * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis<a/>
- * @version $Revision$
- */
-public class SARDeployer extends AbstractAspectDeployer
-{
- /** The suffixes we accept, along with their relative order */
- private static final String[] DEFAULT_ENHANCED_SUFFIXES = new String[] {
- "050:.deployer",
- "050:-deployer.xml",
- "150:.sar",
- "150:-service.xml"
- };
-
- /** The deployment descriptor to look for */
- public static final String SAR_DESCRIPTOR = "META-INF/jboss-service.xml";
-
- /** The MBeanServer for the jmx bus of the ServiceController */
- private MBeanServer server;
- /** The ServiceController. */
- private ServiceController serviceController;
-
- /** The server configuration base URL. For example,
- file:/<jboss_dist_root>/server/default. Relative service
- descriptor codebase elements are relative to this URL.
- */
- private URL serverHomeURL;
-
- /** A Map<ObjectName, DeploymentContext> for the deployed services */
- private Map<ObjectName, DeploymentContext> serviceDeploymentMap = new ConcurrentHashMap<ObjectName, DeploymentContext>();
-
- /**
- * A Map<String, List<String>> of the suffix to accepted archive META-INF descriptor name
- * @todo externalize this
- */
- private Map<String, List<String>> suffixToDescriptorMap = new ConcurrentHashMap<String, List<String>>();
-
- /** A flag indicating if the parser used for the service descriptor should be configured for namespaces */
- private boolean useNamespaceAwareParser;
-
- /**
- * Default CTOR
- */
- public SARDeployer()
- {
- super("SARDeployer");
- setEnhancedSuffixes(DEFAULT_ENHANCED_SUFFIXES);
- // Add the .har to META-INF/{jboss-service.xml,hibernate-service.xml} mapping
- ArrayList tmp = new ArrayList();
- tmp.add(SAR_DESCRIPTOR);
- tmp.add("META-INF/hibernate-service.xml");
- suffixToDescriptorMap.put(".har", tmp);
- }
-
- public String getType()
- {
- return "sar";
- }
-
- public boolean isUseNamespaceAwareParser()
- {
- return useNamespaceAwareParser;
- }
-
- public void setUseNamespaceAwareParser(boolean useNamespaceAwareParser)
- {
- this.useNamespaceAwareParser = useNamespaceAwareParser;
- }
-
- public ServiceControllerMBean getServiceController()
- {
- return serviceController;
- }
- public MBeanServer getServer()
- {
- return server;
- }
- public void setMBeanServer(MBeanServer server)
- {
- this.server = server;
- }
-
- /**
- * Get the associated service DeploymentInfo if found, null otherwise
- *
- * @param serviceName a service object name
- * @return The associated service DeploymentInfo if found, null otherwise
- * @jmx.managed-operation
- */
- public DeploymentContext getService(ObjectName serviceName)
- {
- DeploymentContext ctx = serviceDeploymentMap.get(serviceName);
- return ctx;
- }
-
- /**
- * Start the deployer.
- */
- @Override
- public void start() throws Exception
- {
- if( server == null )
- {
- // Locate the jboss domain server
- server = MBeanServerLocator.locateJBoss();
- }
- // Create the ServiceController
- serviceController = new ServiceController();
- serviceController.setKernel(getKernelContext().getKernel());
- serviceController.setMBeanServer(server);
- }
-
- /**
- * Analyze a deployment for sar artifacts.
- * @param ctx - the current deployment to validate as a sar and analyze
- * @throws DeploymentException - throw if ctx is a sar and we fail to
- * analyze it.
- */
- @Override
- public boolean analyze(DeploymentContext ctx) throws DeploymentException
- {
- boolean isSARDeployment = false;
- String basename = ctx.getFile().getName();
- VirtualFile vf = ctx.getFile();
- if (endsWithOneOfTheSuffixes(basename))
- {
- isSARDeployment = true;
-
- try
- {
- try
- {
- // If the context contains a SAR_DESCRIPTOR its a sar archive
- @SuppressWarnings("unused")
- VirtualFile descriptor = vf.findChild(SAR_DESCRIPTOR);
- log.debug("Found "+SAR_DESCRIPTOR+": "+descriptor);
- ctx.putContextData(getClass(), SAR_DESCRIPTOR, Boolean.TRUE);
- // add deployment base to the classpath
- ctx.addClasspathEntry("");
- }
- catch(IOException ignore)
- {
- // The deployment context has no service descriptor
- log.debug("No "+SAR_DESCRIPTOR+", assuming *-service.xml");
- }
-
- // Get the document if not already present
- parseDocument(ctx);
-
- // In case there is a dependent classpath defined parse it
- parseXMLClasspath(ctx);
-
- /* TODO: Copy local directory if local-directory element is present
- NodeList lds = ctx.document.getElementsByTagName("local-directory");
- 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);
-
- // Get the url of the local copy from the classloader.
- log.debug("copying from " + ctx.localUrl + path + " -> " + dataDir);
-
- inflateJar(ctx.localUrl, dataDir, path);
- }
- */
- }
- catch (DeploymentException de)
- {
- throw de;
- }
- catch (Exception e)
- {
- throw new DeploymentException(e);
- }
- } // if endsWithOneOfTheSuffixes
-
- return isSARDeployment;
- }
-
- /**
- * Return the profileservice managed object for the given ctx.
- * TODO: need to define how a sar expresses its managed properties
- */
- public Object getManagedObject(DeploymentContext ctx)
- {
- return null;
- }
-
- /**
- * deploy all mbeans in the sar deployment context.
- *
- * @param ctx - deployment context to deploy
- * @exception DeploymentException if an error occurs
- */
- public void deploy(DeploymentContext ctx) throws DeploymentException
- {
- log.debug("Deploy, "+ctx);
- try
- {
- // Check for a custom loader-repository for scoping
- Document document = (Document) ctx.getContextData(getClass(), "document");
- NodeList loaders = document.getElementsByTagName("loader-repository");
- LoaderRepositoryConfig config = null;
- if( loaders.getLength() > 0 )
- {
- Element loader = (Element) loaders.item(0);
- config = LoaderRepositoryFactory.parseRepositoryConfig(loader);
- }
-
- // Create the legacy UCL
- RepositoryClassLoader ucl = createClassLoaders(ctx, config);
- // Register the SAR UCL as an mbean so we can use it as the service loader
- ObjectName uclName = ucl.getObjectName();
- if( server.isRegistered(uclName) == false )
- {
- log.debug("Registering service UCL="+uclName);
- server.registerMBean(ucl, uclName);
- }
-
- List<ObjectName> mbeans = (List<ObjectName>) ctx.getContextData(getClass(), "mbeans");
- mbeans.clear();
- List descriptorMbeans = serviceController.install(document.getDocumentElement(), uclName);
- mbeans.addAll(descriptorMbeans);
-
- // create the services
- for (Iterator<ObjectName> iter = mbeans.iterator(); iter.hasNext(); )
- {
- ObjectName service = (ObjectName)iter.next();
-
- // The service won't be created until explicitly dependent mbeans are created
- serviceController.create(service);
- synchronized( this.serviceDeploymentMap )
- {
- serviceDeploymentMap.put(service, ctx);
- }
- }
-
- // TODO: Generate a JMX notification for the create stage
- // super.create(ctx);
-
- for (Iterator<ObjectName> iter = mbeans.iterator(); iter.hasNext(); )
- {
- ObjectName service = iter.next();
-
- // The service won't be started until explicitely dependent mbeans are started
- serviceController.start(service);
- }
- // TODO: Generate a JMX notification for the start stage
- // super.start(ctx);
- }
- catch (Exception e)
- {
- throw new DeploymentException("Failed to deploy SAR: "+ctx, e);
- }
-
- // Generate a notification for the undeploy
- generateDeployerEvent(ctx, DeploymentEvent.DEPLOY);
- }
-
- /** The stop method invokes stop on the mbeans associatedw ith the deployment
- * in reverse order relative to create.
- *
- * @param ctx the <code>DeploymentInfo</code> value to stop.
- * @jmx.managed-operation
- */
- public void undeploy(DeploymentContext ctx) throws DeploymentException
- {
- log.debug("Undeploy, " + ctx);
-
- List<ObjectName> services = (List<ObjectName>) ctx.getContextData(getClass(), "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("stopping mbean " + name);
- try
- {
- serviceController.stop(name);
- }
- catch (Exception e)
- {
- log.error("Could not stop mbean: " + name, e);
- } // end of try-catch
- }
-
- // Generate a notification for the undeploy
- generateDeployerEvent(ctx, DeploymentEvent.UNDEPLOY);
- }
-
- // Protected -----------------------------------------------------
-
- /**
- * @param ctx
- * @throws Exception
- */
- protected void parseXMLClasspath(DeploymentContext ctx)
- throws Exception
- {
- ArrayList classpath = new ArrayList();
- URLListerFactory listerFactory = new URLListerFactory();
-
- Document document = (Document) ctx.getContextData(getClass(), "document");
- NodeList children = document.getDocumentElement().getChildNodes();
- for (int i = 0; i < children.getLength(); i++)
- {
- if (children.item(i).getNodeType() == Node.ELEMENT_NODE)
- {
- Element classpathElement = (Element)children.item(i);
- if (classpathElement.getTagName().equals("classpath"))
- {
- log.debug("Found classpath element: " + classpathElement);
- if (!classpathElement.hasAttribute("codebase"))
- {
- throw new DeploymentException
- ("Invalid classpath element missing codebase: " + classpathElement);
- }
- String codebase = classpathElement.getAttribute("codebase").trim();
- // Replace any system property references like ${x}
- codebase = StringPropertyReplacer.replaceProperties(codebase);
-
- String archives = null;
- if (classpathElement.hasAttribute("archives"))
- {
- archives = classpathElement.getAttribute("archives").trim();
- // Replace any system property references like ${x}
- archives = StringPropertyReplacer.replaceProperties(archives);
- if ("".equals(archives))
- {
- archives = null;
- }
- }
-
- // Convert codebase to a URL
- // "." is resolved relative to the deployment
- // other URLs are resolved relative to SERVER_HOME
- URL codebaseUrl;
- if (".".equals(codebase))
- {
- codebaseUrl = ctx.getFile().toURL();
- }
- else
- {
- if (archives != null && codebase.endsWith("/") == false)
- {
- codebase += "/";
- }
- codebaseUrl = new URL(serverHomeURL, codebase);
- }
- log.debug("codebase URL is " + codebaseUrl);
-
- if (archives == null)
- {
- // archives not supplied so add the codebase itself
- classpath.add(codebaseUrl);
- log.debug("added codebase to classpath");
- }
- else
- {
- // obtain a URLLister for the codebase and use it to obtain
- // the list of URLs to add
- log.debug("listing codebase for archives matching " + archives);
- URLLister lister = listerFactory.createURLLister(codebaseUrl);
- log.debug("URLLister class is " + lister.getClass().getName());
- classpath.addAll(lister.listMembers(codebaseUrl, archives));
- }
- } // end of if ()
-
- } // end of if ()
- } //end of for
-
- // Ok, now we've found the list of urls we need... deploy their classes.
- Iterator jars = classpath.iterator();
- while (jars.hasNext())
- {
- // TODO
- throw new Exception("Have not ported sar classpath to VFS");
- }
- }
-
- /** Parse the META-INF/jboss-service.xml descriptor
- */
- protected void parseDocument(DeploymentContext ctx)
- throws Exception
- {
- InputStream stream = null;
- try
- {
- Document document = (Document) ctx.getContextData(getClass(), "document");
- if (document == null)
- {
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- factory.setNamespaceAware(useNamespaceAwareParser);
- DocumentBuilder parser = factory.newDocumentBuilder();
- VirtualFile docFile = null;
- // Load jboss-service.xml from the jar or directory
- Boolean isJAR = (Boolean) ctx.getContextData(getClass(), SAR_DESCRIPTOR);
- if ( isJAR )
- {
- // Check the suffix to descriptor mapping
- VirtualFile ctxFile = ctx.getFile();
- String[] descriptors = getDescriptorName(ctx);
- for(int n = 0; n < descriptors.length; n ++)
- {
- String descriptor = descriptors[n];
- docFile = ctxFile.findChild(descriptor);
- if( docFile != null )
- {
- // If this is a unpacked deployment, update the watch url
- if (ctxFile.isDirectory())
- {
- ctx.setWatchFile(docFile);
- log.debug("Updated watch URL to: "+docFile);
- }
- break;
- }
- }
- // No descriptors, use the default META-INF/jboss-service.xml
- if( docFile == null )
- docFile = ctxFile.findChild(SAR_DESCRIPTOR);
- }
- else
- {
- docFile = ctx.getFile();
- }
- // Validate that the descriptor was found
- if (docFile == null)
- throw new DeploymentException("Failed to find META-INF/jboss-service.xml for archive: " + ctx);
-
- stream = docFile.openStream();
- InputSource is = new InputSource(stream);
- is.setSystemId(docFile.toURL().toString());
- parser.setEntityResolver(new JBossEntityResolver());
- document = parser.parse(is);
- // TODO: Need remove this dependency on org.w3c.dom.Document
- Serializable serialDoc = (Serializable) document;
- ctx.putContextData(getClass(), "document", serialDoc);
- }
- else
- {
- // TODO: when was this used?
- log.debug("Using existing deployment.document");
- }
- }
- finally
- {
- // Close the stream to get around "Too many open files"-errors
- try
- {
- stream.close();
- }
- catch (Exception ignore)
- {
- }
- }
- }
-
- // Private -------------------------------------------------------
-
- /**
- * Parse the deployment url for its suffix and return a list of the accepted service
- * descriptor names to look for.
- *
- * @param sdi - the sar deployment info
- * @return the array of sar archive/directory relative names of the service descriptor. If
- * there is no suffix to descriptor mapping, the default of {JBOSS_SERVICE} will be
- * returned.
- */
- private String[] getDescriptorName(DeploymentContext ctx)
- {
- String[] descriptorNames = {SAR_DESCRIPTOR};
- String shortName = ctx.getFile().getName();
- int dot = shortName.lastIndexOf('.');
- if( dot >= 0 )
- {
- String suffix = shortName.substring(dot);
- List descriptors = (List) suffixToDescriptorMap.get(suffix);
- if( descriptors != null )
- {
- descriptorNames = new String[descriptors.size()];
- descriptors.toArray(descriptorNames);
- }
- }
- return descriptorNames;
- }
-
- /** Create a UnifiedClassLoader for the deployment that loads from
- the localUrl and uses its parent deployments url as its orignal
- url. Previously xml descriptors simply used the TCL but since the UCLs
- are now registered as mbeans each must be unique.
- */
- private RepositoryClassLoader createClassLoaders(DeploymentContext ctx,
- LoaderRepositoryConfig repositoryConfig) throws Exception
- {
- /* Walk the deployment tree to find the parent deployment and obtain its
- url to use as our URL from which this deployment unit originated. This
- is used to determine permissions using the original URL namespace.
- Also pick up the LoaderRepository from the topmost ancestor.
- */
- DeploymentContext current = ctx;
- while (current.getParentContext() != null)
- {
- current = current.getParentContext();
- }
-
- RepositoryClassLoader ucl = null;
- DeploymentContext parent = ctx.getParentContext();
- URL ctxURL = ctx.getFile().toURL();
- if( parent == null )
- {
- if( repositoryConfig == null )
- repositoryConfig = new LoaderRepositoryConfig();
- // Make sure the specified LoaderRepository exists.
- LoaderRepositoryFactory.createLoaderRepository(server, repositoryConfig);
- log.debug("createLoaderRepository from config: "+repositoryConfig);
- // the classes are passed to a UCL that will share the classes with the whole base
- boolean isXML = ctx.getFile().getName().endsWith(".xml");
- Object[] args = { isXML ? null : ctxURL, ctxURL, Boolean.TRUE };
- String[] sig = { "java.net.URL", "java.net.URL", "boolean" };
- ucl = (RepositoryClassLoader) server.invoke(repositoryConfig.repositoryName,
- "newClassLoader",args, sig);
- ctx.putContextData(getClass(), "ucl", ucl);
- // TODO: add sar classpath jars
- }
- else
- {
- // Add a reference to the LoaderRepository
- LoaderRepositoryFactory.createLoaderRepository(server, repositoryConfig);
- // Add the deployment URL to the parent UCL
- ucl = (RepositoryClassLoader) parent.getContextData(getClass(), "ucl");
- if( ucl != null )
- {
- ucl.addURL(ctxURL);
- }
- /* TODO: there is a problem if parent ucl is null because its not a sar
- for example.
- */
- else
- {
- log.warn("Null parent ucl for sar: "+ctx);
- }
- }
- return ucl;
- }
-
-}
Deleted: branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/SARDeployerMBean.java
===================================================================
--- branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/SARDeployerMBean.java 2006-08-04 16:27:06 UTC (rev 55202)
+++ branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/SARDeployerMBean.java 2006-08-04 16:40:12 UTC (rev 55203)
@@ -1,46 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.deployment;
-
-import javax.management.ObjectName;
-
-import org.jboss.mx.util.ObjectNameFactory;
-
-/**
- * MBean interface.
- */
-public interface SARDeployerMBean extends SubDeployerExtMBean
-{
- /** The default object name */
- ObjectName OBJECT_NAME = ObjectNameFactory.create("jboss.system:service=ServiceDeployer");
-
- // Operations ----------------------------------------------------
-
- /**
- * Get the associated service DeploymentInfo if found, null otherwise
- *
- * @param serviceName a service object name
- * @return The associated service DeploymentInfo if found, null otherwise
- */
- DeploymentInfo getService(ObjectName serviceName);
-
-}
Deleted: branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/SchemaBindingSimpleSubDeployerSupport.java
===================================================================
--- branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/SchemaBindingSimpleSubDeployerSupport.java 2006-08-04 16:27:06 UTC (rev 55202)
+++ branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/SchemaBindingSimpleSubDeployerSupport.java 2006-08-04 16:40:12 UTC (rev 55203)
@@ -1,63 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.deployment;
-
-import java.net.URL;
-
-import org.jboss.xb.binding.Unmarshaller;
-import org.jboss.xb.binding.UnmarshallerFactory;
-import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
-
-/**
- * A simple subdeployer that deploys a managed object after parsing the
- * deployment's xml file using an SchemaBinding.
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision$
- */
-public abstract class SchemaBindingSimpleSubDeployerSupport extends SimpleSubDeployerSupport
-{
- /** The unmarshaller factory */
- private UnmarshallerFactory factory = UnmarshallerFactory.newInstance();
-
- /**
- * Get the schema binding
- *
- * @return the schema binding
- */
- public abstract SchemaBinding getSchemaBinding();
-
- protected void parseMetaData(DeploymentInfo di, URL url) throws DeploymentException
- {
- try
- {
- Unmarshaller unmarshaller = factory.newUnmarshaller();
- di.metaData = unmarshaller.unmarshal(url.toString(), getSchemaBinding());
- if (di.metaData == null)
- throw new RuntimeException("The xml " + url + " is not well formed!");
- }
- catch (Throwable t)
- {
- DeploymentException.rethrowAsDeploymentException("Error parsing meta data " + url, t);
- }
- }
-}
Deleted: branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/SchemaResolverSimpleSubDeployerSupport.java
===================================================================
--- branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/SchemaResolverSimpleSubDeployerSupport.java 2006-08-04 16:27:06 UTC (rev 55202)
+++ branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/SchemaResolverSimpleSubDeployerSupport.java 2006-08-04 16:40:12 UTC (rev 55203)
@@ -1,60 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.deployment;
-
-import java.net.URL;
-
-import org.jboss.xb.binding.Unmarshaller;
-import org.jboss.xb.binding.UnmarshallerFactory;
-import org.jboss.xb.binding.sunday.unmarshalling.SchemaBindingResolver;
-import org.jboss.xb.binding.sunday.unmarshalling.SingletonSchemaResolverFactory;
-
-/**
- * A simple subdeployer that deploys a managed object after parsing the
- * deployment's xml file using the SingletonSchemaResolverFactory.
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision$
- */
-public abstract class SchemaResolverSimpleSubDeployerSupport extends SimpleSubDeployerSupport
-{
- /** The unmarshaller factory */
- private UnmarshallerFactory factory = UnmarshallerFactory.newInstance();
-
- /** The resolver */
- private SchemaBindingResolver resolver = SingletonSchemaResolverFactory.getInstance().getSchemaBindingResolver();
-
- protected void parseMetaData(DeploymentInfo di, URL url) throws DeploymentException
- {
- try
- {
- Unmarshaller unmarshaller = factory.newUnmarshaller();
- di.metaData = unmarshaller.unmarshal(url.toString(), resolver);
- if (di.metaData == null)
- throw new RuntimeException("The xml " + url + " is not well formed!");
- }
- catch (Throwable t)
- {
- DeploymentException.rethrowAsDeploymentException("Error parsing meta data " + url, t);
- }
- }
-}
Deleted: branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/SerializableDeploymentInfo.java
===================================================================
--- branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/SerializableDeploymentInfo.java 2006-08-04 16:27:06 UTC (rev 55202)
+++ branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/SerializableDeploymentInfo.java 2006-08-04 16:40:12 UTC (rev 55203)
@@ -1,134 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.deployment;
-
-// $Id$
-
-import javax.management.ObjectName;
-import java.io.Serializable;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.List;
-
-/**
- * DeploymentInfo for remote access by the DeploymentManager.
- * It provides a serializable subset of the information available in DeploymentInfo.
- *
- * @author thomas.diesler at jboss.org
- * @version $Revision$
- */
-public class SerializableDeploymentInfo implements Serializable
-{
- /** @since 4.0.2 */
- private static final long serialVersionUID = -3847995513551913798L;
-
- // The initial construction timestamp
- public Date date;
- // The URL identifing this SDI
- public URL url;
- // An optional URL to a local copy of the deployment
- public URL localUrl;
- // The URL used to watch for changes when the deployment is unpacked
- public URL watch;
- // The suffix of the deployment url
- public String shortName;
- // The last system time the deployment inited by the MainDeployer
- public long lastDeployed;
- // Use for "should we redeploy failed"
- public long lastModified;
- // A free form status for the "state" can be Deployed/failed etc etc
- public String status;
- // The current state of the deployment
- public DeploymentState state;
- // The subdeployer that handles the deployment
- public ObjectName deployer;
- // The classpath declared by this xml descriptor, needs <classpath> entry
- public Collection classpath = new ArrayList();
- // The mbeans deployed
- public List mbeans;
- // Anyone can have subdeployments
- public List subDeployments;
- // And the subDeployments have a parent
- public SerializableDeploymentInfo parent;
- // the web root context in case of war file
- public String webContext;
- // An optional URL to the URL of the document loaded
- public URL documentUrl;
- // Is this a stand-alone service descriptor
- public boolean isXML;
- public boolean isScript;
- // Does the deployment url point to a directory
- public boolean isDirectory;
- // Can contain the MBean that is created through the deployment
- public ObjectName deployedObject;
-
- // Constructors *****************************************************************************************************
-
- /**
- * Construct this object from a DeploymentInfo
- */
- public SerializableDeploymentInfo(DeploymentInfo info)
- {
- this.date = info.date;
- this.url = info.url;
- this.localUrl = info.localUrl;
- this.watch = info.watch;
- this.shortName = info.shortName;
- this.lastDeployed = info.lastDeployed;
- this.lastModified = info.lastModified;
- this.status = info.status;
- this.state = info.state;
- this.deployer = info.deployer.getServiceName();
- this.classpath = info.classpath;
- this.mbeans = info.mbeans;
- this.webContext = info.webContext;
- this.documentUrl = info.documentUrl;
- this.isXML = info.isXML;
- this.isScript = info.isScript;
- this.isDirectory = info.isDirectory;
- this.deployedObject = info.deployedObject;
-
- // we do these in a second iteration
- this.parent = null;
- this.subDeployments = new ArrayList();
- }
-
- /**
- * Returns a string representation of the object.
- */
- public String toString()
- {
- StringBuffer s = new StringBuffer(super.toString());
- s.append(" { url=" + url + " }\n");
- s.append(" deployer: " + deployer + "\n");
- s.append(" status: " + status + "\n");
- s.append(" state: " + state + "\n");
- s.append(" watch: " + watch + "\n");
- s.append(" lastDeployed: " + lastDeployed + "\n");
- s.append(" lastModified: " + lastModified + "\n");
- s.append(" mbeans: " + mbeans + "\n");
- s.append(" }\n");
- return s.toString();
- }
-}
Deleted: branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/SimpleSubDeployerSupport.java
===================================================================
--- branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/SimpleSubDeployerSupport.java 2006-08-04 16:27:06 UTC (rev 55202)
+++ branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/SimpleSubDeployerSupport.java 2006-08-04 16:40:12 UTC (rev 55203)
@@ -1,408 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.deployment;
-
-import java.io.File;
-import java.net.URL;
-
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-
-import org.jboss.mx.loading.RepositoryClassLoader;
-import org.jboss.mx.util.MBeanProxyExt;
-import org.jboss.system.ServiceControllerMBean;
-
-/**
- * A simple subdeployer that deploys a managed object after parsing the
- * deployment's xml file.
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision$
- */
-public abstract class SimpleSubDeployerSupport extends SubDeployerSupport
-{
- /** A proxy to the ServiceController. */
- private ServiceControllerMBean serviceController;
-
- /** Whether we registered the classloader */
- private boolean registeredClassLoader = false;
-
- /**
- * Get the package extension for this deployment
- *
- * @return the package extension
- */
- public abstract String getExtension();
-
- /**
- * Get the metadata url
- *
- * @return the meta data url
- */
- public abstract String getMetaDataURL();
-
- /**
- * Get the object name for this deployment
- *
- * @param di the deployment info
- * @return the object name
- */
- public abstract String getObjectName(DeploymentInfo di) throws DeploymentException;
-
- /**
- * Get the deployment class
- *
- * @return the deployment class
- */
- public abstract String getDeploymentClass();
-
- public boolean accepts(DeploymentInfo di)
- {
- String urlStr = di.url.toString();
- String extension = getExtension();
- return urlStr.endsWith(extension) || urlStr.endsWith(extension + '/');
- }
-
- public void init(DeploymentInfo di) throws DeploymentException
- {
- URL url = getMetaDataResource(di);
- parseMetaData(di, url);
- resolveWatch(di, url);
- super.init(di);
- }
-
- public void create(DeploymentInfo di) throws DeploymentException
- {
- determineObjectName(di);
- ObjectName uclName = registerClassLoader(di);
- try
- {
- registerDeployment(di, uclName);
- try
- {
- createService(di);
- try
- {
- super.create(di);
- }
- catch (Throwable t)
- {
- destroyService(di);
- }
- }
- catch (Throwable t)
- {
- unregisterDeployment(di);
- throw t;
- }
- }
- catch (Throwable t)
- {
- unregisterClassLoader(di);
- DeploymentException.rethrowAsDeploymentException("Error creating deployment " + di.url, t);
- }
- }
-
- public void start(DeploymentInfo di) throws DeploymentException
- {
- startService(di);
- try
- {
- super.start(di);
- }
- catch (Throwable t)
- {
- stopService(di);
- DeploymentException.rethrowAsDeploymentException("Error in start for deployment " + di.url, t);
- }
- }
-
- public void stop(DeploymentInfo di) throws DeploymentException
- {
- stopService(di);
- super.stop(di);
- }
-
- public void destroy(DeploymentInfo di) throws DeploymentException
- {
- try
- {
- destroyService(di);
- super.destroy(di);
- }
- finally
- {
- unregisterDeployment(di);
- unregisterClassLoader(di);
- }
- }
-
- public void postRegister(Boolean done)
- {
- super.postRegister(done);
-
- if (done.booleanValue())
- {
- serviceController = (ServiceControllerMBean)
- MBeanProxyExt.create(ServiceControllerMBean.class,
- ServiceControllerMBean.OBJECT_NAME,
- server);
- }
- }
-
- /**
- * Get the url of the meta data resource
- *
- * @param di the deployment info
- * @return the url of the meta data resource
- * @throws DeploymentException for any error
- */
- protected URL getMetaDataResource(DeploymentInfo di) throws DeploymentException
- {
- URL url = di.localCl.findResource(getMetaDataURL());
- if (url == null)
- throw new DeploymentException("Could not find meta data " + getMetaDataURL() + " for deployment " + di.url);
- return url;
- }
-
- /**
- * Parse the meta data
- *
- * @param di the deployment info
- * @param url the location of the meta data
- * @throws DeploymentException for any error
- */
- abstract protected void parseMetaData(DeploymentInfo di, URL url) throws DeploymentException;
-
- /**
- * Resolve the watch url
- *
- * @param di the deployment info
- * @param url the location of the meta data
- * @throws DeploymentException for any error
- */
- protected void resolveWatch(DeploymentInfo di, URL url) throws DeploymentException
- {
- // Assume we watch the main deployment
- di.watch = di.url;
-
- // Unless it is an unpacked directory
- if (di.url.getProtocol().equals("file"))
- {
- File file = new File(di.url.getFile());
- if (file.isDirectory())
- di.watch = url;
- }
- }
-
- /**
- * Determine the object name
- *
- * @param di the deployment info
- * @throws DeploymentException for any error
- */
- protected void determineObjectName(DeploymentInfo di) throws DeploymentException
- {
- String objectName = getObjectName(di);
- try
- {
- di.deployedObject = new ObjectName(objectName);
- }
- catch (MalformedObjectNameException e)
- {
- throw new DeploymentException("INTERNAL ERROR: Bad object name. " + objectName);
- }
- }
-
- /**
- * Register the UCL classloader
- *
- * @param di the deployment info
- * @return the object name of the classloader
- * @throws DeploymentException for any error
- */
- protected ObjectName registerClassLoader(DeploymentInfo di) throws DeploymentException
- {
- ObjectName uclName = null;
- try
- {
- RepositoryClassLoader ucl = di.ucl;
- uclName = ucl.getObjectName();
- if (server.isRegistered(uclName) == false)
- {
- server.registerMBean(di.ucl, uclName);
- registeredClassLoader = true;
- }
- }
- catch (Throwable t)
- {
- DeploymentException.rethrowAsDeploymentException("Error registering classloader " + uclName, t);
- }
- return uclName;
- }
-
- /**
- * Unregister the UCL classloader
- *
- * @param di the deployment info
- */
- protected void unregisterClassLoader(DeploymentInfo di)
- {
- ObjectName uclName = null;
- try
- {
- RepositoryClassLoader ucl = di.ucl;
- if (ucl != null)
- {
- uclName = ucl.getObjectName();
- if (registeredClassLoader && server.isRegistered(uclName))
- {
- server.unregisterMBean(uclName);
- registeredClassLoader = false;
- }
- }
- }
- catch (Throwable t)
- {
- log.warn("Error unregistering classloader " + uclName, t);
- }
- }
-
- /**
- * Register the deployment
- *
- * @param di the deployment info
- * @param uclName the object name of the classloader
- * @throws DeploymentException for any error
- */
- protected void registerDeployment(DeploymentInfo di, ObjectName uclName) throws DeploymentException
- {
- try
- {
- String deploymentClass = getDeploymentClass();
- server.createMBean(deploymentClass, di.deployedObject, uclName, new Object[] { di }, new String[] { DeploymentInfo.class.getName() });
- }
- catch (Throwable t)
- {
- DeploymentException.rethrowAsDeploymentException("Error registering deployment " + di.url, t);
- }
- }
-
- /**
- * Unregister the deployment
- *
- * @param di the deployment info
- */
- protected void unregisterDeployment(DeploymentInfo di)
- {
- try
- {
- if (server.isRegistered(di.deployedObject))
- server.unregisterMBean(di.deployedObject);
- }
- catch (Throwable t)
- {
- log.warn("Error unregistering deployment " + di.deployedObject, t);
- }
- }
-
- /**
- * Do the create lifecyle for the deployment
- *
- * @param di the deployment info
- * @throws DeploymentException for any error
- */
- protected void createService(DeploymentInfo di) throws DeploymentException
- {
- try
- {
- serviceController.create(di.deployedObject);
- }
- catch (Throwable t)
- {
- DeploymentException.rethrowAsDeploymentException("Error in create for deployment " + di.url, t);
- }
- }
-
- /**
- * Do the start lifecyle for the deployment
- *
- * @param di the deployment info
- * @throws DeploymentException for any error
- */
- protected void startService(DeploymentInfo di) throws DeploymentException
- {
- try
- {
- serviceController.start(di.deployedObject);
- }
- catch (Throwable t)
- {
- DeploymentException.rethrowAsDeploymentException("Error in start for deployment " + di.url, t);
- }
- }
-
- /**
- * Do the stop lifecyle for the deployment
- *
- * @param di the deployment info
- */
- protected void stopService(DeploymentInfo di)
- {
- try
- {
- if (di.deployedObject != null)
- serviceController.stop(di.deployedObject);
- }
- catch (Throwable t)
- {
- log.warn("Error in stop for deployment " + di.url, t);
- }
- }
-
- /**
- * Do the destroy lifecyle for the deployment
- *
- * @param di the deployment info
- */
- protected void destroyService(DeploymentInfo di) throws DeploymentException
- {
- try
- {
- if (di.deployedObject != null)
- serviceController.destroy(di.deployedObject);
- }
- catch (Throwable t)
- {
- log.warn("Error in destroy for deployment " + di.url, t);
- }
- try
- {
- if (di.deployedObject != null)
- serviceController.remove(di.deployedObject);
- }
- catch (Throwable t)
- {
- log.warn("Error in remove for deployment " + di.url, t);
- }
- }
-}
Deleted: branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/SubDeployer.java
===================================================================
--- branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/SubDeployer.java 2006-08-04 16:27:06 UTC (rev 55202)
+++ branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/SubDeployer.java 2006-08-04 16:40:12 UTC (rev 55203)
@@ -1,138 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.deployment;
-
-import javax.management.ObjectName;
-
-/**
- * The common interface for sub-deployer components which
- * perform the actual deployment services for application
- * components.
- *
- * @jmx:mbean extends="org.jboss.system.ServiceMBean"
- *
- * @version <tt>$Revision$</tt>
- * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
- * @author <a href="mailto:toby.allsopp at peace.com">Toby Allsopp</a>
- * @author <a href="mailto:marc.fleury at jboss.org">Marc Fleury</a>
- * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
- */
-public interface SubDeployer
-{
- /** The notification type send when a SubDeployer completes init */
- public static final String INIT_NOTIFICATION = "org.jboss.deployment.SubDeployer.init";
- /** The notification type send when a SubDeployer completes create */
- public static final String CREATE_NOTIFICATION = "org.jboss.deployment.SubDeployer.create";
- /** The notification type send when a SubDeployer completes start */
- public static final String START_NOTIFICATION = "org.jboss.deployment.SubDeployer.start";
- /** The notification type send when a SubDeployer completes stop */
- public static final String STOP_NOTIFICATION = "org.jboss.deployment.SubDeployer.stop";
- /** The notification type send when a SubDeployer completes destroy */
- public static final String DESTROY_NOTIFICATION = "org.jboss.deployment.SubDeployer.destroy";
-
- /**
- * Get the JMX ObjectName of the service that provides the SubDeployer
- * @return JMX ObjectName of the service
- *
- * @jmx:managed-attribute
- */
- public ObjectName getServiceName();
-
- /**
- * Get an array of suffixes of interest to this subdeployer
- * @return array of suffix strings
- *
- * @jmx:managed-attribute
- */
- public String[] getSuffixes();
-
- /**
- * Get the relative order of the specified suffixes
- * @return the relative order of the specified suffixes
- *
- * @jmx:managed-attribute
- */
- public int getRelativeOrder();
-
- /**
- * The <code>accepts</code> method is called by MainDeployer to
- * determine which deployer is suitable for a DeploymentInfo.
- *
- * @param sdi a <code>DeploymentInfo</code> value
- * @return a <code>boolean</code> value
- *
- * @jmx:managed-operation
- */
- boolean accepts(DeploymentInfo sdi);
-
- /**
- * The <code>init</code> method lets the deployer set a few properties
- * of the DeploymentInfo, such as the watch url.
- *
- * @param sdi a <code>DeploymentInfo</code> value
- * @throws DeploymentException if an error occurs
- *
- * @jmx:managed-operation
- */
- void init(DeploymentInfo sdi) throws DeploymentException;
-
- /**
- * Set up the components of the deployment that do not
- * refer to other components
- *
- * @param sdi a <code>DeploymentInfo</code> value
- * @throws DeploymentException if an error occurs
- *
- * @jmx:managed-operation
- */
- void create(DeploymentInfo sdi) throws DeploymentException;
-
- /**
- * The <code>start</code> method sets up relationships with other components.
- *
- * @param sdi a <code>DeploymentInfo</code> value
- * @throws DeploymentException if an error occurs
- *
- * @jmx:managed-operation
- */
- void start(DeploymentInfo sdi) throws DeploymentException;
-
- /**
- * The <code>stop</code> method removes relationships between components.
- *
- * @param sdi a <code>DeploymentInfo</code> value
- * @throws DeploymentException if an error occurs
- *
- * @jmx:managed-operation
- */
- void stop(DeploymentInfo sdi) throws DeploymentException;
-
- /**
- * The <code>destroy</code> method removes individual components
- *
- * @param sdi a <code>DeploymentInfo</code> value
- * @throws DeploymentException if an error occurs
- *
- * @jmx:managed-operation
- */
- void destroy(DeploymentInfo sdi) throws DeploymentException;
-}
Deleted: branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/SubDeployerExt.java
===================================================================
--- branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/SubDeployerExt.java 2006-08-04 16:27:06 UTC (rev 55202)
+++ branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/SubDeployerExt.java 2006-08-04 16:40:12 UTC (rev 55203)
@@ -1,44 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.deployment;
-
-/**
- * An extension interface that allows the retrieval
- * and setting of the combined suffixes and their relative
- * order supported by a SubDeployer.
- *
- * The syntax of an enhanced suffix is
- *
- * "order:suffix"
- *
- * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
- * @version $Revision$
- */
-public interface SubDeployerExt extends SubDeployer
-{
- /**
- * The list of supported suffixes
- * and their relative order.
- */
- void setEnhancedSuffixes(String[] enhancedSuffixes);
- String[] getEnhancedSuffixes();
-}
Deleted: branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/SubDeployerExtMBean.java
===================================================================
--- branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/SubDeployerExtMBean.java 2006-08-04 16:27:06 UTC (rev 55202)
+++ branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/SubDeployerExtMBean.java 2006-08-04 16:40:12 UTC (rev 55203)
@@ -1,43 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.deployment;
-
-/**
- * An extension mbean interface that allows the retrieval
- * and setting of the combined suffixes and their relative
- * order supported by a SubDeployer.
- *
- * The syntax of an enhanced suffix is
- *
- * "order:suffix"
- *
- * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
- * @version $Revision$
- */
-public interface SubDeployerExtMBean extends SubDeployerMBean
-{
- /**
- * The list of enhanced suffixes
- */
- void setEnhancedSuffixes(String[] enhancedSuffixes);
- String[] getEnhancedSuffixes();
-}
Deleted: branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/SubDeployerInterceptor.java
===================================================================
--- branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/SubDeployerInterceptor.java 2006-08-04 16:27:06 UTC (rev 55202)
+++ branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/SubDeployerInterceptor.java 2006-08-04 16:40:12 UTC (rev 55203)
@@ -1,162 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.deployment;
-
-import org.jboss.mx.interceptor.AbstractInterceptor;
-import org.jboss.mx.interceptor.Interceptor;
-import org.jboss.mx.server.Invocation;
-
-/**
- * Base class for SubDeployer interceptors.
- *
- * Override one or more of the init(), create(), start(), stop(), destroy()
- * methods to add behaviour. Don't forget to call invokeNext() inside
- * your implementation, if you want the call to be continued.
- *
- * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
- * @version $Revision$
- */
-public abstract class SubDeployerInterceptor extends AbstractInterceptor
-{
- // Constructors --------------------------------------------------
-
- /**
- * Default CTOR
- */
- public SubDeployerInterceptor()
- {
- super();
- }
-
- /**
- * CTOR
- *
- * @param name - the name to use for this interceptor
- */
- public SubDeployerInterceptor(String name)
- {
- // invoker is unknown
- super(name);
- }
-
- // Interceptor implementation ------------------------------------
-
- /**
- * This invoke method checks for invocations of interest, .i.e.
- * init(), create(), start(), stop(), destroy() operation calls
- * with a single DeploymentInfo argument and wraps the invocation
- * with calls to corresponding init(), create(), etc. methods.
- */
- public Object invoke(Invocation invocation) throws Throwable
- {
- String type = invocation.getType();
-
- // make sure this is an operation invocation
- if (type.equals(Invocation.OP_INVOKE))
- {
- Object args[] = invocation.getArgs();
- Object retn = invocation.getReturnTypeClass();
-
- // make sure the signature matches -> void <methodName>(DeploymentInfo di)
- if ((args.length == 1) && (args[0] instanceof DeploymentInfo) && (retn == null))
- {
- String method = invocation.getName();
- DeploymentInfo di = (DeploymentInfo)args[0];
-
- if (method.equals("init"))
- {
- return init(invocation, di);
- }
- else if (method.equals("create"))
- {
- return create(invocation, di);
- }
- else if (method.equals("start"))
- {
- return start(invocation, di);
- }
- else if (method.equals("stop"))
- {
- return stop(invocation, di);
- }
- else if (method.equals("destroy"))
- {
- return destroy(invocation, di);
- }
- }
- }
- // if we reached this point invocation is of no interest
- // to SubDeployerInterceptor so simply forward it
- return invokeNext(invocation);
- }
-
- // Protected -----------------------------------------------------
-
- /**
- * Use this to forward the call
- */
- protected Object invokeNext(Invocation invocation) throws Throwable
- {
- // call the next in the interceptor chain,
- // if nobody follows dispatch the call
- Interceptor next = invocation.nextInterceptor();
- if (next != null)
- {
- return next.invoke(invocation);
- }
- else
- {
- return invocation.dispatch();
- }
- }
-
- // Protected overrides -------------------------------------------
-
- // Override the following methods to add behaviour. Remember
- // to call invokeNext() if you want the call to proceed.
-
- protected Object init(Invocation invocation, DeploymentInfo di) throws Throwable
- {
- return invokeNext(invocation);
- }
-
- protected Object create(Invocation invocation, DeploymentInfo di) throws Throwable
- {
- return invokeNext(invocation);
- }
-
- protected Object start(Invocation invocation, DeploymentInfo di) throws Throwable
- {
- return invokeNext(invocation);
- }
-
- protected Object stop(Invocation invocation, DeploymentInfo di) throws Throwable
- {
- return invokeNext(invocation);
- }
-
- protected Object destroy(Invocation invocation, DeploymentInfo di) throws Throwable
- {
- return invokeNext(invocation);
- }
-
-}
\ No newline at end of file
Deleted: branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/SubDeployerInterceptorMBean.java
===================================================================
--- branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/SubDeployerInterceptorMBean.java 2006-08-04 16:27:06 UTC (rev 55202)
+++ branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/SubDeployerInterceptorMBean.java 2006-08-04 16:40:12 UTC (rev 55203)
@@ -1,38 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.deployment;
-
-import org.jboss.system.InterceptorServiceMBean;
-
-/**
- * Interface for SubDeployerInterceptor services.
- *
- * Empty since we inherit the Interceptable
- * settings from InterceptorServiceMBean.
- *
- * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
- * @version $Revision$
- */
-public interface SubDeployerInterceptorMBean extends InterceptorServiceMBean
-{
- // Empty
-}
Deleted: branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/SubDeployerInterceptorSupport.java
===================================================================
--- branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/SubDeployerInterceptorSupport.java 2006-08-04 16:27:06 UTC (rev 55202)
+++ branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/SubDeployerInterceptorSupport.java 2006-08-04 16:40:12 UTC (rev 55203)
@@ -1,220 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.deployment;
-
-import org.jboss.logging.Logger;
-import org.jboss.mx.server.Invocation;
-import org.jboss.system.InterceptorServiceMBeanSupport;
-
-/**
- * Base class that can be used for writing services
- * that dynamically hook to other interceptable deployers
- * in order to add functionality in the deployment cycle.
- *
- * We override attach() to install a different interceptor
- * from that of the base class that understands SubDeployer
- * calls. Note that the baseclass invoke(Invocation) won't be
- * called, so no need to override it.
- *
- * Simply call attach()/detach() from createService()/destroyService()
- * or startService()/stopService() pair methods to attach/detach the
- * interceptor to the configured Interceptable SubDeployer(s).
- * Then override any of the init/create/start/stop/destroy methods to
- * apply the extra interception functionality. Inside those methods
- * don't forget to forward the call using invokeNext().
- *
- * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
- * @version $Revision$
- */
-public abstract class SubDeployerInterceptorSupport extends InterceptorServiceMBeanSupport
- implements SubDeployerInterceptorMBean
-{
-
- // Constructors -------------------------------------------------
-
- /**
- * Constructs an <tt>SubDeployerInterceptorSupport</tt>.
- */
- public SubDeployerInterceptorSupport()
- {
- super();
- }
-
- /**
- * Constructs an <tt>SubDeployerInterceptorSupport</tt>.
- *
- * Pass-through to InterceptorServiceMBeanSupport.
- *
- * @param type The class type to determine Logger name from.
- */
- public SubDeployerInterceptorSupport(final Class type)
- {
- super(type);
- }
-
- /**
- * Constructs an <tt>SubDeployerInterceptorSupport</tt>.
- *
- * Pass-through to InterceptorServiceMBeanSupport.
- *
- * @param category The logger category name.
- */
- public SubDeployerInterceptorSupport(final String category)
- {
- super(category);
- }
-
- /**
- * Constructs an <tt>SubDeployerInterceptorSupport</tt>.
- *
- * Pass-through to InterceptorServiceMBeanSupport.
- *
- * @param log The logger to use.
- */
- public SubDeployerInterceptorSupport(final Logger log)
- {
- super(log);
- }
-
- // Protected API -------------------------------------------------
-
- /**
- * We override attach() from InterceptorServiceMBeanSupport
- * to attach a different interceptor that knows how to switch
- * init/create/start/stop/destroy SubDeployer calls.
- *
- * @throws Exception thrown on any interceptor registration error
- */
- protected void attach() throws Exception
- {
- super.attach(new XMBeanInterceptor());
- }
-
- // Override ------------------------------------------------------
-
- /**
- * Override
- */
- protected Object init(Invocation invocation, DeploymentInfo di) throws Throwable
- {
- return invokeNext(invocation);
- }
-
- /**
- * Override
- */
- protected Object create(Invocation invocation, DeploymentInfo di) throws Throwable
- {
- return invokeNext(invocation);
- }
-
- /**
- * Override
- */
- protected Object start(Invocation invocation, DeploymentInfo di) throws Throwable
- {
- return invokeNext(invocation);
- }
-
- /**
- * Override
- */
- protected Object stop(Invocation invocation, DeploymentInfo di) throws Throwable
- {
- return invokeNext(invocation);
- }
-
- /**
- * Override
- */
- protected Object destroy(Invocation invocation, DeploymentInfo di) throws Throwable
- {
- return invokeNext(invocation);
- }
-
- // Private Inner Class -------------------------------------------
-
- /**
- * Simple SubDeployerInterceptor delegating to
- * the SubDeployerInterceptorSupport callbacks
- */
- private class XMBeanInterceptor extends SubDeployerInterceptor
- {
- public XMBeanInterceptor()
- {
- super("XMBeanInterceptor('" + SubDeployerInterceptorSupport.this.getServiceName() + "')");
- }
-
- protected Object init(Invocation invocation, DeploymentInfo di) throws Throwable
- {
- logSubDeployerInvocation(invocation, di);
-
- // delegate
- return SubDeployerInterceptorSupport.this.init(invocation, di);
- }
-
- protected Object create(Invocation invocation, DeploymentInfo di) throws Throwable
- {
- logSubDeployerInvocation(invocation, di);
-
- // delegate
- return SubDeployerInterceptorSupport.this.create(invocation, di);
- }
-
- protected Object start(Invocation invocation, DeploymentInfo di) throws Throwable
- {
- logSubDeployerInvocation(invocation, di);
-
- // delegate
- return SubDeployerInterceptorSupport.this.start(invocation, di);
- }
-
- protected Object stop(Invocation invocation, DeploymentInfo di) throws Throwable
- {
- logSubDeployerInvocation(invocation, di);
-
- // delegate
- return SubDeployerInterceptorSupport.this.stop(invocation, di);
- }
-
- protected Object destroy(Invocation invocation, DeploymentInfo di) throws Throwable
- {
- logSubDeployerInvocation(invocation, di);
-
- // delegate
- return SubDeployerInterceptorSupport.this.destroy(invocation, di);
- }
-
- protected void logSubDeployerInvocation(Invocation invocation, DeploymentInfo di)
- {
- if (SubDeployerInterceptorSupport.this.log.isTraceEnabled())
- {
- StringBuffer sbuf = new StringBuffer();
- sbuf.append("intercepting ").append(invocation.getName())
- .append("(), url=").append(di.url.toString())
- .append(", state=").append(di.state.toString());
-
- SubDeployerInterceptorSupport.this.log.trace(sbuf.toString());
- }
- }
- }
-}
Deleted: branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/SubDeployerMBean.java
===================================================================
--- branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/SubDeployerMBean.java 2006-08-04 16:27:06 UTC (rev 55202)
+++ branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/SubDeployerMBean.java 2006-08-04 16:40:12 UTC (rev 55203)
@@ -1,105 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.deployment;
-
-import javax.management.ObjectName;
-
-import org.jboss.system.ServiceMBean;
-
-/**
- * MBean interface for SubDeployers
- *
- * @version <tt>$Revision$</tt>
- */
-public interface SubDeployerMBean extends ServiceMBean
-{
- // Attributes ----------------------------------------------------
-
- /**
- * Get the JMX ObjectName of the service that provides the SubDeployer
- * @return JMX ObjectName of the service
- */
- ObjectName getServiceName();
-
- /**
- * Get an array of suffixes of interest to this subdeployer
- * @return array of suffix strings
- */
- String[] getSuffixes();
-
- /**
- * Get the relative order of the specified suffixes
- * @return the relative order of the specified suffixes
- */
- int getRelativeOrder();
-
- // Operations ----------------------------------------------------
-
- /**
- * The <code>accepts</code> method is called by MainDeployer
- * to determine which deployer is suitable for a DeploymentInfo.
- * @param sdi a <code>DeploymentInfo</code> value
- * @return a <code>boolean</code> value
- */
- boolean accepts(DeploymentInfo sdi);
-
- /**
- * The <code>init</code> method lets the deployer set a few
- * properties of the DeploymentInfo, such as the watch url.
- * @param sdi a <code>DeploymentInfo</code> value
- * @throws DeploymentException if an error occurs
- */
- void init(DeploymentInfo sdi) throws DeploymentException;
-
- /**
- * Set up the components of the deployment that do not
- * refer to other components.
- * @param sdi a <code>DeploymentInfo</code> value
- * @throws DeploymentException if an error occurs
- */
- void create(DeploymentInfo sdi) throws DeploymentException;
-
- /**
- * The <code>start</code> method sets up relationships
- * with other components.
- * @param sdi a <code>DeploymentInfo</code> value
- * @throws DeploymentException if an error occurs
- */
- void start(DeploymentInfo sdi) throws DeploymentException;
-
- /**
- * The <code>stop</code> method removes relationships
- * between components.
- * @param sdi a <code>DeploymentInfo</code> value
- * @throws DeploymentException if an error occurs
- */
- void stop(DeploymentInfo sdi) throws DeploymentException;
-
- /**
- * The <code>destroy</code> method removes individual
- * components
- * @param sdi a <code>DeploymentInfo</code> value
- * @throws DeploymentException if an error occurs
- */
- void destroy(DeploymentInfo sdi) throws DeploymentException;
-
-}
Deleted: branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/SubDeployerSupport.java
===================================================================
--- branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/SubDeployerSupport.java 2006-08-04 16:27:06 UTC (rev 55202)
+++ branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/SubDeployerSupport.java 2006-08-04 16:40:12 UTC (rev 55203)
@@ -1,618 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.deployment;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Enumeration;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
-
-import javax.management.Notification;
-
-import org.jboss.mx.util.MBeanProxyExt;
-import org.jboss.system.ServiceMBeanSupport;
-import org.jboss.system.server.ServerConfig;
-import org.jboss.system.server.ServerConfigLocator;
-import org.jboss.system.server.ServerConfigUtil;
-import org.jboss.util.file.JarUtils;
-import org.jboss.util.stream.Streams;
-
-/**
- * An abstract {@link SubDeployer}.
- *
- * Provides registration with {@link MainDeployer} as well as
- * implementations of init, create, start, stop and destroy that
- * generate JMX notifications on completion of the method.
- *
- * @version <tt>$Revision$</tt>
- * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
- * @author <a href="mailto:scott.stark at jboss.org">Scott Stark</a>
- * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
- */
-public abstract class SubDeployerSupport extends ServiceMBeanSupport
- implements SubDeployerExt, SubDeployerExtMBean
-{
- /**
- * Holds the native library <em>suffix</em> for this system.
- *
- * Determined by examining the result of System.mapLibraryName(specialToken).
- * The special token defaults to "XxX", but can be changed by setting the
- * system property: <tt>org.jboss.deployment.SubDeployerSupport.nativeLibToken</tt>.
- */
- protected static final String nativeSuffix;
-
- /**
- * Holds the native library <em>prefix</em> for this system.
- *
- * @see #nativeSuffix
- */
- protected static final String nativePrefix;
-
- /** A proxy to the MainDeployer. */
- protected MainDeployerMBean mainDeployer;
-
- /** The temporary directory into which deployments are unpacked */
- protected File tempDeployDir;
-
- /** The list of enhancedSuffixes for this subdeployer */
- protected String[] enhancedSuffixes;
-
- /** The suffixes of interest to this subdeployer */
- protected String[] suffixes;
-
- /** The relative order of this subdeployer - not really used */
- protected int relativeOrder = -1;
-
- /** The temporary directory where native libs are unpacked. */
- private File tempNativeDir;
-
- /** Whether to load native libraries */
- private boolean loadNative = false;
-
- /**
- * The <code>createService</code> method is one of the ServiceMBean lifecyle operations.
- * (no jmx tag needed from superinterface)
- *
- * @exception Exception if an error occurs
- */
- protected void createService() throws Exception
- {
- // get the temporary directories to use
- ServerConfig config = ServerConfigLocator.locate();
- tempNativeDir = config.getServerNativeDir();
- tempDeployDir = config.getServerTempDeployDir();
- loadNative = ServerConfigUtil.isLoadNative();
-
- // Setup the proxy to mainDeployer
- mainDeployer = (MainDeployerMBean)
- MBeanProxyExt.create(MainDeployerMBean.class,
- MainDeployerMBean.OBJECT_NAME,
- server);
- }
-
- /**
- * Performs SubDeployer registration.
- */
- protected void startService() throws Exception
- {
- // Register with the main deployer
- mainDeployer.addDeployer(this);
- }
-
- /**
- * Performs SubDeployer deregistration.
- */
- protected void stopService() throws Exception
- {
- // Unregister with the main deployer
- mainDeployer.removeDeployer(this);
- }
-
- /**
- * Clean up.
- */
- protected void destroyService() throws Exception
- {
- // Help the GC
- mainDeployer = null;
- tempNativeDir = null;
- }
-
- /**
- * Set an array of suffixes of interest to this subdeployer.
- * No need to register twice suffixes that may refer to
- * unpacked deployments (e.g. .sar, .sar/).
- *
- * @param suffixes array of suffix strings
- */
- protected void setSuffixes(String[] suffixes)
- {
- this.suffixes = suffixes;
- }
-
- /**
- * Set the relative order of the specified suffixes
- * all to the same value.
- *
- * @param relativeOrder the relative order of the specified suffixes
- */
- protected void setRelativeOrder(int relativeOrder)
- {
- this.relativeOrder = relativeOrder;
- }
-
- /**
- * Set the enhanced suffixes list for this deployer,
- * causing also the supported suffixes list to be updated.
- *
- * Each enhanced suffix entries has the form:
- *
- * [order:]suffix
- *
- * No need to register twice suffixes that may refer to
- * unpacked deployments (e.g. .sar, .sar/).
- *
- * @param enhancedSuffixes
- */
- public void setEnhancedSuffixes(String[] enhancedSuffixes)
- {
- if (enhancedSuffixes != null)
- {
- int len = enhancedSuffixes.length;
- suffixes = new String[len];
-
- for (int i = 0; i < len; i++)
- {
- // parse each enhancedSuffix
- SuffixOrderHelper.EnhancedSuffix e =
- new SuffixOrderHelper.EnhancedSuffix(enhancedSuffixes[i]);
-
- suffixes[i] = e.suffix;
- }
- }
- this.enhancedSuffixes = enhancedSuffixes;
- }
-
- /**
- * Get an array of enhancedSuffixes
- *
- * @return array of enhanced suffix strings
- */
- public String[] getEnhancedSuffixes()
- {
- return enhancedSuffixes;
- }
-
- /**
- * Get an array of suffixes of interest to this subdeployer
- *
- * @return array of suffix strings
- */
- public String[] getSuffixes()
- {
- return suffixes;
- }
-
- /**
- * Get the relative order of the specified suffixes
- *
- * @return the relative order of the specified suffixes
- */
- public int getRelativeOrder()
- {
- return relativeOrder;
- }
-
- /**
- * A default implementation that uses the suffixes registered
- * through either setSuffixes() or setEnhancedSuffixes(), to
- * decide if a module is deployable by this deployer.
- *
- * If (according to DeploymentInfo) the deployment refers to
- * a directory, but not an xml or script deployment, then
- * the deployment suffix will be checked also against the
- * registered suffixes + "/".
- *
- * @param sdi the DeploymentInfo to check
- * @return whether the deployer can handle the deployment
- */
- public boolean accepts(DeploymentInfo sdi)
- {
- String[] acceptedSuffixes = getSuffixes();
- if (acceptedSuffixes == null)
- {
- return false;
- }
- else
- {
- String urlPath = sdi.url.getPath();
- String shortName = sdi.shortName;
- boolean checkDir = sdi.isDirectory && !(sdi.isXML || sdi.isScript);
-
- for (int i = 0; i < acceptedSuffixes.length; i++)
- {
- // First check the urlPath the might end in "/"
- // then check the shortName where "/" is removed
- if (urlPath.endsWith(acceptedSuffixes[i]) ||
- (checkDir && shortName.endsWith(acceptedSuffixes[i])))
- {
- return true;
- }
- }
- return false;
- }
- }
-
- /**
- * Sub-classes should override this method to provide
- * custom 'init' logic.
- *
- * <p>This method calls the processNestedDeployments(di) method and then
- * issues a JMX notification of type SubDeployer.INIT_NOTIFICATION.
- * This behaviour can overridden by concrete sub-classes. If further
- * initialization needs to be done, and you wish to preserve the
- * functionality, be sure to call super.init(di) at the end of your
- * implementation.
- */
- public void init(DeploymentInfo di) throws DeploymentException
- {
- processNestedDeployments(di);
-
- emitNotification(SubDeployer.INIT_NOTIFICATION, di);
- }
-
- /**
- * Sub-classes should override this method to provide
- * custom 'create' logic.
- *
- * This method issues a JMX notification of type SubDeployer.CREATE_NOTIFICATION.
- */
- public void create(DeploymentInfo di) throws DeploymentException
- {
- emitNotification(SubDeployer.CREATE_NOTIFICATION, di);
- }
-
- /**
- * Sub-classes should override this method to provide
- * custom 'start' logic.
- *
- * This method issues a JMX notification of type SubDeployer.START_NOTIFICATION.
- */
- public void start(DeploymentInfo di) throws DeploymentException
- {
- emitNotification(SubDeployer.START_NOTIFICATION, di);
- }
-
- /**
- * Sub-classes should override this method to provide
- * custom 'stop' logic.
- *
- * This method issues a JMX notification of type SubDeployer.START_NOTIFICATION.
- */
- public void stop(DeploymentInfo di) throws DeploymentException
- {
- emitNotification(SubDeployer.STOP_NOTIFICATION, di);
- }
-
- /**
- * Sub-classes should override this method to provide
- * custom 'destroy' logic.
- *
- * This method issues a JMX notification of type SubDeployer.DESTROY_NOTIFICATION.
- */
- public void destroy(DeploymentInfo di) throws DeploymentException
- {
- emitNotification(SubDeployer.DESTROY_NOTIFICATION, di);
- }
-
- /**
- * Simple helper to emit a subdeployer notification containing DeploymentInfo
- */
- protected void emitNotification(String type, DeploymentInfo di)
- {
- Notification notification = new Notification(type, this, getNextNotificationSequenceNumber());
- notification.setUserData(di);
- sendNotification(notification);
- }
-
- /**
- * The <code>processNestedDeployments</code> method searches for any nested and
- * deployable elements. Only Directories and Zipped archives are processed,
- * and those are delegated to the addDeployableFiles and addDeployableJar
- * methods respectively. This method can be overridden for alternate
- * behaviour.
- */
- protected void processNestedDeployments(DeploymentInfo di) throws DeploymentException
- {
- log.debug("looking for nested deployments in : " + di.url);
- if (di.isXML)
- {
- // no nested archives in an xml file
- return;
- }
-
- if (di.isDirectory)
- {
- File f = new File(di.url.getFile());
- if (!f.isDirectory())
- {
- // something is screwy
- throw new DeploymentException
- ("Deploy file incorrectly reported as a directory: " + di.url);
- }
-
- addDeployableFiles(di, f);
- }
- else
- {
- try
- {
- // Obtain a jar url for the nested jar
- URL nestedURL = JarUtils.extractNestedJar(di.localUrl, this.tempDeployDir);
- JarFile jarFile = new JarFile(nestedURL.getFile());
- addDeployableJar(di, jarFile);
- }
- catch (Exception e)
- {
- log.warn("Failed to add deployable jar: " + di.localUrl, e);
-
- //
- // jason: should probably throw new DeploymentException
- // ("Failed to add deployable jar: " + jarURLString, e);
- // rather than make assumptions to what type of deployable
- // file this was that failed...
- //
-
- return;
- }
- }
- }
-
- /**
- * This method returns true if the name is a recognized archive file.
- *
- * It will query the MainDeployer that keeps a dynamically updated
- * list of known archive extensions.
- *
- * @param name The "short-name" of the URL. It will have any trailing '/'
- * characters removed, and any directory structure has been removed.
- * @param url The full url.
- *
- * @return true iff the name ends in a known archive extension: .jar, .sar,
- * .ear, .rar, .zip, .wsr, .war, or if the name matches the native
- * library conventions.
- */
- protected boolean isDeployable(String name, URL url)
- {
- // any file under META-INF is not deployable; this method is called
- // also for zipped content, e.g. dir1/dir2.sar/META-INF/bla.xml
- if (url.getPath().indexOf("META-INF") != -1)
- {
- return false;
- }
- String[] acceptedSuffixes = mainDeployer.getSuffixOrder();
- for (int i = 0; i < acceptedSuffixes.length; i++)
- {
- if (name.endsWith(acceptedSuffixes[i]))
- {
- return true;
- }
- }
- // this is probably obsolete
- return (name.endsWith(nativeSuffix) && name.startsWith(nativePrefix));
- }
-
- /**
- * This method recursively searches the directory structure for any files
- * that are deployable (@see isDeployable). If a directory is found to
- * be deployable, then its subfiles and subdirectories are not searched.
- *
- * @param di the DeploymentInfo
- * @param dir The root directory to start searching.
- */
- protected void addDeployableFiles(DeploymentInfo di, File dir)
- throws DeploymentException
- {
- File[] files = dir.listFiles();
- for (int i = 0; i < files.length; i++)
- {
- File file = files[i];
- String name = file.getName();
- try
- {
- URL url = file.toURL();
- if (isDeployable(name, url))
- {
- deployUrl(di, url, name);
- // we don't want deployable units processed any further
- continue;
- }
- }
- catch (MalformedURLException e)
- {
- log.warn("File name invalid; ignoring: " + file, e);
- }
- if (file.isDirectory())
- {
- addDeployableFiles(di, file);
- }
- }
- }
-
- /**
- * This method searches the entire jar file for any deployable files
- * (@see isDeployable).
- *
- * @param di the DeploymentInfo
- * @param jarFile the jar file to process.
- */
- protected void addDeployableJar(DeploymentInfo di, JarFile jarFile)
- throws DeploymentException
- {
- String urlPrefix = "jar:"+di.localUrl.toString()+"!/";
- for (Enumeration e = jarFile.entries(); e.hasMoreElements();)
- {
- JarEntry entry = (JarEntry)e.nextElement();
- String name = entry.getName();
- try
- {
- URL url = new URL(urlPrefix+name);
- if (isDeployable(name, url))
- {
- // Obtain a jar url for the nested jar
- URL nestedURL = JarUtils.extractNestedJar(url, this.tempDeployDir);
- deployUrl(di, nestedURL, name);
- }
- }
- catch (MalformedURLException mue)
- {
- //
- // jason: why are we eating this exception?
- //
- log.warn("Jar entry invalid; ignoring: " + name, mue);
- }
- catch (IOException ex)
- {
- log.warn("Failed to extract nested jar; ignoring: " + name, ex);
- }
- }
- }
-
- protected void deployUrl(DeploymentInfo di, URL url, String name)
- throws DeploymentException
- {
- log.debug("nested deployment: " + url);
- try
- {
- //
- // jason: need better handling for os/arch specific libraries
- // should be able to have multipule native libs in an archive
- // one for each supported platform (os/arch), we only want to
- // load the one for the current platform.
- //
- // This probably means explitly listing the libraries in a
- // deployment descriptor, which could probably also be used
- // to explicitly map the files, as it might be possible to
- // share a native lib between more than one version, no need
- // to duplicate the file, metadata can be used to tell us
- // what needs to be done.
- //
- // Also need this mapping to get around the different values
- // which are used by vm vendors for os.arch and such...
- //
-
- if (name.endsWith(nativeSuffix) && name.startsWith(nativePrefix))
- {
- File destFile = new File(tempNativeDir, name);
- log.info("Loading native library: " + destFile.toString());
-
- File parent = destFile.getParentFile();
- if (!parent.exists()) {
- parent.mkdirs();
- }
-
- InputStream in = url.openStream();
- OutputStream out = new FileOutputStream(destFile);
- Streams.copyb(in, out);
-
- out.flush();
- out.close();
- in.close();
-
- if (loadNative)
- System.load(destFile.toString());
- }
- else
- {
- new DeploymentInfo(url, di, getServer());
- }
- }
- catch (Exception ex)
- {
- throw new DeploymentException
- ("Could not deploy sub deployment "+name+" of deployment "+di.url, ex);
- }
- }
-
- /////////////////////////////////////////////////////////////////////////
- // Class Property Configuration //
- /////////////////////////////////////////////////////////////////////////
-
- /**
- * Static configuration properties for this class. Allows easy access
- * to change defaults with system properties.
- */
- protected static class ClassConfiguration
- extends org.jboss.util.property.PropertyContainer
- {
- private String nativeLibToken = "XxX";
-
- public ClassConfiguration()
- {
- // properties will be settable under our enclosing classes group
- super(SubDeployerSupport.class);
-
- // bind the properties & the access methods
- bindMethod("nativeLibToken");
- }
-
- public void setNativeLibToken(final String token)
- {
- this.nativeLibToken = token;
- }
-
- public String getNativeLibToken()
- {
- return nativeLibToken;
- }
- }
-
- /** The singleton class configuration object for this class. */
- protected static final ClassConfiguration CONFIGURATION = new ClassConfiguration();
-
- //
- // jason: the following needs to be done after setting up the
- // class config reference, so it is moved it down here.
- //
-
- /**
- * Determine the native library suffix and prefix.
- */
- static
- {
- // get the token to use from config, incase the default needs
- // to be changed to resolve problem with a specific platform
- String token = CONFIGURATION.getNativeLibToken();
-
- // then determine what the prefix and suffixes are for this platform
- String nativex = System.mapLibraryName(token);
- int xPos = nativex.indexOf(token);
- nativePrefix = nativex.substring(0, xPos);
- nativeSuffix = nativex.substring(xPos + 3);
- }
-}
Deleted: branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/SuffixOrderHelper.java
===================================================================
--- branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/SuffixOrderHelper.java 2006-08-04 16:27:06 UTC (rev 55202)
+++ branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/SuffixOrderHelper.java 2006-08-04 16:40:12 UTC (rev 55203)
@@ -1,459 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.deployment;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.StringTokenizer;
-
-import org.jboss.logging.Logger;
-
-/**
- * SuffixOrderHelper.
- *
- * This class wraps the SuffixOrder and EnhandedSuffixes attributes
- * of MainDeployer.
- *
- * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
- * @version $Revision$
- */
-public final class SuffixOrderHelper
-{
- // Constants -----------------------------------------------------
-
- /**
- * Default EnhancedSuffixes
- *
- * Those values are indicative - we just know they'll work with
- * the compiled order of subdeployers like the aop or ejb3,
- * but any order can be set using the EnhancedSuffixes
- * attribute and/or the individual subdeployer's relative order.
- *
- * The commented out entries indicate those are dynamically
- * added by their respective subdeployers when they register.
- */
- public static final String[] DEFAULT_ENHANCED_SUFFIXES = {};
- /*
- Moved this list to org.jboss.deployment.MainDeployer-xmbean.xml
- so there are no hardcoded defaults.
- {
- //"050:.deployer",
- //"050:-deployer.xml",
- //"100:.aop",
- //"100:-aop.xml",
- //"150:.sar",
- //"150:-service.xml",
- //"200:.beans",
- "250:.rar",
- "300:-ds.xml",
- //"350:.har",
- "400:.jar", // ejb .jar
- //"450:.ejb3",
- //"450:.par",
- "500:.war", // don't comment out this!
- "600:.wsr",
- "650:.ear",
- //"700:.jar", // plain .jar
- //"750:.zip",
- "800:.bsh",
- "900:.last" // the JARDeployer really handles those?
- };
- */
-
- /** A default relative order just before 900:.last */
- public static final int DEFAULT_RELATIVE_ORDER = 850;
-
- /** The Logger */
- public static final Logger log = Logger.getLogger(SuffixOrderHelper.class);
-
- // Private Data --------------------------------------------------
-
- /** Wrapped DeploymentSorter that stores the value for SuffixOrder attribute */
- private final DeploymentSorter sorter;
-
- /** The actual value of EnhancedSuffixes attribute */
- private String[] enhancedSuffixes;
-
- /** List of sorted EnhancedSuffix instances */
- private List suffixes;
-
- /** Set of static String suffixes that cannot be overriden/removed */
- private Set staticSuffixes;
-
- // Constructor ---------------------------------------------------
-
- public SuffixOrderHelper(DeploymentSorter sorter)
- {
- this.sorter = sorter;
- this.suffixes = new ArrayList();
- this.staticSuffixes = new HashSet();
- }
-
- // Accessors -----------------------------------------------------
-
- /**
- * Getter only for the SuffixOrder as known by the MainDeployer and the Scanners
- *
- * The value is updated during init() with suffixes that remain constant.
- * After that suffixes are added/removed using the corresponding methods.
- *
- * @return the SuffixOrder string array
- */
- public String[] getSuffixOrder()
- {
- return sorter.getSuffixOrder();
- }
-
- /**
- * Getter for the EnhancedSuffixes attribute
- *
- * @return the EnhancedSuffixes string array
- */
- public String[] getEnhancedSuffixes()
- {
- return enhancedSuffixes;
- }
-
- /**
- * Setter for the EnhancedSuffixes attribute
- *
- * @param enhancedSuffixes the EnhancedSuffixes string array
- */
- public void setEnhancedSuffixes(String[] enhancedSuffixes)
- {
- this.enhancedSuffixes = enhancedSuffixes;
- }
-
- /**
- * Initialise the SuffixOrder from EnhancedSuffixes.
- *
- * If no enchangedSuffixes is specified, DEFAULT_ENHANCED_SUFFIXES
- * will be used. Individual entries may contain an additional order
- * element of the form [order:]suffix, e.g. 100:.sar
- *
- * The suffixes specified during init, will remain constant,
- * i.e. they can't be overriden or removed.
- */
- public void initialize()
- {
- // if enhancedSuffixes not provided, use the default
- if (enhancedSuffixes == null)
- {
- enhancedSuffixes = DEFAULT_ENHANCED_SUFFIXES;
- }
-
- // reset, just in case we are called more than once
- suffixes.clear();
- staticSuffixes.clear();
-
- // add all enhanced suffixes; mark them as static, too.
- for (int i = 0; i < enhancedSuffixes.length; i++)
- {
- EnhancedSuffix es = new EnhancedSuffix(enhancedSuffixes[i]);
- addSuffix(es);
-
- // mark all initial entries as static!
- staticSuffixes.add(es.suffix);
- }
-
- // set the resulting SuffixOrder
- sorter.setSuffixOrder(produceSuffixOrder());
- }
-
- /**
- * Add the specified enhanced suffixes in the correct
- * position(s) and regenerate the SuffixOrder, if needed.
- *
- * A suffix that exists already and is marked as static
- * will be skipped. Otherwise, duplicate entries are allowed.
- */
- public void addEnhancedSuffixes(String [] enhancedSuffixes)
- {
- if (enhancedSuffixes != null)
- {
- // remember the initial size of the list
- int size = suffixes.size();
-
- // add all enhanced suffixes
- for (int i = 0; i < enhancedSuffixes.length; i++)
- {
- EnhancedSuffix es = new EnhancedSuffix(enhancedSuffixes[i]);
- addSuffix(es);
- }
- if (suffixes.size() > size)
- {
- // suffixes were added, recreate the resulting SuffixOrder
- sorter.setSuffixOrder(produceSuffixOrder());
- }
- }
- }
-
- /**
- * Insert the specified suffixes in the correct position
- * and regenerate the SuffixOrder array, if needed.
- *
- * A suffix that exists already and is marked as static
- * will be skipped. Otherwise, duplicate entries are allowed.
- */
- public void addSuffixes(String[] suffixes, int relativeOrder)
- {
- if (suffixes != null)
- {
- // remember the initial size of the list
- int size = this.suffixes.size();
-
- for (int i = 0; i < suffixes.length; i++)
- {
- addSuffix(new EnhancedSuffix(suffixes[i], relativeOrder));
- }
-
- if (this.suffixes.size() > size)
- {
- // suffixes were added, recreate the resulting SuffixOrder
- sorter.setSuffixOrder(produceSuffixOrder());
- }
- }
- }
-
- /**
- * Remove the enhanced suffixes if they are not marked as static
- * and regenerate the SuffixOrder, if needed.
- */
- public void removeEnhancedSuffixes(String[] enhancedSuffixes)
- {
- if (enhancedSuffixes != null)
- {
- // remember the initial size of the list
- int size = suffixes.size();
-
- for (int i = 0; i < enhancedSuffixes.length; i++)
- {
- EnhancedSuffix es = new EnhancedSuffix(enhancedSuffixes[i]);
-
- // if this is a static suffix, don't remove
- if (staticSuffixes.contains(es.suffix))
- {
- continue;
- }
- else
- {
- // remove if exists
- suffixes.remove(es);
- }
- }
-
- if (this.suffixes.size() < size)
- {
- // entries removed, recreate the resulting SuffixOrder
- sorter.setSuffixOrder(produceSuffixOrder());
- }
- }
- }
-
- /**
- * Remove the specified suffixes if they are not marked as static
- * and regenerate the SuffixOrder, if needed.
- */
- public void removeSuffixes(String[] suffixes, int relativeOrder)
- {
- if (suffixes != null)
- {
- // remember the initial size of the list
- int size = this.suffixes.size();
-
- for (int i = 0; i < suffixes.length; i++)
- {
- // if this is a static suffix, don't remove
- if (staticSuffixes.contains(suffixes[i]))
- {
- continue;
- }
- else
- {
- // remove if exists
- this.suffixes.remove(new EnhancedSuffix(suffixes[i], relativeOrder));
- }
- }
-
- if (this.suffixes.size() < size)
- {
- // entries removed, recreate the resulting SuffixOrder
- sorter.setSuffixOrder(produceSuffixOrder());
- }
- }
- }
-
- // Private -------------------------------------------------------
-
- /**
- * Produce the SuffixOrder from the sorted suffixes ArrayList
- */
- private String[] produceSuffixOrder()
- {
- String[] suffixOrder = new String[suffixes.size()];
-
- for (int i = 0; i < suffixes.size(); i++)
- {
- suffixOrder[i] = ((EnhancedSuffix)suffixes.get(i)).suffix;
- }
- return suffixOrder;
- }
-
- /**
- * Add an EnhancedSuffix at the correct position in the sorted List.
- *
- * Sorting is based on EnhancedSuffix.order. A new entry with an equal
- * order value to an existing entry is placed AFTER the existing entry.
- *
- * If EnhancedSuffix.suffix exists in the staticSuffixes Set the entry
- * is NOT added. Otherwise, they EnhancedSuffix will be added, even
- * if it is a duplicate of an existing one.
- *
- * @param enhancedsuffix the enhanced suffix
- */
- private void addSuffix(EnhancedSuffix enhancedSuffix)
- {
- // if this is a static suffix, don't add it
- if (staticSuffixes.contains(enhancedSuffix.suffix))
- {
- log.debug("Static suffix exists; ignoring request for adding enhanced suffix: " + enhancedSuffix);
- }
- else
- {
- int size = suffixes.size();
-
- // if List empty, just add the suffix
- if (size == 0)
- {
- suffixes.add(enhancedSuffix);
- }
- else
- {
- // insertion sort starting from the last element
- for (int i = size - 1; i > -1; i--)
- {
- EnhancedSuffix entry = (EnhancedSuffix)suffixes.get(i);
- if (enhancedSuffix.order >= entry.order)
- {
- // add the suffix AFTER the entry and stop
- suffixes.add(i + 1, enhancedSuffix);
- break;
- }
- else if (i == 0)
- {
- // reached the beginning so add the suffix right there
- suffixes.add(0, enhancedSuffix);
- }
- }
- }
- }
- }
-
- /**
- * Inner class that encapsulates an enhanceSuffix
- * consisting of suffix + order
- */
- public final static class EnhancedSuffix
- {
- /** The suffix, e.g. .sar */
- public String suffix;
-
- /** The order, by convention a 3 digit number, e.g. 100 */
- public int order;
-
- /**
- * Simple CTOR
- */
- public EnhancedSuffix(String suffix, int order)
- {
- this.suffix = suffix;
- this.order = order;
- }
-
- /**
- * CTOR that parses an enhancedSuffix string of the form: [order:]suffix
- * If the optional 'order' is missing, use DEFAULT_RELATIVE_ORDER
- */
- public EnhancedSuffix(String enhancedSuffix) throws IllegalArgumentException
- {
- StringTokenizer tokenizer = new StringTokenizer(enhancedSuffix, ":");
- int tokens = tokenizer.countTokens();
-
- switch (tokens)
- {
- case 1:
- this.order = DEFAULT_RELATIVE_ORDER;
- this.suffix = enhancedSuffix;
- break;
-
- case 2:
- this.order = Integer.parseInt(tokenizer.nextToken());
- this.suffix = tokenizer.nextToken();
- break;
-
- default:
- throw new IllegalArgumentException("Cannot parse enhancedSuffix: " + enhancedSuffix);
- }
- }
-
- /**
- * Override equals to allow EnhancedSuffix to be searchable
- * using ArrayList.indexOf()/ArrayList.lastIndexOf()
- *
- * Base equality on both suffix and order
- */
- public boolean equals(Object other)
- {
- if (other == this)
- return true;
-
- if (!(other instanceof EnhancedSuffix))
- return false;
-
- EnhancedSuffix that = (EnhancedSuffix)other;
-
- // suffix shouldn't be null
- return this.suffix.equals(that.suffix) && this.order == that.order;
- }
-
- /**
- * Use both fields
- */
- public int hashCode()
- {
- int result = 17;
- result = 37 * result + suffix.hashCode();
- result = 37 * result + order;
- return result;
- }
-
- /**
- * Pretty print
- */
- public String toString()
- {
- return order + ":" + suffix;
- }
- }
-}
Deleted: branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/XSLSubDeployer.java
===================================================================
--- branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/XSLSubDeployer.java 2006-08-04 16:27:06 UTC (rev 55202)
+++ branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/XSLSubDeployer.java 2006-08-04 16:40:12 UTC (rev 55203)
@@ -1,242 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.deployment;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import javax.management.ObjectName;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.Source;
-import javax.xml.transform.Templates;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMResult;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamSource;
-
-import org.jboss.mx.util.MBeanProxyExt;
-import org.jboss.system.server.ServerConfigUtil;
-import org.jboss.util.xml.DOMWriter;
-import org.jboss.util.xml.JBossEntityResolver;
-import org.jboss.util.xml.JBossErrorHandler;
-import org.w3c.dom.Document;
-import org.xml.sax.SAXException;
-
-/**
- * XSLSubDeployer
- *
- * @author <a href="mailto:d_jencks at users.sourceforge.net">David Jencks</a>
- * @author <a href="mailto:juha at jboss.org">Juha Lindfors</a>
- * @author <a href="mailto:adrian at jboss.org">Adrian Brock</a>
- * @version <tt>$Revision$</tt>
- */
-public class XSLSubDeployer extends SubDeployerSupport implements XSLSubDeployerMBean
-{
- protected String xslUrl;
-
- protected String packageSuffix;
-
- protected String ddSuffix;
-
- protected DocumentBuilderFactory dbf;
-
- private Templates templates;
-
- protected ObjectName delegateName = SARDeployerMBean.OBJECT_NAME;
-
- protected SubDeployer delegate;
-
- /** A flag indicating if deployment descriptors should be validated */
- private boolean validateDTDs;
-
- public XSLSubDeployer()
- {
-
- }
-
- public void setXslUrl(final String xslUrl)
- {
- this.xslUrl = xslUrl;
- }
-
- public String getXslUrl()
- {
- return xslUrl;
- }
-
- public void setPackageSuffix(final String packageSuffix)
- {
- this.packageSuffix = packageSuffix;
- }
-
- public String getPackageSuffix()
- {
- return packageSuffix;
- }
-
- public void setDdSuffix(final String ddSuffix)
- {
- this.ddSuffix = ddSuffix;
- }
-
- public String getDdSuffix()
- {
- return ddSuffix;
- }
-
- public void setDelegateName(final ObjectName delegateName)
- {
- this.delegateName = delegateName;
- }
-
- public ObjectName getDelegateName()
- {
- return delegateName;
- }
- public boolean getValidateDTDs()
- {
- return validateDTDs;
- }
-
- public void setValidateDTDs(boolean validate)
- {
- this.validateDTDs = validate;
- }
-
- protected void createService() throws Exception
- {
- super.createService();
- delegate = (SubDeployer) MBeanProxyExt.create(SubDeployer.class, delegateName, server);
-
- TransformerFactory tf = TransformerFactory.newInstance();
- dbf = DocumentBuilderFactory.newInstance();
- dbf.setNamespaceAware(true);
- dbf.setValidating(validateDTDs);
-
- InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(xslUrl);
- StreamSource ss = new StreamSource(is);
- templates = tf.newTemplates(ss);
- log.debug("Created templates: " + templates);
- }
-
- protected void destroyService() throws Exception
- {
- templates = null;
- super.destroyService();
- }
-
- public boolean accepts(DeploymentInfo di)
- {
- String urlStr = di.url.toString();
- return (packageSuffix != null && (urlStr.endsWith(packageSuffix) || urlStr.endsWith(packageSuffix + "/")))
- || (ddSuffix != null && urlStr.endsWith(ddSuffix));
- }
-
- public void init(DeploymentInfo di) throws DeploymentException
- {
- if (di.document == null)
- findDd(di);
-
- try
- {
- Transformer trans = templates.newTransformer();
- String urlStr = di.url.toString();
- String shortURL = ServerConfigUtil.shortUrlFromServerHome(urlStr);
- trans.setErrorListener(new JBossErrorHandler(shortURL, null));
- Source s = new DOMSource(di.document);
- DOMResult r = new DOMResult();
- setParameters(trans);
-
- trans.transform(s, r);
-
- di.document = (Document) r.getNode();
- log.debug("transformed into doc: " + di.document);
- if (log.isDebugEnabled())
- {
- String docStr = DOMWriter.printNode(di.document, true);
- log.debug("transformed into doc: " + docStr);
- }
- }
- catch (TransformerException ce)
- {
- throw new DeploymentException("Problem with xsl transformation", ce);
- }
- delegate.init(di);
- }
-
- public void create(DeploymentInfo di) throws DeploymentException
- {
- delegate.create(di);
- }
-
- public void start(DeploymentInfo di) throws DeploymentException
- {
- delegate.start(di);
- }
-
- public void stop(DeploymentInfo di) throws DeploymentException
- {
- delegate.stop(di);
- }
-
- public void destroy(DeploymentInfo di) throws DeploymentException
- {
- delegate.destroy(di);
- }
-
- protected void setParameters(Transformer trans) throws TransformerException
- {
- //override to set document names etc.
- }
-
- protected void findDd(DeploymentInfo di) throws DeploymentException
- {
- try
- {
- DocumentBuilder db = dbf.newDocumentBuilder();
- String urlStr = di.url.toString();
- String shortURL = ServerConfigUtil.shortUrlFromServerHome(urlStr);
- JBossEntityResolver resolver = new JBossEntityResolver();
- db.setEntityResolver(resolver);
- db.setErrorHandler(new JBossErrorHandler(shortURL, resolver));
-
- if (ddSuffix != null && urlStr.endsWith(ddSuffix))
- di.document = db.parse(di.url.openStream());
- }
- catch (SAXException se)
- {
- throw new DeploymentException("Could not parse dd", se);
- }
- catch (IOException ioe)
- {
- throw new DeploymentException("Could not read dd", ioe);
- }
- catch (ParserConfigurationException pce)
- {
- throw new DeploymentException("Could not create document builder for dd", pce);
- }
- }
-}
Deleted: branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/XSLSubDeployerMBean.java
===================================================================
--- branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/XSLSubDeployerMBean.java 2006-08-04 16:27:06 UTC (rev 55202)
+++ branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/XSLSubDeployerMBean.java 2006-08-04 16:40:12 UTC (rev 55203)
@@ -1,49 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.deployment;
-
-import javax.management.ObjectName;
-
-import org.jboss.mx.util.ObjectNameFactory;
-
-/**
- * MBean interface.
- */
-public interface XSLSubDeployerMBean extends SubDeployerExtMBean
-{
- public static final ObjectName OBJECT_NAME = ObjectNameFactory.create("jboss.system:service=XSLDeployer");
-
- void setXslUrl(String xslUrl);
- String getXslUrl();
-
- void setPackageSuffix(String packageSuffix);
- String getPackageSuffix();
-
- void setDdSuffix(String ddSuffix);
- String getDdSuffix();
-
- void setDelegateName(ObjectName delegateName);
- ObjectName getDelegateName();
-
- void setValidateDTDs(boolean validate);
- boolean getValidateDTDs();
-}
Deleted: branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/package.html
===================================================================
--- branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/package.html 2006-08-04 16:27:06 UTC (rev 55202)
+++ branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/package.html 2006-08-04 16:40:12 UTC (rev 55203)
@@ -1,41 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
- <head>
- <!-- $Id$ -->
- <!--
-
- JBoss: The OpenSource J2EE WebOS
-
- Distributable under LGPL license.
- See terms of license at gnu.org.
-
- -->
- </head>
-
- <body bgcolor="white">
- <p>Core deployment framework and services.
-
- <h2>Package Specification</h2>
- <ul>
- <li><a href="javascript: alert('not available')">Not Available</a>
- </ul>
-
- <h2>Related Documentation</h2>
- <ul>
- <li><a href="javascript: alert('not available')">Not Available</a>
- </ul>
-
- <h2>Package Status</h2>
- <ul>
- <li><font color="green"><b>STABLE</b></font>
- </ul>
-
- <h2>Todo</h2>
- <ul>
- <li>???
- </ul>
-
- <!-- Put @see and @since tags down here. -->
-
- </body>
-</html>
Deleted: branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/scanner/AbstractDeploymentScanner.java
===================================================================
--- branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/scanner/AbstractDeploymentScanner.java 2006-08-04 16:27:06 UTC (rev 55202)
+++ branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/scanner/AbstractDeploymentScanner.java 2006-08-04 16:40:12 UTC (rev 55203)
@@ -1,382 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.deployment.scanner;
-
-import javax.management.ObjectName;
-
-import org.jboss.deployment.Deployer;
-import org.jboss.deployment.MainDeployerMBean;
-import org.jboss.logging.Logger;
-import org.jboss.mx.util.MBeanProxyExt;
-import org.jboss.mx.util.MBeanProxyInstance;
-import org.jboss.system.MissingAttributeException;
-import org.jboss.system.ServiceMBeanSupport;
-import org.jboss.util.NullArgumentException;
-
-import EDU.oswego.cs.dl.util.concurrent.SynchronizedBoolean;
-
-/**
- * An abstract support class for implementing a deployment scanner.
- *
- * <p>Provides the implementation of period-based scanning, as well
- * as Deployer integration.
- *
- * <p>Sub-classes only need to implement {@link DeploymentScanner#scan}.
- *
- * @version <tt>$Revision$</tt>
- * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
- * @author Scott.Stark at jboss.org
- */
-public abstract class AbstractDeploymentScanner extends ServiceMBeanSupport
- implements DeploymentScanner, DeploymentScannerMBean
-{
- /** The scan period in milliseconds */
- protected long scanPeriod = 5000;
-
- /** True if period based scanning is enabled. */
- protected boolean scanEnabled = true;
-
- /** The stop timeout */
- protected long stopTimeOut = 60000;
-
- /** A proxy to the deployer we are using. */
- protected Deployer deployer;
-
- protected MainDeployerMBean mainDeployer;
-
- /** The scanner thread. */
- protected ScannerThread scannerThread;
-
- /** HACK: Shutdown hook to get around problems with system service shutdown ordering. */
- private Thread shutdownHook;
-
-
- /////////////////////////////////////////////////////////////////////////
- // DeploymentScanner //
- /////////////////////////////////////////////////////////////////////////
-
- public void setDeployer(final ObjectName deployerName)
- {
- if (deployerName == null)
- throw new NullArgumentException("deployerName");
-
- deployer = (Deployer)
- MBeanProxyExt.create(Deployer.class, deployerName, server);
- }
-
- public ObjectName getDeployer()
- {
- return ((MBeanProxyInstance)deployer).getMBeanProxyObjectName();
- }
-
- /**
- * Period must be >= 0.
- */
- public void setScanPeriod(final long period)
- {
- if (period < 0)
- throw new IllegalArgumentException("ScanPeriod must be >= 0; have: " + period);
-
- this.scanPeriod = period;
- }
-
- public long getScanPeriod()
- {
- return scanPeriod;
- }
-
- public void setScanEnabled(final boolean flag)
- {
- this.scanEnabled = flag;
- }
-
- public boolean isScanEnabled()
- {
- return scanEnabled;
- }
-
- public long getStopTimeOut()
- {
- return stopTimeOut;
- }
-
- public void setStopTimeOut(long stopTimeOut)
- {
- this.stopTimeOut = stopTimeOut;
- }
-
- /** This is here to work around a bug in the IBM vm that causes an
- * AbstractMethodError to be thrown when the ScannerThread calls scan.
- * @throws Exception
- */
- public abstract void scan() throws Exception;
-
- /////////////////////////////////////////////////////////////////////////
- // Scanner Thread //
- /////////////////////////////////////////////////////////////////////////
-
- /**
- * Should use Timer/TimerTask instead? This has some issues with
- * interaction with ScanEnabled attribute. ScanEnabled works only
- * when starting/stopping.
- */
- public class ScannerThread
- extends Thread
- {
- /** We get our own logger. */
- protected Logger scannerLog = Logger.getLogger(ScannerThread.class);
-
- /** True if the scan loop should run. */
- protected SynchronizedBoolean enabled = new SynchronizedBoolean(false);
-
- /** True if we are shutting down. */
- protected SynchronizedBoolean shuttingDown = new SynchronizedBoolean(false);
-
- /** Lock/notify object. */
- protected Object lock = new Object();
-
- /** Active synchronization. */
- protected SynchronizedBoolean active = new SynchronizedBoolean(false);
-
- public ScannerThread(boolean enabled)
- {
- super("ScannerThread");
-
- this.enabled.set(enabled);
- }
-
- public void setEnabled(boolean enabled)
- {
- this.enabled.set(enabled);
-
- synchronized (lock)
- {
- lock.notifyAll();
- }
-
- scannerLog.debug("Notified that enabled: " + enabled);
- }
-
- public void shutdown()
- {
- enabled.set(false);
- shuttingDown.set(true);
-
- synchronized (lock)
- {
- lock.notifyAll();
- }
-
- scannerLog.debug("Notified to shutdown");
-
- // jason: shall we also interrupt this thread?
- }
-
- public void run()
- {
- scannerLog.debug("Running");
-
- active.set(true);
- try
- {
- while (shuttingDown.get() == false)
- {
- // If we are not enabled, then wait
- if (enabled.get() == false)
- {
- synchronized (active)
- {
- active.set(false);
- active.notifyAll();
- }
- try
- {
- scannerLog.debug("Disabled, waiting for notification");
- synchronized (lock)
- {
- lock.wait();
- }
- }
- catch (InterruptedException ignore)
- {
- }
- active.set(true);
- }
-
- loop();
- }
- }
- finally
- {
- synchronized (active)
- {
- active.set(false);
- active.notifyAll();
- }
- }
-
- scannerLog.debug("Shutdown");
- }
-
- protected void waitForInactive()
- {
- boolean interrupted = false;
- synchronized (active)
- {
- try
- {
- if (active.get() && stopTimeOut > 0)
- active.wait(stopTimeOut);
- }
- catch (InterruptedException ignored)
- {
- interrupted = true;
- }
- }
- if (interrupted)
- Thread.currentThread().interrupt();
- }
-
- public void doScan()
- {
- // Scan for new/removed/changed/whatever
- try {
- scan();
- }
- catch (Exception e) {
- scannerLog.error("Scanning failed; continuing", e);
- }
- }
-
- protected void loop()
- {
- while (enabled.get() && shuttingDown.get() == false)
- {
- doScan();
-
- // Sleep for scan period
- try
- {
- scannerLog.trace("Sleeping...");
- Thread.sleep(scanPeriod);
- }
- catch (InterruptedException ignore) {}
- }
- }
- }
-
-
- /////////////////////////////////////////////////////////////////////////
- // Service/ServiceMBeanSupport //
- /////////////////////////////////////////////////////////////////////////
-
- protected void createService() throws Exception
- {
- if (deployer == null)
- throw new MissingAttributeException("Deployer");
- mainDeployer = (MainDeployerMBean)MBeanProxyExt.create(MainDeployerMBean.class, MainDeployerMBean.OBJECT_NAME, server);
- // setup + start scanner thread
- scannerThread = new ScannerThread(false);
- scannerThread.setDaemon(true);
- scannerThread.start();
- log.debug("Scanner thread started");
-
- // HACK
- //
- // install a shutdown hook, as the current system service shutdown
- // mechanism will not call this until all other services have stopped.
- // we need to know soon, so we can stop scanning to try to avoid
- // starting new services when shutting down
-
- final ScannerThread _scannerThread = scannerThread;
- shutdownHook = new Thread("DeploymentScanner Shutdown Hook")
- {
- ScannerThread thread = _scannerThread;
-
- public void run()
- {
- thread.shutdown();
- }
- };
-
- try
- {
- Runtime.getRuntime().addShutdownHook(shutdownHook);
- }
- catch (Exception e)
- {
- log.warn("Failed to add shutdown hook", e);
- }
- }
-
- protected void startService() throws Exception
- {
- synchronized( scannerThread )
- {
- // scan before we enable the thread, so JBoss version shows up afterwards
- scannerThread.doScan();
-
- // enable scanner thread if we are enabled
- scannerThread.setEnabled(scanEnabled);
- }
- }
-
- protected void stopService() throws Exception
- {
- // disable scanner thread
- if( scannerThread != null )
- {
- scannerThread.setEnabled(false);
- scannerThread.waitForInactive();
- }
- }
-
- protected void destroyService() throws Exception
- {
- // drop our ref to deployer, so scan will fail
- deployer = null;
-
- // shutdown scanner thread
- if( scannerThread != null )
- {
- synchronized( scannerThread )
- {
- scannerThread.shutdown();
- }
- }
-
- // HACK
- //
- // remove the shutdown hook, we don't need it anymore
- try
- {
- Runtime.getRuntime().removeShutdownHook(shutdownHook);
- }
- catch (Exception ignore)
- {
- } // who cares really
-
- // help gc
- shutdownHook = null;
- scannerThread = null;
- }
-}
Deleted: branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/scanner/AlphaNumericDeploymentSorter.java
===================================================================
--- branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/scanner/AlphaNumericDeploymentSorter.java 2006-08-04 16:27:06 UTC (rev 55202)
+++ branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/scanner/AlphaNumericDeploymentSorter.java 2006-08-04 16:40:12 UTC (rev 55203)
@@ -1,137 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.deployment.scanner;
-
-import org.jboss.deployment.DefaultDeploymentSorter;
-
-import java.util.Comparator;
-import java.net.URL;
-
-/**
- * This is simialr to the PrefixDeploymentSorter in that it will order
- * files that do not start with a numeric value before those that do.
- * If two files begin with a number, will compare the numeric values.
- * However, if the two files do not have numeric prefixes, will
- * compare them using compareToIgnoreCase.
- *
- * @author <a href="mailto:tom at jboss.org">Tom Elrod</a>
- */
-public class AlphaNumericDeploymentSorter implements Comparator, DefaultDeploymentSorter
-{
-
- private PrefixDeploymentSorter sorter = new PrefixDeploymentSorter();
-
- public String[] getSuffixOrder()
- {
- return sorter.getSuffixOrder();
- }
-
- public void setSuffixOrder(String[] suffixOrder)
- {
- sorter.setSuffixOrder(suffixOrder);
- }
-
- public int compare(Object o1, Object o2)
- {
- int comp = sorter.compare(o1, o2);
-
- return comp == 0 ? alphaCompare(o1, o2) : comp;
- }
-
- private String convertURLToString(URL url)
- {
- String path = url.getPath();
- int nameEnd = path.length() - 1;
- if (nameEnd <= 0) {
- return "";
- }
-
- // ignore a trailing '/'
- if (path.charAt(nameEnd) == '/') {
- nameEnd--;
- }
-
- // find the previous URL separator: '/'
- int nameStart = path.lastIndexOf('/', nameEnd) + 1;
-
- return path.substring(nameStart);
-
- }
-
- public int alphaCompare(Object o1, Object o2)
- {
- String s1 = convertURLToString((URL)o1);
- boolean s1IsDigit = Character.isDigit(s1.charAt(0));
- String s2 = convertURLToString((URL)o2);
- boolean s2IsDigit = Character.isDigit(s2.charAt(0));
-
- if(s1IsDigit && !s2IsDigit)
- {
- return 1; // o1 is greater than o2, since has number and o2 does not
- }
- else if(!s1IsDigit && s2IsDigit)
- {
- return -1; //o1 is less than o2, since does not have number and o2 does
- }
- if(s1IsDigit && s2IsDigit) // numeric comapre
- {
- int num1 = getNumericPrefix(s1);
- int num2 = getNumericPrefix(s2);
- int diff = num1 - num2;
- if(diff != 0) // do not begin with same number
- {
- return diff;
- }
- else //numbers are the same, so have to compare rest of the string
- {
- String s1Suf = getAlphaSuffix(s1);
- String s2Sef = getAlphaSuffix(s2);
- return s1Suf.compareToIgnoreCase(s2Sef);
- }
- }
- else // alpha compare
- {
- return s1.compareToIgnoreCase(s2);
- }
- }
-
- private String getAlphaSuffix(String s1)
- {
- int x = 0;
- while(Character.isDigit(s1.charAt(x++)));
- return s1.substring(x);
- }
-
- private int getNumericPrefix(String s1)
- {
- int x = 0;
- String numS1 = null;
- while(Character.isDigit(s1.charAt(x++)))
- {
- numS1 = s1.substring(0, x);
- }
- int number = Integer.parseInt(numS1);
- return number;
- }
-
-
-}
Deleted: branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/scanner/DeploymentFilter.java
===================================================================
--- branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/scanner/DeploymentFilter.java 2006-08-04 16:27:06 UTC (rev 55202)
+++ branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/scanner/DeploymentFilter.java 2006-08-04 16:40:12 UTC (rev 55203)
@@ -1,257 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.deployment.scanner;
-
-import java.io.FileFilter;
-import java.io.File;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.net.URL;
-
-import org.jboss.net.protocol.URLLister;
-
-/**
- * <p>A simple filter for the URLDeploymentScanner. Three arrays are
- * maintained for checking: a prefix, suffix, and match array. If the
- * filename starts with any of the prefixes, ends with any of the
- * suffixes, or exactly matches any of the matches, then the accepts
- * method will return false.
- *
- * NOTE: the arrays *must* be sorted for the string matching to work,
- * and suffixes use the 'reverseComparator'
- *
- * @author somebody at jboss.org
- * @version $Revision$
- */
-public class DeploymentFilter implements FileFilter, URLLister.URLFilter
-{
- /**
- * Compare the strings backwards. This assists in suffix comparisons.
- */
- private static final Comparator reverseComparator = new Comparator()
- {
- public int compare(Object o1, Object o2)
- {
- int idx1 = ((String) o1).length();
- int idx2 = ((String) o2).length();
- int comp = 0;
-
- while (comp == 0 && idx1 > 0 && idx2 > 0)
- comp = ((String) o1).charAt(--idx1) - ((String) o2).charAt(--idx2);
-
- return (comp == 0) ? (idx1 - idx2) : comp;
- }
- };
-
- /** the default prefix list */
- private static final String[] DEFAULT_PREFIXES =
- {"#", "%", ",", ".", "_$"};
-
- /** the default suffix list */
- private static final String[] DEFAULT_SUFFIXES =
- {"#", "$", "%", "~", ",v",
- ".BAK", ".bak", ".old", ".orig", ".tmp", ".rej", ".sh" };
-
- /** the default matches list */
- private static final String[] DEFAULT_MATCHES =
- {".make.state", ".nse_depinfo", "CVS", "CVS.admin", "RCS", "RCSLOG",
- "SCCS", "TAGS", "core", "tags"};
-
- /** The list of disallowed suffixes, sorted using reverse values */
- private ArrayList suffixes;
-
- /** The sorted list of disallowed prefixes */
- private ArrayList prefixes;
-
- /** The sorted list of disallowed values */
- private ArrayList matches;
-
- /** Use the default values for suffixes, prefixes, and matches */
- public DeploymentFilter()
- {
- this(DEFAULT_MATCHES, DEFAULT_PREFIXES, DEFAULT_SUFFIXES);
- }
-
- /**
- * Create using a custom set of matches, prefixes, and suffixes. If any of
- * these arrays are null, then the corresponding default will be
- * substituted.
- */
- public DeploymentFilter(String[] matches, String[] prefixes, String[] suffixes)
- {
- if( matches == null )
- matches = DEFAULT_MATCHES;
- Arrays.sort(matches);
- this.matches = new ArrayList(Arrays.asList(matches));
-
- if( prefixes == null )
- prefixes = DEFAULT_PREFIXES;
- Arrays.sort(prefixes);
- this.prefixes = new ArrayList(Arrays.asList(prefixes));
-
- if( suffixes == null )
- suffixes = DEFAULT_SUFFIXES;
- Arrays.sort(suffixes, reverseComparator);
- this.suffixes = new ArrayList(Arrays.asList(suffixes));
- }
-
- public void addPrefix(String prefix)
- {
- this.prefixes.add(prefix);
- Collections.sort(this.prefixes);
- }
- public void addPrefixes(String[] prefixes)
- {
- this.prefixes.add(Arrays.asList(prefixes));
- Collections.sort(this.prefixes);
- }
-
- public void delPrefix(String prefix)
- {
- this.prefixes.remove(prefix);
- }
- public void delPrefixes(String[] prefixes)
- {
- this.prefixes.removeAll(Arrays.asList(prefixes));
- Collections.sort(this.prefixes);
- }
-
- public void addSuffix(String suffix)
- {
- this.suffixes.add(suffix);
- Collections.sort(this.suffixes, reverseComparator);
- }
- public void addSuffixes(String[] suffixes)
- {
- this.suffixes.add(Arrays.asList(suffixes));
- Collections.sort(this.suffixes, reverseComparator);
- }
-
- public void delSuffix(String suffix)
- {
- this.suffixes.remove(suffix);
- }
- public void delSuffixes(String[] suffixes)
- {
- this.suffixes.removeAll(Arrays.asList(suffixes));
- Collections.sort(this.suffixes, reverseComparator);
- }
-
- public String[] getSuffixes()
- {
- String[] tmp = new String[suffixes.size()];
- suffixes.toArray(tmp);
- return tmp;
- }
- public void setSuffixes(String[] suffixes)
- {
- Arrays.sort(suffixes, reverseComparator);
- this.suffixes.clear();
- this.suffixes.addAll(Arrays.asList(suffixes));
- }
-
- public String[] getPrefixes()
- {
- String[] tmp = new String[prefixes.size()];
- prefixes.toArray(tmp);
- return tmp;
- }
- public void setPrefixes(String[] prefixes)
- {
- Arrays.sort(prefixes);
- this.prefixes.clear();
- this.prefixes.addAll(Arrays.asList(prefixes));
- }
-
- public String[] getMatches()
- {
- String[] tmp = new String[matches.size()];
- matches.toArray(tmp);
- return tmp;
- }
- public void setMatches(String[] matches)
- {
- Arrays.sort(matches);
- this.matches.clear();
- this.matches.addAll(Arrays.asList(matches));
- }
-
- /**
- * If the filename matches any string in the prefix, suffix, or matches
- * array, return false. Perhaps a bit of overkill, but this method
- * operates in log(n) time, where n is the size of the arrays.
- *
- * @param file The file to be tested
- * @return <code>false</code> if the filename matches any of the prefixes,
- * suffixes, or matches.
- */
- public boolean accept(File file)
- {
- return accept(file.getName());
- }
-
- public boolean accept(URL baseURL, String memberName)
- {
- return accept(memberName);
- }
-
- private boolean accept(String name)
- {
- // check exact match
- int index = Collections.binarySearch(matches, name);
- if (index >= 0)
- return false;
-
- // check prefix
- index = Collections.binarySearch(prefixes, name);
- if (index >= 0)
- return false;
- if (index < -1)
- {
- // The < 0 index gives the first index greater than name
- int firstLessIndex = -2 - index;
- String prefix = (String) prefixes.get(firstLessIndex);
- // If name starts with an ingored prefix ignore name
- if( name.startsWith(prefix) )
- return false;
- }
-
- // check suffix
- index = Collections.binarySearch(suffixes, name, reverseComparator);
- if (index >= 0)
- return false;
- if (index < -1)
- {
- // The < 0 index gives the first index greater than name
- int firstLessIndex = -2 - index;
- String suffix = (String) suffixes.get(firstLessIndex);
- // If name ends with an ingored suffix ignore name
- if( name.endsWith(suffix) )
- return false;
- }
-
- // everything checks out.
- return true;
- }
-}
Deleted: branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/scanner/DeploymentScanner.java
===================================================================
--- branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/scanner/DeploymentScanner.java 2006-08-04 16:27:06 UTC (rev 55202)
+++ branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/scanner/DeploymentScanner.java 2006-08-04 16:40:12 UTC (rev 55203)
@@ -1,109 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.deployment.scanner;
-
-import javax.management.ObjectName;
-
-import org.jboss.system.Service;
-
-/**
- * Provides the basic interface for a deployment scanner.
- *
- * <p>A deployment scanner scans for new, removed or changed
- * deployments.
- *
- * @jmx:mbean extends="org.jboss.system.ServiceMBean"
- *
- * @version <tt>$Revision$</tt>
- * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
- */
-public interface DeploymentScanner
- extends Service
-{
- /**
- * The ObjectName of the {@link Deployer} which we will use.
- *
- * @param deployerName The object name of the deployer to use.
- *
- * @jmx:managed-attribute
- */
- void setDeployer(ObjectName deployerName);
-
- /**
- * Get the ObjectName of the {@link Deployer} which we are using.
- *
- * @return The object name of the deployer we are using.
- *
- * @jmx:managed-attribute
- */
- ObjectName getDeployer();
-
- /**
- * Set the scan period for the scanner.
- *
- * @param period This is the time in milliseconds between scans.
- *
- * @throws IllegalArgumentException Period value out of range.
- *
- * @jmx:managed-attribute
- */
- void setScanPeriod(long period);
-
- /**
- * Get the scan period for the scanner.
- *
- * @return This is the time in milliseconds between scans.
- */
- long getScanPeriod();
-
- /**
- * Disable or enable the period based deployment scanning.
- *
- * <p>Manual scanning can still be performed by calling
- * {@link #scan}.
- *
- * @param flag True to enable or false to disable period
- * based scanning.
- *
- * @jmx:managed-attribute
- */
- void setScanEnabled(boolean flag);
-
- /**
- * Check if period based scanning is enabled.
- *
- * @return True if enabled, false if disabled.
- *
- * @jmx:managed-attribute
- */
- boolean isScanEnabled();
-
- /**
- * Scan for deployment changes.
- *
- * @throws IllegalStateException Not initialized.
- * @throws Exception Scan failed.
- *
- * @jmx:managed-operation
- */
- void scan() throws Exception;
-}
Deleted: branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/scanner/DeploymentScannerMBean.java
===================================================================
--- branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/scanner/DeploymentScannerMBean.java 2006-08-04 16:27:06 UTC (rev 55202)
+++ branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/scanner/DeploymentScannerMBean.java 2006-08-04 16:40:12 UTC (rev 55203)
@@ -1,82 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.deployment.scanner;
-
-/**
- * MBean interface.
- */
-public interface DeploymentScannerMBean extends org.jboss.system.ServiceMBean
-{
-
- /**
- * The ObjectName of the {@link Deployer} which we will use.
- * @param deployerName The object name of the deployer to use.
- */
- void setDeployer(javax.management.ObjectName deployerName);
-
- /**
- * Get the ObjectName of the {@link Deployer} which we are using.
- * @return The object name of the deployer we are using.
- */
- javax.management.ObjectName getDeployer();
-
- /**
- * Set the scan period for the scanner.
- * @param period This is the time in milliseconds between scans.
- * @throws IllegalArgumentException Period value out of range.
- */
- void setScanPeriod(long period);
-
- /**
- * Disable or enable the period based deployment scanning. <p>Manual scanning can still be performed by calling {@link #scan}.
- * @param flag True to enable or false to disable period based scanning.
- */
- void setScanEnabled(boolean flag);
-
- /**
- * Check if period based scanning is enabled.
- * @return True if enabled, false if disabled.
- */
- boolean isScanEnabled();
-
- /**
- * How long to wait in stop for the background thread to stop
- *
- * @return the time in milliseconds.
- */
- long getStopTimeOut();
-
- /**
- * How long to wait in stop for the background thread to stop
- *
- * @param stopTimeOut the time in milliseconds.
- */
- void setStopTimeOut(long stopTimeOut);
-
- /**
- * Scan for deployment changes.
- * @throws IllegalStateException Not initialized.
- * @throws Exception Scan failed.
- */
- void scan() throws java.lang.Exception;
-
-}
Deleted: branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/scanner/PrefixDeploymentSorter.java
===================================================================
--- branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/scanner/PrefixDeploymentSorter.java 2006-08-04 16:27:06 UTC (rev 55202)
+++ branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/scanner/PrefixDeploymentSorter.java 2006-08-04 16:40:12 UTC (rev 55203)
@@ -1,103 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.deployment.scanner;
-
-import java.util.Comparator;
-import java.net.URL;
-import org.jboss.deployment.DeploymentSorter;
-import org.jboss.deployment.DefaultDeploymentSorter;
-
-/**
- * <p>This class is a comparator to sort deployment URLs based on the existence
- * of a numeric prefix. The name portion of the URL is evaluated for any
- * leading digits. If they exist, then they will define a numerical ordering
- * for this comparator. If there is no leading digits, then they will
- * compare as less than any name with leading digits. In the case of a
- * tie, the DeploymentSorter is consulted (@see org.jboss.deployment.DeploymentSorter).
- *
- * <p>Ex.these names are in ascending order:
- * test.sar, crap.ear, 001test.jar, 5test.rar, 5foo.jar, 120bar.jar
- */
-public class PrefixDeploymentSorter implements Comparator, DefaultDeploymentSorter
-{
-
- /** This is used to break ties */
- private DeploymentSorter sorter = new DeploymentSorter();
-
- public String[] getSuffixOrder()
- {
- return sorter.getSuffixOrder();
- }
-
- public void setSuffixOrder(String[] suffixOrder)
- {
- sorter.setSuffixOrder(suffixOrder);
- }
-
- /**
- * As described in @see java.util.Comparator. This implements the
- * comparison technique described above.
- */
- public int compare(Object o1, Object o2) {
- int comp = getPrefixValue((URL)o1) - getPrefixValue((URL)o2);
-
- return comp == 0 ? sorter.compare(o1, o2) : comp;
- }
-
- /**
- * This extracts the prefix value from the name of a URL. If no prefix
- * value exists, this returns -1
- */
- private int getPrefixValue(URL url) {
- String path = url.getPath();
- int nameEnd = path.length() - 1;
- if (nameEnd <= 0) {
- return 0;
- }
-
- // ignore a trailing '/'
- if (path.charAt(nameEnd) == '/') {
- nameEnd--;
- }
-
- // find the previous URL separator: '/'
- int nameStart = path.lastIndexOf('/', nameEnd) + 1;
-
- // calculate where the digit-prefix ends
- int prefixEnd = nameStart;
- while (prefixEnd <= nameEnd && Character.isDigit(path.charAt(prefixEnd))) {
- prefixEnd++;
- }
-
- // If zero length prefix, return -1
- if (prefixEnd == nameStart) {
- return -1;
- }
-
- // strip leading zeroes
- while (nameStart < prefixEnd && path.charAt(nameStart) == '0') {
- nameStart++;
- }
-
- return (nameStart == prefixEnd) ? 0 : Integer.parseInt(path.substring(nameStart, prefixEnd));
- }
-}
Deleted: branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/scanner/URLDeploymentScanner.java
===================================================================
--- branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/scanner/URLDeploymentScanner.java 2006-08-04 16:27:06 UTC (rev 55202)
+++ branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/scanner/URLDeploymentScanner.java 2006-08-04 16:40:12 UTC (rev 55203)
@@ -1,836 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.deployment.scanner;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-import java.util.StringTokenizer;
-
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-
-import org.jboss.deployment.DefaultDeploymentSorter;
-import org.jboss.deployment.IncompleteDeploymentException;
-import org.jboss.mx.util.JMXExceptionDecoder;
-import org.jboss.net.protocol.URLLister;
-import org.jboss.net.protocol.URLListerFactory;
-import org.jboss.net.protocol.URLLister.URLFilter;
-import org.jboss.system.server.ServerConfig;
-import org.jboss.system.server.ServerConfigLocator;
-import org.jboss.util.NullArgumentException;
-import org.jboss.util.StringPropertyReplacer;
-
-/**
- * A URL-based deployment scanner. Supports local directory
- * scanning for file-based urls.
- *
- * @jmx:mbean extends="org.jboss.deployment.scanner.DeploymentScannerMBean"
- *
- * @version <tt>$Revision$</tt>
- * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
- * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
- */
-public class URLDeploymentScanner extends AbstractDeploymentScanner
- implements DeploymentScanner, URLDeploymentScannerMBean
-{
- /** A set of deployment URLs to skip **/
- protected Set skipSet = Collections.synchronizedSet(new HashSet());
-
- /** The list of URLs to scan. */
- protected List urlList = Collections.synchronizedList(new ArrayList());
-
- /** A set of scanned urls which have been deployed. */
- protected Set deployedSet = Collections.synchronizedSet(new HashSet());
-
- /** Helper for listing local/remote directory URLs */
- protected URLListerFactory listerFactory = new URLListerFactory();
-
- /** The server's home directory, for relative paths. */
- protected File serverHome;
-
- protected URL serverHomeURL;
-
- /** A sorter urls from a scaned directory to allow for coarse dependency
- ordering based on file type
- */
- protected Comparator sorter;
-
- /** Allow a filter for scanned directories */
- protected URLFilter filter;
-
- protected IncompleteDeploymentException lastIncompleteDeploymentException;
-
- /** Whether to search inside directories whose names containing no dots */
- protected boolean doRecursiveSearch = true;
-
- /**
- * @jmx:managed-attribute
- */
- public void setRecursiveSearch (boolean recurse)
- {
- doRecursiveSearch = recurse;
- }
-
- /**
- * @jmx:managed-attribute
- */
- public boolean getRecursiveSearch ()
- {
- return doRecursiveSearch;
- }
-
- /**
- * @jmx:managed-attribute
- */
- public void setURLList(final List list)
- {
- if (list == null)
- throw new NullArgumentException("list");
-
- // start out with a fresh list
- urlList.clear();
-
- Iterator iter = list.iterator();
- while (iter.hasNext())
- {
- URL url = (URL)iter.next();
- if (url == null)
- throw new NullArgumentException("list element");
-
- addURL(url);
- }
-
- log.debug("URL list: " + urlList);
- }
-
- /**
- * @jmx:managed-attribute
- *
- * @param classname The name of a Comparator class.
- */
- public void setURLComparator(String classname)
- throws ClassNotFoundException, IllegalAccessException,
- InstantiationException
- {
- sorter = (Comparator)Thread.currentThread().getContextClassLoader().loadClass(classname).newInstance();
- }
-
- /**
- * @jmx:managed-attribute
- */
- public String getURLComparator()
- {
- if (sorter == null)
- return null;
- return sorter.getClass().getName();
- }
-
- /**
- * @jmx:managed-attribute
- *
- * @param classname The name of a FileFilter class.
- */
- public void setFilter(String classname)
- throws ClassNotFoundException, IllegalAccessException, InstantiationException
- {
- Class filterClass = Thread.currentThread().getContextClassLoader().loadClass(classname);
- filter = (URLFilter) filterClass.newInstance();
- }
-
- /**
- * @jmx:managed-attribute
- */
- public String getFilter()
- {
- if (filter == null)
- return null;
- return filter.getClass().getName();
- }
-
-
- /**
- * @jmx:managed-attribute
- *
- * @param filter The URLFilter instance
- */
- public void setFilterInstance(URLFilter filter)
- {
- this.filter = filter;
- }
-
- /**
- * @jmx:managed-attribute
- */
- public URLFilter getFilterInstance()
- {
- return filter;
- }
-
- /**
- * @jmx:managed-attribute
- */
- public List getURLList()
- {
- // too bad, List isn't a cloneable
- return new ArrayList(urlList);
- }
-
- /**
- * @jmx:managed-operation
- */
- public void addURL(final URL url)
- {
- if (url == null)
- throw new NullArgumentException("url");
-
- try
- {
- // check if this is a valid url
- url.openConnection().connect();
- }
- catch (IOException e)
- {
- // either a bad configuration (non-existent url) or a transient i/o error
- log.warn("addURL(), caught " + e.getClass().getName() + ": " + e.getMessage());
- }
- urlList.add(url);
-
- log.debug("Added url: " + url);
- }
-
- /**
- * @jmx:managed-operation
- */
- public void removeURL(final URL url)
- {
- if (url == null)
- throw new NullArgumentException("url");
-
- boolean success = urlList.remove(url);
- if (success)
- {
- log.debug("Removed url: " + url);
- }
- }
-
- /**
- * @jmx:managed-operation
- */
- public boolean hasURL(final URL url)
- {
- if (url == null)
- throw new NullArgumentException("url");
-
- return urlList.contains(url);
- }
-
- /**
- * Temporarily ignore changes (addition, updates, removal) to a particular
- * deployment, identified by its deployment URL. The deployment URL is different
- * from the 'base' URLs that are scanned by the scanner (e.g. the full path to
- * deploy/jmx-console.war vs. deploy/). This can be used to avoid an attempt
- * by the scanner to deploy/redeploy/undeploy a URL that is being modified.
- *
- * To re-enable scanning of changes for a URL, use resumeDeployment(URL, boolean).
- *
- * @jmx:managed-operation
- */
- public void suspendDeployment(URL url)
- {
- if (url == null)
- throw new NullArgumentException("url");
-
- if (skipSet.add(url))
- log.debug("Deployment URL added to skipSet: " + url);
- else
- throw new IllegalStateException("Deployment URL already suspended: " + url);
- }
-
- /**
- * Re-enables scanning of a particular deployment URL, previously suspended
- * using suspendDeployment(URL). If the markUpToDate flag is true then the
- * deployment module will be considered up-to-date during the next scan.
- * If the flag is false, at the next scan the scanner will check the
- * modification date to decide if the module needs deploy/redeploy/undeploy.
- *
- * @jmx:managed-operation
- */
- public void resumeDeployment(URL url, boolean markUpToDate)
- {
- if (url == null)
- throw new NullArgumentException("url");
-
- if (skipSet.contains(url))
- {
- if (markUpToDate)
- {
- // look for the deployment and mark it as uptodate
- for (Iterator i = deployedSet.iterator(); i.hasNext(); )
- {
- DeployedURL deployedURL = (DeployedURL)i.next();
- if (deployedURL.url.equals(url))
- {
- // the module could have been removed..
- log.debug("Marking up-to-date: " + url);
- deployedURL.deployed();
- break;
- }
- }
- }
- // don't skip this url anymore
- skipSet.remove(url);
- log.debug("Deployment URL removed from skipSet: " + url);
- }
- else
- {
- throw new IllegalStateException("Deployment URL not suspended: " + url);
- }
- }
-
- /**
- * Lists all urls deployed by the scanner, each URL on a new line.
- *
- * @jmx:managed-operation
- */
- public String listDeployedURLs()
- {
- StringBuffer sbuf = new StringBuffer();
- for (Iterator i = deployedSet.iterator(); i.hasNext(); )
- {
- URL url = ((DeployedURL)i.next()).url;
- if (sbuf.length() > 0)
- {
- sbuf.append("\n").append(url);
- }
- else
- {
- sbuf.append(url);
- }
- }
- return sbuf.toString();
- }
-
- /////////////////////////////////////////////////////////////////////////
- // Management/Configuration Helpers //
- /////////////////////////////////////////////////////////////////////////
-
- /**
- * @jmx:managed-attribute
- */
- public void setURLs(final String listspec) throws MalformedURLException
- {
- if (listspec == null)
- throw new NullArgumentException("listspec");
-
- List list = new LinkedList();
-
- StringTokenizer stok = new StringTokenizer(listspec, ",");
- while (stok.hasMoreTokens())
- {
- String urlspec = stok.nextToken().trim();
- log.debug("Adding URL from spec: " + urlspec);
-
- URL url = makeURL(urlspec);
- log.debug("URL: " + url);
-
- list.add(url);
- }
-
- setURLList(list);
- }
-
- /**
- * A helper to make a URL from a full url, or a filespec.
- */
- protected URL makeURL(String urlspec) throws MalformedURLException
- {
- // First replace URL with appropriate properties
- //
- urlspec = StringPropertyReplacer.replaceProperties (urlspec);
- return new URL(serverHomeURL, urlspec);
- }
-
- /**
- * @jmx:managed-operation
- */
- public void addURL(final String urlspec) throws MalformedURLException
- {
- addURL(makeURL(urlspec));
- }
-
- /**
- * @jmx:managed-operation
- */
- public void removeURL(final String urlspec) throws MalformedURLException
- {
- removeURL(makeURL(urlspec));
- }
-
- /**
- * @jmx:managed-operation
- */
- public boolean hasURL(final String urlspec) throws MalformedURLException
- {
- return hasURL(makeURL(urlspec));
- }
-
- /**
- * A helper to deploy the given URL with the deployer.
- */
- protected void deploy(final DeployedURL du)
- {
- // If the deployer is null simply ignore the request
- if (deployer == null)
- return;
-
- try
- {
- if (log.isTraceEnabled())
- log.trace("Deploying: " + du);
-
- deployer.deploy(du.url);
- }
- catch (IncompleteDeploymentException e)
- {
- lastIncompleteDeploymentException = e;
- }
- catch (Exception e)
- {
- log.debug("Failed to deploy: " + du, e);
- }
-
- du.deployed();
-
- if (!deployedSet.contains(du))
- {
- deployedSet.add(du);
- }
- }
-
- /**
- * A helper to undeploy the given URL from the deployer.
- */
- protected void undeploy(final DeployedURL du)
- {
- try
- {
- if (log.isTraceEnabled())
- log.trace("Undeploying: " + du);
-
- deployer.undeploy(du.url);
- deployedSet.remove(du);
- }
- catch (Exception e)
- {
- log.error("Failed to undeploy: " + du, e);
- }
- }
-
- /**
- * Checks if the url is in the deployed set.
- */
- protected boolean isDeployed(final URL url)
- {
- DeployedURL du = new DeployedURL(url);
- return deployedSet.contains(du);
- }
-
- public synchronized void scan() throws Exception
- {
- lastIncompleteDeploymentException = null;
- if (urlList == null)
- throw new IllegalStateException("not initialized");
-
- updateSorter();
-
- boolean trace = log.isTraceEnabled();
- List urlsToDeploy = new LinkedList();
-
- // Scan for deployments
- if (trace)
- {
- log.trace("Scanning for new deployments");
- }
- synchronized (urlList)
- {
- for (Iterator i = urlList.iterator(); i.hasNext();)
- {
- URL url = (URL) i.next();
- try
- {
- if (url.toString().endsWith("/"))
- {
- // treat URL as a collection
- URLLister lister = listerFactory.createURLLister(url);
-
- // listMembers() will throw an IOException if collection url does not exist
- urlsToDeploy.addAll(lister.listMembers(url, filter, doRecursiveSearch));
- }
- else
- {
- // treat URL as a deployable unit
-
- // throws IOException if this URL does not exist
- url.openConnection().connect();
- urlsToDeploy.add(url);
- }
- }
- catch (IOException e)
- {
- // Either one of the configured URLs is bad, i.e. points to a non-existent
- // location, or it ends with a '/' but it is not a directory (so it
- // is really user's fault), OR some other hopefully transient I/O error
- // happened (e.g. out of file descriptors?) so log a warning.
- log.warn("Scan URL, caught " + e.getClass().getName() + ": " + e.getMessage());
-
- // We need to return because at least one of the listed URLs will
- // return no results, and so all deployments starting from that point
- // (e.g. deploy/) will get undeployed, see JBAS-3107.
- // On the other hand, in case of a bad configuration nothing will get
- // deployed. If really want independence of e.g. 2 deploy urls, more
- // than one URLDeploymentScanners can be setup.
- return;
- }
- }
- }
-
- if (trace)
- {
- log.trace("Updating existing deployments");
- }
- LinkedList urlsToRemove = new LinkedList();
- LinkedList urlsToCheckForUpdate = new LinkedList();
- synchronized (deployedSet)
- {
- // remove previously deployed URLs no longer needed
- for (Iterator i = deployedSet.iterator(); i.hasNext();)
- {
- DeployedURL deployedURL = (DeployedURL) i.next();
-
- if (skipSet.contains(deployedURL.url))
- {
- if (trace)
- log.trace("Skipping update/removal check for: " + deployedURL.url);
- }
- else
- {
- if (urlsToDeploy.contains(deployedURL.url))
- {
- urlsToCheckForUpdate.add(deployedURL);
- }
- else
- {
- urlsToRemove.add(deployedURL);
- }
- }
- }
- }
-
- // ********
- // Undeploy
- // ********
-
- for (Iterator i = urlsToRemove.iterator(); i.hasNext();)
- {
- DeployedURL deployedURL = (DeployedURL) i.next();
- if (trace)
- {
- log.trace("Removing " + deployedURL.url);
- }
- undeploy(deployedURL);
- }
-
- // ********
- // Redeploy
- // ********
-
- // compute the DeployedURL list to update
- ArrayList urlsToUpdate = new ArrayList(urlsToCheckForUpdate.size());
- for (Iterator i = urlsToCheckForUpdate.iterator(); i.hasNext();)
- {
- DeployedURL deployedURL = (DeployedURL) i.next();
- if (deployedURL.isModified())
- {
- if (trace)
- {
- log.trace("Re-deploying " + deployedURL.url);
- }
- urlsToUpdate.add(deployedURL);
- }
- }
-
- // sort to update list
- Collections.sort(urlsToUpdate, new Comparator()
- {
- public int compare(Object o1, Object o2)
- {
- return sorter.compare(((DeployedURL) o1).url, ((DeployedURL) o2).url);
- }
- });
-
- // Undeploy in order
- for (int i = urlsToUpdate.size() - 1; i >= 0;i--)
- {
- undeploy((DeployedURL) urlsToUpdate.get(i));
- }
-
- // Deploy in order
- for (int i = 0; i < urlsToUpdate.size();i++)
- {
- deploy((DeployedURL) urlsToUpdate.get(i));
- }
-
- // ******
- // Deploy
- // ******
-
- Collections.sort(urlsToDeploy, sorter);
- for (Iterator i = urlsToDeploy.iterator(); i.hasNext();)
- {
- URL url = (URL) i.next();
- DeployedURL deployedURL = new DeployedURL(url);
- if (deployedSet.contains(deployedURL) == false)
- {
- if (skipSet.contains(url))
- {
- if (trace)
- log.trace("Skipping deployment of: " + url);
- }
- else
- {
- if (trace)
- log.trace("Deploying " + deployedURL.url);
-
- deploy(deployedURL);
- }
- }
- i.remove();
- // Check to see if mainDeployer suffix list has changed.
- // if so, then resort
- if (i.hasNext() && updateSorter())
- {
- Collections.sort(urlsToDeploy, sorter);
- i = urlsToDeploy.iterator();
- }
- }
-
- // Validate that there are still incomplete deployments
- if (lastIncompleteDeploymentException != null)
- {
- try
- {
- Object[] args = {};
- String[] sig = {};
- getServer().invoke(getDeployer(),
- "checkIncompleteDeployments", args, sig);
- }
- catch (Exception e)
- {
- Throwable t = JMXExceptionDecoder.decode(e);
- log.error(t);
- }
- }
- }
-
- protected boolean updateSorter()
- {
- // Check to see if mainDeployer suffix list has changed.
- if (sorter instanceof DefaultDeploymentSorter)
- {
- DefaultDeploymentSorter defaultSorter = (DefaultDeploymentSorter)sorter;
- if (defaultSorter.getSuffixOrder() != mainDeployer.getSuffixOrder())
- {
- defaultSorter.setSuffixOrder(mainDeployer.getSuffixOrder());
- return true;
- }
- }
- return false;
- }
-
- /////////////////////////////////////////////////////////////////////////
- // Service/ServiceMBeanSupport //
- /////////////////////////////////////////////////////////////////////////
-
- public ObjectName preRegister(MBeanServer server, ObjectName name)
- throws Exception
- {
- // get server's home for relative paths, need this for setting
- // attribute final values, so we need to do it here
- ServerConfig serverConfig = ServerConfigLocator.locate();
- serverHome = serverConfig.getServerHomeDir();
- serverHomeURL = serverConfig.getServerHomeURL();
-
- return super.preRegister(server, name);
- }
-
- protected void createService() throws Exception
- {
- // Perform a couple of sanity checks
- if (this.filter == null)
- {
- throw new IllegalStateException("'FilterInstance' attribute not configured");
- }
- if (this.sorter == null)
- {
- throw new IllegalStateException("'URLComparator' attribute not configured");
- }
- // ok, proceed with normal createService()
- super.createService();
- }
-
- /////////////////////////////////////////////////////////////////////////
- // DeployedURL //
- /////////////////////////////////////////////////////////////////////////
-
- /**
- * A container and help class for a deployed URL.
- * should be static at this point, with the explicit scanner ref, but I'm (David) lazy.
- */
- protected class DeployedURL
- {
- public URL url;
- /** The url to check to decide if we need to redeploy */
- public URL watchUrl;
-
- public long deployedLastModified;
-
- public DeployedURL(final URL url)
- {
- this.url = url;
- }
-
- public void deployed()
- {
- deployedLastModified = getLastModified();
- }
- public boolean isFile()
- {
- return url.getProtocol().equals("file");
- }
-
- public File getFile()
- {
- return new File(url.getFile());
- }
-
- public boolean isRemoved()
- {
- if (isFile())
- {
- File file = getFile();
- return !file.exists();
- }
- return false;
- }
-
- public long getLastModified()
- {
- if (watchUrl == null)
- {
- try
- {
- Object o = getServer().invoke(
- getDeployer(),
- "getWatchUrl",
- new Object[] { url },
- new String[] { URL.class.getName() }
- );
- watchUrl = o == null ? url : (URL)o;
- getLog().debug("Watch URL for: " + url + " -> " + watchUrl);
- }
- catch (Exception e)
- {
- watchUrl = url;
- getLog().debug("Unable to obtain watchUrl from deployer. Use url: " + url, e);
- }
- }
-
- try
- {
- URLConnection connection;
- if (watchUrl != null)
- {
- connection = watchUrl.openConnection();
- }
- else
- {
- connection = url.openConnection();
- }
- // no need to do special checks for files...
- // org.jboss.net.protocol.file.FileURLConnection correctly
- // implements the getLastModified method.
- long lastModified = connection.getLastModified();
-
- return lastModified;
- }
- catch (java.io.IOException e)
- {
- log.warn("Failed to check modification of deployed url: " + url, e);
- }
- return -1;
- }
-
- public boolean isModified()
- {
- long lastModified = getLastModified();
- if (lastModified == -1)
- {
- // ignore errors fetching the timestamp - see bug 598335
- return false;
- }
- return deployedLastModified != lastModified;
- }
-
- public int hashCode()
- {
- return url.hashCode();
- }
-
- public boolean equals(final Object other)
- {
- if (other instanceof DeployedURL)
- {
- return ((DeployedURL)other).url.equals(this.url);
- }
- return false;
- }
-
- public String toString()
- {
- return super.toString() +
- "{ url=" + url +
- ", deployedLastModified=" + deployedLastModified +
- " }";
- }
- }
-}
Deleted: branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/scanner/URLDeploymentScannerMBean.java
===================================================================
--- branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/scanner/URLDeploymentScannerMBean.java 2006-08-04 16:27:06 UTC (rev 55202)
+++ branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/scanner/URLDeploymentScannerMBean.java 2006-08-04 16:40:12 UTC (rev 55203)
@@ -1,99 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.deployment.scanner;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.List;
-
-import org.jboss.net.protocol.URLLister.URLFilter;
-
-/**
- * URLDeploymentScanner MBean interface.
- *
- * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
- * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
- * @version $Revision$
- */
-public interface URLDeploymentScannerMBean extends DeploymentScannerMBean
-{
- // Attributes ----------------------------------------------------
-
- void setRecursiveSearch(boolean recurse);
- boolean getRecursiveSearch();
-
- void setURLList(List list);
- List getURLList();
-
- void setURLComparator(String classname)
- throws ClassNotFoundException, IllegalAccessException, InstantiationException;
- String getURLComparator();
-
- void setFilter(String classname)
- throws ClassNotFoundException, IllegalAccessException, InstantiationException;
- String getFilter();
-
- void setFilterInstance(URLFilter filter);
- URLFilter getFilterInstance();
-
- void setURLs(String listspec) throws MalformedURLException;
-
- // Operations ----------------------------------------------------
-
- void addURL(URL url);
-
- void removeURL(URL url);
-
- boolean hasURL(URL url);
-
- void addURL(String urlspec) throws MalformedURLException;
-
- void removeURL(String urlspec) throws MalformedURLException;
-
- boolean hasURL(String urlspec) throws MalformedURLException;
-
- /**
- * Temporarily ignore changes (addition, updates, removal) to a particular
- * deployment, identified by its deployment URL. The deployment URL is different
- * from the 'base' URLs that are scanned by the scanner (e.g. the full path to
- * deploy/jmx-console.war vs. deploy/). This can be used to avoid an attempt
- * by the scanner to deploy/redeploy/undeploy a URL that is being modified.
- *
- * To re-enable scanning of changes for a URL, use resumeDeployment(URL, boolean).
- */
- void suspendDeployment(URL url);
-
- /**
- * Re-enables scanning of a particular deployment URL, previously suspended
- * using suspendDeployment(URL). If the markUpToDate flag is true then the
- * deployment module will be considered up-to-date during the next scan.
- * If the flag is false, at the next scan the scanner will check the
- * modification date to decide if the module needs deploy/redeploy/undeploy.
- */
- void resumeDeployment(URL url, boolean markUpToDate);
-
- /**
- * Lists all urls deployed by the scanner, each URL on a new line.
- */
- public String listDeployedURLs();
-
-}
Deleted: branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/scanner/package.html
===================================================================
--- branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/scanner/package.html 2006-08-04 16:27:06 UTC (rev 55202)
+++ branches/MC_VDF_WORK/system/src/main/org/jboss/deployment/scanner/package.html 2006-08-04 16:40:12 UTC (rev 55203)
@@ -1,41 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
- <head>
- <!-- $Id$ -->
- <!--
-
- JBoss: The OpenSource J2EE WebOS
-
- Distributable under LGPL license.
- See terms of license at gnu.org.
-
- -->
- </head>
-
- <body bgcolor="white">
- <p>Deployment scanning framework and components.
-
- <h2>Package Specification</h2>
- <ul>
- <li><a href="javascript: alert('not available')">Not Available</a>
- </ul>
-
- <h2>Related Documentation</h2>
- <ul>
- <li><a href="javascript: alert('not available')">Not Available</a>
- </ul>
-
- <h2>Package Status</h2>
- <ul>
- <li><font color="green"><b>STABLE</b></font>
- </ul>
-
- <h2>Todo</h2>
- <ul>
- <li>???
- </ul>
-
- <!-- Put @see and @since tags down here. -->
-
- </body>
-</html>
More information about the jboss-cvs-commits
mailing list