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

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu May 22 18:23:28 EDT 2008


Author: scott.stark at jboss.org
Date: 2008-05-22 18:23:27 -0400 (Thu, 22 May 2008)
New Revision: 73604

Added:
   trunk/profileservice/src/main/org/jboss/profileservice/management/upload/
   trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentManagerImpl.java
   trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentProgressImpl.java
   trunk/profileservice/src/main/org/jboss/profileservice/management/upload/SerializableDeploymentID.java
   trunk/profileservice/src/main/org/jboss/profileservice/management/upload/SerializableDeploymentStatus.java
   trunk/profileservice/src/main/org/jboss/profileservice/management/upload/messages.properties
   trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/
   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/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentID.java
   trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentManager.java
   trunk/testsuite/imports/sections/profileservice.xml
   trunk/testsuite/src/main/org/jboss/test/profileservice/mcbeans/
   trunk/testsuite/src/main/org/jboss/test/profileservice/mcbeans/Bean1.java
   trunk/testsuite/src/main/org/jboss/test/profileservice/test/DeployUnitTestCase.java
   trunk/testsuite/src/resources/profileservice/
   trunk/testsuite/src/resources/profileservice/testMCBeansDeployment-beans.xml
Removed:
   trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentTargetID.java
Modified:
   trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java
   trunk/profileservice/src/main/org/jboss/profileservice/remoting/ProfileServiceInvocationHandler.java
   trunk/profileservice/src/main/org/jboss/profileservice/remoting/ProxyFactory.java
   trunk/profileservice/src/resources/profileservice-beans.xml
   trunk/system/src/main/org/jboss/deployers/spi/management/ManagementView.java
   trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentProgress.java
   trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentStatus.java
   trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentTarget.java
   trunk/system/src/main/org/jboss/deployers/spi/management/deploy/ProgressEvent.java
   trunk/system/src/main/org/jboss/profileservice/spi/DeploymentRepository.java
   trunk/system/src/main/org/jboss/profileservice/spi/ProfileService.java
   trunk/system/src/main/org/jboss/system/server/profileservice/basic/ProfileServiceImpl.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/ProfileServiceImpl.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/RepositoryAdminAdaptor.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/SerializableDeploymentRepository.java
   trunk/testsuite/imports/test-jars.xml
   trunk/testsuite/src/main/org/jboss/test/profileservice/test/AbstractProfileServiceTest.java
Log:
JBAS-5370, update content deployment api

Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java	2008-05-22 21:17:37 UTC (rev 73603)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java	2008-05-22 22:23:27 UTC (rev 73604)
@@ -23,6 +23,7 @@
 
 import java.io.Serializable;
 import java.lang.annotation.Annotation;
+import java.net.URL;
 import java.text.MessageFormat;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -46,6 +47,9 @@
 import org.jboss.deployers.spi.management.DeploymentTemplate;
 import org.jboss.deployers.spi.management.ManagementView;
 import org.jboss.deployers.spi.management.RuntimeComponentDispatcher;
+import org.jboss.deployers.spi.management.deploy.DeploymentProgress;
+import org.jboss.deployers.spi.management.deploy.DeploymentStatus;
+import org.jboss.deployers.spi.management.deploy.DeploymentID;
 import org.jboss.deployers.vfs.spi.client.VFSDeployment;
 import org.jboss.deployers.vfs.spi.client.VFSDeploymentFactory;
 import org.jboss.logging.Logger;
@@ -78,6 +82,8 @@
 import org.jboss.metatype.api.values.SimpleValueSupport;
 import org.jboss.metatype.api.values.MetaValueFactory;
 import org.jboss.profileservice.management.plugins.BasicDeploymentTemplateInfo;
+import org.jboss.profileservice.management.upload.DeploymentProgressImpl;
+import org.jboss.profileservice.management.upload.SerializableDeploymentID;
 import org.jboss.profileservice.spi.AttachmentsSerializer;
 import org.jboss.profileservice.spi.NoSuchDeploymentException;
 import org.jboss.profileservice.spi.NoSuchProfileException;
@@ -193,7 +199,7 @@
          }
          catch(Exception e)
          {
-            log.warn("Failed to create ManagedDeployment for: " + name, e);
+            log.debug("Failed to create ManagedDeployment for: " + name, e);
          }
       }
       if(this.runtimeMOs.size() > 0)

Added: trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentManagerImpl.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentManagerImpl.java	                        (rev 0)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentManagerImpl.java	2008-05-22 22:23:27 UTC (rev 73604)
@@ -0,0 +1,183 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt 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.net.URI;
+import java.net.URL;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+import org.jboss.deployers.spi.management.deploy.DeploymentManager;
+import org.jboss.deployers.spi.management.deploy.DeploymentProgress;
+import org.jboss.deployers.spi.management.deploy.DeploymentTarget;
+import org.jboss.deployers.spi.management.deploy.DeploymentID;
+import org.jboss.logging.Logger;
+import org.jboss.managed.api.ManagedDeployment.DeploymentPhase;
+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.DeploymentRepositoryFactory;
+import org.jboss.profileservice.spi.NoSuchProfileException;
+import org.jboss.profileservice.spi.Profile;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.ProfileService;
+import org.jboss.remoting.InvokerLocator;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class DeploymentManagerImpl
+   implements DeploymentManager
+{
+   private static Logger log = Logger.getLogger(DeploymentManagerImpl.class);
+   private static final String BUNDLE_NAME = "org.jboss.profileservice.management.upload.messages"; //$NON-NLS-1$
+   /** */
+   private ProfileService ps;
+   /** The currently loaded profile */
+   private Profile activeProfile;
+   private DeploymentRepositoryFactory repositoryFactory;
+   private DeployHandler deployHandler;
+
+   /** */
+   private ResourceBundle i18n;
+   /** */
+   private Locale currentLocale;
+   /** */
+   private MessageFormat formatter = new MessageFormat("");
+   private InvokerLocator locator;
+   private String remotingSubsystem = "DeploymentManager";
+
+   public DeploymentManagerImpl()
+   {
+      currentLocale = Locale.getDefault();
+      formatter.setLocale(currentLocale);
+      i18n = ResourceBundle.getBundle(BUNDLE_NAME, currentLocale);
+   }
+
+   
+   public ProfileService getProfileService()
+   {
+      return ps;
+   }
+   public void setProfileService(ProfileService ps)
+   {
+      this.ps = ps;
+   }
+
+   public DeploymentRepositoryFactory getRepositoryFactory()
+   {
+      return repositoryFactory;
+   }
+   public void setRepositoryFactory(DeploymentRepositoryFactory repositoryFactory)
+   {
+      this.repositoryFactory = repositoryFactory;
+   }
+
+   public DeployHandler getDeployHandler()
+   {
+      return deployHandler;
+   }
+   public void setDeployHandler(DeployHandler deployHandler)
+   {
+      this.deployHandler = deployHandler;
+   }
+
+   public InvokerLocator getLocator()
+   {
+      return locator;
+   }
+   public void setLocator(InvokerLocator locator)
+   {
+      this.locator = locator;
+   }
+
+   public String getRemotingSubsystem()
+   {
+      return remotingSubsystem;
+   }
+   public void setRemotingSubsystem(String remotingSubsystem)
+   {
+      this.remotingSubsystem = remotingSubsystem;
+   }
+
+   public DeploymentProgress distribute(String name, DeploymentPhase phase,
+         URL contentURL)
+   {
+      // TODO, the targets need to be externalized
+      List<DeploymentTarget> targets = new ArrayList<DeploymentTarget>();
+      StreamingDeploymentTarget hostTarget = new StreamingDeploymentTarget(locator, name, remotingSubsystem);
+      targets.add(hostTarget);
+      SerializableDeploymentID deployment = new SerializableDeploymentID(name, phase, contentURL.toString());
+      deployment.setContentURL(contentURL);
+      DeploymentProgressImpl progressImpl = new DeploymentProgressImpl(targets, deployment);
+      return progressImpl;
+   }
+
+   public boolean isRedeploySupported()
+   {
+      return true;
+   }
+
+   public void loadProfile(ProfileKey key) throws Exception
+   {
+      activeProfile = ps.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);
+      }
+      // Set the deployment repository on the handler
+      DeploymentRepository repository = repositoryFactory.getDeploymentRepository(key);
+      deployHandler.setDeploymentRepository(repository);
+   }
+
+   public DeploymentProgress redeploy(String name, DeploymentPhase phase,
+         URL contentURL)
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   public void start(String name, DeploymentPhase phase) throws Exception
+   {
+      // TODO Auto-generated method stub
+      
+   }
+
+   public void stop(String name, DeploymentPhase phase) throws Exception
+   {
+      // TODO Auto-generated method stub
+      
+   }
+
+   public void undeploy(String name, DeploymentPhase phase) throws Exception
+   {
+      // TODO Auto-generated method stub
+      
+   }
+}

