You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bi...@apache.org on 2004/08/04 08:48:07 UTC

cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup HostConfig.java mbeans-descriptors.xml

billbarker    2004/08/03 23:48:07

  Modified:    catalina/src/share/org/apache/catalina/startup
                        HostConfig.java mbeans-descriptors.xml
  Log:
  Adding methods for JMX managed Contexts.
  
  -- Adding method to get the configBase via JMX
  -- Adding methods to add and remove apps with minimal dependancy checks.  This is for use with JMX apps (like the admin) that control the Context themselves.
  
  Revision  Changes    Path
  1.43      +74 -3     jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup/HostConfig.java
  
  Index: HostConfig.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup/HostConfig.java,v
  retrieving revision 1.42
  retrieving revision 1.43
  diff -u -r1.42 -r1.43
  --- HostConfig.java	28 Jul 2004 10:30:10 -0000	1.42
  +++ HostConfig.java	4 Aug 2004 06:48:07 -0000	1.43
  @@ -422,6 +422,13 @@
   
       }
   
  +    /**
  +     * Get the name of the configBase.
  +     * For use with JMX management.
  +     */
  +    public String getConfigBaseName() {
  +        return configBase().getAbsolutePath();
  +    }
   
       /**
        * Given a context path, get the config file name.
  @@ -1133,8 +1140,72 @@
               deployApps(name);
           }
       }
  -    
  -    
  +
  +    /**
  +     * Add a new Context to be managed by us.
  +     * Entry point for the admin webapp, and other JMX Context controlers.
  +     */
  +    public void manageApp(Context context)  {    
  +
  +        String contextPath = context.getPath();
  +        
  +        if (deployed.containsKey(contextPath))
  +            return;
  +
  +        DeployedApplication deployedApp = new DeployedApplication(contextPath);
  +        
  +        // Add the associated docBase to the redeployed list if it's a WAR
  +        boolean isWar = false;
  +        if (context.getDocBase() != null) {
  +            File docBase = new File(context.getDocBase());
  +            if (!docBase.isAbsolute()) {
  +                docBase = new File(appBase(), context.getDocBase());
  +            }
  +            deployedApp.redeployResources.put(docBase.getAbsolutePath(),
  +                                          new Long(docBase.lastModified()));
  +            if (docBase.getAbsolutePath().toLowerCase().endsWith(".war")) {
  +                isWar = true;
  +            }
  +        }
  +        host.addChild(context);
  +        // Add the eventual unpacked WAR and all the resources which will be
  +        // watched inside it
  +        if (isWar && unpackWARs) {
  +            String name = null;
  +            String path = context.getPath();
  +            if (path.equals("")) {
  +                name = "ROOT";
  +            } else {
  +                if (path.startsWith("/")) {
  +                    name = path.substring(1);
  +                } else {
  +                    name = path;
  +                }
  +            }
  +            File docBase = new File(name);
  +            if (!docBase.isAbsolute()) {
  +                docBase = new File(appBase(), name);
  +            }
  +            deployedApp.redeployResources.put(docBase.getAbsolutePath(),
  +                        new Long(docBase.lastModified()));
  +            addWatchedResources(deployedApp, docBase.getAbsolutePath(), context);
  +        } else {
  +            addWatchedResources(deployedApp, null, context);
  +        }
  +        deployed.put(contextPath, deployedApp);
  +    }
  +
  +    /**
  +     * Remove a webapp from our control.
  +     * Entry point for the admin webapp, and other JMX Context controlers.
  +     */
  +    public void unmanageApp(String contextPath) {
  +        if(isServiced(contextPath)) {
  +            deployed.remove(contextPath);
  +            host.removeChild(host.findChild(contextPath));
  +        }
  +    }
  +
       // ----------------------------------------------------- Instance Variables
   
   
  
  
  
  1.4       +23 -0     jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup/mbeans-descriptors.xml
  
  Index: mbeans-descriptors.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup/mbeans-descriptors.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- mbeans-descriptors.xml	27 Jul 2004 07:17:21 -0000	1.3
  +++ mbeans-descriptors.xml	4 Aug 2004 06:48:07 -0000	1.4
  @@ -39,6 +39,11 @@
                  type="java.lang.String"
                  writeable="false"/>
   
  +    <attribute name="configBaseName"
  +               description="The base directory for Context configuration files"
  +               type="java.lang.String"
  +               writeable="false" />
  +
       <attribute name="configClass"
                  description="The Java class name of the Context configuration class we should use"
                  type="java.lang.String"/>
  @@ -74,6 +79,15 @@
                    type="java.lang.String"/>
       </operation>
   
  +    <operation name="manageApp"
  +               description="Add a web application managed externally"
  +               impact="ACTION"
  +               returnType="void">
  +      <parameter name="context"
  +                 description="Context to add"
  +                 type="org.apache.catalina.Context" />
  +    </operation>
  +
       <operation name="removeServiced"
                  description="Add a web application name to the serviced list"
                  impact="ACTION"
  @@ -81,6 +95,15 @@
         <parameter name="name"
                    description="Application name"
                    type="java.lang.String"/>
  +    </operation>
  +
  +    <operation name="unmanageApp"
  +               description="Remove a web application from checks"
  +               impact="ACTION"
  +               returnType="void">
  +      <parameter name="contextPath"
  +                 description="The application path"
  +                 type="java.lang.String" />
       </operation>
   
     </mbean>
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Re: cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup HostConfig.java mbeans-descriptors.xml

