[jboss-cvs] JBossAS SVN: r100965 - in projects/profileservice/trunk: core/src/main/java/org/jboss/profileservice/dependency and 21 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Feb 15 08:17:40 EST 2010
Author: emuckenhuber
Date: 2010-02-15 08:17:38 -0500 (Mon, 15 Feb 2010)
New Revision: 100965
Added:
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/DefaultAttachments.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/hotdeploy/
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/DefaultHDScannerFactory.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/deployment/hotdeploy/HDScannerFactory.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/hotdeploy/HDScannerLifeCycleCallback.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/hotdeploy/Scanner.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/hotdeploy/ScannerConfiguration.java
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/ManagedObjectProcessor.java
projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/util/ManagedObjectRuntimeProcessor.java
projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/deployment/
projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/deployment/DeploymentAttachments.java
projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/deployment/ProfileDeploymentFlag.java
projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/deployment/ProfileDeploymentInfo.java
Removed:
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/
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/ProfileViewProcessorHelper.java
projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/helpers/
Modified:
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/AbstractProfileService.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileDeployAction.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/plugin/ScanPeriod.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/plugin/ClassPathAdapterProfile.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/BasicProfileDeployment.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/virtual/AbstractVirtualDeploymentRepository.java
projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/virtual/assembly/StructureMetaDataBuilder.java
projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/deployment/test/HDScannerUnitTestCase.java
projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/repository/test/ArtifactRepositoryUnitTestCase.java
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/virtual/support/TestVirtualDeploymentRepository.java
projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/virtual/test/VirtualDeploymentAssemblyUnitTestCase.java
projects/profileservice/trunk/core/src/test/resources/system/static/deployment/hd-scanner-jboss-beans.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/RegisteredProfileViewsWrapper.java
projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/actions/ProfileViewUpdateAction.java
projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/view/AbstractProfileViewWrapper.java
projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/spi/ProfileViewWrapper.java
projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/mgt/test/AbstractViewTestBase.java
projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/DeploymentContentFlags.java
projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/DeploymentRepositoryFactory.java
projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/MutableProfile.java
projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/ProfileDeployment.java
projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/ProfileKey.java
projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/ProfileRepository.java
Log:
deprecate legacy repository spi, extract deploymentContentFlags to the deployment info and try to clean up the managed deployment processing a bit more
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-15 12:02:10 UTC (rev 100964)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/AbstractProfileService.java 2010-02-15 13:17:38 UTC (rev 100965)
@@ -282,7 +282,7 @@
{
JBossStringBuilder builder = new JBossStringBuilder();
builder.append("Profile: ").append(ctx.getName());
- builder.append(" in error due to ").append(ctx.getError().toString());
+ builder.append(" in error due to ").append(ctx.getError());
errors.add(builder.toString());
}
else
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-15 12:02:10 UTC (rev 100964)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/dependency/ProfileDeployAction.java 2010-02-15 13:17:38 UTC (rev 100965)
@@ -32,6 +32,7 @@
import org.jboss.profileservice.spi.NoSuchProfileException;
import org.jboss.profileservice.spi.Profile;
import org.jboss.profileservice.spi.ProfileDeployment;
+import org.jboss.profileservice.spi.deployment.ProfileDeploymentFlag;
/**
* deploy/undeploy action. This deploys/undeploys the profile deployments
@@ -85,6 +86,19 @@
}
// Deploy
deploy(profile, deployer);
+ // TODO add isCheckComplete flag.
+ try
+ {
+ for(ProfileDeployment deployment : profile.getDeployments())
+ {
+ deployer.checkComplete(deployment.getName());
+ }
+ }
+ catch(Exception e)
+ {
+ log.error(e);
+ throw e;
+ }
}
}
@@ -119,6 +133,8 @@
{
// Add deployment
deployer.addDeployment(deployment);
+ // mark as deployed
+ deployment.getDeploymentInfo().setFlag(ProfileDeploymentFlag.DEPLOYED);
}
catch(Exception e)
{
@@ -147,6 +163,8 @@
{
log.warn("failed to remove deployment: " + deployment, t);
}
+ // mark as not deployed
+ deployment.getDeploymentInfo().clearFlag(ProfileDeploymentFlag.DEPLOYED);
}
// undeploy
deployer.process();
Added: 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 (rev 0)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/AbstractDeploymentInfo.java 2010-02-15 13:17:38 UTC (rev 100965)
@@ -0,0 +1,86 @@
+/*
+* 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.deployment;
+
+import org.jboss.profileservice.spi.deployment.ProfileDeploymentFlag;
+import org.jboss.profileservice.spi.deployment.ProfileDeploymentInfo;
+
+/**
+ * The abstract deployment info.
+ *
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class AbstractDeploymentInfo implements ProfileDeploymentInfo
+{
+
+ /** The deployment name. */
+ private final String name;
+
+ /** The flags. */
+ private int dFlags = 0;
+
+ public AbstractDeploymentInfo(String name)
+ {
+ this.name = name;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getName()
+ {
+ return this.name;
+ }
+
+ @Override
+ public boolean hasFlag(ProfileDeploymentFlag flag)
+ {
+ return ((dFlags & flag.getFlag()) == flag.getFlag());
+ }
+
+ @Override
+ public boolean isDeployed()
+ {
+ return hasFlag(ProfileDeploymentFlag.DEPLOYED);
+ }
+
+ @Override
+ public boolean isLocked()
+ {
+ return hasFlag(ProfileDeploymentFlag.LOCKED);
+ }
+
+ @Override
+ public void setFlag(ProfileDeploymentFlag flag)
+ {
+ dFlags |= flag.getFlag();
+ }
+
+ @Override
+ public void clearFlag(ProfileDeploymentFlag flag)
+ {
+ dFlags &= ~flag.getFlag();
+ }
+
+}
+
Copied: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/AbstractProfileDeployment.java (from rev 100818, projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/helpers/AbstractProfileDeployment.java)
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/AbstractProfileDeployment.java (rev 0)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/AbstractProfileDeployment.java 2010-02-15 13:17:38 UTC (rev 100965)
@@ -0,0 +1,161 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.profileservice.deployment;
+
+import org.jboss.deployers.vfs.spi.client.VFSDeployment;
+import org.jboss.profileservice.spi.ProfileDeployment;
+import org.jboss.profileservice.spi.deployment.DeploymentAttachments;
+import org.jboss.profileservice.spi.deployment.ProfileDeploymentInfo;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * The abstract profile deployment.
+ *
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public abstract class AbstractProfileDeployment implements ProfileDeployment
+{
+
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 1536294883676418931L;
+
+ /** The deployment policy. */
+ private final ProfileDeploymentInfo policy;
+
+ /** The vfs root. */
+ private VirtualFile root;
+
+ /** The attachments. */
+ private DeploymentAttachments attachments = new DefaultAttachments();
+
+ /** The transient attachments. */
+ private transient DeploymentAttachments transientAttachments = new DefaultAttachments();
+
+ protected AbstractProfileDeployment(String name)
+ {
+ if(name == null)
+ {
+ throw new IllegalArgumentException("null name");
+ }
+ name = name.trim();
+ if(name.length() == 0)
+ {
+ throw new IllegalArgumentException("empty name");
+ }
+ this.policy = new AbstractDeploymentInfo(name);
+ }
+
+ /**
+ * Get the vfs file name safely.
+ * @see VFSDeployment
+ *
+ * @param root the virtual file
+ * @return the name
+ */
+ protected static final String safeVirtualFileName(VirtualFile root)
+ {
+ if (root == null)
+ throw new IllegalArgumentException("null root");
+
+ try
+ {
+ return root.toURI().toString();
+ }
+ catch (Exception e)
+ {
+ return root.getName();
+ }
+ }
+
+ /**
+ * Get the deployment name.
+ *
+ * @return the name
+ */
+ public String getName()
+ {
+ return this.policy.getName();
+ }
+
+ /**
+ * Get the root of the deployment.
+ *
+ * @return the root, or null if it's not a VFS deployment.
+ */
+ public VirtualFile getRoot()
+ {
+ return this.root;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getSimpleName()
+ {
+ if(root != null)
+ {
+ return getRoot().getName();
+ }
+ return getName();
+ }
+
+ /**
+ * Set the VirtualFile root.
+ *
+ * @param root the root
+ */
+ protected void setRoot(VirtualFile root)
+ {
+ if(root == null)
+ {
+ throw new IllegalArgumentException("null root");
+ }
+ this.root = root;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public ProfileDeploymentInfo getDeploymentInfo()
+ {
+ return this.policy;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public DeploymentAttachments getPredeterminedAttachments()
+ {
+ return attachments;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public DeploymentAttachments getTransientAttachments()
+ {
+ return transientAttachments;
+ }
+
+}
+
Added: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/DefaultAttachments.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/DefaultAttachments.java (rev 0)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/DefaultAttachments.java 2010-02-15 13:17:38 UTC (rev 100965)
@@ -0,0 +1,125 @@
+/*
+* 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.deployment;
+
+import java.util.Collections;
+import java.util.Map;
+
+import org.jboss.profileservice.spi.deployment.DeploymentAttachments;
+import org.jboss.util.collection.CollectionsFactory;
+
+/**
+ * The deployment attachments.
+ *
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class DefaultAttachments implements DeploymentAttachments
+{
+
+ /** The attachments. */
+ private Map<String, Object> attachments = CollectionsFactory.createLazyMap();
+
+ /**
+ * {@inheritDoc}
+ */
+ public Map<String, Object> getAttachments()
+ {
+ return Collections.unmodifiableMap(this.attachments);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object getAttachment(String name)
+ {
+ if(name == null)
+ {
+ throw new IllegalArgumentException("Null attachment name.");
+ }
+ return this.attachments.get(name);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public <T> T getAttachment(String name, Class<T> expectedType)
+ {
+ if(expectedType == null)
+ {
+ throw new IllegalArgumentException("null expected type");
+ }
+ Object attachment = getAttachment(name);
+ if(attachment == null)
+ {
+ return null;
+ }
+ if(expectedType.isInstance(attachment) == false)
+ {
+ throw new IllegalStateException("attachment " + name +
+ " with value " + attachment + " is not of the expected type " + expectedType);
+ }
+ return expectedType.cast(attachment);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object putAttachment(String name, Object attachment)
+ {
+ if(name == null)
+ {
+ throw new IllegalArgumentException("Null attachment name.");
+ }
+ if(attachment == null)
+ {
+ throw new IllegalArgumentException("Null attachment.");
+ }
+ return this.attachments.put(name, attachment);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object removeAttachment(String name)
+ {
+ if(name == null)
+ {
+ throw new IllegalArgumentException("Null attachment name.");
+ }
+ return this.attachments.remove(name);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean hasAttachment(String name)
+ {
+ if(name == null)
+ {
+ throw new IllegalArgumentException("Null attachment name.");
+ }
+ return this.attachments.containsKey(name);
+ }
+
+}
+
Copied: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/hotdeploy/AbstractHDScannerFactory.java (from rev 100913, projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/AbstractHDScannerFactory.java)
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/hotdeploy/AbstractHDScannerFactory.java (rev 0)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/hotdeploy/AbstractHDScannerFactory.java 2010-02-15 13:17:38 UTC (rev 100965)
@@ -0,0 +1,350 @@
+/*
+* 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.deployment.hotdeploy;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import org.jboss.logging.Logger;
+import org.jboss.profileservice.spi.MutableProfile;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.action.engine.ActionController;
+
+/**
+ * The HDScannerFactory represents a HDScanner registry for profiles, having
+ * different scan configurations.
+ *
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+abstract class AbstractHDScannerFactory implements HDScannerFactory
+{
+
+ /** The logger. */
+ protected static final Logger log = Logger.getLogger(HDScannerFactory.class);
+
+ /** The registered scans. */
+ private Map<ProfileKey, ScannerWrapper> registeredScans = new ConcurrentHashMap<ProfileKey, ScannerWrapper>();
+
+ /** The action controller. */
+ private final ActionController actionController;
+
+ /** Flag indicating if scanners can be scheduled. */
+ private final AtomicBoolean enabled = new AtomicBoolean(false);
+
+ protected AbstractHDScannerFactory(ActionController actionController)
+ {
+ if(actionController == null)
+ {
+ throw new IllegalArgumentException("null action controller");
+ }
+ this.actionController = actionController;
+ }
+
+ /**
+ * Schedule a HDScanner for execution.
+ *
+ * @param <T> the expected type
+ * @param scanner the hd scanner runnable
+ * @param scanPeriod the schedule interval
+ * @param timeUnit the schedule time unit
+ * @return the scheduled future
+ */
+ abstract <T extends Runnable> ScheduledFuture<Void> schedule(T scanner, int scanPeriod, TimeUnit timeUnit);
+
+ /**
+ * Stop and unregister all still active scanners.
+ */
+ public void stop()
+ {
+ // This should have been set already
+ enabled.set(false);
+ // Actually all scanners should be unregistered during the profile lifecycle
+ for(ProfileKey key : this.registeredScans.keySet())
+ {
+ unregisterScanner(key, true);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Scanner registerScanner(MutableProfile profile, ScannerConfiguration configuration)
+ {
+ if(profile == null)
+ {
+ throw new IllegalArgumentException("null profile");
+ }
+ ProfileKey key = profile.getKey();
+ if(key == null)
+ {
+ throw new IllegalArgumentException("null profile key");
+ }
+ if(configuration == null)
+ {
+ throw new IllegalArgumentException("null scanner configuration.");
+ }
+ if(this.registeredScans.containsKey(key))
+ {
+ throw new IllegalArgumentException("scanner already registered for profile " + key);
+ }
+ HDScanner scanner = new HDScanner(profile, null);
+ ScannerWrapper wrapper = createScannerWrapper(key, scanner, configuration);
+ if(wrapper.isStartAutomatically() && enabled.get())
+ {
+ wrapper.start();
+ }
+ return wrapper;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void activateScanner(ProfileKey key)
+ {
+ Scanner scanner = this.registeredScans.get(key);
+ if(scanner != null)
+ {
+ scanner.start();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void stopScanner(ProfileKey key)
+ {
+ Scanner scanner = this.registeredScans.get(key);
+ if(scanner != null)
+ {
+ scanner.stop();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Scanner unregisterScanner(ProfileKey key)
+ {
+ return unregisterScanner(key, false);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void enableScanning()
+ {
+ if(enabled.getAndSet(true) == false)
+ {
+ synchronized (registeredScans)
+ {
+ for(ScannerWrapper wrapper : registeredScans.values())
+ {
+ if(wrapper.isStartAutomatically())
+ {
+ wrapper.start();
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void disabledScanning()
+ {
+ if(enabled.getAndSet(false))
+ {
+ for(ProfileKey key : registeredScans.keySet())
+ {
+ stopScanner(key);
+ }
+ }
+ }
+
+ /**
+ * Schedule a HDScanner for execution.
+ *
+ * @param scanner the hd scanner
+ * @param configuration the scanner configuration
+ * @return the scheduled future
+ */
+ protected ScheduledFuture<Void> schedule(HDScanner scanner, ScannerConfiguration configuration)
+ {
+ if(enabled.get() == false)
+ {
+ throw new IllegalStateException("scanning is disabled");
+ }
+ if(this.registeredScans.containsKey(scanner.getKey()) == false)
+ {
+ throw new IllegalStateException("Scanner unregistered " + scanner.getKey());
+ }
+ return schedule(scanner, configuration.getScanPeriod(), configuration.getTimeUnit());
+ }
+
+ /**
+ * Internally unregister a scanner.
+ *
+ * @param key the profile key
+ * @param mayInterruptIfRunning interrupt if running
+ * @return the scanner
+ */
+ protected Scanner unregisterScanner(ProfileKey key, boolean mayInterruptIfRunning)
+ {
+ ScannerWrapper wrapper = this.registeredScans.remove(key);
+ if(wrapper != null)
+ {
+ wrapper.stop(mayInterruptIfRunning);
+ }
+ return wrapper;
+ }
+
+ /**
+ * Register a scanner and wrap it.
+ *
+ * @param key the associated profile key
+ * @param scanner the scanner
+ * @param activeScan the schedule future
+ * @return the scanner wrapper
+ */
+ protected ScannerWrapper createScannerWrapper(ProfileKey key, HDScanner scanner, ScannerConfiguration configuration)
+ {
+ ScannerWrapper wrapper = new ScannerWrapper(scanner, configuration);
+ this.registeredScans.put(key, wrapper);
+ return wrapper;
+ }
+
+ class ScannerWrapper implements Scanner, ScannerConfiguration
+ {
+ /** The scanner configuration. */
+ private final ScannerConfiguration configuration;
+ /** The actual scanner. */
+ private final HDScanner scanner;
+ /** The scanner future. */
+ private ScheduledFuture<Void> activeScan;
+
+ public ScannerWrapper(HDScanner scanner, ScannerConfiguration configuration)
+ {
+ this.scanner = scanner;
+ this.configuration = configuration;
+ }
+
+ @Override
+ public ProfileKey getKey()
+ {
+ return scanner.getKey();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int getScanPeriod()
+ {
+ return configuration.getScanPeriod();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public TimeUnit getTimeUnit()
+ {
+ return configuration.getTimeUnit();
+ }
+
+ @Override
+ public boolean isStartAutomatically()
+ {
+ return configuration.isStartAutomatically();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int getScanCount()
+ {
+ return scanner.getScanCount();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isScheduled()
+ {
+ return activeScan != null;
+ }
+
+ @Override
+ public synchronized void start()
+ {
+ if(activeScan == null)
+ {
+ activeScan = schedule(scanner, configuration);
+ }
+ }
+
+ @Override
+ public synchronized void scan() throws Exception
+ {
+ scanner.scan();
+ }
+
+ @Override
+ public synchronized void stop()
+ {
+ if (activeScan != null)
+ {
+ activeScan.cancel(false);
+ try
+ {
+ activeScan.get();
+ }
+ catch (Exception ignored)
+ {
+ }
+ activeScan = null;
+ }
+ }
+
+ protected synchronized void stop(boolean mayInterruptIfRunning)
+ {
+ if(activeScan != null)
+ {
+ activeScan.cancel(mayInterruptIfRunning);
+ activeScan = null;
+ }
+ }
+ }
+
+}
+
Property changes on: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/hotdeploy/AbstractHDScannerFactory.java
___________________________________________________________________
Name: svn:keywords
+ Id Date Revision
Copied: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/hotdeploy/DefaultHDScannerFactory.java (from rev 100913, projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/DefaultHDScannerFactory.java)
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/hotdeploy/DefaultHDScannerFactory.java (rev 0)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/hotdeploy/DefaultHDScannerFactory.java 2010-02-15 13:17:38 UTC (rev 100965)
@@ -0,0 +1,152 @@
+/*
+* 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.deployment.hotdeploy;
+
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.TimeUnit;
+
+import org.jboss.profileservice.spi.action.engine.ActionController;
+
+/**
+ * The default HDScanner factory.
+ *
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class DefaultHDScannerFactory extends AbstractHDScannerFactory
+{
+
+ /** The executor. */
+ private ScheduledExecutorService scanExecutor;
+
+ /** The thread factory. */
+ private ThreadFactory threadFactory;
+
+ /** Thread name used when the ScheduledExecutorService is created internally. */
+ private String scanThreadName = "HDScanner";
+
+ public DefaultHDScannerFactory(ActionController actionController)
+ {
+ super(actionController);
+ }
+
+ /**
+ * Get the optional thread factory used to create
+ * the ScheduledExcecutor.
+ *
+ * @return the thread factory
+ */
+ public ThreadFactory getThreadFactory()
+ {
+ return threadFactory;
+ }
+
+ /**
+ * Set the thread factory.
+ *
+ * @param threadFactory
+ */
+ public void setThreadFactory(ThreadFactory threadFactory)
+ {
+ this.threadFactory = threadFactory;
+ }
+
+
+ /**
+ * Get the scan thread name.
+ *
+ * @return the thread name
+ */
+ public String getScanThreadName()
+ {
+ return scanThreadName;
+ }
+
+ /**
+ * Set the scan thread name.
+ *
+ * @param scanThreadName the thread name
+ * @throws IllegalArgumentException for a null name
+ */
+ public void setScanThreadName(String scanThreadName)
+ {
+ if(scanThreadName == null)
+ {
+ throw new IllegalArgumentException("null thread name.");
+ }
+ this.scanThreadName = scanThreadName;
+ }
+
+ /**
+ * Start, creates a single thread executor if there
+ * was no executor injected before.
+ */
+ public void start()
+ {
+ if(this.threadFactory == null)
+ {
+ 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
+ public void stop()
+ {
+ super.stop();
+ // Shutdown the scanExecutor
+ try
+ {
+ scanExecutor.shutdownNow();
+ }
+ catch(Exception e)
+ {
+ log.debug("Failed to cleanly shutdown scanExecutor", e);
+ }
+ finally
+ {
+ scanExecutor = null;
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ @SuppressWarnings("unchecked")
+ <T extends Runnable> ScheduledFuture schedule(T scanner, int scanPeriod, TimeUnit timeUnit)
+ {
+ return scanExecutor.scheduleWithFixedDelay(scanner, scanPeriod, scanPeriod, timeUnit);
+ }
+
+}
+
Property changes on: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/hotdeploy/DefaultHDScannerFactory.java
___________________________________________________________________
Name: svn:keywords
+ Id Date Revision
Copied: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/hotdeploy/HDScanner.java (from rev 100913, projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/HDScanner.java)
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/hotdeploy/HDScanner.java (rev 0)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/hotdeploy/HDScanner.java 2010-02-15 13:17:38 UTC (rev 100965)
@@ -0,0 +1,185 @@
+/*
+* 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.deployment.hotdeploy;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.logging.Logger;
+import org.jboss.profileservice.deployment.ProfileDeployerPlugin;
+import org.jboss.profileservice.spi.ModificationInfo;
+import org.jboss.profileservice.spi.MutableProfile;
+import org.jboss.profileservice.spi.ProfileDeployment;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.action.deployment.DeploymentAction;
+
+/**
+ * The HDScanner.
+ *
+ * TODO This needs to be redone, since all deployment action should be using
+ * the actionController to get exclusive access to a profile. The checking and
+ * deployment should be part of a ModificationAction...
+ *
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+class HDScanner implements Runnable
+{
+
+ /** The logger. */
+ private static final Logger log = Logger.getLogger(HDScanner.class);
+
+ /** The number of scans that have been done. */
+ private int scanCount = 0;
+
+ /** The mutable profile. */
+ private final MutableProfile profile;
+
+ /** TODO we should not use the deployer here.
+ * @see DeploymentAction
+ */
+ private final ProfileDeployerPlugin deployer;
+
+ protected HDScanner(MutableProfile profile, ProfileDeployerPlugin plugin)
+ {
+ this.profile = profile;
+ this.deployer = plugin;
+ }
+
+ /**
+ * Get the profile key.
+ *
+ * @return the profile key
+ */
+ protected ProfileKey getKey()
+ {
+ return profile.getKey();
+ }
+
+ @Override
+ public void run()
+ {
+ try
+ {
+ scan();
+ }
+ catch (Throwable e)
+ {
+ log.warn("Scan failed", e);
+ }
+ finally
+ {
+ incScanCount();
+ }
+ }
+
+ /**
+ * Get the scan count.
+ *
+ * @return the scan count
+ */
+ protected synchronized int getScanCount()
+ {
+ return scanCount;
+ }
+
+ /**
+ * Reset the scan count.
+ */
+ protected synchronized void resetScanCount()
+ {
+ this.scanCount = 0;
+ }
+
+ /**
+ * Scan.
+ *
+ * @throws Exception
+ */
+ protected synchronized void scan() throws Exception
+ {
+ boolean trace = log.isTraceEnabled();
+ if(trace)
+ {
+ log.debug("Begin deployment scan: " + profile.getKey());
+ }
+ boolean modified = false;
+ Collection<String> modifiedDeploymentNames = new ArrayList<String>();
+ Collection<ModificationInfo> modifiedDeployments = profile.getModifiedDeployments();
+ for (ModificationInfo info : modifiedDeployments)
+ {
+ ProfileDeployment ctx = info.getDeployment();
+ try
+ {
+ switch (info.getStatus())
+ {
+ case ADDED:
+ case MODIFIED:
+ deployer.addDeployment(ctx);
+ modifiedDeploymentNames.add(ctx.getName());
+ break;
+ case REMOVED:
+ deployer.removeDeployment(ctx);
+ modified = true;
+ break;
+ }
+ }
+ catch(DeploymentException e)
+ {
+ log.warn("Failed to add deployment: " + ctx.getName(), e);
+ }
+ }
+ if (modifiedDeployments.size() > 0)
+ {
+ modified = true;
+ }
+ // Process the changes
+ if (modified)
+ {
+ deployer.process();
+ // 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);
+ }
+ }
+ }
+ if(trace)
+ {
+ log.trace("End deployment scan: " + profile.getKey());
+ }
+ }
+
+ /**
+ * Inc the scanCount and to a notifyAll.
+ */
+ protected synchronized void incScanCount()
+ {
+ scanCount++;
+ notifyAll();
+ }
+}
+
Property changes on: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/hotdeploy/HDScanner.java
___________________________________________________________________
Name: svn:keywords
+ Id Date Revision
Copied: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/hotdeploy/HDScannerFactory.java (from rev 100913, projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/HDScannerFactory.java)
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/hotdeploy/HDScannerFactory.java (rev 0)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/hotdeploy/HDScannerFactory.java 2010-02-15 13:17:38 UTC (rev 100965)
@@ -0,0 +1,87 @@
+/*
+* 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.deployment.hotdeploy;
+
+import org.jboss.profileservice.spi.MutableProfile;
+import org.jboss.profileservice.spi.ProfileKey;
+
+/**
+ * The HDScanner factory.
+ *
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public interface HDScannerFactory
+{
+
+ /**
+ * Enable the scanning. This is used
+ * when the deployment process is complete
+ * and the server is started to signal that
+ * the HDScanner can start.
+ *
+ * Scanners registered with startAutomatically
+ * enabled will be scheduled.
+ *
+ * Until this point no HDScanner is allowed to
+ * schedule itself using it's lifecycle methods.
+ */
+ void enableScanning();
+
+ /**
+ * Disable HDScanning. This will stop all
+ * registered scanners and prevent other
+ * HDScanners from starting.
+ */
+ void disabledScanning();
+
+ /**
+ * Register a mutable profile for HDScanning.
+ *
+ * @param profile the mutable profile
+ * @return the Scanner created
+ */
+ Scanner registerScanner(MutableProfile profile, ScannerConfiguration configuration);
+
+ /**
+ * Activate a scanner.
+ *
+ * @param key the profile key
+ */
+ void activateScanner(ProfileKey key);
+
+ /**
+ * Stop a scanner.
+ *
+ * @param key the profile key
+ */
+ void stopScanner(ProfileKey key);
+
+ /**
+ * Unregister a profile from HDScanning.
+ *
+ * @param key the profile key
+ */
+ Scanner unregisterScanner(ProfileKey key);
+
+}
+
Property changes on: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/hotdeploy/HDScannerFactory.java
___________________________________________________________________
Name: svn:keywords
+ Id Date Revision
Copied: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/hotdeploy/HDScannerLifeCycleCallback.java (from rev 100913, projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/HDScannerLifeCycleCallback.java)
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/hotdeploy/HDScannerLifeCycleCallback.java (rev 0)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/hotdeploy/HDScannerLifeCycleCallback.java 2010-02-15 13:17:38 UTC (rev 100965)
@@ -0,0 +1,78 @@
+/*
+* 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.deployment.hotdeploy;
+
+import org.jboss.profileservice.dependency.plugin.ProfileLifeCycleCallbackAction;
+import org.jboss.profileservice.spi.MutableProfile;
+import org.jboss.profileservice.spi.Profile;
+
+/**
+ * Lifecycle callback registering a HDScanner, for mutable profiles.
+ *
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class HDScannerLifeCycleCallback implements ProfileLifeCycleCallbackAction<ScannerConfiguration>
+{
+
+ /** The scanner configuration. */
+ private static final Class<ScannerConfiguration> namespace = ScannerConfiguration.class;
+
+ /** The HDScanner factory. */
+ private final HDScannerFactory hdScannerFactory;
+
+ public HDScannerLifeCycleCallback(HDScannerFactory hdScannerFactory)
+ {
+ if(hdScannerFactory == null)
+ {
+ throw new IllegalArgumentException("null HDScanner factory");
+ }
+ this.hdScannerFactory = hdScannerFactory;
+ }
+
+ @Override
+ public Class<ScannerConfiguration> getFeatureType()
+ {
+ return namespace;
+ }
+
+ @Override
+ public void install(Profile profile, ScannerConfiguration configuration)
+ {
+ if(profile.isMutable() && profile instanceof MutableProfile)
+ {
+ MutableProfile mutable = MutableProfile.class.cast(profile);
+ Scanner scanner = hdScannerFactory.registerScanner(mutable, configuration);
+ }
+ }
+
+ @Override
+ public void uninstall(Profile profile, ScannerConfiguration configuration)
+ {
+ if(profile.isMutable() && profile instanceof MutableProfile)
+ {
+ hdScannerFactory.unregisterScanner(profile.getKey());
+ }
+ }
+
+}
+
Property changes on: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/hotdeploy/HDScannerLifeCycleCallback.java
___________________________________________________________________
Name: svn:keywords
+ Id Date Revision
Copied: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/hotdeploy/Scanner.java (from rev 100913, projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/Scanner.java)
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/hotdeploy/Scanner.java (rev 0)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/hotdeploy/Scanner.java 2010-02-15 13:17:38 UTC (rev 100965)
@@ -0,0 +1,104 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.profileservice.deployment.hotdeploy;
+
+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.ManagementProperties;
+import org.jboss.managed.api.annotation.ManagementProperty;
+import org.jboss.profileservice.spi.ProfileKey;
+
+/**
+ * The scanner interface.
+ *
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ */
+// TODO check how to expose this scanner MO through PS
+ at ManagementObject(componentType = @ManagementComponent(type="Profile", subtype = "HDScanner"),
+ properties = ManagementProperties.EXPLICIT)
+public interface Scanner extends ScannerConfiguration
+{
+
+ /**
+ * Get the associated profile key.
+ *
+ * @return the profile key
+ */
+ @ManagementProperty(name = "profile", description = "The associated profile", readOnly = true)
+ @ManagementObjectID
+ ProfileKey getKey();
+
+ /**
+ * {@inheritDoc}
+ */
+ @ManagementProperty(name = "scan-period", description = "The scan period", readOnly = true)
+ public int getScanPeriod();
+
+ /**
+ * {@inheritDoc}
+ */
+ @ManagementProperty(name = "time-unit", description = "The time unit", readOnly = true)
+ public TimeUnit getTimeUnit();
+
+ /**
+ * Get the scan count.
+ *
+ * @return the scan count
+ */
+ @ManagementProperty(name = "scan-count", description = "The scan count", readOnly = true)
+ int getScanCount();
+
+ /**
+ * Boolean flag indicating if the scanner is scheduled.
+ *
+ * @return true if schedule
+ */
+ @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", impact = Impact.ReadOnly)
+ void stop();
+
+ /**
+ * Do scan.
+ *
+ * @throws Exception for any error
+ */
+ @ManagementOperation(name = "scan", description = "Scan the profile for modified deployments", impact = Impact.ReadWrite)
+ void scan() throws Exception;
+
+}
+
Property changes on: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/hotdeploy/Scanner.java
___________________________________________________________________
Name: svn:keywords
+ Id Date Revision
Copied: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/hotdeploy/ScannerConfiguration.java (from rev 100913, projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/hotdeploy/ScannerConfiguration.java)
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/hotdeploy/ScannerConfiguration.java (rev 0)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/hotdeploy/ScannerConfiguration.java 2010-02-15 13:17:38 UTC (rev 100965)
@@ -0,0 +1,65 @@
+/*
+* 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.deployment.hotdeploy;
+
+import java.util.concurrent.TimeUnit;
+
+import org.jboss.profileservice.spi.metadata.ProfileFeatureMetaData;
+
+/**
+ * The hot deployment scanner configuration.
+ *
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public interface ScannerConfiguration extends ProfileFeatureMetaData
+{
+
+ /**
+ * Get the scan period.
+ *
+ * @return the scan period
+ */
+ int getScanPeriod();
+
+ /**
+ * Get the time unit
+ *
+ * @return the time unit
+ */
+ TimeUnit getTimeUnit();
+
+ /**
+ * Boolean flag indicating if the scanner
+ * should be started automatically, once the
+ * boostrap deployment process is complete.
+ *
+ * When the server is started and the flag is
+ * set to true the scanner will be started
+ * as well.
+ *
+ * @return true if the should be started, false otherwise
+ */
+ boolean isStartAutomatically();
+
+}
+
Property changes on: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/deployment/hotdeploy/ScannerConfiguration.java
___________________________________________________________________
Name: svn:keywords
+ Id Date Revision
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/plugin/ScanPeriod.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/plugin/ScanPeriod.java 2010-02-15 12:02:10 UTC (rev 100964)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/metadata/plugin/ScanPeriod.java 2010-02-15 13:17:38 UTC (rev 100965)
@@ -28,7 +28,7 @@
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlValue;
-import org.jboss.profileservice.hotdeploy.ScannerConfiguration;
+import org.jboss.profileservice.deployment.hotdeploy.ScannerConfiguration;
import org.jboss.profileservice.profile.metadata.FeatureRequirement;
import org.jboss.profileservice.spi.metadata.ProfileFeatureMetaData;
import org.jboss.profileservice.spi.metadata.ProfileMetaDataVisitor;
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/plugin/ClassPathAdapterProfile.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/plugin/ClassPathAdapterProfile.java 2010-02-15 12:02:10 UTC (rev 100964)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/profile/plugin/ClassPathAdapterProfile.java 2010-02-15 13:17:38 UTC (rev 100965)
@@ -90,7 +90,7 @@
clMetaData.setRoots(roots);
// Create deployment
classPathDeployment = ProfileDeploymentFactory.getInstance().createDeployment(deploymentName);
- classPathDeployment.addAttachment(ClassLoadingMetaData.class.getName(), clMetaData);
+ classPathDeployment.getPredeterminedAttachments().putAttachment(ClassLoadingMetaData.class.getName(), clMetaData);
}
@Override
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/BasicProfileDeployment.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/BasicProfileDeployment.java 2010-02-15 12:02:10 UTC (rev 100964)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/BasicProfileDeployment.java 2010-02-15 13:17:38 UTC (rev 100965)
@@ -21,8 +21,7 @@
*/
package org.jboss.profileservice.repository;
-import org.jboss.profileservice.spi.helpers.AbstractProfileDeployment;
-import org.jboss.profileservice.spi.virtual.assembly.VirtualDeploymentAssemblyContext;
+import org.jboss.profileservice.deployment.AbstractProfileDeployment;
import org.jboss.virtual.VirtualFile;
/**
@@ -48,11 +47,5 @@
setRoot(vf);
}
- public BasicProfileDeployment(VirtualFile vf, VirtualDeploymentAssemblyContext ctx)
- {
- this(vf);
- addAttachment(VirtualDeploymentAssemblyContext.class.getName(), ctx);
- }
-
}
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/virtual/AbstractVirtualDeploymentRepository.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/virtual/AbstractVirtualDeploymentRepository.java 2010-02-15 12:02:10 UTC (rev 100964)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/repository/virtual/AbstractVirtualDeploymentRepository.java 2010-02-15 13:17:38 UTC (rev 100965)
@@ -65,7 +65,7 @@
throw new IllegalStateException("Assembled null virtual file");
}
ProfileDeployment profileDeployment = deploymentFactory.createDeployment(vf);
- profileDeployment.addAttachment(VirtualDeploymentAssemblyContext.class.getName(), ctx);
+ profileDeployment.getTransientAttachments().putAttachment(VirtualDeploymentAssemblyContext.class.getName(), ctx);
return profileDeployment;
}
Modified: projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/virtual/assembly/StructureMetaDataBuilder.java
===================================================================
--- projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/virtual/assembly/StructureMetaDataBuilder.java 2010-02-15 12:02:10 UTC (rev 100964)
+++ projects/profileservice/trunk/core/src/main/java/org/jboss/profileservice/virtual/assembly/StructureMetaDataBuilder.java 2010-02-15 13:17:38 UTC (rev 100965)
@@ -50,7 +50,7 @@
public Deployment processDeployment(ProfileDeployment deployment, Deployment target)
{
// Get the assembly context
- VirtualDeploymentAssemblyContext ctx = deployment.getAttachment(
+ VirtualDeploymentAssemblyContext ctx = deployment.getTransientAttachments().getAttachment(
VirtualDeploymentAssemblyContext.class.getName(), VirtualDeploymentAssemblyContext.class);
// Create the structure meta data
Modified: projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/deployment/test/HDScannerUnitTestCase.java
===================================================================
--- projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/deployment/test/HDScannerUnitTestCase.java 2010-02-15 12:02:10 UTC (rev 100964)
+++ projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/deployment/test/HDScannerUnitTestCase.java 2010-02-15 13:17:38 UTC (rev 100965)
@@ -26,9 +26,9 @@
import java.util.Set;
import java.util.concurrent.TimeUnit;
-import org.jboss.profileservice.hotdeploy.DefaultHDScannerFactory;
-import org.jboss.profileservice.hotdeploy.Scanner;
-import org.jboss.profileservice.hotdeploy.ScannerConfiguration;
+import org.jboss.profileservice.deployment.hotdeploy.DefaultHDScannerFactory;
+import org.jboss.profileservice.deployment.hotdeploy.Scanner;
+import org.jboss.profileservice.deployment.hotdeploy.ScannerConfiguration;
import org.jboss.profileservice.management.AbstractActionController;
import org.jboss.profileservice.spi.ModificationInfo;
import org.jboss.profileservice.spi.MutableProfile;
Modified: projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/repository/test/ArtifactRepositoryUnitTestCase.java
===================================================================
--- projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/repository/test/ArtifactRepositoryUnitTestCase.java 2010-02-15 12:02:10 UTC (rev 100964)
+++ projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/repository/test/ArtifactRepositoryUnitTestCase.java 2010-02-15 13:17:38 UTC (rev 100965)
@@ -65,7 +65,7 @@
{
ProfileDeployment d = factory.createDeployment(deployment);
assertNotNull(d);
- assertNotNull(d.getAttachment(VirtualDeploymentAssemblyContext.class.getName()));
+ assertNotNull(d.getTransientAttachments().getAttachment(VirtualDeploymentAssemblyContext.class.getName()));
}
}
}
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-15 12:02:10 UTC (rev 100964)
+++ projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/test/BasicProfileServiceUnitTestCase.java 2010-02-15 13:17:38 UTC (rev 100965)
@@ -34,9 +34,9 @@
import org.jboss.profileservice.dependency.ProfileDependencyContext;
import org.jboss.profileservice.dependency.ProfileMetaDataRegistry;
import org.jboss.profileservice.deployers.MainDeployerPlugin;
+import org.jboss.profileservice.deployment.hotdeploy.HDScannerFactory;
import org.jboss.profileservice.domain.spi.DomainFeatureNode;
import org.jboss.profileservice.domain.spi.DomainMetaData;
-import org.jboss.profileservice.hotdeploy.HDScannerFactory;
import org.jboss.profileservice.metadata.ProfileMetaDataFactory;
import org.jboss.profileservice.resolver.AbstractRequirementResolver;
import org.jboss.profileservice.spi.ProfileKey;
@@ -161,10 +161,5 @@
}
}
- public void testWait() throws Exception
- {
-
- }
-
}
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-02-15 12:02:10 UTC (rev 100964)
+++ projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/virtual/support/TestVirtualDeploymentRepository.java 2010-02-15 13:17:38 UTC (rev 100965)
@@ -70,7 +70,7 @@
throw new IllegalStateException("Assembled null virtual file");
}
ProfileDeployment profileDeployment = deploymentFactory.createDeployment(vf);
- profileDeployment.addAttachment(VirtualDeploymentAssemblyContext.class.getName(), ctx);
+ profileDeployment.getTransientAttachments().putAttachment(VirtualDeploymentAssemblyContext.class.getName(), ctx);
return profileDeployment;
}
Modified: projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/virtual/test/VirtualDeploymentAssemblyUnitTestCase.java
===================================================================
--- projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/virtual/test/VirtualDeploymentAssemblyUnitTestCase.java 2010-02-15 12:02:10 UTC (rev 100964)
+++ projects/profileservice/trunk/core/src/test/java/org/jboss/test/profileservice/virtual/test/VirtualDeploymentAssemblyUnitTestCase.java 2010-02-15 13:17:38 UTC (rev 100965)
@@ -25,6 +25,7 @@
import org.jboss.profileservice.spi.ProfileDeployment;
import org.jboss.profileservice.spi.VirtualDeploymentRepository;
+import org.jboss.profileservice.spi.deployment.ProfileDeploymentFlag;
import org.jboss.profileservice.spi.virtual.VirtualDeployment;
import org.jboss.profileservice.version.helpers.NameAndVersionRangeSupport;
import org.jboss.profileservice.virtual.deployment.AbstractVirtualDeployment;
@@ -46,7 +47,7 @@
{
super(name);
}
-
+
public void test() throws Exception
{
// Set the jboss.deployment.resources
@@ -63,6 +64,7 @@
AbstractVirtualDeployment simpleVD = (AbstractVirtualDeployment) deployments.get("simple.deployer");
ProfileDeployment simple = factory.createDeployment(simpleVD);
assertFalse("root must be a non-assembled file", simple.getRoot() instanceof AssembledDirectory);
+ testDeploymentFlags(simple);
log.debug(simple.getRoot());
// Test test.deployer
@@ -95,7 +97,7 @@
assertIncluded(subDeploymentRoot, new String[] {"test.jar"});
// Check requirement
resolves(deployerVD, deploymentVD.getRequires().get(0));
-
+ testDeploymentFlags(deployment);
log.debug(deployment.getRoot());
log.debug(subDeploymentRoot);
@@ -113,6 +115,24 @@
capability.resolves(
((AbstractVirtualDeploymentRequirement) requirement)));
}
-
+
+ protected void testDeploymentFlags(ProfileDeployment deployment)
+ {
+ assertFalse(deployment.getDeploymentInfo().isDeployed());
+ assertFalse(deployment.getDeploymentInfo().isLocked());
+ deployment.getDeploymentInfo().setFlag(ProfileDeploymentFlag.LOCKED);
+ assertFalse(deployment.getDeploymentInfo().isDeployed());
+ assertTrue(deployment.getDeploymentInfo().isLocked());
+ deployment.getDeploymentInfo().setFlag(ProfileDeploymentFlag.DEPLOYED);
+ assertTrue(deployment.getDeploymentInfo().isDeployed());
+ assertTrue(deployment.getDeploymentInfo().isLocked());
+ deployment.getDeploymentInfo().clearFlag(ProfileDeploymentFlag.DEPLOYED);
+ assertFalse(deployment.getDeploymentInfo().isDeployed());
+ assertTrue(deployment.getDeploymentInfo().isLocked());
+ deployment.getDeploymentInfo().clearFlag(ProfileDeploymentFlag.LOCKED);
+ assertFalse(deployment.getDeploymentInfo().isDeployed());
+ assertFalse(deployment.getDeploymentInfo().isLocked());
+ }
+
}
Modified: projects/profileservice/trunk/core/src/test/resources/system/static/deployment/hd-scanner-jboss-beans.xml
===================================================================
--- projects/profileservice/trunk/core/src/test/resources/system/static/deployment/hd-scanner-jboss-beans.xml 2010-02-15 12:02:10 UTC (rev 100964)
+++ projects/profileservice/trunk/core/src/test/resources/system/static/deployment/hd-scanner-jboss-beans.xml 2010-02-15 13:17:38 UTC (rev 100965)
@@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<deployment xmlns="urn:jboss:bean-deployer:2.0">
- <bean name="HDScannerFactory" class="org.jboss.profileservice.hotdeploy.DefaultHDScannerFactory" />
- <bean name="HDScannerCallbackAction" class="org.jboss.profileservice.hotdeploy.HDScannerLifeCycleCallback">
+ <bean name="HDScannerFactory" class="org.jboss.profileservice.deployment.hotdeploy.DefaultHDScannerFactory">
+ <constructor><parameter><inject bean="ActionController" /></parameter></constructor>
+ </bean>
+ <bean name="HDScannerCallbackAction" class="org.jboss.profileservice.deployment.hotdeploy.HDScannerLifeCycleCallback">
<constructor><parameter><inject bean="HDScannerFactory" /></parameter></constructor>
</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-15 12:02:10 UTC (rev 100964)
+++ projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/AggregatingLocalManagementView.java 2010-02-15 13:17:38 UTC (rev 100965)
@@ -41,7 +41,7 @@
import org.jboss.managed.api.ManagedComponent;
import org.jboss.managed.api.ManagedDeployment;
import org.jboss.profileservice.plugins.management.util.AbstractManagementProxyFactory;
-import org.jboss.profileservice.plugins.management.util.ProfileViewProcessorHelper;
+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.profileservice.spi.NoSuchDeploymentException;
@@ -81,7 +81,7 @@
private AbstractManagementProxyFactory proxyFactory;
/** The processor helper. */
- private ProfileViewProcessorHelper processorHelper;
+ private ManagedDeploymentProcessorHelper processorHelper;
public AggregatingLocalManagementView()
{
@@ -110,7 +110,7 @@
{
throw new IllegalStateException("null proxy factory");
}
- this.processorHelper = new ProfileViewProcessorHelper(proxyFactory);
+ this.processorHelper = new ManagedDeploymentProcessorHelper(proxyFactory);
}
/**
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-02-15 12:02:10 UTC (rev 100964)
+++ projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/RegisteredProfileViewsWrapper.java 2010-02-15 13:17:38 UTC (rev 100965)
@@ -35,7 +35,7 @@
import org.jboss.managed.api.ManagedComponent;
import org.jboss.managed.api.ManagedDeployment;
import org.jboss.profileservice.plugins.management.actions.ProfileViewUpdateAction;
-import org.jboss.profileservice.plugins.management.util.ProfileViewProcessorHelper;
+import org.jboss.profileservice.plugins.management.util.ManagedDeploymentProcessorHelper;
import org.jboss.profileservice.plugins.management.view.RegisteredProfileView;
import org.jboss.profileservice.plugins.spi.ProfileView;
import org.jboss.profileservice.plugins.spi.ProfileViewWrapper;
@@ -61,7 +61,7 @@
private Map<ProfileKey, RegisteredProfileView> viewsByName = new ConcurrentHashMap<ProfileKey, RegisteredProfileView>();
/** The helper. */
- private ProfileViewProcessorHelper helper;
+ private ManagedDeploymentProcessorHelper helper;
/** The action controller. */
private final ActionController controller;
@@ -84,21 +84,21 @@
// Additions
for(ProfileKey key : controller.getActiveProfiles())
{
- have.remove(key);
+ boolean exists = have.remove(key);
registeredKeys.add(key);
- RegisteredProfileView view = createProfileView(key);
- viewsByName.put(key, view);
-
- // TODO
- EventBus.class.cast(controller).addListener(view);
+ if(exists == false)
+ {
+ RegisteredProfileView view = createProfileView(key);
+ viewsByName.put(key, view);
+ getEventBus().addListener(view);
+ }
}
// Removals
for(ProfileKey key : have)
{
ProfileView view = viewsByName.remove(key);
- // TODO
- EventBus.class.cast(controller).removeListener(view);
+ getEventBus().removeListener(view);
changed = true;
}
// Load and process
@@ -125,10 +125,16 @@
return this.viewsByName.values();
}
+ protected EventBus getEventBus()
+ {
+ // TODO
+ return EventBus.class.cast(controller);
+ }
+
/**
* {@inheritDoc}
*/
- public void setProcessorHelper(ProfileViewProcessorHelper processorHelper)
+ public void setProcessorHelper(ManagedDeploymentProcessorHelper processorHelper)
{
this.helper = processorHelper;
}
Modified: projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/actions/ProfileViewUpdateAction.java
===================================================================
--- projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/actions/ProfileViewUpdateAction.java 2010-02-15 12:02:10 UTC (rev 100964)
+++ projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/actions/ProfileViewUpdateAction.java 2010-02-15 13:17:38 UTC (rev 100965)
@@ -21,10 +21,16 @@
*/
package org.jboss.profileservice.plugins.management.actions;
+import java.util.Collection;
+import java.util.HashSet;
+
+import org.jboss.deployers.spi.management.KnownDeploymentTypes;
import org.jboss.logging.Logger;
+import org.jboss.managed.api.DeploymentState;
import org.jboss.managed.api.ManagedDeployment;
+import org.jboss.managed.plugins.ManagedDeploymentImpl;
import org.jboss.profileservice.deployment.ProfileDeployerPlugin;
-import org.jboss.profileservice.plugins.management.util.ProfileViewProcessorHelper;
+import org.jboss.profileservice.plugins.management.util.ManagedDeploymentProcessorHelper;
import org.jboss.profileservice.plugins.spi.ProfileViewProcessingContext;
import org.jboss.profileservice.spi.Profile;
import org.jboss.profileservice.spi.ProfileDeployment;
@@ -33,6 +39,8 @@
import org.jboss.profileservice.spi.metadata.ProfileMetaData;
/**
+ * The <code>ProfileView</code> update action.
+ *
* @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
* @version $Revision$
*/
@@ -42,15 +50,23 @@
/** The logger. */
private static final Logger log = Logger.getLogger(ProfileViewUpdateAction.class);
+ /** The deployment types. */
+ static final String DEPLOYMENT_TYPES = KnownDeploymentTypes.class.getName();
+
+ /** is complete. */
private boolean complete = false;
-
+
+ // ----- TODO
+
Profile profile; // has to come from the ActionController
ProfileMetaData metaData; // has to come from the ActionController
ProfileDeployerPlugin deployer; // has to come from the ActionController
- ProfileViewProcessorHelper helper; // modification context ?
+ ManagedDeploymentProcessorHelper helper; // modification context ?
ProfileViewProcessingContext context;
-
+
+ // -----
+
@Override
public ProfileModificationContext getContext()
{
@@ -63,14 +79,33 @@
{
try
{
- ManagedDeployment md = deployer.getManagedDeployment(deployment);
- helper.processRootManagedDeployment(md, context);
+ if(deployment.getDeploymentInfo().isDeployed())
+ {
+ // Deployed
+ ManagedDeployment md = deployer.getManagedDeployment(deployment);
+ helper.processRootManagedDeployment(md, context);
+ if(md.getTypes() != null && md.getTypes().isEmpty() == false)
+ {
+ if(deployment.getTransientAttachments().hasAttachment(DEPLOYMENT_TYPES) == false)
+ {
+ deployment.getTransientAttachments().putAttachment(DEPLOYMENT_TYPES, md.getTypes());
+ }
+ }
+ }
+ else
+ {
+ // Not deployed
+ ManagedDeployment md = new ManagedDeploymentImpl(deployment.getName(), deployment.getSimpleName());
+ updateStoppedDeploymentTypes(deployment, md);
+ helper.processManagedDeployment(md, DeploymentState.STOPPED, 0, context);
+ }
}
catch(Exception e)
{
log.debug("failed to process managed deployment " + deployment.getName(), e);
}
- }
+ }
+ this.complete = true;
}
@Override
@@ -91,6 +126,32 @@
return complete;
}
+ @SuppressWarnings("unchecked")
+ protected void updateStoppedDeploymentTypes(ProfileDeployment deployment, ManagedDeployment md)
+ {
+ String deploymentName = deployment.getName();
+ // Try to get the cached deployment type
+ Collection<String> deploymentTypes = deployment
+ .getTransientAttachments().getAttachment(DEPLOYMENT_TYPES, Collection.class);
+
+ if(deploymentTypes != null)
+ {
+ md.setTypes(new HashSet<String>(deploymentTypes));
+ }
+ else
+ {
+ int i = deploymentName.lastIndexOf(".");
+ if(i != -1 && (i + 1) < deploymentName.length())
+ {
+ String guessedType = deploymentName.substring(i + 1, deploymentName.length());
+ if(guessedType.endsWith("/"))
+ guessedType = guessedType.substring(0, guessedType.length() -1 );
+ md.setTypes(new HashSet<String>(1));
+ md.addType(guessedType);
+ }
+ }
+ }
+
}
Deleted: 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 2010-02-15 12:02:10 UTC (rev 100964)
+++ projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/util/ManagedDeploymentProcessor.java 2010-02-15 13:17:38 UTC (rev 100965)
@@ -1,421 +0,0 @@
-/*
-* 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.lang.annotation.Annotation;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.jboss.logging.Logger;
-import org.jboss.managed.api.ComponentType;
-import org.jboss.managed.api.DeploymentState;
-import org.jboss.managed.api.ManagedComponent;
-import org.jboss.managed.api.ManagedDeployment;
-import org.jboss.managed.api.ManagedObject;
-import org.jboss.managed.api.ManagedOperation;
-import org.jboss.managed.api.ManagedProperty;
-import org.jboss.managed.api.MutableManagedObject;
-import org.jboss.managed.api.RunState;
-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.ManagementObjectRef;
-import org.jboss.managed.plugins.ManagedComponentImpl;
-import org.jboss.managed.plugins.ManagedDeploymentImpl;
-import org.jboss.managed.plugins.factory.AbstractManagedObjectFactory;
-import org.jboss.metatype.api.types.ArrayMetaType;
-import org.jboss.metatype.api.types.CollectionMetaType;
-import org.jboss.metatype.api.types.MetaType;
-import org.jboss.metatype.api.values.ArrayValue;
-import org.jboss.metatype.api.values.CollectionValue;
-import org.jboss.metatype.api.values.GenericValue;
-import org.jboss.metatype.api.values.MetaValue;
-import org.jboss.metatype.api.values.SimpleValue;
-import org.jboss.profileservice.plugins.spi.ProfileViewProcessingContext;
-
-/**
- * A helper to process managed deployments.
- *
- * TODO we need separate the registry out of the processor.
- *
- * TODO (long term) 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 abstract class ManagedDeploymentProcessor
-{
-
- /** The logger. */
- private static final Logger log = Logger.getLogger(ManagedDeploymentProcessor.class);
-
- /** id/type key to ManagedObject map */
- private Map<String, ManagedObject> moRegistry = new HashMap<String, ManagedObject>();
-
- /** The ManagedPropertys with unresolved ManagementObjectRefs */
- private Map<String, Set<ManagedProperty>> unresolvedRefs = new HashMap<String, Set<ManagedProperty>>();
-
- /** A map of runtime ManagedObjects needing to be merged with their matching ManagedObject. */
- private Map<String, ManagedObject> runtimeMOs = new HashMap<String, ManagedObject>();
-
- /**
- * FIXME clear()
- */
- public void clear()
- {
- moRegistry.clear();
- unresolvedRefs.clear();
- runtimeMOs.clear();
- }
-
- // runtime functionality
-
- protected abstract void mergeRuntimeMO(ManagedObject mo, ManagedObject runtimeMO) throws Exception;
-
- protected abstract Set<ManagedOperation> createOperationProxies(ManagedObject mo, Set<ManagedOperation> runtimeOps) throws Exception;
-
- protected abstract RunState updateRunState(ManagedObject mo, ManagedComponent comp) throws Exception;
-
- // use the implementation from the previous ManagementViewImpl
-
- protected void processManagedDeployment(ManagedDeployment md, DeploymentState state, int level, ProfileViewProcessingContext context) throws Exception
- {
- boolean trace = log.isTraceEnabled();
-
- String name = md.getName();
- if (trace)
- log.trace(name + " ManagedDeployment_" + level + ": " + md);
- Map<String, ManagedObject> mos = md.getManagedObjects();
- if (trace)
- log.trace(name + " ManagedObjects_ " + level + ": " + mos);
-
- // Set the deployment state
- if(state != null && md instanceof ManagedDeploymentImpl)
- ((ManagedDeploymentImpl)md).setDeploymentState(state);
-
- for(ManagedObject mo : mos.values())
- {
- processManagedObject(mo, md, context);
- }
- // Add the deployment
- context.addManagedDeployment(md);
-
- // Process children
- List<ManagedDeployment> mdChildren = md.getChildren();
- if(mdChildren != null && mdChildren.isEmpty() == false)
- {
- for(ManagedDeployment mdChild : mdChildren)
- {
- // process the child deployments, with the state of the parent.
- processManagedDeployment(mdChild, state, level + 1, context);
- }
- }
- }
-
- /**
- * Process managed object.
- *
- * @param mo the managed object
- * @param md the managed deployment
- */
- public void processManagedObject(ManagedObject mo, ManagedDeployment md, ProfileViewProcessingContext context)
- throws Exception
- {
- boolean trace = log.isTraceEnabled();
-
- String key = mo.getName() + "/" + mo.getNameType();
- if(trace)
- {
- log.trace("ID for ManagedObject: "+key+", attachmentName: "+mo.getAttachmentName());
- }
- // See if this is a runtime ManagedObject
- Map<String, Annotation> moAnns = mo.getAnnotations();
- ManagementObject managementObject = (ManagementObject) moAnns.get(ManagementObject.class.getName());
- if (managementObject.isRuntime())
- {
- boolean merged = false;
- ManagementComponent mc = managementObject.componentType();
- boolean isMC = !(mc.type().length() == 0 && mc.subtype().length() == 0);
-
- // Merge this with the ManagedObject
- ManagedObject parentMO = moRegistry.get(key);
- if (parentMO == null && isMC == false)
- {
- if(trace)
- {
- log.trace("Deferring resolution of runtime ManagedObject: "+managementObject);
- }
- // Save the runtime mo for merging
- runtimeMOs.put(key, mo);
- }
- else
- {
- mergeRuntimeMO(parentMO, mo);
- merged = true;
- runtimeMOs.remove(key);
- }
- // Update the runtime state of any ManagedComponent associated with this runtime mo
- if(md != null && md.getComponents() != null)
- {
- ManagedComponent comp = md.getComponent(mo.getName());
- if (comp != null)
- {
- RunState state = updateRunState(mo, comp);
- if(trace)
- {
- log.trace("Updated component: "+comp+" run state to: "+state);
- }
-
- }
- }
-
- // There is no further processing of runtime ManagedObjects, unless its marked as a component
- if (isMC == false)
- return;
- //
- else if (merged == false)
- {
- Set<ManagedOperation> runtimeOps = mo.getOperations();
- runtimeOps = createOperationProxies(mo, runtimeOps);
- MutableManagedObject moi = (MutableManagedObject) mo;
- moi.setOperations(runtimeOps);
- }
- }
- else
- {
- // See if there is runtime info to merge
- ManagedObject runtimeMO = runtimeMOs.get(key);
- if (runtimeMO != null)
- {
- mergeRuntimeMO(mo, runtimeMO);
- runtimeMOs.remove(key);
- // Update the runtime state of any ManagedComponent associated with this runtime mo
- if(md != null && md.getComponents() != null)
- {
- ManagedComponent comp = md.getComponent(mo.getName());
- if (comp != null)
- {
- RunState state = updateRunState(runtimeMO, comp);
- if(trace)
- {
- log.trace("Updated component: "+comp+" run state to: "+state);
- }
- }
- }
- }
- }
-
- // Check for unresolved refs
- checkForReferences(key, mo);
-
- // Map any existing ManagedComponent types
- if(md != null && md.getComponents() != null)
- {
- for(ManagedComponent comp : md.getComponents().values())
- {
- if(trace)
- {
- log.trace("Updating ManagementComponent: "+comp);
- }
- context.addManagedComponent(comp);
- }
- }
-
- // Create ManagedComponents for ManagedObjects annotated with ManagementComponent
- ManagementComponent mc = (ManagementComponent) moAnns.get(ManagementComponent.class.getName());
- if (mc != null)
- {
- ComponentType type = new ComponentType(mc.type(), mc.subtype());
- ManagedComponentImpl comp = new ManagedComponentImpl(type, md, mo);
- if(trace)
- {
- log.trace("Processing ManagementComponent("+mo.getName()+"): "+comp);
- }
- if(md != null && md.getComponent(mo.getName()) == null)
- {
- md.addComponent(mo.getName(), comp);
- }
- context.addManagedComponent(comp);
- updateRunState(null, comp);
- }
-
- // Scan for @ManagementObjectRef
- for(ManagedProperty prop : mo.getProperties().values())
- {
- // See if this is a ManagementObjectID
- Map<String, Annotation> pannotations = prop.getAnnotations();
- if (pannotations != null && pannotations.isEmpty() == false)
- {
- ManagementObjectID id = (ManagementObjectID) pannotations.get(ManagementObjectID.class.getName());
- if (id != null)
- {
- Object refName = getRefName(prop.getValue());
- if (refName == null)
- refName = id.name();
- String propKey = refName + "/" + id.type();
- if(trace)
- {
- log.trace("ManagedProperty level ID for ManagedObject: "+propKey+", attachmentName: "+mo.getAttachmentName());
- }
- moRegistry.put(propKey, mo);
- checkForReferences(propKey, mo);
- }
- // See if this is a ManagementObjectRef
- ManagementObjectRef ref = (ManagementObjectRef) pannotations.get(ManagementObjectRef.class.getName());
- if ( ref != null )
- {
- // The reference key is the prop value + ref.type()
- if(trace)
- {
- log.trace("Property("+prop.getName()+") references: "+ref);
- }
- Object refName = getRefName(prop.getValue());
- if (refName == null)
- refName = ref.name();
- String targetKey = refName + "/" + ref.type();
- ManagedObject target = moRegistry.get(targetKey);
- if (target != null)
- {
- if(trace)
- {
- log.trace("Resolved property("+prop.getName()+") reference to: "+targetKey);
- }
- prop.setTargetManagedObject(target);
- }
- else
- {
- Set<ManagedProperty> referers = unresolvedRefs.get(targetKey);
- if (referers == null)
- {
- referers = new HashSet<ManagedProperty>();
- unresolvedRefs.put(targetKey, referers);
- }
- referers.add(prop);
- }
- }
- }
-
- MetaType propType = prop.getMetaType();
- if (propType == AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE)
- {
- processGenericValue ((GenericValue)prop.getValue(), md, context);
- }
- else if (propType.isArray())
- {
- ArrayMetaType amt = (ArrayMetaType) propType;
- MetaType etype = amt.getElementType();
- if (etype == AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE)
- {
- ArrayValue avalue = (ArrayValue) prop.getValue();
- int length = avalue != null ? avalue.getLength() : 0;
- for(int n = 0; n < length; n ++)
- processGenericValue((GenericValue) avalue.getValue(n), md, context);
- }
- }
- else if (propType.isCollection())
- {
- CollectionMetaType amt = (CollectionMetaType) propType;
- MetaType etype = amt.getElementType();
- if (etype == AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE)
- {
- CollectionValue avalue = (CollectionValue) prop.getValue();
- if(avalue != null)
- {
- MetaValue[] elements = avalue.getElements();
- for(int n = 0; n < avalue.getSize(); n ++)
- {
- GenericValue gv = (GenericValue) elements[n];
- ManagedObject propMO = (ManagedObject) gv.getValue();
- if(propMO != null)
- processManagedObject(propMO, md, context);
- }
- }
- }
- }
- }
- }
-
- /**
- * Get ref name.
- *
- * @param value property value
- * @return plain value
- */
- protected Object getRefName(Object value)
- {
- if (value instanceof MetaValue)
- {
- MetaValue metaValue = (MetaValue)value;
- if (metaValue.getMetaType().isSimple() == false)
- throw new IllegalArgumentException("Can only get ref from simple value: " + value);
- SimpleValue svalue = (SimpleValue) metaValue;
- return svalue.getValue();
- }
- return value;
- }
-
- /**
- * Check for references.
- *
- * @param key the property key
- * @param mo the managed object
- */
- protected void checkForReferences(String key, ManagedObject mo)
- {
- Set<ManagedProperty> referers = unresolvedRefs.get(key);
- log.trace("checkForReferences, "+key+" has referers: "+referers);
- if (referers != null)
- {
- for(ManagedProperty prop : referers)
- {
- prop.setTargetManagedObject(mo);
- }
- unresolvedRefs.remove(key);
- }
- }
-
- /**
- * Process generic value.
- *
- * @param genericValue the generic value
- * @param md the managed deployment
- * @throws Exception for any error
- */
- protected void processGenericValue(GenericValue genericValue, ManagedDeployment md, ProfileViewProcessingContext context) throws Exception
- {
- // TODO: a null is probably an error condition
- if (genericValue != null)
- {
- ManagedObject propMO = (ManagedObject) genericValue.getValue();
- // TODO: a null is probably an error condition
- if (propMO != null)
- processManagedObject(propMO, md, context);
- }
- }
-
-
-}
-
Copied: projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/util/ManagedDeploymentProcessorHelper.java (from rev 100821, projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/util/ProfileViewProcessorHelper.java)
===================================================================
--- projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/util/ManagedDeploymentProcessorHelper.java (rev 0)
+++ projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/util/ManagedDeploymentProcessorHelper.java 2010-02-15 13:17:38 UTC (rev 100965)
@@ -0,0 +1,145 @@
+/*
+* 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.management.util;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.deployers.spi.management.ContextStateMapper;
+import org.jboss.logging.Logger;
+import org.jboss.managed.api.DeploymentState;
+import org.jboss.managed.api.ManagedDeployment;
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.plugins.ManagedDeploymentImpl;
+import org.jboss.profileservice.plugins.spi.ProfileViewProcessingContext;
+
+/**
+ * The profile view processor helper.
+ *
+ * TODO we need to make the this stateless.
+ *
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class ManagedDeploymentProcessorHelper extends ManagedObjectRuntimeProcessor
+{
+
+ /** The logger. */
+ private static final Logger log = Logger.getLogger(ManagedDeploymentProcessorHelper.class);
+
+ /** The deployment states. */
+ private static final ContextStateMapper<DeploymentState> deploymentStateMapper;
+
+ static
+ {
+ 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 DefaultContextStateMapper<DeploymentState>(deploymentMappings,
+ DeploymentState.STARTING, DeploymentState.STOPPING, DeploymentState.FAILED, DeploymentState.UNKNOWN);
+ }
+
+ public ManagedDeploymentProcessorHelper(AbstractManagementProxyFactory proxyFactory)
+ {
+ super(proxyFactory);
+ }
+
+ /**
+ * Process a root managed deployment.
+ *
+ * @param md the managed deployment
+ * @param context the profile view context
+ * @throws Exception
+ */
+ public void processRootManagedDeployment(ManagedDeployment md, ProfileViewProcessingContext context) throws Exception
+ {
+ DeploymentState state = getDeploymentState(md);
+ processManagedDeployment(md, state, 0, context);
+ }
+
+ /**
+ * Process a managed deployment.
+ *
+ * @param md the managed deployment
+ * @param state the deployment state
+ * @param level the level
+ * @param context the profile view context
+ * @throws Exception
+ */
+ public void processManagedDeployment(ManagedDeployment md, DeploymentState state, int level, ProfileViewProcessingContext context) throws Exception
+ {
+ boolean trace = log.isTraceEnabled();
+
+ String name = md.getName();
+ if (trace)
+ {
+ log.trace(name + " ManagedDeployment_" + level + ": " + md);
+ }
+
+ // Set the deployment state
+ if(state != null && md instanceof ManagedDeploymentImpl)
+ ManagedDeploymentImpl.class.cast(md).setDeploymentState(state);
+
+ Map<String, ManagedObject> mos = md.getManagedObjects();
+ for(ManagedObject mo : mos.values())
+ {
+ processManagedObject(mo, md, context);
+ }
+ // Add the deployment
+ context.addManagedDeployment(md);
+
+ // Process children
+ List<ManagedDeployment> mdChildren = md.getChildren();
+ if(mdChildren != null && mdChildren.isEmpty() == false)
+ {
+ for(ManagedDeployment mdChild : mdChildren)
+ {
+ // process the child deployments, with the state of the parent.
+ processManagedDeployment(mdChild, state, level + 1, context);
+ }
+ }
+ }
+
+ /**
+ * Get the deployment state.
+ *
+ * @param md the managed deployment
+ * @return the deployment state
+ */
+ protected DeploymentState getDeploymentState(ManagedDeployment md)
+ {
+ DeploymentState state = md.getDeploymentState();
+ if (state == DeploymentState.UNKNOWN)
+ {
+ Object name = md.getName();
+ if (name != null)
+ {
+ state = getMappedState(name, deploymentStateMapper);
+ }
+ }
+ return state;
+ }
+
+}
Copied: projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/util/ManagedObjectProcessor.java (from rev 100913, 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/ManagedObjectProcessor.java (rev 0)
+++ projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/util/ManagedObjectProcessor.java 2010-02-15 13:17:38 UTC (rev 100965)
@@ -0,0 +1,349 @@
+/*
+* 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.lang.annotation.Annotation;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.logging.Logger;
+import org.jboss.managed.api.ComponentType;
+import org.jboss.managed.api.ManagedComponent;
+import org.jboss.managed.api.ManagedDeployment;
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.managed.api.RunState;
+import org.jboss.managed.api.annotation.ManagementComponent;
+import org.jboss.managed.api.annotation.ManagementObjectID;
+import org.jboss.managed.api.annotation.ManagementObjectRef;
+import org.jboss.managed.plugins.ManagedComponentImpl;
+import org.jboss.managed.plugins.factory.AbstractManagedObjectFactory;
+import org.jboss.metatype.api.types.ArrayMetaType;
+import org.jboss.metatype.api.types.CollectionMetaType;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.values.ArrayValue;
+import org.jboss.metatype.api.values.CollectionValue;
+import org.jboss.metatype.api.values.GenericValue;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValue;
+import org.jboss.profileservice.plugins.spi.ProfileViewProcessingContext;
+
+/**
+ * A helper to process managed deployments.
+ *
+ * TODO we need separate the registry out of the processor.
+ *
+ * TODO (long term) 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 abstract class ManagedObjectProcessor
+{
+
+ /** The logger. */
+ private static final Logger log = Logger.getLogger(ManagedObjectProcessor.class);
+
+ /** id/type key to ManagedObject map */
+ private Map<String, ManagedObject> moRegistry = new HashMap<String, ManagedObject>();
+
+ /** The ManagedPropertys with unresolved ManagementObjectRefs */
+ private Map<String, Set<ManagedProperty>> unresolvedRefs = new HashMap<String, Set<ManagedProperty>>();
+
+ // runtime functionality
+
+ /**
+ * Update the RunState of a managed component
+ *
+ * @param runtimeMO the runtime ManagedObject
+ * @param comp the managed component
+ * @return the run state
+ */
+ protected abstract RunState updateRunState(ManagedObject runtimeMO, ManagedComponent comp);
+
+ //
+
+ /**
+ * FIXME clear()
+ */
+ public void clear()
+ {
+ moRegistry.clear();
+ unresolvedRefs.clear();
+ }
+
+ /**
+ * Process a managed object
+ *
+ * @param mo the managed object
+ * @param md the managed deployment
+ * @param context the profile view
+ * @throws Exception
+ */
+ public void processManagedObject(ManagedObject mo, ManagedDeployment md, ProfileViewProcessingContext context)
+ throws Exception
+ {
+ boolean trace = log.isTraceEnabled();
+ String key = mo.getName() + "/" + mo.getNameType();
+ if(trace)
+ {
+ log.trace("ID for ManagedObject: "+key+", attachmentName: "+mo.getAttachmentName());
+ }
+ processManagedObject(key, mo, md, context);
+ }
+
+ /**
+ * Get a registered managed object
+ *
+ * @param key the managed object key
+ * @return the managed object
+ */
+ protected ManagedObject getRegisteredManagedObject(String key)
+ {
+ return this.moRegistry.get(key);
+ }
+
+ /**
+ * Process managed object.
+ *
+ * @param mo the managed object
+ * @param md the managed deployment
+ */
+ protected void processManagedObject(String key, ManagedObject mo, ManagedDeployment md, ProfileViewProcessingContext context)
+ throws Exception
+ {
+ boolean trace = log.isTraceEnabled();
+
+ // Check for unresolved refs
+ checkForReferences(key, mo);
+
+ // Map any existing ManagedComponent types
+ if(md != null && md.getComponents() != null)
+ {
+ for(ManagedComponent comp : md.getComponents().values())
+ {
+ if(trace)
+ {
+ log.trace("Updating ManagementComponent: "+comp);
+ }
+ context.addManagedComponent(comp);
+ }
+ }
+
+ // Create ManagedComponents for ManagedObjects annotated with ManagementComponent
+ ManagementComponent mc = getAnnotation(mo, ManagementComponent.class);
+ if (mc != null)
+ {
+ ComponentType type = new ComponentType(mc.type(), mc.subtype());
+ ManagedComponentImpl comp = new ManagedComponentImpl(type, md, mo);
+ if(trace)
+ {
+ log.trace("Processing ManagementComponent("+mo.getName()+"): "+comp);
+ }
+ if(md != null && md.getComponent(mo.getName()) == null)
+ {
+ md.addComponent(mo.getName(), comp);
+ }
+ context.addManagedComponent(comp);
+ updateRunState(null, comp);
+ }
+
+ // Scan for @ManagementObjectRef
+ // Process nested ManagedObjects
+ for(ManagedProperty prop : mo.getProperties().values())
+ {
+ // See if this is a ManagementObjectID
+ Map<String, Annotation> pannotations = prop.getAnnotations();
+ if (pannotations != null && pannotations.isEmpty() == false)
+ {
+ ManagementObjectID id = (ManagementObjectID) pannotations.get(ManagementObjectID.class.getName());
+ if (id != null)
+ {
+ Object refName = getRefName(prop.getValue());
+ if (refName == null)
+ {
+ refName = id.name();
+ }
+ String propKey = refName + "/" + id.type();
+ if(trace)
+ {
+ log.trace("ManagedProperty level ID for ManagedObject: "+propKey+", attachmentName: "+mo.getAttachmentName());
+ }
+ moRegistry.put(propKey, mo);
+ checkForReferences(propKey, mo);
+ }
+ // See if this is a ManagementObjectRef
+ ManagementObjectRef ref = (ManagementObjectRef) pannotations.get(ManagementObjectRef.class.getName());
+ if ( ref != null )
+ {
+ // The reference key is the prop value + ref.type()
+ if(trace)
+ {
+ log.trace("Property("+prop.getName()+") references: "+ref);
+ }
+ Object refName = getRefName(prop.getValue());
+ if (refName == null)
+ {
+ refName = ref.name();
+ }
+ String targetKey = refName + "/" + ref.type();
+ ManagedObject target = moRegistry.get(targetKey);
+ if (target != null)
+ {
+ if(trace)
+ {
+ log.trace("Resolved property("+prop.getName()+") reference to: "+targetKey);
+ }
+ prop.setTargetManagedObject(target);
+ }
+ else
+ {
+ Set<ManagedProperty> referers = unresolvedRefs.get(targetKey);
+ if (referers == null)
+ {
+ referers = new HashSet<ManagedProperty>();
+ unresolvedRefs.put(targetKey, referers);
+ }
+ referers.add(prop);
+ }
+ }
+ }
+
+ // Process generic values and extract nested ManagedObjects
+ MetaType propType = prop.getMetaType();
+ if (propType == AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE)
+ {
+ processGenericValue ((GenericValue)prop.getValue(), md, context);
+ }
+ else if (propType.isArray())
+ {
+ ArrayMetaType amt = (ArrayMetaType) propType;
+ MetaType etype = amt.getElementType();
+ if (etype == AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE)
+ {
+ ArrayValue avalue = (ArrayValue) prop.getValue();
+ int length = avalue != null ? avalue.getLength() : 0;
+ for(int n = 0; n < length; n ++)
+ {
+ processGenericValue((GenericValue) avalue.getValue(n), md, context);
+ }
+ }
+ }
+ else if (propType.isCollection())
+ {
+ CollectionMetaType amt = (CollectionMetaType) propType;
+ MetaType etype = amt.getElementType();
+ if (etype == AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE)
+ {
+ CollectionValue avalue = (CollectionValue) prop.getValue();
+ if(avalue != null)
+ {
+ MetaValue[] elements = avalue.getElements();
+ for(int n = 0; n < avalue.getSize(); n ++)
+ {
+ processGenericValue((GenericValue) elements[n], md, context);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Get ref name.
+ *
+ * @param value property value
+ * @return plain value
+ */
+ protected Object getRefName(Object value)
+ {
+ if (value instanceof MetaValue)
+ {
+ MetaValue metaValue = MetaValue.class.cast(value);
+ if (metaValue.getMetaType().isSimple() == false)
+ {
+ throw new IllegalArgumentException("Can only get ref from simple value: " + value);
+ }
+ return SimpleValue.class.cast(metaValue).getValue();
+ }
+ return value;
+ }
+
+ /**
+ * Check for references.
+ *
+ * @param key the property key
+ * @param mo the managed object
+ */
+ protected void checkForReferences(String key, ManagedObject mo)
+ {
+ Set<ManagedProperty> referers = unresolvedRefs.get(key);
+ log.trace("checkForReferences, "+key+" has referers: "+referers);
+ if (referers != null)
+ {
+ for(ManagedProperty prop : referers)
+ {
+ prop.setTargetManagedObject(mo);
+ }
+ unresolvedRefs.remove(key);
+ }
+ }
+
+ /**
+ * Process generic value.
+ *
+ * @param genericValue the generic value
+ * @param md the managed deployment
+ * @throws Exception for any error
+ */
+ protected void processGenericValue(GenericValue genericValue, ManagedDeployment md, ProfileViewProcessingContext context) throws Exception
+ {
+ // TODO: a null is probably an error condition
+ if (genericValue != null)
+ {
+ ManagedObject propMO = (ManagedObject) genericValue.getValue();
+ // TODO: a null is probably an error condition
+ if (propMO != null)
+ {
+ processManagedObject(propMO, md, context);
+ }
+ }
+ }
+
+ /**
+ * Get the annotation.
+ *
+ * @param <T> the expected type
+ * @param mo the managed object
+ * @param annotationType the annotation type
+ * @return the annotation
+ */
+ protected <T> T getAnnotation(ManagedObject mo, Class<T> annotationType)
+ {
+ return annotationType.cast(mo.getAnnotations().get(annotationType.getName()));
+ }
+
+}
+
Added: projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/util/ManagedObjectRuntimeProcessor.java
===================================================================
--- projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/util/ManagedObjectRuntimeProcessor.java (rev 0)
+++ projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/util/ManagedObjectRuntimeProcessor.java 2010-02-15 13:17:38 UTC (rev 100965)
@@ -0,0 +1,395 @@
+/*
+* 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.management.util;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.deployers.spi.management.ContextStateMapper;
+import org.jboss.deployers.spi.management.RuntimeComponentDispatcher;
+import org.jboss.logging.Logger;
+import org.jboss.managed.api.ManagedComponent;
+import org.jboss.managed.api.ManagedDeployment;
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.api.ManagedOperation;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.managed.api.MutableManagedComponent;
+import org.jboss.managed.api.MutableManagedObject;
+import org.jboss.managed.api.RunState;
+import org.jboss.managed.api.annotation.ManagementComponent;
+import org.jboss.managed.api.annotation.ManagementObject;
+import org.jboss.managed.api.annotation.ViewUse;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.profileservice.plugins.spi.ProfileViewProcessingContext;
+
+/**
+ * A helper to process runtime managed objects.
+ *
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public abstract class ManagedObjectRuntimeProcessor extends ManagedObjectProcessor
+{
+
+ /** The logger. */
+ private static final Logger log = Logger.getLogger(ManagedObjectRuntimeProcessor.class);
+
+ /** A map of runtime ManagedObjects needing to be merged with their matching ManagedObject. */
+ private Map<String, ManagedObject> runtimeMOs = new HashMap<String, ManagedObject>();
+
+ /** The state mappings. */
+ private static final ContextStateMapper<RunState> runStateMapper;
+
+ /** The runtime component dispatcher. */
+ private final RuntimeComponentDispatcher dispatcher;
+
+ /** The proxy factory. */
+ private final AbstractManagementProxyFactory proxyFactory;
+
+ 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 DefaultContextStateMapper<RunState>(runStateMappings, RunState.STARTING, RunState.STOPPED,
+ RunState.FAILED, RunState.UNKNOWN);
+ }
+
+ public ManagedObjectRuntimeProcessor(AbstractManagementProxyFactory proxyFactory)
+ {
+ if (proxyFactory == null)
+ throw new IllegalArgumentException("null proxy factory");
+ if (proxyFactory.getDispatcher() == null)
+ throw new IllegalArgumentException("null runtime component dispatcher");
+
+ this.proxyFactory = proxyFactory;
+ this.dispatcher = proxyFactory.getDispatcher();
+ }
+
+ @Override
+ public void clear()
+ {
+ super.clear();
+ this.runtimeMOs.clear();
+ }
+
+ protected void processManagedObject(String key, ManagedObject mo, ManagedDeployment md,
+ ProfileViewProcessingContext context) throws Exception
+ {
+ boolean trace = log.isTraceEnabled();
+
+ ManagementObject managementObject = getAnnotation(mo, ManagementObject.class);
+ if (managementObject.isRuntime())
+ {
+ boolean merged = false;
+ ManagementComponent mc = managementObject.componentType();
+ boolean isMC = !(mc.type().length() == 0 && mc.subtype().length() == 0);
+
+ // Merge this with the ManagedObject
+ ManagedObject parentMO = getRegisteredManagedObject(key);
+ if (parentMO == null && isMC == false)
+ {
+ if (trace)
+ {
+ log.trace("Deferring resolution of runtime ManagedObject: " + managementObject);
+ }
+ // Save the runtime mo for merging
+ runtimeMOs.put(key, mo);
+ }
+ else
+ {
+ mergeRuntimeMO(parentMO, mo);
+ merged = true;
+ runtimeMOs.remove(key);
+ }
+ // Update the runtime state of any ManagedComponent associated with this runtime mo
+ if (md != null && md.getComponents() != null)
+ {
+ ManagedComponent comp = md.getComponent(mo.getName());
+ if (comp != null)
+ {
+ RunState state = updateRunState(mo, comp);
+ if (trace)
+ {
+ log.trace("Updated component: " + comp + " run state to: " + state);
+ }
+
+ }
+ }
+
+ // There is no further processing of runtime ManagedObjects, unless its marked as a component
+ if (isMC == false)
+ return;
+ //
+ else if (merged == false)
+ {
+ Set<ManagedOperation> runtimeOps = mo.getOperations();
+ runtimeOps = createOperationProxies(mo, runtimeOps);
+ MutableManagedObject moi = (MutableManagedObject) mo;
+ moi.setOperations(runtimeOps);
+ }
+ }
+ else
+ {
+ // See if there is runtime info to merge
+ ManagedObject runtimeMO = runtimeMOs.get(key);
+ if (runtimeMO != null)
+ {
+ mergeRuntimeMO(mo, runtimeMO);
+ runtimeMOs.remove(key);
+ // Update the runtime state of any ManagedComponent associated with this runtime mo
+ if (md != null && md.getComponents() != null)
+ {
+ ManagedComponent comp = md.getComponent(mo.getName());
+ if (comp != null)
+ {
+ RunState state = updateRunState(runtimeMO, comp);
+ if (trace)
+ {
+ log.trace("Updated component: " + comp + " run state to: " + state);
+ }
+ }
+ }
+ }
+ }
+ // Process the managed object
+ super.processManagedObject(key, mo, md, context);
+ }
+
+ /**
+ * Merge the runtime ManagedObject
+ *
+ * @param mo the managed object
+ * @param runtimeMO the runtime managed object
+ * @throws Exception
+ */
+ protected void mergeRuntimeMO(ManagedObject mo, ManagedObject runtimeMO) throws Exception
+ {
+ boolean trace = log.isTraceEnabled();
+
+ Map<String, ManagedProperty> runtimeProps = runtimeMO.getProperties();
+ Set<ManagedOperation> runtimeOps = runtimeMO.getOperations();
+ // Get the runtime MO component name
+ Object componentName = runtimeMO.getComponentName();
+ if (trace)
+ {
+ log.trace("Merging runtime: " + runtimeMO.getName() + ", compnent name: " + componentName);
+ }
+ Map<String, ManagedProperty> moProps = null;
+ Set<ManagedOperation> moOps = null;
+ HashMap<String, ManagedProperty> props = null;
+ HashSet<ManagedOperation> ops = null;
+ // If mo is null, the merge target is the runtimeMO
+ if (mo == null)
+ {
+ // Just proxy the runtime props/ops
+ mo = runtimeMO;
+ moProps = mo.getProperties();
+ moOps = mo.getOperations();
+ // These will be updated with the proxied values, don't duplicate props/ops
+ props = new HashMap<String, ManagedProperty>();
+ ops = new HashSet<ManagedOperation>();
+ }
+ else
+ {
+ // Merge the runtime props/ops
+ moProps = mo.getProperties();
+ moOps = mo.getOperations();
+ props = new HashMap<String, ManagedProperty>(moProps);
+ ops = new HashSet<ManagedOperation>(moOps);
+ }
+
+ if (runtimeProps != null && runtimeProps.size() > 0)
+ {
+ if (trace)
+ {
+ log.trace("Properties before:" + props);
+ }
+ // We need to pull the runtime values for stats
+ for (ManagedProperty prop : runtimeProps.values())
+ {
+ if (prop.hasViewUse(ViewUse.STATISTIC))
+ {
+ String propName = prop.getMappedName();
+ try
+ {
+ // RuntimeComponentDispatcher.setActiveProperty(prop);
+ MetaValue propValue = dispatcher.get(componentName, propName);
+ if (propValue != null)
+ prop.setValue(propValue);
+ }
+ catch (Throwable t)
+ {
+ log.debug("Failed to get stat value, " + componentName + ":" + propName);
+ }
+ ManagedProperty proxiedProp = createPropertyProxy(prop);
+ props.put(prop.getName(), proxiedProp);
+ }
+ else
+ {
+ props.put(prop.getName(), prop);
+ }
+ // Keep the property associated with the runtime MO for invocations/updates
+ if (prop.getTargetManagedObject() == null)
+ prop.setTargetManagedObject(runtimeMO);
+ }
+ if (trace)
+ {
+ log.trace("Properties after:" + props);
+ }
+ }
+ if (runtimeOps != null && runtimeOps.size() > 0)
+ {
+ if (trace)
+ {
+ log.trace("Ops before:" + ops);
+ }
+ runtimeOps = createOperationProxies(runtimeMO, runtimeOps);
+ ops.addAll(runtimeOps);
+ if (trace)
+ {
+ log.trace("Ops after:" + ops);
+ }
+ }
+ MutableManagedObject moi = (MutableManagedObject) mo;
+ moi.setProperties(props);
+ moi.setOperations(ops);
+ }
+
+ /**
+ * Create a proxy for managed operations.
+ *
+ * @param mo the managed object
+ * @param ops the managed operations
+ * @return a set of proxied managed operations
+ * @throws Exception
+ */
+ protected Set<ManagedOperation> createOperationProxies(ManagedObject mo, Set<ManagedOperation> ops) throws Exception
+ {
+ if (proxyFactory == null)
+ throw new IllegalArgumentException("Missing RuntimeComponentDispatcher.");
+
+ Object componentName = mo.getComponentName();
+ return createOperationProxies(ops, componentName);
+ }
+
+ /**
+ * Create a proxy for managed operations.
+ *
+ * @param ops the managed operations
+ * @param componentName the runtime component name
+ * @return a set of proxied managed operations
+ * @throws Exception
+ */
+ protected Set<ManagedOperation> createOperationProxies(Set<ManagedOperation> ops, Object componentName)
+ throws Exception
+ {
+ // Create the delegate operation
+ Set<ManagedOperation> operations = new HashSet<ManagedOperation>();
+ for (ManagedOperation op : ops)
+ {
+ ManagedOperation operation = proxyFactory.createOperationProxy(op, componentName);
+ operations.add(operation);
+ }
+ return operations;
+ }
+
+ /**
+ * Create a proxy for a managed property
+ *
+ * @param prop the managed property
+ * @return the proxied managed property
+ * @throws Exception
+ */
+ private ManagedProperty createPropertyProxy(ManagedProperty prop) throws Exception
+ {
+ if (proxyFactory == null)
+ throw new IllegalArgumentException("Missing RuntimeComponentDispatcher.");
+
+ // Create the delegate property
+ Object componentName = prop.getManagedObject().getComponentName();
+ return proxyFactory.createPropertyProxy(prop, componentName);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected RunState updateRunState(ManagedObject runtimeMO, ManagedComponent comp)
+ {
+ RunState state = comp.getRunState();
+ if (state == RunState.UNKNOWN && dispatcher != null)
+ {
+ Object name = comp.getComponentName();
+ if (name == null && runtimeMO != null)
+ name = runtimeMO.getComponentName();
+ if (name != null)
+ {
+ state = getMappedState(name, runStateMapper);
+ if (comp instanceof MutableManagedComponent)
+ {
+ MutableManagedComponent mcomp = MutableManagedComponent.class.cast(comp);
+ mcomp.setRunState(state);
+ }
+ }
+ }
+ return state;
+ }
+
+ /**
+ * Get the mapped state.
+ *
+ * @param <T> the enum type
+ * @param name the runtime component name
+ * @param mapper the context mapper
+ * @return the state
+ */
+ protected <T extends Enum<?>> T getMappedState(Object name, ContextStateMapper<T> mapper)
+ {
+ T state = null;
+ if (dispatcher != null)
+ {
+ try
+ {
+ //TODO, update RuntimeComponentDispatcher
+ RuntimeComponentDispatcher xdispatcher = dispatcher;
+ state = xdispatcher.mapControllerState(name, mapper);
+ }
+ catch (Exception e)
+ {
+ state = mapper.getErrorState();
+ }
+ }
+ return state;
+ }
+
+}
Deleted: projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/util/ProfileViewProcessorHelper.java
===================================================================
--- projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/util/ProfileViewProcessorHelper.java 2010-02-15 12:02:10 UTC (rev 100964)
+++ projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/util/ProfileViewProcessorHelper.java 2010-02-15 13:17:38 UTC (rev 100965)
@@ -1,296 +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.management.util;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.jboss.deployers.spi.management.ContextStateMapper;
-import org.jboss.deployers.spi.management.RuntimeComponentDispatcher;
-import org.jboss.logging.Logger;
-import org.jboss.managed.api.DeploymentState;
-import org.jboss.managed.api.ManagedComponent;
-import org.jboss.managed.api.ManagedDeployment;
-import org.jboss.managed.api.ManagedObject;
-import org.jboss.managed.api.ManagedOperation;
-import org.jboss.managed.api.ManagedProperty;
-import org.jboss.managed.api.MutableManagedComponent;
-import org.jboss.managed.api.MutableManagedObject;
-import org.jboss.managed.api.RunState;
-import org.jboss.managed.api.annotation.ViewUse;
-import org.jboss.metatype.api.values.MetaValue;
-import org.jboss.profileservice.plugins.spi.ProfileViewProcessingContext;
-
-/**
- * The profile view processor helper.
- *
- * TODO we need to make the this stateless.
- *
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public class ProfileViewProcessorHelper extends ManagedDeploymentProcessor
-{
-
- /** The logger. */
- private static final Logger log = Logger.getLogger(ProfileViewProcessorHelper.class);
-
- /** The state mappings. */
- private static final ContextStateMapper<RunState> runStateMapper;
- private static final ContextStateMapper<DeploymentState> deploymentStateMapper;
-
- /** The runtime component dispatcher. */
- private RuntimeComponentDispatcher dispatcher;
-
- /** The proxy factory. */
- private AbstractManagementProxyFactory proxyFactory;
-
- 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 DefaultContextStateMapper<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 DefaultContextStateMapper<DeploymentState>(deploymentMappings,
- DeploymentState.STARTING, DeploymentState.STOPPING, DeploymentState.FAILED, DeploymentState.UNKNOWN);
- }
-
- public ProfileViewProcessorHelper(AbstractManagementProxyFactory proxyFactory)
- {
- if(proxyFactory == null)
- throw new IllegalArgumentException("null proxy factory");
- if(proxyFactory.getDispatcher() == null)
- throw new IllegalArgumentException("null runtime component dispatcher");
-
- this.proxyFactory = proxyFactory;
- this.dispatcher = proxyFactory.getDispatcher();
- }
-
- public void processRootManagedDeployment(ManagedDeployment md, ProfileViewProcessingContext context) throws Exception
- {
- DeploymentState state = getDeploymentState(md);
- processManagedDeployment(md, state, 0, context);
- }
-
- @Override
- protected void mergeRuntimeMO(ManagedObject mo, ManagedObject runtimeMO)
- throws Exception
- {
- boolean trace = log.isTraceEnabled();
-
- Map<String, ManagedProperty> runtimeProps = runtimeMO.getProperties();
- Set<ManagedOperation> runtimeOps = runtimeMO.getOperations();
- // Get the runtime MO component name
- Object componentName = runtimeMO.getComponentName();
- if(trace)
- {
- log.trace("Merging runtime: "+runtimeMO.getName()+", compnent name: "+componentName);
- }
- Map<String, ManagedProperty> moProps = null;
- Set<ManagedOperation> moOps = null;
- HashMap<String, ManagedProperty> props = null;
- HashSet<ManagedOperation> ops = null;
- // If mo is null, the merge target is the runtimeMO
- if (mo == null)
- {
- // Just proxy the runtime props/ops
- mo = runtimeMO;
- moProps = mo.getProperties();
- moOps = mo.getOperations();
- // These will be updated with the proxied values, don't duplicate props/ops
- props = new HashMap<String, ManagedProperty>();
- ops = new HashSet<ManagedOperation>();
- }
- else
- {
- // Merge the runtime props/ops
- moProps = mo.getProperties();
- moOps = mo.getOperations();
- props = new HashMap<String, ManagedProperty>(moProps);
- ops = new HashSet<ManagedOperation>(moOps);
- }
-
- if (runtimeProps != null && runtimeProps.size() > 0)
- {
- if(trace)
- {
- log.trace("Properties before:"+props);
- }
- // We need to pull the runtime values for stats
- for(ManagedProperty prop : runtimeProps.values())
- {
- if(prop.hasViewUse(ViewUse.STATISTIC))
- {
- String propName = prop.getMappedName();
- try
- {
- // RuntimeComponentDispatcher.setActiveProperty(prop);
- MetaValue propValue = dispatcher.get(componentName, propName);
- if(propValue != null)
- prop.setValue(propValue);
- }
- catch(Throwable t)
- {
- log.debug("Failed to get stat value, "+componentName+":"+propName);
- }
- ManagedProperty proxiedProp = createPropertyProxy(prop);
- props.put(prop.getName(), proxiedProp);
- }
- else
- {
- props.put(prop.getName(), prop);
- }
- // Keep the property associated with the runtime MO for invocations/updates
- if (prop.getTargetManagedObject() == null)
- prop.setTargetManagedObject(runtimeMO);
- }
- if(trace)
- {
- log.trace("Properties after:"+props);
- }
- }
- if (runtimeOps != null && runtimeOps.size() > 0)
- {
- if(trace)
- {
- log.trace("Ops before:"+ops);
- }
- runtimeOps = createOperationProxies(runtimeMO, runtimeOps);
- ops.addAll(runtimeOps);
- if(trace)
- {
- log.trace("Ops after:"+ops);
- }
- }
- MutableManagedObject moi = (MutableManagedObject) mo;
- moi.setProperties(props);
- moi.setOperations(ops);
- }
-
- @Override
- protected Set<ManagedOperation> createOperationProxies(ManagedObject mo, Set<ManagedOperation> ops)
- throws Exception
- {
- if (proxyFactory == null)
- throw new IllegalArgumentException("Missing RuntimeComponentDispatcher.");
-
- Object componentName = mo.getComponentName();
- return createOperationProxies(ops, componentName);
- }
-
- protected Set<ManagedOperation> createOperationProxies(Set<ManagedOperation> ops, Object componentName)
- throws Exception
- {
- // Create the delegate operation
- Set<ManagedOperation> operations = new HashSet<ManagedOperation>();
- for(ManagedOperation op : ops)
- {
- ManagedOperation operation = proxyFactory.createOperationProxy(op, componentName);
- operations.add(operation);
- }
- return operations;
- }
-
- private ManagedProperty createPropertyProxy(ManagedProperty prop)
- throws Exception
- {
- if (proxyFactory == null)
- throw new IllegalArgumentException("Missing RuntimeComponentDispatcher.");
-
- // Create the delegate property
- Object componentName = prop.getManagedObject().getComponentName();
- return proxyFactory.createPropertyProxy(prop, componentName);
- }
-
- protected RunState updateRunState(ManagedObject runtimeMO, ManagedComponent comp)
- {
- RunState state = comp.getRunState();
- if (state == RunState.UNKNOWN && dispatcher != null)
- {
- Object name = comp.getComponentName();
- if (name == null && runtimeMO != null)
- name = runtimeMO.getComponentName();
- if (name != null)
- {
- state = getMappedState(name, runStateMapper);
- if (comp instanceof MutableManagedComponent)
- {
- MutableManagedComponent mcomp = MutableManagedComponent.class.cast(comp);
- mcomp.setRunState(state);
- }
- }
- }
- return state;
- }
-
- protected DeploymentState getDeploymentState(ManagedDeployment md)
- {
- DeploymentState state = md.getDeploymentState();
- if(state == DeploymentState.UNKNOWN && dispatcher != null)
- {
- Object name = md.getName();
- if(name != null)
- {
- state = getMappedState(name, deploymentStateMapper);
- }
- }
- return state;
- }
-
- protected <T extends Enum<?>> T getMappedState(Object name, ContextStateMapper<T> mapper)
- {
- T state = null;
- if(dispatcher != null)
- {
- try
- {
- //TODO, update RuntimeComponentDispatcher
- RuntimeComponentDispatcher xdispatcher = dispatcher;
- state = xdispatcher.mapControllerState(name, mapper);
- }
- catch(Exception e)
- {
- state = mapper.getErrorState();
- }
- }
- return state;
- }
-
-}
Modified: projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/view/AbstractProfileViewWrapper.java
===================================================================
--- projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/view/AbstractProfileViewWrapper.java 2010-02-15 12:02:10 UTC (rev 100964)
+++ projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/management/view/AbstractProfileViewWrapper.java 2010-02-15 13:17:38 UTC (rev 100965)
@@ -28,7 +28,7 @@
import org.jboss.managed.api.ComponentType;
import org.jboss.managed.api.ManagedComponent;
import org.jboss.managed.api.ManagedDeployment;
-import org.jboss.profileservice.plugins.management.util.ProfileViewProcessorHelper;
+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.profileservice.spi.action.engine.ModificationEvent;
@@ -41,7 +41,7 @@
{
/** The processor helper... */
- private ProfileViewProcessorHelper processorHelper;
+ private ManagedDeploymentProcessorHelper processorHelper;
/**
* {@inheritDoc}
@@ -55,12 +55,12 @@
*/
protected abstract ProfileView getDelegate();
- public ProfileViewProcessorHelper getProcessorHelper()
+ public ManagedDeploymentProcessorHelper getProcessorHelper()
{
return processorHelper;
}
- public void setProcessorHelper(ProfileViewProcessorHelper processorHelper)
+ public void setProcessorHelper(ManagedDeploymentProcessorHelper processorHelper)
{
this.processorHelper = processorHelper;
}
Modified: projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/spi/ProfileViewWrapper.java
===================================================================
--- projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/spi/ProfileViewWrapper.java 2010-02-15 12:02:10 UTC (rev 100964)
+++ projects/profileservice/trunk/plugins/src/main/java/org/jboss/profileservice/plugins/spi/ProfileViewWrapper.java 2010-02-15 13:17:38 UTC (rev 100965)
@@ -21,7 +21,7 @@
*/
package org.jboss.profileservice.plugins.spi;
-import org.jboss.profileservice.plugins.management.util.ProfileViewProcessorHelper;
+import org.jboss.profileservice.plugins.management.util.ManagedDeploymentProcessorHelper;
/**
* @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
@@ -31,7 +31,7 @@
{
// FIXME
- void setProcessorHelper(ProfileViewProcessorHelper processorHelper);
+ void setProcessorHelper(ManagedDeploymentProcessorHelper processorHelper);
}
Modified: projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/mgt/test/AbstractViewTestBase.java
===================================================================
--- projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/mgt/test/AbstractViewTestBase.java 2010-02-15 12:02:10 UTC (rev 100964)
+++ projects/profileservice/trunk/plugins/src/test/java/org/jboss/test/profileservice/plugins/mgt/test/AbstractViewTestBase.java 2010-02-15 13:17:38 UTC (rev 100965)
@@ -31,7 +31,7 @@
import org.jboss.managed.api.factory.ManagedObjectFactory;
import org.jboss.managed.plugins.ManagedDeploymentImpl;
import org.jboss.managed.plugins.factory.ManagedObjectFactoryBuilder;
-import org.jboss.profileservice.plugins.management.util.ProfileViewProcessorHelper;
+import org.jboss.profileservice.plugins.management.util.ManagedDeploymentProcessorHelper;
import org.jboss.test.BaseTestCase;
import org.jboss.test.profileservice.plugins.mgt.support.NoopManagementProxyFactory;
import org.jboss.test.profileservice.plugins.mgt.support.TestComponentMetaData;
@@ -53,7 +53,7 @@
private static final NoopManagementProxyFactory proxyFactory = new NoopManagementProxyFactory();
/** The helper. */
- private ProfileViewProcessorHelper helper;
+ private ManagedDeploymentProcessorHelper helper;
public AbstractViewTestBase(String name)
{
@@ -70,7 +70,7 @@
return proxyFactory;
}
- public ProfileViewProcessorHelper getHelper()
+ public ManagedDeploymentProcessorHelper getHelper()
{
return helper;
}
@@ -78,7 +78,7 @@
public void setUp() throws Exception
{
super.setUp();
- this.helper = new ProfileViewProcessorHelper(proxyFactory);
+ this.helper = new ManagedDeploymentProcessorHelper(proxyFactory);
}
protected ManagedDeployment createDeployment(String name, Object... objects)
Modified: projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/DeploymentContentFlags.java
===================================================================
--- projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/DeploymentContentFlags.java 2010-02-15 12:02:10 UTC (rev 100964)
+++ projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/DeploymentContentFlags.java 2010-02-15 13:17:38 UTC (rev 100965)
@@ -27,6 +27,7 @@
* @author Scott.Stark at jboss.org
* @version $Revision$
*/
+ at Deprecated
public interface DeploymentContentFlags
{
/** content that is not publicly visible in profile */
Modified: projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/DeploymentRepositoryFactory.java
===================================================================
--- projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/DeploymentRepositoryFactory.java 2010-02-15 12:02:10 UTC (rev 100964)
+++ projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/DeploymentRepositoryFactory.java 2010-02-15 13:17:38 UTC (rev 100965)
@@ -30,6 +30,7 @@
* @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
* @version $Revision$
*/
+ at Deprecated
public interface DeploymentRepositoryFactory
{
Modified: projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/MutableProfile.java
===================================================================
--- projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/MutableProfile.java 2010-02-15 12:02:10 UTC (rev 100964)
+++ projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/MutableProfile.java 2010-02-15 13:17:38 UTC (rev 100965)
@@ -67,6 +67,7 @@
* @see #getModifiedDeployments
* @param flag - the enable/disable flag
*/
+ @Deprecated
void enableModifiedDeploymentChecks(boolean flag);
}
Modified: projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/ProfileDeployment.java
===================================================================
--- projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/ProfileDeployment.java 2010-02-15 12:02:10 UTC (rev 100964)
+++ projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/ProfileDeployment.java 2010-02-15 13:17:38 UTC (rev 100965)
@@ -22,8 +22,9 @@
package org.jboss.profileservice.spi;
import java.io.Serializable;
-import java.util.Map;
+import org.jboss.profileservice.spi.deployment.DeploymentAttachments;
+import org.jboss.profileservice.spi.deployment.ProfileDeploymentInfo;
import org.jboss.virtual.VirtualFile;
/**
@@ -45,104 +46,39 @@
String getName();
/**
- * Get the root of the deployment
+ * The simple deployment name.
*
- * @return the deployment root, null if it's not a VFS based deployment
+ * @return the simple deployment name
*/
- VirtualFile getRoot();
+ String getSimpleName();
/**
- * Get all attachments.
+ * Get the root of the deployment
*
- * @return the attachments
+ * @return the deployment root, null if it's not a VFS based deployment
*/
- Map<String, Object> getAttachments();
-
+ VirtualFile getRoot();
+
/**
- * Get attachment.
+ * Get the deployment info.
*
- * @param name the name of the attachment
- * @return the attachment or null if not present
- *
- * @throws IllegalArgumentException for a null name
+ * @return the deployment info
*/
- Object getAttachment(String name);
+ ProfileDeploymentInfo getDeploymentInfo();
/**
- * Get attachment.
+ * Get the predetermined attachments.
*
- * @param <T> the expected type
- * @param name the name of the attachment
- * @param expectedType the expected type
- * @return the attachment or null if not present
- *
- * @throws IllegalArgumentException for a null name
+ * @return the predetermined attachments
*/
- <T> T getAttachment(String name, Class<T> expectedType);
-
+ DeploymentAttachments getPredeterminedAttachments();
+
/**
- * Add attachment
- *
- * @param name the name of the attachment
- * @param attachment the attachment
- * @return any previous attachment
+ * Get the transient attachments.
*
- * @throws IllegalArgumentException for a null name or attachment
+ * @return the transient attachments
*/
- Object addAttachment(String name, Object attachment);
+ DeploymentAttachments getTransientAttachments();
- /**
- * Remove attachment.
- *
- * @param name the attachment name
- * @return the attachment or null if not present
- *
- * @throws IllegalArgumentException for a null name
- */
- Object removeAttachment(String name);
-
- /**
- * Get transient attachment.
- *
- * @param name the name of the attachment
- * @return the attachment or null if not present
- *
- * @throws IllegalArgumentException for a null name
- */
- Object getTransientAttachment(String name);
-
- /**
- * Get transient attachment.
- *
- * @param <T> the expected type
- * @param name the name of the attachment
- * @param expectedType the expected type
- * @return the attachment or null if not present
- *
- * @throws IllegalArgumentException for a null name
- */
- <T> T getTransientAttachment(String name, Class<T> expectedType);
-
- /**
- * Add transient attachment
- *
- * @param name the name of the attachment
- * @param attachment the attachment
- * @return any previous attachment
- *
- * @throws IllegalArgumentException for a null name or attachment
- */
- Object addTransientAttachment(String name, Object attachment);
-
- /**
- * Remove transient attachment.
- *
- * @param name the attachment name
- * @return the attachment or null if not present
- *
- * @throws IllegalArgumentException for a null name
- */
- Object removeTransientAttachment(String name);
-
}
Modified: projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/ProfileKey.java
===================================================================
--- projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/ProfileKey.java 2010-02-15 12:02:10 UTC (rev 100964)
+++ projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/ProfileKey.java 2010-02-15 13:17:38 UTC (rev 100965)
@@ -148,7 +148,7 @@
if(o == this)
return true;
if(o instanceof ProfileKey)
- return compareTo((ProfileKey) o) == 0;
+ return compareTo(ProfileKey.class.cast(o)) == 0;
return false;
}
Modified: projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/ProfileRepository.java
===================================================================
--- projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/ProfileRepository.java 2010-02-15 12:02:10 UTC (rev 100964)
+++ projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/ProfileRepository.java 2010-02-15 13:17:38 UTC (rev 100965)
@@ -33,6 +33,7 @@
* @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
* @version $Revision$
*/
+ at Deprecated
public interface ProfileRepository
{
/**
Added: projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/deployment/DeploymentAttachments.java
===================================================================
--- projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/deployment/DeploymentAttachments.java (rev 0)
+++ projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/deployment/DeploymentAttachments.java 2010-02-15 13:17:38 UTC (rev 100965)
@@ -0,0 +1,94 @@
+/*
+* 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.spi.deployment;
+
+import java.util.Map;
+
+/**
+ * The profile deployment attachments.
+ *
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public interface DeploymentAttachments
+{
+
+ /**
+ * Get all attachments.
+ *
+ * @return the attachments
+ */
+ Map<String, Object> getAttachments();
+
+ /**
+ * Get attachment.
+ *
+ * @param name the name of the attachment
+ * @return the attachment or null if not present
+ *
+ * @throws IllegalArgumentException for a null name
+ */
+ Object getAttachment(String name);
+
+ /**
+ * Get attachment.
+ *
+ * @param <T> the expected type
+ * @param name the name of the attachment
+ * @param expectedType the expected type
+ * @return the attachment or null if not present
+ *
+ * @throws IllegalArgumentException for a null name
+ */
+ <T> T getAttachment(String name, Class<T> expectedType);
+
+ /**
+ * Add attachment
+ *
+ * @param name the name of the attachment
+ * @param attachment the attachment
+ * @return any previous attachment
+ *
+ * @throws IllegalArgumentException for a null name or attachment
+ */
+ Object putAttachment(String name, Object attachment);
+
+ /**
+ * Remove attachment.
+ *
+ * @param name the attachment name
+ * @return the attachment or null if not present
+ *
+ * @throws IllegalArgumentException for a null name
+ */
+ Object removeAttachment(String name);
+
+ /**
+ * Has attachment.
+ *
+ * @param name the attachment name
+ * @return true when the attachment is present
+ */
+ boolean hasAttachment(String name);
+
+}
+
Added: projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/deployment/ProfileDeploymentFlag.java
===================================================================
--- projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/deployment/ProfileDeploymentFlag.java (rev 0)
+++ projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/deployment/ProfileDeploymentFlag.java 2010-02-15 13:17:38 UTC (rev 100965)
@@ -0,0 +1,57 @@
+/*
+* 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.spi.deployment;
+
+/**
+ * State of a profile deployment.
+ *
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public enum ProfileDeploymentFlag
+{
+
+ /** the deployed state */
+ DEPLOYED(2),
+
+ /** exists in profile, but is excluded from modified deployment checks. */
+ LOCKED(4),
+
+ /** Can be used to explicitly put a deployment into the modified list */
+ MODIFIED(8);
+
+ //
+
+ private final int flag;
+
+ private ProfileDeploymentFlag(int i)
+ {
+ this.flag = i;
+ }
+
+ public int getFlag()
+ {
+ return flag;
+ }
+
+}
+
Added: projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/deployment/ProfileDeploymentInfo.java
===================================================================
--- projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/deployment/ProfileDeploymentInfo.java (rev 0)
+++ projects/profileservice/trunk/spi/src/main/java/org/jboss/profileservice/spi/deployment/ProfileDeploymentInfo.java 2010-02-15 13:17:38 UTC (rev 100965)
@@ -0,0 +1,77 @@
+/*
+* 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.spi.deployment;
+
+/**
+ * The profile deployment info.
+ *
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public interface ProfileDeploymentInfo
+{
+
+ /**
+ * Get the deployment name
+ *
+ * @return the deployment name
+ */
+ String getName();
+
+ /**
+ * Flag indicating if a deployment is deployed.
+ *
+ * @return true if deployed, false otherwise
+ */
+ boolean isDeployed();
+
+ /**
+ * Flag indicating if the deployment is locked for
+ * modification checking.
+ *
+ * @return true if locked, false otherwise
+ */
+ boolean isLocked();
+
+ /**
+ * Check whether the deployment has the indicated flag.
+ *
+ * @param flag the flag
+ * @return true if the policy contains the flag, false otherwise.
+ */
+ boolean hasFlag(ProfileDeploymentFlag flag);
+
+ /**
+ * Set a deployment flag.
+ *
+ * @param flag the flag
+ */
+ void setFlag(ProfileDeploymentFlag flag);
+
+ /**
+ * Clear the deployment flag.
+ *
+ * @param flag the flag
+ */
+ void clearFlag(ProfileDeploymentFlag flag);
+}
+
More information about the jboss-cvs-commits
mailing list