Added: trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentProgressImpl.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentProgressImpl.java	                        (rev 0)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentProgressImpl.java	2008-05-22 22:23:27 UTC (rev 73604)
@@ -0,0 +1,150 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt 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.io.Serializable;
+import java.net.URL;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import org.jboss.deployers.spi.management.deploy.DeploymentProgress;
+import org.jboss.deployers.spi.management.deploy.DeploymentStatus;
+import org.jboss.deployers.spi.management.deploy.DeploymentID;
+import org.jboss.deployers.spi.management.deploy.DeploymentTarget;
+import org.jboss.deployers.spi.management.deploy.ProgressEvent;
+import org.jboss.deployers.spi.management.deploy.ProgressListener;
+import org.jboss.deployers.spi.management.deploy.DeploymentStatus.CommandType;
+import org.jboss.deployers.spi.management.deploy.DeploymentStatus.StateType;
+
+/**
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class DeploymentProgressImpl
+   implements DeploymentProgress, Serializable
+{
+   private static final long serialVersionUID = 1;
+
+   /** The client side listeners */
+   private transient CopyOnWriteArrayList<ProgressListener> listeners =
+      new CopyOnWriteArrayList<ProgressListener>();
+   private transient DeploymentStatus currentStatus;
+   private transient boolean isCancelled;
+   /** The targets to distribute to */
+   private List<DeploymentTarget> targets;
+   /** The deployment being distributed */
+   private DeploymentID deployment;
+
+   public DeploymentProgressImpl(List<DeploymentTarget> targets, DeploymentID deployment)
+   {
+      this.targets = targets;
+      this.deployment = deployment;
+   }
+
+   public synchronized void addProgressListener(ProgressListener listener)
+   {
+      if(listeners == null)
+         listeners = new CopyOnWriteArrayList<ProgressListener>();
+      listeners.add(listener);
+   }
+   public void removeProgressListener(ProgressListener listener)
+   {
+      listeners.remove(listener);
+   }
+
+   /**
+    * Begins the deployment distribution process
+    */
+   public void run()
+   {
+      CommandType command = CommandType.DISTRIBUTE;
+      currentStatus = new SerializableDeploymentStatus(command, StateType.DEPLOYING);
+      ProgressEvent event =  new ProgressEvent(deployment, currentStatus);
+      notify(event);
+      for(DeploymentTarget target : targets)
+      {
+         if(isCancelled)
+         {
+            currentStatus = new SerializableDeploymentStatus(command, StateType.CANCELLED);
+            event =  new ProgressEvent(deployment, currentStatus);
+            notify(event);
+            break;
+         }
+
+         try
+         {
+            target.distribute(deployment);
+            currentStatus = new SerializableDeploymentStatus(command, StateType.COMPLETED);
+            event =  new ProgressEvent(deployment, currentStatus);
+            notify(event);
+         }
+         catch(Exception e)
+         {
+            SerializableDeploymentStatus status = new SerializableDeploymentStatus(command, StateType.FAILED);
+            status.setFailure(e);
+            status.setFailed(true);
+            currentStatus = status;
+            ProgressEvent error = new ProgressEvent(deployment, currentStatus);
+            notify(error);
+         }
+      }
+   }
+
+   public void cancel()
+   {
+      isCancelled = true;
+   }
+
+   public DeploymentStatus getDeploymentStatus()
+   {
+      return currentStatus;
+   }
+   public void setDeploymentStatus(DeploymentStatus currentStatus)
+   {
+      this.currentStatus = currentStatus;
+   }
+
+   public DeploymentID getDeploymentID()
+   {
+      return deployment;
+   }
+
+   public List<DeploymentTarget> getDeploymentTargets()
+   {
+      return targets;
+   }
+
+   protected void notify(ProgressEvent event)
+   {
+      for(ProgressListener listener : listeners)
+      {
+         try
+         {
+            listener.progressEvent(event);
+         }
+         catch(Throwable ignore)
+         {
+         }
+      }
+   }
+}

Added: trunk/profileservice/src/main/org/jboss/profileservice/management/upload/SerializableDeploymentID.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/upload/SerializableDeploymentID.java	                        (rev 0)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/upload/SerializableDeploymentID.java	2008-05-22 22:23:27 UTC (rev 73604)
@@ -0,0 +1,100 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt 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.io.InputStream;
+import java.io.Serializable;
+import java.net.URL;
+
+import org.jboss.deployers.spi.management.deploy.DeploymentID;
+import org.jboss.managed.api.ManagedDeployment.DeploymentPhase;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class SerializableDeploymentID
+   implements DeploymentID, Serializable
+{
+   private static final long serialVersionUID = 1;
+
+   /** An InputStream to use to copy the contents */
+   private transient InputStream contentIS;
+   private String deploymentName;
+   private DeploymentPhase phase;
+   private String description;
+   private URL contentURL;
+
+   public SerializableDeploymentID(DeploymentID deployment)
+   {
+      this(deployment.getName(), deployment.getPhase(), deployment.getDescription());
+   }
+   public SerializableDeploymentID(String name, DeploymentPhase phase, String description)
+   {
+      this.deploymentName = name;
+      this.phase = phase;
+      this.description = description;
+   }
+
+   public String getName()
+   {
+      return deploymentName;
+   }
+
+   public DeploymentPhase getPhase()
+   {
+      return phase;
+   }
+
+   public String getDescription()
+   {
+      return description;
+   }
+
+   public URL getContentURL()
+   {
+      return contentURL;
+   }
+   public void setContentURL(URL contentURL)
+   {
+      this.contentURL = contentURL;
+   }
+
+   /**
+    * An optional deployment archive content stream for the top-level
+    * deployment.
+    * 
+    * @return the archive input stream if it exists
+    */
+   public InputStream getContentIS()
+   {
+      return contentIS;
+   }
+   /**
+    * 
+    * @param contentIS
+    */
+   public void setContentIS(InputStream contentIS)
+   {
+      this.contentIS = contentIS;
+   }
+}

