[jboss-cvs] JBossAS SVN: r100760 - in projects/profileservice/trunk: core/src/main/java/org/jboss/profileservice/bootstrap and 23 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Feb 9 11:04:41 EST 2010
Author: emuckenhuber
Date: 2010-02-09 11:04:39 -0500 (Tue, 09 Feb 2010)
New Revision: 100760
Added:
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/management/
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/management/AbstractActionController.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/management/AbstractEventBus.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/management/event/
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/management/event/ProfileLifeCycleEvent.java
projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/util/
projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/util/AbstractManagementProxyFactory.java
projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/util/ManagedDeploymentProcessor.java
projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/util/RuntimeManagedObjectRegistry.java
projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/action/ProfileModificationActions.java
Removed:
projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/view/ProfileViewWrapper.java
projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/view/RuntimeManagedObjectRegistry.java
Modified:
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/AbstractProfileService.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/TypedProfileFactory.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/bootstrap/AbstractProfileServiceInitializer.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileControllerContext.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileDependencyContext.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileDeployAction.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileMetaDataRegistry.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileServiceController.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/plugin/ProfileLifeCycleCallbackActions.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/ProfileDeployerPluginRegistry.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/DefaultHDScannerFactory.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/Scanner.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/bootstrap/BootstrapDeployerPlugin.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/AbstractArtifact.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/file/FileArtifactRepositoryFactory.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/file/LocalFileArtifactRepository.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/maven/AbstractMavenArtifactRepository.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/maven/LocalMavenArtifactRepository.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/maven/MavenArtifactId.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/resolver/AbstractRequirementResolver.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/resolver/ProfileNode.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/resolver/ProfileNodeDependency.java
projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/resolver/test/ActivationCallbackUnitTestCase.java
projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/test/AbstractProfileServiceTest.java
projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/test/BasicProfileServiceUnitTestCase.java
projects/profileservice/trunk/core/src/test/resources/org/jboss/test/profileservice/resolver/test/callbacks.xml
projects/profileservice/trunk/core/src/test/resources/system/bootstrap.xml
projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/AggregatingLocalManagementView.java
projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/view/AbstractProfileView.java
projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/spi/ProfileView.java
projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/action/ProfileModificationContext.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/action/engine/EventBus.java
projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/action/engine/ModificationListener.java
projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/action/engine/ModificationStatus.java
projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/dependency/ProfileRequirementResolverPlugin.java
projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/repository/Artifact.java
Log:
WIP on the ManagementView integration.
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/AbstractProfileService.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/AbstractProfileService.java 2010-02-09 16:04:06 UTC (rev 100759)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/AbstractProfileService.java 2010-02-09 16:04:39 UTC (rev 100760)
@@ -106,6 +106,10 @@
*/
public void setViewManager(ManagementView mgtView)
{
+ if(mgtView == null)
+ {
+ throw new IllegalArgumentException("null management view");
+ }
this.mgtView = mgtView;
}
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/TypedProfileFactory.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/TypedProfileFactory.java 2010-02-09 16:04:06 UTC (rev 100759)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/TypedProfileFactory.java 2010-02-09 16:04:39 UTC (rev 100760)
@@ -24,8 +24,6 @@
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-import org.jboss.kernel.spi.dependency.KernelControllerContext;
-import org.jboss.kernel.spi.dependency.KernelControllerContextAware;
import org.jboss.profileservice.profile.NoopProfile;
import org.jboss.profileservice.profile.metadata.plugin.EmptyProfileMetaData;
import org.jboss.profileservice.spi.Profile;
@@ -40,15 +38,12 @@
* @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
* @version $Revision$
*/
-public class TypedProfileFactory implements ProfileFactory<ProfileMetaData, Profile>, KernelControllerContextAware
+public class TypedProfileFactory implements ProfileFactory<ProfileMetaData, Profile>
{
/** The type we create locally. */
private static final String typeName = EmptyProfileMetaData.class.getName();
- /** The bean name. */
- private Object name;
-
/** The profile factories. */
private Map<String, ProfileFactory<ProfileMetaData, Profile>> factories = new ConcurrentHashMap<String, ProfileFactory<ProfileMetaData, Profile>>();
@@ -57,11 +52,6 @@
super();
}
- public Object getName()
- {
- return this.name;
- }
-
public String[] getTypes()
{
return new String[] { typeName };
@@ -193,17 +183,5 @@
this.factories.remove(type);
}
- @Override
- public void setKernelControllerContext(KernelControllerContext context) throws Exception
- {
- this.name = context.getName();
- }
-
- @Override
- public void unsetKernelControllerContext(KernelControllerContext context) throws Exception
- {
-
- }
-
}
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/bootstrap/AbstractProfileServiceInitializer.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/bootstrap/AbstractProfileServiceInitializer.java 2010-02-09 16:04:06 UTC (rev 100759)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/bootstrap/AbstractProfileServiceInitializer.java 2010-02-09 16:04:39 UTC (rev 100760)
@@ -73,8 +73,8 @@
// initialize the config
config.setManagementDomain(createManagementDomain(domainMetaData));
config.setServerConfiguration(createServerConfiguration(domainMetaData));
-
- return createprofileService();
+ // Create profile service
+ return createProfileService();
}
/**
@@ -83,10 +83,13 @@
* @return the profile service
* @throws Throwable
*/
- public ProfileService createprofileService() throws Throwable
+ public ProfileService createProfileService() throws Throwable
{
+ // Create the registry
ProfileMetaDataRegistry registry = createProfileMetaDataRegistry();
+ // Create the controller
ProfileServiceController controller = new ProfileServiceController(getKernel().getController(), registry, config);
+ // Create the profile service
AbstractProfileService ps = new AbstractProfileService(controller);
register(ProfileServiceConstants.PROFILESERVICE_NAME, ps);
return ps;
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileControllerContext.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileControllerContext.java 2010-02-09 16:04:06 UTC (rev 100759)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileControllerContext.java 2010-02-09 16:04:39 UTC (rev 100760)
@@ -23,8 +23,8 @@
import org.jboss.beans.metadata.spi.BeanMetaData;
import org.jboss.dependency.spi.Controller;
-import org.jboss.dependency.spi.ControllerMode;
import org.jboss.kernel.plugins.dependency.AbstractKernelControllerContext;
+import org.jboss.profileservice.deployment.ProfileDeployerPlugin;
import org.jboss.profileservice.spi.Profile;
import org.jboss.profileservice.spi.ProfileKey;
import org.jboss.profileservice.spi.metadata.ProfileMetaData;
@@ -38,7 +38,7 @@
public class ProfileControllerContext extends AbstractKernelControllerContext
{
- /** Some addtional meta data information. */
+ /** Some additional meta data information. */
private ProfileDependencyContext metaDataContext;
protected ProfileControllerContext(BeanMetaData metaData, Object target)
@@ -49,7 +49,6 @@
@Override
public void setController(Controller controller)
{
- ProfileControllerContextActions.initializeController(controller);
super.setController(controller);
}
@@ -68,6 +67,11 @@
return getDependencyContext().getProfileMetaData();
}
+ public ProfileDeployerPlugin getDeployerPlugin()
+ {
+ return getDependencyContext().getDeployer();
+ }
+
public ProfileDependencyContext getDependencyContext()
{
return metaDataContext;
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileDependencyContext.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileDependencyContext.java 2010-02-09 16:04:06 UTC (rev 100759)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileDependencyContext.java 2010-02-09 16:04:39 UTC (rev 100760)
@@ -43,7 +43,6 @@
* since features might depend on other profiles to be installed/deployed
* first before they can be processed.
*
- *
* @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
* @version $Revision$
*/
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileDeployAction.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileDeployAction.java 2010-02-09 16:04:06 UTC (rev 100759)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileDeployAction.java 2010-02-09 16:04:39 UTC (rev 100760)
@@ -78,7 +78,7 @@
if(profile.getDeployments() != null & profile.getDeployments().isEmpty() == false)
{
// Get the deployer plugin
- ProfileDeployerPlugin deployer = context.getDependencyContext().getDeployer();
+ ProfileDeployerPlugin deployer = context.getDeployerPlugin();
if(deployer == null)
{
throw new IllegalStateException("null deployer for profile " + profile.getKey());
@@ -96,7 +96,7 @@
if(profile.getDeployments() != null & profile.getDeployments().isEmpty() == false)
{
// Get the deployer plugin
- ProfileDeployerPlugin deployer = context.getDependencyContext().getDeployer();
+ ProfileDeployerPlugin deployer = context.getDeployerPlugin();
if(deployer == null)
{
throw new IllegalStateException("null deployer for profile " + profile.getKey());
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileMetaDataRegistry.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileMetaDataRegistry.java 2010-02-09 16:04:06 UTC (rev 100759)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileMetaDataRegistry.java 2010-02-09 16:04:39 UTC (rev 100760)
@@ -60,8 +60,12 @@
/** The profiles by name. */
private Map<String, ProfileDependencyContext> profilesByName = new ConcurrentHashMap<String, ProfileDependencyContext>();
+ /** The registered profiles. */
private List<ProfileKey> registeredProfiles = new ArrayList<ProfileKey>();
+ /** Contexts registered as on-demand. */
+ private List<ProfileKey> onDemandContexts = new ArrayList<ProfileKey>();
+
/** Check consistency. */
private boolean checkConsistency = true;
@@ -153,6 +157,11 @@
this.profiles.add(context);
this.registeredProfiles.add(context.getKey());
this.profilesByName.put(context.getName(), context);
+ if(context.isOnDemandEnabled())
+ {
+ // TODO
+ this.onDemandContexts.add(context.getKey());
+ }
}
public ProfileDependencyContext getContext(String name)
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileServiceController.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileServiceController.java 2010-02-09 16:04:06 UTC (rev 100759)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileServiceController.java 2010-02-09 16:04:39 UTC (rev 100760)
@@ -68,6 +68,8 @@
this.controller = controller;
this.metaDataRegistry = registry;
this.config = config;
+ // initialize
+ ProfileControllerContextActions.initializeController(controller);
}
public ProfileKey resolveProfileKey(ProfileMetaData metaData)
@@ -131,7 +133,7 @@
throw new NoSuchProfileException("no such profile registered " + key);
}
- public ProfileKey registerProfile(ProfileMetaData metaData) throws Throwable
+ ProfileKey registerProfile(ProfileMetaData metaData) throws Throwable
{
ProfileDependencyContext metaDataContext = internalRegisterProfile(metaData, false);
return metaDataContext.getKey();
@@ -215,7 +217,7 @@
kCtx.setDependencyContext(context);
// Add the lifecycle callback
- LifecycleCallbackItem callbackItem = config.getLifeCycleActions();
+ final LifecycleCallbackItem callbackItem = config.getLifeCycleActions();
if(callbackItem != null)
{
kCtx.getDependencyInfo().addLifecycleCallback(callbackItem);
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/plugin/ProfileLifeCycleCallbackActions.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/plugin/ProfileLifeCycleCallbackActions.java 2010-02-09 16:04:06 UTC (rev 100759)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/plugin/ProfileLifeCycleCallbackActions.java 2010-02-09 16:04:39 UTC (rev 100760)
@@ -31,6 +31,7 @@
import org.jboss.kernel.spi.dependency.KernelControllerContextAware;
import org.jboss.profileservice.dependency.ProfileControllerContext;
import org.jboss.profileservice.dependency.ProfileDependencyContext;
+import org.jboss.profileservice.management.AbstractActionController;
import org.jboss.profileservice.spi.Profile;
import org.jboss.profileservice.spi.metadata.ProfileFeatureMetaData;
import org.jboss.util.collection.ConcurrentReferenceHashMap;
@@ -51,9 +52,21 @@
/** My name. */
private Object beanName;
+ /** The action controller. */
+ private final AbstractActionController actionController;
+
/** The actions. */
private Map<ProfileLifeCycleCallbackAction<ProfileFeatureMetaData>, Object> actions = new ConcurrentReferenceHashMap<ProfileLifeCycleCallbackAction<ProfileFeatureMetaData>, Object>();
+ public ProfileLifeCycleCallbackActions(AbstractActionController actionController)
+ {
+ if(actionController == null)
+ {
+ throw new IllegalArgumentException("null action controller");
+ }
+ this.actionController = actionController;
+ }
+
public void addCallback(ProfileLifeCycleCallbackAction<ProfileFeatureMetaData> callback)
{
actions.put(callback, value);
@@ -124,7 +137,11 @@
ProfileDependencyContext metaDataCtx = context.getDependencyContext();
if(profile != null && metaDataCtx != null)
{
+ // Process install callbacks
processCallbacks(profile, metaDataCtx, true);
+
+ // Register the profile
+ actionController.addProfile(profile);
}
}
}
@@ -139,6 +156,10 @@
ProfileDependencyContext metaDataCtx = context.getDependencyContext();
if(profile != null && metaDataCtx != null)
{
+ // Unregister the profile
+ actionController.removeProfile(profile);
+
+ // Process uninstall callbacks
processCallbacks(profile, metaDataCtx, false);
}
}
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/ProfileDeployerPluginRegistry.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/ProfileDeployerPluginRegistry.java 2010-02-09 16:04:06 UTC (rev 100759)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/ProfileDeployerPluginRegistry.java 2010-02-09 16:04:39 UTC (rev 100760)
@@ -29,7 +29,6 @@
import org.jboss.profileservice.profile.bootstrap.BootstrapProfileMetaData;
import org.jboss.profileservice.spi.metadata.ProfileMetaData;
-
/**
* A deployer registry to swap the used deployer. Normally either a
* BasicXmlDeployer or the MainDeployer.
@@ -50,7 +49,7 @@
{
ProfileDeployerPlugin kernelDeployer = new BootstrapDeployerPlugin(kernel);
this.map.put(BootstrapProfileMetaData.class.getName(), kernelDeployer);
- }
+ }
public ProfileDeployerPlugin getDeployer(ProfileMetaData metaData)
{
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/DefaultHDScannerFactory.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/DefaultHDScannerFactory.java 2010-02-09 16:04:06 UTC (rev 100759)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/DefaultHDScannerFactory.java 2010-02-09 16:04:39 UTC (rev 100760)
@@ -39,37 +39,35 @@
/** The executor. */
private ScheduledExecutorService scanExecutor;
- /** Did we create the ScheduledExecutorService */
- private boolean createdScanExecutor;
+ /** The thread factory. */
+ private ThreadFactory threadFactory;
/** Thread name used when the ScheduledExecutorService is created internally. */
private String scanThreadName = "HDScanner";
+
/**
- * Get the scan Executor.
+ * Get the optional thread factory used to create
+ * the ScheduledExcecutor.
*
- * @return Returns the scanExecutor.
+ * @return the thread factory
*/
- public ScheduledExecutorService getScanExecutor()
+ public ThreadFactory getThreadFactory()
{
- return scanExecutor;
+ return threadFactory;
}
-
+
/**
- * Set the scan executor.
+ * Set the thread factory.
*
- * @param scanExecutor The scanExecutor to set.
+ * @param threadFactory
*/
- public void setScanExecutor(ScheduledExecutorService scanExecutor)
+ public void setThreadFactory(ThreadFactory threadFactory)
{
- if(scanExecutor == null)
- {
- throw new IllegalArgumentException("null scan executor");
- }
- this.scanExecutor = scanExecutor;
- createdScanExecutor = false;
+ this.threadFactory = threadFactory;
}
-
+
+
/**
* Get the scan thread name.
*
@@ -101,20 +99,18 @@
*/
public void start()
{
- // Default to a single thread executor
- if (scanExecutor == null)
+ if(this.threadFactory == null)
{
- scanExecutor = Executors.newSingleThreadScheduledExecutor(
- new ThreadFactory()
- {
- public Thread newThread(Runnable r)
- {
- return new Thread(r, DefaultHDScannerFactory.this.getScanThreadName());
- }
- }
- );
- createdScanExecutor = true;
+ this.threadFactory = new ThreadFactory()
+ {
+ public Thread newThread(Runnable r)
+ {
+ return new Thread(r, DefaultHDScannerFactory.this.getScanThreadName());
+ }
+ };
}
+ // Always use a single thread scheduled executor for now
+ scanExecutor = Executors.newSingleThreadScheduledExecutor(this.threadFactory);
}
@Override
@@ -122,21 +118,18 @@
{
super.stop();
// Shutdown the scanExecutor
- if (scanExecutor != null && createdScanExecutor)
+ try
{
- try
- {
- scanExecutor.shutdownNow();
- }
- catch(Exception e)
- {
- log.debug("Failed to cleanly shutdown scanExecutor", e);
- }
- finally
- {
- scanExecutor = null;
- }
+ scanExecutor.shutdownNow();
}
+ catch(Exception e)
+ {
+ log.debug("Failed to cleanly shutdown scanExecutor", e);
+ }
+ finally
+ {
+ scanExecutor = null;
+ }
}
/**
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/Scanner.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/Scanner.java 2010-02-09 16:04:06 UTC (rev 100759)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/Scanner.java 2010-02-09 16:04:39 UTC (rev 100760)
@@ -23,6 +23,10 @@
import java.util.concurrent.TimeUnit;
+import org.jboss.managed.api.ManagedOperation.Impact;
+import org.jboss.managed.api.annotation.ManagementComponent;
+import org.jboss.managed.api.annotation.ManagementObject;
+import org.jboss.managed.api.annotation.ManagementObjectID;
import org.jboss.managed.api.annotation.ManagementOperation;
import org.jboss.managed.api.annotation.ManagementProperty;
import org.jboss.profileservice.spi.ProfileKey;
@@ -32,8 +36,8 @@
*
* @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
*/
-// TODO we need to merge a scanner into a Profile MO
-// @ManagementObject(componentType = @ManagementComponent(type="Profile", subtype = "HDScanner"))
+// TODO scan-period should be configurable through a management interface
+ at ManagementObject(componentType = @ManagementComponent(type="Profile", subtype = "HDScanner"))
public interface Scanner extends ScannerConfiguration
{
@@ -43,6 +47,7 @@
* @return the profile key
*/
@ManagementProperty(name = "profile", description = "The associated profile", readOnly = true)
+ @ManagementObjectID
ProfileKey getKey();
/**
@@ -72,25 +77,25 @@
*/
@ManagementProperty(name = "is-scheduled", description = "Is the scanner scheduled", readOnly = true)
boolean isScheduled();
+
+ /**
+ * Resume scanning.
+ */
+ @ManagementOperation(name = "start", description = "Start the scanning", impact = Impact.ReadOnly)
+ void start();
/**
* Suspend scanning.
*/
- @ManagementOperation(name = "stop", description = "Stop the scanning")
+ @ManagementOperation(name = "stop", description = "Stop the scanning", impact = Impact.ReadOnly)
void stop();
/**
- * Resume scanning.
- */
- @ManagementOperation(name = "start", description = "Start the scanning")
- void start();
-
- /**
* Do scan.
*
* @throws Exception for any error
*/
- @ManagementOperation(name = "scan", description = "Scan the profile for modified deployments")
+ @ManagementOperation(name = "scan", description = "Scan the profile for modified deployments", impact = Impact.ReadWrite)
void scan() throws Exception;
}
Added: 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 (rev 0)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/management/AbstractActionController.java 2010-02-09 16:04:39 UTC (rev 100760)
@@ -0,0 +1,173 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, 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;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+import org.jboss.profileservice.management.event.ProfileLifeCycleEvent;
+import org.jboss.profileservice.management.event.ProfileLifeCycleEvent.LifeCycleState;
+import org.jboss.profileservice.spi.Profile;
+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.ProfileModificationType;
+import org.jboss.profileservice.spi.action.TwoPhaseCommitProfileAction;
+import org.jboss.profileservice.spi.action.engine.ActionController;
+import org.jboss.profileservice.spi.action.engine.ModificationStatus;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class AbstractActionController extends AbstractEventBus implements ActionController
+{
+
+ /** The profiles. */
+ private Map<ProfileKey, ProfileWrapper> profiles = new ConcurrentHashMap<ProfileKey, ProfileWrapper>();
+
+ public void addProfile(Profile profile)
+ {
+ ProfileKey key = profile.getKey();
+ this.profiles.put(key, new ProfileWrapper(profile));
+ fireModificationEvent(new ProfileLifeCycleEvent(key, LifeCycleState.INSTALLED));
+ }
+
+ public void removeProfile(Profile profile)
+ {
+ ProfileKey key = profile.getKey();
+ fireModificationEvent(new ProfileLifeCycleEvent(key, LifeCycleState.UNINSTALLED));
+ ProfileWrapper wrapper = this.profiles.remove(key);
+ if(wrapper != null)
+ {
+ wrapper.lockWrite();
+ try
+ {
+ //
+ }
+ finally
+ {
+ wrapper.unlockWrite();
+ }
+ }
+ }
+
+ @Override
+ public ModificationStatus perfom(ProfileKey key, ProfileModificationActions<?> actions)
+ {
+ if(key == null)
+ {
+ throw new IllegalArgumentException("null profile key");
+ }
+ ProfileWrapper wrapper = profiles.get(key);
+ if(wrapper == null)
+ {
+ throw new IllegalStateException("no such profile registered" + key);
+ }
+ ProfileModificationType type = actions.getType();
+ if(type == ProfileModificationType.GET)
+ {
+ return performRead(wrapper, actions);
+ }
+ else
+ {
+ return performWrite(wrapper, actions);
+ }
+ }
+
+ ModificationStatus performRead(ProfileWrapper wrapper, ProfileModificationActions<?> actions)
+ {
+ wrapper.lockRead();
+ try
+ {
+ return internalPerfom(wrapper.getProfile(), actions);
+ }
+ finally
+ {
+ wrapper.unlockRead();
+ }
+ }
+
+ ModificationStatus performWrite(ProfileWrapper wrapper, ProfileModificationActions<?> actions)
+ {
+ wrapper.lockWrite();
+ try
+ {
+ return internalPerfom(wrapper.getProfile(), actions);
+ }
+ finally
+ {
+ wrapper.unlockWrite();
+ }
+ }
+
+ ModificationStatus internalPerfom(Profile profile, ProfileModificationActions<?> actions)
+ {
+ for(ProfileModificationAction<?> action : actions.getActions())
+ {
+ ((TwoPhaseCommitProfileAction<?>) action).complete();
+ }
+ return null;
+ }
+
+ /**
+ * The profile wrapper, used to lock the profile
+ * when actions are performed.
+ */
+ private static class ProfileWrapper
+ {
+ private final Profile profile;
+ private final ReentrantReadWriteLock lock;
+
+ ProfileWrapper(Profile profile)
+ {
+ this.profile = profile;
+ this.lock = new ReentrantReadWriteLock(true);
+ }
+
+ Profile getProfile()
+ {
+ return profile;
+ }
+
+ void lockRead()
+ {
+ lock.readLock().lock();
+ }
+ void unlockRead()
+ {
+ lock.readLock().unlock();
+ }
+
+ void lockWrite()
+ {
+ lock.writeLock().lock();
+ }
+ void unlockWrite()
+ {
+ lock.writeLock().unlock();
+ }
+ }
+
+}
+
Added: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/management/AbstractEventBus.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/management/AbstractEventBus.java (rev 0)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/management/AbstractEventBus.java 2010-02-09 16:04:39 UTC (rev 100760)
@@ -0,0 +1,80 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, 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;
+
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import org.jboss.logging.Logger;
+import org.jboss.profileservice.spi.action.engine.EventBus;
+import org.jboss.profileservice.spi.action.engine.ModificationEvent;
+import org.jboss.profileservice.spi.action.engine.ModificationListener;
+
+/**
+ * The abstract event bus.
+ *
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+// TODO integration with the kernel event bus
+public class AbstractEventBus implements EventBus
+{
+
+ /** The logger. */
+ private static final Logger log = Logger.getLogger(EventBus.class);
+
+ /** The modification listeners. */
+ private List<ModificationListener> listeners = new CopyOnWriteArrayList<ModificationListener>();
+
+ @Override
+ public void fireModificationEvent(ModificationEvent event)
+ {
+ if(listeners != null && listeners.isEmpty() == false)
+ {
+ for(ModificationListener listener : listeners)
+ {
+ try
+ {
+ listener.notify(event);
+ }
+ catch(Throwable t)
+ {
+ log.debug("failed to notify listener: " + listener);
+ }
+ }
+ }
+ }
+
+ @Override
+ public void addListener(ModificationListener listener)
+ {
+ this.listeners.add(listener);
+ }
+
+ @Override
+ public void removeListener(ModificationListener listener)
+ {
+ this.listeners.remove(listener);
+ }
+
+}
+
Added: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/management/event/ProfileLifeCycleEvent.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/management/event/ProfileLifeCycleEvent.java (rev 0)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/management/event/ProfileLifeCycleEvent.java 2010-02-09 16:04:39 UTC (rev 100760)
@@ -0,0 +1,61 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, 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;
+
+/**
+ * The profile lifecycle event.
+ *
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class ProfileLifeCycleEvent implements ModificationEvent
+{
+
+ public static enum LifeCycleState { INSTALLED, UNINSTALLED }
+
+ /** The state. */
+ private final LifeCycleState state;
+
+ /** The profile key. */
+ private final ProfileKey key;
+
+ public ProfileLifeCycleEvent(final ProfileKey key, final LifeCycleState state)
+ {
+ this.key = key;
+ this.state = state;
+ }
+
+ public LifeCycleState getState()
+ {
+ return state;
+ }
+
+ public ProfileKey getKey()
+ {
+ return key;
+ }
+
+}
+
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/bootstrap/BootstrapDeployerPlugin.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/bootstrap/BootstrapDeployerPlugin.java 2010-02-09 16:04:06 UTC (rev 100759)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/bootstrap/BootstrapDeployerPlugin.java 2010-02-09 16:04:39 UTC (rev 100760)
@@ -21,36 +21,60 @@
*/
package org.jboss.profileservice.profile.bootstrap;
+import java.util.Collection;
+import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.BeanMetaDataFactory;
+import org.jboss.dependency.spi.ControllerContext;
import org.jboss.kernel.Kernel;
import org.jboss.kernel.plugins.deployment.xml.BasicXMLDeployer;
+import org.jboss.kernel.spi.dependency.KernelController;
import org.jboss.kernel.spi.deployment.KernelDeployment;
+import org.jboss.kernel.spi.metadata.KernelMetaDataRepository;
import org.jboss.managed.api.ManagedDeployment;
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.api.factory.ManagedObjectFactory;
+import org.jboss.managed.plugins.ManagedDeploymentImpl;
+import org.jboss.managed.plugins.factory.ManagedObjectFactoryBuilder;
+import org.jboss.metadata.spi.MetaData;
import org.jboss.profileservice.deployment.ProfileDeployerPlugin;
import org.jboss.profileservice.spi.ProfileDeployment;
/**
+ * The bootstrap profile deployer pluging, delegating work to the
+ * KernelDeployer.
+ *
* @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
* @version $Revision$
*/
public class BootstrapDeployerPlugin implements ProfileDeployerPlugin
{
- /** The deployments. */
- private final Map<String, KernelDeployment> deployments = new ConcurrentHashMap<String, KernelDeployment>();
+ /** The managed object factory. */
+ private final static ManagedObjectFactory managedObjectFactory = ManagedObjectFactoryBuilder.create();
+ /** The kernel. */
+ private final Kernel kernel;
+
/** The deployer. */
private final BasicXMLDeployer deployer;
/** Shutdown. */
private volatile boolean shutdown = false;
+ /** The deployments. */
+ private final Map<String, KernelDeployment> deployments = new ConcurrentHashMap<String, KernelDeployment>();
+
public BootstrapDeployerPlugin(Kernel kernel)
{
if(kernel == null)
+ {
throw new IllegalArgumentException("null kernel");
+ }
+ this.kernel = kernel;
this.deployer = new BasicXMLDeployer(kernel);
}
@@ -61,6 +85,7 @@
try
{
// Deploy
+ // TODO update management changes before deploying
KernelDeployment result = this.deployer.deploy(deployment.getRoot().toURL());
// Add to the deployments
this.deployments.put(deployment.getName(), result);
@@ -153,9 +178,7 @@
{
throw new IllegalStateException("no deployment registered with name " + deployment.getName());
}
- // FIXME getManagedDeployment
- // mgtDeploymentCreator.build(result, managedObjects);
- return null;
+ return createManagedDeployment(result);
}
@Override
@@ -178,5 +201,49 @@
}
}
+ /**
+ * Create a managed deployment based on the KernelDeployment
+ *
+ * @param kernelDeployment the kernel deployment
+ * @return the managed deployment
+ */
+ ManagedDeployment createManagedDeployment(KernelDeployment kernelDeployment)
+ {
+ Map<String, ManagedObject> managedObjects = new HashMap<String, ManagedObject>();
+ Collection<BeanMetaDataFactory> beanFactories = kernelDeployment.getBeanFactories();
+ if(beanFactories != null && beanFactories.isEmpty() == false)
+ {
+ for(BeanMetaDataFactory beanFactory : beanFactories)
+ {
+ Collection<BeanMetaData> beans = beanFactory.getBeans();
+ if(beans != null && beans.isEmpty() == false)
+ {
+ for(BeanMetaData bmd : beans)
+ {
+ String name = bmd.getName();
+ ControllerContext context = getKernelController().getContext(bmd.getName(), null);
+ MetaData metaData = getMetaDataRepository().getMetaData(context);
+ // Create the managed object
+ ManagedObject mo = managedObjectFactory.initManagedObject(bmd, null, metaData, name, null);
+ if(mo != null)
+ {
+ managedObjects.put(name, mo);
+ }
+ }
+ }
+ }
+ }
+ return new ManagedDeploymentImpl(kernelDeployment.getName(), kernelDeployment.getName(), null, managedObjects);
+ }
+
+ KernelController getKernelController()
+ {
+ return kernel.getController();
+ }
+
+ KernelMetaDataRepository getMetaDataRepository()
+ {
+ return kernel.getMetaDataRepository();
+ }
}
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/AbstractArtifact.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/AbstractArtifact.java 2010-02-09 16:04:06 UTC (rev 100759)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/AbstractArtifact.java 2010-02-09 16:04:39 UTC (rev 100760)
@@ -22,6 +22,7 @@
package org.jboss.profileservice.repository.artifact;
import java.io.IOException;
+import java.io.InputStream;
import org.jboss.profileservice.spi.repository.Artifact;
import org.jboss.profileservice.spi.repository.ArtifactId;
@@ -80,6 +81,11 @@
return this.repository.getIdentifier();
}
+ public InputStream getInputStream() throws IOException
+ {
+ return getFile().openStream();
+ }
+
public VirtualFile getFile() throws IOException
{
return this.repository.getArtifactFile(getIdentifier());
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/file/FileArtifactRepositoryFactory.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/file/FileArtifactRepositoryFactory.java 2010-02-09 16:04:06 UTC (rev 100759)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/file/FileArtifactRepositoryFactory.java 2010-02-09 16:04:39 UTC (rev 100760)
@@ -57,7 +57,7 @@
@Override
public ArtifactRepository<FileArtifactId> createArtifactRepository(ArtifactRepositoryId repositoryId,
- ArtifactRepositoryConfiguration configuration) throws IOException
+ ArtifactRepositoryConfiguration<FileArtifactId> configuration) throws IOException
{
if(repositoryId == null)
{
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/file/LocalFileArtifactRepository.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/file/LocalFileArtifactRepository.java 2010-02-09 16:04:06 UTC (rev 100759)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/file/LocalFileArtifactRepository.java 2010-02-09 16:04:39 UTC (rev 100760)
@@ -21,7 +21,6 @@
*/
package org.jboss.profileservice.repository.artifact.file;
-import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
@@ -90,7 +89,7 @@
VirtualFile vf = getRepositoryRoot().getChild(artifact.getPath());
if(vf == null)
{
- throw new FileNotFoundException(artifact.getPath() + ", root: " + getRepositoryRoot());
+ getConfiguration().getNotFoundHandler().handleArtifactNotFound(this, artifact);
}
return vf;
}
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/maven/AbstractMavenArtifactRepository.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/maven/AbstractMavenArtifactRepository.java 2010-02-09 16:04:06 UTC (rev 100759)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/maven/AbstractMavenArtifactRepository.java 2010-02-09 16:04:39 UTC (rev 100760)
@@ -21,7 +21,6 @@
*/
package org.jboss.profileservice.repository.artifact.maven;
-import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URI;
@@ -43,45 +42,45 @@
super(identifier, root);
}
- protected VirtualFile getGroupRoot(String groupId) throws IOException
+ protected VirtualFile getGroupRoot(MavenArtifactId artifactId) throws IOException
{
- String[] groups = groupId.split("\\.");
+ String[] groups = artifactId.getGroupId().split("\\.");
VirtualFile child = getRepositoryRoot();
for(String group : groups)
{
child = child.getChild(group);
if(child == null)
{
- throw new FileNotFoundException("failed to get " + group + " for groupId " + groupId);
+ getConfiguration().getNotFoundHandler().handleArtifactNotFound(this, artifactId);
}
}
return child;
}
- protected VirtualFile getArtifactIdRoot(String groupId, String artifactId) throws IOException
+ protected VirtualFile getArtifactIdRoot(MavenArtifactId artifactId) throws IOException
{
- VirtualFile artifact = getGroupRoot(groupId).getChild(artifactId);
+ VirtualFile artifact = getGroupRoot(artifactId).getChild(artifactId.getArtifactId());
if(artifact == null)
{
- throw new FileNotFoundException("artifact root not found for groupId " + groupId + "-" + artifactId);
+ getConfiguration().getNotFoundHandler().handleArtifactNotFound(this, artifactId);
}
return artifact;
}
protected VirtualFile resolveArtifactFile(MavenArtifactMetaData artifact) throws IOException
{
- VirtualFile artifactIdRoot = getArtifactIdRoot(artifact.getGroupId(), artifact.getArtifactId());
+ VirtualFile artifactIdRoot = getArtifactIdRoot(artifact);
VirtualFile vf = artifactIdRoot.getChild(artifact.getVersion().toString());
if(vf == null)
{
- throw new FileNotFoundException("failed to get artifact " + artifact);
+ getConfiguration().getNotFoundHandler().handleArtifactNotFound(this, artifact);
}
// Build the artifact name
String artifactName = createArtifactName(artifact);
VirtualFile artifactRoot = vf.getChild(artifactName);
if(artifactRoot == null)
{
- throw new FileNotFoundException("failed to get artifact " + createArtifactName(artifact));
+ getConfiguration().getNotFoundHandler().handleArtifactNotFound(this, artifact);
}
return artifactRoot;
}
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/maven/LocalMavenArtifactRepository.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/maven/LocalMavenArtifactRepository.java 2010-02-09 16:04:06 UTC (rev 100759)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/maven/LocalMavenArtifactRepository.java 2010-02-09 16:04:39 UTC (rev 100760)
@@ -21,7 +21,6 @@
*/
package org.jboss.profileservice.repository.artifact.maven;
-import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URI;
import java.util.ArrayList;
@@ -102,7 +101,7 @@
MavenArtifact artifact = resolveArtifact(artifactId);
if(artifact == null)
{
- throw new FileNotFoundException("Artifact not found " + artifactId);
+ getConfiguration().getNotFoundHandler().handleArtifactNotFound(this, artifactId);
}
return resolveArtifactFile(artifact.getIdentifier());
}
@@ -125,7 +124,7 @@
*/
@Override
public ArtifactRepository<MavenArtifactId> createArtifactRepository(ArtifactRepositoryId repositoryId,
- ArtifactRepositoryConfiguration configuration) throws IOException
+ ArtifactRepositoryConfiguration<MavenArtifactId> configuration) throws IOException
{
return this;
}
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/maven/MavenArtifactId.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/maven/MavenArtifactId.java 2010-02-09 16:04:06 UTC (rev 100759)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/artifact/maven/MavenArtifactId.java 2010-02-09 16:04:39 UTC (rev 100760)
@@ -24,7 +24,7 @@
import org.jboss.profileservice.spi.repository.ArtifactId;
/**
- * A mvn like artifact id.
+ * A mvn like artifact id. This is just used to talk to a local repository.
*
* @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
* @version $Revision$
@@ -32,13 +32,46 @@
public interface MavenArtifactId extends ArtifactId
{
+ /** The mvn artifact type */
static final String TYPE = MavenArtifactId.class.getName();
+ /**
+ * Get the mvn groupId.
+ *
+ * @return the group id
+ */
String getGroupId();
+
+ /**
+ * Get the artifactId.
+ *
+ * @return the artifact id
+ */
String getArtifactId();
+
+ /**
+ * Get the classifier.
+ *
+ * @return the classifier
+ */
String getClassifier();
+
+ /**
+ * Get the packaging type.
+ *
+ * @return the packaging type
+ */
String getPackagingType();
+ /**
+ * Match a <code>MavenArtifactId</code>. This can be used
+ * to resolve an artifact with a <code>VersionRange</code>
+ * against an artifact which provides a <code>Version</code>.
+ *
+ * @param artifact the other artifactId.
+ * @return
+ */
boolean matches(MavenArtifactId artifact);
+
}
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/resolver/AbstractRequirementResolver.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/resolver/AbstractRequirementResolver.java 2010-02-09 16:04:06 UTC (rev 100759)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/resolver/AbstractRequirementResolver.java 2010-02-09 16:04:39 UTC (rev 100760)
@@ -26,7 +26,6 @@
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
-import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -60,7 +59,7 @@
private List<ProfileKey> includedKeys = new ArrayList<ProfileKey>();
/** The activation callback registry. */
- private List<ProfileNode> callbacks = new LinkedList<ProfileNode>();
+ private List<ProfileNode> callbacks = new ArrayList<ProfileNode>();
/** The unresolved requirements. */
private List<ProfileRequirement> unresolved = new ArrayList<ProfileRequirement>();
@@ -118,6 +117,10 @@
// Include it in the configuration
included.add(currentNode);
includedKeys.add(currentKey);
+ if(callbacks.contains(currentNode))
+ {
+ callbacks.remove(currentNode);
+ }
}
else
{
@@ -161,8 +164,8 @@
resolve(dependencyContext, true);
}
// If the dependency is already included we can mark it as non-optional
- boolean dependencyIncluded = included(depenencyNode);
- boolean optional = requirement.isOptional() && dependencyIncluded == false;
+ final boolean dependencyIncluded = included(depenencyNode);
+ final boolean optional = requirement.isOptional() && dependencyIncluded == false;
final ProfileNodeDependency dependency = new ProfileNodeDependency(requirement, currentKey, dependencyKey, optional);
// Add dependency information
@@ -197,7 +200,7 @@
// Process activation callbacks to determine if they can be included
for(Iterator<ProfileNode> i = callbacks.iterator() ; i.hasNext() ;)
{
- ProfileNode callback = i.next();
+ final ProfileNode callback = i.next();
if(included(callback) == false)
{
// Check if the activation callback can be resolved
@@ -246,7 +249,12 @@
return included.contains(node);
}
-
+ /**
+ * Get the dependency mode.
+ *
+ * @param requirement the profile requirement
+ * @return the dependency mode
+ */
static DependencyMode getDependencyMode(ProfileRequirement requirement)
{
DependencyMode mode = requirement.getDependencyMode();
@@ -289,7 +297,7 @@
final ProfileNode otherNode = getNode(dependsOnMe.getFrom());
if(included(otherNode) == false)
{
- throw new IllegalArgumentException("trying to activate non included node " + otherNode);
+ throw new IllegalStateException("trying to activate non included node " + otherNode);
}
// Mark my dependency as resolved
otherNode.markAsResolved(node.getKey());
@@ -321,7 +329,7 @@
*/
List<ProfileNode> getRoots()
{
- ArrayList<ProfileNode> roots = new ArrayList<ProfileNode>();
+ final ArrayList<ProfileNode> roots = new ArrayList<ProfileNode>();
for(Iterator<ProfileNode> i = included.iterator(); i.hasNext() ;)
{
ProfileNode node = i.next();
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/resolver/ProfileNode.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/resolver/ProfileNode.java 2010-02-09 16:04:06 UTC (rev 100759)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/resolver/ProfileNode.java 2010-02-09 16:04:39 UTC (rev 100760)
@@ -32,11 +32,11 @@
* @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
* @version $Revision$
*/
-public class ProfileNode
+class ProfileNode
{
/** The node key. */
- private ProfileKey key;
+ private final ProfileKey key;
/** I depend on. */
private List<ProfileNodeDependency> iDependOn = new LinkedList<ProfileNodeDependency>();
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/resolver/ProfileNodeDependency.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/resolver/ProfileNodeDependency.java 2010-02-09 16:04:06 UTC (rev 100759)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/resolver/ProfileNodeDependency.java 2010-02-09 16:04:39 UTC (rev 100760)
@@ -30,7 +30,7 @@
* @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
* @version $Revision$
*/
-public class ProfileNodeDependency
+class ProfileNodeDependency
{
/** The from node. */
Modified: projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/resolver/test/ActivationCallbackUnitTestCase.java
===================================================================
--- projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/resolver/test/ActivationCallbackUnitTestCase.java 2010-02-09 16:04:06 UTC (rev 100759)
+++ projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/resolver/test/ActivationCallbackUnitTestCase.java 2010-02-09 16:04:39 UTC (rev 100760)
@@ -46,6 +46,23 @@
List<String> result = resolve("callbacks.xml", "other", "activation-group1");
assertOrdering(result, "other", "test", "activation-group1");
}
+
+ public void testActivation2() throws Exception
+ {
+ List<String> result = resolve("callbacks.xml", "other", "activation-group1", "test2");
+ assertOrdering(result, "other", "test", "test2", "activation-group1");
+ }
+
+ public void testActivation3() throws Exception
+ {
+ List<String> result = resolve("callbacks.xml", "activation-group2", "test1", "other");
+ assertOrdering(result, "other", "test", "test1", "test2", "activation-group2");
+ }
+ public void testWait() throws Exception
+ {
+ Thread.sleep(3 * 60 * 1000);
+ }
+
}
Modified: projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/test/AbstractProfileServiceTest.java
===================================================================
--- projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/test/AbstractProfileServiceTest.java 2010-02-09 16:04:06 UTC (rev 100759)
+++ projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/test/AbstractProfileServiceTest.java 2010-02-09 16:04:39 UTC (rev 100760)
@@ -23,7 +23,6 @@
import java.net.URL;
-import org.jboss.dependency.spi.ControllerContext;
import org.jboss.kernel.Kernel;
import org.jboss.kernel.plugins.bootstrap.basic.BasicBootstrap;
import org.jboss.kernel.plugins.deployment.xml.BasicXMLDeployer;
@@ -105,6 +104,7 @@
}
}
+ @SuppressWarnings("deprecation")
protected <T> T getBean(String name, Class<T> clazz)
{
KernelRegistryEntry entry = getKernel().getRegistry().getEntry(name);
Modified: projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/test/BasicProfileServiceUnitTestCase.java
===================================================================
--- projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/test/BasicProfileServiceUnitTestCase.java 2010-02-09 16:04:06 UTC (rev 100759)
+++ projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/test/BasicProfileServiceUnitTestCase.java 2010-02-09 16:04:39 UTC (rev 100760)
@@ -26,6 +26,10 @@
import java.util.List;
import org.jboss.deployers.client.spi.main.MainDeployer;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.metadata.spi.MetaData;
+import org.jboss.metadata.spi.scope.CommonLevels;
+import org.jboss.metadata.spi.scope.ScopeKey;
import org.jboss.profileservice.config.ProfileServiceConstants;
import org.jboss.profileservice.dependency.ProfileDependencyContext;
import org.jboss.profileservice.dependency.ProfileMetaDataRegistry;
@@ -127,9 +131,18 @@
{
if(profile.getName().equals("test") == false)
{
- assertNotNull(profile.toString(), getController().getInstalledContext(profile));
+ KernelControllerContext context = (KernelControllerContext) getController().getInstalledContext(profile);
+ assertNotNull(profile.toString(), context);
+ ScopeKey key = context.getScopeInfo().getMutableScope();
+ MetaData md = context.getScopeInfo().getMetaData().getScopeMetaData(CommonLevels.SERVER);
+ for(Object o : md.getMetaData())
+ {
+ log.debug(o);
+ }
+
}
}
+
// reverse
Collections.reverse(list);
for(ProfileKey key : list)
Modified: projects/profileservice/trunk/core/src/test/resources/org/jboss/test/profileservice/resolver/test/callbacks.xml
===================================================================
--- projects/profileservice/trunk/core/src/test/resources/org/jboss/test/profileservice/resolver/test/callbacks.xml 2010-02-09 16:04:06 UTC (rev 100759)
+++ projects/profileservice/trunk/core/src/test/resources/org/jboss/test/profileservice/resolver/test/callbacks.xml 2010-02-09 16:04:39 UTC (rev 100760)
@@ -1,15 +1,22 @@
<profiles xmlns="urn:jboss:profileservice:profiles:1.0">
<profile name="activation-group1">
- <requires name="test" mode="activation-callback" />
+ <requires name="test" mode="activation-callback" />
</profile>
+
+ <profile name="activation-group2">
+ <requires name="test" mode="activation-callback" />
+ <requires name="test2" mode="activation-callback" />
+ <requires name="test1" optional="true" />
+ </profile>
<profile name="test">
<requires name="other" />
</profile>
<profile name="test1">
- <requires name="other" optional="true" />
+ <requires name="other" />
+ <requires name="test3" optional="true" />
</profile>
<profile name="test2">
@@ -17,6 +24,10 @@
<requires name="test1" optional="true" />
</profile>
+ <profile name="test3">
+ <requires name="test2" optional="true" />
+ </profile>
+
<profile name="other" />
</profiles>
\ No newline at end of file
Modified: projects/profileservice/trunk/core/src/test/resources/system/bootstrap.xml
===================================================================
--- projects/profileservice/trunk/core/src/test/resources/system/bootstrap.xml 2010-02-09 16:04:06 UTC (rev 100759)
+++ projects/profileservice/trunk/core/src/test/resources/system/bootstrap.xml 2010-02-09 16:04:39 UTC (rev 100760)
@@ -11,7 +11,7 @@
<property name="lifeCycleActions"><inject bean="ProfileLifeCycleCallbackActions" /></property>
</bean>
- <!-- The Profile Service -->
+ <!-- The Profile Service Bootstrap -->
<bean name="ProfileServiceBootstrap" class="org.jboss.test.profileservice.support.ProfileServiceBootstrap">
<constructor>
<parameter><inject bean="jboss.kernel:service=Kernel" /></parameter>
@@ -43,8 +43,15 @@
<uncallback method="removeProfileFactory" />
</bean>
+ <!-- The management action controller -->
+ <bean name="ActionController" class="org.jboss.profileservice.management.AbstractActionController">
+ <incallback method="addListener" />
+ <uncallback method="removeListener" />
+ </bean>
+
<!-- The lifecycle callback action registry -->
<bean name="ProfileLifeCycleCallbackActions" class="org.jboss.profileservice.dependency.plugin.ProfileLifeCycleCallbackActions">
+ <constructor><parameter><inject bean="ActionController" /></parameter></constructor>
<incallback method="addCallback" />
<uncallback method="removeCallback" />
</bean>
Modified: projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/AggregatingLocalManagementView.java
===================================================================
--- projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/AggregatingLocalManagementView.java 2010-02-09 16:04:06 UTC (rev 100759)
+++ projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/AggregatingLocalManagementView.java 2010-02-09 16:04:39 UTC (rev 100760)
@@ -22,13 +22,10 @@
package org.jboss.profileservice.plugins.management;
import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import org.jboss.profileservice.plugins.management.view.AbstractProfileView;
-import org.jboss.profileservice.plugins.management.view.ProfileViewWrapper;
-import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.plugins.spi.ProfileView;
/**
* The aggregating management view.
@@ -40,22 +37,17 @@
{
/** The profile views. */
- private List<ProfileViewWrapper> views = new CopyOnWriteArrayList<ProfileViewWrapper>();
-
- /** The views by key. */
- private Map<ProfileKey, ProfileViewWrapper> viewsByKey = new ConcurrentHashMap<ProfileKey, ProfileViewWrapper>();
-
- protected AggregatingLocalManagementView()
+ private List<ProfileView> views = new CopyOnWriteArrayList<ProfileView>();
+
+ public boolean load()
{
- //
- }
-
- public void load()
- {
- for(ProfileViewWrapper view : views)
+ boolean changed = false;
+ for(ProfileView view : views)
{
- view.load();
+ if(view.load())
+ changed = true;
}
+ return changed;
}
public void addProfileView(AbstractProfileView view)
@@ -68,9 +60,7 @@
{
throw new IllegalArgumentException("null profile key");
}
- ProfileViewWrapper wrapper = new ProfileViewWrapper(view);
- this.views.add(wrapper);
- this.viewsByKey.put(wrapper.getKey(), wrapper);
+ this.views.add(view);
}
public void removeProfileView(AbstractProfileView view)
@@ -83,11 +73,7 @@
{
throw new IllegalArgumentException("null profile key");
}
- ProfileViewWrapper wrapper = this.viewsByKey.get(view.getKey());
- if(wrapper != null)
- {
- this.views.remove(wrapper);
- }
+ this.views.remove(view);
}
}
Added: projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/util/AbstractManagementProxyFactory.java
===================================================================
--- projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/util/AbstractManagementProxyFactory.java (rev 0)
+++ projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/util/AbstractManagementProxyFactory.java 2010-02-09 16:04:39 UTC (rev 100760)
@@ -0,0 +1,60 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, 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.management.util;
+
+import org.jboss.managed.api.ManagedComponent;
+import org.jboss.managed.api.ManagedOperation;
+import org.jboss.managed.api.ManagedProperty;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public abstract class AbstractManagementProxyFactory
+{
+
+ /**
+ * Create a proxy component.
+ *
+ * @param delegate the delegate component
+ * @return the proxy component
+ */
+ protected abstract ManagedComponent createComponentProxy(ManagedComponent delegate);
+
+ /**
+ * Create a proxy property.
+ *
+ * @param delegate the delegate property
+ * @return the proxy property
+ */
+ protected abstract ManagedProperty createPropertyProxy(ManagedProperty delegate);
+
+ /**
+ * Create a proxy operation.
+ *
+ * @param delegate the delegate operation
+ * @return the proxy operation
+ */
+ protected abstract ManagedOperation createOperationProxy(ManagedOperation delegate);
+
+}
+
Added: projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/util/ManagedDeploymentProcessor.java
===================================================================
--- projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/util/ManagedDeploymentProcessor.java (rev 0)
+++ projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/util/ManagedDeploymentProcessor.java 2010-02-09 16:04:39 UTC (rev 100760)
@@ -0,0 +1,74 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, 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.management.util;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.deployers.spi.management.ContextStateMapper;
+import org.jboss.managed.api.DeploymentState;
+import org.jboss.managed.api.RunState;
+
+/**
+ * A helper to process managed deployments.
+ *
+ * TODO we need to change how ManagedDeployments/ManagedObjects/ManagedComponents
+ * are created. This is a temporary solution to make things work.
+ *
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class ManagedDeploymentProcessor
+{
+
+ /** The state mappings. */
+ private static final ContextStateMapper<RunState> runStateMapper;
+ private static final ContextStateMapper<DeploymentState> deploymentStateMapper;
+
+ static
+ {
+ // Set default run state mappings for mc beans/mbeans
+ Map<String, RunState> runStateMappings = new HashMap<String, RunState>();
+ runStateMappings.put("**ERROR**", RunState.FAILED);
+ runStateMappings.put("Not Installed", RunState.STOPPED);
+ runStateMappings.put("PreInstall", RunState.STOPPED);
+ runStateMappings.put("Described", RunState.STOPPED);
+ runStateMappings.put("Instantiated", RunState.STOPPED);
+ runStateMappings.put("Configured", RunState.STOPPED);
+ runStateMappings.put("Create", RunState.STOPPED);
+ runStateMappings.put("Start", RunState.STOPPED);
+ runStateMappings.put("Installed", RunState.RUNNING);
+
+ runStateMapper = new ContextStateMapper<RunState>(runStateMappings,
+ RunState.STARTING, RunState.STOPPED, RunState.FAILED, RunState.UNKNOWN);
+
+ Map<String, DeploymentState> deploymentMappings = new HashMap<String, DeploymentState>();
+ deploymentMappings.put("**ERROR**", DeploymentState.FAILED);
+ deploymentMappings.put("Not Installed", DeploymentState.STOPPED);
+ deploymentMappings.put("Installed", DeploymentState.STARTED);
+
+ deploymentStateMapper = new ContextStateMapper<DeploymentState>(deploymentMappings,
+ DeploymentState.STARTING, DeploymentState.STOPPING, DeploymentState.FAILED, DeploymentState.UNKNOWN);
+ }
+
+}
+
Copied: projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/util/RuntimeManagedObjectRegistry.java (from rev 99447, projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/view/RuntimeManagedObjectRegistry.java)
===================================================================
--- projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/util/RuntimeManagedObjectRegistry.java (rev 0)
+++ projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/util/RuntimeManagedObjectRegistry.java 2010-02-09 16:04:39 UTC (rev 100760)
@@ -0,0 +1,94 @@
+/*
+* 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.plugins.management.util;
+
+import java.util.Map;
+
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.util.collection.ConcurrentReferenceHashMap;
+import org.jboss.util.collection.ConcurrentReferenceHashMap.ReferenceType;
+
+/**
+ * Registry for runtime ManagedObjects.
+ *
+ * TODO we need to change the composition of managed objects.
+ *
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+class RuntimeManagedObjectRegistry
+{
+
+ /** The runtime managed objects. */
+ private Map<String, ManagedObject> runtimeMOs = new ConcurrentReferenceHashMap<String, ManagedObject>(ReferenceType.STRONG, ReferenceType.WEAK);
+
+ /**
+ * Get a registered runtime ManagedObject.
+ *
+ * @param name the runtime managed object name
+ * @return the runtime managed object, null if not available
+ */
+ public ManagedObject get(String name)
+ {
+ if(name == null)
+ {
+ throw new IllegalArgumentException("null runtime MO name");
+ }
+ return this.runtimeMOs.get(name);
+ }
+
+ /**
+ * Add a runtime ManagedObject.
+ *
+ * @param name the runtime managed object name
+ * @param mo the runtime managed object
+ */
+ public void put(String name, ManagedObject mo)
+ {
+ if(name == null)
+ {
+ throw new IllegalArgumentException("null runtime MO name");
+ }
+ if(mo == null)
+ {
+ throw new IllegalArgumentException("null runtime MO");
+ }
+ this.runtimeMOs.put(name, mo);
+ }
+
+ /**
+ * Remove a runtime ManagedObject from the registry.
+ *
+ * @param name the runtime managed object name
+ * @return the removed object or null if not registered
+ */
+ public ManagedObject remove(String name)
+ {
+ if(name == null)
+ {
+ throw new IllegalArgumentException("null name");
+ }
+ return this.runtimeMOs.remove(name);
+ }
+
+}
+
Modified: projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/view/AbstractProfileView.java
===================================================================
--- projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/view/AbstractProfileView.java 2010-02-09 16:04:06 UTC (rev 100759)
+++ projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/view/AbstractProfileView.java 2010-02-09 16:04:39 UTC (rev 100760)
@@ -29,6 +29,7 @@
import org.jboss.profileservice.spi.Profile;
import org.jboss.profileservice.spi.ProfileDeployment;
import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.metadata.ProfileMetaData;
/**
@@ -40,16 +41,22 @@
/** The profile. */
private final Profile profile;
+ private final ProfileMetaData metaData;
private final ProfileDeployerPlugin deployer;
- public AbstractProfileView(Profile profile, ProfileDeployerPlugin deployer)
+ public AbstractProfileView(Profile profile, ProfileMetaData metaData, ProfileDeployerPlugin deployer)
{
if(profile == null)
{
throw new IllegalArgumentException("null profile");
}
+ if(metaData == null)
+ {
+ throw new IllegalArgumentException("null profile meta data");
+ }
this.profile = profile;
this.deployer = deployer;
+ this.metaData = metaData;
}
public ProfileKey getKey()
@@ -71,13 +78,21 @@
return null;
}
- protected void load() throws Exception
+ public boolean load()
{
for(ProfileDeployment deployment : profile.getDeployments())
{
- ManagedDeployment md = deployer.getManagedDeployment(deployment);
+ try
+ {
+ ManagedDeployment md = deployer.getManagedDeployment(deployment);
+ }
+ catch(Exception e)
+ {
+
+ }
}
+ return true;
}
}
Deleted: projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/view/ProfileViewWrapper.java
===================================================================
--- projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/view/ProfileViewWrapper.java 2010-02-09 16:04:06 UTC (rev 100759)
+++ projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/view/ProfileViewWrapper.java 2010-02-09 16:04:39 UTC (rev 100760)
@@ -1,72 +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.plugins.management.view;
-
-import java.util.Collection;
-
-import org.jboss.managed.api.ManagedDeployment;
-import org.jboss.profileservice.plugins.spi.ProfileView;
-import org.jboss.profileservice.spi.ProfileKey;
-
-/**
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public class ProfileViewWrapper implements ProfileView
-{
-
- /** The wrapped view. */
- private ProfileView view;
-
- public ProfileViewWrapper(ProfileView view)
- {
- if(view == null)
- {
- throw new IllegalArgumentException("null profile view");
- }
- this.view = view;
- }
-
- public ProfileKey getKey()
- {
- return this.view.getKey();
- }
-
- public void load()
- {
-
- }
-
- @Override
- public Collection<String> getDeploymentNames()
- {
- return view.getDeploymentNames();
- }
-
- @Override
- public ManagedDeployment getManagedDeployment(String name)
- {
- return view.getManagedDeployment(name);
- }
-
-}
-
Deleted: projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/view/RuntimeManagedObjectRegistry.java
===================================================================
--- projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/view/RuntimeManagedObjectRegistry.java 2010-02-09 16:04:06 UTC (rev 100759)
+++ projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/view/RuntimeManagedObjectRegistry.java 2010-02-09 16:04:39 UTC (rev 100760)
@@ -1,92 +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.plugins.management.view;
-
-import java.util.Map;
-
-import org.jboss.managed.api.ManagedObject;
-import org.jboss.util.collection.ConcurrentReferenceHashMap;
-import org.jboss.util.collection.ConcurrentReferenceHashMap.ReferenceType;
-
-/**
- * Registry for runtime ManagedObjects.
- *
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-class RuntimeManagedObjectRegistry
-{
-
- /** The runtime managed objects. */
- private Map<String, ManagedObject> runtimeMOs = new ConcurrentReferenceHashMap<String, ManagedObject>(ReferenceType.STRONG, ReferenceType.WEAK);
-
- /**
- * Get a registered runtime ManagedObject.
- *
- * @param name the runtime managed object name
- * @return the runtime managed object, null if not available
- */
- public ManagedObject get(String name)
- {
- if(name == null)
- {
- throw new IllegalArgumentException("null runtime MO name");
- }
- return this.runtimeMOs.get(name);
- }
-
- /**
- * Add a runtime ManagedObject.
- *
- * @param name the runtime managed object name
- * @param mo the runtime managed object
- */
- public void put(String name, ManagedObject mo)
- {
- if(name == null)
- {
- throw new IllegalArgumentException("null runtime MO name");
- }
- if(mo == null)
- {
- throw new IllegalArgumentException("null runtime MO");
- }
- this.runtimeMOs.put(name, mo);
- }
-
- /**
- * Remove a runtime ManagedObject from the registry.
- *
- * @param name the runtime managed object name
- * @return the removed object or null if not registered
- */
- public ManagedObject remove(String name)
- {
- if(name == null)
- {
- throw new IllegalArgumentException("null name");
- }
- return this.runtimeMOs.remove(name);
- }
-
-}
-
Modified: projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/spi/ProfileView.java
===================================================================
--- projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/spi/ProfileView.java 2010-02-09 16:04:06 UTC (rev 100759)
+++ projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/spi/ProfileView.java 2010-02-09 16:04:39 UTC (rev 100760)
@@ -37,6 +37,13 @@
{
/**
+ * Load a profile view.
+ *
+ * @return if there were changes
+ */
+ boolean load();
+
+ /**
* Get the profile key.
*
* @return the profile key
Added: 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 (rev 0)
+++ projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/action/ProfileModificationActions.java 2010-02-09 16:04:39 UTC (rev 100760)
@@ -0,0 +1,49 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, 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.spi.action;
+
+import java.util.List;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public interface ProfileModificationActions<T extends ProfileModificationContext>
+{
+
+
+ /**
+ * Get the type of the action.
+ *
+ * @return the modification type
+ */
+ ProfileModificationType getType();
+
+ /**
+ * Get the modification actions.
+ *
+ * @return the actions
+ */
+ List<ProfileModificationAction<T>> getActions();
+
+}
+
Modified: projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/action/ProfileModificationContext.java
===================================================================
--- projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/action/ProfileModificationContext.java 2010-02-09 16:04:06 UTC (rev 100759)
+++ projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/action/ProfileModificationContext.java 2010-02-09 16:04:39 UTC (rev 100760)
@@ -36,13 +36,6 @@
* @return the target profile key
*/
ProfileKey getTargetProfile();
-
- /**
- * Get the type of the action.
- *
- * @return the modification type
- */
- ProfileModificationType getTYpe();
}
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-02-09 16:04:06 UTC (rev 100759)
+++ projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/action/engine/ActionController.java 2010-02-09 16:04:39 UTC (rev 100760)
@@ -21,10 +21,8 @@
*/
package org.jboss.profileservice.spi.action.engine;
-import java.util.List;
-
import org.jboss.profileservice.spi.ProfileKey;
-import org.jboss.profileservice.spi.action.ProfileModificationAction;
+import org.jboss.profileservice.spi.action.ProfileModificationActions;
/**
* @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
@@ -40,7 +38,7 @@
* @param actions the modification actions
* @return the modification status
*/
- ModificationStatus perfom(ProfileKey key, List<ProfileModificationAction<?>> actions);
+ ModificationStatus perfom(ProfileKey key, ProfileModificationActions<?> actions);
}
Modified: projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/action/engine/EventBus.java
===================================================================
--- projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/action/engine/EventBus.java 2010-02-09 16:04:06 UTC (rev 100759)
+++ projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/action/engine/EventBus.java 2010-02-09 16:04:39 UTC (rev 100760)
@@ -28,9 +28,25 @@
public interface EventBus
{
+ /**
+ * Add a listener.
+ *
+ * @param listener the listener
+ */
void addListener(ModificationListener listener);
+
+ /**
+ * Remove a listener
+ *
+ * @param listener the listener
+ */
void removeListener(ModificationListener listener);
+ /**
+ * Fire a modification event.
+ *
+ * @param event the modification event
+ */
void fireModificationEvent(ModificationEvent event);
}
Modified: projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/action/engine/ModificationListener.java
===================================================================
--- projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/action/engine/ModificationListener.java 2010-02-09 16:04:06 UTC (rev 100759)
+++ projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/action/engine/ModificationListener.java 2010-02-09 16:04:39 UTC (rev 100760)
@@ -22,11 +22,19 @@
package org.jboss.profileservice.spi.action.engine;
/**
+ * The modification listener.
+ *
* @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
* @version $Revision$
*/
public interface ModificationListener
{
+
+ /**
+ * Notify.
+ *
+ * @param event the modification event
+ */
void notify(ModificationEvent event);
}
Modified: projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/action/engine/ModificationStatus.java
===================================================================
--- projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/action/engine/ModificationStatus.java 2010-02-09 16:04:06 UTC (rev 100759)
+++ projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/action/engine/ModificationStatus.java 2010-02-09 16:04:39 UTC (rev 100760)
@@ -39,6 +39,7 @@
/**
* Get the failure exception.
+ *
* @return any failure exception associated with reaching the FAILED state.
*/
Exception getFailure();
Modified: projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/dependency/ProfileRequirementResolverPlugin.java
===================================================================
--- projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/dependency/ProfileRequirementResolverPlugin.java 2010-02-09 16:04:06 UTC (rev 100759)
+++ projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/dependency/ProfileRequirementResolverPlugin.java 2010-02-09 16:04:39 UTC (rev 100760)
@@ -47,7 +47,7 @@
* @param requirement the profile requirement
* @return the profileKey, null if not resolved
*/
- ProfileKey resolve(ProfileRequirement requirement);
+ ProfileKey resolve(T requirement);
}
Modified: projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/repository/Artifact.java
===================================================================
--- projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/repository/Artifact.java 2010-02-09 16:04:06 UTC (rev 100759)
+++ projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/repository/Artifact.java 2010-02-09 16:04:39 UTC (rev 100760)
@@ -21,7 +21,10 @@
*/
package org.jboss.profileservice.spi.repository;
+import java.io.IOException;
+import java.io.InputStream;
+
/**
* The artifact.
*
@@ -32,6 +35,13 @@
{
/**
+ * Get the repository id.
+ *
+ * @return the repository id.
+ */
+ ArtifactRepositoryId getRepository();
+
+ /**
* Get the last modified.
*
* @return last modified
@@ -39,11 +49,11 @@
long getLastModified();
/**
- * Get the repository id.
+ * Get the artifacts input stream.
*
- * @return the repository id.
+ * @return the input stream
*/
- ArtifactRepositoryId getRepository();
+ InputStream getInputStream() throws IOException;
}
More information about the jboss-cvs-commits
mailing list