Posted by Bill Barker <wb...@wilshire.com>.
On add, there isn't a context.xml file (yet), and there is no particular
relationship between the Context path and the docBase.

On remove, it's not conditional on changing watched resources.


----- Original Message ----- 
From: "Remy Maucherat" <re...@apache.org>
To: "Tomcat Developers List" <to...@jakarta.apache.org>
Sent: Wednesday, August 04, 2004 2:40 AM
Subject: Re: cvs commit:
jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup
HostConfig.java mbeans-descriptors.xml


billbarker@apache.org wrote:

>billbarker    2004/08/03 23:48:07
>
>  Modified:    catalina/src/share/org/apache/catalina/startup
>                        HostConfig.java mbeans-descriptors.xml
>  Log:
>  Adding methods for JMX managed Contexts.
>
>  -- Adding method to get the configBase via JMX
>  -- Adding methods to add and remove apps with minimal dependancy checks.
This is for use with JMX apps (like the admin) that control the Context
themselves.
>
>
I don't quite see how this is any different from check(String name).

Rémy


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Re: cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup HostConfig.java mbeans-descriptors.xml

Posted by Remy Maucherat <re...@apache.org>.
Bill Barker wrote:

>The way that the admin works at the moment, any change you make only affects
>the currently running instance of Tomcat unless you hit the "Commit Changes"
>button.  With my patch, that doesn't change.  If I create the context.xml
>file when you do a "Create Context" action, then you will still have that
>Context defined next time Tomcat is started, even if you didn't do a "Commit
>Changes".  Even worse is that if I delete the context.xml file when you do a
>"Delete Context" action, then your Context is still gone the next time
>Tomcat is started.
>
>That being said, I'm +-0 on the issue as a whole (the admin is one of the
>first things I remove when installing Tomcat :).  I can change the admin to
>use check(String) if people think that admin should work like manager.
>However, I'm going to be without computer access through the weekend, so it
>will have to wait until next week.
>  
>
No, don't change it, it looks ok.

Rémy


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Re: cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup HostConfig.java mbeans-descriptors.xml

Posted by Bill Barker <wb...@wilshire.com>.
----- Original Message -----
From: "Remy Maucherat" <re...@apache.org>
To: "Tomcat Developers List" <to...@jakarta.apache.org>
Sent: Wednesday, August 04, 2004 12:19 PM
Subject: Re: cvs commit:
jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup
HostConfig.java mbeans-descriptors.xml


>Bill Barker wrote:
>
>>"Remy Maucherat" <re...@apache.org> wrote in message
>>news:4110AF0A.9000501@apache.org...
>>
>>
>>>billbarker@apache.org wrote:
>>>
>>>
>>>
>>>>billbarker    2004/08/03 23:48:07
>>>>
>>>> Modified:    catalina/src/share/org/apache/catalina/startup
>>>>                       HostConfig.java mbeans-descriptors.xml
>>>> Log:
>>>> Adding methods for JMX managed Contexts.
>>>>
>>>> -- Adding method to get the configBase via JMX
>>>> -- Adding methods to add and remove apps with minimal dependancy
>>>>
>>>>
>>checks.  This is for use with JMX apps (like the admin) that control the
>>Context themselves.
>>
>>
>>>>
>>>>
>>>I don't quite see how this is any different from check(String name).
>>>
>>>
>>>
>>
>>Well, for 'add', there isn't necessarily any context.xml file, and there
>>isn't necessarily any relationship between the Context path and docBase.
>>For 'remove', the remove is unconditional and doesn't require touching
>>resources that may have never existed.
>>
>>One alternative would be to have the admin webapp alway create context.xml
>>for the "Create Context" action, and delete it for the "Remove Context"
>>action.  However, this creates way more problems then it will ever solve
(at
>>least with the config as it is now).
>>
>>
>Yes, why not.
>
>To be perfectly honest, I envisioned that these manager/admin/etc would
>indeed create the needed context.xml file (or the folder or war in the
>docBase; you get the idea). The most important thing is that all
>deployment operations are fully handled by one component (otherwise, we
>fall back in the previous situation where the auto deployer doesn't talk
>to the deployer, which doesn't know about the manager webapp). The new
>methods don't change this, so it's not a problem.
>

The way that the admin works at the moment, any change you make only affects
the currently running instance of Tomcat unless you hit the "Commit Changes"
button.  With my patch, that doesn't change.  If I create the context.xml
file when you do a "Create Context" action, then you will still have that
Context defined next time Tomcat is started, even if you didn't do a "Commit
Changes".  Even worse is that if I delete the context.xml file when you do a
"Delete Context" action, then your Context is still gone the next time
Tomcat is started.

That being said, I'm +-0 on the issue as a whole (the admin is one of the
first things I remove when installing Tomcat :).  I can change the admin to
use check(String) if people think that admin should work like manager.
However, I'm going to be without computer access through the weekend, so it
will have to wait until next week.