Added: trunk/profileservice/src/main/org/jboss/profileservice/management/upload/SerializableDeploymentStatus.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/upload/SerializableDeploymentStatus.java	                        (rev 0)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/upload/SerializableDeploymentStatus.java	2008-05-22 22:23:27 UTC (rev 73604)
@@ -0,0 +1,141 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt 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.io.PrintWriter;
+import java.io.Serializable;
+import java.io.StringWriter;
+
+import org.jboss.deployers.spi.management.deploy.DeploymentStatus;
+
+/**
+ * Simple javabean impl of DeploymentStatus
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class SerializableDeploymentStatus implements DeploymentStatus,
+      Serializable
+{
+   private static final long serialVersionUID = 1;
+
+   private CommandType command;
+   private Exception failure;
+   private String message;
+   private StateType state;
+   private boolean isCompleted;
+   private boolean isFailed;
+   private boolean isRunning;
+
+   public SerializableDeploymentStatus(CommandType command, StateType state)
+   {
+      this.command = command;
+      this.state = state;
+   }
+
+   public CommandType getCommand()
+   {
+      return command;
+   }
+   public void setCommand(CommandType command)
+   {
+      this.command = command;
+   }
+   public Exception getFailure()
+   {
+      return failure;
+   }
+   public void setFailure(Exception failure)
+   {
+      this.failure = failure;
+   }
+   public String getMessage()
+   {
+      return message;
+   }
+   public void setMessage(String message)
+   {
+      this.message = message;
+   }
+   public StateType getState()
+   {
+      return state;
+   }
+   public void setState(StateType state)
+   {
+      this.state = state;
+   }
+   public boolean isCompleted()
+   {
+      return isCompleted;
+   }
+   public void setCompleted(boolean isCompleted)
+   {
+      this.isCompleted = isCompleted;
+   }
+   public boolean isFailed()
+   {
+      return isFailed;
+   }
+   public void setFailed(boolean isFailed)
+   {
+      this.isFailed = isFailed;
+   }
+   public boolean isRunning()
+   {
+      return isRunning;
+   }
+   public void setRunning(boolean isRunning)
+   {
+      this.isRunning = isRunning;
+   }
+
+   @Override
+   public String toString()
+   {
+      StringBuffer tmp = new StringBuffer("DeploymentStatus(");
+      tmp.append("command=");
+      tmp.append(command);
+      tmp.append(",state=");
+      tmp.append(state);
+      tmp.append(",message=");
+      tmp.append(message);
+      tmp.append(",isCompleted=");
+      tmp.append(isCompleted);
+      tmp.append(",isRunning=");
+      tmp.append(isRunning);
+      tmp.append(",isFailed=");
+      tmp.append(isFailed);
+
+      if(failure != null)
+      {
+         StringWriter sw = new StringWriter();
+         PrintWriter pw = new PrintWriter(sw);
+         failure.printStackTrace(pw);
+         tmp.append(",failure:\n");
+         tmp.append(sw.toString());
+      }
+      tmp.append(")");
+      return tmp.toString();
+   }
+
+}

Added: trunk/profileservice/src/main/org/jboss/profileservice/management/upload/messages.properties
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/upload/messages.properties	                        (rev 0)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/upload/messages.properties	2008-05-22 22:23:27 UTC (rev 73604)
@@ -0,0 +1,2 @@
+# resource bundle for the DeploymentManager
+DeploymentManager.NoSuchProfileException=Failed to find profile for key: {0}

Added: trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/DeployHandler.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/DeployHandler.java	                        (rev 0)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/DeployHandler.java	2008-05-22 22:23:27 UTC (rev 73604)
@@ -0,0 +1,148 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt 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.remoting;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.util.Map;
+import java.util.zip.ZipInputStream;
+
+import javax.management.MBeanServer;
+import javax.management.MBeanServerInvocationHandler;
+import javax.management.ObjectName;
+
+import org.jboss.aop.joinpoint.InvocationResponse;
+import org.jboss.aspects.remoting.AOPRemotingInvocationHandler;
+import org.jboss.deployers.spi.management.deploy.DeploymentTarget;
+import org.jboss.deployers.spi.management.deploy.DeploymentID;
+import org.jboss.deployers.vfs.plugins.client.AbstractVFSDeployment;
+import org.jboss.deployers.vfs.spi.client.VFSDeployment;
+import org.jboss.logging.Logger;
+import org.jboss.managed.api.ManagedDeployment.DeploymentPhase;
+import org.jboss.profileservice.management.upload.SerializableDeploymentID;
+import org.jboss.profileservice.spi.DeploymentRepository;
+import org.jboss.remoting.InvocationRequest;
+import org.jboss.remoting.ServerInvoker;
+import org.jboss.remoting.callback.InvokerCallbackHandler;
+import org.jboss.remoting.stream.StreamInvocationHandler;
+import org.jboss.virtual.VFS;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * A remoting StreamInvocationHandler installed as the profile service subsystem
+ * handler and used by the StreamingDeploymentTarget implementation. 
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class DeployHandler extends AOPRemotingInvocationHandler
+   implements StreamInvocationHandler
+{
+   static Logger log = Logger.getLogger(DeployHandler.class);
+   private DeploymentRepository deploymentRepository;
+
+   
+   public DeploymentRepository getDeploymentRepository()
+   {
+      return deploymentRepository;
+   }
+
+   public void setDeploymentRepository(DeploymentRepository deploymentRepository)
+   {
+      this.deploymentRepository = deploymentRepository;
+   }
+
+   /**
+    * Handle a deployService deploy invocation
+    * @param request - the remoting invocation
+    */
+   public Object handleStream(InputStream contentIS, InvocationRequest request)
+      throws Throwable
+   {
+      SerializableDeploymentID deploymentTarget = (SerializableDeploymentID) request.getParameter();
+      log.debug("handleStream, deploymentTarget: "+deploymentTarget);
+      Map payload = request.getRequestPayload();
+      deploymentTarget.setContentIS(contentIS);
+      DeploymentPhase phase = deploymentTarget.getPhase();
+      //ZipInputStream zis = new ZipInputStream(contentIS);
+      deploymentRepository.addDeploymentContent(deploymentTarget.getName(), contentIS, phase);
+
+      return new InvocationResponse(null);
+   }
+
+   public void addListener(InvokerCallbackHandler arg0)
+   {      
+   }
+
+   /**
+    * Handle a deployService invocation other than deploy
+    * @param request - the remoting invocation
+    */
+   public Object invoke(InvocationRequest request) throws Throwable
+   {
+      InvocationResponse value = (InvocationResponse) super.invoke(request);
+      Map payload = request.getRequestPayload();
+      DeploymentID dtID = (DeploymentID) payload.get("DeploymentTargetID");
+      Object returnValue = value;
+      log.debug("invoke, dtID: "+dtID+", payload: "+payload);
+/*
+      if( name.equals("start") )
+      {
+         deployService.start(url);
+      }
+      else if( name.equals("stop") )
+      {
+         deployService.stop(url);
+         
+      }
+      else if( name.equals("undeploy") )
+      {
+         deployService.undeploy(url);         
+      }
+      else if( name.equals("getAvailableModules") )
+      {
+         Integer moduleType = (Integer) payload.get("moduleType");
+         SerializableTargetModuleID[] ids = deployService.getAvailableModules(moduleType);
+         returnValue = ids;
+      }
+      */
+      return returnValue;
+   }
+
+   public void removeListener(InvokerCallbackHandler arg0)
+   {
+   }
+
+   public void setInvoker(ServerInvoker arg0)
+   {
+   }
+
+   public void setMBeanServer(MBeanServer arg0)
+   {
+   }
+}

