[jboss-cvs] JBossAS SVN: r84925 - in trunk: profileservice/src/main/org/jboss/profileservice/management/upload/remoting and 3 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Mar 2 04:26:46 EST 2009


Author: emuckenhuber
Date: 2009-03-02 04:26:46 -0500 (Mon, 02 Mar 2009)
New Revision: 84925

Added:
   trunk/profileservice/src/main/org/jboss/profileservice/management/upload/AbstractTransientProfileManager.java
Removed:
   trunk/profileservice/src/main/org/jboss/profileservice/management/upload/AbstractDeploymentManager.java
Modified:
   trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentManagerImpl.java
   trunk/profileservice/src/main/org/jboss/profileservice/management/upload/SerializableDeploymentID.java
   trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/AbstractDeployHandler.java
   trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/DeployHandler.java
   trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/StreamingDeploymentTarget.java
   trunk/profileservice/src/resources/profileservice-jboss-beans.xml
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/TypedProfileRepository.java
   trunk/system/src/tests/org/jboss/test/server/profileservice/support/MockProfileRepository.java
Log:
[JBAS-6525] don't set the deploymentRepo to the deployHandler directly.

Deleted: trunk/profileservice/src/main/org/jboss/profileservice/management/upload/AbstractDeploymentManager.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/upload/AbstractDeploymentManager.java	2009-03-02 09:20:03 UTC (rev 84924)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/upload/AbstractDeploymentManager.java	2009-03-02 09:26:46 UTC (rev 84925)
@@ -1,162 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */ 
-package org.jboss.profileservice.management.upload;
-
-import java.util.ArrayList;
-
-import org.jboss.logging.Logger;
-import org.jboss.profileservice.spi.Profile;
-import org.jboss.profileservice.spi.ProfileFactory;
-import org.jboss.profileservice.spi.ProfileKey;
-import org.jboss.profileservice.spi.ProfileService;
-import org.jboss.profileservice.spi.metadata.ProfileMetaData;
-import org.jboss.system.server.profile.repository.metadata.BasicProfileMetaData;
-import org.jboss.system.server.profile.repository.metadata.ImmutableProfileSourceMetaData;
-
-/**
- * The AbstractDeploymentManager maintains a profile for transient deployments.
- * Transient deployments are copyContent = false, therefore they are not
- * getting deployed again after AS is restarted.
- * The aim of the transient profile is to expose those deployments to the
- * ManagementView.
- * 
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public abstract class AbstractDeploymentManager
-{
-   /** The transient profile name. */
-   public static final String TRANSIENT_PROFILE_NAME = "transient-deployment-profile";
-   
-   /** The transient profile key. */
-   public static final ProfileKey TRANSIENT_PROFILE_KEY = new ProfileKey(TRANSIENT_PROFILE_NAME);
-   
-   /** The profile factory. */
-   private ProfileFactory profileFactory;
-   
-   /** The profile service. */
-   protected ProfileService ps;
-   
-   /** The logger. */
-   private static final Logger log = Logger.getLogger(AbstractDeploymentManager.class);
-   
-   public ProfileService getProfileService()
-   {
-      return this.ps;
-   }
-   
-   public void setProfileService(ProfileService ps)
-   {
-      this.ps = ps;
-   }
-   
-   public ProfileFactory getProfileFactory()
-   {
-      return profileFactory;
-   }
-   
-   public void setProfileFactory(ProfileFactory profileFactory)
-   {
-      this.profileFactory = profileFactory;
-   }
-
-   /**
-    * Start registers and activates the transient deployments profile
-    * 
-    * @throws Exception for any error
-    */
-   public void start() throws Exception
-   {
-      if(this.ps == null)
-         throw new IllegalStateException("Null profile service.");
-      if(this.profileFactory == null)
-         throw new IllegalStateException("Null profile factory.");
-      
-      // Create the transient deployment profile
-      Profile profile = createTransientProfile();
-      // Register
-      this.ps.registerProfile(profile);
-      // Activate
-      {
-         log.debug("activating transient profile " + TRANSIENT_PROFILE_NAME);
-         this.ps.activateProfile(TRANSIENT_PROFILE_KEY);
-      }
-   }
-   
-   /**
-    * Stop deactivates and unregisters the transient deployments profile.
-    */
-   public void stop()
-   {
-      try
-      {
-         // Deactivate
-         log.debug("deactivating transient profile: " + TRANSIENT_PROFILE_NAME);
-         this.ps.deactivateProfile(TRANSIENT_PROFILE_KEY);
-      }
-      catch(Exception e)
-      {
-         log.debug("Failed to deactivate transient profile: ", e);
-      }
-      try
-      {
-         // Unregister
-         log.debug("unregistering transient profile: " + TRANSIENT_PROFILE_NAME);
-         this.ps.unregisterProfile(TRANSIENT_PROFILE_KEY);
-      }
-      catch(Exception e)
-      {
-         log.debug("Failed to unregister transient profile: ", e);
-      }
-   }
-   
-   /**
-    * Create the transient profile.
-    * 
-    * @return the transient profile
-    * @throws Exception for any error
-    */
-   protected Profile createTransientProfile() throws Exception
-   {
-      ProfileMetaData metaData = createTransientProfileMetaData();
-      return profileFactory.createProfile(TRANSIENT_PROFILE_KEY, metaData);
-   }
-   
-   /**
-    * Create the transient profile meta data.
-    * 
-    * @return the transient profile meta data
-    */
-   protected ProfileMetaData createTransientProfileMetaData()
-   {
-      // Source
-      ImmutableProfileSourceMetaData source = new ImmutableProfileSourceMetaData();
-      source.setSources(new ArrayList<String>());
-      // Profile
-      BasicProfileMetaData profile = new BasicProfileMetaData();
-      profile.setSource(source);
-      profile.setName(TRANSIENT_PROFILE_NAME);
-      //
-      return profile;
-   }
-   
-}

