[jboss-cvs] JBossAS SVN: r102402 - in projects/profileservice/trunk: core/src/main/java/org/jboss/profileservice/deployment/hotdeploy and 19 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Mar 15 08:49:19 EDT 2010
Author: emuckenhuber
Date: 2010-03-15 08:49:17 -0400 (Mon, 15 Mar 2010)
New Revision: 102402
Added:
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/management/actions/AbstractTwoPhaseModificationAction.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/management/event/ProfileModificationEvent.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/NoopVirtualDeploymentMetaData.java
projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/resolver/test/ProcessingUnitTestCase.java
projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/DeploymentConstants.java
projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/TransientDeploymentMetaData.java
projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/TransientProfileActivator.java
projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/actions/AbstractDeploymentAddAction.java
projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/actions/AbstractDeploymentLifeCycleAction.java
projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/actions/DeploymentAddAction.java
projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/actions/DeploymentRemoveAction.java
projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/actions/DeploymentStartAction.java
projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/actions/DeploymentStopAction.java
projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/deploy/
projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/deploy/support/
projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/deploy/support/DeployHandlerSupport.java
projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/deploy/support/DeploymentIDSupport.java
projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/deploy/support/ManagedProfileSupport.java
projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/deploy/support/ProfileDeployerSupport.java
projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/deploy/test/
projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/deploy/test/AbstractDeployTest.java
projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/deploy/test/TransientProfileUnitTestCase.java
projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/action/ActionState.java
Removed:
projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/FileDeploymentTarget.java
projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/spi/
projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/action/ActionStatus.java
Modified:
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/AbstractDeploymentInfo.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/AbstractProfileDeployment.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/hotdeploy/AbstractHDScannerFactory.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/hotdeploy/HDScanner.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/management/AbstractActionController.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/management/TwoPCActionWrapper.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/management/actions/BasicProfileModificationActions.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/AbstractScanningProfile.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/ScanningProfileFactory.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/ProfileDeploymentFactory.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/virtual/assembly/BasicVirtualAssemblyContext.java
projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/virtual/support/TestVirtualDeploymentRepository.java
projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/AbstractDeployHandler.java
projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/DeploymentManagerImpl.java
projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/actions/DeploymentDistributeAction.java
projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/RegisteredProfileViewsWrapper.java
projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/util/ManagedDeploymentProcessorHelper.java
projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/action/ProfileModificationActions.java
projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/action/TwoPhaseCommitProfileAction.java
projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/action/engine/ActionController.java
projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/managed/ManagedProfile.java
Log:
initial work on deployment modification actions.
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/AbstractDeploymentInfo.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/AbstractDeploymentInfo.java 2010-03-15 12:49:05 UTC (rev 102401)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/AbstractDeploymentInfo.java 2010-03-15 12:49:17 UTC (rev 102402)
@@ -41,10 +41,18 @@
private final VirtualDeploymentMetaData deploymentMetaData;
/** The flags. */
- private int dFlags = 0;
+ private volatile int dFlags = 0;
public AbstractDeploymentInfo(String name, VirtualDeploymentMetaData deploymentMetaData)
{
+ if(name == null)
+ {
+ throw new IllegalArgumentException("null deployment name");
+ }
+ if(deploymentMetaData == null)
+ {
+ throw new IllegalArgumentException("null deployment meta data");
+ }
this.name = name;
this.deploymentMetaData = deploymentMetaData;
}
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/AbstractProfileDeployment.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/AbstractProfileDeployment.java 2010-03-15 12:49:05 UTC (rev 102401)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/AbstractProfileDeployment.java 2010-03-15 12:49:17 UTC (rev 102402)
@@ -21,6 +21,9 @@
*/
package org.jboss.profileservice.deployment;
+import java.io.Closeable;
+import java.io.IOException;
+
import org.jboss.deployers.vfs.spi.client.VFSDeployment;
import org.jboss.profileservice.spi.ProfileDeployment;
import org.jboss.profileservice.spi.deployment.DeploymentAttachments;
@@ -165,8 +168,23 @@
*/
public void cleanup() throws Exception
{
- // FIXME cleanup
+ cleanup(getPredeterminedAttachments());
+ cleanup(getTransientAttachments());
+
}
+ protected void cleanup(DeploymentAttachments attachments)
+ {
+ for(Object o : attachments.getAttachments().values())
+ {
+ if(o instanceof Closeable)
+ {
+ try {
+ Closeable.class.cast(o).close();
+ } catch(IOException ignore) { }
+ }
+ }
+ }
+
}
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/hotdeploy/AbstractHDScannerFactory.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/hotdeploy/AbstractHDScannerFactory.java 2010-03-15 12:49:05 UTC (rev 102401)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/hotdeploy/AbstractHDScannerFactory.java 2010-03-15 12:49:17 UTC (rev 102402)
@@ -107,7 +107,7 @@
{
throw new IllegalArgumentException("scanner already registered for profile " + key);
}
- HDScanner scanner = new HDScanner(key, actionController);
+ HDScanner scanner = createHDScannerRunnable(key, actionController);
ScannerWrapper wrapper = createScannerWrapper(key, scanner, configuration);
if(wrapper.isStartAutomatically() && enabled.get())
{
@@ -245,6 +245,18 @@
return wrapper;
}
+ /**
+ * Create the HDScanner runnable.
+ *
+ * @param key the profile key
+ * @param controller the action controller
+ * @return the hd scanner runnable
+ */
+ protected HDScanner createHDScannerRunnable(ProfileKey key, ActionController controller)
+ {
+ return new HDScanner(key, controller);
+ }
+
class ScannerWrapper implements Scanner, ScannerConfiguration
{
/** The scanner configuration. */
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/hotdeploy/HDScanner.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/hotdeploy/HDScanner.java 2010-03-15 12:49:05 UTC (rev 102401)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/hotdeploy/HDScanner.java 2010-03-15 12:49:17 UTC (rev 102402)
@@ -27,7 +27,6 @@
import org.jboss.deployers.spi.DeploymentException;
import org.jboss.logging.Logger;
-import org.jboss.profileservice.management.actions.BasicProfileModificationActions;
import org.jboss.profileservice.spi.ModificationInfo;
import org.jboss.profileservice.spi.MutableProfile;
import org.jboss.profileservice.spi.ProfileDeployment;
@@ -65,6 +64,9 @@
/** the action controller. */
private ActionController controller;
+ /** Mark the HDScanner as broken. */
+ private volatile boolean defunct = false;
+
protected HDScanner(ProfileKey key, ActionController controller)
{
this.key = key;
@@ -90,11 +92,20 @@
}
catch (Throwable e)
{
- log.warn("Scan failed", e);
+ if(defunct == false)
+ {
+ // Exceptions here won't come from the actual scanning
+ // So report the error only once
+ log.warn("Scan failed", e);
+ defunct = true;
+ }
}
finally
{
- incScanCount();
+ if(defunct == false)
+ {
+ incScanCount();
+ }
}
}
@@ -123,36 +134,25 @@
*/
protected synchronized void scan() throws Exception
{
- boolean trace = log.isTraceEnabled();
- if(trace)
- {
- log.debug("Begin deployment scan: " + getKey());
- }
// Get the profile
ManagedProfile managedProfile = controller.getManagedProfile(key);
if(managedProfile == null)
{
- // TODO This should be a warning and disable the check ?
- log.debug("profile not installed, skipping hot deployment check: " + key);
- return;
+ throw new IllegalStateException("Profile not active " + key);
}
// obviously the action installing the HDScanner has to check if this is mutable
MutableProfile profile = MutableProfile.class.cast(managedProfile.getProfile());
- ProfileModificationAction<ProfileModificationContext> action = new HDScanAction(profile, managedProfile.getManagedDeployer());
- BasicProfileModificationActions<ProfileModificationContext> actions = new BasicProfileModificationActions<ProfileModificationContext>(
- ProfileModificationType.UPDATE, Collections.singletonList(action));
+ ProfileModificationAction<ProfileModificationContext> action = new HDScanAction(profile, managedProfile.getManagedDeployer());
+ ModificationStatus modificationStatus = this.controller.perform(key, ProfileModificationType.UPDATE, Collections.singletonList(action));
- ModificationStatus modificationStatus = this.controller.perfom(key, actions);
-
if(modificationStatus.isFailed())
{
- // TODO
+ // TODO error reporting should be done here
}
-
- if(trace)
+ if(defunct)
{
- log.trace("End deployment scan: " + profile.getKey());
+ defunct = false;
}
}
@@ -165,6 +165,9 @@
notifyAll();
}
+ /**
+ * The HDScan action.
+ */
class HDScanAction implements ProfileModificationAction<ProfileModificationContext>
{
@@ -203,7 +206,6 @@
{
log.trace("Begin deployment scan: " + profile.getKey());
}
-
boolean modified = false;
Collection<String> modifiedDeploymentNames = new ArrayList<String>();
Collection<ModificationInfo> modifiedDeployments = profile.getModifiedDeployments();
@@ -241,11 +243,7 @@
// Only check the modified deployments to avoid duplicate errors
for(String name : modifiedDeploymentNames)
{
- // Can be nulled by a shutdown
- if (deployer != null)
- {
- deployer.checkComplete(name);
- }
+ deployer.checkComplete(name);
}
}
if(trace)
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/management/AbstractActionController.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/management/AbstractActionController.java 2010-03-15 12:49:05 UTC (rev 102401)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/management/AbstractActionController.java 2010-03-15 12:49:17 UTC (rev 102402)
@@ -30,7 +30,9 @@
import java.util.concurrent.locks.ReentrantReadWriteLock;
import org.jboss.managed.api.ManagedDeployment;
+import org.jboss.profileservice.management.actions.BasicProfileModificationActions;
import org.jboss.profileservice.management.event.ProfileLifeCycleEvent;
+import org.jboss.profileservice.management.event.ProfileModificationEvent;
import org.jboss.profileservice.management.event.ProfileLifeCycleEvent.LifeCycleState;
import org.jboss.profileservice.spi.Profile;
import org.jboss.profileservice.spi.ProfileDeployment;
@@ -65,6 +67,9 @@
return Collections.unmodifiableList(this.profiles);
}
+ /**
+ * {@inheritDoc}
+ */
public ManagedProfile getManagedProfile(ProfileKey key)
{
return this.profilesByName.get(key);
@@ -73,7 +78,7 @@
/**
* Register a profile.
*
- * @param profile the profile to register
+ * @param managed the profile to register
*/
public void addProfile(ManagedProfile context)
{
@@ -86,7 +91,7 @@
/**
* Unregister a profile.
*
- * @param profile the profile to unregister
+ * @param managed the profile to unregister
*/
public void removeProfile(ManagedProfile context)
{
@@ -100,7 +105,7 @@
wrapper.lockWrite();
try
{
- //
+ wrapper.deactivate();
}
finally
{
@@ -112,65 +117,99 @@
/**
* {@inheritDoc}
*/
- public ModificationStatus perfom(ProfileKey key, ProfileModificationActions<ProfileModificationContext> actions)
+ public ModificationStatus perform(ProfileKey key, ProfileModificationType type, List<ProfileModificationAction<ProfileModificationContext>> actions)
{
- if(key == null)
+ BasicProfileModificationActions modifications = new BasicProfileModificationActions(type);
+ for(ProfileModificationAction<ProfileModificationContext> action : actions)
{
- throw new IllegalArgumentException("null profile key");
+ modifications.addAction(key, action);
}
- ProfileWrapper wrapper = profilesByName.get(key);
- if(wrapper == null)
- {
- throw new IllegalStateException("no such profile registered" + key);
- }
+ return perform(modifications);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public ModificationStatus perform(ProfileModificationActions actions)
+ {
ProfileModificationType type = actions.getType();
if(type == ProfileModificationType.GET)
{
- return performRead(wrapper, actions);
+ return performRead(actions);
}
else
{
- return performWrite(wrapper, actions);
+ return performWrite(actions);
}
}
/**
* Perform read operations on a profile.
*
- * @param wrapper the wrapper
* @param actions the read actions
* @return the status
*/
- ModificationStatus performRead(ProfileWrapper wrapper, ProfileModificationActions<ProfileModificationContext> actions)
+ ModificationStatus performRead(ProfileModificationActions actions)
{
- wrapper.lockRead();
+ List<ProfileWrapper> profiles = new ArrayList<ProfileWrapper>();
try
{
- return internalPerfom(wrapper.getProfile(), actions);
+ for(ProfileKey key : actions.getProfilesKeys())
+ {
+ ProfileWrapper wrapper = this.profilesByName.get(key);
+ if(wrapper == null)
+ {
+ throw new IllegalStateException("profile not registered" + key);
+ }
+ if(profiles.contains(wrapper) == false)
+ {
+ wrapper.lockRead();
+ profiles.add(wrapper);
+ }
+ }
+ return internalPerfom(actions);
}
finally
{
- wrapper.unlockRead();
- }
+ for(ProfileWrapper wrapper : profiles)
+ {
+ wrapper.unlockRead();
+ }
+ }
}
/**
* Perform a write operations on a profile.
*
- * @param wrapper the wrapper
* @param actions the write actions
* @return the status
*/
- ModificationStatus performWrite(ProfileWrapper wrapper, ProfileModificationActions<ProfileModificationContext> actions)
+ ModificationStatus performWrite(ProfileModificationActions actions)
{
- wrapper.lockWrite();
+ List<ProfileWrapper> profiles = new ArrayList<ProfileWrapper>();
try
{
- return internalPerfom(wrapper.getProfile(), actions);
+ for(ProfileKey key : actions.getProfilesKeys())
+ {
+ ProfileWrapper wrapper = this.profilesByName.get(key);
+ if(wrapper == null)
+ {
+ throw new IllegalStateException("profile not registered" + key);
+ }
+ if(profiles.contains(wrapper) == false)
+ {
+ wrapper.lockWrite();
+ profiles.add(wrapper);
+ }
+ }
+ return internalPerfom(actions);
}
finally
{
- wrapper.unlockWrite();
+ for(ProfileWrapper wrapper : profiles)
+ {
+ wrapper.unlockWrite();
+ }
}
}
@@ -181,31 +220,36 @@
* @param actions the actions
* @return the status
*/
- ModificationStatus internalPerfom(Profile profile, ProfileModificationActions<ProfileModificationContext> actions)
+ ModificationStatus internalPerfom(ProfileModificationActions actions)
{
boolean success = true;
final List<TwoPhaseCommitProfileAction<?>> prepared = new ArrayList<TwoPhaseCommitProfileAction<?>>();
- for(ProfileModificationAction<ProfileModificationContext> action : actions.getActions())
+ for(ProfileKey key : actions.getProfilesKeys())
{
- // In case a previous action failed to prepare, cancel others
- if(success == false)
+ for(ProfileModificationAction<? extends ProfileModificationContext> action : actions.getActions(key))
{
- action.cancel();
- continue;
+ // In case a previous action failed to prepare, cancel others
+ if(success == false)
+ {
+ action.cancel();
+ continue;
+ }
+ TwoPhaseCommitProfileAction<?> tpca = null;
+ if(action instanceof TwoPhaseCommitProfileAction<?>)
+ {
+ tpca = TwoPhaseCommitProfileAction.class.cast(action);
+ }
+ else
+ {
+ // Wrap others
+ tpca = new TwoPCActionWrapper(action);
+ }
+ // Prepare
+ success &= tpca.prepare();
+ prepared.add(tpca);
}
- TwoPhaseCommitProfileAction<?> tpca = null;
- if(action instanceof TwoPhaseCommitProfileAction<?>)
- {
- tpca = TwoPhaseCommitProfileAction.class.cast(action);
- }
- else
- {
- // Wrap others
- tpca = new TwoPCActionWrapper(action);
- }
- // Prepare
- success &= tpca.prepare();
- prepared.add(tpca);
+ // FIXME
+ fireModificationEvent(new ProfileModificationEvent(key));
}
if(success)
{
@@ -230,40 +274,51 @@
*/
private static class ProfileWrapper implements ManagedProfile
{
- private final ManagedProfile profile;
+ private final ManagedProfile managed;
private final ReentrantReadWriteLock lock;
+ private volatile boolean active = true;
ProfileWrapper(final ManagedProfile profile)
{
- this.profile = profile;
+ this.managed = profile;
this.lock = new ReentrantReadWriteLock(true);
}
public ProfileKey getProfileKey()
{
- return profile.getProfileKey();
+ return getManaged().getProfileKey();
}
-
public Profile getProfile()
{
- return profile.getProfile();
+ return getManaged().getProfile();
}
-
public ProfileMetaData getProfileMetaData()
{
- return profile.getProfileMetaData();
+ return getManaged().getProfileMetaData();
}
-
public ManagedProfileDeployer getManagedDeployer()
{
- return profile.getManagedDeployer();
+ return getManaged().getManagedDeployer();
}
-
public ManagedDeployment getManagedDeployment(ProfileDeployment deployment) throws Exception
{
- return profile.getManagedDeployment(deployment);
+ return getManaged().getManagedDeployment(deployment);
}
+ private ManagedProfile getManaged()
+ {
+ if(active)
+ {
+ return managed;
+ }
+ throw new IllegalStateException("profile in inactive state " + managed.getProfileKey());
+ }
+
+ void deactivate()
+ {
+ active = false;
+ }
+
void lockRead()
{
lock.readLock().lock();
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/management/TwoPCActionWrapper.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/management/TwoPCActionWrapper.java 2010-03-15 12:49:05 UTC (rev 102401)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/management/TwoPCActionWrapper.java 2010-03-15 12:49:17 UTC (rev 102402)
@@ -21,69 +21,69 @@
*/
package org.jboss.profileservice.management;
-import org.jboss.profileservice.spi.action.ActionStatus;
+import org.jboss.profileservice.management.actions.AbstractTwoPhaseModificationAction;
import org.jboss.profileservice.spi.action.ProfileModificationAction;
import org.jboss.profileservice.spi.action.ProfileModificationContext;
-import org.jboss.profileservice.spi.action.TwoPhaseCommitProfileAction;
/**
* @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
* @version $Revision$
*/
-class TwoPCActionWrapper implements TwoPhaseCommitProfileAction<ProfileModificationContext>
+class TwoPCActionWrapper extends AbstractTwoPhaseModificationAction<ProfileModificationContext>
{
/** The delegate. */
- private final ProfileModificationAction<ProfileModificationContext> delegate;
+ private final ProfileModificationAction<? extends ProfileModificationContext> delegate;
- public TwoPCActionWrapper(ProfileModificationAction<ProfileModificationContext> delegate)
+ public TwoPCActionWrapper(ProfileModificationAction<? extends ProfileModificationContext> delegate)
{
+ super(delegate.getContext());
this.delegate = delegate;
}
-
- public void commit()
+
+ protected void doCancel()
{
- this.delegate.complete();
+ delegate.cancel();
}
- public ActionStatus getStatus()
+ protected void doCommit()
{
- return ActionStatus.UNKNOWN;
+ //
}
- public boolean prepare()
+ protected void doComplete() throws Exception
{
- return true;
+ delegate.complete();
}
- public void rollback()
+ protected boolean doPrepare()
{
- //
+ return true;
}
- public void cancel()
+ protected void doRollbackFromCancelled()
{
- this.delegate.cancel();
+ //
}
- public void complete()
+ protected void doRollbackFromComplete()
{
- this.delegate.complete();
+ //
}
- public ProfileModificationContext getContext()
+ protected void doRollbackFromActive()
{
- return this.delegate.getContext();
+ //
}
- public boolean isCancelled()
+ protected void doRollbackFromPrepared()
{
- return this.delegate.isCancelled();
+ //
}
- public boolean isComplete()
+ protected void doRollbackFromRollbackOnly()
{
- return this.delegate.isComplete();
+ //
}
}
Added: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/management/actions/AbstractTwoPhaseModificationAction.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/management/actions/AbstractTwoPhaseModificationAction.java (rev 0)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/management/actions/AbstractTwoPhaseModificationAction.java 2010-03-15 12:49:17 UTC (rev 102402)
@@ -0,0 +1,197 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2010, Red Hat Inc., and individual contributors as indicated
+* 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.actions;
+
+import org.jboss.profileservice.spi.action.ActionState;
+import org.jboss.profileservice.spi.action.ProfileModificationContext;
+import org.jboss.profileservice.spi.action.TwoPhaseCommitProfileAction;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public abstract class AbstractTwoPhaseModificationAction<T extends ProfileModificationContext> implements TwoPhaseCommitProfileAction<T>
+{
+
+ /** The modification context. */
+ private final T modificationContext;
+
+ private ActionState state = ActionState.ACTIVE;
+ private boolean cancelled = false;
+ private boolean complete = false;
+
+ public AbstractTwoPhaseModificationAction(T modificationContext)
+ {
+ this.modificationContext = modificationContext;
+ }
+
+ public T getContext()
+ {
+ return this.modificationContext;
+ }
+
+ public ActionState getState()
+ {
+ return this.state;
+ }
+
+ public void cancel()
+ {
+ if(state == ActionState.ACTIVE)
+ {
+ doCancel();
+ this.cancelled = true;
+ this.state = ActionState.CANCELLED;
+ }
+ }
+
+ public void complete()
+ {
+ if(state == ActionState.ACTIVE)
+ {
+ try
+ {
+ doComplete();
+ this.state = ActionState.COMPLETED;
+ }
+ catch(Exception e)
+ {
+ this.state = ActionState.ROLLBACK;
+ }
+ finally
+ {
+ this.complete = true;
+ }
+ }
+ }
+
+ public boolean prepare()
+ {
+ boolean result = false;
+ switch (state)
+ {
+ case ACTIVE:
+ complete();
+ if (state != ActionState.COMPLETED)
+ {
+ break;
+ }
+ case COMPLETED:
+ result = doPrepare();
+ if (result)
+ {
+ state = ActionState.PREPARED;
+ result = true;
+ }
+ else
+ {
+ state = ActionState.ROLLBACK;
+ }
+ break;
+ case PREPARED:
+ case COMMITTED:
+ case ROLLEDBACK:
+ case CANCELLED:
+ case ROLLBACK:
+ break;
+ }
+ return result;
+ }
+
+ public void commit()
+ {
+ switch(state)
+ {
+ case PREPARED:
+ doCommit();
+ state = ActionState.COMMITTED;
+ break;
+ case ACTIVE:
+ case CANCELLED:
+ case COMPLETED:
+ case ROLLBACK:
+ case COMMITTED:
+ case ROLLEDBACK:
+ // warn
+ break;
+ }
+ }
+
+ public void rollback()
+ {
+ switch (state)
+ {
+ case COMMITTED:
+ case ROLLEDBACK:
+ // warn
+ return;
+ case ACTIVE:
+ doRollbackFromActive();
+ break;
+ case CANCELLED:
+ doRollbackFromCancelled();
+ break;
+ case ROLLBACK:
+ doRollbackFromRollbackOnly();
+ break;
+ case COMPLETED:
+ doRollbackFromComplete();
+ break;
+ case PREPARED:
+ doRollbackFromPrepared();
+ break;
+ }
+ state = ActionState.ROLLEDBACK;
+ }
+
+ public boolean isCancelled()
+ {
+ return cancelled;
+ }
+
+ public boolean isComplete()
+ {
+ return complete;
+ }
+
+ protected abstract void doCancel();
+ protected abstract void doComplete() throws Exception;
+ protected abstract boolean doPrepare();
+ protected abstract void doCommit();
+ protected abstract void doRollbackFromActive();
+ protected abstract void doRollbackFromCancelled();
+ protected abstract void doRollbackFromRollbackOnly();
+ protected abstract void doRollbackFromComplete();
+ protected abstract void doRollbackFromPrepared();
+
+ protected void setRollbackOnly()
+ {
+
+ if (this.state != ActionState.PREPARED && this.state != ActionState.COMMITTED
+ && this.state != ActionState.ROLLEDBACK)
+ {
+ this.state = ActionState.ROLLBACK;
+ }
+ }
+
+}
+
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/management/actions/BasicProfileModificationActions.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/management/actions/BasicProfileModificationActions.java 2010-03-15 12:49:05 UTC (rev 102401)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/management/actions/BasicProfileModificationActions.java 2010-03-15 12:49:17 UTC (rev 102402)
@@ -21,8 +21,12 @@
*/
package org.jboss.profileservice.management.actions;
+import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
+import org.jboss.profileservice.spi.ProfileKey;
import org.jboss.profileservice.spi.action.ProfileModificationAction;
import org.jboss.profileservice.spi.action.ProfileModificationActions;
import org.jboss.profileservice.spi.action.ProfileModificationContext;
@@ -34,29 +38,48 @@
* @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
* @version $Revision$
*/
-public class BasicProfileModificationActions<T extends ProfileModificationContext> implements ProfileModificationActions<T>
+public class BasicProfileModificationActions implements ProfileModificationActions
{
/** The modification type. */
- private ProfileModificationType type;
+ private final ProfileModificationType type;
- /** The modification actions. */
- private List<ProfileModificationAction<T>> actions;
+ /** The profiles. */
+ private List<ProfileKey> profiles = new ArrayList<ProfileKey>();
+
+ /** The actions by profile. */
+ private Map<ProfileKey, List<ProfileModificationAction<? extends ProfileModificationContext>>> modificationActions = new HashMap<ProfileKey, List<ProfileModificationAction<? extends ProfileModificationContext>>>();
- public BasicProfileModificationActions(ProfileModificationType type, List<ProfileModificationAction<T>> actions)
+ public BasicProfileModificationActions(ProfileModificationType type)
{
this.type = type;
- this.actions = actions;
}
+
+ public ProfileModificationType getType()
+ {
+ return this.type;
+ }
- public List<ProfileModificationAction<T>> getActions()
+ public List<ProfileKey> getProfilesKeys()
{
- return this.actions;
+ return this.profiles;
}
+
+ public List<ProfileModificationAction<? extends ProfileModificationContext>> getActions(ProfileKey key)
+ {
+ return modificationActions.get(key);
+ }
- public ProfileModificationType getType()
+ public void addAction(ProfileKey key, ProfileModificationAction<? extends ProfileModificationContext> action)
{
- return this.type;
+ List<ProfileModificationAction<? extends ProfileModificationContext>> actions = this.modificationActions.get(key);
+ if(actions == null)
+ {
+ actions = new ArrayList<ProfileModificationAction<? extends ProfileModificationContext>>();
+ this.profiles.add(key);
+ this.modificationActions.put(key, actions);
+ }
+ actions.add(action);
}
}
Added: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/management/event/ProfileModificationEvent.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/management/event/ProfileModificationEvent.java (rev 0)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/management/event/ProfileModificationEvent.java 2010-03-15 12:49:17 UTC (rev 102402)
@@ -0,0 +1,48 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2010, Red Hat Inc., and individual contributors as indicated
+* 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.event;
+
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.action.engine.ModificationEvent;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class ProfileModificationEvent implements ModificationEvent
+{
+
+ /** The profile key. */
+ private final ProfileKey key;
+
+ public ProfileModificationEvent(ProfileKey key)
+ {
+ this.key = key;
+ }
+
+ public ProfileKey getKey()
+ {
+ return key;
+ }
+
+}
+
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/AbstractScanningProfile.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/AbstractScanningProfile.java 2010-03-15 12:49:05 UTC (rev 102401)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/AbstractScanningProfile.java 2010-03-15 12:49:17 UTC (rev 102402)
@@ -25,7 +25,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
-import java.util.HashSet;
+import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
@@ -68,7 +68,7 @@
private Map<String, ProfileDeployment> deployments = new ConcurrentHashMap<String, ProfileDeployment>();
/** The repository names, containing all files we recognized as deployments */
- private Set<String> repositoryNames = new HashSet<String>();
+ private Map<String, String> repositoryNames = new HashMap<String, String>();
/** The last modified. */
private volatile long lastModified;
@@ -158,7 +158,7 @@
*/
public boolean hasDeployment(final String name)
{
- return this.deployments.containsKey(name);
+ return resolveDeployment(name) != null ? true : false;
}
/**
@@ -242,7 +242,7 @@
public boolean accepts(final Artifact<FileArtifactId> artifact)
{
final FileArtifactId id = artifact.getIdentifier();
- boolean exists = repositoryNames.contains(id.getPath());
+ boolean exists = repositoryNames.containsKey(id.getPath());
if(exists)
{
return false;
@@ -287,9 +287,16 @@
*/
protected ProfileDeployment resolveDeployment(final String name)
{
+ // Get full deployment name
ProfileDeployment deployment = this.deployments.get(name);
if(deployment == null)
{
+ // Resolve repository name
+ if(repositoryNames.containsKey(name))
+ {
+ return this.deployments.get(this.repositoryNames.get(name));
+ }
+ // Match simple names
for(ProfileDeployment d : getDeployments())
{
if(d.getSimpleName().equals(name))
@@ -311,7 +318,7 @@
protected void internalAddDeployment(final ProfileDeployment deployment, final FileArtifactId artifactId)
{
this.deployments.put(deployment.getName(), deployment);
- this.repositoryNames.add(artifactId.getPath());
+ this.repositoryNames.put(artifactId.getPath(), deployment.getName());
// Mark as modified if it already exists ?
}
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/ScanningProfileFactory.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/ScanningProfileFactory.java 2010-03-15 12:49:05 UTC (rev 102401)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/ScanningProfileFactory.java 2010-03-15 12:49:17 UTC (rev 102402)
@@ -42,8 +42,11 @@
import org.jboss.profileservice.spi.repository.ArtifactId;
import org.jboss.profileservice.spi.repository.ArtifactRepository;
import org.jboss.profileservice.spi.repository.ArtifactRepositoryConfiguration;
+import org.jboss.profileservice.spi.repository.ArtifactRepositoryId;
/**
+ * The scanning profile factory, creating scanning profiles.
+ *
* @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
* @version $Revision$
*/
@@ -104,6 +107,9 @@
this.modificationChecker = modificationChecker;
}
+ /**
+ * {@inheritDoc}
+ */
public AbstractScanningProfile createProfile(ProfileKey key, PropertyProfileMetaData metaData) throws Exception
{
PropertyProfileSourceMetaData source = metaData.getSource();
@@ -123,6 +129,24 @@
}
}
+ /**
+ * {@inheritDoc}
+ */
+ public void destroyProfile(PropertyProfileMetaData metaData, AbstractScanningProfile profile)
+ {
+ cleanupRepository(profile.getDeploymentRepository());
+ }
+
+ /**
+ * Create the virtual deployment repository.
+ *
+ * @param artifactRepoName the repository name
+ * @param source the profile source meta data
+ * @param isMutable whether the repository should be mutable
+ * @return the virtual deployment repository
+ * @throws IOException
+ * @throws URISyntaxException
+ */
protected VirtualDeploymentRepository createDeploymentRepository(String artifactRepoName, PropertyProfileSourceMetaData source, boolean isMutable)
throws IOException, URISyntaxException
{
@@ -135,19 +159,19 @@
fileRepository.getIdentifier());
}
- public void destroyProfile(PropertyProfileMetaData metaData, AbstractScanningProfile profile)
+ /**
+ * Cleanup the created repositories.
+ *
+ * @param repository the virtual deployment repository
+ */
+ protected void cleanupRepository(VirtualDeploymentRepository repository)
{
- VirtualDeploymentRepository repository = profile.getDeploymentRepository();
- if(repository instanceof DelegatingDeploymentRepository)
+ Collection<ArtifactRepositoryId> repositories = repository.getRepositoryIDs();
+ if(repositories != null && repositories.isEmpty() == false)
{
- DelegatingDeploymentRepository created = (DelegatingDeploymentRepository) repository;
- Collection<ArtifactRepository<ArtifactId>> repositories = created.getArtifactRepositories();
- if(repositories != null && repositories.isEmpty() == false)
+ for(ArtifactRepositoryId artifactRepository : repositories)
{
- for(ArtifactRepository<ArtifactId> artifactRepository : repositories)
- {
- repositoryManager.removeRepository(artifactRepository.getIdentifier());
- }
+ repositoryManager.removeRepository(artifactRepository);
}
}
}
Added: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/NoopVirtualDeploymentMetaData.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/NoopVirtualDeploymentMetaData.java (rev 0)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/NoopVirtualDeploymentMetaData.java 2010-03-15 12:49:17 UTC (rev 102402)
@@ -0,0 +1,59 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2010, Red Hat Inc., and individual contributors as indicated
+* 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.repository;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.jboss.profileservice.spi.repository.ArtifactId;
+import org.jboss.profileservice.spi.virtual.VirtualArtifactMetaData;
+import org.jboss.profileservice.spi.virtual.VirtualDeploymentMetaData;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class NoopVirtualDeploymentMetaData implements VirtualDeploymentMetaData
+{
+
+ public ArtifactId getArtifact()
+ {
+ return null;
+ }
+
+ public List<VirtualArtifactMetaData> getArtifacts()
+ {
+ return Collections.emptyList();
+ }
+
+ public List<VirtualDeploymentMetaData> getChildren()
+ {
+ return Collections.emptyList();
+ }
+
+ public String getName()
+ {
+ return null;
+ }
+
+}
+
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/ProfileDeploymentFactory.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/ProfileDeploymentFactory.java 2010-03-15 12:49:05 UTC (rev 102401)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/ProfileDeploymentFactory.java 2010-03-15 12:49:17 UTC (rev 102402)
@@ -34,6 +34,9 @@
public class ProfileDeploymentFactory
{
+ /** The noop deployment meta data. */
+ public static final VirtualDeploymentMetaData noopDeploymentMetaData = new NoopVirtualDeploymentMetaData();
+
/** The instance. */
private static final ProfileDeploymentFactory instance = new ProfileDeploymentFactory();
@@ -53,7 +56,7 @@
{
throw new IllegalArgumentException("null deployment name");
}
- return new BasicProfileDeployment(name, null);
+ return new BasicProfileDeployment(name, noopDeploymentMetaData);
}
public ProfileDeployment createDeployment(VirtualFile vf, VirtualDeploymentMetaData metaData)
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/virtual/assembly/BasicVirtualAssemblyContext.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/virtual/assembly/BasicVirtualAssemblyContext.java 2010-03-15 12:49:05 UTC (rev 102401)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/virtual/assembly/BasicVirtualAssemblyContext.java 2010-03-15 12:49:17 UTC (rev 102402)
@@ -29,6 +29,7 @@
import org.jboss.profileservice.spi.virtual.VirtualArtifactMetaData;
import org.jboss.profileservice.spi.virtual.VirtualDeploymentMetaData;
import org.jboss.profileservice.spi.virtual.assembly.VirtualDeploymentAssemblyContext;
+import org.jboss.vfs.VFSUtils;
import org.jboss.vfs.VirtualFile;
import org.jboss.vfs.VirtualFileAssembly;
import org.jboss.vfs.VirtualFileFilter;
@@ -40,7 +41,7 @@
* @version $Revision$
*/
public class BasicVirtualAssemblyContext extends AbstractVirtualAssemblyContext
- implements VirtualDeploymentAssemblyContext
+ implements VirtualDeploymentAssemblyContext, Closeable
{
/** The meta-inf name. */
@@ -236,5 +237,10 @@
}
+ public void close()
+ {
+ VFSUtils.safeClose(this.closeable);
+ }
+
}
Added: projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/resolver/test/ProcessingUnitTestCase.java
===================================================================
--- projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/resolver/test/ProcessingUnitTestCase.java (rev 0)
+++ projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/resolver/test/ProcessingUnitTestCase.java 2010-03-15 12:49:17 UTC (rev 102402)
@@ -0,0 +1,162 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2010, Red Hat Inc., and individual contributors as indicated
+* 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.resolver.test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.plugins.bootstrap.basic.BasicBootstrap;
+import org.jboss.profileservice.dependency.ProfileDependencyContext;
+import org.jboss.profileservice.dependency.ProfileServiceController;
+import org.jboss.profileservice.profile.metadata.domain.RequiredProfiles.ResolveRequirement;
+import org.jboss.profileservice.profile.metadata.plugin.EmptyProfileMetaData;
+import org.jboss.profileservice.profile.metadata.plugin.EmptyProfileMetaData.DependencyModeRequirement;
+import org.jboss.profileservice.resolver.AbstractRequirementResolver;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.dependency.DependencyMode;
+import org.jboss.profileservice.spi.metadata.ProfileMetaDataVisitorNode;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class ProcessingUnitTestCase extends AbstractResolverTest
+{
+
+ Kernel kernel;
+ ProfileServiceController controller;
+
+ public ProcessingUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ BasicBootstrap bootstrap = new BasicBootstrap();
+ bootstrap.run();
+ kernel = bootstrap.getKernel();
+ controller = new ProfileServiceController(kernel.getController(), createRegistry(), getConfig());
+ }
+
+ public void tearDown() throws Exception
+ {
+ super.tearDown();
+ // kernel.getController().shutdown();
+ controller = null;
+ kernel = null;
+ }
+
+ public void test() throws Throwable
+ {
+ createProfileMetaData(100);
+ for(int i = 1; i <= 100; i++)
+ {
+ controller.activate(new ProfileKey("profile"+i));
+ }
+ }
+
+ public void test1() throws Throwable
+ {
+ int numbers = 100;
+ createProfileMetaData(numbers);
+ long millis = System.currentTimeMillis();
+ for(int i = 1; i <= numbers; i++)
+ // for(int i = numbers; i > 0 ; i--)
+ {
+ controller.activate(new ProfileKey("profile"+i));
+ }
+ getLog().debug("time: " + (System.currentTimeMillis() - millis));
+ }
+
+ public void test2() throws Throwable
+ {
+ long millis = System.currentTimeMillis();
+
+ int numbers = 100;
+
+ createProfileMetaData(numbers);
+
+ ProfileDependencyContext d = new ProfileDependencyContext(new ProfileKey("test"), new EmptyProfileMetaData(), getRegistry());
+ d.addRequirement(new ResolveRequirement("profile"+numbers));
+
+ controller.install(d, null);
+
+ AbstractRequirementResolver resolver = new AbstractRequirementResolver(getRegistry());
+
+ resolver.resolve(d);
+ List<ProfileKey> sorted = resolver.sort();
+ getLog().debug(sorted);
+
+ getLog().debug("time: " + (System.currentTimeMillis() - millis));
+ millis = System.currentTimeMillis();
+ for(ProfileKey key : sorted)
+ {
+ controller.activate(key);
+ }
+ getLog().debug("time: " + (System.currentTimeMillis() - millis));
+ }
+
+
+
+ protected void createProfileMetaData(int numbers) throws Exception
+ {
+ int blah = 0;
+ for(int i = numbers; i > 0 ; i--)
+ {
+ EmptyProfileMetaData metaData = new EmptyProfileMetaData("profile" + i);
+
+ boolean ten = (i % 10) == 0;
+ if(ten)
+ getLog().debug(i);
+
+ if( i != 0)
+ {
+ ArrayList<ProfileMetaDataVisitorNode> requirements = new ArrayList<ProfileMetaDataVisitorNode>();
+
+ int start = i - 1 > 0 ? i - 1 : 0;
+ int end = start - 50 > 0 ? start - 50 : 0;
+ for(int j = start; j > end; j--)
+ {
+ DependencyModeRequirement r = new DependencyModeRequirement("profile" + j);
+ r.setDependencyMode(DependencyMode.RESOLVE);
+ requirements.add(r);
+ blah++;
+ }
+ metaData.setFeatures(requirements);
+ }
+ try
+ {
+ controller.registerAndInstallContext(metaData, null);
+ }
+ catch(Throwable t)
+ {
+ throw new RuntimeException(t);
+ }
+ }
+ getLog().debug("blah " + blah);
+ }
+
+}
+
Modified: projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/virtual/support/TestVirtualDeploymentRepository.java
===================================================================
--- projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/virtual/support/TestVirtualDeploymentRepository.java 2010-03-15 12:49:05 UTC (rev 102401)
+++ projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/virtual/support/TestVirtualDeploymentRepository.java 2010-03-15 12:49:17 UTC (rev 102402)
@@ -71,7 +71,6 @@
/**
* Create a ProfileDeployment.
- * TODO - ProfileDeployment should maybe be a virtual deployment?
*
* @param deployment the virtual deployment descriptor
* @return the profile deployment
Modified: projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/AbstractDeployHandler.java
===================================================================
--- projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/AbstractDeployHandler.java 2010-03-15 12:49:05 UTC (rev 102401)
+++ projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/AbstractDeployHandler.java 2010-03-15 12:49:17 UTC (rev 102402)
@@ -22,104 +22,236 @@
package org.jboss.profileservice.plugins.deploy;
import java.io.InputStream;
-import java.util.Collection;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
import org.jboss.deployers.spi.management.deploy.DeploymentID;
-import org.jboss.profileservice.deployment.ProfileDeploymentRegistry;
-import org.jboss.profileservice.plugins.deploy.spi.DeploymentTarget;
-import org.jboss.profileservice.repository.artifact.file.FileArtifactId;
-import org.jboss.profileservice.spi.DeploymentOption;
+import org.jboss.profileservice.management.actions.BasicProfileModificationActions;
+import org.jboss.profileservice.plugins.deploy.actions.DeploymentAddAction;
+import org.jboss.profileservice.plugins.deploy.actions.DeploymentDistributeAction;
+import org.jboss.profileservice.plugins.deploy.actions.DeploymentRemoveAction;
+import org.jboss.profileservice.plugins.deploy.actions.DeploymentStartAction;
+import org.jboss.profileservice.plugins.deploy.actions.DeploymentStopAction;
+import org.jboss.profileservice.spi.MutableProfile;
import org.jboss.profileservice.spi.NoSuchDeploymentException;
+import org.jboss.profileservice.spi.NoSuchProfileException;
import org.jboss.profileservice.spi.Profile;
-import org.jboss.profileservice.spi.ProfileDeployment;
import org.jboss.profileservice.spi.ProfileKey;
-import org.jboss.profileservice.spi.ProfileService;
+import org.jboss.profileservice.spi.action.ProfileModificationType;
+import org.jboss.profileservice.spi.action.engine.ActionController;
+import org.jboss.profileservice.spi.action.engine.ModificationStatus;
+import org.jboss.profileservice.spi.managed.ManagedProfile;
/**
+ * The abstract deploy handler.
+ *
* @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
* @version $Revision$
*/
public class AbstractDeployHandler
{
-
- /** The deployment registry. */
- private ProfileDeploymentRegistry deploymentRegistry;
- /** The ProfileService. */
- private ProfileService ps;
+ /** The action controller. */
+ private ActionController actionController;
- protected Profile getProfile(ProfileKey key)
+ public ActionController getActionController()
{
- return null;
+ return actionController;
}
- protected void distribute(DeploymentID id)
+ public void setActionController(ActionController actionController)
{
- if(id.isCopyContent())
+ this.actionController = actionController;
+ }
+
+ /**
+ * Add a deployment.
+ *
+ * @param dtID the deployment id
+ * @param contentIS the content IS
+ */
+ protected void addDeployment(DeploymentID dtID, InputStream contentIS)
+ {
+ BasicProfileModificationActions actions = new BasicProfileModificationActions(ProfileModificationType.ADD);
+ if(dtID.isCopyContent())
{
- ///
+ ManagedProfile managed = actionController.getManagedProfile(dtID.getProfile());
+ if(managed != null && managed.getProfile().isMutable() && managed.getProfile() instanceof MutableProfile)
+ {
+ MutableProfile mutable = MutableProfile.class.cast(managed.getProfile());
+ actions.addAction(mutable.getKey(), new DeploymentDistributeAction(mutable, dtID, contentIS, null));
+ }
+ else
+ {
+ throw new IllegalStateException("failed to get profile " + dtID.getProfile());
+ }
}
else
{
-
-
-
-
+ ManagedProfile managed = actionController.getManagedProfile(TransientProfileActivator.TRANSIENT_PROFILE_KEY);
+ if(managed != null && managed.getProfile().isMutable() && managed.getProfile() instanceof MutableProfile)
+ {
+ MutableProfile mutable = MutableProfile.class.cast(managed.getProfile());
+ actions.addAction(mutable.getKey(), new DeploymentAddAction(dtID, mutable, null));
+ }
+ else
+ {
+ throw new IllegalStateException("failed to get profile " + TransientProfileActivator.TRANSIENT_PROFILE_KEY);
+ }
}
+ ModificationStatus status = actionController.perform(actions);
+ if(status.isFailed())
+ {
+ throw new IllegalStateException("failed to add deployment " + dtID);
+ }
}
-
- protected String copyContent(InputStream contentIS, DeploymentID id) throws Exception
+
+ /**
+ * Start a set of deployments.
+ *
+ * @param deploymentNames the deployment names
+ * @throws Exception for any error
+ */
+ protected void startDeployments(String... deploymentNames) throws Exception
{
- ProfileKey key = id.getProfile();
- DeploymentTarget<FileArtifactId> deploymentTarget = FileDeploymentTarget.createDeploymentTarget(getProfile(key));
-
- // We only distribute one deployment
- String name = id.getNames()[0];
- DeploymentOption[] options = id.getDeploymentOptions();
-
- ProfileDeployment deployment = deploymentTarget.distributeContent(name, contentIS, options);
- return deployment.getName();
+ Map<ProfileKey, Set<String>> mappings = resolveProfiles(deploymentNames, false, true);
+ BasicProfileModificationActions actions = new BasicProfileModificationActions(ProfileModificationType.UPDATE);
+ for(ProfileKey key : mappings.keySet())
+ {
+ ManagedProfile managed = actionController.getManagedProfile(key);
+ if(managed == null)
+ {
+ throw new NoSuchProfileException(key.getName());
+ }
+ actions.addAction(key, new DeploymentStartAction(managed, mappings.get(key), null));
+ }
+ ModificationStatus status = actionController.perform(actions);
+ if(status.isFailed())
+ {
+ throw new IllegalStateException("failed to start deployments " + Arrays.asList(deploymentNames));
+ }
}
-
- protected void startDeployment(String deploymentName) throws Exception
+ /**
+ * Stop a set of deployments.
+ *
+ * @param deploymentNames the deployment names
+ * @throws Exception for any error
+ */
+ protected void stopDeployments(String... deploymentNames) throws Exception
{
- ProfileKey key = checkProfileForDeployment(deploymentName);
-
+ Map<ProfileKey, Set<String>> mappings = resolveProfiles(deploymentNames, false, true);
+ BasicProfileModificationActions actions = new BasicProfileModificationActions(ProfileModificationType.UPDATE);
+ for(ProfileKey key : mappings.keySet())
+ {
+ ManagedProfile managed = actionController.getManagedProfile(key);
+ if(managed == null)
+ {
+ throw new NoSuchProfileException(key.getName());
+ }
+ actions.addAction(key, new DeploymentStopAction(managed, mappings.get(key), null));
+ }
+ ModificationStatus status = actionController.perform(actions);
+ if(status.isFailed())
+ {
+ throw new IllegalStateException("failed to stop deployments " + Arrays.asList(deploymentNames));
+ }
}
- protected void stopDeployment(String deploymentName) throws Exception
+ /**
+ * Remove a set of deployments.
+ *
+ * @param deploymentNames the deployment names
+ * @throws Exception for any error
+ */
+ protected void removeDeployments(String... deploymentNames) throws Exception
{
- ProfileKey key = checkProfileForDeployment(deploymentName);
-
+ Map<ProfileKey, Set<String>> mappings = resolveProfiles(deploymentNames, true, true);
+ BasicProfileModificationActions actions = new BasicProfileModificationActions(ProfileModificationType.UPDATE);
+ for(ProfileKey key : mappings.keySet())
+ {
+ ManagedProfile managed = actionController.getManagedProfile(key);
+ if(managed == null)
+ {
+ throw new NoSuchProfileException(key.getName());
+ }
+ Set<String> names = mappings.get(key);
+ for(String deploymentName : names)
+ {
+ actions.addAction(key, new DeploymentRemoveAction(managed, deploymentName, null));
+ }
+ }
+ ModificationStatus status = actionController.perform(actions);
+ if(status.isFailed())
+ {
+ throw new IllegalStateException("failed to remove deployments " + Arrays.asList(deploymentNames));
+ }
}
- protected void removeDeployment(String deploymentName) throws Exception
+ /**
+ * Resolve the profiles for the names.
+ *
+ * @param deploymentNames the deployment names
+ * @return the profile map
+ * @throws NoSuchDeploymentException
+ */
+ Map<ProfileKey, Set<String>> resolveProfiles(String[] deploymentNames, boolean checkMutable, boolean fail) throws NoSuchDeploymentException
{
- ProfileKey key = checkProfileForDeployment(deploymentName);
-
+ Map<ProfileKey, Set<String>> mapping = new HashMap<ProfileKey, Set<String>>();
+ for(String deploymentName : deploymentNames)
+ {
+ ProfileKey key = resolveProfileForDeployment(deploymentName, checkMutable, fail);
+ Set<String> names = mapping.get(key);
+ if(names == null)
+ {
+ names = new HashSet<String>();
+ mapping.put(key, names);
+ }
+ names.add(deploymentName);
+ }
+ return mapping;
}
- ProfileKey checkProfileForDeployment(String deploymentName) throws NoSuchDeploymentException
+ /**
+ * Resolve the profile for a given deployment
+ *
+ * @param deploymentName the deployment name
+ * @param checkMutableOnly check only mutable profiles
+ * @param fail fail if the deployment cannot be resolved
+ * @return the profile
+ * @throws NoSuchDeploymentException
+ */
+ ProfileKey resolveProfileForDeployment(String deploymentName, boolean checkMutableOnly, boolean fail) throws NoSuchDeploymentException
{
- ProfileKey key = deploymentRegistry.getProfileForDeployment(deploymentName);
- if(key == null)
+ for(ProfileKey key : actionController.getActiveProfiles())
{
- Collection<String> resolved = deploymentRegistry.resolveDeploymentName(deploymentName);
- if(resolved != null && resolved.size() == 1)
+ ManagedProfile managed = actionController.getManagedProfile(key);
+ if(managed == null)
{
- key = deploymentRegistry.getProfileForDeployment(resolved.iterator().next());
+ continue;
}
- else
+ Profile profile = managed.getProfile();
+ // only check mutable profiles
+ if(checkMutableOnly && profile.isMutable() == false)
{
- throw new NoSuchDeploymentException("failed to resolve deployment name " + deploymentName + " result " + resolved);
+ continue;
}
+ if(profile.hasDeployment(deploymentName))
+ {
+ return managed.getProfileKey();
+ }
}
- if(key == null)
+ if(fail)
{
throw new NoSuchDeploymentException(deploymentName);
}
- return key;
+ else
+ {
+ return null;
+ }
}
}
Added: projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/DeploymentConstants.java
===================================================================
--- projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/DeploymentConstants.java (rev 0)
+++ projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/DeploymentConstants.java 2010-03-15 12:49:17 UTC (rev 102402)
@@ -0,0 +1,36 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2010, Red Hat Inc., and individual contributors as indicated
+* 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.plugins.deploy;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class DeploymentConstants
+{
+
+ /** The deployment category. */
+ public static final String DEPLOYMENT_LOGGER_CATEGORY = "org.jboss.profileservice.deployment.action";
+
+
+}
+
Modified: projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/DeploymentManagerImpl.java
===================================================================
--- projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/DeploymentManagerImpl.java 2010-03-15 12:49:05 UTC (rev 102401)
+++ projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/DeploymentManagerImpl.java 2010-03-15 12:49:17 UTC (rev 102402)
@@ -21,12 +21,80 @@
*/
package org.jboss.profileservice.plugins.deploy;
+import java.net.URL;
+import java.util.Collection;
+
+import org.jboss.deployers.spi.management.deploy.DeploymentManager;
+import org.jboss.deployers.spi.management.deploy.DeploymentProgress;
+import org.jboss.profileservice.spi.DeploymentOption;
+import org.jboss.profileservice.spi.ProfileKey;
+
/**
* @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
* @version $Revision$
*/
-public class DeploymentManagerImpl
+public class DeploymentManagerImpl implements DeploymentManager
{
+ public DeploymentProgress distribute(String name, URL contentURL, boolean copyContent) throws Exception
+ {
+ // FIXME distribute
+ return null;
+ }
+
+ public DeploymentProgress distribute(String name, URL contentURL, DeploymentOption... options) throws Exception
+ {
+ // FIXME distribute
+ return null;
+ }
+
+ public Collection<ProfileKey> getProfiles()
+ {
+ // FIXME getProfiles
+ return null;
+ }
+
+ public String[] getRepositoryNames(String[] names) throws Exception
+ {
+ // FIXME getRepositoryNames
+ return null;
+ }
+
+ public boolean isRedeploySupported()
+ {
+ // FIXME isRedeploySupported
+ return false;
+ }
+
+ public DeploymentProgress prepare(String... names) throws Exception
+ {
+ // FIXME prepare
+ return null;
+ }
+
+ public DeploymentProgress redeploy(String name) throws Exception
+ {
+ // FIXME redeploy
+ return null;
+ }
+
+ public DeploymentProgress remove(String... names) throws Exception
+ {
+ // FIXME remove
+ return null;
+ }
+
+ public DeploymentProgress start(String... names) throws Exception
+ {
+ // FIXME start
+ return null;
+ }
+
+ public DeploymentProgress stop(String... names) throws Exception
+ {
+ // FIXME stop
+ return null;
+ }
+
}
Deleted: projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/FileDeploymentTarget.java
===================================================================
--- projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/FileDeploymentTarget.java 2010-03-15 12:49:05 UTC (rev 102401)
+++ projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/FileDeploymentTarget.java 2010-03-15 12:49:17 UTC (rev 102402)
@@ -1,199 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2010, Red Hat Inc., and individual contributors as indicated
-* 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.plugins.deploy;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.SyncFailedException;
-import java.util.Arrays;
-import java.util.List;
-
-import org.jboss.profileservice.plugins.deploy.spi.DeploymentTarget;
-import org.jboss.profileservice.profile.metadata.BasicProfileDeploymentMetaData;
-import org.jboss.profileservice.repository.artifact.CopyStreamArtifactTransformer;
-import org.jboss.profileservice.repository.artifact.ExplodedArtifactTransformer;
-import org.jboss.profileservice.repository.artifact.file.FileArtifactId;
-import org.jboss.profileservice.spi.DeploymentOption;
-import org.jboss.profileservice.spi.MutableProfile;
-import org.jboss.profileservice.spi.NoSuchDeploymentException;
-import org.jboss.profileservice.spi.Profile;
-import org.jboss.profileservice.spi.ProfileDeployment;
-import org.jboss.profileservice.spi.VirtualDeploymentRepository;
-import org.jboss.profileservice.spi.VirtualDeploymentRepositoryExt;
-import org.jboss.profileservice.spi.deployment.ProfileDeploymentFlag;
-import org.jboss.profileservice.spi.repository.ArtifactId;
-import org.jboss.profileservice.spi.repository.ArtifactRepository;
-import org.jboss.profileservice.spi.repository.ArtifactTransformer;
-import org.jboss.profileservice.spi.repository.MutableArtifactRepository;
-
-/**
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public class FileDeploymentTarget implements DeploymentTarget<FileArtifactId>
-{
-
- private MutableProfile profile;
- private VirtualDeploymentRepository deploymentRepository;
- private MutableArtifactRepository<FileArtifactId> artifactRepository;
-
- public FileDeploymentTarget(MutableProfile profile, VirtualDeploymentRepository deploymentRepository,
- MutableArtifactRepository<FileArtifactId> artifactRepository)
- {
- this.profile = profile;
- this.deploymentRepository = deploymentRepository;
- this.artifactRepository = artifactRepository;
- }
-
- public ProfileDeployment distributeContent(String name, InputStream contentIS, DeploymentOption[] options) throws Exception
- {
- // Get the content options
- List<DeploymentOption> deploymentOptions = Arrays.asList(options);
-
- // Create the file artifact id
- FileArtifactId artifactId = new FileArtifactId(name);
-
- // Check if the artifact is already there
- boolean failIfAlreadyExsists = deploymentOptions.contains(DeploymentOption.FailIfExists);
- if(failIfAlreadyExsists && artifactRepository.containsArtifact(artifactId))
- {
- throw new SyncFailedException("Deployment content already exists: "+ name);
- }
-
- // Check if we need unpack this deployment
- ArtifactTransformer<FileArtifactId> transformer = null;
- if(deploymentOptions.contains(DeploymentOption.Explode))
- {
- transformer = ExplodedArtifactTransformer.getInstance();
- }
- else
- {
- transformer = CopyStreamArtifactTransformer.getInstance();
- }
-
- // Create the deployment
- ProfileDeployment deployment = deploymentRepository.createDeployment(new BasicProfileDeploymentMetaData(name));
- // Mark it as locked, so we can add contents after
- deployment.getDeploymentInfo().setFlag(ProfileDeploymentFlag.LOCKED);
- // Add the deployment
- profile.addDeployment(deployment);
- // Add the content
- artifactRepository.addArtifact(artifactId, contentIS, transformer);
-
- return deployment;
- }
-
-
- public ProfileDeployment removeDeployment(String deploymentName) throws NoSuchDeploymentException, IOException, Exception
- {
- ProfileDeployment deployment = profile.getDeployment(deploymentName);
- deployment.getDeploymentInfo().setFlag(ProfileDeploymentFlag.LOCKED);
-
- FileArtifactId artifactId = getArtifactId(deployment);
- artifactRepository.removeArtifact(artifactId);
- profile.removeDeployment(deploymentName);
-
- return deployment;
- }
-
- //
-
- /**
- * Create the deployment target based on a profile.
- *
- * This will require the profile to be mutable, implement VirtualDeploymentRepsoitoryExt
- * and contain a MutableArtifactRepository<FileArtifactId>
- *
- * @return the deployment target
- */
- static FileDeploymentTarget createDeploymentTarget(Profile profile)
- {
- MutableProfile mutable = getMutableProfile(profile);
- VirtualDeploymentRepository vdr = getDeploymentRepository(mutable);
- MutableArtifactRepository<FileArtifactId> artifactRepository = resolveRepository(vdr);
- return new FileDeploymentTarget(mutable, vdr, artifactRepository);
- }
-
- /**
- * Cast to a mutable profile
- *
- * @param profile the profile
- * @return the mutable profile
- */
- static MutableProfile getMutableProfile(Profile profile)
- {
- if(profile.isMutable() == false || profile instanceof MutableProfile)
- {
- throw new IllegalStateException("failed to create deployment target for and immutable profile " + profile.getKey());
- }
- return MutableProfile.class.cast(profile);
- }
-
- /**
- * Cast to VirtualDeploymentRepositoryExt
- *
- * @param profile the mutable profile
- * @return the virtual deployment repository
- */
- static VirtualDeploymentRepository getDeploymentRepository(MutableProfile profile)
- {
- if(profile instanceof VirtualDeploymentRepositoryExt == false)
- {
- throw new IllegalStateException("");
- }
- return VirtualDeploymentRepositoryExt.class.cast(profile).getDeploymentRepository();
- }
-
- /**
- * Resolve and cast to mutable artifact repository
- *
- * @param deploymentRepository the virtual deployment repository
- * @return the mutable artifact repository
- */
- static MutableArtifactRepository<FileArtifactId> resolveRepository(VirtualDeploymentRepository deploymentRepository)
- {
- ArtifactRepository<FileArtifactId> repo = deploymentRepository.resolveArtifactRepository(FileArtifactId.EMPTY_ARTIFACT);
- if(repo instanceof MutableArtifactRepository<?> == false)
- {
- throw new IllegalStateException("no mutable artifact repository");
- }
- return MutableArtifactRepository.class.cast(repo);
- }
-
- /**
- * Get the FileArtifactId from a profile deployment
- *
- * @param deployment the profile deployment
- * @return the file artifact id
- */
- static FileArtifactId getArtifactId(ProfileDeployment deployment)
- {
- ArtifactId id =deployment.getDeploymentInfo().getMetaData().getArtifact();
- if(id instanceof FileArtifactId == false)
- {
- throw new IllegalStateException("failed to resolve artifact");
- }
- return FileArtifactId.class.cast(id);
- }
-
-}
-
Added: projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/TransientDeploymentMetaData.java
===================================================================
--- projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/TransientDeploymentMetaData.java (rev 0)
+++ projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/TransientDeploymentMetaData.java 2010-03-15 12:49:17 UTC (rev 102402)
@@ -0,0 +1,66 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2010, Red Hat Inc., and individual contributors as indicated
+* 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.plugins.deploy;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.jboss.profileservice.spi.repository.ArtifactId;
+import org.jboss.profileservice.spi.virtual.VirtualArtifactMetaData;
+import org.jboss.profileservice.spi.virtual.VirtualDeploymentMetaData;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class TransientDeploymentMetaData implements VirtualDeploymentMetaData
+{
+
+ final String name;
+
+ public TransientDeploymentMetaData(String name)
+ {
+ this.name = name;
+ }
+
+ public ArtifactId getArtifact()
+ {
+ return null;
+ }
+
+ public List<VirtualArtifactMetaData> getArtifacts()
+ {
+ return Collections.emptyList();
+ }
+
+ public List<VirtualDeploymentMetaData> getChildren()
+ {
+ return Collections.emptyList();
+ }
+
+ public String getName()
+ {
+ return this.name;
+ }
+
+}
+
Added: projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/TransientProfileActivator.java
===================================================================
--- projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/TransientProfileActivator.java (rev 0)
+++ projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/TransientProfileActivator.java 2010-03-15 12:49:17 UTC (rev 102402)
@@ -0,0 +1,176 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2010, Red Hat Inc., and individual contributors as indicated
+* 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.plugins.deploy;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.jboss.profileservice.profile.metadata.plugin.EmptyProfileMetaData;
+import org.jboss.profileservice.spi.ModificationInfo;
+import org.jboss.profileservice.spi.MutableProfile;
+import org.jboss.profileservice.spi.NoSuchDeploymentException;
+import org.jboss.profileservice.spi.Profile;
+import org.jboss.profileservice.spi.ProfileDeployment;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.ProfileService;
+
+/**
+ * The transient profile activator.
+ *
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class TransientProfileActivator
+{
+
+ /** The transient profile name. */
+ public static final ProfileKey TRANSIENT_PROFILE_KEY = new ProfileKey("transient-deployments");
+
+ /** The attachment name for the transient deployment url. */
+ public static final String TRANSIENT_DEPLOYMENT_URL_KEY = "deployment-url";
+
+ /** The profile service. */
+ private ProfileService ps;
+
+ public ProfileService getProfileService()
+ {
+ return this.ps;
+ }
+
+ public void setProfileService(ProfileService profileService)
+ {
+ this.ps = profileService;
+ }
+
+ public void start() throws Exception
+ {
+ Profile profile = new TransientDeploymentsProfile();
+ this.ps.registerProfile(new EmptyProfileMetaData(TRANSIENT_PROFILE_KEY.getName()), profile);
+ this.ps.activateProfile(TRANSIENT_PROFILE_KEY);
+ this.ps.validateProfile(TRANSIENT_PROFILE_KEY);
+ }
+
+ public void stop() throws Exception
+ {
+ this.ps.deactivateProfile(TRANSIENT_PROFILE_KEY);
+ this.ps.unregisterProfile(TRANSIENT_PROFILE_KEY);
+ }
+
+ public static class TransientDeploymentsProfile implements MutableProfile
+ {
+
+ private Map<String, ProfileDeployment> deployments = new ConcurrentHashMap<String, ProfileDeployment>();
+ private volatile long lastModified = System.currentTimeMillis();
+
+ public void addDeployment(ProfileDeployment deployment) throws Exception
+ {
+ this.deployments.put(deployment.getName(), deployment);
+ lastModified = System.currentTimeMillis();
+ }
+
+ public void enableModifiedDeploymentChecks(boolean flag)
+ {
+ //
+ }
+
+ public Collection<ModificationInfo> getModifiedDeployments() throws Exception
+ {
+ return Collections.emptySet();
+ }
+
+ public ProfileDeployment removeDeployment(String name) throws NoSuchDeploymentException, Exception
+ {
+ ProfileDeployment deployment = getDeployment(name);
+ lastModified = System.currentTimeMillis();
+ return this.deployments.remove(deployment.getName());
+ }
+
+ public ProfileDeployment getDeployment(String name) throws NoSuchDeploymentException
+ {
+ ProfileDeployment deployment = resolveDeployment(name);
+ if(deployment == null)
+ {
+ throw new NoSuchDeploymentException(name);
+ }
+ return deployment;
+ }
+
+ public Set<String> getDeploymentNames()
+ {
+ return this.deployments.keySet();
+ }
+
+ public Collection<ProfileDeployment> getDeployments()
+ {
+ return this.deployments.values();
+ }
+
+ public ProfileKey getKey()
+ {
+ return TRANSIENT_PROFILE_KEY;
+ }
+
+ public long getLastModified()
+ {
+ return lastModified;
+ }
+
+ public boolean hasDeployment(String name)
+ {
+ return resolveDeployment(name) != null ? true : false;
+ }
+
+ public boolean isMutable()
+ {
+ return true;
+ }
+
+ protected ProfileDeployment resolveDeployment(String name)
+ {
+ ProfileDeployment deployment = this.deployments.get(name);
+ if(deployment == null)
+ {
+ for(ProfileDeployment d : getDeployments())
+ {
+ String transientURL = d.getTransientAttachments().getAttachment(TRANSIENT_DEPLOYMENT_URL_KEY, String.class);
+ if(transientURL != null && transientURL.equals(name))
+ {
+ deployment = d;
+ break;
+ }
+ if(d.getSimpleName().equals(name))
+ {
+ deployment = d;
+ break;
+ }
+ }
+ }
+ return deployment;
+ }
+
+ }
+
+}
+
Added: projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/actions/AbstractDeploymentAddAction.java
===================================================================
--- projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/actions/AbstractDeploymentAddAction.java (rev 0)
+++ projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/actions/AbstractDeploymentAddAction.java 2010-03-15 12:49:17 UTC (rev 102402)
@@ -0,0 +1,70 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2010, Red Hat Inc., and individual contributors as indicated
+* 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.plugins.deploy.actions;
+
+import org.jboss.deployers.spi.management.deploy.DeploymentID;
+import org.jboss.logging.Logger;
+import org.jboss.profileservice.management.actions.AbstractTwoPhaseModificationAction;
+import org.jboss.profileservice.spi.MutableProfile;
+import org.jboss.profileservice.spi.action.ProfileModificationAction;
+import org.jboss.profileservice.spi.action.deployment.DeploymentActionContext;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public abstract class AbstractDeploymentAddAction extends AbstractTwoPhaseModificationAction<DeploymentActionContext>
+ implements ProfileModificationAction<DeploymentActionContext>
+{
+
+ static final Logger log = Logger.getLogger("org.jboss.profileservice.deployment.action");
+
+ /** The deployment id. */
+ private final DeploymentID dtID;
+
+ /** The mutable profile. */
+ private final MutableProfile profile;
+
+ public AbstractDeploymentAddAction(DeploymentID dtID, MutableProfile profile, DeploymentActionContext modificationContext)
+ {
+ super(modificationContext);
+ this.dtID = dtID;
+ this.profile = profile;
+ }
+
+ protected DeploymentID getDeploymentID()
+ {
+ return this.dtID;
+ }
+
+ protected String getDeploymentName()
+ {
+ return getDeploymentID().getNames()[0];
+ }
+
+ protected MutableProfile getProfile()
+ {
+ return this.profile;
+ }
+
+}
+
Added: projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/actions/AbstractDeploymentLifeCycleAction.java
===================================================================
--- projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/actions/AbstractDeploymentLifeCycleAction.java (rev 0)
+++ projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/actions/AbstractDeploymentLifeCycleAction.java 2010-03-15 12:49:17 UTC (rev 102402)
@@ -0,0 +1,142 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2010, Red Hat Inc., and individual contributors as indicated
+* 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.plugins.deploy.actions;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.jboss.logging.Logger;
+import org.jboss.profileservice.management.actions.AbstractTwoPhaseModificationAction;
+import org.jboss.profileservice.plugins.deploy.DeploymentConstants;
+import org.jboss.profileservice.spi.ProfileDeployment;
+import org.jboss.profileservice.spi.action.deployment.DeploymentAction;
+import org.jboss.profileservice.spi.action.deployment.DeploymentActionContext;
+import org.jboss.profileservice.spi.managed.ManagedProfile;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public abstract class AbstractDeploymentLifeCycleAction extends AbstractTwoPhaseModificationAction<DeploymentActionContext>
+ implements DeploymentAction<DeploymentActionContext>
+{
+
+ static final Logger log = Logger.getLogger(DeploymentConstants.DEPLOYMENT_LOGGER_CATEGORY);
+
+ private final Collection<String> deploymentNames;
+ private final ManagedProfile managed;
+ private final List<DeploymentState> deployments = new ArrayList<DeploymentState>();
+
+ public AbstractDeploymentLifeCycleAction(ManagedProfile managed, Collection<String> names, DeploymentActionContext modificationContext)
+ {
+ super(modificationContext);
+ this.deploymentNames = names;
+ this.managed = managed;
+ }
+
+ /**
+ * Add a deployment.
+ *
+ * @param deployment the deployment
+ * @return the deployment state
+ */
+ protected DeploymentState addDeployment(ProfileDeployment deployment)
+ {
+ DeploymentState state = new DeploymentState(deployment);
+ this.deployments.add(state);
+ return state;
+ }
+
+ public Collection<String> getDeploymentNames()
+ {
+ return deploymentNames;
+ }
+
+ /**
+ * Get the deployment states.
+ *
+ * @return the deployment states
+ */
+ protected List<DeploymentState> getDeployments()
+ {
+ return deployments;
+ }
+
+ /**
+ * Get the managed profile
+ *
+ * @return the profile
+ */
+ protected ManagedProfile getManagedProfile()
+ {
+ return managed;
+ }
+
+ /**
+ * Resolve the deployment names.
+ *
+ * @return the deployment names
+ */
+ protected String[] resolvedNames()
+ {
+ Set<String> set = new HashSet<String>();
+ for(DeploymentState state : deployments)
+ {
+ set.add(state.getName());
+ }
+ return set.toArray(new String[set.size()]);
+ }
+
+ static class DeploymentState
+ {
+
+ private final ProfileDeployment deployment;
+ private final boolean deployed;
+
+ public DeploymentState(ProfileDeployment deployment)
+ {
+ this.deployment = deployment;
+ this.deployed = deployment.getDeploymentInfo().isDeployed();
+ }
+
+ public ProfileDeployment getDeployment()
+ {
+ return deployment;
+ }
+
+ public String getName()
+ {
+ return this.deployment.getName();
+ }
+
+ public boolean isDeployed()
+ {
+ return deployed;
+ }
+
+ }
+
+}
+
Added: projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/actions/DeploymentAddAction.java
===================================================================
--- projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/actions/DeploymentAddAction.java (rev 0)
+++ projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/actions/DeploymentAddAction.java 2010-03-15 12:49:17 UTC (rev 102402)
@@ -0,0 +1,135 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2010, Red Hat Inc., and individual contributors as indicated
+* 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.plugins.deploy.actions;
+
+import java.net.URL;
+
+import org.jboss.deployers.spi.management.deploy.DeploymentID;
+import org.jboss.profileservice.plugins.deploy.TransientDeploymentMetaData;
+import org.jboss.profileservice.plugins.deploy.TransientProfileActivator;
+import org.jboss.profileservice.repository.ProfileDeploymentFactory;
+import org.jboss.profileservice.spi.MutableProfile;
+import org.jboss.profileservice.spi.ProfileDeployment;
+import org.jboss.profileservice.spi.action.deployment.DeploymentAction;
+import org.jboss.profileservice.spi.action.deployment.DeploymentActionContext;
+import org.jboss.profileservice.spi.deployment.ProfileDeploymentFlag;
+import org.jboss.vfs.VFS;
+import org.jboss.vfs.VirtualFile;
+
+/**
+ * Add a deployment to a profile. This action only targets to add transient deployments, which is handled
+ * by the profile created through the {@code TransientProfileActivator}. This profile does not provide any
+ * persistence, so references to deployments will be lost after a restart.
+ *
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class DeploymentAddAction extends AbstractDeploymentAddAction implements DeploymentAction<DeploymentActionContext>
+{
+
+ /** The {@code ProfileDeployment} factory. */
+ private static final ProfileDeploymentFactory deploymentFactory = ProfileDeploymentFactory.getInstance();
+
+ public DeploymentAddAction(DeploymentID dtID, MutableProfile profile, DeploymentActionContext modificationContext)
+ {
+ super(dtID, profile, modificationContext);
+ }
+
+ protected void doCancel()
+ {
+ //
+ }
+
+ protected void doCommit()
+ {
+ //
+ }
+
+ protected void doComplete() throws Exception
+ {
+ //
+ }
+
+ protected boolean doPrepare()
+ {
+ try
+ {
+ final String name = getDeploymentName();
+ final URL url = getDeploymentID().getContentURL();
+ if(url == null)
+ {
+ return false;
+ }
+ //
+ final VirtualFile vf = VFS.getChild(url);
+ // Create the deployment directly
+ final ProfileDeployment deployment = deploymentFactory.createDeployment(vf, new TransientDeploymentMetaData(name));
+ deployment.getDeploymentInfo().setFlag(ProfileDeploymentFlag.LOCKED);
+ // Attach original deployment url for resolving deployment names
+ deployment.getTransientAttachments().putAttachment(TransientProfileActivator.TRANSIENT_DEPLOYMENT_URL_KEY, url.toExternalForm());
+ getProfile().addDeployment(deployment);
+ }
+ catch(Exception e)
+ {
+ return false;
+ }
+ return true;
+ }
+
+ protected void doRollbackFromActive()
+ {
+ //
+ }
+
+ protected void doRollbackFromCancelled()
+ {
+ //
+ }
+
+ protected void doRollbackFromComplete()
+ {
+ //
+ }
+
+ protected void doRollbackFromPrepared()
+ {
+ final String name = getDeploymentName();
+ if(getProfile().hasDeployment(name))
+ {
+ try
+ {
+ getProfile().removeDeployment(name);
+ }
+ catch(Exception e)
+ {
+ log.error("failed to rollback changes " + name);
+ }
+ }
+ }
+
+ protected void doRollbackFromRollbackOnly()
+ {
+ //
+ }
+
+}
+
Modified: projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/actions/DeploymentDistributeAction.java
===================================================================
--- projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/actions/DeploymentDistributeAction.java 2010-03-15 12:49:05 UTC (rev 102401)
+++ projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/actions/DeploymentDistributeAction.java 2010-03-15 12:49:17 UTC (rev 102402)
@@ -22,17 +22,22 @@
package org.jboss.profileservice.plugins.deploy.actions;
import java.io.InputStream;
+import java.io.SyncFailedException;
+import java.util.Arrays;
-import org.jboss.logging.Logger;
+import org.jboss.deployers.spi.management.deploy.DeploymentID;
import org.jboss.profileservice.profile.metadata.BasicProfileDeploymentMetaData;
import org.jboss.profileservice.repository.artifact.CopyStreamArtifactTransformer;
+import org.jboss.profileservice.repository.artifact.ExplodedArtifactTransformer;
import org.jboss.profileservice.repository.artifact.file.FileArtifactId;
+import org.jboss.profileservice.spi.DeploymentOption;
import org.jboss.profileservice.spi.MutableProfile;
-import org.jboss.profileservice.spi.Profile;
import org.jboss.profileservice.spi.ProfileDeployment;
import org.jboss.profileservice.spi.VirtualDeploymentRepository;
+import org.jboss.profileservice.spi.VirtualDeploymentRepositoryExt;
+import org.jboss.profileservice.spi.action.deployment.DeploymentAction;
+import org.jboss.profileservice.spi.action.deployment.DeploymentActionContext;
import org.jboss.profileservice.spi.deployment.ProfileDeploymentFlag;
-import org.jboss.profileservice.spi.repository.ArtifactId;
import org.jboss.profileservice.spi.repository.ArtifactRepository;
import org.jboss.profileservice.spi.repository.ArtifactTransformer;
import org.jboss.profileservice.spi.repository.MutableArtifactRepository;
@@ -42,68 +47,171 @@
* @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
* @version $Revision$
*/
-public abstract class DeploymentDistributeAction
+public class DeploymentDistributeAction extends AbstractDeploymentAddAction implements DeploymentAction<DeploymentActionContext>
{
- private static final Logger log = Logger.getLogger("org.jboss.profileservice.deployment.action");
- private static final ArtifactId noopArtifactId = FileArtifactId.EMPTY_ARTIFACT;
+ private static final FileArtifactId noopArtifactId = FileArtifactId.EMPTY_ARTIFACT;
+
+ private final InputStream contentIS;
- abstract String getDeploymentName();
- abstract InputStream getDeploymentInputStream();
- abstract Profile getProfile();
- abstract VirtualDeploymentRepository getVirtualDeploymentRepository();
- abstract boolean isExplode();
+ public DeploymentDistributeAction(MutableProfile profile, DeploymentID dtId, InputStream is, DeploymentActionContext modificationContext)
+ {
+ super(dtId, profile, modificationContext);
+ this.contentIS = is;
+ }
- protected boolean prepare()
+ protected boolean doPrepare()
{
- if(getProfile().isMutable() == false)
- {
- return false;
- }
- ArtifactRepository<ArtifactId> artifactRepository = getVirtualDeploymentRepository().resolveArtifactRepository(noopArtifactId);
- if(artifactRepository == null || artifactRepository.getConfiguration().isMutable() == false)
- {
- return false;
- }
- // Create the artifact based on the deployment name
- String artifactName = getDeploymentName();
- FileArtifactId artifactId = new FileArtifactId(getDeploymentName());
- // We need a mutable repository
- MutableArtifactRepository<ArtifactId> mutable = MutableArtifactRepository.class.cast(artifactRepository);
- // Create the transformer
- ArtifactTransformer<ArtifactId> transformer = createTransformer();
-
try
{
- // Add IS
- mutable.addArtifact(artifactId, getDeploymentInputStream(), transformer);
- // Assemble
- ProfileDeployment deployment = getVirtualDeploymentRepository().createDeployment(new BasicProfileDeploymentMetaData(artifactName));
- // Lock hd-scanning
+ VirtualDeploymentRepository deploymentRepository = resolveDeploymentRepository(getProfile());
+ if(deploymentRepository == null)
+ {
+ return false;
+ }
+ String deploymentName = getDeploymentName();
+ MutableArtifactRepository<FileArtifactId> artifactRepository = resolveRepository(deploymentRepository);
+ // Create the artifact based on the deployment name
+ String artifactName = deploymentName;
+ FileArtifactId artifactId = new FileArtifactId(artifactName);
+
+ // Check if the artifact is already there
+ if(isFailIfExists() && artifactRepository.containsArtifact(artifactId))
+ {
+ throw new SyncFailedException("Deployment content already exists: "+ artifactName);
+ }
+ // Check if we need unpack this deployment
+ ArtifactTransformer<FileArtifactId> transformer = null;
+ if(isExplode())
+ {
+ transformer = ExplodedArtifactTransformer.getInstance();
+ }
+ else
+ {
+ transformer = CopyStreamArtifactTransformer.getInstance();
+ }
+
+ // Create the deployment
+ ProfileDeployment deployment = deploymentRepository.createDeployment(new BasicProfileDeploymentMetaData(artifactName));
+ // Mark it as locked, so we can add contents after
deployment.getDeploymentInfo().setFlag(ProfileDeploymentFlag.LOCKED);
- // Add deployment
- MutableProfile m = MutableProfile.class.cast(getProfile());
- m.addDeployment(deployment);
+ // Add the deployment
+ getProfile().addDeployment(deployment);
+ // Add the content
+ artifactRepository.addArtifact(artifactId, contentIS, transformer);
+
}
catch(Exception e)
{
- log.warn("failed to distribute content.", e);
+ // TODO Error reporting
+ log.error("failed to distribute deployment content", e);
return false;
}
return true;
}
- protected ArtifactTransformer<ArtifactId> createTransformer()
+ protected ArtifactTransformer<FileArtifactId> createTransformer()
{
if(isExplode())
{
- return CopyStreamArtifactTransformer.getInstance();
+ return ExplodedArtifactTransformer.getInstance();
}
else
{
return CopyStreamArtifactTransformer.getInstance();
}
}
+
+ protected void doCancel()
+ {
+ // FIXME doCancel
+
+ }
+ protected void doCommit()
+ {
+ // FIXME doCommit
+
+ }
+ protected void doComplete() throws Exception
+ {
+ // FIXME doComplete
+
+ }
+ protected void doRollbackFromCancelled()
+ {
+ // FIXME doRollbackFromCancelled
+
+ }
+ protected void doRollbackFromComplete()
+ {
+ // FIXME doRollbackFromComplete
+
+ }
+ protected void doRollbackFromActive()
+ {
+ // FIXME doRollbackFromOpen
+
+ }
+ protected void doRollbackFromPrepared()
+ {
+ // FIXME doRollbackFromPrepared
+
+ }
+ protected void doRollbackFromRollbackOnly()
+ {
+ // FIXME doRollbackFromRollbackOnly
+
+ }
+ protected boolean isExplode()
+ {
+ return hasDeploymentOption(DeploymentOption.Explode);
+ }
+
+ protected boolean isFailIfExists()
+ {
+ return hasDeploymentOption(DeploymentOption.FailIfExists);
+ }
+
+ protected boolean hasDeploymentOption(DeploymentOption option)
+ {
+ if(getDeploymentID().getDeploymentOptions() != null)
+ {
+ return Arrays.binarySearch(getDeploymentID().getDeploymentOptions(), option) != -1;
+ }
+ return false;
+ }
+
+ /**
+ * Cast to VirtualDeploymentRepositoryExt
+ *
+ * @param profile the mutable profile
+ * @return the virtual deployment repository
+ */
+ static VirtualDeploymentRepository resolveDeploymentRepository(MutableProfile profile)
+ {
+ if(profile instanceof VirtualDeploymentRepositoryExt == false)
+ {
+ throw new IllegalStateException("Failed to get the deployment repository for profile " + profile.getKey());
+ }
+ return VirtualDeploymentRepositoryExt.class.cast(profile).getDeploymentRepository();
+ }
+
+ /**
+ * Resolve and cast to mutable artifact repository
+ *
+ * @param deploymentRepository the virtual deployment repository
+ * @return the mutable artifact repository
+ */
+ static MutableArtifactRepository<FileArtifactId> resolveRepository(VirtualDeploymentRepository deploymentRepository)
+ {
+ ArtifactRepository<FileArtifactId> repo = deploymentRepository.resolveArtifactRepository(noopArtifactId);
+ if(repo instanceof MutableArtifactRepository<?> == false)
+ {
+ throw new IllegalStateException("no mutable artifact repository");
+ }
+ return MutableArtifactRepository.class.cast(repo);
+ }
+
}
Added: projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/actions/DeploymentRemoveAction.java
===================================================================
--- projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/actions/DeploymentRemoveAction.java (rev 0)
+++ projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/actions/DeploymentRemoveAction.java 2010-03-15 12:49:17 UTC (rev 102402)
@@ -0,0 +1,161 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2010, Red Hat Inc., and individual contributors as indicated
+* 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.plugins.deploy.actions;
+
+import org.jboss.profileservice.management.actions.AbstractTwoPhaseModificationAction;
+import org.jboss.profileservice.spi.MutableProfile;
+import org.jboss.profileservice.spi.ProfileDeployment;
+import org.jboss.profileservice.spi.VirtualDeploymentRepository;
+import org.jboss.profileservice.spi.VirtualDeploymentRepositoryExt;
+import org.jboss.profileservice.spi.action.deployment.DeploymentAction;
+import org.jboss.profileservice.spi.action.deployment.DeploymentActionContext;
+import org.jboss.profileservice.spi.managed.ManagedProfile;
+import org.jboss.profileservice.spi.repository.ArtifactId;
+import org.jboss.profileservice.spi.repository.ArtifactRepository;
+import org.jboss.profileservice.spi.repository.MutableArtifactRepository;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class DeploymentRemoveAction extends AbstractTwoPhaseModificationAction<DeploymentActionContext>
+ implements DeploymentAction<DeploymentActionContext>
+{
+
+ private String deploymentName;
+ private ManagedProfile managed;
+
+ public DeploymentRemoveAction(ManagedProfile managed, String deploymentName,
+ DeploymentActionContext modificationContext)
+ {
+ super(modificationContext);
+ this.managed = managed;
+ this.deploymentName = deploymentName;
+ }
+
+ protected void doCancel()
+ {
+ // FIXME doCancel
+ }
+
+ protected void doCommit()
+ {
+ // FIXME doCommit
+ }
+
+ protected void doComplete() throws Exception
+ {
+ // FIXME doComplete
+ }
+
+ protected boolean doPrepare()
+ {
+ try
+ {
+ if(managed.getProfile().isMutable() == false || managed.getProfile() instanceof MutableProfile == false)
+ {
+ return false;
+ }
+ final MutableProfile profile = MutableProfile.class.cast(managed.getProfile());
+ final ProfileDeployment deployment = profile.getDeployment(deploymentName);
+
+ final ArtifactId artifactId = resolveArtifactMetaData(deployment);
+ // In case there is no artifact we just remove it from the profile
+ if(artifactId != null)
+ {
+ MutableArtifactRepository<ArtifactId> repository = resolveArtifactRepository(profile, deployment);
+ if(repository != null)
+ {
+ repository.removeArtifact(artifactId);
+ }
+ }
+ // Remove the deployment from the profile
+ profile.removeDeployment(deployment.getName());
+ }
+ catch(Exception e)
+ {
+ return false;
+ }
+ return true;
+ }
+
+ protected void doRollbackFromActive()
+ {
+ // FIXME doRollbackFromActive
+ }
+
+ protected void doRollbackFromCancelled()
+ {
+ // FIXME doRollbackFromCancelled
+ }
+
+ protected void doRollbackFromComplete()
+ {
+ // FIXME doRollbackFromComplete
+ }
+
+ protected void doRollbackFromPrepared()
+ {
+ // FIXME doRollbackFromPrepared
+ }
+
+ protected void doRollbackFromRollbackOnly()
+ {
+ // FIXME doRollbackFromRollbackOnly
+ }
+
+ MutableArtifactRepository<ArtifactId> resolveArtifactRepository(MutableProfile profile, ProfileDeployment deployment)
+ {
+ VirtualDeploymentRepository deploymentRepository = resolveVirtualDeploymentRepository(profile);
+ if(deploymentRepository == null)
+ {
+ return null;
+ }
+ ArtifactId artifactId = resolveArtifactMetaData(deployment);
+ if(artifactId == null)
+ {
+ return null;
+ }
+ ArtifactRepository<ArtifactId> repository = deploymentRepository.resolveArtifactRepository(artifactId);
+ if(repository != null && repository instanceof MutableArtifactRepository<?>)
+ {
+ return MutableArtifactRepository.class.cast(repository);
+ }
+ return null;
+ }
+
+ VirtualDeploymentRepository resolveVirtualDeploymentRepository(MutableProfile profile)
+ {
+ if(profile instanceof VirtualDeploymentRepositoryExt)
+ {
+ return VirtualDeploymentRepositoryExt.class.cast(profile).getDeploymentRepository();
+ }
+ return null;
+ }
+
+ ArtifactId resolveArtifactMetaData(ProfileDeployment deployment)
+ {
+ return deployment.getDeploymentInfo().getMetaData().getArtifact();
+ }
+
+}
+
Added: projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/actions/DeploymentStartAction.java
===================================================================
--- projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/actions/DeploymentStartAction.java (rev 0)
+++ projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/actions/DeploymentStartAction.java 2010-03-15 12:49:17 UTC (rev 102402)
@@ -0,0 +1,155 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2010, Red Hat Inc., and individual contributors as indicated
+* 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.plugins.deploy.actions;
+
+
+import java.util.Collection;
+
+import org.jboss.profileservice.spi.Profile;
+import org.jboss.profileservice.spi.ProfileDeployment;
+import org.jboss.profileservice.spi.action.deployment.DeploymentAction;
+import org.jboss.profileservice.spi.action.deployment.DeploymentActionContext;
+import org.jboss.profileservice.spi.deployment.ProfileDeploymentFlag;
+import org.jboss.profileservice.spi.deployment.ProfileDeploymentInfo;
+import org.jboss.profileservice.spi.managed.ManagedProfile;
+import org.jboss.profileservice.spi.managed.ManagedProfileDeployer;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class DeploymentStartAction extends AbstractDeploymentLifeCycleAction implements DeploymentAction<DeploymentActionContext>
+{
+
+ public DeploymentStartAction(ManagedProfile managed, Collection<String> names, DeploymentActionContext modificationContext)
+ {
+ super(managed, names, modificationContext);
+ }
+
+ protected void doCancel()
+ {
+ //
+ }
+
+ protected void doCommit()
+ {
+ for(DeploymentState state : getDeployments())
+ {
+ ProfileDeploymentInfo info = state.getDeployment().getDeploymentInfo();
+ // Mark as deployed
+ info.setFlag(ProfileDeploymentFlag.DEPLOYED);
+ // Clear locked and enable hot-deployment scans
+ info.clearFlag(ProfileDeploymentFlag.LOCKED);
+ }
+ }
+
+ protected void doComplete() throws Exception
+ {
+ //
+ }
+
+ protected boolean doPrepare()
+ {
+ try
+ {
+ final Profile profile = getManagedProfile().getProfile();
+ final ManagedProfileDeployer deployer = getManagedProfile().getManagedDeployer();
+ for(String deploymentName : getDeploymentNames())
+ {
+ ProfileDeployment deployment = profile.getDeployment(deploymentName);
+ ProfileDeploymentInfo info = deployment.getDeploymentInfo();
+ if(info.isDeployed())
+ {
+ // TODO
+ if(log.isTraceEnabled())
+ {
+ log.debugf("marking deployment (%1s) to redeploy ", deployment.getName());
+ }
+ }
+ // Add to deployer
+ deployer.addDeployment(deployment);
+ // Add to the deployment list
+ addDeployment(deployment);
+ }
+
+ // Process
+ deployer.process();
+
+ // Check complete
+ deployer.checkComplete(resolvedNames());
+
+
+ }
+ catch(Exception e)
+ {
+ // ERROR reporting
+ log.error("failed to start deployments: " + getDeploymentNames(), e);
+ }
+ return true;
+ }
+
+ protected void doRollbackFromCancelled()
+ {
+ //
+ }
+
+ protected void doRollbackFromComplete()
+ {
+ //
+ }
+
+ protected void doRollbackFromActive()
+ {
+ //
+ }
+
+ protected void doRollbackFromPrepared()
+ {
+ final ManagedProfileDeployer deployer = getManagedProfile().getManagedDeployer();
+ for(DeploymentState state : getDeployments())
+ {
+ // If the deployment was undeployed before restore the state
+ if(state.isDeployed() == false)
+ {
+ try
+ {
+ deployer.removeDeployment(state.getDeployment());
+ }
+ catch(Exception e)
+ {
+ log.debugf("failed to move deployment (%1s) back to it's original state", state.getName());
+ }
+ }
+ }
+ // Process
+ deployer.process();
+
+ // deployer.checkComplete(resolvedNames());
+ }
+
+ protected void doRollbackFromRollbackOnly()
+ {
+ // FIXME
+ }
+
+}
+
Added: projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/actions/DeploymentStopAction.java
===================================================================
--- projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/actions/DeploymentStopAction.java (rev 0)
+++ projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/deploy/actions/DeploymentStopAction.java 2010-03-15 12:49:17 UTC (rev 102402)
@@ -0,0 +1,127 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2010, Red Hat Inc., and individual contributors as indicated
+* 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.plugins.deploy.actions;
+
+import java.util.Collection;
+
+import org.jboss.profileservice.spi.Profile;
+import org.jboss.profileservice.spi.ProfileDeployment;
+import org.jboss.profileservice.spi.action.deployment.DeploymentAction;
+import org.jboss.profileservice.spi.action.deployment.DeploymentActionContext;
+import org.jboss.profileservice.spi.deployment.ProfileDeploymentFlag;
+import org.jboss.profileservice.spi.deployment.ProfileDeploymentInfo;
+import org.jboss.profileservice.spi.managed.ManagedProfile;
+import org.jboss.profileservice.spi.managed.ManagedProfileDeployer;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class DeploymentStopAction extends AbstractDeploymentLifeCycleAction implements DeploymentAction<DeploymentActionContext>
+{
+
+ public DeploymentStopAction(ManagedProfile managed, Collection<String> names,
+ DeploymentActionContext modificationContext)
+ {
+ super(managed, names, modificationContext);
+ }
+
+ protected void doCancel()
+ {
+ //
+ }
+
+ protected void doCommit()
+ {
+ for(DeploymentState state : getDeployments())
+ {
+ ProfileDeploymentInfo info = state.getDeployment().getDeploymentInfo();
+ // Mark as undeployed
+ info.clearFlag(ProfileDeploymentFlag.DEPLOYED);
+ }
+ }
+
+ protected void doComplete() throws Exception
+ {
+ //
+ }
+
+ protected boolean doPrepare()
+ {
+ try
+ {
+ final Profile profile = getManagedProfile().getProfile();
+ final ManagedProfileDeployer deployer = getManagedProfile().getManagedDeployer();
+ for(String deploymentName : getDeploymentNames())
+ {
+ ProfileDeployment deployment = profile.getDeployment(deploymentName);
+ ProfileDeploymentInfo info = deployment.getDeploymentInfo();
+ info.setFlag(ProfileDeploymentFlag.LOCKED);
+ // If it's already stopped ignore
+ if(info.isDeployed() == false)
+ {
+ continue;
+ }
+ // Add to deployer
+ deployer.removeDeployment(deployment);
+ // Add to the deployment list
+ addDeployment(deployment);
+ }
+
+ // Process
+ deployer.process();
+ }
+ catch(Exception e)
+ {
+ // ERROR reporting
+ log.error("failed to start deployments: " + getDeploymentNames(), e);
+ }
+ return true;
+ }
+
+ protected void doRollbackFromActive()
+ {
+ //
+ }
+
+ protected void doRollbackFromCancelled()
+ {
+ //
+ }
+
+ protected void doRollbackFromComplete()
+ {
+ //
+ }
+
+ protected void doRollbackFromPrepared()
+ {
+ // FIXME, do we have to start that stuff again ?
+ }
+
+ protected void doRollbackFromRollbackOnly()
+ {
+ // FIXME
+ }
+
+}
+
Modified: projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/RegisteredProfileViewsWrapper.java
===================================================================
--- projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/RegisteredProfileViewsWrapper.java 2010-03-15 12:49:05 UTC (rev 102401)
+++ projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/RegisteredProfileViewsWrapper.java 2010-03-15 12:49:17 UTC (rev 102402)
@@ -35,7 +35,6 @@
import org.jboss.managed.api.ComponentType;
import org.jboss.managed.api.ManagedComponent;
import org.jboss.managed.api.ManagedDeployment;
-import org.jboss.profileservice.management.actions.BasicProfileModificationActions;
import org.jboss.profileservice.plugins.management.actions.ProfileViewUpdateAction;
import org.jboss.profileservice.plugins.management.util.ManagedDeploymentProcessorHelper;
import org.jboss.profileservice.plugins.management.view.RegisteredProfileView;
@@ -114,7 +113,7 @@
ManagedProfile managedProfile = controller.getManagedProfile(key);
ProfileModificationAction<ProfileModificationContext> action = new ProfileViewUpdateAction(managedProfile, view, helper);
- controller.perfom(key, new BasicProfileModificationActions<ProfileModificationContext>(ProfileModificationType.GET, Collections.singletonList(action)));
+ controller.perform(key, ProfileModificationType.GET, Collections.singletonList(action));
changed = true;
}
Modified: projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/util/ManagedDeploymentProcessorHelper.java
===================================================================
--- projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/util/ManagedDeploymentProcessorHelper.java 2010-03-15 12:49:05 UTC (rev 102401)
+++ projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/util/ManagedDeploymentProcessorHelper.java 2010-03-15 12:49:17 UTC (rev 102402)
@@ -80,6 +80,19 @@
}
/**
+ * Process a root managed deployment.
+ *
+ * @param md the managed deployment
+ * @param state the deployment state
+ * @param context the profile view context
+ * @throws Exception
+ */
+ public void processRootManagedDeployment(ManagedDeployment md, DeploymentState state, ProfileViewProcessingContext context) throws Exception
+ {
+ processManagedDeployment(md, state, 0, context);
+ }
+
+ /**
* Process a managed deployment.
*
* @param md the managed deployment
Added: projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/deploy/support/DeployHandlerSupport.java
===================================================================
--- projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/deploy/support/DeployHandlerSupport.java (rev 0)
+++ projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/deploy/support/DeployHandlerSupport.java 2010-03-15 12:49:17 UTC (rev 102402)
@@ -0,0 +1,70 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2010, Red Hat Inc., and individual contributors as indicated
+* 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.plugins.deploy.support;
+
+import java.net.URL;
+import java.util.Collection;
+import java.util.HashSet;
+
+import org.jboss.deployers.spi.management.deploy.DeploymentID;
+import org.jboss.profileservice.plugins.deploy.AbstractDeployHandler;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class DeployHandlerSupport extends AbstractDeployHandler
+{
+
+ public void addDeployment(URL url)
+ {
+ DeploymentID id = new DeploymentIDSupport(url, url.getFile());
+ super.addDeployment(id, null);
+ }
+
+ public void startDeployment(URL... urls) throws Exception
+ {
+ super.startDeployments(getNames(urls));
+ }
+
+ public void stopDeployments(URL... urls) throws Exception
+ {
+ super.stopDeployments(getNames(urls));
+ }
+
+ public void removeDeployments(URL... urls) throws Exception
+ {
+ super.removeDeployments(getNames(urls));
+ }
+
+ protected String[] getNames(URL... urls)
+ {
+ Collection<String> names = new HashSet<String>(urls.length);
+ for(URL url : urls)
+ {
+ names.add(url.toExternalForm());
+ }
+ return names.toArray(new String[urls.length]);
+ }
+
+}
+
Added: projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/deploy/support/DeploymentIDSupport.java
===================================================================
--- projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/deploy/support/DeploymentIDSupport.java (rev 0)
+++ projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/deploy/support/DeploymentIDSupport.java 2010-03-15 12:49:17 UTC (rev 102402)
@@ -0,0 +1,102 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2010, Red Hat Inc., and individual contributors as indicated
+* 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.plugins.deploy.support;
+
+import java.net.URL;
+
+import org.jboss.deployers.spi.management.deploy.DeploymentID;
+import org.jboss.profileservice.spi.DeploymentOption;
+import org.jboss.profileservice.spi.ProfileKey;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class DeploymentIDSupport implements DeploymentID
+{
+
+ private URL url;
+ private String name;
+
+ public DeploymentIDSupport(URL url, String name)
+ {
+ super();
+ this.url = url;
+ this.name = name;
+ }
+
+ public URL getContentURL()
+ {
+ return url;
+ }
+
+ public String getDescription()
+ {
+ return null;
+ }
+
+ public String[] getNames()
+ {
+ return new String[] {name};
+ }
+
+ public ProfileKey getProfile()
+ {
+ return null;
+ }
+
+ public String[] getRepositoryNames()
+ {
+ return null;
+ }
+
+ public boolean isCopyContent()
+ {
+ return false;
+ }
+
+ public void setRepositoryNames(String[] names)
+ {
+
+ }
+
+ public void addDeploymentOption(DeploymentOption option)
+ {
+
+ }
+
+ public DeploymentOption[] getDeploymentOptions()
+ {
+ return null;
+ }
+
+ public boolean hasDeploymentOption(DeploymentOption option)
+ {
+ return false;
+ }
+
+ public boolean removeDeploymentOption(DeploymentOption option)
+ {
+ return false;
+ }
+
+}
Added: projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/deploy/support/ManagedProfileSupport.java
===================================================================
--- projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/deploy/support/ManagedProfileSupport.java (rev 0)
+++ projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/deploy/support/ManagedProfileSupport.java 2010-03-15 12:49:17 UTC (rev 102402)
@@ -0,0 +1,75 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2010, Red Hat Inc., and individual contributors as indicated
+* 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.plugins.deploy.support;
+
+import org.jboss.managed.api.ManagedDeployment;
+import org.jboss.profileservice.spi.Profile;
+import org.jboss.profileservice.spi.ProfileDeployment;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.managed.ManagedProfile;
+import org.jboss.profileservice.spi.managed.ManagedProfileDeployer;
+import org.jboss.profileservice.spi.metadata.ProfileMetaData;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class ManagedProfileSupport implements ManagedProfile
+{
+
+ Profile profile;
+ ProfileDeployerSupport deployer;
+
+ public ManagedProfileSupport(Profile profile, ProfileDeployerSupport deployer)
+ {
+ super();
+ this.profile = profile;
+ this.deployer = deployer;
+ }
+
+ public ManagedProfileDeployer getManagedDeployer()
+ {
+ return deployer;
+ }
+
+ public ManagedDeployment getManagedDeployment(ProfileDeployment deployment) throws Exception
+ {
+ return deployer.getManagedDeployment(deployment);
+ }
+
+ public Profile getProfile()
+ {
+ return profile;
+ }
+
+ public ProfileKey getProfileKey()
+ {
+ return profile.getKey();
+ }
+
+ public ProfileMetaData getProfileMetaData()
+ {
+ return null;
+ }
+
+}
+
Added: projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/deploy/support/ProfileDeployerSupport.java
===================================================================
--- projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/deploy/support/ProfileDeployerSupport.java (rev 0)
+++ projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/deploy/support/ProfileDeployerSupport.java 2010-03-15 12:49:17 UTC (rev 102402)
@@ -0,0 +1,73 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2010, Red Hat Inc., and individual contributors as indicated
+* 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.plugins.deploy.support;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.managed.api.ManagedDeployment;
+import org.jboss.managed.plugins.ManagedDeploymentImpl;
+import org.jboss.profileservice.spi.ProfileDeployment;
+import org.jboss.profileservice.spi.managed.ManagedProfileDeployer;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class ProfileDeployerSupport implements ManagedProfileDeployer
+{
+
+ /** The deployments. */
+ private Map<String, ProfileDeployment> deployments = new HashMap<String, ProfileDeployment>();
+
+ public void addDeployment(ProfileDeployment deployment) throws Exception
+ {
+ this.deployments.put(deployment.getName(), deployment);
+ }
+
+ public void checkComplete(String... names) throws Exception
+ {
+
+ }
+
+ public void process()
+ {
+
+ }
+
+ public boolean hasDeployment(String name)
+ {
+ return this.deployments.containsKey(name);
+ }
+
+ public void removeDeployment(ProfileDeployment deployment) throws Exception
+ {
+ this.deployments.remove(deployment.getName());
+ }
+
+ public ManagedDeployment getManagedDeployment(ProfileDeployment deployment)
+ {
+ return new ManagedDeploymentImpl(deployment.getName(), deployment.getSimpleName());
+ }
+
+}
+
Added: projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/deploy/test/AbstractDeployTest.java
===================================================================
--- projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/deploy/test/AbstractDeployTest.java (rev 0)
+++ projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/deploy/test/AbstractDeployTest.java 2010-03-15 12:49:17 UTC (rev 102402)
@@ -0,0 +1,92 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2010, Red Hat Inc., and individual contributors as indicated
+* 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.plugins.deploy.test;
+
+import org.jboss.profileservice.management.AbstractActionController;
+import org.jboss.profileservice.plugins.management.RegisteredProfileViewsWrapper;
+import org.jboss.profileservice.plugins.management.util.ManagedDeploymentProcessorHelper;
+import org.jboss.profileservice.plugins.spi.ProfileView;
+import org.jboss.profileservice.plugins.spi.ProfileViewWrapper;
+import org.jboss.test.BaseTestCase;
+import org.jboss.test.profileservice.plugins.deploy.support.DeployHandlerSupport;
+import org.jboss.test.profileservice.plugins.deploy.support.ProfileDeployerSupport;
+import org.jboss.test.profileservice.plugins.mgt.support.NoopManagementProxyFactory;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class AbstractDeployTest extends BaseTestCase
+{
+
+ private AbstractActionController actionController;
+ private ProfileDeployerSupport deployer;
+ private DeployHandlerSupport deployHandler;
+
+ private static final NoopManagementProxyFactory proxyFactory = new NoopManagementProxyFactory();
+ private ManagedDeploymentProcessorHelper helper;
+
+ private ProfileViewWrapper view;
+
+ public AbstractDeployTest(String name)
+ {
+ super(name);
+ }
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ this.actionController = new AbstractActionController();
+ this.deployer = new ProfileDeployerSupport();
+ this.deployHandler = new DeployHandlerSupport();
+ this.deployHandler.setActionController(actionController);
+
+ this.helper = new ManagedDeploymentProcessorHelper(proxyFactory);
+ this.view = new RegisteredProfileViewsWrapper(actionController);
+ this.view.setProcessorHelper(helper);
+
+ }
+
+ public AbstractActionController getActionController()
+ {
+ return actionController;
+ }
+
+ public ProfileDeployerSupport getDeployer()
+ {
+ return deployer;
+ }
+
+ public DeployHandlerSupport getDeployHandler()
+ {
+ return deployHandler;
+ }
+
+ public ProfileView getView()
+ {
+ view.load();
+ return view;
+ }
+
+}
+
Added: projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/deploy/test/TransientProfileUnitTestCase.java
===================================================================
--- projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/deploy/test/TransientProfileUnitTestCase.java (rev 0)
+++ projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/deploy/test/TransientProfileUnitTestCase.java 2010-03-15 12:49:17 UTC (rev 102402)
@@ -0,0 +1,82 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2010, Red Hat Inc., and individual contributors as indicated
+* 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.plugins.deploy.test;
+
+import java.net.URL;
+
+import org.jboss.managed.api.DeploymentState;
+import org.jboss.managed.api.ManagedDeployment;
+import org.jboss.profileservice.plugins.deploy.TransientProfileActivator.TransientDeploymentsProfile;
+import org.jboss.profileservice.spi.MutableProfile;
+import org.jboss.profileservice.spi.ProfileDeployment;
+import org.jboss.test.profileservice.plugins.deploy.support.ManagedProfileSupport;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class TransientProfileUnitTestCase extends AbstractDeployTest
+{
+
+ public TransientProfileUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testTransient() throws Exception
+ {
+ MutableProfile profile = new TransientDeploymentsProfile();
+ ManagedProfileSupport support = new ManagedProfileSupport(profile, getDeployer());
+
+ getActionController().addProfile(support);
+
+ URL url = new URL("file:///home/jboss/deployment/deployment1.jar");
+
+ getDeployHandler().addDeployment(url);
+
+ assertTrue(profile.hasDeployment("deployment1.jar"));
+ assertTrue(profile.hasDeployment(url.toExternalForm()));
+
+ getDeployHandler().startDeployment(url);
+ ProfileDeployment deployment = profile.getDeployment("deployment1.jar");
+ assertTrue(getDeployer().hasDeployment(deployment.getName()));
+ assertTrue(deployment.getDeploymentInfo().isDeployed());
+ assertFalse(deployment.getDeploymentInfo().isLocked());
+
+ assertNotNull(getView().getManagedDeployment(deployment.getName()));
+
+ getDeployHandler().stopDeployments(url);
+ deployment = profile.getDeployment("deployment1.jar");
+ assertFalse(getDeployer().hasDeployment(deployment.getName()));
+ assertFalse(deployment.getDeploymentInfo().isDeployed());
+ assertTrue(deployment.getDeploymentInfo().isLocked());
+
+ ManagedDeployment md = getView().getManagedDeployment(deployment.getName());
+ assertNotNull(md);
+ assertEquals(DeploymentState.STOPPED, md.getDeploymentState());
+
+ getDeployHandler().removeDeployments(url);
+ assertFalse(profile.hasDeployment("deployment1.jar"));
+ }
+
+}
+
Copied: projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/action/ActionState.java (from rev 102115, projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/action/ActionStatus.java)
===================================================================
--- projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/action/ActionState.java (rev 0)
+++ projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/action/ActionState.java 2010-03-15 12:49:17 UTC (rev 102402)
@@ -0,0 +1,49 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, JBoss Inc., and individual contributors as indicated
+* 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.spi.action;
+
+/**
+ * The state of a {@code TwoPhaseCommitProfileAction}.
+ *
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public enum ActionState
+{
+
+ ACTIVE,
+ ROLLBACK,
+ CANCELLED,
+
+ COMPLETED,
+ PREPARED,
+ COMMITTED,
+ ROLLEDBACK,
+
+ PREPARING,
+ COMMITTING,
+ ROLLING_BACK,
+
+ UNKNOWN
+
+}
+
Deleted: projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/action/ActionStatus.java
===================================================================
--- projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/action/ActionStatus.java 2010-03-15 12:49:05 UTC (rev 102401)
+++ projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/action/ActionStatus.java 2010-03-15 12:49:17 UTC (rev 102402)
@@ -1,45 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2009, JBoss Inc., and individual contributors as indicated
-* 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.spi.action;
-
-/**
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public enum ActionStatus
-{
-
- ACTIVE,
- ROLLBACK,
-
- PREPARED,
- COMMITTED,
- ROLLEDBACK,
-
- PREPARING,
- COMMITTING,
- ROLLING_BACK,
-
- UNKNOWN
-
-}
-
Modified: projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/action/ProfileModificationActions.java
===================================================================
--- projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/action/ProfileModificationActions.java 2010-03-15 12:49:05 UTC (rev 102401)
+++ projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/action/ProfileModificationActions.java 2010-03-15 12:49:17 UTC (rev 102402)
@@ -23,11 +23,13 @@
import java.util.List;
+import org.jboss.profileservice.spi.ProfileKey;
+
/**
* @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
* @version $Revision$
*/
-public interface ProfileModificationActions<T extends ProfileModificationContext>
+public interface ProfileModificationActions
{
@@ -39,11 +41,19 @@
ProfileModificationType getType();
/**
- * Get the modification actions.
+ * List the profiles affected by the modification.
*
+ * @return the profiles
+ */
+ List<ProfileKey> getProfilesKeys();
+
+ /**
+ * Get the modification actions for a given profile key
+ *
+ * @param key the profile key
* @return the actions
*/
- List<ProfileModificationAction<T>> getActions();
+ List<ProfileModificationAction<? extends ProfileModificationContext>> getActions(ProfileKey key);
}
Modified: projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/action/TwoPhaseCommitProfileAction.java
===================================================================
--- projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/action/TwoPhaseCommitProfileAction.java 2010-03-15 12:49:05 UTC (rev 102401)
+++ projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/action/TwoPhaseCommitProfileAction.java 2010-03-15 12:49:17 UTC (rev 102402)
@@ -29,11 +29,11 @@
{
/**
- * Get the current status.
+ * Get the current state.
*
- * @return the status
+ * @return the state
*/
- ActionStatus getStatus();
+ ActionState getState();
/**
* Prepare this action.
Modified: projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/action/engine/ActionController.java
===================================================================
--- projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/action/engine/ActionController.java 2010-03-15 12:49:05 UTC (rev 102401)
+++ projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/action/engine/ActionController.java 2010-03-15 12:49:17 UTC (rev 102402)
@@ -24,8 +24,10 @@
import java.util.List;
import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.action.ProfileModificationAction;
import org.jboss.profileservice.spi.action.ProfileModificationActions;
import org.jboss.profileservice.spi.action.ProfileModificationContext;
+import org.jboss.profileservice.spi.action.ProfileModificationType;
import org.jboss.profileservice.spi.managed.ManagedProfile;
/**
@@ -51,13 +53,21 @@
public ManagedProfile getManagedProfile(ProfileKey key);
/**
- * Perform a set of modification actions.
+ * Perform a list of modification actions on a single profile.
*
* @param key the target profile key
* @param actions the modification actions
* @return the modification status
*/
- ModificationStatus perfom(ProfileKey key, ProfileModificationActions<ProfileModificationContext> actions);
+ ModificationStatus perform(ProfileKey key, ProfileModificationType type, List<ProfileModificationAction<ProfileModificationContext>> actions);
+ /**
+ * Perform modification actions affecting multiple profiles.
+ *
+ * @param actions the modification actions
+ * @return the modification status
+ */
+ ModificationStatus perform(ProfileModificationActions actions);
+
}
Modified: projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/managed/ManagedProfile.java
===================================================================
--- projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/managed/ManagedProfile.java 2010-03-15 12:49:05 UTC (rev 102401)
+++ projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/managed/ManagedProfile.java 2010-03-15 12:49:17 UTC (rev 102402)
@@ -60,6 +60,12 @@
*/
ProfileMetaData getProfileMetaData();
+ /**
+ * Get the associated deploy plugin, handling
+ * this profile.
+ *
+ * @return the deployer
+ */
ManagedProfileDeployer getManagedDeployer();
/**
More information about the jboss-cvs-commits
mailing list