Added: trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/StreamingDeploymentTarget.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/StreamingDeploymentTarget.java	                        (rev 0)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/StreamingDeploymentTarget.java	2008-05-22 22:23:27 UTC (rev 73604)
@@ -0,0 +1,199 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt 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.remoting;
+
+import java.io.InputStream;
+import java.io.Serializable;
+import java.net.URL;
+import java.util.HashMap;
+
+import org.jboss.deployers.spi.management.deploy.DeploymentTarget;
+import org.jboss.deployers.spi.management.deploy.DeploymentID;
+import org.jboss.logging.Logger;
+import org.jboss.profileservice.management.upload.SerializableDeploymentID;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.InvokerLocator;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class StreamingDeploymentTarget
+   implements DeploymentTarget, Serializable
+{
+   private static final long serialVersionUID = 1;
+   private static final Logger log = Logger.getLogger(StreamingDeploymentTarget.class);
+
+   /** The deployment target locator */
+   private InvokerLocator locator;
+   private String name;
+   private String subsystem;
+
+   /**
+    * Create a target given a remoting locator 
+    * @param locator -
+    * @param name - 
+    * @param subsystem - 
+    */
+   public StreamingDeploymentTarget(InvokerLocator locator, String name, String subsystem)
+   {
+      log.debug("new StreamingTarget: " + locator);
+      this.name = name;
+      this.subsystem = subsystem;
+      this.locator = locator;
+   }
+   
+   public String getDescription()
+   {
+      return name + "(" + locator + ")";
+   }
+
+   public String getName()
+   {
+      return name;
+   }
+
+   public InvokerLocator getInvokerLocator()
+   {
+      return locator;
+   }
+
+   /**
+    * Deploy a given module
+    */
+   public void distribute(DeploymentID deployment)
+      throws Exception
+   {
+      DeploymentID moduleID = deployment;
+      URL contentURL = deployment.getContentURL();
+      SerializableDeploymentID sdtID = new SerializableDeploymentID(moduleID);
+      InputStream contentIS = contentURL.openStream();
+      sdtID.setContentIS(contentIS);
+      Client client = getClient();
+      log.info("Begin deploy: " + moduleID);
+      transferDeployment(client, sdtID);
+      log.info("End deploy");
+      contentIS.close();
+      client.disconnect();
+   }
+
+   /**
+    * Start a given module
+    */
+   public void start(DeploymentID dtID) throws Exception
+   {
+      Client client = getClient();
+      log.debug("Start: " + dtID);
+      HashMap<String, DeploymentID> args = new HashMap<String, DeploymentID>(1);
+      args.put("DeploymentTargetID", dtID);
+      invoke(client, "start", args);
+      log.info("End start: "+dtID);
+   }
+
+   /**
+    * Stop a given module
+    */
+   public void stop(DeploymentID dtID) throws Exception
+   {
+      Client client = getClient();
+      HashMap<String, DeploymentID> args = new HashMap<String, DeploymentID>(1);
+      args.put("DeploymentTargetID", dtID);
+      log.info("Begin stop: " + dtID);
+      invoke(client, "stop", args);
+      log.info("End stop");
+   }
+
+   /**
+    * Undeploy a given module
+    */
+   public void undeploy(DeploymentID dtID) throws Exception
+   {
+      Client client = getClient();
+      HashMap<String, DeploymentID> args = new HashMap<String, DeploymentID>(1);
+      args.put("DeploymentTargetID", dtID);
+      log.info("Begin undeploy: " + dtID);
+      invoke(client, "undeploy", args);
+      log.info("End undeploy");
+   }
+   /**
+    * Get the remoting client connection
+    * @return
+    * @throws Exception
+    */
+   private Client getClient() throws Exception
+   {
+      log.debug("Calling remoting server with locator of: " + locator);
+
+      Client remotingClient = new Client(locator, subsystem);
+      remotingClient.connect();
+      return remotingClient;
+   }
+
+   private void transferDeployment(Client client, SerializableDeploymentID sdtID)
+      throws Exception
+   {
+      InputStream is = sdtID.getContentIS();
+      try
+      {
+         client.invoke(is, sdtID);
+      }
+      catch(Exception e)
+      {
+         throw e;
+      }
+      catch(Error e)
+      {
+         throw new RuntimeException(e);
+      }
+      catch(Throwable e)
+      {
+         throw new RuntimeException(e);         
+      }
+      finally
+      {
+         is.close();
+      }
+   }
+
+   private Object invoke(Client client, String name, HashMap<?, ?> args)
+      throws Exception
+   {
+      try
+      {
+         Object returnValue = client.invoke(name, args);
+         return returnValue;
+      }
+      catch(Exception e)
+      {
+         throw e;
+      }
+      catch(Error e)
+      {
+         throw new RuntimeException(e);
+      }
+      catch(Throwable e)
+      {
+         throw new RuntimeException(e);         
+      }      
+   }
+
+}

Modified: trunk/profileservice/src/main/org/jboss/profileservice/remoting/ProfileServiceInvocationHandler.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/remoting/ProfileServiceInvocationHandler.java	2008-05-22 21:17:37 UTC (rev 73603)
+++ trunk/profileservice/src/main/org/jboss/profileservice/remoting/ProfileServiceInvocationHandler.java	2008-05-22 22:23:27 UTC (rev 73604)
@@ -24,6 +24,7 @@
 import org.jboss.aop.joinpoint.InvocationResponse;
 import org.jboss.aspects.remoting.AOPRemotingInvocationHandler;
 import org.jboss.deployers.spi.management.ManagementView;
+import org.jboss.deployers.spi.management.deploy.DeploymentManager;
 import org.jboss.remoting.InvocationRequest;
 import org.jboss.remoting.ServerInvocationHandler;
 
@@ -39,17 +40,27 @@
    implements ServerInvocationHandler
 {
    private ManagementView mgtViewProxy;
+   private DeploymentManager deployMgrProxy;
 
    public ManagementView getManagementViewProxy()
    {
       return mgtViewProxy;
    }
-
    public void setManagementViewProxy(ManagementView mgtViewProxy)
    {
       this.mgtViewProxy = mgtViewProxy;
    }
 
+   
+   public DeploymentManager getDeployMgrProxy()
+   {
+      return deployMgrProxy;
+   }
+   public void setDeployMgrProxy(DeploymentManager deployMgrProxy)
+   {
+      this.deployMgrProxy = deployMgrProxy;
+   }
+
    public Object invoke(InvocationRequest invocation)
       throws Throwable
    {
@@ -59,6 +70,12 @@
          // Replace the ManagementView with its proxy
          value.setResponse(mgtViewProxy);
       }
+      if( value.getResponse() instanceof DeploymentManager )
+      {
+         // Replace the DeploymentManager with its proxy
+         value.setResponse(deployMgrProxy);
+      }
+
       return value;
    }
 

Modified: trunk/profileservice/src/main/org/jboss/profileservice/remoting/ProxyFactory.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/remoting/ProxyFactory.java	2008-05-22 21:17:37 UTC (rev 73603)
+++ trunk/profileservice/src/main/org/jboss/profileservice/remoting/ProxyFactory.java	2008-05-22 22:23:27 UTC (rev 73604)
@@ -33,6 +33,7 @@
 import org.jboss.aspects.remoting.Remoting;
 import org.jboss.aspects.security.SecurityClientInterceptor;
 import org.jboss.deployers.spi.management.ManagementView;
+import org.jboss.deployers.spi.management.deploy.DeploymentManager;
 import org.jboss.logging.Logger;
 import org.jboss.profileservice.spi.ProfileService;
 import org.jboss.remoting.InvokerLocator;
@@ -53,8 +54,10 @@
    private InvokerLocator locator;
    private ProfileService ps;
    private ManagementView mgtView;
+   private DeploymentManager deployMgr;
    private Proxy psProxy;
    private Proxy mgtViewProxy;
+   private Proxy deployMgrProxy;
 
    public String getDispatchName()
    {
@@ -115,6 +118,20 @@
       return mgtViewProxy;
    }
 
+   public DeploymentManager getDeploymentManager()
+   {
+      return deployMgr;
+   }
+   public void setDeploymentManager(DeploymentManager deployMgr)
+   {
+      this.deployMgr = deployMgr;
+   }
+
+   public Proxy getDeployMgrProxy()
+   {
+      return deployMgrProxy;
+   }
+
    public void start()
       throws Exception
    {
@@ -140,6 +157,13 @@
       Dispatcher.singleton.registerTarget(mvDispatchName, mgtView);
       mgtViewProxy = Remoting.createRemoteProxy(mvDispatchName, loader, mvIfaces, locator, interceptors, "ProfileService");
       log.debug("Created ManagementView proxy");
+
+      // Create the DeploymentManager proxy
+      Class[] dmIfaces = {DeploymentManager.class};
+      String dmDispatchName = dispatchName+".DeploymentManager";
+      Dispatcher.singleton.registerTarget(dmDispatchName, deployMgr);
+      deployMgrProxy = Remoting.createRemoteProxy(dmDispatchName, loader, dmIfaces, locator, interceptors, "DeploymentManager");
+      log.debug("Created DeploymentManager proxy");      
    }
 
    public void stop()