Copied: trunk/profileservice/src/main/org/jboss/profileservice/management/upload/AbstractTransientProfileManager.java (from rev 84894, trunk/profileservice/src/main/org/jboss/profileservice/management/upload/AbstractDeploymentManager.java)
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/upload/AbstractTransientProfileManager.java	                        (rev 0)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/upload/AbstractTransientProfileManager.java	2009-03-02 09:26:46 UTC (rev 84925)
@@ -0,0 +1,162 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */ 
+package org.jboss.profileservice.management.upload;
+
+import java.util.ArrayList;
+
+import org.jboss.logging.Logger;
+import org.jboss.profileservice.spi.Profile;
+import org.jboss.profileservice.spi.ProfileFactory;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.ProfileService;
+import org.jboss.profileservice.spi.metadata.ProfileMetaData;
+import org.jboss.system.server.profile.repository.metadata.BasicProfileMetaData;
+import org.jboss.system.server.profile.repository.metadata.ImmutableProfileSourceMetaData;
+
+/**
+ * The AbstractTransientProfileManager maintains a profile for transient deployments.
+ * Transient deployments are copyContent = false, therefore they are not
+ * getting deployed again after AS is restarted.
+ * The aim of the transient profile is to expose those deployments to the
+ * ManagementView.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class AbstractTransientProfileManager
+{
+   /** The transient profile name. */
+   public static final String TRANSIENT_PROFILE_NAME = "transient-deployment-profile";
+   
+   /** The transient profile key. */
+   public static final ProfileKey TRANSIENT_PROFILE_KEY = new ProfileKey(TRANSIENT_PROFILE_NAME);
+   
+   /** The profile factory. */
+   private ProfileFactory profileFactory;
+   
+   /** The profile service. */
+   protected ProfileService ps;
+   
+   /** The logger. */
+   private static final Logger log = Logger.getLogger(AbstractTransientProfileManager.class);
+   
+   public ProfileService getProfileService()
+   {
+      return this.ps;
+   }
+   
+   public void setProfileService(ProfileService ps)
+   {
+      this.ps = ps;
+   }
+   
+   public ProfileFactory getProfileFactory()
+   {
+      return profileFactory;
+   }
+   
+   public void setProfileFactory(ProfileFactory profileFactory)
+   {
+      this.profileFactory = profileFactory;
+   }
+
+   /**
+    * Start registers and activates the transient deployments profile
+    * 
+    * @throws Exception for any error
+    */
+   public void start() throws Exception
+   {
+      if(this.ps == null)
+         throw new IllegalStateException("Null profile service.");
+      if(this.profileFactory == null)
+         throw new IllegalStateException("Null profile factory.");
+      
+      // Create the transient deployment profile
+      Profile profile = createTransientProfile();
+      // Register
+      this.ps.registerProfile(profile);
+      // Activate
+      {
+         log.debug("activating transient profile " + TRANSIENT_PROFILE_NAME);
+         this.ps.activateProfile(TRANSIENT_PROFILE_KEY);
+      }
+   }
+   
+   /**
+    * Stop deactivates and unregisters the transient deployments profile.
+    */
+   public void stop()
+   {
+      try
+      {
+         // Deactivate
+         log.debug("deactivating transient profile: " + TRANSIENT_PROFILE_NAME);
+         this.ps.deactivateProfile(TRANSIENT_PROFILE_KEY);
+      }
+      catch(Exception e)
+      {
+         log.debug("Failed to deactivate transient profile: ", e);
+      }
+      try
+      {
+         // Unregister
+         log.debug("unregistering transient profile: " + TRANSIENT_PROFILE_NAME);
+         this.ps.unregisterProfile(TRANSIENT_PROFILE_KEY);
+      }
+      catch(Exception e)
+      {
+         log.debug("Failed to unregister transient profile: ", e);
+      }
+   }
+   
+   /**
+    * Create the transient profile.
+    * 
+    * @return the transient profile
+    * @throws Exception for any error
+    */
+   protected Profile createTransientProfile() throws Exception
+   {
+      ProfileMetaData metaData = createTransientProfileMetaData();
+      return profileFactory.createProfile(TRANSIENT_PROFILE_KEY, metaData);
+   }
+   
+   /**
+    * Create the transient profile meta data.
+    * 
+    * @return the transient profile meta data
+    */
+   protected ProfileMetaData createTransientProfileMetaData()
+   {
+      // Source
+      ImmutableProfileSourceMetaData source = new ImmutableProfileSourceMetaData();
+      source.setSources(new ArrayList<String>());
+      // Profile
+      BasicProfileMetaData profile = new BasicProfileMetaData();
+      profile.setSource(source);
+      profile.setName(TRANSIENT_PROFILE_NAME);
+      //
+      return profile;
+   }
+   
+}

Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentManagerImpl.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentManagerImpl.java	2009-03-02 09:20:03 UTC (rev 84924)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentManagerImpl.java	2009-03-02 09:26:46 UTC (rev 84925)
@@ -25,6 +25,7 @@
 import java.text.MessageFormat;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Locale;
 import java.util.ResourceBundle;
