User: mnf999  
  Date: 01/12/18 13:06:30

  Modified:    src/main/org/jboss/resource RARDeployer.java
  Log:
  Make the RARDeployer use create and start on the services it deploys
  
  Revision  Changes    Path
  1.15      +112 -101  jbosscx/src/main/org/jboss/resource/RARDeployer.java
  
  Index: RARDeployer.java
  ===================================================================
  RCS file: /cvsroot/jboss/jbosscx/src/main/org/jboss/resource/RARDeployer.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- RARDeployer.java  2001/11/26 03:24:52     1.14
  +++ RARDeployer.java  2001/12/18 21:06:30     1.15
  @@ -1,9 +1,9 @@
   /*
  - * JBoss, the OpenSource J2EE webOS
  - *
  - * Distributable under LGPL license.
  - * See terms of license at gnu.org.
  - */
  +* JBoss, the OpenSource J2EE webOS
  +*
  +* Distributable under LGPL license.
  +* See terms of license at gnu.org.
  +*/
   package org.jboss.resource;
   
   
  @@ -33,6 +33,7 @@
   import javax.management.ObjectName;
   import org.jboss.deployment.DeployerMBeanSupport;
   import org.jboss.deployment.DeploymentException;
  +import org.jboss.deployment.ServiceDeploymentInfo;
   import org.jboss.logging.Logger;
   import org.jboss.metadata.XmlFileLoader;
   import org.jboss.system.ServiceLibraries;
  @@ -49,7 +50,7 @@
   *
   * @author     Toby Allsopp ([EMAIL PROTECTED])
   * @author     <a href="mailto:[EMAIL PROTECTED]";>David Jencks</a>
  -* @version    $Revision: 1.14 $
  +* @version    $Revision: 1.15 $
   * @see        org.jboss.resource.ConnectionFactoryLoader <p>
   *
   *      <b>Revisions:</b> <p>
  @@ -59,88 +60,93 @@
   *        <li> Implemented <code>getMetaData</code> so that connection factories
   *        can be loaded after RAR deployment</li>
   *      </ul>
  +*      <b>20011219 Marc Fleury</b>
  +*      <ul>
  +*        <li> Make the deployer call create and start on the service it deploys</li>
  +*      </ul>
   *
   */
   public class RARDeployer
  -       extends DeployerMBeanSupport
  -       implements RARDeployerMBean
  +extends DeployerMBeanSupport
  +implements RARDeployerMBean
   {
  -
  +   
      // Package protected ---------------------------------------------
  -
  +   
      // Protected -----------------------------------------------------
  -
  +   
      // Private -------------------------------------------------------
  -
  +   
      private static int nextNum = 0;
      // Constants -----------------------------------------------------
  -
  +   
      // Attributes ----------------------------------------------------
  -
  -
  +   
  +   
      /**
  -    *  The next sequence number to be used in notifications about (un)deployment
  -    */
  +   *  The next sequence number to be used in notifications about (un)deployment
  +   */
      private int nextMessageNum = 0;
  -
  +   
      // Static --------------------------------------------------------
  -
  +   
      // Constructors --------------------------------------------------
  -
  +   
      // Public --------------------------------------------------------
  -
  +   
      /**
  -    *  Gets the DeployableFilter attribute of the RARDeployer object
  -    *
  -    * @return    The DeployableFilter value
  -    */
  +   *  Gets the DeployableFilter attribute of the RARDeployer object
  +   *
  +   * @return    The DeployableFilter value
  +   */
      public FilenameFilter getDeployableFilter()
      {
         return
  -         new FilenameFilter()
  +      new FilenameFilter()
  +      {
  +         /**
  +         *  #Description of the Method
  +         *
  +         * @param  dir       Description of Parameter
  +         * @param  filename  Description of Parameter
  +         * @return           Description of the Returned Value
  +         */
  +         public boolean accept(File dir, String filename)
            {
  -            /**
  -             *  #Description of the Method
  -             *
  -             * @param  dir       Description of Parameter
  -             * @param  filename  Description of Parameter
  -             * @return           Description of the Returned Value
  -             */
  -            public boolean accept(File dir, String filename)
  -            {
  -               return filename.endsWith(".rar");
  -            }
  -         };
  +            return filename.endsWith(".rar");
  +         }
  +      };
      }
  -
  +   
      // RARDeployerMBean implementation -------------------------------
  -
  +   
      // DeployerMBeanSupport overrides ---------------------------------
  -
  +   
      /**
  -    *  Gets the Name attribute of the RARDeployer object
  -    *
  -    * @return    The Name value
  -    */
  +   *  Gets the Name attribute of the RARDeployer object
  +   *
  +   * @return    The Name value
  +   */
      public String getName()
      {
         return "RARDeployer";
      }
  -
  -
  -    /**
  -     * The <code>deploy</code> method deploys a rar at the given url.
  -     *
  -     * @param url The <code>URL</code> location of the rar to deploy.
  -     * @return an <code>Object</code> to identify this deployment.
  -     * @exception IOException if an error occurs
  -     * @exception DeploymentException if an error occurs
  -     */
  -    protected Object deploy(URL url)
  -          throws IOException, DeploymentException
  +   
  +   
  +   /**
  +   * The <code>deploy</code> method deploys a rar at the given url.
  +   *
  +   * @param url The <code>URL</code> location of the rar to deploy.
  +   * @return an <code>Object</code> to identify this deployment.
  +   * @exception IOException if an error occurs
  +   * @exception DeploymentException if an error occurs
  +   */
  +   protected Object deploy(URL url)
  +   throws IOException, DeploymentException
      {
         getLog().info("Attempting to deploy RAR at '" + url + "'");
         RarDeploymentInfo rdi = new RarDeploymentInfo(url);
  +      
         File localCopy = getLocalCopy(url, rdi);
         URL localUrl =localCopy.toURL();
         extractPackages(localUrl, rdi);
  @@ -150,29 +156,29 @@
            URL xml = (URL)i.next();
            if (xml.getFile().endsWith("META-INF/ra.xml")) 
            {
  -             ddUrl = xml;
  -             break;              
  -          }
  +            ddUrl = xml;
  +            break;              
  +         }
         }
         
         if (ddUrl == null)
         {
            throw new DeploymentException("No deployment descriptor " +
  -               "('META-INF/ra.xml') found in alleged " +
  -               "resource adapter at '" + url + "'");
  +            "('META-INF/ra.xml') found in alleged " +
  +            "resource adapter at '" + url + "'");
         }
  -
  +      
         Document dd = XmlFileLoader.getDocument(ddUrl);
  -
  +      
         Element root = dd.getDocumentElement();
  -
  +      
         RARMetaData metadata = new RARMetaData();
         metadata.importXml(root);
  -
  +      
         // Create a class loader that can load classes from any JARs
         // inside the RAR. extractPackages found the JARs.
  -
  -
  +      
  +      
         // Ok, now we have the URLs of the JARs contained in the RAR we
         // can create a classloader that loads classes from them
         //Note, we're using the jboss system classloader so the rar
  @@ -181,66 +187,71 @@
         //We use the original (uncopied) url as the id key.
         ClassLoader cl = rdi.createClassLoader();
         metadata.setClassLoader(cl);
  -
  +      
         //set up the RARDeployment mbean for dependency management.
         try 
         {
            ObjectName deploymentName = new 
ObjectName("JCA:service=RARDeployment,name=" + metadata.getDisplayName());
            getServer().createMBean("org.jboss.resource.RARDeployment", 
  -                              deploymentName,
  -                              new Object[] {metadata},
  -                              new String[] {"org.jboss.resource.RARMetaData"});
  +            deploymentName,
  +            new Object[] {metadata},
  +            new String[] {"org.jboss.resource.RARMetaData"});
            
  -
  -         getServer().invoke(getServiceControllerName(),
  -                            "registerAndStartService",
  -                            new Object[] {deploymentName, null},
  -                            new String[] {"javax.management.ObjectName", 
"java.lang.String"});
  -
  -
  -
  +         
  +         getServer().invoke(
  +            getServiceControllerName(),
  +            "create",
  +            new Object[] {deploymentName},
  +            new String[] {"javax.management.ObjectName"});
  +         
  +         getServer().invoke(
  +            getServiceControllerName(),
  +            "start",
  +            new Object[] {deploymentName},
  +            new String[] {"javax.management.ObjectName"});
  +         
         } 
         catch (Exception e) 
         {
            throw new DeploymentException("Problem making RARDeployment MBean", e);  
         } // end of try-catch
  -
  +      
         rdi.metadata = metadata;
         return rdi;
      }
  -
  +   
      protected void undeploy(URL url, Object o)
  -          throws DeploymentException
  +   throws DeploymentException
      {
         getLog().info("Undeploying RAR at '" + url + "'");
  -
  +      
         RarDeploymentInfo rdi = (RarDeploymentInfo)o;
  -
  +      
         if (rdi == null)
         {
            throw new DeploymentException("There doesn't appear to be a RAR " +
  -               "deployed at '" + url + "'");
  +            "deployed at '" + url + "'");
         }
  -
  +      
         RARMetaData metadata = rdi.metadata;
         try 
         {
            ObjectName deploymentName = new 
ObjectName("JCA:service=RARDeployment,name=" + metadata.getDisplayName());
            log.info("About to undeploy RARDeploymentMBean, objectname: " + 
deploymentName);
  -
  +         
            getServer().invoke(getServiceControllerName(),
  -                            "undeploy",
  -                            new Object[] {deploymentName},
  -                            new String[] {"javax.management.ObjectName"});
  -
  -    
  +            "undeploy",
  +            new Object[] {deploymentName},
  +            new String[] {"javax.management.ObjectName"});
  +      
  +      
         } catch (Exception e) 
         {
            log.error("Problem undeploying RARDeployment MBean", e);
            throw new DeploymentException("Problem undeploying RARDeployment MBean", 
e);  
         } // end of try-catch
  -
  -
  +      
  +      
         //unregister the classloader from the system libraries.
         //this is the org.jboss.system.URLClassLoader.
         URLClassLoader cl = (URLClassLoader)metadata.getClassLoader();
  @@ -255,17 +266,17 @@
         metadata.setClassLoader(null);
         // Remove the temporary copy
         rdi.cleanup(getLog());
  -      
  +   
      }
  -
  +   
      // Inner classes -------------------------------------------------
  -
  +   
      /**
  -    */
  -   private static class RarDeploymentInfo extends 
DeployerMBeanSupport.DeploymentInfo
  +   */
  +   private static class RarDeploymentInfo extends ServiceDeploymentInfo
      {
         public RARMetaData metadata;
  -
  +      
         public RarDeploymentInfo(URL key)
         {
            super(key);
  
  
  

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

Reply via email to