Modified: trunk/profileservice/src/resources/profileservice-beans.xml
===================================================================
--- trunk/profileservice/src/resources/profileservice-beans.xml	2008-05-22 21:17:37 UTC (rev 73603)
+++ trunk/profileservice/src/resources/profileservice-beans.xml	2008-05-22 22:23:27 UTC (rev 73604)
@@ -30,7 +30,21 @@
             <parameter>ProfileService</parameter>
         </uninstall>
         <property name="managementViewProxy"><inject bean="ProfileServiceProxyFactory" property="managementViewProxy"/></property>
+        <property name="deployMgrProxy"><inject bean="ProfileServiceProxyFactory" property="deployMgrProxy"/></property>
     </bean>
+    <!--
+        Add a ProfileService handler to the remoting socket connector
+    -->
+    <bean name="DeploymentInvocationHandler"
+        class="org.jboss.profileservice.management.upload.remoting.DeployHandler">
+        <install bean="ConnectorMBean" method="addInvocationHandler">
+            <parameter class="java.lang.String">DeploymentManager</parameter>
+            <parameter class="org.jboss.remoting.ServerInvocationHandler"><this/></parameter>
+        </install>
+        <uninstall bean="ConnectorMBean" method="removeInvocationHandler">
+            <parameter>DeploymentManager</parameter>
+        </uninstall>
+    </bean>
 
     <bean name="RuntimeComponentDispatcher" class="org.jboss.profileservice.management.KernelBusRuntimeComponentDispatcher">
        <constructor>
@@ -61,15 +75,36 @@
         <uncallback method="removeTemplate"/>
     </bean>
 
+    <!-- The DeploymentManager plugin -->
+    <bean name="DeploymentManager"
+        class="org.jboss.profileservice.management.upload.DeploymentManagerImpl">
+        <install bean="ProfileService" method="setDeploymentManager">
+            <parameter>
+                <this/>
+            </parameter>
+        </install>
+        <uninstall bean="ProfileService" method="setDeploymentManager">
+            <parameter>
+                <null/>
+            </parameter>
+        </uninstall>
+        <property name="repositoryFactory"><inject bean="SerializableDeploymentRepositoryFactory" /></property>
+        <property name="profileService"><inject bean="ProfileService"/></property>
+        <property name="deployHandler"><inject bean="DeploymentInvocationHandler"/></property>
+        <property name="locator"><inject bean="ConnectorMBean" property="invokerLocator"/></property>
+        <property name="remotingSubsystem">DeploymentManager</property>
+    </bean>
+
     <bean name="ProfileServiceProxyFactory" class="org.jboss.profileservice.remoting.ProxyFactory">
         <property name="dispatchName">ProfileService</property>
         <property name="jndiName">ProfileService</property>
         <property name="locator"><inject bean="ConnectorMBean" property="invokerLocator"/></property>
         <property name="profileService"><inject bean="ProfileService"/></property>
         <property name="viewManager"><inject bean="ManagementView"/></property>
+        <property name="deploymentManager"><inject bean="DeploymentManager"/></property>
         <depends>ConnectorMBean</depends>
     </bean>
-    
+
     <!-- Hotdeployment of applications -->
     <bean name="HDScanner"
         class="org.jboss.system.server.profileservice.hotdeploy.HDScanner">

Modified: trunk/system/src/main/org/jboss/deployers/spi/management/ManagementView.java
===================================================================
--- trunk/system/src/main/org/jboss/deployers/spi/management/ManagementView.java	2008-05-22 21:17:37 UTC (rev 73603)
+++ trunk/system/src/main/org/jboss/deployers/spi/management/ManagementView.java	2008-05-22 22:23:27 UTC (rev 73604)
@@ -70,17 +70,6 @@
    public Set<String> getDeploymentNamesForType(String type);
 
    /**
-    * Add raw deployment content to the profile.
-    * 
-    * @param name phase unique name
-    * @param phase the phase this deployment applies to
-    * @param contentURL - URL for obtaining the deployment archive
-    * @return DeploymentProgress progress object for the deployment
-    */
-   //public DeploymentProgress addDeployment(String name, DeploymentPhase phase,
-   //      URL contentURL);
-
-   /**
     * Search for a deployment matching the regex expression.
     * @param regex - the regex to query deployment name 
     * @return the deployment name.

Copied: trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentID.java (from rev 73557, trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentTargetID.java)
===================================================================
--- trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentID.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentID.java	2008-05-22 22:23:27 UTC (rev 73604)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt 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.deployers.spi.management.deploy;
+
+import java.net.URL;
+
+import org.jboss.managed.api.ManagedDeployment.DeploymentPhase;
+
+/**
+ * A representation of a top-level deployment id.
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public interface DeploymentID
+{
+   /**
+    * Get the name of the deployment
+    *
+    * @return the deployment name
+    */
+   String getName();
+
+   /**
+    * Get the phase the deployment is associated with
+    * @return
+    */
+   DeploymentPhase getPhase();
+
+   /**
+    * 
+    * @return
+    */
+   public URL getContentURL();
+
+   /**
+    * Get a description of the deployment
+    *
+    * @return the identifier
+    */
+   String getDescription();
+}

Added: trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentManager.java
===================================================================
--- trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentManager.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentManager.java	2008-05-22 22:23:27 UTC (rev 73604)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt 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.deployers.spi.management.deploy;
+
+import java.net.URL;
+
+import org.jboss.managed.api.ManagedDeployment.DeploymentPhase;
+import org.jboss.profileservice.spi.NoSuchProfileException;
+import org.jboss.profileservice.spi.ProfileKey;
+
+/**
+ * An interface for uploading and controlling deployments in a profile.
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public interface DeploymentManager
+{
+   /**
+    * Load and associate the given profile with the DeploymentManager
+    * for future operations.
+    * 
+    * @param key - the profile to load
+    * @throws NoSuchProfileException
+    */
+   public void loadProfile(ProfileKey key)
+      throws Exception;
+
+   /**
+    * Add raw deployment content to the profile.
+    * 
+    * @param name phase unique name
+    * @param phase the phase this deployment applies to
+    * @param contentURL - URL for obtaining the deployment archive
+    * @return DeploymentProgress progress object for the deployment
+    */
+   public DeploymentProgress distribute(String name, DeploymentPhase phase,
+         URL contentURL);
+
+   public boolean isRedeploySupported();
+   public DeploymentProgress redeploy(String name, DeploymentPhase phase,
+         URL contentURL);
+
+   public void start(String name, DeploymentPhase phase)
+      throws Exception;
+   public void stop(String name, DeploymentPhase phase)
+      throws Exception;
+   public void undeploy(String name, DeploymentPhase phase)
+      throws Exception;
+}

Modified: trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentProgress.java
===================================================================
--- trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentProgress.java	2008-05-22 21:17:37 UTC (rev 73603)
+++ trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentProgress.java	2008-05-22 22:23:27 UTC (rev 73604)
@@ -38,27 +38,28 @@
     * @return the status
     */
    DeploymentStatus getDeploymentStatus();
-   
+
+   DeploymentID getDeploymentID();
+
    /**
-    * Retrieve the resulting deployment module ids
+    * Retrieve the list of targets the deployment is distributed to
     *
-    * @return the deployment module ids
+    * @return the deployment targets
     */