@@ -34,40 +35,36 @@
 import org.jboss.deployers.spi.management.deploy.DeploymentTarget;
 import org.jboss.deployers.spi.management.deploy.DeploymentStatus.CommandType;
 import org.jboss.logging.Logger;
-import org.jboss.profileservice.management.upload.remoting.DeployHandler;
 import org.jboss.profileservice.management.upload.remoting.StreamingDeploymentTarget;
-import org.jboss.profileservice.spi.DeploymentRepository;
 import org.jboss.profileservice.spi.MutableProfile;
 import org.jboss.profileservice.spi.NoSuchProfileException;
 import org.jboss.profileservice.spi.Profile;
 import org.jboss.profileservice.spi.ProfileKey;
-import org.jboss.profileservice.spi.ProfileRepository;
+import org.jboss.profileservice.spi.ProfileService;
 import org.jboss.remoting.InvokerLocator;
 
 /**
  * The remoting base DeploymentManager implementation.
  * 
  * @author Scott.Stark at jboss.org
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
  * @version $Revision$
  */
-public class DeploymentManagerImpl extends AbstractDeploymentManager implements DeploymentManager
+public class DeploymentManagerImpl implements DeploymentManager
 {
    /** The logger. */
    private static Logger log = Logger.getLogger(DeploymentManagerImpl.class);
    
    /** The bundle name. */
    private static final String BUNDLE_NAME = "org.jboss.profileservice.management.upload.messages"; //$NON-NLS-1$
-
-   /** The currently loaded profile */
-   private MutableProfile activeProfile;
-
-   /** The profile repository. */
-   private ProfileRepository profileRepository;
-   /** The remoting deploy handler. */
-   private DeployHandler deployHandler;
    
-   /** The transient deployment repository */
-   private DeploymentRepository transientDeploymentRepository;
+   /** The profile service. */
+   private ProfileService ps;
+   
+   /** The default profile key to upload contents. */
+   private ProfileKey defaultKey;
+   /** The loaded profile key. */
+   private ProfileKey activeProfileKey;
 
    /** The resource bundle. */
    private ResourceBundle i18n;
@@ -88,22 +85,22 @@
       i18n = ResourceBundle.getBundle(BUNDLE_NAME, currentLocale);
    }
 
-   public ProfileRepository getProfileRepository()
+   public ProfileKey getDefaultProfileKey()
    {
-      return profileRepository;
+      return defaultKey;
    }
-   public void setProfileRepository(ProfileRepository repositoryFactory)
+   public void setDefaultProfileKey(ProfileKey defaultKey)
    {
-      this.profileRepository = repositoryFactory;
+      this.defaultKey = defaultKey;
    }
-
-   public DeployHandler getDeployHandler()
+   
+   public ProfileService getProfileService()
    {
-      return deployHandler;
+      return this.ps;
    }
-   public void setDeployHandler(DeployHandler deployHandler)
+   public void setProfileService(ProfileService ps)
    {
-      this.deployHandler = deployHandler;
+      this.ps = ps;
    }
 
    public InvokerLocator getLocator()
@@ -123,27 +120,33 @@
    {
       this.remotingSubsystem = remotingSubsystem;
    }
