| 
     
      
      
      From: Scott S. <sco...@jb...> - 2006-07-09 23:48:24
      
     
   | 
  User: starksm 
  Date: 06/07/09 19:48:22
  Modified:    src/main/org/jboss/system/server/profileservice    
                        ProfileServiceBootstrap.java ServerImpl.java
                        ProfileServiceImpl.java
  Removed:     src/main/org/jboss/system/server/profileservice    
                        ServerPSBootstrap.java
  Log:
  Bootstrap the ProfileService implementation from the deployer-beans.xml and drop the unnecessary ServerPSBootstrap class.
  
  Revision  Changes    Path
  1.2       +70 -16    system2/src/main/org/jboss/system/server/profileservice/ProfileServiceBootstrap.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ProfileServiceBootstrap.java
  ===================================================================
  RCS file: /cvsroot/jboss/system2/src/main/org/jboss/system/server/profileservice/ProfileServiceBootstrap.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -b -r1.1 -r1.2
  --- ProfileServiceBootstrap.java	6 Jul 2006 03:30:21 -0000	1.1
  +++ ProfileServiceBootstrap.java	9 Jul 2006 23:48:22 -0000	1.2
  @@ -24,15 +24,20 @@
   import java.net.URL;
   import java.util.Enumeration;
   
  +import org.jboss.deployers.spi.Deployment;
   import org.jboss.deployers.spi.MainDeployer;
   import org.jboss.kernel.plugins.bootstrap.basic.BasicBootstrap;
   import org.jboss.kernel.plugins.deployment.xml.BasicXMLDeployer;
   import org.jboss.kernel.spi.registry.KernelRegistry;
   import org.jboss.kernel.spi.registry.KernelRegistryEntry;
  +import org.jboss.profileservice.spi.Profile;
  +import org.jboss.profileservice.spi.ProfileKey;
  +import org.jboss.profileservice.spi.ProfileService;
   
   /**
  - * An extension of the kernel basic bootstrap that adds a loadProfile(String)
  - * hook to load beans into the kernel using the ProfileService.
  + * An extension of the kernel basic bootstrap that boots the mc from
  + * deployer-beans.xml descriptors using the BasicXMLDeployer, and loads
  + * additional deployments using the ProfileService.
    * 
    * @author Sco...@jb...
    * @version $Revision$
  @@ -44,8 +49,10 @@
      protected String profileName;
      /** The kernel deployer used to load the server deployers */
      protected BasicXMLDeployer kernelDeployer;
  -   /** The server MainkernelDeployer */
  +   /** The server MainDeployer */
      protected MainDeployer mainDeployer;
  +   /** The server ProfileService */
  +   protected ProfileService profileService;
   
      public ProfileServiceBootstrap()
      {
  @@ -57,21 +64,33 @@
      }
   
      /**
  -    * Return the MainkernelDeployer bean.
  -    * @return the MainkernelDeployer bean if bootstrap succeeded, null otherwise.
  +    * Return the MainDeployer bean.
  +    * @return the MainDeployer bean if bootstrap succeeded, null otherwise.
       */
      public MainDeployer getMainDeployer()
      {
         return mainDeployer;
      }
  -
  -   public BasicXMLDeployer getKernelkernelDeployer()
  +   /**
  +    * Return the ProfileService bean.
  +    * @return the ProfileService bean if bootstrap succeeded, null otherwise
  +    */
  +   public ProfileService getProfileService()
  +   {
  +      return profileService;
  +   }
  +   /**
  +    * Return the bootstrap XML kernel deployer.
  +    * @return BasicXMLDeployer instance.
  +    */
  +   public BasicXMLDeployer getKernelDeployer()
      {
         return kernelDeployer;
      }
   
      /**
  -    * Boot the kernel by loading all kernelDeployer-beans.xml followed by the
  +    * Boot the kernel by loading all deployer-beans.xml descriptors available
  +    * on the classpath.
       * 
       */
      public void bootstrap() throws Throwable
  @@ -98,10 +117,10 @@
         // Validate that everything is ok
         kernelDeployer.validate();
   
  -      // Get the MainkernelDeployer
  +      // Get the MainDeployer
         KernelRegistry registry = getKernel().getRegistry();
  -      KernelRegistryEntry entry = registry.getEntry("MainDeployer");
  -      Object target = entry.getTarget();
  +      KernelRegistryEntry mdEntry = registry.getEntry("MainDeployer");
  +      Object target = mdEntry.getTarget();
         if( target instanceof MainDeployer )
         {
            mainDeployer = (MainDeployer) target;
  @@ -114,14 +133,31 @@
            tmp.append(MainDeployer.class.getName());
            throw new IllegalStateException(tmp.toString());
         }
  -      log.debug("Using MainkernelDeployer: "+mainDeployer);
  +      log.debug("Using MainDeployer: "+mainDeployer);
  +
  +      // Get the ProfileService
  +      KernelRegistryEntry psEntry = registry.getEntry("ProfileService");
  +      target = psEntry.getTarget();
  +      if( target instanceof ProfileService )
  +      {
  +         profileService = (ProfileService) target;
  +      }
  +      else
  +      {
  +         StringBuilder tmp = new StringBuilder("Kernel entry ProfileService(");
  +         tmp.append(profileService);
  +         tmp.append(") is not an instanceof ");
  +         tmp.append(ProfileService.class.getName());
  +         throw new IllegalStateException(tmp.toString());
  +      }
  +      log.debug("Using ProfileService: "+profileService);
   
         // Load the profile beans
         loadProfile(profileName);
      }
   
      /**
  -    * Deploy a url
  +    * Bootstrap deployment of the 
       *
       * @param url the deployment url
       * @throws Throwable for any error  
  @@ -150,13 +186,31 @@
   
   
      /**
  -    * Load the beans associated with the named profile. Should be overriden
  -    * to do something meaningful.
  +    * Load the deployments associated with the named profile and deploy them
  +    * using the MainDeployer.
       * @param name
       * @throws Throwable
  +    * @throws NullPointerException if either the MainDeployer or ProfileService
  +    * have not been injected.
       */
      protected void loadProfile(String name) throws Throwable
      {
  -      
  +      MainDeployer deployer = getMainDeployer();
  +      if( deployer == null )
  +         throw new NullPointerException("MainDeployer has not been set");
  +      ProfileService ps = getProfileService();
  +      if( ps == null )
  +         throw new NullPointerException("ProfileService has not been set");
  +
  +      // Load the named profile
  +      ProfileKey key = new ProfileKey(name);
  +      Profile profile = ps.getProfile(key);
  +      Deployment[] profileDeployments = profile.getDeployments();
  +      // Deploy the profile deployments
  +      for(Deployment d : profileDeployments)
  +      {
  +         log.debug("Deploying: "+d);
  +         deployer.deploy(d);
  +      }
      }
   }
  
  
  
  1.3       +5 -5      system2/src/main/org/jboss/system/server/profileservice/ServerImpl.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ServerImpl.java
  ===================================================================
  RCS file: /cvsroot/jboss/system2/src/main/org/jboss/system/server/profileservice/ServerImpl.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -b -r1.2 -r1.3
  --- ServerImpl.java	6 Jul 2006 06:49:41 -0000	1.2
  +++ ServerImpl.java	9 Jul 2006 23:48:22 -0000	1.3
  @@ -60,7 +60,7 @@
      private final Package jbossPackage = Package.getPackage("org.jboss");
   
      /** The kernel bootstrap */
  -   private ServerPSBootstrap bootstrap;
  +   private ProfileServiceBootstrap bootstrap;
   
      /** The basic configuration for the server. */
      private ServerConfigImpl config;
  @@ -319,7 +319,7 @@
         startDate = new Date();
   
         log.info("Starting MicroContainer");
  -      bootstrap = new ServerPSBootstrap(config.getServerName());
  +      bootstrap = new ProfileServiceBootstrap(config.getServerName());
         bootstrap.run();
         
         // Install the shutdown hook
  @@ -641,11 +641,11 @@
         extends Thread
      {
         /** The ServiceController which we will ask to shut things down with. */
  -      private ServerPSBootstrap bootstrap;
  +      private ProfileServiceBootstrap bootstrap;
   
         private boolean forceHalt = true;
   
  -      public ShutdownHook(final ServerPSBootstrap bootstrap)
  +      public ShutdownHook(final ProfileServiceBootstrap bootstrap)
         {
            super("JBoss Shutdown Hook");
   
  @@ -704,7 +704,7 @@
         {
            try
            {
  -            BasicKernelDeployer deployer = bootstrap.getKernelkernelDeployer();
  +            BasicKernelDeployer deployer = bootstrap.getKernelDeployer();
               deployer.shutdown();
            }
            catch (Exception e)
  
  
  
  1.2       +9 -4      system2/src/main/org/jboss/system/server/profileservice/ProfileServiceImpl.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ProfileServiceImpl.java
  ===================================================================
  RCS file: /cvsroot/jboss/system2/src/main/org/jboss/system/server/profileservice/ProfileServiceImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -b -r1.1 -r1.2
  --- ProfileServiceImpl.java	6 Jul 2006 03:30:21 -0000	1.1
  +++ ProfileServiceImpl.java	9 Jul 2006 23:48:22 -0000	1.2
  @@ -40,12 +40,13 @@
   public class ProfileServiceImpl
      implements ProfileService
   {
  -   protected Profile defatulImpl;
  -   private ManagementViewImpl mgtView;
  +   private Profile defaultImpl;
  +   private ManagementView mgtView;
   
      public ProfileServiceImpl(String name) throws IOException
      {
  -      defatulImpl = new ProfileImpl(name);
  +      defaultImpl = new ProfileImpl(name);
  +      mgtView = new ManagementViewImpl(this);
      }
      public String[] getDomains()
      {
  @@ -65,7 +66,7 @@
      public Profile getProfile(ProfileKey key)
         throws NoSuchProfileException
      {
  -      return defatulImpl;
  +      return defaultImpl;
      }
   
      public String[] getProfileDeploymentNames(ProfileKey key)
  @@ -79,6 +80,10 @@
      {
         return mgtView;
      }
  +   public void setViewManager(ManagementView mgtView)
  +   {
  +      this.mgtView = mgtView;
  +   }
   
      // Admin of profiles @todo could be an option plugin
      public Profile newProfile(ProfileKey key)
  
  
  
 |