-   List<DeploymentTargetID> getDeploymentTargetIDs();
+   List<DeploymentTarget> getDeploymentTargets();
 
    /**
+    * Begins the deployment distribution process
+    */
+   void run();
+
+   /**
     * Cancels the deployment
     *
     */
    void cancel();
    
    /**
-    * Stops the deployment
-    *
-    */
-   void stop();
-   
-   /**
     * Add a progress listener
     *
     * @param listener the listener

Modified: trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentStatus.java
===================================================================
--- trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentStatus.java	2008-05-22 21:17:37 UTC (rev 73603)
+++ trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentStatus.java	2008-05-22 22:23:27 UTC (rev 73604)
@@ -60,12 +60,18 @@
    String getMessage();
 
    /**
+    * Get the failure exception.
+    * @return any failure exception associated with reaching the FAILED state.
+    */
+   Exception getFailure();
+
+   /**
     * Is the deployment complete
     *
     * @return true when complete, false otherwise
     */
    boolean isCompleted();
-   
+
    /**
     * Has the deployment failed
     *

Modified: trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentTarget.java
===================================================================
--- trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentTarget.java	2008-05-22 21:17:37 UTC (rev 73603)
+++ trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentTarget.java	2008-05-22 22:23:27 UTC (rev 73604)
@@ -21,10 +21,10 @@
  */
 package org.jboss.deployers.spi.management.deploy;
 
-import org.jboss.managed.api.ManagedDeployment.DeploymentPhase;
+import java.net.URL;
 
 /**
- * A deployment target representation.
+ * A target to which a deployment is uploaded.
  * 
  * @author Scott.Stark at jboss.org
  * @version $Revision:$
@@ -32,19 +32,17 @@
 public interface DeploymentTarget
 {
    /**
-    * Get the deployment name
+    * Get the target name
     *
     * @return the name
     */
    String getName();
-   /**
-    * Get the phase the deployment is associated with
-    * @return
-    */
-   DeploymentPhase getPhase();
    
+   void distribute(DeploymentID deployment)
+      throws Exception;
+
    /**
-    * Get the deployment description
+    * Get the target description
     *
     * @return the description
     */

Deleted: trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentTargetID.java
===================================================================
--- trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentTargetID.java	2008-05-22 21:17:37 UTC (rev 73603)
+++ trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentTargetID.java	2008-05-22 22:23:27 UTC (rev 73604)
@@ -1,52 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt 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.deployers.spi.management.deploy;
-
-/**
- * A representation of a deployment target and the top-level deployment id.
- * 
- * @author Scott.Stark at jboss.org
- * @version $Revision:$
- */
-public interface DeploymentTargetID
-{
-   /**
-    * Get the target
-    *
-    * @return the target
-    */
-   DeploymentTarget getTarget();
-   
-   /**
-    * Get the name of the deployment
-    *
-    * @return the id
-    */
-   String getName();
-
-   /**
-    * Return the identifier of this module 
-    *
-    * @return the identifier
-    */
-   String toString();
-}

Modified: trunk/system/src/main/org/jboss/deployers/spi/management/deploy/ProgressEvent.java
===================================================================
--- trunk/system/src/main/org/jboss/deployers/spi/management/deploy/ProgressEvent.java	2008-05-22 21:17:37 UTC (rev 73603)
+++ trunk/system/src/main/org/jboss/deployers/spi/management/deploy/ProgressEvent.java	2008-05-22 22:23:27 UTC (rev 73604)
@@ -33,17 +33,17 @@
    implements Serializable
 {
    private static final long serialVersionUID = 1;
-   private DeploymentTargetID deploymentTargetID;
+   private DeploymentID deploymentTargetID;
    private DeploymentStatus status;
    
-   public ProgressEvent(DeploymentTargetID deploymentTargetID, DeploymentStatus status)
+   public ProgressEvent(DeploymentID deploymentTargetID, DeploymentStatus status)
    {
       super();
       this.deploymentTargetID = deploymentTargetID;
       this.status = status;
    }
 
-   public DeploymentTargetID getDeploymentName()
+   public DeploymentID getDeploymentName()
    {
       return deploymentTargetID;
    }
@@ -51,4 +51,15 @@
    {
       return status;
    }
+
+   public String toString()
+   {
+      StringBuffer tmp = new StringBuffer("ProgressEvent(");
+      tmp.append("deploymentTargetID=");
+      tmp.append(this.deploymentTargetID);
+      tmp.append("status=");
+      tmp.append(this.status);
+      tmp.append(")");
+      return tmp.toString();
+   }
 }

Modified: trunk/system/src/main/org/jboss/profileservice/spi/DeploymentRepository.java
===================================================================
--- trunk/system/src/main/org/jboss/profileservice/spi/DeploymentRepository.java	2008-05-22 21:17:37 UTC (rev 73603)
+++ trunk/system/src/main/org/jboss/profileservice/spi/DeploymentRepository.java	2008-05-22 22:23:27 UTC (rev 73604)
@@ -22,6 +22,7 @@
 package org.jboss.profileservice.spi;
 
 import java.io.IOException;
+import java.io.InputStream;
 import java.net.URI;
 import java.util.Collection;
 import java.util.Set;
@@ -53,7 +54,7 @@
    public Set<String> getDeploymentNamesForType(String type);
 
    // Upload a raw deployment
-   public void addDeploymentContent(String name, ZipInputStream contentIS, DeploymentPhase phase)
+   public void addDeploymentContent(String name, InputStream contentIS, DeploymentPhase phase)
       throws IOException;
 
    /**

Modified: trunk/system/src/main/org/jboss/profileservice/spi/ProfileService.java
===================================================================
--- trunk/system/src/main/org/jboss/profileservice/spi/ProfileService.java	2008-05-22 21:17:37 UTC (rev 73603)
+++ trunk/system/src/main/org/jboss/profileservice/spi/ProfileService.java	2008-05-22 22:23:27 UTC (rev 73604)
@@ -25,6 +25,7 @@
 import java.util.Collection;
 
 import org.jboss.deployers.spi.management.ManagementView;
+import org.jboss.deployers.spi.management.deploy.DeploymentManager;
 
 /**
  * The entry point service for accessing/administiring server profiles
@@ -84,6 +85,12 @@
     */
    public ManagementView getViewManager();
 
+   /**
+    * Obtain the DeploymentManager plugin
+    * @return the DeploymentManager plugin if supported
+    */
+   public DeploymentManager getDeploymentManager();
+
    // Admin of profiles @todo could be an option plugin
    public Profile newProfile(ProfileKey key)
       throws Exception;

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/basic/ProfileServiceImpl.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/basic/ProfileServiceImpl.java	2008-05-22 21:17:37 UTC (rev 73603)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/basic/ProfileServiceImpl.java	2008-05-22 22:23:27 UTC (rev 73604)
@@ -26,6 +26,7 @@
 import java.util.HashSet;
 
 import org.jboss.deployers.spi.management.ManagementView;
+import org.jboss.deployers.spi.management.deploy.DeploymentManager;
 import org.jboss.profileservice.spi.NoSuchProfileException;
 import org.jboss.profileservice.spi.Profile;
 import org.jboss.profileservice.spi.ProfileKey;
@@ -47,6 +48,7 @@
    private String profileRoot;
    private Profile defaultImpl;
    private ManagementView mgtView;
+   private DeploymentManager deployMgr;
 
    public ProfileServiceImpl(String name) throws IOException
    {
@@ -121,6 +123,15 @@
       this.mgtView = mgtView;
    }
 