-   
-   @Override
-   public void start() throws Exception
-   {
-      // Start the transient profile
-      super.start();
-      
-      // Get the transient deployment repository
-      this.transientDeploymentRepository = profileRepository.getProfileDeploymentRepository(TRANSIENT_PROFILE_KEY);
-      if(this.transientDeploymentRepository == null)
-         throw new IllegalStateException("Could not obtain the deployment repository for transient deployments.");
-   }
 
-   @Override
-   public void stop()
+   /**
+    * Get the mutable profile keys.
+    */
+   public Collection<ProfileKey> getProfiles()
    {
-      this.transientDeploymentRepository = null;
-      // Stop the transient profile
-      super.stop();
+      Collection<ProfileKey> mutableProfiles = new HashSet<ProfileKey>(); 
+      for( ProfileKey key : this.ps.getActiveProfileKeys())
+      {
+         // Exclude the transient profile
+         if(key.equals(AbstractTransientProfileManager.TRANSIENT_PROFILE_KEY))
+            continue;
+         
+         try
+         {
+            Profile profile = this.ps.getActiveProfile(key);
+            if(profile.isMutable())
+               mutableProfiles.add(key);
+         }
+         catch(NoSuchProfileException ignore)
+         {
+            //
+         }
+      }
+      return mutableProfiles; 
    }
-
+   
    public DeploymentProgress distribute(String name, URL contentURL)
       throws Exception
    {
@@ -157,7 +160,7 @@
       if(contentURL == null)
          throw new IllegalArgumentException("Null content url.");
       
-      if(activeProfile == null)
+      if(getTargetProfile() == null)
       {
          formatter.applyPattern(i18n.getString("DeploymentManager.NoProfileLoadedException")); //$NON-NLS-1$
          Object[] args = {};
@@ -166,7 +169,7 @@
       }
 
       List<DeploymentTarget> targets = getDeploymentTargets();
-      SerializableDeploymentID deployment = new SerializableDeploymentID(name, contentURL.toString());
+      SerializableDeploymentID deployment = new SerializableDeploymentID(name, getTargetProfile(), contentURL.toString());
       deployment.setContentURL(contentURL);
       deployment.setCopyContent(copyContent);
       return new DeploymentProgressImpl(targets, deployment, CommandType.DISTRIBUTE);
@@ -175,7 +178,8 @@
    public String[] getRepositoryNames(String[] names) throws Exception
    {
       List<DeploymentTarget> targets = getDeploymentTargets();
-      return targets.get(0).getRepositoryNames(names);
+      SerializableDeploymentID deployment = new SerializableDeploymentID(names, getTargetProfile(), null);
+      return targets.get(0).getRepositoryNames(deployment);
    }
 
    public boolean isRedeploySupported(ProfileKey key) throws NoSuchProfileException
@@ -187,41 +191,35 @@
    public void loadProfile(ProfileKey key, boolean allowHotDeployments)
       throws Exception
    {
-      activeProfile = getProfile(key);
-      if( activeProfile == null )
-      {
-         formatter.applyPattern(i18n.getString("DeploymentManager.NoSuchProfileException")); //$NON-NLS-1$
-         Object[] args = {key};
-         String msg = formatter.format(args);
-         throw new NoSuchProfileException(msg);
-      }
+      // Override a DEFAULT key with the injected default
+      if(key.isDefaultKey() && this.defaultKey != null)
+         key = this.defaultKey;
+      
+      // Get the mutable profile
+      MutableProfile activeProfile = getProfile(key);
+      // Set the key
+      this.activeProfileKey = key;
+     
+      // TODO this should be handled by the deployHandler
       log.debug("Loading profile, key: "+key+", allowHotDeployments: "+allowHotDeployments);
       activeProfile.enableModifiedDeploymentChecks(allowHotDeployments);
-      
-      // Set the deployment repository on the handler
-      DeploymentRepository repository = profileRepository.getProfileDeploymentRepository(key);
-      log.debug("DeploymentRepository for profile: "+repository);
-      deployHandler.setDeploymentRepository(repository);
-      deployHandler.setTransientDeploymentRepository(transientDeploymentRepository);
    }
 
    public void releaseProfile(ProfileKey key, boolean allowHotDeployments)
          throws Exception
    {
-      activeProfile = getProfile(key);
-      if( activeProfile == null )
-      {
-         formatter.applyPattern(i18n.getString("DeploymentManager.NoSuchProfileException")); //$NON-NLS-1$
-         Object[] args = {key};
-         String msg = formatter.format(args);
-         throw new NoSuchProfileException(msg);
-      }
+      // Override a DEFAULT key with the injected default
+      if(key.isDefaultKey() && this.defaultKey != null)
+         key = this.defaultKey;
+     
+      // Get the mutable profile
+      MutableProfile activeProfile = getProfile(key);
+      // Unset the key
+      this.activeProfileKey = null;
+      
+      // TODO this should be handled by the deployHandler
       log.debug("Releasing profile, key: "+key);
       activeProfile.enableModifiedDeploymentChecks(allowHotDeployments);
-      
-      // Unset deployment repositories
-      deployHandler.setDeploymentRepository(null);
-      deployHandler.setTransientDeploymentRepository(null);
    }
 
    public DeploymentProgress redeploy(String name)
@@ -229,7 +227,7 @@
       if(name == null)
          throw new IllegalArgumentException("Null name.");
       
-      if(activeProfile == null)
+      if(getTargetProfile() == null)
       {
          formatter.applyPattern(i18n.getString("DeploymentManager.NoProfileLoadedException")); //$NON-NLS-1$
          Object[] args = {};
@@ -238,7 +236,7 @@
       }
 
       List<DeploymentTarget> targets = getDeploymentTargets();
-      SerializableDeploymentID deployment = new SerializableDeploymentID(name, null);
+      SerializableDeploymentID deployment = new SerializableDeploymentID(name, getTargetProfile(), null);
       return new DeploymentProgressImpl(targets, deployment, CommandType.REDEPLOY);
    }
 
