User: cgjung  
  Date: 01/07/18 05:02:02

  Modified:    src/main/org/jboss/deployment/scope
                        J2eeGlobalScopeDeployer.java
  Added:       src/main/org/jboss/deployment/scope
                        J2eeGlobalScopeDeployerMBean.java
  Log:
  Deployment opened up for subclassing (e.g., to re-introduce pure directory
  deployments via the J2eeDeployer). extended Mbean interface added to access
  scoped deployments.
  
  Revision  Changes    Path
  1.11      +85 -38    
jboss/src/main/org/jboss/deployment/scope/J2eeGlobalScopeDeployer.java
  
  Index: J2eeGlobalScopeDeployer.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/jboss/src/main/org/jboss/deployment/scope/J2eeGlobalScopeDeployer.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- J2eeGlobalScopeDeployer.java      2001/06/27 06:51:42     1.10
  +++ J2eeGlobalScopeDeployer.java      2001/07/18 12:02:02     1.11
  @@ -28,11 +28,11 @@
   /**
    * This is a deployer that introduces a J2ee application scoping facility and
    * proper (re-)deployment procedures. It implements a default global scope.
  - * @author  cgjung
  + * @author  <a href="mailto:[EMAIL PROTECTED]";>cgjung</a>
    * @version 0.9
    */
   
  -public class J2eeGlobalScopeDeployer extends org.jboss.deployment.J2eeDeployer {
  +public class J2eeGlobalScopeDeployer extends org.jboss.deployment.J2eeDeployer 
implements J2eeGlobalScopeDeployerMBean {
       
       /** the scopes that are in effect */
       final protected Map scopes=new java.util.HashMap();
  @@ -41,42 +41,88 @@
       public J2eeGlobalScopeDeployer() {
       }
       
  -    /** registers a new scope in this deployer
  +    /** 
  +     * registers a new scope in this deployer
        * @param name unique name of the new scope
  -     *
        * @param scope the scope to register
        * @return the scope that has been isolated by that action
  -     *
        */
  -    public Scope registerScope(String name, Scope scope) {
  -        synchronized(scopes) {
  -            return (Scope) scopes.put(name,scope);
  -        }
  +    protected Scope registerScope(String name, Scope scope) {
  +     synchronized(scopes) {
  +             return (Scope) scopes.put(name,scope);
  +     }
       }
       
  -    /** looks up a scope
  +    /** 
  +     * looks up a scope and creates it of not yet registered
        * @param name the unique name of the scope
  -     *
        * @return the registered scope
  -     *
        */
       public Scope getScope(String name) {
  -        synchronized(scopes) {
  -            return (Scope) scopes.get(name);
  -        }
  +     synchronized(scopes) {
  +             return (Scope) scopes.get(name);
  +     }
       }
       
  -    /** deregisters a scope
  +    /** 
  +     * returns a list of the registered scope names
  +     * @return scope name list
  +     */
  +    public String[] listScopes() {
  +     synchronized(scopes) {
  +             return (String[]) scopes.keySet().toArray(new String[scopes.size()]);
  +     }
  +    }
  +
  +    /** 
  +     * deregisters a scope
        * @param name unique name of the scope to deRegister
        * @return the deRegistered scope
        *
        */
  -    public Scope deRegisterScope(String name) {
  -        synchronized(scopes) {
  -            return (Scope) scopes.remove(name);
  -        }
  +    protected Scope deRegisterScope(String name) {
  +     synchronized(scopes) {
  +             return (Scope) scopes.remove(name);
  +     }
  +    }
  +    
  +    /** 
  +     * deregisters all scopes
  +     */
  +    protected void deRegisterScopes() {
  +     synchronized(scopes) {
  +         Iterator allScopes=scopes.keySet().iterator();
  +         while(allScopes.hasNext()) {
  +             allScopes.remove();
  +         }
  +     }
       }
  -    
  +
  +    /** factory method to create a new scope, May throw a general exception
  +     * if this very basic enterprise fails.
  +     * @throws Exception May throw any exception to indicate
  +     * instantiation problems of the scope (probably
  +     * because initial meta-data could not be found,
  +     * is corrupt, etc.)
  +     * @return a freshly instantiated and preconfigured scope.
  +     *
  +     */
  +    protected Scope createScope() throws Exception {
  +        return new Scope(log);
  +    }
  +
  +    /** creates and registers fresh scope */
  +    public Scope createScope(String name) throws Exception {
  +     synchronized(scopes) {
  +             Scope result=getScope(name);
  +             if(result==null) {
  +                     result=createScope();
  +                     registerScope(name,result);
  +             }
  +             return result;
  +     }
  +    }
  +
       /** static name of the global scope */
       final public static String GLOBAL_SCOPE="GLOBAL_SCOPE";
       
  @@ -87,29 +133,17 @@
        * went wrong.
        */
       public void startService() throws Exception {
  -        registerScope(GLOBAL_SCOPE,createScope());
           super.startService();
  +     createScope(GLOBAL_SCOPE);
       }
       
  -    /** factory method to create a new scope, May throw a general exception
  -     * if this very basic enterprise fails.
  -     * @throws Exception May throw any exception to indicate
  -     * instantiation problems of the scope (probably
  -     * because initial meta-data could not be found,
  -     * is corrupt, etc.)
  -     * @return a freshly instantiated and preconfigured scope.
  -     *
  -     */
  -    protected Scope createScope() throws Exception {
  -        return new Scope(log);
  -    }
       
       /** stops the service by freeing
  -     * scope afterwards
  +     *  scopes
        */
       public void stopService() {
           super.stopService();
  -        deRegisterScope(GLOBAL_SCOPE);
  +     deRegisterScopes();
       }
       
       
  @@ -196,9 +230,22 @@
        * @throws IOException if trouble while file download occurs
        */
       public void deploy(String _url) throws MalformedURLException, IOException, 
J2eeDeploymentException {
  -        deploy(_url,getScope(GLOBAL_SCOPE));
  +        deploy(_url,GLOBAL_SCOPE);
       }
  -    
  +
  +
  +    /** scoped (re-)deploy method. Using a particular scope name
  +     *
  +     * @param scope the scope in which the file should be deployed
  +     * @param _url the url (file or http) to the archiv to deploy
  +     * @throws MalformedURLException in case of a malformed url
  +     * @throws J2eeDeploymentException if something went wrong...
  +     * @throws IOException if trouble while file download occurs
  +     */
  +    public void deploy(String _url, String scopeName) throws MalformedURLException, 
IOException, J2eeDeploymentException {
  +     deploy(_url,getScope(scopeName));
  +    }
  +
       /** scoped (re-)deploy method.
        *
        * @param scope the scope in which the file should be deployed
  
  
  
  1.1                  
jboss/src/main/org/jboss/deployment/scope/J2eeGlobalScopeDeployerMBean.java
  
  Index: J2eeGlobalScopeDeployerMBean.java
  ===================================================================
  /*
   * JBoss, the OpenSource EJB server
   *
   * Distributable under LGPL license.
   * See terms of license at gnu.org.
   */
  
  package org.jboss.deployment.scope;
  
  import org.jboss.deployment.J2eeDeployerMBean;
  import org.jboss.deployment.DeploymentException;
  import java.io.IOException;
  import java.net.MalformedURLException;
  
  /**
   *   The JMX interface for scoped deployment services
   *
   *   @author <a href="mailto:[EMAIL PROTECTED]";>Christoph G. Jung</a>
   *   @version $Revision: 1.1 $
   */
  public interface J2eeGlobalScopeDeployerMBean extends J2eeDeployerMBean
  {
     // Constants -----------------------------------------------------
      
     // Public --------------------------------------------------------
     
  
     Scope getScope(String name);
  
     void deploy(String url, String scopeName)    
        throws MalformedURLException, IOException, DeploymentException;
  
     Scope createScope(String name) throws Exception;
  
     String[] listScopes();
  
  }
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to