[jboss-cvs] JBossAS SVN: r74225 - 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
Fri Jun 6 02:08:41 EDT 2008
Author: scott.stark at jboss.org
Date: 2008-06-06 02:08:41 -0400 (Fri, 06 Jun 2008)
New Revision: 74225
Modified:
trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentProgressImpl.java
trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/DeployHandler.java
trunk/profileservice/src/resources/profileservice-beans.xml
trunk/system/src/main/org/jboss/profileservice/spi/DeploymentRepository.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
Log:
Update the DeployHandler to process start, stop, undeploy
Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentProgressImpl.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentProgressImpl.java 2008-06-06 05:39:44 UTC (rev 74224)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentProgressImpl.java 2008-06-06 06:08:41 UTC (rev 74225)
@@ -218,6 +218,8 @@
status = new SerializableDeploymentStatus(command, StateType.COMPLETED);
status.setTarget(target);
status.setMessage("Completed start for target: "+target);
+ status.setCompleted(true);
+ status.setRunning(true);
currentStatus = status;
event = new ProgressEvent(deployment, currentStatus);
notify(event);
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 2008-06-06 05:39:44 UTC (rev 74224)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/DeployHandler.java 2008-06-06 06:08:41 UTC (rev 74225)
@@ -40,10 +40,12 @@
import org.jboss.aop.joinpoint.Invocation;
import org.jboss.aop.joinpoint.InvocationResponse;
import org.jboss.aspects.remoting.AOPRemotingInvocationHandler;
+import org.jboss.deployers.client.spi.main.MainDeployer;
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.deployers.vfs.spi.client.VFSDeploymentFactory;
import org.jboss.logging.Logger;
import org.jboss.managed.api.ManagedDeployment.DeploymentPhase;
import org.jboss.profileservice.management.upload.SerializableDeploymentID;
@@ -67,18 +69,38 @@
{
static Logger log = Logger.getLogger(DeployHandler.class);
private DeploymentRepository deploymentRepository;
+ /** The deployment factory */
+ private VFSDeploymentFactory deploymentFactory = VFSDeploymentFactory.getInstance();
+ private MainDeployer mainDeployer;
public DeploymentRepository getDeploymentRepository()
{
return deploymentRepository;
}
-
public void setDeploymentRepository(DeploymentRepository deploymentRepository)
{
this.deploymentRepository = deploymentRepository;
}
+
+ public VFSDeploymentFactory getDeploymentFactory()
+ {
+ return deploymentFactory;
+ }
+ public void setDeploymentFactory(VFSDeploymentFactory deploymentFactory)
+ {
+ this.deploymentFactory = deploymentFactory;
+ }
+
+ public MainDeployer getMainDeployer()
+ {
+ return mainDeployer;
+ }
+ public void setMainDeployer(MainDeployer mainDeployer)
+ {
+ this.mainDeployer = mainDeployer;
+ }
/**
* Handle a deployService deploy invocation
* @param request - the remoting invocation
@@ -123,8 +145,16 @@
log.debug("invoke, dtID: "+dtID+", payload: "+payload);
if( parameter.equals("start") )
{
- log.info("start, "+Arrays.asList(dtID.getNames()));
+ start(dtID);
}
+ if( parameter.equals("stop") )
+ {
+ stop(dtID);
+ }
+ if( parameter.equals("undeploy") )
+ {
+ undeploy(dtID);
+ }
}
return returnValue;
}
@@ -140,4 +170,63 @@
public void setMBeanServer(MBeanServer arg0)
{
}
+
+ protected void start(DeploymentID dtID)
+ throws Exception
+ {
+ String[] names = dtID.getNames();
+ log.info("start, "+Arrays.asList(names));
+ for(String name : names)
+ {
+ VirtualFile vf = deploymentRepository.getDeploymentContent(name, dtID.getPhase());
+ VFSDeployment vfsd = createDeployment(vf);
+ deploymentRepository.addDeployment(vf.getPathName(), vfsd, dtID.getPhase());
+ mainDeployer.addDeployment(vfsd);
+ log.info("Started: "+vfsd);
+ }
+ mainDeployer.process();
+ mainDeployer.checkComplete();
+ }
+
+ protected void stop(DeploymentID dtID)
+ throws Exception
+ {
+ String[] names = dtID.getNames();
+ log.info("start, "+Arrays.asList(names));
+ for(String name : names)
+ {
+ VirtualFile vf = deploymentRepository.getDeploymentContent(name, dtID.getPhase());
+ VFSDeployment vfsd = createDeployment(vf);
+ mainDeployer.removeDeployment(vfsd);
+ log.info("Stopped: "+vfsd);
+ }
+ mainDeployer.process();
+ mainDeployer.checkComplete();
+ }
+
+ protected void undeploy(DeploymentID dtID)
+ throws Exception
+ {
+ String[] names = dtID.getNames();
+ log.info("start, "+Arrays.asList(names));
+ for(String name : names)
+ {
+ VirtualFile vf = deploymentRepository.getDeploymentContent(name, dtID.getPhase());
+ deploymentRepository.removeDeployment(name, dtID.getPhase());
+ log.info("Undeployed: "+name);
+ }
+ }
+
+ /**
+ * Create a deployment
+ *
+ * @param file the root file
+ * @return the deployment
+ */
+ protected VFSDeployment createDeployment(VirtualFile file)
+ {
+ if (file == null)
+ throw new IllegalArgumentException("Null file");
+ return deploymentFactory.createVFSDeployment(file);
+ }
}
Modified: trunk/profileservice/src/resources/profileservice-beans.xml
===================================================================
--- trunk/profileservice/src/resources/profileservice-beans.xml 2008-06-06 05:39:44 UTC (rev 74224)
+++ trunk/profileservice/src/resources/profileservice-beans.xml 2008-06-06 06:08:41 UTC (rev 74225)
@@ -44,6 +44,7 @@
<uninstall bean="ConnectorMBean" method="removeInvocationHandler">
<parameter>DeploymentManager</parameter>
</uninstall>
+ <property name="mainDeployer"><inject bean="MainDeployer"/></property>
</bean>
<bean name="RuntimeComponentDispatcher" class="org.jboss.profileservice.management.KernelBusRuntimeComponentDispatcher">
Modified: trunk/system/src/main/org/jboss/profileservice/spi/DeploymentRepository.java
===================================================================
--- trunk/system/src/main/org/jboss/profileservice/spi/DeploymentRepository.java 2008-06-06 05:39:44 UTC (rev 74224)
+++ trunk/system/src/main/org/jboss/profileservice/spi/DeploymentRepository.java 2008-06-06 06:08:41 UTC (rev 74225)
@@ -31,6 +31,7 @@
import org.jboss.deployers.spi.attachments.Attachments;
import org.jboss.deployers.vfs.spi.client.VFSDeployment;
import org.jboss.managed.api.ManagedDeployment.DeploymentPhase;
+import org.jboss.virtual.VirtualFile;
/**
* An interface for managing the contents of a Profile.
@@ -53,11 +54,36 @@
public Set<String> getDeploymentNames(DeploymentPhase phase);
public Set<String> getDeploymentNamesForType(String type);
- // Upload a raw deployment
- public void addDeploymentContent(String name, InputStream contentIS, DeploymentPhase phase)
+
+ /**
+ * Upload raw deployment content to a profile repository. This does not make
+ * the deployment avaialble to
+ * @param vfsPath - the vfs path relative to the phase root
+ * @param contentIS - the input stream for the deployment contents
+ * @param phase - the phase of the deployment as it relates to when the
+ * deployment is loaded
+ * @throws IOException
+ */
+ public void addDeploymentContent(String vfsPath, InputStream contentIS, DeploymentPhase phase)
throws IOException;
+ public VirtualFile getDeploymentContent(String vfsPath, DeploymentPhase phase)
+ throws IOException;
+
/**
+ * lock deployment content and exclude it from modified deployment checks.
+ * @param vfsPath
+ * @param phase
+ */
+ public void lockDeploymentContent(String vfsPath, DeploymentPhase phase);
+ /**
+ * Unlock a previously locked deployment content.
+ * @param vfsPath
+ * @param phase
+ */
+ public void unlockDeploymentContent(String vfsPath, DeploymentPhase phase);
+
+ /**
* Add a deployment
*
* @param vfsPath the path
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-06-06 05:39:44 UTC (rev 74224)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/RepositoryAdminAdaptor.java 2008-06-06 06:08:41 UTC (rev 74225)
@@ -95,6 +95,25 @@
throw new IOException("Not yet implemented");
}
+ public VirtualFile getDeploymentContent(String vfsPath, DeploymentPhase phase)
+ throws IOException
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void lockDeploymentContent(String vfsPath, DeploymentPhase phase)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void unlockDeploymentContent(String vfsPath, DeploymentPhase phase)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
public void addManagedObject(String vfsPath, Attachments edits) throws Exception
{
MutableRepository repo = this.getRepository(adminEditsRoot.toURI());
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-06-06 05:39:44 UTC (rev 74224)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/SerializableDeploymentRepository.java 2008-06-06 06:08:41 UTC (rev 74225)
@@ -77,7 +77,7 @@
/** The server root container the deployments */
private File root;
- /** The bootstrap jboss-service.xml dir */
+ /** The bootstrap descriptor dir */
private File bootstrapDir;
/** The server static libraries */
private File libDir;
@@ -85,7 +85,7 @@
private File deployersDir;
/** The application phase deployments dir */
private File[] applicationDirs;
- /** The deployment post edit */
+ /** The deployment post edit root location */
private File adminEditsRoot;
/** The profile key this repository is associated with */
private ProfileKey key;
@@ -97,6 +97,7 @@
private LinkedHashMap<String,VFSDeployment> applicationCtxs = new LinkedHashMap<String,VFSDeployment>();
/** The {@link VFSDeployment#getTransientManagedObjects()} serializer */
private AttachmentsSerializer serializer;
+ private Set<String> lockedApps = Collections.synchronizedSet(new HashSet<String>());
/** The last time the profile was modified */
private long lastModified;
/** A lock for the hot deployment/{@link #getModifiedDeployments()} */
@@ -265,7 +266,8 @@
fos.close();
//contentIS.close();
- // TODO: without hot deployment, this change will not be seen?
+ // Lock the content
+ lockDeploymentContent(name, phase);
// Allow hot deployment checking
contentLock.writeLock().unlock();
@@ -273,6 +275,27 @@
log.trace("Released content write lock");
}
+ public VirtualFile getDeploymentContent(String vfsPath, DeploymentPhase phase)
+ throws IOException
+ {
+ URI rootURI = this.getDeploymentURI(phase);
+ VirtualFile root = VFS.getRoot(rootURI);
+ VirtualFile content = root.getChild(vfsPath);
+ if(content == null)
+ throw new FileNotFoundException(vfsPath+" not found under root: "+rootURI);
+ return content;
+ }
+
+ public void lockDeploymentContent(String vfsPath, DeploymentPhase phase)
+ {
+ lockedApps.add(vfsPath);
+ }
+
+ public void unlockDeploymentContent(String vfsPath, DeploymentPhase phase)
+ {
+ lockedApps.remove(vfsPath);
+ }
+
public void addDeployment(String vfsPath, VFSDeployment d, DeploymentPhase phase)
throws Exception
{
@@ -380,6 +403,13 @@
{
VFSDeployment ctx = iter.next();
VirtualFile root = ctx.getRoot();
+ // See if this file is locked
+ if(this.lockedApps.contains(root.getPathName()))
+ {
+ if(trace)
+ log.trace("Ignoring locked application: "+root);
+ continue;
+ }
Long rootLastModified = root.getLastModified();
String name = root.getPathName();
// Check for removal
More information about the jboss-cvs-commits
mailing list