@@ -273,7 +271,7 @@
 
    protected DeploymentProgress doProgress(CommandType type, String... names)
    {
-      if(activeProfile == null)
+      if(getTargetProfile() == null)
       {
          formatter.applyPattern(i18n.getString("DeploymentManager.NoProfileLoadedException")); //$NON-NLS-1$
          Object[] args = {};
@@ -285,10 +283,17 @@
          log.warn("Null or empty names.");
 
       List<DeploymentTarget> targets = getDeploymentTargets();
-      SerializableDeploymentID deployment = new SerializableDeploymentID(names, null);
+      SerializableDeploymentID deployment = new SerializableDeploymentID(names, getTargetProfile(), null);
       return new DeploymentProgressImpl(targets, deployment, type);
    }
 
+   /**
+    * Get a mutable profile
+    * 
+    * @param key the profile key
+    * @return the mutable profile
+    * @throws NoSuchProfileException if the profile does not exist or is not mutable
+    */
    public MutableProfile getProfile(ProfileKey key) throws NoSuchProfileException
    {
       Profile profile = this.ps.getActiveProfile(key);
@@ -303,6 +308,21 @@
    }
    
    /**
+    * Get the target profile to upload contents.
+    * If the DeploymentManager was not loaded, the
+    * default key is used.
+    * 
+    * @return the target profile key
+    */
+   protected ProfileKey getTargetProfile()
+   {
+      if(this.activeProfileKey == null)
+         return this.defaultKey;
+      
+      return this.activeProfileKey;
+   }
+   
+   /**
     * TODO: should the targets include cluster info
     * @param name
     * @return
@@ -315,11 +335,5 @@
       targets.add(hostTarget);
       return targets;
    }
-
-   public Collection<ProfileKey> getProfiles()
-   {
-      // FIXME
-      return this.ps.getActiveProfileKeys();
-   }
    
 }

Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/upload/SerializableDeploymentID.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/upload/SerializableDeploymentID.java	2009-03-02 09:20:03 UTC (rev 84924)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/upload/SerializableDeploymentID.java	2009-03-02 09:26:46 UTC (rev 84925)
@@ -41,23 +41,25 @@
    private transient InputStream contentIS;
    private String[] deploymentNames;
    private String[] repositoryNames;
+   private ProfileKey profileKey;
    private String description;
    private URL contentURL;
    private boolean copyContent;
 
    public SerializableDeploymentID(DeploymentID deployment)
    {
-      this(deployment.getNames(), deployment.getDescription());
+      this(deployment.getNames(), deployment.getProfile(), deployment.getDescription());
    }
    
-   public SerializableDeploymentID(String name, String description)
+   public SerializableDeploymentID(String name, ProfileKey profileKey, String description)
    {
-      this(new String[]{name}, description);
+      this(new String[]{name}, profileKey, description);
    }
    
-   public SerializableDeploymentID(String[] names, String description)
+   public SerializableDeploymentID(String[] names, ProfileKey profileKey, String description)
    {
       this.deploymentNames = names;
+      this.profileKey = profileKey;
       this.description = description;
       this.copyContent = true; // by default we copy content
    }
@@ -84,7 +86,7 @@
     */
    public ProfileKey getProfile()
    {
-      return null;
+      return this.profileKey;
    }
    
    public String getDescription()

Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/AbstractDeployHandler.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/AbstractDeployHandler.java	2009-03-02 09:20:03 UTC (rev 84924)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/AbstractDeployHandler.java	2009-03-02 09:26:46 UTC (rev 84925)
@@ -37,7 +37,10 @@
 import org.jboss.managed.api.ManagedDeployment.DeploymentPhase;
 import org.jboss.profileservice.management.upload.SerializableDeploymentID;
 import org.jboss.profileservice.spi.DeploymentRepository;
+import org.jboss.profileservice.spi.NoSuchProfileException;
 import org.jboss.profileservice.spi.ProfileDeployment;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.ProfileRepository;
 import org.jboss.remoting.InvocationRequest;
 import org.jboss.remoting.ServerInvoker;
 import org.jboss.remoting.callback.InvokerCallbackHandler;
@@ -58,8 +61,8 @@
    implements StreamInvocationHandler
 {
 
-   /** The profile deployment repository. */
-   private DeploymentRepository deploymentRepository;
+   /** The profile repository. */
+   protected ProfileRepository profileRepository;
    
    /** The deployer. */
    private MainDeployerAdapter deployer;
@@ -70,14 +73,14 @@
    /** The logger. */
    protected static final Logger log = Logger.getLogger(DeployHandler.class);
    
-   public DeploymentRepository getDeploymentRepository()
+   public ProfileRepository getProfileRepository()
    {
-      return deploymentRepository;
+      return profileRepository;
    }
    
-   public void setDeploymentRepository(DeploymentRepository deploymentRepository)
+   public void setProfileRepository(ProfileRepository profileRepository)
    {
-      this.deploymentRepository = deploymentRepository;
+      this.profileRepository = profileRepository;
    }
    
    public MainDeployerAdapter getDeployer()
@@ -90,12 +93,12 @@
       this.deployer = deployer;
    }
    
-   protected String[] getRepositoryNames(String[] names) throws Exception
+   protected String[] getRepositoryNames(String[] names, DeploymentRepository deploymentRepository) throws Exception
    {
       if(names == null || names.length == 0)
          return new String[0];
       
-      return this.deploymentRepository.getRepositoryNames(names);
+      return deploymentRepository.getRepositoryNames(names);
    }
    
    public void addListener(InvokerCallbackHandler arg0)
@@ -115,6 +118,22 @@
    }
    
    /**
+    * Get the deployment repository for a given DeploymentID.
+    * 
+    * @param dtID the DeploymentID
+    * @return the deployment repository
+    * @throws NoSuchProfileException if the deployment repository does not exist 
+    */
+   protected DeploymentRepository getDeploymentRepository(DeploymentID dtID) throws Exception
+   {
+      ProfileKey key = dtID.getProfile();
+      if(key == null)
+         throw new IllegalStateException("No profile key attached to deploymentID "+ dtID);
+      
+      return this.profileRepository.getProfileDeploymentRepository(key);
+   }
+   
+   /**
     * Handle a DeploymentManager invocation other than distribute
     * 
     * @param request - the remoting invocation
@@ -138,8 +157,9 @@
          {
             if( parameter.equals("getRepositoryNames"))
             {
-               String[] names = (String[]) payload.get("names");
-               returnValue = getRepositoryNames(names);
+               String[] names = dtID.getNames();
+               DeploymentRepository deploymentRepository = getDeploymentRepository(dtID);
+               returnValue = getRepositoryNames(names, deploymentRepository);
             }
             else if( parameter.equals("distribute") )
             {
@@ -184,12 +204,17 @@
     */
    public Object handleStream(InputStream contentIS, InvocationRequest request) throws Throwable
    {
+      // Get the deployment repository for this deploymentID
       SerializableDeploymentID deploymentTarget = (SerializableDeploymentID) request.getParameter();
+      DeploymentRepository deploymentRepository = getDeploymentRepository(deploymentTarget);
+      // Start to handle stream
       log.info("Handle stream, deploymentTarget: " + deploymentTarget);
       deploymentTarget.setContentIS(contentIS);
       String[] names = deploymentTarget.getNames();
+      // Add deployment content to the repository
       String repositoryName = deploymentRepository.addDeploymentContent(names[0], contentIS);
       log.info("End handle stream, repositoryName: " + repositoryName);
+      // Return the repository names
       String[] rnames = {repositoryName};
       deploymentTarget.setRepositoryNames(rnames);
       return new InvocationResponse(repositoryName);
@@ -204,22 +229,23 @@
    protected void start(DeploymentID dtID) throws Exception
    {
       String[] names = dtID.getNames();
+      DeploymentRepository deploymentRepository = getDeploymentRepository(dtID);
       log.info("Begin start, "+Arrays.asList(names));
       
       for(String name : names)
       {
          // Schedule start for the deployment
-         scheduleStart(name);
+         scheduleStart(name, deploymentRepository);
       }
       // CheckComplete
       processCheckComplete();
       log.info("End start, "+Arrays.asList(names));
    }
 
-   protected void scheduleStart(String name) throws Exception
+   protected void scheduleStart(String name, DeploymentRepository deploymentRepository) throws Exception
    {
-      VirtualFile vf = this.deploymentRepository.getDeploymentContent(name);
-      scheduleStart(vf, this.deploymentRepository);
+      VirtualFile vf = deploymentRepository.getDeploymentContent(name);
+      scheduleStart(vf, deploymentRepository);
    }
    
    protected void scheduleStart(VirtualFile vf, DeploymentRepository repository) throws Exception
@@ -245,22 +271,18 @@
    protected void stop(DeploymentID dtID) throws Exception
    {
       String[] names = dtID.getNames();
+      DeploymentRepository deploymentRepository = getDeploymentRepository(dtID);
       log.info("Stop, "+Arrays.asList(names));
       
       for(String name : names)
       {
          // Schedule stop
-         scheduleStop(name);
+         scheduleStop(name, deploymentRepository);
       }
       // CheckComplete
       processCheckComplete();
    }
    
-   protected void scheduleStop(String name) throws Exception
-   {
-      scheduleStop(name, this.deploymentRepository);
-   }
-   
    protected void scheduleStop(String name, DeploymentRepository repository) throws Exception
    {
       // Obtain the deployment
@@ -284,19 +306,16 @@
    protected void remove(DeploymentID dtID) throws Exception
    {
       String[] names = dtID.getNames();
+      DeploymentRepository deploymentRepository = getDeploymentRepository(dtID);
       log.info("Remove, "+Arrays.asList(names));
+      
       for(String name : names)
       {
          // Remove from repository
-         removeDeployment(name);
+         removeDeployment(name, deploymentRepository);
       }
    }
    
-   protected void removeDeployment(String name) throws Exception
-   {
-      removeDeployment(name, this.deploymentRepository);
-   }
-   
    protected void removeDeployment(String name, DeploymentRepository repository) throws Exception
    {
       // Remove the deployment

Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/DeployHandler.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/DeployHandler.java	2009-03-02 09:20:03 UTC (rev 84924)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/DeployHandler.java	2009-03-02 09:26:46 UTC (rev 84925)
@@ -31,6 +31,7 @@
 
 import org.jboss.deployers.spi.management.deploy.DeploymentID;
 import org.jboss.logging.Logger;
+import org.jboss.profileservice.management.upload.AbstractTransientProfileManager;
 import org.jboss.profileservice.spi.DeploymentRepository;
 import org.jboss.virtual.VFS;
 import org.jboss.virtual.VirtualFile;
@@ -59,19 +60,20 @@
       return transientDeploymentRepository;
    }
    
-   public void setTransientDeploymentRepository(DeploymentRepository transientDeploymentRepository)
+   public void start() throws Exception
    {
-      this.transientDeploymentRepository = transientDeploymentRepository;
+      // Set the transient profile repository
+      this.transientDeploymentRepository = profileRepository.getProfileDeploymentRepository(AbstractTransientProfileManager.TRANSIENT_PROFILE_KEY);
    }
 
    @Override
-   protected String[] getRepositoryNames(String[] names) throws Exception
+   protected String[] getRepositoryNames(String[] names, DeploymentRepository deploymentRepository) throws Exception
    {
       // get the transient repository names
       List<String> repositoryNames = getTransientRepositoryNames(names);
       
       // Add the results from the profile deployment repository
-      for(String name : super.getRepositoryNames(names))
+      for(String name : super.getRepositoryNames(names, deploymentRepository))
          repositoryNames.add(name);
       
       return repositoryNames.toArray( new String[repositoryNames.size()] );
@@ -126,7 +128,7 @@
    }
 
    @Override
-   protected void scheduleStart(String name) throws Exception
+   protected void scheduleStart(String name, DeploymentRepository deploymentRepository) throws Exception
    {
       String deploymentName = resolveDeploymentName(name);
       if(deploymentName != null)
@@ -136,12 +138,12 @@
       }
       else
       {
-         super.scheduleStart(name);
+         super.scheduleStart(name, deploymentRepository);
       }
    }
    
    @Override
-   protected void scheduleStop(String name) throws Exception
+   protected void scheduleStop(String name, DeploymentRepository deploymentRepository) throws Exception
    {
       String deploymentName = resolveDeploymentName(name);
       if(deploymentName != null)
@@ -150,12 +152,12 @@
       }
       else
       {
-         super.scheduleStop(name);
+         super.scheduleStop(name, deploymentRepository);
       }
    }
    
    @Override