+   public DeploymentManager getDeploymentManager()
+   {
+      return deployMgr;
+   }
+   public void setDeploymentManager(DeploymentManager deployMgr)
+   {
+      this.deployMgr = deployMgr;
+   }
+
    // Admin of profiles @todo could be an option plugin
    public Profile newProfile(ProfileKey key)
    {

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/ProfileServiceImpl.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/ProfileServiceImpl.java	2008-05-22 21:17:37 UTC (rev 73603)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/ProfileServiceImpl.java	2008-05-22 22:23:27 UTC (rev 73604)
@@ -25,6 +25,7 @@
 import java.util.Collection;
 
 import org.jboss.deployers.spi.management.ManagementView;
+import org.jboss.deployers.spi.management.deploy.DeploymentManager;
 import org.jboss.logging.Logger;
 import org.jboss.profileservice.spi.DeploymentRepository;
 import org.jboss.profileservice.spi.NoSuchProfileException;
@@ -56,6 +57,8 @@
    private Profile profile;
    /** The management view for the active profile */
    private ManagementView mgtView;
+   /** The profiles DeploymentManager */
+   private DeploymentManager deployMgr;
    /** The version of the profile to use */
    private String version;
 
@@ -188,6 +191,15 @@
       this.mgtView = mgtView;
    }
 
+   public DeploymentManager getDeploymentManager()
+   {
+      return deployMgr;
+   }
+   public void setDeploymentManager(DeploymentManager deployMgr)
+   {
+      this.deployMgr = deployMgr;
+   }
+
    public Profile newProfile(ProfileKey key)
       throws Exception
    {

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/RepositoryAdminAdaptor.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/RepositoryAdminAdaptor.java	2008-05-22 21:17:37 UTC (rev 73603)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/RepositoryAdminAdaptor.java	2008-05-22 22:23:27 UTC (rev 73604)
@@ -23,6 +23,7 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.io.InputStream;
 import java.net.URI;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -87,7 +88,7 @@
       mrepo.addResource(dres);
    }
 
-   public void addDeploymentContent(String name, ZipInputStream contentIS, DeploymentPhase phase)
+   public void addDeploymentContent(String name, InputStream contentIS, DeploymentPhase phase)
       throws IOException
    {
       // TODO

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/SerializableDeploymentRepository.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/SerializableDeploymentRepository.java	2008-05-22 21:17:37 UTC (rev 73603)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/SerializableDeploymentRepository.java	2008-05-22 22:23:27 UTC (rev 73604)
@@ -25,7 +25,9 @@
 import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
+import java.io.InputStream;
 import java.io.ObjectOutputStream;
+import java.io.SyncFailedException;
 import java.net.URI;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -36,6 +38,7 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
 import java.util.zip.ZipInputStream;
 
 import org.jboss.deployers.spi.attachments.Attachments;
@@ -96,6 +99,10 @@
    private AttachmentsSerializer serializer;
    /** The last time the profile was modified */
    private long lastModified;
+   /** A lock for the hot deployment/{@link #getModifiedDeployments()} */
+   private ReentrantReadWriteLock contentLock = new ReentrantReadWriteLock(true);
+   /** Should an attempt to overwrite existing content fail in {@link #addDeploymentContent(String, ZipInputStream, DeploymentPhase)}*/
+   private boolean failIfAlreadyExists = false;
 
    public SerializableDeploymentRepository(File root, URI[] appURIs, ProfileKey key)
    {
@@ -226,11 +233,46 @@
       return names;
    }
 
-   public void addDeploymentContent(String name, ZipInputStream contentIS, DeploymentPhase phase)
+   /**
+    * 
+    */
+   public void addDeploymentContent(String name, InputStream contentIS, DeploymentPhase phase)
       throws IOException
    {
-      throw new IOException("Not yet implemented");
+      boolean trace = log.isTraceEnabled();
+      // Suspend hot deployment checking
+      contentLock.writeLock().lock();
+      if( trace )
+         log.trace("Aquired content read lock");
+
+      // Write the content out 
+      URI uri = getPhaseURI(phase);
+      if(uri == null)
+         throw new FileNotFoundException("Failed to obtain content URI for phase: "+phase);
+      File contentRoot = new File(uri);
+      File contentFile = new File(contentRoot, name);
+      if(failIfAlreadyExists && contentFile.exists())
+         throw new SyncFailedException("Deployment content already exists: "+contentFile.getAbsolutePath());
+      FileOutputStream fos = new FileOutputStream(contentFile);
+      byte[] tmp = new byte[4096];
+      int read = 0;
+      while((read = contentIS.read(tmp)) > 0)
+      {
+         log.info("write, "+read);
+         fos.write(tmp, 0, read);
+      }
+      fos.flush();
+      fos.close();
+      //contentIS.close();
+
+      // TODO: without hot deployment, this change will not be seen?
+
+      // Allow hot deployment checking
+      contentLock.writeLock().unlock();
+      if(trace)
+         log.trace("Released content write lock");
    }
+
    public void addDeployment(String vfsPath, VFSDeployment d, DeploymentPhase phase)
       throws Exception
    {
@@ -245,6 +287,9 @@
          case APPLICATION:
             this.addApplication(vfsPath, d);
             break;
+         case APPLICATION_CLUSTERED:
+            this.addApplication(vfsPath, d);
+            break;
       }
    }
 
@@ -324,6 +369,10 @@
       boolean trace = log.isTraceEnabled();
       if( trace )
          log.trace("Checking applications for modifications");
+      contentLock.readLock().lock();
+      if( trace )
+         log.trace("Aquired content read lock");
+
       if( apps != null )
       {
          Iterator<VFSDeployment> iter = apps.iterator();
@@ -373,6 +422,10 @@
             }
          }
       }
+      contentLock.readLock().unlock();
+      if( trace )
+         log.trace("Released content read lock");
+
       if(modified.size() > 0)
          lastModified = System.currentTimeMillis();
       return modified;
@@ -580,6 +633,27 @@
       return ctxs;
    }
 