>Rémy


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org



Re: cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup HostConfig.java mbeans-descriptors.xml

Posted by Remy Maucherat <re...@apache.org>.
Bill Barker wrote:

>"Remy Maucherat" <re...@apache.org> wrote in message
>news:4110AF0A.9000501@apache.org...
>  
>
>>billbarker@apache.org wrote:
>>
>>    
>>
>>>billbarker    2004/08/03 23:48:07
>>>
>>> Modified:    catalina/src/share/org/apache/catalina/startup
>>>                       HostConfig.java mbeans-descriptors.xml
>>> Log:
>>> Adding methods for JMX managed Contexts.
>>>
>>> -- Adding method to get the configBase via JMX
>>> -- Adding methods to add and remove apps with minimal dependancy
>>>      
>>>
>checks.  This is for use with JMX apps (like the admin) that control the
>Context themselves.
>  
>
>>>      
>>>
>>I don't quite see how this is any different from check(String name).
>>
>>    
>>
>
>Well, for 'add', there isn't necessarily any context.xml file, and there
>isn't necessarily any relationship between the Context path and docBase.
>For 'remove', the remove is unconditional and doesn't require touching
>resources that may have never existed.
>
>One alternative would be to have the admin webapp alway create context.xml
>for the "Create Context" action, and delete it for the "Remove Context"
>action.  However, this creates way more problems then it will ever solve (at
>least with the config as it is now).
>  
>
Yes, why not.

To be perfectly honest, I envisioned that these manager/admin/etc would 
indeed create the needed context.xml file (or the folder or war in the 
docBase; you get the idea). The most important thing is that all 
deployment operations are fully handled by one component (otherwise, we 
fall back in the previous situation where the auto deployer doesn't talk 
to the deployer, which doesn't know about the manager webapp). The new 
methods don't change this, so it's not a problem.

Rémy


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Re: cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup HostConfig.java mbeans-descriptors.xml

Posted by Bill Barker <wb...@wilshire.com>.
"Remy Maucherat" <re...@apache.org> wrote in message
news:4110AF0A.9000501@apache.org...
> billbarker@apache.org wrote:
>
> >billbarker    2004/08/03 23:48:07
> >
> >  Modified:    catalina/src/share/org/apache/catalina/startup
> >                        HostConfig.java mbeans-descriptors.xml
> >  Log:
> >  Adding methods for JMX managed Contexts.
> >
> >  -- Adding method to get the configBase via JMX
> >  -- Adding methods to add and remove apps with minimal dependancy
checks.  This is for use with JMX apps (like the admin) that control the
Context themselves.
> >
> >
> I don't quite see how this is any different from check(String name).
>

Well, for 'add', there isn't necessarily any context.xml file, and there
isn't necessarily any relationship between the Context path and docBase.
For 'remove', the remove is unconditional and doesn't require touching
resources that may have never existed.

One alternative would be to have the admin webapp alway create context.xml
for the "Create Context" action, and delete it for the "Remove Context"
action.  However, this creates way more problems then it will ever solve (at
least with the config as it is now).



> R�my




---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Re: cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup HostConfig.java mbeans-descriptors.xml

Posted by Remy Maucherat <re...@apache.org>.
billbarker@apache.org wrote:

>billbarker    2004/08/03 23:48:07
>
>  Modified:    catalina/src/share/org/apache/catalina/startup
>                        HostConfig.java mbeans-descriptors.xml
>  Log:
>  Adding methods for JMX managed Contexts.
>  
>  -- Adding method to get the configBase via JMX
>  -- Adding methods to add and remove apps with minimal dependancy checks.  This is for use with JMX apps (like the admin) that control the Context themselves.
> 
>
I don't quite see how this is any different from check(String name).

Rémy


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org