User: schaefera
  Date: 01/05/14 11:39:27

  Modified:    src/main/org/jboss/deployment J2eeDeployer.java
  Log:
  Implementation of the 1. draft for the JBoss management class in the
  J2EEDeployer to figure out what applications are deployed.
  
  Revision  Changes    Path
  1.22      +88 -1     jboss/src/main/org/jboss/deployment/J2eeDeployer.java
  
  Index: J2eeDeployer.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/deployment/J2eeDeployer.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- J2eeDeployer.java 2001/04/15 05:41:21     1.21
  +++ J2eeDeployer.java 2001/05/14 18:39:27     1.22
  @@ -41,6 +41,9 @@
   import javax.management.RuntimeMBeanException;
   import javax.management.RuntimeErrorException;
   
  +import org.jboss.mgt.Application;
  +import org.jboss.mgt.Module;
  +import org.jboss.mgt.ServerDataCollector;
   import org.jboss.logging.Log;
   import org.jboss.util.MBeanProxy;
   import org.jboss.util.ServiceMBeanSupport;
  @@ -67,7 +70,7 @@
   *
   *   @author <a href="mailto:[EMAIL PROTECTED]";>Daniel Schulze</a>
   *   @author Toby Allsopp ([EMAIL PROTECTED])
  -*   @version $Revision: 1.21 $
  +*   @version $Revision: 1.22 $
   */
   public class J2eeDeployer 
   extends ServiceMBeanSupport
  @@ -178,10 +181,24 @@
      {
         URL url = new URL (_url);
         
  +      ObjectName lCollector = null;
  +      try {
  +         lCollector = new ObjectName( "Management", "service", "Collector" );
  +      }
  +      catch( Exception e ) {
  +      }
  +      
         // undeploy first if it is a redeploy
         try
         {
            undeploy (_url);
  +         // Remove application data by its id
  +         server.invoke(
  +            lCollector,
  +            "removeApplication",
  +            new Object[] { _url },
  +            new String[] { "java.lang.String" }
  +         );
         }
         catch (Exception _e)
         {}
  @@ -195,6 +212,25 @@
          {
                  startApplication (d);
                  log.log ("J2EE application: " + _url + " is deployed.");
  +        try {
  +            // Now the application is deployed add it to the server data collector
  +            Application lApplication = convert2Application( _url, d );
  +            server.invoke(
  +               lCollector,
  +               "saveApplication",
  +               new Object[] {
  +                  _url,
  +                  lApplication
  +               },
  +               new String[] {
  +                  "java.lang.String",
  +                  lApplication.getClass().getName()
  +               }
  +            );
  +        }
  +        catch( Exception e ) {
  +           log.log ("Report of deployment of J2EE application: " + _url + " could 
not be reported.");
  +        }
         } 
         catch (Exception _e)
         {
  @@ -648,5 +684,56 @@
   
         // set it as the context class loader for the deployment thread
         Thread.currentThread().setContextClassLoader(appCl);
  +   }
  +   
  +   /**
  +    * Converts a given Deployment to a Management Application
  +    *
  +    * @param pId Application Id
  +    * @param pDeployment Deployment to be converted
  +    *
  +    * @return Converted Applicaiton
  +    **/
  +   public Application convert2Application(
  +      String pId,
  +      Deployment pDeployment
  +   ) {
  +      Collection lModules = new ArrayList();
  +      // Go through web applications
  +      Iterator i = pDeployment.webModules.iterator();
  +      Collection lItems = new ArrayList();
  +      while( i.hasNext() ) {
  +         Deployment.Module lModule = (Deployment.Module) i.next();
  +         lItems.add( lModule.webContext );
  +      }
  +      // Add Web Module
  +      lModules.add(
  +         new Module(
  +            "WebModule:FixeLater",
  +            "DD:FixeLater",
  +            lItems
  +         )
  +      );
  +      // Go through ejb applications
  +      i = pDeployment.webModules.iterator();
  +      lItems = new ArrayList();
  +      while( i.hasNext() ) {
  +         Deployment.Module lModule = (Deployment.Module) i.next();
  +         lItems.add( ( (URL) lModule.localUrls.firstElement() ).getFile() );
  +      }
  +      // Add EJB Module
  +      lModules.add(
  +         new Module(
  +            "EJBModule:FixeLater",
  +            "DD:FixeLater",
  +            lItems
  +         )
  +      );
  +      // Create Applications
  +      return new Application(
  +         pId,
  +         "DD:FixeLater",
  +         lModules
  +      );
      }
   }
  
  
  

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

Reply via email to