+   protected URI getPhaseURI(DeploymentPhase phase)
+   {
+      URI uri = null;
+      switch( phase )
+      {
+         case BOOTSTRAP:
+            uri = getBootstrapURI();
+            break;
+         case DEPLOYER:
+            uri = getDeployersURI();
+            break;
+         case APPLICATION:
+            uri = getApplicationURI();
+            break;
+         case APPLICATION_CLUSTERED:
+            // TODO
+            break;
+      }
+      return uri;
+   }
+
    protected URI getBootstrapURI()
    {
       return bootstrapDir.toURI();

Added: trunk/testsuite/imports/sections/profileservice.xml
===================================================================
--- trunk/testsuite/imports/sections/profileservice.xml	                        (rev 0)
+++ trunk/testsuite/imports/sections/profileservice.xml	2008-05-22 22:23:27 UTC (rev 73604)
@@ -0,0 +1,16 @@
+<project name="tests-profileservice-jars">
+   <!-- proxy compiler tests -->
+   <target name="_jars-profileservice">
+      <mkdir dir="${build.lib}"/>
+      
+      <!-- build testMCBeansDeployment.beans -->
+      <jar destfile="${build.lib}/testMCBeansDeployment.beans">
+         <fileset dir="${build.classes}">
+            <include name="org/jboss/test/profileservice/mcbeans/**"/>
+         </fileset>
+         <zipfileset dir="${build.resources}/profileservice/" prefix="META-INF">
+            <include name="testMCBeansDeployment-beans.xml"/>
+         </zipfileset>
+      </jar> 
+   </target>
+</project>

Modified: trunk/testsuite/imports/test-jars.xml
===================================================================
--- trunk/testsuite/imports/test-jars.xml	2008-05-22 21:17:37 UTC (rev 73603)
+++ trunk/testsuite/imports/test-jars.xml	2008-05-22 22:23:27 UTC (rev 73604)
@@ -56,6 +56,7 @@
    <import file="sections/naming.xml"/>
    <import file="sections/perf.xml"/>
    <import file="sections/pooled.xml"/>
+   <import file="sections/profileservice.xml"/>
    <import file="sections/proxycompiler.xml"/>
    <import file="sections/readahead.xml"/>
    <import file="sections/refs.xml"/>
@@ -122,7 +123,7 @@
         _jars-invokers,
         _jars-isolation,
         _jars-jbossmessaging,
-	    _jars-jbossmessaging-cluster,
+	     _jars-jbossmessaging-cluster,
         _jars-jbossmq,
         _jars-jbossmx,
         _jars-jbpm,
@@ -146,6 +147,7 @@
         _jars-naming,
         _jars-perf,
         _jars-pooled,
+   	  _jars-profileservice,
         _jars-proxycompiler,
         _jars-readahead,
         _jars-refs,

Added: trunk/testsuite/src/main/org/jboss/test/profileservice/mcbeans/Bean1.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/mcbeans/Bean1.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/mcbeans/Bean1.java	2008-05-22 22:23:27 UTC (rev 73604)
@@ -0,0 +1,81 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt 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.test.profileservice.mcbeans;
+
+import org.jboss.managed.api.annotation.ManagementComponent;
+import org.jboss.managed.api.annotation.ManagementObject;
+import org.jboss.managed.api.annotation.ManagementOperation;
+import org.jboss.managed.api.annotation.ManagementProperty;
+import org.jboss.managed.api.annotation.ViewUse;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+ at ManagementObject(componentType=@ManagementComponent(type="MCBean",subtype=""),
+      description="A managed mc bean")
+public class Bean1
+{
+   private String prop1;
+   private float prop2;
+   private Double prop3;
+   private long calls;
+
+   @ManagementProperty
+   public String getProp1()
+   {
+      return prop1;
+   }
+   public void setProp1(String prop1)
+   {
+      this.prop1 = prop1;
+   }
+   @ManagementProperty
+   public float getProp2()
+   {
+      return prop2;
+   }
+   public void setProp2(float prop2)
+   {
+      this.prop2 = prop2;
+   }
+   @ManagementProperty
+   public Double getProp3()
+   {
+      return prop3;
+   }
+   public void setProp3(Double prop3)
+   {
+      this.prop3 = prop3;
+   }
+   @ManagementProperty(use={ViewUse.STATISTIC})
+   public long getCalls()
+   {
+      return calls;
+   }
+
+   @ManagementOperation
+   public synchronized void op1()
+   {
+      calls ++;
+   }
+}

Modified: trunk/testsuite/src/main/org/jboss/test/profileservice/test/AbstractProfileServiceTest.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/test/AbstractProfileServiceTest.java	2008-05-22 21:17:37 UTC (rev 73603)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/test/AbstractProfileServiceTest.java	2008-05-22 22:23:27 UTC (rev 73604)
@@ -29,6 +29,7 @@
 import javax.naming.InitialContext;
 import org.jboss.test.JBossTestCase;
 import org.jboss.deployers.spi.management.ManagementView;
+import org.jboss.deployers.spi.management.deploy.DeploymentManager;
 import org.jboss.managed.api.DeploymentTemplateInfo;
 import org.jboss.managed.api.ManagedDeployment;
 import org.jboss.managed.api.ManagedComponent;
@@ -49,6 +50,7 @@
    extends JBossTestCase
 {
    protected ManagementView activeView;
+   protected DeploymentManager deployMgr;
    private MetaValueFactory metaValueFactory;
 
    public AbstractProfileServiceTest(String name)
@@ -150,6 +152,27 @@
       }
       return activeView;
    }
+   /**
+    * Obtain the ProfileService.ManagementView
+    * @return
+    * @throws Exception
+    */
+   protected DeploymentManager getDeploymentManager()
+      throws Exception
+   {
+      if( deployMgr == null )
+      {
+         String profileName = getProfileName();
+         InitialContext ctx = getInitialContext();
+         ProfileService ps = (ProfileService) ctx.lookup("ProfileService");
+         deployMgr = ps.getDeploymentManager();
+         ProfileKey defaultKey = new ProfileKey(profileName);
+         deployMgr.loadProfile(defaultKey);
+         // Init the VFS to setup the vfs* protocol handlers
+         VFS.init();
+      }
+      return deployMgr;
+   }
 
    /**
     * Locate the given ComponentType with the given component name.

Added: trunk/testsuite/src/main/org/jboss/test/profileservice/test/DeployUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/test/DeployUnitTestCase.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/test/DeployUnitTestCase.java	2008-05-22 22:23:27 UTC (rev 73604)
@@ -0,0 +1,111 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt 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.test.profileservice.test;
+
+import java.io.InputStream;
+import java.net.URL;
+import java.util.zip.ZipInputStream;
+
+import org.jboss.deployers.spi.management.ManagementView;
+import org.jboss.deployers.spi.management.deploy.DeploymentManager;
+import org.jboss.deployers.spi.management.deploy.DeploymentProgress;
+import org.jboss.deployers.spi.management.deploy.DeploymentStatus;
+import org.jboss.deployers.spi.management.deploy.ProgressEvent;
+import org.jboss.deployers.spi.management.deploy.ProgressListener;
+import org.jboss.managed.api.ManagedDeployment.DeploymentPhase;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class DeployUnitTestCase extends AbstractProfileServiceTest
+   implements ProgressListener
+{
+   private ProgressEvent eventInfo;
+   private long eventCount = 0;
+
+   public DeployUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void progressEvent(ProgressEvent eventInfo)
+   {
+      eventCount ++;
+      this.eventInfo = eventInfo;
+      getLog().debug(eventInfo);
+   }
+
+   @Override
+   protected String getProfileName()
+   {
+      return "default";
+   }
+
+   public void testWarDeployment()
+      throws Exception
+   {
+      DeploymentManager mgtView = getDeploymentManager();
+      URL contentURL = super.getDeployURL("testWarDeployment.war");
+      mgtView.distribute("testWarDeployment.war", DeploymentPhase.APPLICATION, contentURL);
+   }
+   public void testEarDeployment()
+      throws Exception
+   {
+      DeploymentManager mgtView = getDeploymentManager();
+      URL contentURL = super.getDeployURL("testEarDeployment.ear");
+      mgtView.distribute("testEarDeployment.ear", DeploymentPhase.APPLICATION, contentURL);      
+   }
+   public void testMCBeansDeployment()
+      throws Exception
+   {
+      URL contentURL = super.getDeployURL("testMCBeansDeployment.beans");
+      /*
+      assertNotNull(contentURL);
+      InputStream is = contentURL.openStream();
+      byte[] tmp = new byte[4096];
+      int totalRead = 0, read = 0;
+      while((read = is.read(tmp)) > 0)
+      {
+         totalRead += read;
+      }
+      is.close();
+      getLog().info(contentURL+", bytes: "+totalRead);
+      */
+
+      DeploymentManager mgtView = getDeploymentManager();
+      DeploymentProgress progress = mgtView.distribute("testMCBeansDeployment.beans", DeploymentPhase.APPLICATION, contentURL);
+      progress.addProgressListener(this);
+      progress.run();
+      DeploymentStatus status = progress.getDeploymentStatus();
+      assertTrue("DeploymentStatus.isCompleted", status.isCompleted());
+      assertTrue("DeploymentStatus.isRunning", status.isRunning());
+      assertFalse("DeploymentStatus.isFailed", status.isFailed());
+   }
+   public void testSarDeployment()
+      throws Exception
+   {
+      DeploymentManager mgtView = getDeploymentManager();
+      URL contentURL = super.getDeployURL("testSarDeployment.sar");
+      mgtView.distribute("testSarDeployment.sar", DeploymentPhase.APPLICATION, contentURL);
+   }
+}

Added: trunk/testsuite/src/resources/profileservice/testMCBeansDeployment-beans.xml
===================================================================
--- trunk/testsuite/src/resources/profileservice/testMCBeansDeployment-beans.xml	                        (rev 0)
+++ trunk/testsuite/src/resources/profileservice/testMCBeansDeployment-beans.xml	2008-05-22 22:23:27 UTC (rev 73604)
@@ -0,0 +1,5 @@
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+    <bean name="testMCBeansDeployment-Bean1"
+        class="org.jboss.test.profileservice.mcbeans.Bean1">
+    </bean>
+</deployment>




More information about the jboss-cvs-commits mailing list