You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by dj...@apache.org on 2003/11/14 17:27:35 UTC

cvs commit: incubator-geronimo/modules/web/src/java/org/apache/geronimo/web WebDeploymentPlanner.java AbstractWebContainer.java

djencks     2003/11/14 08:27:35

  Modified:    modules/core/src/conf boot-service.xml
               modules/core/src/java/org/apache/geronimo/client
                        ClientDeploymentPlanner.java
               modules/core/src/java/org/apache/geronimo/connector/deployment
                        ConnectorDeploymentPlanner.java
               modules/kernel/src/conf boot.mlet
               modules/kernel/src/java/org/apache/geronimo/kernel/deployment
                        DeploymentController.java DeploymentPlan.java
                        DeploymentPlanner.java
               modules/kernel/src/java/org/apache/geronimo/kernel/deployment/scanner
                        DeploymentScanner.java
               modules/kernel/src/java/org/apache/geronimo/kernel/deployment/service
                        ServiceDeploymentPlanner.java
               modules/web/src/deploy/jetty jetty-service.xml
               modules/web/src/java/org/apache/geronimo/web
                        AbstractWebContainer.java
  Added:       modules/kernel/src/java/org/apache/geronimo/kernel/deployment
                        AbstractDeploymentPlanner.java
               modules/web/src/java/org/apache/geronimo/web
                        WebDeploymentPlanner.java
  Log:
  Change the deployment system to use GeronimoMBeans, eliminating direct use of the relation service.  Web deployment refactoring is incomplete, but works.
  
  Revision  Changes    Path
  1.20      +4 -12     incubator-geronimo/modules/core/src/conf/boot-service.xml
  
  Index: boot-service.xml
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/conf/boot-service.xml,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- boot-service.xml	11 Nov 2003 21:11:55 -0000	1.19
  +++ boot-service.xml	14 Nov 2003 16:27:34 -0000	1.20
  @@ -21,18 +21,10 @@
       </mbean>
       -->
   
  -    <mbean code="org.apache.geronimo.kernel.deployment.scanner.DeploymentScanner"
  +    <mbean descriptor="org.apache.geronimo.kernel.deployment.scanner.DeploymentScanner"
           name="geronimo.deployment:role=DeploymentScanner">
  -        <constructor>
  -            <arg type="java.net.URL[]">
  -                ${geronimo.home}/deploy/,
  -            </arg>
  -            <arg type="boolean">true</arg>
  -        </constructor>
  +        <attribute name="RecursiveURLs">${geronimo.home}/deploy/,</attribute>
           <attribute name="ScanInterval">5000</attribute>
  -        <relationship type="DeploymentController-DeploymentScanner"
  -            name="DeploymentController-DeploymentScanner"
  -            role="DeploymentScanner"/>
       </mbean>
   
       <mbean code="org.apache.geronimo.deployment.app.ApplicationDeployer"
  @@ -47,7 +39,7 @@
              descriptor="org/apache/geronimo/connector/outbound/CachedConnectionManager.xml">
       </mbean>
   
  -    <mbean code="org.apache.geronimo.connector.deployment.ConnectorDeploymentPlanner"
  +    <mbean descriptor="org.apache.geronimo.connector.deployment.ConnectorDeploymentPlanner"
              name="geronimo.deployment:role=DeploymentPlanner,type=Connector">
       </mbean>
   
  
  
  
  1.5       +25 -5     incubator-geronimo/modules/core/src/java/org/apache/geronimo/client/ClientDeploymentPlanner.java
  
  Index: ClientDeploymentPlanner.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/client/ClientDeploymentPlanner.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ClientDeploymentPlanner.java	8 Sep 2003 04:22:00 -0000	1.4
  +++ ClientDeploymentPlanner.java	14 Nov 2003 16:27:34 -0000	1.5
  @@ -58,16 +58,36 @@
   import java.util.Set;
   
   import org.apache.geronimo.kernel.deployment.DeploymentException;
  +import org.apache.geronimo.kernel.deployment.AbstractDeploymentPlanner;
  +import org.apache.geronimo.kernel.deployment.goal.DeployURL;
  +import org.apache.geronimo.kernel.deployment.goal.RedeployURL;
  +import org.apache.geronimo.kernel.deployment.goal.UndeployURL;
  +import org.apache.geronimo.kernel.service.GeronimoMBeanInfo;
   
   /**
    *
  - * @jmx:mbean
  - *      extends="org.apache.geronimo.kernel.deployment.DeploymentPlanner"
    *
    * @version $Revision$ $Date$
    */
  -public class ClientDeploymentPlanner implements ClientDeploymentPlannerMBean {
  -    public boolean plan(Set goals, Set plans) throws DeploymentException {
  +public class ClientDeploymentPlanner extends AbstractDeploymentPlanner {
  +
  +    /**
  +     * Supply our own GeronimoMBeanInfo for xml-free deployment.
  +     * @return
  +     */
  +    public static GeronimoMBeanInfo getGeronimoMBeanInfo() {
  +        return AbstractDeploymentPlanner.getGeronimoMBeanInfo(ClientDeploymentPlanner.class.getName());
  +    }
  +
  +    protected boolean addURL(DeployURL deployURL, Set goals, Set plans) throws DeploymentException {
  +        return false;
  +    }
  +
  +    protected boolean redeployURL(RedeployURL redeployURL, Set goals) throws DeploymentException {
  +        return false;
  +    }
  +
  +    protected boolean removeURL(UndeployURL undeployURL, Set goals, Set plans) throws DeploymentException {
           return false;
       }
   
  
  
  
  1.2       +114 -168  incubator-geronimo/modules/core/src/java/org/apache/geronimo/connector/deployment/ConnectorDeploymentPlanner.java
  
  Index: ConnectorDeploymentPlanner.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/connector/deployment/ConnectorDeploymentPlanner.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ConnectorDeploymentPlanner.java	11 Nov 2003 21:11:56 -0000	1.1
  +++ ConnectorDeploymentPlanner.java	14 Nov 2003 16:27:34 -0000	1.2
  @@ -86,6 +86,7 @@
   import org.apache.geronimo.kernel.deployment.DeploymentException;
   import org.apache.geronimo.kernel.deployment.DeploymentInfo;
   import org.apache.geronimo.kernel.deployment.DeploymentPlan;
  +import org.apache.geronimo.kernel.deployment.AbstractDeploymentPlanner;
   import org.apache.geronimo.kernel.deployment.goal.DeployURL;
   import org.apache.geronimo.kernel.deployment.goal.DeploymentGoal;
   import org.apache.geronimo.kernel.deployment.goal.RedeployURL;
  @@ -110,60 +111,18 @@
   /**
    * DeploymentPlanner in charge of the plannification of Connector deployments.
    *
  - * @jmx:mbean
  - *      extends="org.apache.geronimo.kernel.deployment.DeploymentPlanner"
    *
    * @version $Revision$ $Date$
    */
   public class ConnectorDeploymentPlanner
  -    implements MBeanRegistration, ConnectorDeploymentPlannerMBean
  -{
  -
  +        extends AbstractDeploymentPlanner {
       private static final Log log = LogFactory.getLog(ConnectorDeploymentPlanner.class);
   
  -    /**
  -     * Reference the MBeanServer
  -     */
  -    private MBeanServer server;
  -
  -    /**
  -     * JMX name of this instance.
  -     */
  -    private ObjectName objectName;
  -
  -    /**
  -     * Reference the RelationService MBean
  -     */
  -    private RelationServiceMBean relationService;
  -
  -    /**
  -     * JMX name of the Connector deployment planner. This name MUST match
  -     * the one used to mount the connector deployment service.
  -     */
  -    public static ObjectName CONNECTOR_DEPLOYER =
  -        JMXUtil.getObjectName("geronimo.jca:role=ConnectorDeploymentPlanner");
  -
  -    /**
  -     * Entry point for the DeploymentPlanner coordinator.
  -     */
  -    public boolean plan(Set goals, Set plans) throws DeploymentException {
  -        boolean progress = false;
  -        Set x = new HashSet(goals);
  -        for (Iterator i = x.iterator(); i.hasNext();) {
  -            DeploymentGoal goal = (DeploymentGoal) i.next();
  -            if (goal instanceof DeployURL) {
  -                progress = deploy((DeployURL) goal, goals, plans);
  -            } else if (goal instanceof RedeployURL) {
  -                // TODO implement me.
  -                progress = false;
  -            } else if (goal instanceof UndeployURL) {
  -                // TODO implement me.
  -                progress = false;
  -            }
  -        }
  -        return progress;
  +    public static GeronimoMBeanInfo getGeronimoMBeanInfo() {
  +        return AbstractDeploymentPlanner.getGeronimoMBeanInfo(ConnectorDeploymentPlanner.class.getName());
       }
   
  +
       /**
        * Deploys the specified URL. If this deployer can deploy the specified
        * URL, then two plans are added to the current plan set. The first plan
  @@ -179,19 +138,19 @@
        *
        * @throws DeploymentException
        */
  -    private boolean deploy(DeployURL goal, Set goals, Set plans)
  -        throws DeploymentException {
  +    protected boolean addURL(DeployURL goal, Set goals, Set plans)
  +            throws DeploymentException {
           URL url = goal.getUrl();
           DeploymentHelper dHelper =
  -            new DeploymentHelper(url, goal.getType());
  +                new DeploymentHelper(url, goal.getType());
           URL raURL = dHelper.locateDD();
           URL graURL = dHelper.locateGeronimoDD();
           // Is the specific URL deployable?
  -        if ( null == raURL ) {
  +        if (null == raURL) {
               log.info("Looking at and rejecting url " + url);
               return false;
           }
  -		URI baseURI = URI.create(url.toString()).normalize();
  +        URI baseURI = URI.create(url.toString()).normalize();
   
           log.trace("Planning the connector deployment " + url);
   
  @@ -204,15 +163,15 @@
           // Defines a deployment plan for the deployment unit.
           DeploymentPlan deploymentPlan = new DeploymentPlan();
           DeploymentInfo deploymentInfo =
  -            new DeploymentInfo(deploymentUnitName, null, url);
  -        deploymentPlan.addTask (
  -            new RegisterMBeanInstance(server, deploymentUnitName, deploymentInfo));
  +                new DeploymentInfo(deploymentUnitName, null, url);
  +        deploymentPlan.addTask(
  +                new RegisterMBeanInstance(getServer(), deploymentUnitName, deploymentInfo));
           MBeanMetadata deploymentUnitMetadata = new MBeanMetadata(deploymentUnitName);
  -        deploymentPlan.addTask (
  -            new StartMBeanInstance(server, deploymentUnitMetadata));
  +        deploymentPlan.addTask(
  +                new StartMBeanInstance(getServer(), deploymentUnitMetadata));
           // Define the ClassSpace for the Connector archives.
           ClassSpaceMetadata raCS = dHelper.buildClassSpace();
  -        deploymentPlan.addTask (new CreateClassSpace(server, raCS));//parent???
  +        deploymentPlan.addTask(new CreateClassSpace(getServer(), raCS));//parent???
           plans.add(deploymentPlan);
   
           //now another plan for the tasks that depend on the class space.
  @@ -223,18 +182,18 @@
   
           GeronimoConnectorDocument gconDoc = null;
           try {
  -			Document raDocument =
  -				LoaderUtil.parseXML(new InputStreamReader(raURL.openStream()));
  -			ConnectorDocument conDoc = ConnectorLoader.load(raDocument);
  -			Document graDocument =
  -				LoaderUtil.parseXML(new InputStreamReader(graURL.openStream()));
  -			gconDoc = GeronimoConnectorLoader.load(graDocument, conDoc);
  +            Document raDocument =
  +                    LoaderUtil.parseXML(new InputStreamReader(raURL.openStream()));
  +            ConnectorDocument conDoc = ConnectorLoader.load(raDocument);
  +            Document graDocument =
  +                    LoaderUtil.parseXML(new InputStreamReader(graURL.openStream()));
  +            gconDoc = GeronimoConnectorLoader.load(graDocument, conDoc);
           } catch (FileNotFoundException e1) {
  -            throw new DeploymentException ("Deployment descriptor not found", e1);
  +            throw new DeploymentException("Deployment descriptor not found", e1);
           } catch (SAXException e1) {
  -            throw new DeploymentException ("[geronimo-]ra.xml malformed", e1);
  +            throw new DeploymentException("[geronimo-]ra.xml malformed", e1);
           } catch (IOException e1) {
  -            throw new DeploymentException ("Deployment descriptor not readable", e1);
  +            throw new DeploymentException("Deployment descriptor not readable", e1);
           }
           GeronimoResourceAdapter gra = gconDoc.getGeronimoConnector().getGeronimoResourceAdapter();
           //deploy ra
  @@ -243,51 +202,76 @@
               MBeanMetadata raMD = getMBeanMetadata(raCS.getName(), deploymentUnitName, baseURI);
               raMD.setCode(gra.getResourceAdapterClass());
               raMD.setName(dHelper.buildResourceAdapterDeploymentName(gra));
  -            configureMBeanMetadata(gra.getConfigProperty(), raMD); 
  +            configureMBeanMetadata(gra.getConfigProperty(), raMD);
               addTasks(raMD, deploymentPlan);
               resourceAdapterName = raMD.getName();
               ObjectName bootstrapContextName = dHelper.buildBootstrapContextName(gra);
  -			ResourceAdapterHelperImpl.addMBeanInfo(raMD.getGeronimoMBeanInfo(), bootstrapContextName);
  -		}
  +            ResourceAdapterHelperImpl.addMBeanInfo(raMD.getGeronimoMBeanInfo(), bootstrapContextName);
  +        }
   
   
           //deploy mcfs
  -		for (int i = 0; i < gra.getGeronimoOutboundResourceAdapter().getGeronimoConnectionDefinition().length; i++) {
  -			GeronimoConnectionDefinition gcd = gra.getGeronimoOutboundResourceAdapter().getGeronimoConnectionDefinition(i);
  +        for (int i = 0; i < gra.getGeronimoOutboundResourceAdapter().getGeronimoConnectionDefinition().length; i++) {
  +            GeronimoConnectionDefinition gcd = gra.getGeronimoOutboundResourceAdapter().getGeronimoConnectionDefinition(i);
               assert gcd != null: "Null GeronimoConnectionDefinition";
  -			//deploy cm factory
  -			GeronimoConnectionManagerFactory gcmf = gcd.getGeronimoConnectionManagerFactory();
  +            //deploy cm factory
  +            GeronimoConnectionManagerFactory gcmf = gcd.getGeronimoConnectionManagerFactory();
               assert gcmf != null: "Null GeronimoConnectionManagerFactory";
  -			MBeanMetadata cmfMD = getMBeanMetadata(raCS.getName(), deploymentUnitName, baseURI);
  -			cmfMD.setGeronimoMBeanDescriptor(gcmf.getConnectionManagerFactoryDescriptor());
  -			cmfMD.setName(dHelper.buildConnectionManagerFactoryDeploymentName(gcd));
  -			adaptConfigProperties(gcmf.getConfigProperty(), null, cmfMD.getAttributeValues());
  -			addTasks(cmfMD, deploymentPlan);
  -        
  -        
  -			MBeanMetadata mcfMD = getMBeanMetadata(raCS.getName(), deploymentUnitName, baseURI);
  -			mcfMD.setCode(gcd.getManagedConnectionFactoryClass());
  -			mcfMD.setName(dHelper.buildManagedConnectionFactoryDeploymentName(gcd));
  -			configureMBeanMetadata(gcd.getConfigProperty(), mcfMD);
  -			ManagedConnectionFactoryHelper.addMBeanInfo(mcfMD.getGeronimoMBeanInfo(), resourceAdapterName, cmfMD.getName());
  -			Map attributes = mcfMD.getAttributeValues();
  -			attributes.put("ConnectionFactoryImplClass", gcd.getConnectionFactoryImplClass());
  -			attributes.put("ConnectionFactoryInterface", gcd.getConnectionFactoryInterface());
  -			attributes.put("ConnectionImplClass", gcd.getConnectionImplClass());
  -			attributes.put("ConnectionInterface", gcd.getConnectionInterface());
  -			attributes.put("ManagedConnectionFactoryClass", gcd.getManagedConnectionFactoryClass());
  -			if (resourceAdapterName != null) {
  -			    attributes.put("ResourceAdapterName", resourceAdapterName);
  -			}
  -			attributes.put("ConnectionManagerFactoryName", cmfMD.getName());
  -			addTasks(mcfMD, deploymentPlan);
  -        
  -		}
  -        plans.add (deploymentPlan);
  +            MBeanMetadata cmfMD = getMBeanMetadata(raCS.getName(), deploymentUnitName, baseURI);
  +            cmfMD.setGeronimoMBeanDescriptor(gcmf.getConnectionManagerFactoryDescriptor());
  +            cmfMD.setName(dHelper.buildConnectionManagerFactoryDeploymentName(gcd));
  +            adaptConfigProperties(gcmf.getConfigProperty(), null, cmfMD.getAttributeValues());
  +            addTasks(cmfMD, deploymentPlan);
  +
  +
  +            MBeanMetadata mcfMD = getMBeanMetadata(raCS.getName(), deploymentUnitName, baseURI);
  +            mcfMD.setCode(gcd.getManagedConnectionFactoryClass());
  +            mcfMD.setName(dHelper.buildManagedConnectionFactoryDeploymentName(gcd));
  +            configureMBeanMetadata(gcd.getConfigProperty(), mcfMD);
  +            ManagedConnectionFactoryHelper.addMBeanInfo(mcfMD.getGeronimoMBeanInfo(), resourceAdapterName, cmfMD.getName());
  +            Map attributes = mcfMD.getAttributeValues();
  +            attributes.put("ConnectionFactoryImplClass", gcd.getConnectionFactoryImplClass());
  +            attributes.put("ConnectionFactoryInterface", gcd.getConnectionFactoryInterface());
  +            attributes.put("ConnectionImplClass", gcd.getConnectionImplClass());
  +            attributes.put("ConnectionInterface", gcd.getConnectionInterface());
  +            attributes.put("ManagedConnectionFactoryClass", gcd.getManagedConnectionFactoryClass());
  +            if (resourceAdapterName != null) {
  +                attributes.put("ResourceAdapterName", resourceAdapterName);
  +            }
  +            attributes.put("ConnectionManagerFactoryName", cmfMD.getName());
  +            addTasks(mcfMD, deploymentPlan);
  +
  +        }
  +        plans.add(deploymentPlan);
   
           return true;
       }
   
  +    /**
  +     *
  +     * @param redeployURL
  +     * @param goals
  +     * @return
  +     * @throws DeploymentException
  +     * @todo implement this
  +     */
  +    protected boolean redeployURL(RedeployURL redeployURL, Set goals) throws DeploymentException {
  +        return false;
  +    }
  +
  +    /**
  +     *
  +     * @param undeployURL
  +     * @param goals
  +     * @param plans
  +     * @return
  +     * @throws DeploymentException
  +     * @todo implement this
  +     */
  +    protected boolean removeURL(UndeployURL undeployURL, Set goals, Set plans) throws DeploymentException {
  +        return false;
  +    }
  +
       private MBeanMetadata getMBeanMetadata(ObjectName loader, ObjectName parent, URI baseURI) {
           MBeanMetadata metadata = new MBeanMetadata();
           metadata.setLoaderName(loader);
  @@ -295,87 +279,48 @@
           metadata.setBaseURI(baseURI);
           return metadata;
       }
  -    
  +
       private void configureMBeanMetadata(ConfigProperty[] props, MBeanMetadata metadata) throws DeploymentException {
  -		GeronimoMBeanInfo info = new GeronimoMBeanInfo();
  +        GeronimoMBeanInfo info = new GeronimoMBeanInfo();
           info.setTargetClass(metadata.getCode());
  -		Map attributes = metadata.getAttributeValues();
  -		adaptConfigProperties(props, info, attributes);
  -		metadata.setGeronimoMBeanInfo(info);
  +        Map attributes = metadata.getAttributeValues();
  +        adaptConfigProperties(props, info, attributes);
  +        metadata.setGeronimoMBeanInfo(info);
   
       }
  -    
  -	private void adaptConfigProperties(
  -		ConfigProperty[] configProperty,
  -		GeronimoMBeanInfo mbeanInfo,
  -		Map attributes)
  -		throws DeploymentException {
  -		ClassLoader cl = Classes.getContextClassLoader();
  -		for (int i = 0; i < configProperty.length; i++) {
  -			if (mbeanInfo != null) {
  +
  +    private void adaptConfigProperties(
  +            ConfigProperty[] configProperty,
  +            GeronimoMBeanInfo mbeanInfo,
  +            Map attributes)
  +            throws DeploymentException {
  +        ClassLoader cl = Classes.getContextClassLoader();
  +        for (int i = 0; i < configProperty.length; i++) {
  +            if (mbeanInfo != null) {
                   GeronimoAttributeInfo attInfo = new GeronimoAttributeInfo();
  -		    	attInfo.setName(configProperty[i].getConfigPropertyName());
  +                attInfo.setName(configProperty[i].getConfigPropertyName());
                   if (configProperty[i].getConfigPropertyValue() != null) {
                       attInfo.setInitialValue(configProperty[i].getConfigPropertyValue());
                   }
  -			    //descriptions are now multilingual, so we'll leave them to
  -			    // someone who knows how to determine the locale.
  +                //descriptions are now multilingual, so we'll leave them to
  +                // someone who knows how to determine the locale.
                   mbeanInfo.addAttributeInfo(attInfo);
               } else if (configProperty[i].getConfigPropertyValue() != null) {
  -				attributes.put(configProperty[i].getConfigPropertyName(), configProperty[i].getConfigPropertyValue());
  -			}
  -		}
  -	}
  -    
  -    private void addTasks(MBeanMetadata metadata, DeploymentPlan plan) throws DeploymentException {
  -		DeployGeronimoMBean createTask =
  -			new DeployGeronimoMBean(server, metadata);
  -		plan.addTask(createTask);
  -		InitializeMBeanInstance initTask =
  -			new InitializeMBeanInstance(server, metadata);
  -		plan.addTask(initTask);
  -		StartMBeanInstance startTask =
  -			new StartMBeanInstance(server, metadata);
  -		plan.addTask(startTask);
  -    }
  -    
  -    /**
  -     * Gets an handle on the MBeanServer and the RelationService.
  -     */
  -    public ObjectName preRegister(MBeanServer aServer, ObjectName anObjectName)
  -        throws Exception {
  -        server = aServer;
  -        relationService = JMXUtil.getRelationService(server);
  -        objectName = anObjectName;
  -        return objectName;
  -    }
  -
  -    /**
  -     * Adds ourself as a DeploymentPlanner in case of a successful registration.
  -     * One also registers the MasterPartition at this stage and one starts it.
  -     */
  -    public void postRegister(Boolean aBoolean) {
  -        // The registration is not successful.
  -        if ( !aBoolean.booleanValue() ) {
  -            return;
  -        }
  -        try {
  -            // Register ourself as a DeploymentPlanner.
  -            List planners = relationService.getRole(
  -                "DeploymentController-DeploymentPlanner", "DeploymentPlanner");
  -            planners.add(objectName);
  -            relationService.setRole(
  -                "DeploymentController-DeploymentPlanner",
  -                new Role("DeploymentPlanner", planners));
  -        } catch (JMException e) {
  -            throwISE("Should never occur", e);
  +                attributes.put(configProperty[i].getConfigPropertyName(), configProperty[i].getConfigPropertyValue());
  +            }
           }
       }
   
  -    public void preDeregister() throws Exception {
  -    }
  -
  -    public void postDeregister() {
  +    private void addTasks(MBeanMetadata metadata, DeploymentPlan plan) throws DeploymentException {
  +        DeployGeronimoMBean createTask =
  +                new DeployGeronimoMBean(getServer(), metadata);
  +        plan.addTask(createTask);
  +        InitializeMBeanInstance initTask =
  +                new InitializeMBeanInstance(getServer(), metadata);
  +        plan.addTask(initTask);
  +        StartMBeanInstance startTask =
  +                new StartMBeanInstance(getServer(), metadata);
  +        plan.addTask(startTask);
       }
   
       /**
  @@ -391,4 +336,5 @@
           e.initCause(aThrowable);
           throw e;
       }
  +
   }
  
  
  
  1.3       +4 -2      incubator-geronimo/modules/kernel/src/conf/boot.mlet
  
  Index: boot.mlet
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/kernel/src/conf/boot.mlet,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- boot.mlet	6 Nov 2003 20:56:31 -0000	1.2
  +++ boot.mlet	14 Nov 2003 16:27:34 -0000	1.3
  @@ -17,15 +17,17 @@
         >
   </MLET>
   
  -<MLET CODE="org.apache.geronimo.kernel.deployment.DeploymentController"
  +<MLET CODE="org.apache.geronimo.kernel.service.GeronimoMBean"
         NAME="geronimo.deployment:role=DeploymentController"
         ARCHIVE=""
         >
  +      <ARG type="java.lang.String" value="org.apache.geronimo.kernel.deployment.DeploymentController"/>
   </MLET>
   
  -<MLET CODE="org.apache.geronimo.kernel.deployment.service.ServiceDeploymentPlanner"
  +<MLET CODE="org.apache.geronimo.kernel.service.GeronimoMBean"
         NAME="geronimo.deployment:role=DeploymentPlanner,type=Service"
         ARCHIVE=""
         >
  +      <ARG type="java.lang.String" value="org.apache.geronimo.kernel.deployment.service.ServiceDeploymentPlanner"/>
   </MLET>
   
  
  
  
  1.3       +82 -64    incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/deployment/DeploymentController.java
  
  Index: DeploymentController.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/deployment/DeploymentController.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DeploymentController.java	29 Sep 2003 13:03:00 -0000	1.2
  +++ DeploymentController.java	14 Nov 2003 16:27:34 -0000	1.3
  @@ -58,7 +58,7 @@
   import java.io.IOException;
   import java.net.URL;
   import java.util.ArrayList;
  -import java.util.Collections;
  +import java.util.Collection;
   import java.util.HashMap;
   import java.util.HashSet;
   import java.util.Iterator;
  @@ -66,82 +66,73 @@
   import java.util.List;
   import java.util.Map;
   import java.util.Set;
  -import javax.management.MBeanRegistration;
  -import javax.management.MBeanServer;
  +import java.util.Collections;
  +
   import javax.management.MalformedObjectNameException;
   import javax.management.ObjectName;
  -import javax.management.relation.RelationServiceMBean;
  -import javax.management.relation.Role;
  -import javax.management.relation.RoleInfo;
  -import javax.management.relation.RoleList;
   
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
  -import org.apache.geronimo.kernel.deployment.scanner.URLInfo;
  -import org.apache.geronimo.kernel.deployment.scanner.URLType;
   import org.apache.geronimo.kernel.deployment.goal.DeployURL;
   import org.apache.geronimo.kernel.deployment.goal.RedeployURL;
   import org.apache.geronimo.kernel.deployment.goal.UndeployURL;
  -import org.apache.geronimo.kernel.jmx.JMXUtil;
  +import org.apache.geronimo.kernel.deployment.scanner.URLInfo;
  +import org.apache.geronimo.kernel.deployment.scanner.URLType;
  +import org.apache.geronimo.kernel.service.GeronimoMBeanContext;
  +import org.apache.geronimo.kernel.service.GeronimoMBeanEndpoint;
  +import org.apache.geronimo.kernel.service.GeronimoMBeanInfo;
  +import org.apache.geronimo.kernel.service.GeronimoMBeanTarget;
  +import org.apache.geronimo.kernel.service.GeronimoOperationInfo;
  +import org.apache.geronimo.kernel.service.GeronimoParameterInfo;
   
   /**
    *
  - * @jmx:mbean
    *
    * @version $Revision$ $Date$
    */
  -public class DeploymentController implements MBeanRegistration, DeploymentControllerMBean {
  -    private static final ObjectName DEFAULT_NAME = JMXUtil.getObjectName("geronimo.deployment:role=DeploymentController");
  +public class DeploymentController implements GeronimoMBeanTarget {
   
       private static final Log log = LogFactory.getLog(DeploymentController.class);
   
  -    private MBeanServer server;
  -    private RelationServiceMBean relationService;
  -    private ObjectName objectName;
  +    private GeronimoMBeanContext context;
  +    private Collection planners = Collections.EMPTY_LIST;
       private final Map scanResults = new HashMap();
  -    private final Map deployedURLs = new HashMap();
       private final Set goals = new HashSet();
       private final LinkedHashSet plans = new LinkedHashSet();
   
  -    public ObjectName preRegister(MBeanServer mBeanServer, ObjectName objectName) throws Exception {
  -        server = mBeanServer;
  -        this.objectName = objectName == null ? DEFAULT_NAME : objectName;
  -
  -        relationService = JMXUtil.getRelationService(server);
  -        RoleInfo[] roleInfo = {
  -            new RoleInfo("DeploymentController", getClass().getName()),
  -            new RoleInfo("DeploymentPlanner", "org.apache.geronimo.kernel.deployment.DeploymentPlanner", true, true, 0, RoleInfo.ROLE_CARDINALITY_INFINITY, null)
  -        };
  -        relationService.createRelationType("DeploymentController-DeploymentPlanner", roleInfo);
  -
  -        roleInfo = new RoleInfo[]{
  -            new RoleInfo("DeploymentController", getClass().getName()),
  -            new RoleInfo("DeploymentScanner", "org.apache.geronimo.kernel.deployment.scanner.DeploymentScannerMBean", true, true, 0, RoleInfo.ROLE_CARDINALITY_INFINITY, null)
  -        };
  -        relationService.createRelationType("DeploymentController-DeploymentScanner", roleInfo);
  -
  -        return this.objectName;
  -    }
  -
  -    public void postRegister(Boolean aBoolean) {
  -        Role controllerRole = new Role("DeploymentController", Collections.singletonList(this.objectName));
  -        RoleList roleList = new RoleList();
  -        roleList.add(controllerRole);
   
  -        try {
  -            relationService.createRelation("DeploymentController-DeploymentPlanner", "DeploymentController-DeploymentPlanner", roleList);
  -            relationService.createRelation("DeploymentController-DeploymentScanner", "DeploymentController-DeploymentScanner", roleList);
  -        } catch (Exception e) {
  -            IllegalStateException e1 = new IllegalStateException();
  -            e1.initCause(e);
  -            throw e1;
  -        }
  -    }
  -
  -    public void preDeregister() throws Exception {
  -    }
  -
  -    public void postDeregister() {
  +    public static GeronimoMBeanInfo getGeronimoMBeanInfo() throws Exception {
  +        GeronimoMBeanInfo mbeanInfo = new GeronimoMBeanInfo();
  +        mbeanInfo.setAutostart(true);
  +        mbeanInfo.setTargetClass(DeploymentController.class.getName());
  +        mbeanInfo.addOperationInfo(new GeronimoOperationInfo("planDeployment",
  +                new GeronimoParameterInfo[] {
  +                    new GeronimoParameterInfo("Source", ObjectName.class.getName(), "Good question!"),
  +                    new GeronimoParameterInfo("URLInfos", Set.class.getName(), "Set of URLs to plan deployments for")
  +                },
  +                0,
  +                "plan the set of deployments"));
  +        mbeanInfo.addOperationInfo(new GeronimoOperationInfo("isDeployed",
  +                new GeronimoParameterInfo[] {
  +                    new GeronimoParameterInfo("URL", URL.class.getName(), "URL to test")
  +                },
  +                0,
  +                "Determine if the supplied URL is deployed"));
  +        mbeanInfo.addOperationInfo(new GeronimoOperationInfo("deploy",
  +                new GeronimoParameterInfo[] {
  +                    new GeronimoParameterInfo("URL", URL.class.getName(), "URL to deploy")
  +                },
  +                0,
  +                "Deploy the URL"));
  +        mbeanInfo.addOperationInfo(new GeronimoOperationInfo("undeploy",
  +                new GeronimoParameterInfo[] {
  +                    new GeronimoParameterInfo("URL", URL.class.getName(), "URL to undeploy")
  +                },
  +                0,
  +                "Undeploy the URL"));
  +        mbeanInfo.addEndpoint(new GeronimoMBeanEndpoint("Planners", DeploymentPlanner.class.getName(),
  +                ObjectName.getInstance("geronimo.deployment:role=DeploymentPlanner,*")));
  +        return mbeanInfo;
       }
   
       /**
  @@ -159,12 +150,15 @@
   
   
               if (!isDeployed(url)) {
  +                log.info("Considering undeployed url " + url);
                   //only add a new deployment goal if we don't already have one. One can already exist if
                   //there was no deployer available when the url was scanned
                   if ((lastScan == null) || ((lastScan != null) &&!lastScan.contains (urlInfo))){
  +                    log.info("Adding url goal for " + url);
                       goals.add(new DeployURL(url, urlInfo.getType()));
                   }
               } else {
  +                log.info("Redeploying url " + url);
                   goals.add(new RedeployURL(url));
               }
           }
  @@ -174,7 +168,7 @@
               for (Iterator i = lastScan.iterator(); i.hasNext();) {
                   URLInfo urlInfo = (URLInfo) i.next();
                   URL url = urlInfo.getUrl();
  -	       
  +
                   if (!urlInfos.contains(urlInfo) && isDeployed(url)) {
                       goals.add(new UndeployURL(url));
                   }
  @@ -203,7 +197,7 @@
       public boolean isDeployed(URL url) {
           try {
               ObjectName pattern = new ObjectName("*:role=DeploymentUnit,url=" + ObjectName.quote(url.toString()) + ",*");
  -            return !server.queryNames(pattern, null).isEmpty();
  +            return !context.getServer().queryNames(pattern, null).isEmpty();
           } catch (MalformedObjectNameException e) {
               throw new AssertionError();
           }
  @@ -254,15 +248,13 @@
   
       private void generatePlans() throws DeploymentException {
           try {
  -            List planners = relationService.getRole("DeploymentController-DeploymentPlanner", "DeploymentPlanner");
  -            Object[] args = {goals, plans};
  -            String[] types = {"java.util.Set", "java.util.Set"};
               while (true) {
                   boolean madeProgress = false;
                   for (Iterator i = planners.iterator(); i.hasNext();) {
  -                    ObjectName planner = (ObjectName) i.next();
  -                    Boolean progress = (Boolean) server.invoke(planner, "plan", args, types);
  -                    if (progress.booleanValue()) {
  +                    DeploymentPlanner planner = (DeploymentPlanner) i.next();
  +                    log.info("Talking to planner: " + planner);
  +                    boolean progress = planner.plan(goals, plans);
  +                    if (progress) {
                           madeProgress = true;
                       }
                   }
  @@ -311,5 +303,31 @@
                   plans.remove(plan);
               }
           }
  +    }
  +
  +    public void setPlanners(Collection planners) {
  +        System.out.println("Setting the planners collection to " + planners);
  +        this.planners = planners;
  +    }
  +
  +    public void setMBeanContext(GeronimoMBeanContext context) {
  +        this.context = context;
  +    }
  +
  +    public boolean canStart() {
  +        return true;
  +    }
  +
  +    public void doStart() {
  +    }
  +
  +    public boolean canStop() {
  +        return true;
  +    }
  +
  +    public void doStop() {
  +    }
  +
  +    public void doFail() {
       }
   }
  
  
  
  1.2       +4 -2      incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/deployment/DeploymentPlan.java
  
  Index: DeploymentPlan.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/deployment/DeploymentPlan.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DeploymentPlan.java	8 Sep 2003 04:38:33 -0000	1.1
  +++ DeploymentPlan.java	14 Nov 2003 16:27:34 -0000	1.2
  @@ -91,7 +91,9 @@
               log.trace("Checking if task can run " + task);
   
               // always check each task, so the task can throw an exception if the task can never run
  -            canRun = canRun && task.canRun();
  +            boolean thisCanRun = task.canRun();
  +            canRun = canRun && thisCanRun;
  +            log.trace("Answer: " + thisCanRun);
           }
           return canRun;
       }
  
  
  
  1.2       +1 -2      incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/deployment/DeploymentPlanner.java
  
  Index: DeploymentPlanner.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/deployment/DeploymentPlanner.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DeploymentPlanner.java	8 Sep 2003 04:38:33 -0000	1.1
  +++ DeploymentPlanner.java	14 Nov 2003 16:27:34 -0000	1.2
  @@ -59,7 +59,6 @@
   
   /**
    *
  - * @jmx:mbean
    *
    * @version $Revision$ $Date$
    */
  
  
  
  1.1                  incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/deployment/AbstractDeploymentPlanner.java
  
  Index: AbstractDeploymentPlanner.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Geronimo" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Geronimo", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  
  package org.apache.geronimo.kernel.deployment;
  
  import java.util.Set;
  import java.util.HashSet;
  import java.util.Iterator;
  
  import javax.management.MBeanServer;
  
  import org.apache.geronimo.kernel.service.GeronimoMBeanInfo;
  import org.apache.geronimo.kernel.service.GeronimoOperationInfo;
  import org.apache.geronimo.kernel.service.GeronimoParameterInfo;
  import org.apache.geronimo.kernel.service.GeronimoMBeanTarget;
  import org.apache.geronimo.kernel.service.GeronimoMBeanContext;
  import org.apache.geronimo.kernel.deployment.goal.DeploymentGoal;
  import org.apache.geronimo.kernel.deployment.goal.DeployURL;
  import org.apache.geronimo.kernel.deployment.goal.RedeployURL;
  import org.apache.geronimo.kernel.deployment.goal.UndeployURL;
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  
  /**
   *
   *
   * @version $REVISION$ Nov 13, 2003$
   *
   * */
  public abstract class AbstractDeploymentPlanner implements DeploymentPlanner, GeronimoMBeanTarget {
  
      private static final Log log = LogFactory.getLog(AbstractDeploymentPlanner.class);
  
      private GeronimoMBeanContext context;
  
      /**
       * Supply our own GeronimoMBeanInfo for xml-free deployment.
       * @return
       */
      public static GeronimoMBeanInfo getGeronimoMBeanInfo(String subclassName) {
          GeronimoMBeanInfo mbeanInfo = new GeronimoMBeanInfo();
          mbeanInfo.setTargetClass(subclassName);
          mbeanInfo.addOperationInfo(new GeronimoOperationInfo("plan",
                  new GeronimoParameterInfo[] {
                      new GeronimoParameterInfo("Goals",
                              java.util.Set.class.getName(),
                              "Goals needing deployment"),
                      new GeronimoParameterInfo("Plans",
                              java.util.Set.class.getName(),
                              "Deployment plans to add to")
                  },
                  0,
                  "Plan to deploy as many goals as possible"));
  
          return mbeanInfo;
      }
  
  
      public boolean plan(Set goals, Set plans) throws DeploymentException {
          log.info(context.getObjectName().toString() + " Got to plan method with goals " + goals);
          boolean progress = false;
          Set x = new HashSet(goals);
          for (Iterator i = x.iterator(); i.hasNext();) {
              DeploymentGoal goal = (DeploymentGoal) i.next();
              log.info("Considering goal " + goal + " by planner " + context.getObjectName());
              if (goal instanceof DeployURL) {
                  progress = addURL((DeployURL) goal, goals, plans);
              } else if (goal instanceof RedeployURL) {
                  progress = redeployURL((RedeployURL) goal, goals);
              } else if (goal instanceof UndeployURL) {
                  progress = removeURL((UndeployURL) goal, goals, plans);
              }
          }
          return progress;
      }
  
      protected abstract boolean addURL(DeployURL deployURL, Set goals, Set plans) throws DeploymentException;
  
      protected abstract boolean redeployURL(RedeployURL redeployURL, Set goals) throws DeploymentException;
  
      protected abstract boolean removeURL(UndeployURL undeployURL, Set goals, Set plans) throws DeploymentException;
  
  
      public void setMBeanContext(GeronimoMBeanContext context) {
          this.context = context;
      }
  
      public boolean canStart() {
          return true;
      }
  
      public void doStart() {
      }
  
      public boolean canStop() {
          return true;
      }
  
      public void doStop() {
      }
  
      public void doFail() {
      }
  
      protected MBeanServer getServer() {
          return context.getServer();
      }
  
  }
  
  
  
  1.2       +90 -23    incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/deployment/scanner/DeploymentScanner.java
  
  Index: DeploymentScanner.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/deployment/scanner/DeploymentScanner.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DeploymentScanner.java	8 Sep 2003 04:38:33 -0000	1.1
  +++ DeploymentScanner.java	14 Nov 2003 16:27:34 -0000	1.2
  @@ -65,6 +65,7 @@
   import java.util.Iterator;
   import java.util.Map;
   import java.util.Set;
  +
   import javax.management.MBeanServer;
   import javax.management.ObjectName;
   import javax.management.relation.RelationServiceMBean;
  @@ -73,24 +74,71 @@
   import org.apache.commons.logging.LogFactory;
   import org.apache.geronimo.kernel.jmx.JMXUtil;
   import org.apache.geronimo.kernel.service.AbstractManagedObject;
  +import org.apache.geronimo.kernel.service.GeronimoMBeanInfo;
  +import org.apache.geronimo.kernel.service.GeronimoAttributeInfo;
  +import org.apache.geronimo.kernel.service.GeronimoOperationInfo;
  +import org.apache.geronimo.kernel.service.GeronimoParameterInfo;
  +import org.apache.geronimo.kernel.service.GeronimoMBeanEndpoint;
  +import org.apache.geronimo.kernel.service.GeronimoMBeanTarget;
  +import org.apache.geronimo.kernel.service.GeronimoMBeanContext;
  +import org.apache.geronimo.kernel.deployment.DeploymentController;
   
   /**
    * An MBean that maintains a list of URLs and periodically invokes a Scanner
    * to search them for deployments.
    *
  - * @jmx:mbean
  - *      extends="org.apache.geronimo.kernel.management.StateManageable,org.apache.geronimo.kernel.management.ManagedObject"
  - *
    * @version $Revision$ $Date$
    */
  -public class DeploymentScanner extends AbstractManagedObject implements DeploymentScannerMBean {
  +public class DeploymentScanner implements GeronimoMBeanTarget {
  +
       private static final Log log = LogFactory.getLog(DeploymentScanner.class);
   
  -    private RelationServiceMBean relationService;
  +    private GeronimoMBeanContext context;
  +
       private final Map scanners = new HashMap();
       private long scanInterval;
       private boolean run;
       private Thread scanThread;
  +    private DeploymentController deploymentController;
  +
  +    public static GeronimoMBeanInfo getGeronimoMBeanInfo() throws Exception {
  +        GeronimoMBeanInfo mbeanInfo = new GeronimoMBeanInfo();
  +        mbeanInfo.setTargetClass(DeploymentScanner.class.getName());
  +        mbeanInfo.addAttributeInfo(new GeronimoAttributeInfo("ScanInterval",
  +                true, true,
  +                "Milliseconds between deployment scans"));
  +        mbeanInfo.addAttributeInfo(new GeronimoAttributeInfo("RecursiveURLs",
  +                false, true,
  +                "Array of URLs to scan recursively"));
  +        mbeanInfo.addAttributeInfo(new GeronimoAttributeInfo("NonRecursiveURLs",
  +                false, true,
  +                "Array of URLs to scan non-recursively"));
  +        mbeanInfo.addAttributeInfo(new GeronimoAttributeInfo("WatchedURLs",
  +                true, false,
  +                "Set of scanned URLs, without recursive information"));
  +        mbeanInfo.addOperationInfo(new GeronimoOperationInfo("addURL",
  +                new GeronimoParameterInfo[]{new GeronimoParameterInfo("URL", URL.class.getName(), "URL to scan"),
  +                                            new GeronimoParameterInfo("Recurse", "boolean", "Should subdirectories be scanned")},
  +                1,
  +                "Start scanning a single URL"));
  +        mbeanInfo.addOperationInfo(new GeronimoOperationInfo("removeURL",
  +                new GeronimoParameterInfo[]{new GeronimoParameterInfo("URL", URL.class.getName(), "URL to scan")},
  +                1,
  +                "Stop scanning a single URL"));
  +        mbeanInfo.addOperationInfo(new GeronimoOperationInfo("scanNow",
  +                new GeronimoParameterInfo[]{},
  +                1,
  +                "Scan all URLs now"));
  +        mbeanInfo.addEndpoint(new GeronimoMBeanEndpoint("DeploymentController",
  +                DeploymentController.class.getName(),
  +                ObjectName.getInstance("geronimo.deployment:role=DeploymentController"),
  +                true));
  +        return mbeanInfo;
  +    }
  +
  +    public void setDeploymentController(DeploymentController deploymentController) {
  +        this.deploymentController = deploymentController;
  +    }
   
       /**
        * @jmx:managed-constructor
  @@ -102,15 +150,15 @@
        * @jmx:managed-constructor
        */
       public DeploymentScanner(final URL[] urls, final boolean recurse) {
  +        addURLs(urls, recurse);
  +    }
  +
  +    private void addURLs(final URL[] urls, final boolean recurse) {
           for (int i = 0; i < urls.length; i++) {
               addURL(urls[i], recurse);
           }
       }
   
  -    public ObjectName preRegister(MBeanServer server, ObjectName objectName) throws Exception {
  -        relationService = JMXUtil.getRelationService(server);
  -        return super.preRegister(server, objectName);
  -    }
   
       /**
        * @jmx:managed-attribute
  @@ -126,6 +174,19 @@
           this.scanInterval = scanInterval;
       }
   
  +    public void setRecursiveURLs(URL[] urls) {
  +        if (urls != null) {
  +            addURLs(urls, true);
  +        }
  +    }
  +
  +
  +    public void setNonRecursiveURLs(URL[] urls) {
  +        if (urls != null) {
  +            addURLs(urls, false);
  +        }
  +    }
  +
       /**
        * @jmx:managed-attribute
        */
  @@ -186,10 +247,18 @@
           return run;
       }
   
  -    protected synchronized void doStart() throws Exception {
  +    public void setMBeanContext(GeronimoMBeanContext context) {
  +        this.context = context;
  +    }
  +
  +    public boolean canStart() {
  +        return true;
  +    }
  +
  +    public synchronized void doStart() {
           if (scanThread == null) {
               run = true;
  -            scanThread = new Thread("DeploymentScanner: ObjectName=" + objectName) {
  +            scanThread = new Thread("DeploymentScanner: ObjectName=" + context.getObjectName()) {
                   public void run() {
                       while (shouldScannerThreadRun()) {
                           scanNow();
  @@ -204,7 +273,11 @@
           }
       }
   
  -    protected synchronized void doStop() throws Exception {
  +    public boolean canStop() {
  +        return true;
  +    }
  +
  +    public synchronized void doStop() {
           run = false;
           if (scanThread != null) {
               scanThread.interrupt();
  @@ -212,6 +285,9 @@
           }
       }
   
  +    public void doFail() {
  +    }
  +
       /**
        * @jmx:managed-operation
        */
  @@ -242,16 +318,7 @@
           }
   
           try {
  -            Map controllers = relationService.findAssociatedMBeans(objectName, "DeploymentController-DeploymentScanner", "DeploymentScanner");
  -            log.trace("Found " + controllers.size() + " controller(s)");
  -            if (!controllers.isEmpty()) {
  -                Set set = controllers.keySet();
  -                ObjectName controller = (ObjectName) set.iterator().next();
  -                server.invoke(controller,
  -                        "planDeployment",
  -                        new Object[]{objectName, results},
  -                        new String[]{"javax.management.ObjectName", "java.util.Set"});
  -            }
  +            deploymentController.planDeployment(context.getObjectName(), results);
           } catch (Exception e) {
               log.error(e.getMessage(), e);
           }
  
  
  
  1.6       +39 -67    incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/deployment/service/ServiceDeploymentPlanner.java
  
  Index: ServiceDeploymentPlanner.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/deployment/service/ServiceDeploymentPlanner.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ServiceDeploymentPlanner.java	11 Nov 2003 04:39:08 -0000	1.5
  +++ ServiceDeploymentPlanner.java	14 Nov 2003 16:27:34 -0000	1.6
  @@ -64,6 +64,7 @@
   import java.util.Iterator;
   import java.util.List;
   import java.util.Set;
  +
   import javax.management.AttributeNotFoundException;
   import javax.management.InstanceNotFoundException;
   import javax.management.MBeanException;
  @@ -87,6 +88,8 @@
   import org.apache.geronimo.kernel.deployment.task.CreateClassSpace;
   import org.apache.geronimo.kernel.deployment.task.CreateMBeanInstance;
   import org.apache.geronimo.kernel.deployment.DeploymentPlan;
  +import org.apache.geronimo.kernel.deployment.DeploymentPlanner;
  +import org.apache.geronimo.kernel.deployment.AbstractDeploymentPlanner;
   import org.apache.geronimo.kernel.deployment.task.DestroyMBeanInstance;
   import org.apache.geronimo.kernel.deployment.task.InitializeMBeanInstance;
   import org.apache.geronimo.kernel.deployment.task.RegisterMBeanInstance;
  @@ -95,6 +98,11 @@
   import org.apache.geronimo.kernel.deployment.task.DeployGeronimoMBean;
   import org.apache.geronimo.kernel.jmx.JMXUtil;
   import org.apache.geronimo.kernel.service.GeronimoMBeanInfoXMLLoader;
  +import org.apache.geronimo.kernel.service.GeronimoMBeanTarget;
  +import org.apache.geronimo.kernel.service.GeronimoMBeanContext;
  +import org.apache.geronimo.kernel.service.GeronimoMBeanInfo;
  +import org.apache.geronimo.kernel.service.GeronimoOperationInfo;
  +import org.apache.geronimo.kernel.service.GeronimoParameterInfo;
   
   import org.w3c.dom.Document;
   import org.w3c.dom.Element;
  @@ -103,17 +111,24 @@
   /**
    * Plans deployment of MBean services.
    *
  - * @jmx:mbean extends="org.apache.geronimo.kernel.deployment.DeploymentPlanner"
    *
    * @version $Revision$ $Date$
    */
  -public class ServiceDeploymentPlanner implements ServiceDeploymentPlannerMBean, MBeanRegistration {
  -    private MBeanServer server;
  -    private ObjectName objectName;
  -    private RelationServiceMBean relationService;
  +public class ServiceDeploymentPlanner extends AbstractDeploymentPlanner {
  +
       private final DocumentBuilder parser;
       private final MBeanMetadataXMLLoader mbeanLoader;
   
  +    /**
  +     * Supply our own GeronimoMBeanInfo for xml-free deployment.
  +     * @return
  +     */
  +    public static GeronimoMBeanInfo getGeronimoMBeanInfo() {
  +        GeronimoMBeanInfo mbeanInfo = AbstractDeploymentPlanner.getGeronimoMBeanInfo(ServiceDeploymentPlanner.class.getName());
  +        mbeanInfo.setAutostart(true);
  +        return mbeanInfo;
  +    }
  +
       public ServiceDeploymentPlanner() throws DeploymentException {
           DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
           try {
  @@ -124,49 +139,8 @@
           mbeanLoader = new MBeanMetadataXMLLoader();
       }
   
  -    public ObjectName preRegister(MBeanServer mBeanServer, ObjectName objectName) throws Exception {
  -        this.server = mBeanServer;
  -        relationService = JMXUtil.getRelationService(server);
  -
  -        this.objectName = objectName;
  -        return objectName;
  -    }
  -
  -    public void postRegister(Boolean aBoolean) {
  -        try {
  -            List planners = relationService.getRole("DeploymentController-DeploymentPlanner", "DeploymentPlanner");
  -            planners.add(objectName);
  -            relationService.setRole("DeploymentController-DeploymentPlanner", new Role("DeploymentPlanner", planners));
  -        } catch (Exception e) {
  -            IllegalStateException e1 = new IllegalStateException();
  -            e1.initCause(e);
  -            throw e1;
  -        }
  -    }
  -
  -    public void preDeregister() throws Exception {
  -    }
  -
  -    public void postDeregister() {
  -    }
  -
  -    public boolean plan(Set goals, Set plans) throws DeploymentException {
  -        boolean progress = false;
  -        Set x = new HashSet(goals);
  -        for (Iterator i = x.iterator(); i.hasNext();) {
  -            DeploymentGoal goal = (DeploymentGoal) i.next();
  -            if (goal instanceof DeployURL) {
  -                progress = addURL((DeployURL) goal, goals, plans);
  -            } else if (goal instanceof RedeployURL) {
  -                progress = verifyURL((RedeployURL) goal, goals);
  -            } else if (goal instanceof UndeployURL) {
  -                progress = removeURL((UndeployURL) goal, goals, plans);
  -            }
  -        }
  -        return progress;
  -    }
   
  -    private boolean addURL(DeployURL goal, Set goals, Set plans) throws DeploymentException {
  +    protected boolean addURL(DeployURL goal, Set goals, Set plans) throws DeploymentException {
           InputStream is;
           URL url = goal.getUrl();
           URI baseURI = URI.create(url.toString()).normalize();
  @@ -209,13 +183,13 @@
               throw new DeploymentException(e);
           }
           ServiceDeployment serviceInfo = new ServiceDeployment(deploymentName, null, url);
  -        createDeploymentUnitPlan.addTask(new RegisterMBeanInstance(server, deploymentName, serviceInfo));
  +        createDeploymentUnitPlan.addTask(new RegisterMBeanInstance(getServer(), deploymentName, serviceInfo));
           MBeanMetadata metadata = new MBeanMetadata(deploymentName);
  -        createDeploymentUnitPlan.addTask(new StartMBeanInstance(server, metadata));
  +        createDeploymentUnitPlan.addTask(new StartMBeanInstance(getServer(), metadata));
   
           // add a plan to create a class space
           ClassSpaceMetadata md = createClassSpaceMetadata((Element) doc.getElementsByTagName("class-space").item(0), deploymentName, url);
  -        createDeploymentUnitPlan.addTask(new CreateClassSpace(server, md));
  +        createDeploymentUnitPlan.addTask(new CreateClassSpace(getServer(), md));
           plans.add(createDeploymentUnitPlan);
           ObjectName loaderName = md.getName();
   
  @@ -225,24 +199,21 @@
   
               Element mbeanElement = (Element) nl.item(i);
               metadata = mbeanLoader.loadXML(baseURI, mbeanElement);
  -            if (server.isRegistered(metadata.getName())) {
  +            if (getServer().isRegistered(metadata.getName())) {
                   throw new DeploymentException("MBean already exists " + metadata.getName());
               }
               metadata.setLoaderName(loaderName);
               metadata.setParentName(deploymentName);
               metadata.setBaseURI(baseURI);
  +            DeploymentPlan createPlan = new DeploymentPlan();
               if (metadata.isGeronimoMBean()) {
  -                plans.add(new DeploymentPlan(new DeployGeronimoMBean(server, metadata)));
  +                createPlan.addTask(new DeployGeronimoMBean(getServer(), metadata));
               } else {
  -                DeploymentPlan createPlan = new DeploymentPlan();
  -                CreateMBeanInstance createTask = new CreateMBeanInstance(server, metadata);
  -                createPlan.addTask(createTask);
  -                InitializeMBeanInstance initTask = new InitializeMBeanInstance(server, metadata);
  -                createPlan.addTask(initTask);
  -                StartMBeanInstance startTask = new StartMBeanInstance(server, metadata);
  -                createPlan.addTask(startTask);
  -                plans.add(createPlan);
  +                createPlan.addTask(new CreateMBeanInstance(getServer(), metadata));
               }
  +            createPlan.addTask(new InitializeMBeanInstance(getServer(), metadata));
  +            createPlan.addTask(new StartMBeanInstance(getServer(), metadata));
  +            plans.add(createPlan);
   
           }
   
  @@ -272,7 +243,7 @@
           return classSpaceMetadata;
       }
   
  -    private boolean removeURL(UndeployURL goal, Set goals, Set plans) throws DeploymentException {
  +    protected boolean removeURL(UndeployURL goal, Set goals, Set plans) throws DeploymentException {
   
           URL url = goal.getUrl();
   
  @@ -296,7 +267,7 @@
   
           Collection mbeans;
           try {
  -            mbeans = (Collection) server.getAttribute(deploymentName, "Children");
  +            mbeans = (Collection) getServer().getAttribute(deploymentName, "Children");
           } catch (InstanceNotFoundException e) {
               return false;
           } catch (AttributeNotFoundException e) {
  @@ -309,18 +280,18 @@
   
           // Stop the main deployment which stopps all dependents including its children
           DeploymentPlan stopPlan = new DeploymentPlan();
  -        stopPlan.addTask(new StopMBeanInstance(server, deploymentName));
  +        stopPlan.addTask(new StopMBeanInstance(getServer(), deploymentName));
           plans.add(stopPlan);
   
           // Plan the destruction of all the children and then the deployment
           DeploymentPlan destroyPlan = new DeploymentPlan();
           for (Iterator i = mbeans.iterator(); i.hasNext();) {
               ObjectName name = (ObjectName) i.next();
  -            destroyPlan.addTask(new DestroyMBeanInstance(server, name));
  +            destroyPlan.addTask(new DestroyMBeanInstance(getServer(), name));
   
           }
   
  -        destroyPlan.addTask(new DestroyMBeanInstance(server, deploymentName));
  +        destroyPlan.addTask(new DestroyMBeanInstance(getServer(), deploymentName));
           plans.add(destroyPlan);
   
           goals.remove(goal);
  @@ -328,7 +299,7 @@
           return true;
       }
   
  -    private boolean verifyURL(RedeployURL goal, Set goals) throws DeploymentException {
  +    protected boolean redeployURL(RedeployURL goal, Set goals) throws DeploymentException {
           URL url = goal.getUrl();
           try {
               new ObjectName("geronimo.deployment:role=DeploymentUnit,type=Service,url=" + ObjectName.quote(url.toString()));
  @@ -338,4 +309,5 @@
           goals.remove(goal);
           return true;
       }
  +
   }
  
  
  
  1.6       +6 -2      incubator-geronimo/modules/web/src/deploy/jetty/jetty-service.xml
  
  Index: jetty-service.xml
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/web/src/deploy/jetty/jetty-service.xml,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- jetty-service.xml	8 Nov 2003 04:25:27 -0000	1.5
  +++ jetty-service.xml	14 Nov 2003 16:27:34 -0000	1.6
  @@ -18,16 +18,20 @@
       <!-- ================================================================ -->
       <!-- Set up a Jetty container                                         -->
       <!-- ================================================================ -->
  -    <mbean code="org.apache.geronimo.web.jetty.JettyWebContainer" 
  +    <mbean code="org.apache.geronimo.web.jetty.JettyWebContainer"
              name="jetty:role=WebContainer">
          <attribute type="java.net.URI" name="DefaultWebXmlURI">webdefault.xml</attribute>
       </mbean>
  +<!-- planner that delegates to the mbean above -->
  +    <mbean descriptor="org.apache.geronimo.web.WebDeploymentPlanner"
  +           name="geronimo.deployment:role=DeploymentPlanner,type=Jetty">
  +    </mbean>
   
   
       <!-- ================================================================ -->
       <!-- Set up a connector to listen for http requests                   -->
       <!-- ================================================================ -->
  -    <mbean code="org.apache.geronimo.web.jetty.JettyWebConnector" 
  +    <mbean code="org.apache.geronimo.web.jetty.JettyWebConnector"
              name="jetty:role=WebConnector, port=8080">
           <attribute name="Port">8080</attribute>
   	<attribute name="Contexts">/abc, /def, /geh</attribute>
  
  
  
  1.14      +65 -153   incubator-geronimo/modules/web/src/java/org/apache/geronimo/web/AbstractWebContainer.java
  
  Index: AbstractWebContainer.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/web/src/java/org/apache/geronimo/web/AbstractWebContainer.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- AbstractWebContainer.java	11 Nov 2003 16:41:23 -0000	1.13
  +++ AbstractWebContainer.java	14 Nov 2003 16:27:34 -0000	1.14
  @@ -107,8 +107,8 @@
    * AbstractWebContainer
    *
    * Base class for web containers in Geronimo.  Integrations of existing web containers
  - * such as Jetty, Tomcat et al need, in general, to subclass this class. 
  - * 
  + * such as Jetty, Tomcat et al need, in general, to subclass this class.
  + *
    * The AbstractWebContainer provides the ability for concrete subclasses to
    * able to deploy web applications by registering as a DeploymentPlanner
    * with the Relationship service. This causes the DeploymentController to pass
  @@ -117,8 +117,8 @@
    * 1. the url is a packed jar whose name ends in .war and contains a WEB-INF/web.xml file
    * or
    * 2. the url is a directory which contains a WEB-INF/web.xml file
  - * 
  - * @jmx:mbean extends="org.apache.geronimo.kernel.deployment.DeploymentPlanner, org.apache.geronimo.web.WebContainer, org.apache.geronimo.kernel.management.StateManageable, javax.management.MBeanRegistration" 
  + *
  + * @jmx:mbean extends="org.apache.geronimo.web.WebContainer, org.apache.geronimo.kernel.management.StateManageable, javax.management.MBeanRegistration"
    * @version $Revision$ $Date$
    */
   public abstract class AbstractWebContainer
  @@ -137,10 +137,10 @@
        * Parsed default web.xml
        */
       private Document defaultWebXmlDoc = null;
  -    
  +
       //this should move down to AbstractContainer
       private Map webAppMap = new HashMap();
  -    
  +
   
   
       /* -------------------------------------------------------------------------------------- */
  @@ -151,67 +151,6 @@
       }
   
       /* -------------------------------------------------------------------------------------- */
  -    /** Get our mbean name from a pre-registration call.
  -     * @param mBeanServer a <code>MBeanServer</code> value
  -     * @param objectName an <code>ObjectName</code> value
  -     * @return an <code>ObjectName</code> value
  -     * @exception Exception if an error occurs
  -     */
  -    public ObjectName preRegister(MBeanServer server, ObjectName objectName)
  -        throws Exception
  -    {
  -        return super.preRegister(server, objectName);
  -    }
  -
  -    /* -------------------------------------------------------------------------------------- */
  -    /**Establish this webcontainer as a deployment planner.
  -     *
  -     * @param aBoolean a <code>Boolean</code> value
  -     */
  -    public void postRegister(Boolean aBoolean)
  -    {
  -        try
  -        {
  -            super.postRegister(aBoolean);
  -            List planners =
  -                relationService.getRole(
  -                    "DeploymentController-DeploymentPlanner",
  -                    "DeploymentPlanner");
  -
  -            planners.add(objectName);
  -            relationService.setRole(
  -                "DeploymentController-DeploymentPlanner",
  -                new Role("DeploymentPlanner", planners));
  -            log.trace(
  -                "Registered WebContainer  "
  -                    + getObjectName()
  -                    + " as a DeploymentPlanner");
  -        }
  -        catch (Exception e)
  -        {
  -            IllegalStateException e1 = new IllegalStateException();
  -            e1.initCause(e);
  -            throw e1;
  -        }
  -    }
  -
  -    /* -------------------------------------------------------------------------------------- */
  -    /**Webcontainer is about to be deregistered from the mbean server.
  -     * 
  -     * @exception Exception if an error occurs
  -     */
  -    public void preDeregister() throws Exception
  -    {
  -    }
  -
  -    /* -------------------------------------------------------------------------------------- */
  -    /**Webcontainer has been deregistered from mbean server
  -     */
  -    public void postDeregister()
  -    {
  -    }
  -
  -    /* -------------------------------------------------------------------------------------- */
       /**Monitor JMX notifications
        * When a web layer object such as a WebConnector, a WebAccessLog
        * or a WebApplication is registered in JMX, then set up the containment
  @@ -271,43 +210,10 @@
   
           super.handleNotification(n, o);
       }
  -    
  -    
  -    /* -------------------------------------------------------------------------------------- */
  -    /**Plan a deployment
  -     * This is called by the DeploymentController when there is
  -     * something to be deployed/redeployed/undeployed.
  -     *
  -     * @param goals a <code>Set</code> value
  -     * @param plans a <code>Set</code> value
  -     * @return a <code>boolean</code> value
  -     * @exception DeploymentException if an error occurs
  -     */
  -    public boolean plan(Set goals, Set plans) throws DeploymentException
  -    {
  -        boolean progress = false;
  -        Set x = new HashSet(goals);
  -        for (Iterator i = x.iterator(); i.hasNext();)
  -        {
  -            DeploymentGoal goal = (DeploymentGoal) i.next();
  -            if (goal instanceof DeployURL)
  -            {
  -                progress = deploy((DeployURL) goal, goals, plans);
  -            }
  -            else if (goal instanceof RedeployURL)
  -            {
  -                progress = redeploy((RedeployURL) goal, goals);
  -            }
  -            else if (goal instanceof UndeployURL)
  -            {
  -                progress = remove((UndeployURL) goal, goals, plans);
  -            }
  -        }
  -        return progress;
  -    }
   
   
  -    /* -------------------------------------------------------------------------------------- */ 
  +
  +    /* -------------------------------------------------------------------------------------- */
       /**Something to be deployed.
        * We will deploy it if it looks and smells like a webapp. That is, it
        * is either a packed war with a ".war" suffix or a directory, and
  @@ -318,6 +224,8 @@
        * @param plans a <code>Set</code> value
        * @return a <code>boolean</code> value
        * @exception DeploymentException if an error occurs
  +     *
  +     * @jmx.managed-operation
        */
       public boolean deploy(DeployURL goal, Set goals, Set plans)
           throws DeploymentException
  @@ -392,34 +300,34 @@
           }
           else if (type == URLType.RESOURCE)
           {
  -            //we will try and deploy a WEB-INF/web.xml by looking for the parent directory 
  +            //we will try and deploy a WEB-INF/web.xml by looking for the parent directory
                if (!url.getPath().endsWith("web.xml"))
                    return false;
   
               try
               {
                   File file = new File (url.toExternalForm());
  -                
  +
                   if (!file.exists())
                       throw new DeploymentException ("No such file:"+url);
  -                    
  +
                   File parent = file.getParentFile();
                   if (!parent.getName().equals("WEB-INF"))
                       throw new DeploymentException ("web.xml must be in WEB-INF directory");
  -                
  -                // find the parent dir of WEB-INF and try to deploy that    
  -                parent = parent.getParentFile();         
  +
  +                // find the parent dir of WEB-INF and try to deploy that
  +                parent = parent.getParentFile();
                   url = parent.toURL();
               }
               catch (NullPointerException e)
               {
  -                 throw new DeploymentException ("No path to web.xml file", e);       
  +                 throw new DeploymentException ("No path to web.xml file", e);
               }
               catch (MalformedURLException e)
               {
                   throw new DeploymentException ("Bad url for possible webapp directory", e);
               }
  -            
  +
           }
           else
           {
  @@ -429,7 +337,7 @@
   
           log.debug("Identified webapp to deploy");
   
  -        //check to see if there is already a deployment for the  webapp 
  +        //check to see if there is already a deployment for the  webapp
           ObjectName deploymentName = null;
           try
           {
  @@ -447,7 +355,7 @@
               throw new DeploymentException( "A web application deployment is already registered at:"
                                                                         + deploymentName.toString());
   
  -        //Deploy the deployment unit itself. This registers an mbean for the deployment unit, 
  +        //Deploy the deployment unit itself. This registers an mbean for the deployment unit,
           //so we wind up with an mbean for the deployment of the webapp, as well as one for
           //the webapp itself.
           DeploymentPlan deploymentUnitPlan = new DeploymentPlan();
  @@ -461,7 +369,7 @@
               new StartMBeanInstance(server, deploymentUnitMetadata));
           plans.add(deploymentUnitPlan);
   
  -        
  +
           //Create a webapp typed to the concrete type of the web container
           WebApplication webapp = createWebApplication(baseURI);
           ObjectName webappName;
  @@ -517,21 +425,23 @@
   
       /* -------------------------------------------------------------------------------------- */
       /**Remove the deployment of a webapp.
  -     * 
  +     *
        * @param goal
        * @param goals
        * @param plans
        * @return
        * @throws DeploymentException
  +     *
  +     * @jmx.managed-operation
        */
  -    private boolean remove(UndeployURL goal, Set goals, Set plans)
  +    public boolean remove(UndeployURL goal, Set goals, Set plans)
           throws DeploymentException
       {
           //work out what the name of the deployment would be, assuming it is a webapp
           URL url = goal.getUrl();
  -        
  +
           log.debug ("WebContainer "+getObjectName()+" checking for removal of "+url);
  -       
  +
           ObjectName deploymentName = null;
            try
            {
  @@ -552,28 +462,28 @@
               log.debug ("No deployment registered at: "+deploymentName);
               return false;
           }
  -            
  +
           log.debug ("Deployment is registered");
  -        
  +
           //It is a webapp, and it is registered, so we should maybe undeploy it
           //so find out if it was in fact us that deployed it (could have been a different web container)
           Collection deploymentChildren = null;
  -      
  +
           deploymentChildren = dependencyService.getStartChildren(deploymentName);
  -         
  +
           List webapps = new ArrayList();
  -        
  +
           log.debug ("there are "+deploymentChildren.size()+" children" );
  -        
  +
           Iterator itor = deploymentChildren.iterator();
           try
           {
               while (itor.hasNext())
               {
                   ObjectName childName = (ObjectName) itor.next();
  -           
  +
                       if (server.isInstanceOf(childName, WebApplication.class.getName())
  -                         && 
  +                         &&
                            (server.getAttribute(childName, "Container") == this))
                       {
                           log.debug ("Adding webapp for removal: "+ childName);
  @@ -591,41 +501,41 @@
           {
               throw new DeploymentException (e);
           }
  -              
  +
   
           if (webapps.isEmpty())
           {
               //we didn't deploy anything so nothing for us to do
               return false;
           }
  -     
  +
           //we have webapps to undeploy, so check if we are able to
           if (getStateInstance() != State.RUNNING)
              throw new DeploymentException ("WebContainer "+getObjectName()+" cannot undeploy webapps because it is not RUNNING");
  -    
  -        //put in a stoptask for the deployment unit, which will also stop the webapp(s) 
  +
  +        //put in a stoptask for the deployment unit, which will also stop the webapp(s)
           //because of the dependency between them
           DeploymentPlan stopPlan = new DeploymentPlan();
           stopPlan.addTask(new StopMBeanInstance(server, deploymentName));
           plans.add(stopPlan);
  -                                      
  +
           //destroy each of the webapps
  -        DeploymentPlan removePlan = new DeploymentPlan();       
  -        
  +        DeploymentPlan removePlan = new DeploymentPlan();
  +
           itor = webapps.iterator();
           while (itor.hasNext())
           {
               //unregister it
               ObjectName webappName = (ObjectName)itor.next();
               removePlan.addTask (new DestroyMBeanInstance (server, webappName));
  -            
  -            //now remove it from the container          
  -            removePlan.addTask (new RemoveWebApplication (server, this, (WebApplication)webAppMap.get(webappName.toString())));          
  +
  +            //now remove it from the container
  +            removePlan.addTask (new RemoveWebApplication (server, this, (WebApplication)webAppMap.get(webappName.toString())));
           }
   
           //unregister the deployment itself
           removePlan.addTask(new DestroyMBeanInstance(server, deploymentName));
  -        
  +
           plans.add (removePlan);
           goals.remove(goal);
           return true;
  @@ -636,7 +546,7 @@
   
       /* -------------------------------------------------------------------------------------- */
       /**Handle a redeployment.
  -     * 
  +     *
        * This is going to be tricky, as I believe the Scanner just always
        * inserts a redeploy goal if it scans the directory and finds the same
        * url as was there previously - I don't think it is checking the timestamps.
  @@ -644,8 +554,10 @@
        * @param goals
        * @return
        * @throws DeploymentException
  +     *
  +     * @jmx.managed-operation
        */
  -    private boolean redeploy(RedeployURL goal, Set goals)
  +    public boolean redeploy(RedeployURL goal, Set goals)
           throws DeploymentException
       {
           //TODO
  @@ -654,7 +566,7 @@
       }
   
   
  -    /* -------------------------------------------------------------------------------------- */ 
  +    /* -------------------------------------------------------------------------------------- */
       /**Create a WebApplication suitable to the container's type.
        * @return WebApplication instance, preferably derived from AbstractWebApplication suitable to the container
        */
  @@ -663,7 +575,7 @@
   
   
   
  -    /* -------------------------------------------------------------------------------------- */ 
  +    /* -------------------------------------------------------------------------------------- */
       /**Get the URI of the web defaults.
        * @return the location of the default web.xml file for this container
        */
  @@ -674,7 +586,7 @@
   
   
   
  -    /* -------------------------------------------------------------------------------------- */ 
  +    /* -------------------------------------------------------------------------------------- */
       /** Set a uri of a web.xml containing defaults for this container.
         * @param uri the location of the default web.xml file
        */
  @@ -685,7 +597,7 @@
       }
   
   
  -    /* -------------------------------------------------------------------------------------- */ 
  +    /* -------------------------------------------------------------------------------------- */
       /** Get the parsed web defaults
        *
        * @return
  @@ -697,7 +609,7 @@
   
   
   
  -    /* -------------------------------------------------------------------------------------- */ 
  +    /* -------------------------------------------------------------------------------------- */
       /**
        * Get a webapp context path from its uri
        *
  @@ -722,7 +634,7 @@
       }
   
   
  -    /* -------------------------------------------------------------------------------------- */ 
  +    /* -------------------------------------------------------------------------------------- */
       /**
        * Parse the web defaults descriptor
        * @throws Exception
  @@ -736,7 +648,7 @@
       }
   
   
  -    /* -------------------------------------------------------------------------------------- */ 
  +    /* -------------------------------------------------------------------------------------- */
       /**
        * Add a component to this container's containment hierarchy
        * @see org.apache.geronimo.core.service.Container#addComponent(org.apache.geronimo.core.service.Component)
  @@ -759,7 +671,7 @@
           }
       }
   
  -    /* -------------------------------------------------------------------------------------- */ 
  +    /* -------------------------------------------------------------------------------------- */
       /**
        *  Remove a component from this container's hierarchy
        * @see org.apache.geronimo.core.service.Container#removeComponent(org.apache.geronimo.core.service.Component)
  @@ -779,7 +691,7 @@
       }
   
   
  -    /* -------------------------------------------------------------------------------------- */ 
  +    /* -------------------------------------------------------------------------------------- */
       /**
        * Method called by addComponent after a WebConnector has been added.
        * @param connector
  @@ -789,7 +701,7 @@
   
       }
   
  -    /* -------------------------------------------------------------------------------------- */ 
  +    /* -------------------------------------------------------------------------------------- */
       /**
        * Method called by addComponment after a WebApplication has been added.
        * @param app
  @@ -799,7 +711,7 @@
           webAppMap.put(((AbstractWebApplication)app).getObjectName(), app);
       }
   
  -    /* -------------------------------------------------------------------------------------- */ 
  +    /* -------------------------------------------------------------------------------------- */
       /**
        * @param log
        */
  @@ -807,7 +719,7 @@
       {
       }
   
  -    /* -------------------------------------------------------------------------------------- */ 
  +    /* -------------------------------------------------------------------------------------- */
       /**
        * Method called by removeComponent before a WebConnector has been removed.
        * @param connector
  @@ -816,7 +728,7 @@
       {
       }
   
  -    /* -------------------------------------------------------------------------------------- */ 
  +    /* -------------------------------------------------------------------------------------- */
       /**
        * Method called by removeComponment before a WebApplication has been removed.
        * @param app
  @@ -826,7 +738,7 @@
           webAppMap.remove (((AbstractWebApplication)app).getObjectName());
       }
   
  -    /* -------------------------------------------------------------------------------------- */ 
  +    /* -------------------------------------------------------------------------------------- */
       /**
        * Remove an access log service from the container
        * @param log
  
  
  
  1.1                  incubator-geronimo/modules/web/src/java/org/apache/geronimo/web/WebDeploymentPlanner.java
  
  Index: WebDeploymentPlanner.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Geronimo" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Geronimo", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  
  package org.apache.geronimo.web;
  
  import java.util.Set;
  
  import javax.management.ObjectName;
  
  import org.apache.geronimo.kernel.deployment.AbstractDeploymentPlanner;
  import org.apache.geronimo.kernel.deployment.DeploymentException;
  import org.apache.geronimo.kernel.deployment.goal.DeployURL;
  import org.apache.geronimo.kernel.deployment.goal.RedeployURL;
  import org.apache.geronimo.kernel.deployment.goal.UndeployURL;
  import org.apache.geronimo.kernel.service.GeronimoMBeanInfo;
  import org.apache.geronimo.kernel.service.GeronimoMBeanEndpoint;
  
  /**
   *
   *
   * @version $Revision: 1.1 $ $Date: 2003/11/14 16:27:34 $
   *
   * */
  public class WebDeploymentPlanner extends AbstractDeploymentPlanner {
      /**
       * We delegate to this guy pending refactoring
       */
      private AbstractWebContainer webContainer;
  
      public static GeronimoMBeanInfo getGeronimoMBeanInfo() throws Exception {
          GeronimoMBeanInfo mbeanInfo = AbstractDeploymentPlanner.getGeronimoMBeanInfo(WebDeploymentPlanner.class.getName());
          mbeanInfo.addEndpoint(new GeronimoMBeanEndpoint("WebContainer",
                  AbstractWebContainer.class.getName(),
                  ObjectName.getInstance("jetty:role=WebContainer"), //hard coded for now...
                  true));
          return mbeanInfo;
      }
  
      public void setWebContainer(AbstractWebContainer webContainer) {
          this.webContainer = webContainer;
      }
  
      protected boolean addURL(DeployURL deployURL, Set goals, Set plans) throws DeploymentException {
          return webContainer.deploy(deployURL, goals, plans);
      }
  
      protected boolean redeployURL(RedeployURL redeployURL, Set goals) throws DeploymentException {
          return webContainer.redeploy(redeployURL, goals);
      }
  
      protected boolean removeURL(UndeployURL undeployURL, Set goals, Set plans) throws DeploymentException {
          return webContainer.remove(undeployURL, goals, plans);
      }
  }