-   protected void removeDeployment(String name) throws Exception
+   protected void removeDeployment(String name, DeploymentRepository deploymentRepository) throws Exception
    {
       String deploymentName = resolveDeploymentName(name);
       if(deploymentName != null)
@@ -165,7 +167,7 @@
       }
       else
       {
-         super.removeDeployment(name);
+         super.removeDeployment(name, deploymentRepository);
       }
    }
    

Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/StreamingDeploymentTarget.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/StreamingDeploymentTarget.java	2009-03-02 09:20:03 UTC (rev 84924)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/StreamingDeploymentTarget.java	2009-03-02 09:26:46 UTC (rev 84925)
@@ -121,15 +121,13 @@
       }
    }
 
-   public String[] getRepositoryNames(String[] names) throws Exception
+   public String[] getRepositoryNames(DeploymentID dtID) throws Exception
    {
       Client client = getClient();
       try
       {
-         log.debug("Begin getRepositoryNames: " + Arrays.asList(names));
-         HashMap<Object, Object> args = new HashMap<Object, Object>();
-         args.put("names", names);
-         String[] rnames = (String[]) invoke(client, "getRepositoryNames", args);
+         log.debug("Begin getRepositoryNames: " + Arrays.asList(dtID.getNames()));
+         String[] rnames = (String[]) invoke(client, "getRepositoryNames", createArgs(dtID));
          log.debug("End getRepositoryNames: " + Arrays.asList(rnames));
          return rnames;
       }

Modified: trunk/profileservice/src/resources/profileservice-jboss-beans.xml
===================================================================
--- trunk/profileservice/src/resources/profileservice-jboss-beans.xml	2009-03-02 09:20:03 UTC (rev 84924)
+++ trunk/profileservice/src/resources/profileservice-jboss-beans.xml	2009-03-02 09:26:46 UTC (rev 84925)
@@ -88,14 +88,22 @@
             <parameter>DeploymentManager</parameter>
         </uninstall>
         <property name="deployer"><inject bean="ProfileServiceDeployer"/></property>
+        <property name="profileRepository"><inject bean="ProfileRepositoryFactory" /></property>
+        <depends>TransientDeploymentsProfileManager</depends>
     </bean>
 
+    <bean name="TransientDeploymentsProfileManager"
+        class="org.jboss.profileservice.management.upload.AbstractTransientProfileManager">
+        <property name="profileService"><inject bean="ProfileService"/></property>
+        <property name="profileFactory"><inject bean="ProfileFactory" /></property>
+    </bean>
+
     <bean name="RuntimeComponentDispatcher" class="org.jboss.profileservice.management.KernelBusRuntimeComponentDispatcher">
        <constructor>
           <parameter class="org.jboss.kernel.Kernel"><inject bean="jboss.kernel:service=Kernel"/></parameter>
        </constructor>
     </bean>
-
+    
     <!--
         The ManagementView plugin
     -->
@@ -138,10 +146,8 @@
                 <null/>
             </parameter>
         </uninstall>
+        <property name="defaultProfileKey"><inject bean="DefaultProfileKey"/></property>
         <property name="profileService"><inject bean="ProfileService"/></property>
-        <property name="profileFactory"><inject bean="ProfileFactory" /></property>
-        <property name="profileRepository"><inject bean="ProfileRepositoryFactory" /></property>
-        <property name="deployHandler"><inject bean="DeploymentInvocationHandler"/></property>
         <property name="locator"><inject bean="ConnectorMBean" property="invokerLocator"/></property>
         <property name="remotingSubsystem">DeploymentManager</property>
     </bean>

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/TypedProfileRepository.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/TypedProfileRepository.java	2009-03-02 09:20:03 UTC (rev 84924)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/TypedProfileRepository.java	2009-03-02 09:26:46 UTC (rev 84925)
@@ -61,7 +61,7 @@
       return this.repositories.keySet();
    }
 
-   public DeploymentRepository getProfileDeploymentRepository(ProfileKey key) throws Exception, NoSuchProfileException
+   public DeploymentRepository getProfileDeploymentRepository(ProfileKey key) throws NoSuchProfileException
    {
       DeploymentRepository repository = this.repositories.get(key);
       if(repository == null)

Modified: trunk/system/src/tests/org/jboss/test/server/profileservice/support/MockProfileRepository.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/server/profileservice/support/MockProfileRepository.java	2009-03-02 09:20:03 UTC (rev 84924)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/support/MockProfileRepository.java	2009-03-02 09:26:46 UTC (rev 84925)
@@ -58,7 +58,7 @@
       return repository.createDeploymentRepository(key, source);
    }
 
-   public DeploymentRepository getProfileDeploymentRepository(ProfileKey key) throws Exception, NoSuchProfileException
+   public DeploymentRepository getProfileDeploymentRepository(ProfileKey key) throws NoSuchProfileException
    {
       // FIXME
       return null;




More information about the jboss-cvs-commits mailing list