[jboss-cvs] JBossAS SVN: r97699 - in trunk: profileservice and 15 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Dec 10 12:35:50 EST 2009


Author: pgier
Date: 2009-12-10 12:35:48 -0500 (Thu, 10 Dec 2009)
New Revision: 97699

Added:
   trunk/profileservice/src/assembly/
   trunk/profileservice/src/assembly/client.xml
   trunk/profileservice/src/main/java/org/jboss/profileservice/ejb/
   trunk/profileservice/src/main/java/org/jboss/profileservice/ejb/SecureDeploymentManager.java
   trunk/profileservice/src/main/java/org/jboss/profileservice/ejb/SecureManagementView.java
   trunk/profileservice/src/main/java/org/jboss/profileservice/ejb/SecureProfileServiceBean.java
   trunk/profileservice/src/main/java/org/jboss/profileservice/management/AggregatingManagementView.java
   trunk/profileservice/src/main/java/org/jboss/profileservice/management/MBeanManagedObjectFactory.java
   trunk/profileservice/src/main/java/org/jboss/profileservice/management/MBeanRuntimeComponentDispatcher.java
   trunk/profileservice/src/main/java/org/jboss/profileservice/management/PlatformMBeanIDC.java
   trunk/profileservice/src/main/java/org/jboss/profileservice/management/PlatformMBeanKernelRegistryPlugin.java
   trunk/profileservice/src/main/java/org/jboss/profileservice/management/ProxyManagedDeploymentFactory.java
   trunk/profileservice/src/main/java/org/jboss/profileservice/management/client/
   trunk/profileservice/src/main/java/org/jboss/profileservice/management/client/ManagedComponentDelegate.java
   trunk/profileservice/src/main/java/org/jboss/profileservice/management/client/ManagedOperationDelegate.java
   trunk/profileservice/src/main/java/org/jboss/profileservice/management/client/ManagedPropertyDelegate.java
   trunk/profileservice/src/main/java/org/jboss/profileservice/management/client/package.html
   trunk/profileservice/src/main/java/org/jboss/profileservice/management/client/upload/
   trunk/profileservice/src/main/java/org/jboss/profileservice/management/client/upload/DeploymentProgressImpl.java
   trunk/profileservice/src/main/java/org/jboss/profileservice/management/client/upload/SerializableDeploymentID.java
   trunk/profileservice/src/main/java/org/jboss/profileservice/management/client/upload/SerializableDeploymentStatus.java
   trunk/profileservice/src/main/java/org/jboss/profileservice/management/client/upload/StreamingDeploymentTarget.java
   trunk/profileservice/src/main/java/org/jboss/profileservice/management/mbean/EJBInvocationStatsMapper.java
   trunk/profileservice/src/main/java/org/jboss/profileservice/management/upload/remoting/SecurityActions.java
   trunk/profileservice/src/main/java/org/jboss/profileservice/management/views/
   trunk/profileservice/src/main/java/org/jboss/profileservice/management/views/AbstractManagedDeploymentView.java
   trunk/profileservice/src/main/java/org/jboss/profileservice/management/views/AbstractProfileView.java
   trunk/profileservice/src/main/java/org/jboss/profileservice/management/views/BootstrapProfileView.java
   trunk/profileservice/src/main/java/org/jboss/profileservice/management/views/MBeanProfileView.java
   trunk/profileservice/src/main/java/org/jboss/profileservice/management/views/PlatformMbeansView.java
   trunk/profileservice/src/main/java/org/jboss/profileservice/management/views/ProfileView.java
   trunk/profileservice/src/main/java/org/jboss/profileservice/remoting/BasicInvocation.java
   trunk/profileservice/src/main/java/org/jboss/profileservice/remoting/InstanceInterceptor.java
   trunk/profileservice/src/main/java/org/jboss/profileservice/remoting/PojiMethodInvocation.java
   trunk/profileservice/src/main/java/org/jboss/profileservice/remoting/SecurityContainer.java
   trunk/profileservice/src/main/java/org/jboss/profileservice/spi/
   trunk/profileservice/src/main/java/org/jboss/profileservice/spi/MBeanDeploymentNameBuilder.java
   trunk/profileservice/src/main/java/org/jboss/profileservice/spi/ManagedMBeanDeploymentFactory.java
   trunk/profileservice/src/main/java/org/jboss/profileservice/web/
   trunk/profileservice/src/main/java/org/jboss/profileservice/web/DebugServlet.java
Removed:
   trunk/profileservice/src/main/java/org/jboss/profileservice/domain/
   trunk/profileservice/src/main/java/org/jboss/profileservice/ejb/SecureDeploymentManager.java
   trunk/profileservice/src/main/java/org/jboss/profileservice/ejb/SecureManagementView.java
   trunk/profileservice/src/main/java/org/jboss/profileservice/ejb/SecureProfileServiceBean.java
   trunk/profileservice/src/main/java/org/jboss/profileservice/management/MBeanManagedObjectFactory.java
   trunk/profileservice/src/main/java/org/jboss/profileservice/management/MBeanRuntimeComponentDispatcher.java
   trunk/profileservice/src/main/java/org/jboss/profileservice/management/PlatformMBeanIDC.java
   trunk/profileservice/src/main/java/org/jboss/profileservice/management/PlatformMBeanKernelRegistryPlugin.java
   trunk/profileservice/src/main/java/org/jboss/profileservice/management/ProxyManagedDeploymentFactory.java
   trunk/profileservice/src/main/java/org/jboss/profileservice/management/client/
   trunk/profileservice/src/main/java/org/jboss/profileservice/management/client/ManagedComponentDelegate.java
   trunk/profileservice/src/main/java/org/jboss/profileservice/management/client/ManagedOperationDelegate.java
   trunk/profileservice/src/main/java/org/jboss/profileservice/management/client/ManagedPropertyDelegate.java
   trunk/profileservice/src/main/java/org/jboss/profileservice/management/client/package.html
   trunk/profileservice/src/main/java/org/jboss/profileservice/management/client/upload/
   trunk/profileservice/src/main/java/org/jboss/profileservice/management/client/upload/DeploymentProgressImpl.java
   trunk/profileservice/src/main/java/org/jboss/profileservice/management/client/upload/SerializableDeploymentID.java
   trunk/profileservice/src/main/java/org/jboss/profileservice/management/client/upload/SerializableDeploymentStatus.java
   trunk/profileservice/src/main/java/org/jboss/profileservice/management/client/upload/StreamingDeploymentTarget.java
   trunk/profileservice/src/main/java/org/jboss/profileservice/management/mbean/EJBInvocationStatsMapper.java
   trunk/profileservice/src/main/java/org/jboss/profileservice/management/upload/remoting/SecurityActions.java
   trunk/profileservice/src/main/java/org/jboss/profileservice/management/views/AbstractManagedDeploymentView.java
   trunk/profileservice/src/main/java/org/jboss/profileservice/management/views/AbstractProfileView.java
   trunk/profileservice/src/main/java/org/jboss/profileservice/management/views/BootstrapProfileView.java
   trunk/profileservice/src/main/java/org/jboss/profileservice/management/views/MBeanProfileView.java
   trunk/profileservice/src/main/java/org/jboss/profileservice/management/views/PlatformMbeansView.java
   trunk/profileservice/src/main/java/org/jboss/profileservice/management/views/ProfileView.java
   trunk/profileservice/src/main/java/org/jboss/profileservice/remoting/BasicInvocation.java
   trunk/profileservice/src/main/java/org/jboss/profileservice/remoting/InstanceInterceptor.java
   trunk/profileservice/src/main/java/org/jboss/profileservice/remoting/PojiMethodInvocation.java
   trunk/profileservice/src/main/java/org/jboss/profileservice/remoting/SecurityContainer.java
   trunk/profileservice/src/main/java/org/jboss/profileservice/spi/
   trunk/profileservice/src/main/java/org/jboss/profileservice/spi/MBeanDeploymentNameBuilder.java
   trunk/profileservice/src/main/java/org/jboss/profileservice/spi/ManagedMBeanDeploymentFactory.java
   trunk/profileservice/src/main/java/org/jboss/profileservice/web/
   trunk/profileservice/src/main/java/org/jboss/profileservice/web/DebugServlet.java
   trunk/profileservice/src/test/java/org/jboss/test/ps/DomainMetaDataTest.java
Modified:
   trunk/component-matrix/pom.xml
   trunk/profileservice/pom.xml
   trunk/profileservice/src/main/java/org/
   trunk/profileservice/src/main/java/org/jboss/profileservice/management/ManagementViewImpl.java
Log:
[JBAS-7539] Merging profileservice changes from 6.0.0.M1 tag to trunk.

Modified: trunk/component-matrix/pom.xml
===================================================================
--- trunk/component-matrix/pom.xml	2009-12-10 16:45:13 UTC (rev 97698)
+++ trunk/component-matrix/pom.xml	2009-12-10 17:35:48 UTC (rev 97699)
@@ -2004,6 +2004,12 @@
       </dependency>
       
       <dependency>
+        <groupId>org.jboss.ejb3</groupId>
+        <artifactId>jboss-ejb3-ext-api</artifactId>
+        <version>1.0.0</version>
+      </dependency>
+      
+      <dependency>
         <groupId>org.jboss.javaee</groupId>
         <artifactId>jboss-jacc-api</artifactId>
         <version>1.1.0${version.suffix.org.jboss.javaee}_SP1</version>

Modified: trunk/profileservice/pom.xml
===================================================================
--- trunk/profileservice/pom.xml	2009-12-10 16:45:13 UTC (rev 97698)
+++ trunk/profileservice/pom.xml	2009-12-10 17:35:48 UTC (rev 97699)
@@ -44,6 +44,34 @@
           </execution>
         </executions>
       </plugin>
+      <!--<plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jar-plugin</artifactId>
+        <configuration>
+          <includes>
+            <include></include>
+          </includes>
+        </configuration>
+      </plugin>-->
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-assembly-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>assembly</id>
+            <goals>
+              <goal>single</goal>
+            </goals>
+            <phase>package</phase>
+            <configuration>
+              <descriptors>
+                <descriptor>src/assembly/client.xml</descriptor>
+                <descriptor>src/assembly/secured.xml</descriptor>
+              </descriptors>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
     </plugins>
   </build>
   <dependencies>
@@ -156,6 +184,14 @@
       <groupId>stax</groupId>
       <artifactId>stax-api</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.jboss.javaee</groupId>
+      <artifactId>jboss-javaee</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.ejb3</groupId>
+      <artifactId>jboss-ejb3-ext-api</artifactId>
+    </dependency>
   </dependencies>
   
 </project>

Added: trunk/profileservice/src/assembly/client.xml
===================================================================
--- trunk/profileservice/src/assembly/client.xml	                        (rev 0)
+++ trunk/profileservice/src/assembly/client.xml	2009-12-10 17:35:48 UTC (rev 97699)
@@ -0,0 +1,16 @@
+<assembly>
+  <id>client</id>
+  <formats>
+    <format>jar</format>
+  </formats>
+  <includeBaseDirectory>false</includeBaseDirectory>
+  <fileSets>
+    <fileSet>
+      <directory>target/classes</directory>
+      <outputDirectory>/</outputDirectory>
+      <includes>
+        <include>org/jboss/profileservice/management/client/**</include>
+      </includes>
+    </fileSet>
+  </fileSets>
+</assembly>


Property changes on: trunk/profileservice/src/assembly/client.xml
___________________________________________________________________
Name: svn:keywords
   + "Author Date Id Revision"
Name: svn:eol-style
   + native


Property changes on: trunk/profileservice/src/main/java/org
___________________________________________________________________
Name: svn:mergeinfo
   - 

Copied: trunk/profileservice/src/main/java/org/jboss/profileservice/ejb (from rev 97697, tags/JBoss_6_0_0_M1/profileservice/src/main/org/jboss/profileservice/ejb)

Deleted: trunk/profileservice/src/main/java/org/jboss/profileservice/ejb/SecureDeploymentManager.java
===================================================================
--- tags/JBoss_6_0_0_M1/profileservice/src/main/org/jboss/profileservice/ejb/SecureDeploymentManager.java	2009-12-10 15:49:13 UTC (rev 97697)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/ejb/SecureDeploymentManager.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -1,122 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, 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.ejb;
-
-import java.net.URL;
-import java.util.Collection;
-
-import javax.annotation.PostConstruct;
-import javax.annotation.PreDestroy;
-import javax.annotation.Resource;
-import javax.annotation.security.RolesAllowed;
-import javax.ejb.Remote;
-import javax.ejb.Stateless;
-
-import org.jboss.deployers.spi.management.ManagementView;
-import org.jboss.deployers.spi.management.deploy.DeploymentManager;
-import org.jboss.deployers.spi.management.deploy.DeploymentProgress;
-import org.jboss.ejb3.annotation.SecurityDomain;
-import org.jboss.logging.Logger;
-import org.jboss.managed.api.ManagedDeployment.DeploymentPhase;
-import org.jboss.profileservice.spi.DeploymentOption;
-import org.jboss.profileservice.spi.ProfileKey;
-import org.jboss.profileservice.spi.ProfileService;
-
-/**
- * A secured ejb facade over the DeploymentManager interface
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
- at Stateless(name="SecureDeploymentManager")
- at SecurityDomain(value="jmx-console", unauthenticatedPrincipal="nobody")
- at Remote(DeploymentManager.class)
- at RolesAllowed({"JBossAdmin"})
-public class SecureDeploymentManager implements DeploymentManager
-{
-   static Logger log = Logger.getLogger(SecureManagementView.class);
-
-   /** The local ProfileService to obtain the DeploymentManager delegate from */
-   @Resource(mappedName="ProfileService")
-   private ProfileService profileService;
-   private DeploymentManager delegate;
-
-   @PostConstruct
-   public void postConstruct()
-   {
-      log.debug("Looking up ProfileService.DeploymentManager");
-      delegate = profileService.getDeploymentManager();
-   }
-   @PreDestroy
-   public void preDestroy()
-   {
-      delegate = null;
-   }
-   public DeploymentProgress distribute(String name, URL contentURL, boolean copyContent) throws Exception
-   {
-      return delegate.distribute(name, contentURL, copyContent);
-   }
-   public DeploymentProgress distribute(String name, URL contentURL, DeploymentOption... options) throws Exception
-   {
-      return delegate.distribute(name, contentURL, options);
-   }
-   public Collection<ProfileKey> getProfiles()
-   {
-      return delegate.getProfiles();
-   }
-   public String[] getRepositoryNames(String[] names) throws Exception
-   {
-      return delegate.getRepositoryNames(names);
-   }
-   public boolean isRedeploySupported()
-   {
-      return delegate.isRedeploySupported();
-   }
-   public void loadProfile(ProfileKey key) throws Exception
-   {
-      delegate.loadProfile(key);
-   }
-   public DeploymentProgress prepare(String... names) throws Exception
-   {
-      return delegate.prepare(names);
-   }
-   public DeploymentProgress redeploy(String name) throws Exception
-   {
-      return delegate.redeploy(name);
-   }
-   public void releaseProfile() throws Exception
-   {
-      delegate.releaseProfile();
-   }
-   public DeploymentProgress remove(String... names) throws Exception
-   {
-      return delegate.remove(names);
-   }
-   public DeploymentProgress start(String... names) throws Exception
-   {
-      return delegate.start(names);
-   }
-   public DeploymentProgress stop(String... names) throws Exception
-   {
-      return delegate.stop(names);
-   }
-   
-}

Copied: trunk/profileservice/src/main/java/org/jboss/profileservice/ejb/SecureDeploymentManager.java (from rev 97697, tags/JBoss_6_0_0_M1/profileservice/src/main/org/jboss/profileservice/ejb/SecureDeploymentManager.java)
===================================================================
--- trunk/profileservice/src/main/java/org/jboss/profileservice/ejb/SecureDeploymentManager.java	                        (rev 0)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/ejb/SecureDeploymentManager.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -0,0 +1,122 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.ejb;
+
+import java.net.URL;
+import java.util.Collection;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.annotation.Resource;
+import javax.annotation.security.RolesAllowed;
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+
+import org.jboss.deployers.spi.management.ManagementView;
+import org.jboss.deployers.spi.management.deploy.DeploymentManager;
+import org.jboss.deployers.spi.management.deploy.DeploymentProgress;
+import org.jboss.ejb3.annotation.SecurityDomain;
+import org.jboss.logging.Logger;
+import org.jboss.managed.api.ManagedDeployment.DeploymentPhase;
+import org.jboss.profileservice.spi.DeploymentOption;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.ProfileService;
+
+/**
+ * A secured ejb facade over the DeploymentManager interface
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+ at Stateless(name="SecureDeploymentManager")
+ at SecurityDomain(value="jmx-console", unauthenticatedPrincipal="nobody")
+ at Remote(DeploymentManager.class)
+ at RolesAllowed({"JBossAdmin"})
+public class SecureDeploymentManager implements DeploymentManager
+{
+   static Logger log = Logger.getLogger(SecureManagementView.class);
+
+   /** The local ProfileService to obtain the DeploymentManager delegate from */
+   @Resource(mappedName="ProfileService")
+   private ProfileService profileService;
+   private DeploymentManager delegate;
+
+   @PostConstruct
+   public void postConstruct()
+   {
+      log.debug("Looking up ProfileService.DeploymentManager");
+      delegate = profileService.getDeploymentManager();
+   }
+   @PreDestroy
+   public void preDestroy()
+   {
+      delegate = null;
+   }
+   public DeploymentProgress distribute(String name, URL contentURL, boolean copyContent) throws Exception
+   {
+      return delegate.distribute(name, contentURL, copyContent);
+   }
+   public DeploymentProgress distribute(String name, URL contentURL, DeploymentOption... options) throws Exception
+   {
+      return delegate.distribute(name, contentURL, options);
+   }
+   public Collection<ProfileKey> getProfiles()
+   {
+      return delegate.getProfiles();
+   }
+   public String[] getRepositoryNames(String[] names) throws Exception
+   {
+      return delegate.getRepositoryNames(names);
+   }
+   public boolean isRedeploySupported()
+   {
+      return delegate.isRedeploySupported();
+   }
+   public void loadProfile(ProfileKey key) throws Exception
+   {
+      delegate.loadProfile(key);
+   }
+   public DeploymentProgress prepare(String... names) throws Exception
+   {
+      return delegate.prepare(names);
+   }
+   public DeploymentProgress redeploy(String name) throws Exception
+   {
+      return delegate.redeploy(name);
+   }
+   public void releaseProfile() throws Exception
+   {
+      delegate.releaseProfile();
+   }
+   public DeploymentProgress remove(String... names) throws Exception
+   {
+      return delegate.remove(names);
+   }
+   public DeploymentProgress start(String... names) throws Exception
+   {
+      return delegate.start(names);
+   }
+   public DeploymentProgress stop(String... names) throws Exception
+   {
+      return delegate.stop(names);
+   }
+   
+}

Deleted: trunk/profileservice/src/main/java/org/jboss/profileservice/ejb/SecureManagementView.java
===================================================================
--- tags/JBoss_6_0_0_M1/profileservice/src/main/org/jboss/profileservice/ejb/SecureManagementView.java	2009-12-10 15:49:13 UTC (rev 97697)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/ejb/SecureManagementView.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -1,175 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, 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.ejb;
-
-import java.util.Set;
-
-import javax.annotation.PostConstruct;
-import javax.annotation.PreDestroy;
-import javax.annotation.Resource;
-import javax.annotation.security.RolesAllowed;
-import javax.ejb.Remote;
-import javax.ejb.Stateless;
-
-import org.jboss.deployers.spi.management.ManagementView;
-import org.jboss.deployers.spi.management.NameMatcher;
-import org.jboss.ejb3.annotation.SecurityDomain;
-import org.jboss.logging.Logger;
-import org.jboss.managed.api.ComponentType;
-import org.jboss.managed.api.DeploymentTemplateInfo;
-import org.jboss.managed.api.ManagedComponent;
-import org.jboss.managed.api.ManagedDeployment;
-import org.jboss.profileservice.spi.NoSuchDeploymentException;
-import org.jboss.profileservice.spi.ProfileService;
-
-/**
- * A secured ejb facade over the ManagementView interface
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
- at Stateless
- at SecurityDomain(value="jmx-console", unauthenticatedPrincipal="nobody")
- at Remote(ManagementView.class)
- at RolesAllowed({"JBossAdmin"})
-public class SecureManagementView implements ManagementView
-{
-   static Logger log = Logger.getLogger(SecureManagementView.class);
-
-   /** The local ProfileService to obtain the ManagementView delegate from */
-   @Resource(mappedName="ProfileService")
-   private ProfileService profileService;
-   private ManagementView delegate;
-
-   @PostConstruct
-   public void postConstruct()
-   {
-      log.debug("Looking up ProfileService.ManagementView");
-      delegate = profileService.getViewManager();
-   }
-   @PreDestroy
-   public void preDestroy()
-   {
-      delegate = null;
-   }
-
-   public void applyTemplate(String deploymentBaseName,
-         DeploymentTemplateInfo info) throws Exception
-   {
-      delegate.applyTemplate(deploymentBaseName, info);
-   }
-
-   public ManagedComponent getComponent(String name, ComponentType type)
-         throws Exception
-   {
-      return delegate.getComponent(name, type);
-   }
-
-   public Set<ComponentType> getComponentTypes()
-   {
-      return delegate.getComponentTypes();
-   }
-
-   public Set<ManagedComponent> getComponentsForType(ComponentType type)
-         throws Exception
-   {
-      return delegate.getComponentsForType(type);
-   }
-
-   public ManagedDeployment getDeployment(String name)
-         throws NoSuchDeploymentException
-   {
-      return delegate.getDeployment(name);
-   }
-
-   public Set<String> getDeploymentNames()
-   {
-      return delegate.getDeploymentNames();
-   }
-
-   public Set<String> getDeploymentNamesForType(String type)
-   {
-      return delegate.getDeploymentNamesForType(type);
-   }
-
-   public Set<ManagedDeployment> getDeploymentsForType(String type)
-         throws Exception
-   {
-      return delegate.getDeploymentsForType(type);
-   }
-
-   public Set<ManagedComponent> getMatchingComponents(String name,
-         ComponentType type, NameMatcher<ManagedComponent> matcher)
-         throws Exception
-   {
-      return delegate.getMatchingComponents(name, type, matcher);
-   }
-
-   public Set<String> getMatchingDeploymentName(String regex)
-         throws NoSuchDeploymentException
-   {
-      return delegate.getMatchingDeploymentName(regex);
-   }
-
-   public Set<ManagedDeployment> getMatchingDeployments(String name,
-         NameMatcher<ManagedDeployment> matcher)
-         throws NoSuchDeploymentException, Exception
-   {
-      return delegate.getMatchingDeployments(name, matcher);
-   }
-
-   public DeploymentTemplateInfo getTemplate(String name)
-         throws NoSuchDeploymentException
-   {
-      return delegate.getTemplate(name);
-   }
-
-   public Set<String> getTemplateNames()
-   {
-      return delegate.getTemplateNames();
-   }
-
-   public boolean load()
-   {
-      return delegate.load();
-   }
-
-   public void process() throws Exception
-   {
-      delegate.process();
-   }
-
-   public void reload()
-   {
-      delegate.reload();
-   }
-
-   public void updateComponent(ManagedComponent comp) throws Exception
-   {
-      delegate.updateComponent(comp);
-   }
-   
-   public void removeComponent(ManagedComponent comp) throws Exception
-   {
-      delegate.removeComponent(comp);
-   }
-   
-}

Copied: trunk/profileservice/src/main/java/org/jboss/profileservice/ejb/SecureManagementView.java (from rev 97697, tags/JBoss_6_0_0_M1/profileservice/src/main/org/jboss/profileservice/ejb/SecureManagementView.java)
===================================================================
--- trunk/profileservice/src/main/java/org/jboss/profileservice/ejb/SecureManagementView.java	                        (rev 0)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/ejb/SecureManagementView.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -0,0 +1,175 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.ejb;
+
+import java.util.Set;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.annotation.Resource;
+import javax.annotation.security.RolesAllowed;
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+
+import org.jboss.deployers.spi.management.ManagementView;
+import org.jboss.deployers.spi.management.NameMatcher;
+import org.jboss.ejb3.annotation.SecurityDomain;
+import org.jboss.logging.Logger;
+import org.jboss.managed.api.ComponentType;
+import org.jboss.managed.api.DeploymentTemplateInfo;
+import org.jboss.managed.api.ManagedComponent;
+import org.jboss.managed.api.ManagedDeployment;
+import org.jboss.profileservice.spi.NoSuchDeploymentException;
+import org.jboss.profileservice.spi.ProfileService;
+
+/**
+ * A secured ejb facade over the ManagementView interface
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+ at Stateless
+ at SecurityDomain(value="jmx-console", unauthenticatedPrincipal="nobody")
+ at Remote(ManagementView.class)
+ at RolesAllowed({"JBossAdmin"})
+public class SecureManagementView implements ManagementView
+{
+   static Logger log = Logger.getLogger(SecureManagementView.class);
+
+   /** The local ProfileService to obtain the ManagementView delegate from */
+   @Resource(mappedName="ProfileService")
+   private ProfileService profileService;
+   private ManagementView delegate;
+
+   @PostConstruct
+   public void postConstruct()
+   {
+      log.debug("Looking up ProfileService.ManagementView");
+      delegate = profileService.getViewManager();
+   }
+   @PreDestroy
+   public void preDestroy()
+   {
+      delegate = null;
+   }
+
+   public void applyTemplate(String deploymentBaseName,
+         DeploymentTemplateInfo info) throws Exception
+   {
+      delegate.applyTemplate(deploymentBaseName, info);
+   }
+
+   public ManagedComponent getComponent(String name, ComponentType type)
+         throws Exception
+   {
+      return delegate.getComponent(name, type);
+   }
+
+   public Set<ComponentType> getComponentTypes()
+   {
+      return delegate.getComponentTypes();
+   }
+
+   public Set<ManagedComponent> getComponentsForType(ComponentType type)
+         throws Exception
+   {
+      return delegate.getComponentsForType(type);
+   }
+
+   public ManagedDeployment getDeployment(String name)
+         throws NoSuchDeploymentException
+   {
+      return delegate.getDeployment(name);
+   }
+
+   public Set<String> getDeploymentNames()
+   {
+      return delegate.getDeploymentNames();
+   }
+
+   public Set<String> getDeploymentNamesForType(String type)
+   {
+      return delegate.getDeploymentNamesForType(type);
+   }
+
+   public Set<ManagedDeployment> getDeploymentsForType(String type)
+         throws Exception
+   {
+      return delegate.getDeploymentsForType(type);
+   }
+
+   public Set<ManagedComponent> getMatchingComponents(String name,
+         ComponentType type, NameMatcher<ManagedComponent> matcher)
+         throws Exception
+   {
+      return delegate.getMatchingComponents(name, type, matcher);
+   }
+
+   public Set<String> getMatchingDeploymentName(String regex)
+         throws NoSuchDeploymentException
+   {
+      return delegate.getMatchingDeploymentName(regex);
+   }
+
+   public Set<ManagedDeployment> getMatchingDeployments(String name,
+         NameMatcher<ManagedDeployment> matcher)
+         throws NoSuchDeploymentException, Exception
+   {
+      return delegate.getMatchingDeployments(name, matcher);
+   }
+
+   public DeploymentTemplateInfo getTemplate(String name)
+         throws NoSuchDeploymentException
+   {
+      return delegate.getTemplate(name);
+   }
+
+   public Set<String> getTemplateNames()
+   {
+      return delegate.getTemplateNames();
+   }
+
+   public boolean load()
+   {
+      return delegate.load();
+   }
+
+   public void process() throws Exception
+   {
+      delegate.process();
+   }
+
+   public void reload()
+   {
+      delegate.reload();
+   }
+
+   public void updateComponent(ManagedComponent comp) throws Exception
+   {
+      delegate.updateComponent(comp);
+   }
+   
+   public void removeComponent(ManagedComponent comp) throws Exception
+   {
+      delegate.removeComponent(comp);
+   }
+   
+}

Deleted: trunk/profileservice/src/main/java/org/jboss/profileservice/ejb/SecureProfileServiceBean.java
===================================================================
--- tags/JBoss_6_0_0_M1/profileservice/src/main/org/jboss/profileservice/ejb/SecureProfileServiceBean.java	2009-12-10 15:49:13 UTC (rev 97697)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/ejb/SecureProfileServiceBean.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -1,104 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.profileservice.ejb;
-
-import java.util.Collection;
-
-import javax.annotation.Resource;
-import javax.annotation.security.RolesAllowed;
-import javax.ejb.EJB;
-import javax.ejb.Remote;
-import javax.ejb.Stateless;
-
-import org.jboss.deployers.spi.management.ManagementView;
-import org.jboss.deployers.spi.management.deploy.DeploymentManager;
-import org.jboss.ejb3.annotation.SecurityDomain;
-import org.jboss.profileservice.spi.NoSuchProfileException;
-import org.jboss.profileservice.spi.Profile;
-import org.jboss.profileservice.spi.ProfileKey;
-import org.jboss.profileservice.spi.ProfileService;
-
-/**
- * A secured ejb facade over the ProfileService interface
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
- at Stateless(name="SecureProfileService")
- at SecurityDomain(value="jmx-console", unauthenticatedPrincipal="nobody")
- at Remote(ProfileService.class)
- at RolesAllowed({"JBossAdmin"})
-public class SecureProfileServiceBean implements ProfileService
-{
-   @Resource(mappedName="ProfileService")
-   private ProfileService delegate;
-   @EJB(beanName="SecureManagementView") ManagementView mgtView;
-   
-   public void activateProfile(ProfileKey key) throws NoSuchProfileException, Exception
-   {
-      delegate.activateProfile(key);
-   }
-   public void deactivateProfile(ProfileKey key) throws NoSuchProfileException
-   {
-      delegate.deactivateProfile(key);  
-   }
-   public Profile getActiveProfile(ProfileKey key) throws NoSuchProfileException
-   {
-      return delegate.getActiveProfile(key);
-   }
-   public Collection<ProfileKey> getActiveProfileKeys()
-   {
-      return delegate.getActiveProfileKeys();
-   }
-   public DeploymentManager getDeploymentManager()
-   {
-      return delegate.getDeploymentManager();
-   }
-   public String[] getDomains()
-   {
-      return delegate.getDomains();
-   }
-   public Profile getProfile(ProfileKey key) throws NoSuchProfileException
-   {
-      return delegate.getProfile(key);
-   }
-   public Collection<ProfileKey> getProfileKeys()
-   {
-      return delegate.getProfileKeys();
-   }
-   public ManagementView getViewManager()
-   {
-      return delegate.getViewManager();
-   }
-   public void registerProfile(Profile profile) throws Exception
-   {
-      delegate.registerProfile(profile);
-   }
-   public void unregisterProfile(ProfileKey key) throws NoSuchProfileException
-   {
-      delegate.unregisterProfile(key);
-   }
-   public void validateProfile(ProfileKey key) throws Exception
-   {
-     delegate.validateProfile(key);
-   }
-
-}

Copied: trunk/profileservice/src/main/java/org/jboss/profileservice/ejb/SecureProfileServiceBean.java (from rev 97697, tags/JBoss_6_0_0_M1/profileservice/src/main/org/jboss/profileservice/ejb/SecureProfileServiceBean.java)
===================================================================
--- trunk/profileservice/src/main/java/org/jboss/profileservice/ejb/SecureProfileServiceBean.java	                        (rev 0)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/ejb/SecureProfileServiceBean.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -0,0 +1,104 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.profileservice.ejb;
+
+import java.util.Collection;
+
+import javax.annotation.Resource;
+import javax.annotation.security.RolesAllowed;
+import javax.ejb.EJB;
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+
+import org.jboss.deployers.spi.management.ManagementView;
+import org.jboss.deployers.spi.management.deploy.DeploymentManager;
+import org.jboss.ejb3.annotation.SecurityDomain;
+import org.jboss.profileservice.spi.NoSuchProfileException;
+import org.jboss.profileservice.spi.Profile;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.ProfileService;
+
+/**
+ * A secured ejb facade over the ProfileService interface
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+ at Stateless(name="SecureProfileService")
+ at SecurityDomain(value="jmx-console", unauthenticatedPrincipal="nobody")
+ at Remote(ProfileService.class)
+ at RolesAllowed({"JBossAdmin"})
+public class SecureProfileServiceBean implements ProfileService
+{
+   @Resource(mappedName="ProfileService")
+   private ProfileService delegate;
+   @EJB(beanName="SecureManagementView") ManagementView mgtView;
+   
+   public void activateProfile(ProfileKey key) throws NoSuchProfileException, Exception
+   {
+      delegate.activateProfile(key);
+   }
+   public void deactivateProfile(ProfileKey key) throws NoSuchProfileException
+   {
+      delegate.deactivateProfile(key);  
+   }
+   public Profile getActiveProfile(ProfileKey key) throws NoSuchProfileException
+   {
+      return delegate.getActiveProfile(key);
+   }
+   public Collection<ProfileKey> getActiveProfileKeys()
+   {
+      return delegate.getActiveProfileKeys();
+   }
+   public DeploymentManager getDeploymentManager()
+   {
+      return delegate.getDeploymentManager();
+   }
+   public String[] getDomains()
+   {
+      return delegate.getDomains();
+   }
+   public Profile getProfile(ProfileKey key) throws NoSuchProfileException
+   {
+      return delegate.getProfile(key);
+   }
+   public Collection<ProfileKey> getProfileKeys()
+   {
+      return delegate.getProfileKeys();
+   }
+   public ManagementView getViewManager()
+   {
+      return delegate.getViewManager();
+   }
+   public void registerProfile(Profile profile) throws Exception
+   {
+      delegate.registerProfile(profile);
+   }
+   public void unregisterProfile(ProfileKey key) throws NoSuchProfileException
+   {
+      delegate.unregisterProfile(key);
+   }
+   public void validateProfile(ProfileKey key) throws Exception
+   {
+     delegate.validateProfile(key);
+   }
+
+}

Copied: trunk/profileservice/src/main/java/org/jboss/profileservice/management/AggregatingManagementView.java (from rev 97697, tags/JBoss_6_0_0_M1/profileservice/src/main/org/jboss/profileservice/management/AggregatingManagementView.java)
===================================================================
--- trunk/profileservice/src/main/java/org/jboss/profileservice/management/AggregatingManagementView.java	                        (rev 0)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/management/AggregatingManagementView.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -0,0 +1,711 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.management;
+
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.ResourceBundle;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.jboss.deployers.client.spi.main.MainDeployer;
+import org.jboss.deployers.spi.management.DeploymentTemplate;
+import org.jboss.deployers.spi.management.ManagementView;
+import org.jboss.deployers.spi.management.NameMatcher;
+import org.jboss.deployers.spi.management.RuntimeComponentDispatcher;
+import org.jboss.logging.Logger;
+import org.jboss.managed.api.ComponentType;
+import org.jboss.managed.api.DeploymentTemplateInfo;
+import org.jboss.managed.api.Fields;
+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.annotation.ActivationPolicy;
+import org.jboss.managed.api.annotation.ViewUse;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.profileservice.management.views.AbstractProfileView;
+import org.jboss.profileservice.management.views.BootstrapProfileView;
+import org.jboss.profileservice.management.views.PlatformMbeansView;
+import org.jboss.profileservice.management.views.ProfileView;
+import org.jboss.profileservice.spi.NoSuchDeploymentException;
+import org.jboss.profileservice.spi.NoSuchProfileException;
+import org.jboss.profileservice.spi.Profile;
+import org.jboss.profileservice.spi.ProfileDeployment;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.ProfileService;
+import org.jboss.system.server.profileservice.attachments.AttachmentStore;
+
+/**
+ * A aggregating management view, handling profile views for all active profiles.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class AggregatingManagementView extends AbstractTemplateCreator implements ManagementView
+{
+
+   /** The logger. */
+   private static final Logger log = Logger.getLogger(AggregatingManagementView.class);
+   
+   /** The bundle name. */
+   private static final String BUNDLE_NAME = "org.jboss.profileservice.management.messages";
+   
+   /** The internationalization resource bundle. */
+   private ResourceBundle i18n;
+   /** the Locale for the i18n messages. */
+   private Locale currentLocale;
+   /** The formatter used for i18n messages. */
+   private MessageFormat formatter = new MessageFormat("");
+   
+   /** The profile service. */
+   private ProfileService ps;
+   
+   /** The runtime component dispatcher. */
+   private RuntimeComponentDispatcher dispatcher;
+   private ManagedOperationProxyFactory proxyFactory;
+   
+   /** The main deployer. */
+   private MainDeployer mainDeployer;
+   
+   /** The attachment store. */
+   private AttachmentStore store;
+   
+   /** The bootstrap deployment name to ManagedDeployment map. */
+   private Map<String, ManagedDeployment> bootstrapManagedDeployments = Collections.emptyMap(); 
+
+   /** The deployment templates that have been registered with the MV. */
+   private HashMap<String, DeploymentTemplate> templates = new HashMap<String, DeploymentTemplate>();
+   
+   /** The profile views. */
+   private Map<ProfileKey, AbstractProfileView> profileViews = new ConcurrentHashMap<ProfileKey, AbstractProfileView>();
+   
+   public AggregatingManagementView()
+   {
+      currentLocale = Locale.getDefault();
+      formatter.setLocale(currentLocale);
+      i18n = ResourceBundle.getBundle(BUNDLE_NAME, currentLocale);
+   }
+   
+   public RuntimeComponentDispatcher getDispatcher()
+   {
+      return dispatcher;
+   }
+   
+   public void setDispatcher(RuntimeComponentDispatcher dispatcher)
+   {
+      this.dispatcher = dispatcher;
+   }
+   
+   public ProfileService getProfileService()
+   {
+      return ps;
+   }
+
+   public void setProfileService(ProfileService ps)
+   {
+      this.ps = ps;
+   }
+
+   public ManagedOperationProxyFactory getProxyFactory()
+   {
+      return proxyFactory;
+   }
+   
+   public void setProxyFactory(ManagedOperationProxyFactory proxyFactory)
+   {
+      this.proxyFactory = proxyFactory;
+   }
+   
+   public AttachmentStore getAttachmentStore()
+   {
+      return store;
+   }
+   
+   public void setAttachmentStore(AttachmentStore store)
+   {
+      this.store = store;
+   }
+   
+   public MainDeployer getMainDeployer()
+   {
+      return mainDeployer;
+   }
+
+   public void setMainDeployer(MainDeployer mainDeployer)
+   {
+      this.mainDeployer = mainDeployer;
+   }
+   
+   public Map<String, ManagedDeployment> getBootstrapManagedDeployments()
+   {
+      return bootstrapManagedDeployments;
+   }
+   
+   public void setBootstrapManagedDeployments(Map<String, ManagedDeployment> bootstrapManagedDeployments)
+   {
+      this.bootstrapManagedDeployments = bootstrapManagedDeployments;
+   }
+   
+   public void start() throws Exception
+   {
+      if(this.proxyFactory == null)
+         throw new IllegalStateException("proxy factory not injected");
+      
+      // Add the platform MBeans
+      addView(new PlatformMbeansView(this.proxyFactory));
+      
+      // Add the bootstrap deployments
+      if(this.bootstrapManagedDeployments != null)
+      {
+         addView(new BootstrapProfileView(this.proxyFactory,
+                     this.bootstrapManagedDeployments.values()));
+      }
+   }
+   
+   public boolean load()
+   {
+      return loadProfiles(false);
+   }
+   
+   public void reload()
+   {
+      loadProfiles(true);
+   }
+   
+   public void process() throws Exception
+   {
+      // FIXME process
+   }
+   
+   public void addView(AbstractProfileView view)
+   {
+      if(view == null)
+         throw new IllegalArgumentException("null view");
+      if(view.getProfileKey() == null)
+         throw new IllegalArgumentException("null profile key");
+      
+      this.profileViews.put(view.getProfileKey(), view);
+      log.debug("add view: " + view);
+   }
+
+   public void removeView(AbstractProfileView view)
+   {
+      if(view == null)
+         throw new IllegalArgumentException("null view");
+      if(view.getProfileKey() == null)
+         throw new IllegalArgumentException("null profile key");
+      
+      this.profileViews.remove(view.getProfileKey());
+      log.debug("remove view: " + view);
+   }
+   
+   public void addTemplate(DeploymentTemplate template)
+   {
+      this.templates.put(template.getInfo().getName(), template);
+      log.debug("addTemplate: " + template);
+   }
+
+   public void removeTemplate(DeploymentTemplate template)
+   {
+      this.templates.remove(template.getInfo().getName());
+      log.debug("removeTemplate: " + template);
+   }
+
+   public void applyTemplate(String deploymentBaseName, DeploymentTemplateInfo info) throws Exception
+   {
+      if(deploymentBaseName == null)
+         throw new IllegalArgumentException("Null deployment base name.");
+      if(info == null)
+         throw new IllegalArgumentException("Null template info.");
+      
+      DeploymentTemplate template = templates.get(info.getName());
+      if( template == null )
+      {
+         formatter.applyPattern(i18n.getString("ManagementView.NoSuchTemplate"));
+         Object[] args = {info.getName()};
+         String msg = formatter.format(args);
+         throw new IllegalStateException(msg);
+      }
+
+      // Create a deployment base from the template
+      if( log.isTraceEnabled() )
+         log.trace("applyTemplate, deploymentBaseName=" + deploymentBaseName + ", info=" + info);
+      
+      // Apply the template
+      super.applyTemplate(template, deploymentBaseName, info);
+      
+      // reload this profile
+      this.profileViews.put(getDefaulProfiletKey(), createProfileView(getDefaulProfiletKey()));
+   }
+
+   public ManagedComponent getComponent(String name, ComponentType type) throws Exception
+   {
+      Set<ManagedComponent> components = getComponentsForType(type);
+      ManagedComponent comp = null;
+      if(components != null)
+      {
+         for(ManagedComponent mc : components)
+         {
+            if(mc.getName().equals(name))
+            {
+               comp = mc;
+               break;
+            }
+         }
+      }
+      if(comp != null)
+      {
+         Map<String, ManagedProperty> props = comp.getProperties();
+         Set<ManagedOperation> ops = comp.getOperations();
+         log.debug("Component"
+               +"(ops.size="
+               +ops != null ? ops.size() : 0
+               +",props.size=)"
+               +props != null ? props.size() : 0);
+      }
+      return comp;
+   }
+
+   
+   public Set<ComponentType> getComponentTypes()
+   {
+      Set<ComponentType> componentTypes = new HashSet<ComponentType>();
+      for(AbstractProfileView view : profileViews.values())
+      {
+         componentTypes.addAll(view.getComponentTypes());
+      }
+      return componentTypes;
+   }
+
+   public Set<ManagedComponent> getComponentsForType(ComponentType type) throws Exception
+   {
+      Set<ManagedComponent> components = new HashSet<ManagedComponent>();
+      for(AbstractProfileView view : profileViews.values())
+      {
+         components.addAll(view.getComponentsForType(type));
+      }
+      return components;
+   }
+
+   public ManagedDeployment getDeployment(String name) throws NoSuchDeploymentException
+   {
+      List<ManagedDeployment> deployments = new ArrayList<ManagedDeployment>();
+      for(AbstractProfileView view : profileViews.values())
+      {
+         deployments.addAll(view.getDeployment(name));
+      }
+      if(deployments.size() == 0)
+      {
+         throw new NoSuchDeploymentException(name);
+      }
+      else if(deployments.size() > 1)
+      {
+         throw new NoSuchDeploymentException("multiple matching deployments found for name: "  + name 
+               + ", available: " + deployments);
+      }
+      return deployments.get(0);
+   }
+
+   public Set<String> getDeploymentNames()
+   {
+      Set<String> deploymentNames = new TreeSet<String>();
+      for(AbstractProfileView view : profileViews.values())
+      {
+         deploymentNames.addAll(view.getDeploymentNames());
+      }
+      return deploymentNames;
+   }
+
+   public Set<String> getDeploymentNamesForType(String type)
+   {
+      Set<String> deploymentNames = new TreeSet<String>();
+      for(AbstractProfileView view : profileViews.values())
+      {
+         deploymentNames.addAll(view.getDeploymentNamesForType(type));
+      }
+      return deploymentNames;
+   }
+
+   public Set<ManagedDeployment> getDeploymentsForType(String type) throws Exception
+   {
+      Set<ManagedDeployment> deployments = new HashSet<ManagedDeployment>();
+      for(AbstractProfileView view : profileViews.values())
+      {
+         deployments.addAll(view.getDeploymentsForType(type));
+      }
+      return deployments;
+   }
+
+   public Set<ManagedComponent> getMatchingComponents(String name, ComponentType type,
+         NameMatcher<ManagedComponent> matcher)
+      throws Exception
+   {
+      Set<ManagedComponent> components = getComponentsForType(type);
+      Set<ManagedComponent> matched = new HashSet<ManagedComponent>();
+      if(components != null)
+      {
+         for(ManagedComponent mc : components)
+         {
+            if(matcher.matches(mc, name))
+               matched.add(mc);
+         }
+      }
+      if(matched.size() > 0)
+      {
+         log.debug("getComponents matched: "+matched);
+      }
+      return matched;
+   }
+
+   public Set<String> getMatchingDeploymentName(String regex)
+      throws NoSuchDeploymentException
+   {
+      Set<String> names = getDeploymentNames();
+      HashSet<String> matches = new HashSet<String>();
+      Pattern p = Pattern.compile(regex);
+      for(String name : names)
+      {
+         Matcher m = p.matcher(name);
+         if( m.matches() )
+            matches.add(name);
+      }
+      if( matches.size() == 0 )
+      {
+         formatter.applyPattern(i18n.getString("ManagementView.NoSuchDeploymentException")); //$NON-NLS-1$
+         Object[] args = {regex};
+         String msg = formatter.format(args);
+         throw new NoSuchDeploymentException(msg);
+      }
+      return matches;
+   }
+
+   public Set<ManagedDeployment> getMatchingDeployments(String name, NameMatcher<ManagedDeployment> matcher)
+         throws NoSuchDeploymentException, Exception
+   {
+      // FIXME getMatchingDeployments
+      return new HashSet<ManagedDeployment>();
+   }
+
+   public DeploymentTemplateInfo getTemplate(String name)
+      throws NoSuchDeploymentException
+   {
+      DeploymentTemplate template = templates.get(name);
+      if( template == null )
+      {
+         formatter.applyPattern(i18n.getString("ManagementView.NoSuchTemplate")); //$NON-NLS-1$
+         Object[] args = {name};
+         String msg = formatter.format(args);
+         throw new IllegalStateException(msg);
+      }
+   
+      // Make sure to return a copy to avoid call by reference uses modifying the template values
+      DeploymentTemplateInfo info = template.getInfo();
+      info = info.copy();
+      log.debug("getTemplate, "+info);
+      return info;
+   }
+
+   public Set<String> getTemplateNames()
+   {
+      return new HashSet<String>(templates.keySet());
+   }
+
+   public void removeComponent(ManagedComponent comp) throws Exception
+   {
+      if(comp == null)
+         throw new IllegalArgumentException("null managed component.");
+      //
+      ManagedDeployment md = comp.getDeployment();
+
+      // Get the parent
+      while( md.getParent() != null )
+         md = md.getParent();
+         
+      String name = md.getName();
+      ProfileDeployment profileDeployment = getProfileDeployment(name);
+      if( profileDeployment == null )
+      {
+         formatter.applyPattern(i18n.getString("ManagementView.NoSuchDeploymentException")); //$NON-NLS-1$
+         Object[] args = {name};
+         String msg = formatter.format(args);
+         throw new NoSuchDeploymentException(msg);
+      }
+      
+      // Apply the managed properties to the server ManagedDeployment/ManagedComponent
+      ManagedDeployment compMD = getDeployment(md.getName());
+      log.debug("updateComponent, deploymentName="+name+": "+compMD);
+      
+      ManagedComponent serverComp = null;
+      // Find the managed component again
+      if(comp.getDeployment().getParent() == null)
+      {
+         serverComp = compMD.getComponent(comp.getName());
+      }
+      else
+      {
+         // Look at the children
+         // TODO - support more levels of nested deployments ?
+         if(compMD.getChildren() != null && compMD.getChildren().isEmpty() == false)
+         {
+            for(ManagedDeployment child : compMD.getChildren())
+            {
+               if(serverComp != null)
+                  break;
+               
+               serverComp = child.getComponent(comp.getName());
+            }            
+         }
+      }
+      if(serverComp == null)
+      {
+         log.debug("Name: "+comp.getName()+" does not map to existing ManagedComponet in ManagedDeployment: "+md.getName()
+               + ", components: "+compMD.getComponents());
+         formatter.applyPattern(i18n.getString("ManagementView.InvalidComponentName")); //$NON-NLS-1$
+         Object[] args = {comp.getName(), md.getName()};
+         String msg = formatter.format(args);
+         throw new IllegalArgumentException(msg);
+      }
+      
+      //
+      log.debug("remove component: " + comp + ", deployment: "+ profileDeployment);
+      // Remove
+      Profile profile = getProfileForDeployment(md.getName());
+      this.store.removeComponent(comp.getDeployment().getName(), serverComp);      
+      this.profileViews.put(profile.getKey(), createProfileView(profile));
+   }
+
+   public void updateComponent(ManagedComponent comp)
+      throws Exception
+   {
+      if(comp == null)
+         throw new IllegalArgumentException("Null managed component.");
+      // Find the comp deployment
+      ManagedDeployment md = comp.getDeployment();
+   
+      // Get the parent
+      while( md.getParent() != null )
+         md = md.getParent();
+         
+      String name = md.getName();
+      ProfileDeployment compDeployment = getProfileDeployment(name);
+      if( compDeployment == null )
+      {
+         formatter.applyPattern(i18n.getString("ManagementView.NoSuchDeploymentException")); //$NON-NLS-1$
+         Object[] args = {name};
+         String msg = formatter.format(args);
+         throw new NoSuchDeploymentException(msg);
+      }
+   
+      // Apply the managed properties to the server ManagedDeployment/ManagedComponent
+      ManagedDeployment compMD = getDeployment(md.getName());
+      log.debug("updateComponent, deploymentName="+name+": "+compMD);
+      
+      ManagedComponent serverComp = null;
+      // Find the managed component again
+      if(comp.getDeployment().getParent() == null)
+      {
+         serverComp = compMD.getComponent(comp.getName());
+      }
+      else
+      {
+         // Look at the children
+         // TODO - support more levels of nested deployments ?
+         if(compMD.getChildren() != null && compMD.getChildren().isEmpty() == false)
+         {
+            for(ManagedDeployment child : compMD.getChildren())
+            {
+               if(serverComp != null)
+                  break;
+               
+               serverComp = child.getComponent(comp.getName());
+            }            
+         }
+      }
+      if(serverComp == null)
+      {
+         log.debug("Name: "+comp.getName()+" does not map to existing ManagedComponet in ManagedDeployment: " + md.getName()
+               + ", components: "+compMD.getComponents());
+         formatter.applyPattern(i18n.getString("ManagementView.InvalidComponentName")); //$NON-NLS-1$
+         Object[] args = {comp.getName(), md.getName()};
+         String msg = formatter.format(args);
+         throw new IllegalArgumentException(msg);
+      }
+   
+      // Dispatch any runtime component property values
+      for(ManagedProperty prop : comp.getProperties().values())
+      {
+         // Skip null values && non-CONFIGURATION values, unmodified values, and removed values
+         boolean skip = prop.getValue() == null
+            || prop.isReadOnly()
+            || prop.hasViewUse(ViewUse.CONFIGURATION) == false
+   //         || prop.isModified() == false
+            || prop.isRemoved() == true;
+         if( skip )
+         {
+            if(log.isTraceEnabled())
+               log.trace("Skipping component property: "+prop);
+            continue;
+         }
+   
+         ManagedProperty ctxProp = serverComp.getProperties().get(prop.getName());
+         // Check for a mapped name
+         if( ctxProp == null )
+         {
+            String mappedName = prop.getMappedName();
+            if( mappedName != null )
+               ctxProp = serverComp.getProperties().get(mappedName);
+         }
+         if( ctxProp == null )
+         {
+            formatter.applyPattern(i18n.getString("ManagementView.InvalidTemplateProperty")); //$NON-NLS-1$
+            Object[] args = {prop.getName()};
+            String msg = formatter.format(args);
+            throw new IllegalArgumentException(msg);
+         }
+         // The property value must be a MetaValue
+         Object value = prop.getValue();
+         if ((value instanceof MetaValue) == false)
+         {
+            formatter.applyPattern(i18n.getString("ManagementView.InvalidPropertyValue")); //$NON-NLS-1$
+            Object[] args = {prop.getName(), value.getClass()};
+            String msg = formatter.format(args);
+            throw new IllegalArgumentException(msg);
+         }
+         // Update the serverComp
+         MetaValue metaValue = (MetaValue)value;
+         ctxProp.setField(Fields.META_TYPE, metaValue.getMetaType());
+         ctxProp.setValue(metaValue);
+         
+         // Dispatch any runtime component property values
+         Object componentName = getComponentName(ctxProp);
+         ActivationPolicy policy = ctxProp.getActivationPolicy();
+         
+         if (componentName != null && policy.equals(ActivationPolicy.IMMEDIATE))
+         {
+            AbstractRuntimeComponentDispatcher.setActiveProperty(ctxProp);
+            dispatcher.set(componentName, ctxProp.getName(), metaValue);
+         }
+      }
+   
+      // Persist the changed values
+      Profile profile = getProfileForDeployment(md.getName());
+      this.store.updateDeployment(comp.getDeployment().getName(), serverComp);
+      this.profileViews.put(profile.getKey(), createProfileView(profile));
+   }
+
+   protected boolean loadProfiles(boolean forceReload)
+   {
+      boolean wasReloaded = false;
+      Collection<ProfileKey> activeProfiles = ps.getActiveProfileKeys();
+      for(ProfileKey key : activeProfiles)
+      {
+         if(loadProfile(key, forceReload))
+            wasReloaded = true;
+      }
+      return wasReloaded;      
+   }
+   
+   protected boolean loadProfile(ProfileKey key, boolean forceReload) 
+   {
+      boolean wasModified = false;
+      try
+      {
+         // The active profile
+         Profile profile = ps.getActiveProfile(key);
+         AbstractProfileView view = this.profileViews.get(profile.getKey());
+         
+         // Check if we need to reload the profile
+         wasModified = forceReload 
+            || view == null
+            || view.hasBeenModified(profile);
+         
+         if(wasModified)
+         {
+            this.profileViews.put(key, createProfileView(profile));
+            wasModified = true;
+         }         
+      }
+      catch(NoSuchProfileException e)
+      {
+         wasModified = profileViews.remove(key) != null;
+         log.debug("Failed to load profile " + key);
+      }
+      return wasModified;
+   }
+
+   protected AbstractProfileView createProfileView(ProfileKey key) throws NoSuchProfileException
+   {
+      Profile profile = this.ps.getActiveProfile(key);
+      return createProfileView(profile);
+   }
+   
+   protected AbstractProfileView createProfileView(Profile profile)
+   {
+      return new ProfileView(profile, proxyFactory, mainDeployer);
+   }
+   
+   protected Object getComponentName(ManagedProperty property)
+   {
+      // first check target
+      ManagedObject targetObject = property.getTargetManagedObject();
+      if (targetObject != null)
+         return targetObject.getComponentName();
+
+      // check owner
+      targetObject = property.getManagedObject();
+      return targetObject != null ? targetObject.getComponentName() : null;
+   }
+
+   private ProfileKey getProfileKeyForDeployemnt(String name) throws NoSuchDeploymentException
+   {
+      ManagedDeployment md = getDeployment(name);
+      return md.getAttachment(ProfileKey.class);
+   }
+   
+   private Profile getProfileForDeployment(String name) throws Exception
+   {
+      ProfileKey key = getProfileKeyForDeployemnt(name);
+      if(key == null)
+         throw new NoSuchDeploymentException("No associated profile found for deployment:" + name);
+      
+      return this.ps.getActiveProfile(key);
+   }
+   
+   private ProfileDeployment getProfileDeployment(String name) throws Exception
+   {
+      Profile profile = getProfileForDeployment(name);
+      return profile.getDeployment(name);
+   }
+   
+}

Deleted: trunk/profileservice/src/main/java/org/jboss/profileservice/management/MBeanManagedObjectFactory.java
===================================================================
--- trunk/profileservice/src/main/java/org/jboss/profileservice/management/MBeanManagedObjectFactory.java	2009-12-10 16:45:13 UTC (rev 97698)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/management/MBeanManagedObjectFactory.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -1,595 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.profileservice.management;
-
-import java.io.Serializable;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import javax.management.Descriptor;
-import javax.management.DescriptorAccess;
-import javax.management.MBeanAttributeInfo;
-import javax.management.MBeanFeatureInfo;
-import javax.management.MBeanInfo;
-import javax.management.MBeanOperationInfo;
-import javax.management.MBeanParameterInfo;
-import javax.management.ObjectName;
-
-import org.jboss.logging.Logger;
-import org.jboss.managed.api.Fields;
-import org.jboss.managed.api.ManagedObject;
-import org.jboss.managed.api.ManagedOperation;
-import org.jboss.managed.api.ManagedParameter;
-import org.jboss.managed.api.ManagedProperty;
-import org.jboss.managed.api.ManagedOperation.Impact;
-import org.jboss.managed.api.annotation.ActivationPolicy;
-import org.jboss.managed.api.annotation.DefaultValueBuilderFactory;
-import org.jboss.managed.api.annotation.FieldsFactory;
-import org.jboss.managed.api.annotation.ManagementConstants;
-import org.jboss.managed.api.annotation.ManagementObjectID;
-import org.jboss.managed.api.annotation.ManagementObjectRef;
-import org.jboss.managed.api.annotation.ManagementOperation;
-import org.jboss.managed.api.annotation.ManagementProperty;
-import org.jboss.managed.api.annotation.ManagementPropertyFactory;
-import org.jboss.managed.api.annotation.ManagementRuntimeRef;
-import org.jboss.managed.api.annotation.Masked;
-import org.jboss.managed.api.annotation.RunStateProperty;
-import org.jboss.managed.api.annotation.ViewUse;
-import org.jboss.managed.plugins.DefaultFieldsImpl;
-import org.jboss.managed.plugins.ManagedObjectImpl;
-import org.jboss.managed.plugins.ManagedOperationImpl;
-import org.jboss.managed.plugins.ManagedParameterImpl;
-import org.jboss.managed.plugins.ManagedPropertyImpl;
-import org.jboss.managed.plugins.factory.AbstractManagedObjectFactory;
-import org.jboss.metadata.spi.MetaData;
-import org.jboss.metatype.api.annotations.MetaMapping;
-import org.jboss.metatype.api.annotations.MetaMappingFactory;
-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.types.MetaTypeFactory;
-import org.jboss.metatype.api.values.MetaValue;
-import org.jboss.metatype.spi.values.DefaultValueBuilder;
-import org.jboss.metatype.spi.values.MetaMapper;
-import org.jboss.metatype.spi.values.MetaMapperFactory;
-
-/**
- * A type of ManagedObject factory that generates a ManagedObject from an MBean
- * MBeanInfo.
- *
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public class MBeanManagedObjectFactory
-{
-   private static Logger log = Logger.getLogger(MBeanManagedObjectFactory.class);
-   /** The meta type factory */
-   private MetaTypeFactory metaTypeFactory = MetaTypeFactory.getInstance();
-
-   public MetaTypeFactory getMetaTypeFactory()
-   {
-      return metaTypeFactory;
-   }
-   public void setMetaTypeFactory(MetaTypeFactory metaTypeFactory)
-   {
-      this.metaTypeFactory = metaTypeFactory;
-   }
-
-   /**
-    * Builds a ManagedObject from the MBeanInfo.
-    * TODO: none of the org.jboss.managed.api.annotation.* annotations are
-    * taken from the MBeanInfo. The descriptor feature could be used for this.
-    *
-    * @param mbean
-    * @param info
-    * @param mbeanLoader
-    * @param metaData
-    * @return
-    * @throws Exception
-    */
-
-   public ManagedObject getManagedObject(ObjectName mbean, MBeanInfo info,
-         ClassLoader mbeanLoader, MetaData metaData)
-      throws Exception
-   {
-      return getManagedObject(mbean, info, mbeanLoader, metaData, null, null);
-   }
-
-   // FIXME - Hack until metadata mechanism is provided
-   public ManagedObject getManagedObject(ObjectName mbean, MBeanInfo info,
-         ClassLoader mbeanLoader, MetaData metaData, ViewUse[] defaultViewUse, Map<String, String> propertyMetaMappings)
-      throws Exception
-   {
-      boolean trace = log.isTraceEnabled();
-
-      // Process the ManagementObject fields
-      boolean isRuntime = false;
-      String name = mbean.getCanonicalName();
-      String nameType = null;
-      String attachmentName = null;
-      Class<? extends Fields> moFieldsFactory = null;
-      Class<? extends ManagedProperty> moPropertyFactory = null;
-
-      // Build the ManagedProperties
-      Set<ManagedProperty> properties = new HashSet<ManagedProperty>();
-
-      MBeanAttributeInfo[] attributes = info.getAttributes();
-      for(MBeanAttributeInfo propertyInfo : attributes)
-      {
-
-            ManagementProperty managementProperty = getAnnotation(ManagementProperty.class, propertyInfo, metaData);
-            ManagementObjectID id = getAnnotation(ManagementObjectID.class, propertyInfo, metaData);
-            ManagementObjectRef ref = getAnnotation(ManagementObjectRef.class, propertyInfo, metaData);
-            ManagementRuntimeRef runtimeRef = getAnnotation(ManagementRuntimeRef.class, propertyInfo, metaData);
-            RunStateProperty rsp = getAnnotation(RunStateProperty.class, propertyInfo, metaData);
-            Masked masked = getAnnotation(Masked.class, propertyInfo, metaData);
-            DefaultValueBuilderFactory defaultsFactory = getAnnotation(DefaultValueBuilderFactory.class, propertyInfo, metaData);
-            HashMap<String, Annotation> propAnnotations = new HashMap<String, Annotation>();
-            if (managementProperty != null)
-               propAnnotations.put(ManagementProperty.class.getName(), managementProperty);
-            if (id != null)
-            {
-               propAnnotations.put(ManagementObjectID.class.getName(), id);
-               // This overrides the MO nameType
-               nameType = id.type();
-            }
-            if (ref != null)
-               propAnnotations.put(ManagementObjectRef.class.getName(), ref);
-            if (runtimeRef != null)
-               propAnnotations.put(ManagementRuntimeRef.class.getName(), runtimeRef);
-            if (rsp != null)
-               propAnnotations.put(RunStateProperty.class.getName(), rsp);
-            if (masked != null)
-               propAnnotations.put(Masked.class.getName(), masked);
-
-            // Check whether this property should be included
-            boolean includeProperty = propertyInfo.isReadable() | propertyInfo.isWritable();
-
-            if (includeProperty)
-            {
-               Fields fields = null;
-               Class<? extends Fields> factory = moFieldsFactory;
-               FieldsFactory ff = getAnnotation(FieldsFactory.class, propertyInfo, metaData);
-               if(ff != null)
-                  factory = ff.value();
-               if (factory != null)
-               {
-                  try
-                  {
-                     fields = factory.newInstance();
-                  }
-                  catch (Exception e)
-                  {
-                     log.debug("Failed to created Fields", e);
-                  }
-               }
-               if (fields == null)
-                  fields = new DefaultFieldsImpl();
-
-               if( propertyInfo instanceof Serializable )
-               {
-                  Serializable pinfo = Serializable.class.cast(propertyInfo);
-                  fields.setField(Fields.PROPERTY_INFO, pinfo);
-               }
-
-               String propertyName = propertyInfo.getName();
-               if (managementProperty != null)
-                  propertyName = managementProperty.name();
-               if( propertyName.length() == 0 )
-                  propertyName = propertyInfo.getName();
-               fields.setField(Fields.NAME, propertyName);
-
-               // This should probably always the the propertyInfo name?
-               String mappedName = propertyInfo.getName();
-               if (managementProperty != null)
-                  mappedName = managementProperty.mappedName();
-               if( mappedName.length() == 0 )
-                  mappedName = propertyInfo.getName();
-               fields.setField(Fields.MAPPED_NAME, mappedName);
-
-               String description = ManagementConstants.GENERATED;
-               if (managementProperty != null)
-                  description = managementProperty.description();
-               if (description.equals(ManagementConstants.GENERATED))
-                  description = propertyName;
-               fields.setField(Fields.DESCRIPTION, description);
-
-               if (trace)
-               {
-                  log.trace("Building MangedProperty(name="+propertyName
-                        +",mappedName="+mappedName
-                        +") ,annotations="+propAnnotations);
-               }
-
-               boolean mandatory = false;
-               if (managementProperty != null)
-                  mandatory = managementProperty.mandatory();
-               if (mandatory)
-                  fields.setField(Fields.MANDATORY, Boolean.TRUE);
-
-               boolean readOnly = propertyInfo.isWritable() == false;
-               if (readOnly == false && managementProperty != null)
-                  readOnly = managementProperty.readOnly();
-               if (readOnly)
-                  fields.setField(Fields.READ_ONLY, Boolean.TRUE);
-
-               boolean managed = false;
-               if (managementProperty != null)
-                  managed = managementProperty.managed();
-               // View Use
-               if (managementProperty != null)
-               {
-                  ViewUse[] use = managementProperty.use();
-                  fields.setField(Fields.VIEW_USE, use);
-               }
-               else if (defaultViewUse != null)
-               {
-                  fields.setField(Fields.VIEW_USE, defaultViewUse);
-               }
-               // ActivationPolicy
-               ActivationPolicy apolicy = ActivationPolicy.IMMEDIATE;
-               if (managementProperty != null)
-               {
-                  apolicy = managementProperty.activationPolicy();
-               }
-               fields.setField(Fields.ACTIVATION_POLICY, apolicy);
-               // The managed property type
-               MetaMapper[] mapperReturn = {null};
-               String propertyType = propertyInfo.getType();
-               MetaType metaType = null;
-               Class<?> type = null;
-               try
-               {
-                  type = loadTypeClass(propertyType, mbeanLoader);
-                  metaType = this.getMetaType(propertyInfo, type, metaData, false, propertyMetaMappings, mapperReturn);
-               }
-               catch(Exception e)
-               {
-                  log.debug("Failed to create ManagedProperty on failure to load type:"+propertyType+", for property: "+propertyInfo.getName());
-                  continue;
-               }
-
-               // Determine meta type based on property type
-               if(metaType == null)
-               {
-                  if (managed)
-                  {
-                     if(type.isArray())
-                        metaType = new ArrayMetaType(1, AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE);
-                     else if (Collection.class.isAssignableFrom(type))
-                        metaType = new CollectionMetaType(type.getName(), AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE);
-                     else
-                        metaType = AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE;
-                  }
-                  else
-                  {
-                     metaType = metaTypeFactory.resolve(type);
-                  }
-               }
-               fields.setField(Fields.META_TYPE, metaType);
-
-               // Default value
-               if(managementProperty != null)
-               {
-                  String defaultValue = managementProperty.defaultValue();
-                  if(defaultValue.length() > 0)
-                  {
-                     try
-                     {
-                       // Check for a DefaultValueBuilderFactory
-                        DefaultValueBuilder builder = null;
-                        if(defaultsFactory != null)
-                        {
-                              Class<? extends DefaultValueBuilder> factoryClass = defaultsFactory.value();
-                              builder = factoryClass.newInstance();
-                        }
-                        if(builder != null)
-                        {
-                           MetaValue defaultMV = builder.buildMetaValue(defaultValue);
-                           if(defaultMV != null)
-                              fields.setField(Fields.DEFAULT_VALUE, defaultMV);
-                        }
-                        else
-                        {
-                           log.warn("Failed to find DefaultValueBuilder for type: "+metaType);
-                        }
-                     }
-                     catch(Exception e)
-                     {
-                        log.warn("Failed to create default value for: "+propertyInfo, e);
-                     }
-                  }
-               }
-
-               // Property annotations
-               if (propAnnotations.isEmpty() == false)
-                  fields.setField(Fields.ANNOTATIONS, propAnnotations);
-
-               ManagedProperty property = null;
-               Class<? extends ManagedProperty> mpClass = moPropertyFactory;
-               ManagementPropertyFactory mpf = getAnnotation(ManagementPropertyFactory.class, propertyInfo, metaData);
-               if (mpf != null)
-                  mpClass = mpf.value();
-               if (mpClass != null)
-                  property = AbstractManagedObjectFactory.createManagedProperty(mpClass, fields);
-               if (property == null)
-                  property = new ManagedPropertyImpl(fields);
-               // Pass the MetaMapper as an attachment
-               if (mapperReturn[0] != null)
-                  property.setTransientAttachment(MetaMapper.class.getName(), mapperReturn[0]);
-               properties.add(property);
-            }
-            else if (trace)
-               log.trace("Ignoring property: " + propertyInfo);
-      }
-
-      /* TODO: Operations. In general the bean metadata does not contain
-         operation information.
-      */
-      Set<ManagedOperation> operations = new HashSet<ManagedOperation>();
-
-      MBeanOperationInfo[] methodInfos = info.getOperations();
-      if (methodInfos != null && methodInfos.length > 0)
-      {
-         for (MBeanOperationInfo methodInfo : methodInfos)
-         {
-            ManagementOperation managementOp = getAnnotation(ManagementOperation.class, methodInfo, metaData);
-            try
-            {
-               ManagedOperation op = getManagedOperation(methodInfo, managementOp, mbeanLoader, metaData);
-               operations.add(op);
-            }
-            catch(Exception e)
-            {
-               log.debug("Failed to create ManagedOperation for: "+methodInfo.getName(), e);
-            }
-         }
-      }
-
-      ManagedObjectImpl result = new ManagedObjectImpl(mbean.getCanonicalName(), properties);
-      // TODO
-      Map<String, Annotation> empty = Collections.emptyMap();
-      result.setAnnotations(empty);
-      // Set the component name to name if this is a runtime MO with a name specified
-      result.setComponentName(name);
-      if (nameType != null)
-         result.setNameType(nameType);
-      if (attachmentName != null)
-         result.setAttachmentName(attachmentName);
-      if (operations.size() > 0 )
-         result.setOperations(operations);
-      for (ManagedProperty property : properties)
-         property.setManagedObject(result);
-      result.setTransientAttachment(MBeanInfo.class.getName(), info);
-
-      // Marker for associating the correct dispatcher
-      result.setTransientAttachment(MBeanRuntimeComponentDispatcher.class.getName(), true);
-      return result;
-   }
-
-   protected <X extends Annotation> X getAnnotation(Class<X> annotationType,
-         MBeanFeatureInfo info, MetaData metaData)
-   {
-      X annotation = null;
-      if(metaData != null)
-      {
-         annotation = metaData.getAnnotation(annotationType);
-         if(annotation == null && info instanceof DescriptorAccess)
-         {
-            DescriptorAccess daccess = (DescriptorAccess) info;
-            Descriptor descriptor = daccess.getDescriptor();
-            annotation = getAnnotation(annotationType, descriptor);
-         }
-      }
-      return annotation;
-   }
-   protected <X extends Annotation> X getAnnotation(Class<X> annotationType,
-         Descriptor descriptor)
-   {
-      // TODO...
-      return null;
-   }
-
-   /**
-    * Get the MetaType for info by looking for MetaMapping/MetaMappingFactory
-    * annotations in addition to the info type.
-    *
-    * @param methodInfo
-    * @param metaData
-    * @return the MetaType for info's type
-    */
-   protected MetaType getMetaType(MBeanFeatureInfo info, Type infoType, MetaData metaData,
-         boolean useTypeFactory, Map<String, String> propertyMetaMappings, MetaMapper[] mapperReturn)
-   {
-      MetaType returnType = null;
-      // First look for meta mappings
-      MetaMapper<?> metaMapper = null;
-      MetaMapping metaMapping = getAnnotation(MetaMapping.class, info, metaData);
-      MetaMappingFactory metaMappingFactory = getAnnotation(MetaMappingFactory.class, info, metaData);
-      if(metaMappingFactory != null)
-      {
-         Class<? extends MetaMapperFactory<?>> mmfClass = metaMappingFactory.value();
-         try
-         {
-            MetaMapperFactory<?> mmf = mmfClass.newInstance();
-            String[] args = metaMappingFactory.args();
-            if(args.length > 0)
-               metaMapper = mmf.newInstance(args);
-            else
-               metaMapper = mmf.newInstance();
-         }
-         catch(Exception e)
-         {
-            log.debug("Failed to create MetaMapperFactory: "+metaMappingFactory, e);
-         }
-      }
-      if(metaMapping != null)
-      {
-         // Use the mapping for the type
-         Class<? extends MetaMapper<?>> mapperClass = metaMapping.value();
-         try
-         {
-            metaMapper = mapperClass.newInstance();
-         }
-         catch(Exception e)
-         {
-            log.debug("Failed to create MetaMapper: "+metaMapping, e);
-         }
-      }
-
-      if (info instanceof MBeanAttributeInfo && propertyMetaMappings != null)
-      {
-         String className = propertyMetaMappings.get(info.getName());
-         if (className != null)
-         {
-            try
-            {
-               // Use the same loader of the profile service
-               metaMapper = (MetaMapper<?>)Class.forName(className).newInstance();
-            }
-            catch (Exception e)
-            {
-               log.debug("Failed to create MetaMapper: " + className + " for property: " + info.getName());
-            }
-         }
-      }
-
-      if(metaMapper != null)
-      {
-         returnType = metaMapper.getMetaType();
-         // Return the MetaMapper
-         if(mapperReturn != null && mapperReturn.length > 0)
-            mapperReturn[0] = metaMapper;
-      }
-
-      if(returnType == null && useTypeFactory)
-      {
-         // Use the type factory to convert the info type
-         returnType = metaTypeFactory.resolve(infoType);
-      }
-      return returnType;
-   }
-
-   protected ManagedOperation getManagedOperation(MBeanOperationInfo methodInfo,
-         ManagementOperation opAnnotation, ClassLoader mbeanLoader, MetaData metaData)
-      throws Exception
-   {
-      String name = methodInfo.getName();
-      String description = opAnnotation != null ? opAnnotation.description() : name;
-      Impact impact = Impact.Unknown;
-      switch(methodInfo.getImpact())
-      {
-         case MBeanOperationInfo.ACTION:
-            impact = Impact.WriteOnly;
-            break;
-         case MBeanOperationInfo.ACTION_INFO:
-            impact = Impact.ReadWrite;
-            break;
-         case MBeanOperationInfo.INFO:
-            impact = Impact.ReadOnly;
-            break;
-         case MBeanOperationInfo.UNKNOWN:
-            impact = Impact.Unknown;
-            break;
-      }
-      // The op return type
-      MetaMapper[] returnTypeMapper = {null};
-      Class<?> returnTypeClass = loadTypeClass(methodInfo.getReturnType(), mbeanLoader);
-      MetaType returnType = getMetaType(methodInfo, returnTypeClass, metaData, true, null, returnTypeMapper);
-
-      // Process the op parameters
-      ArrayList<ManagedParameter> mparams = new ArrayList<ManagedParameter>();
-      MBeanParameterInfo[] paramInfo = methodInfo.getSignature();
-      if( paramInfo != null )
-      {
-         for(int i = 0; i < paramInfo.length; i ++)
-         {
-            MBeanParameterInfo pinfo = paramInfo[i];
-            String pname = pinfo.getName();
-            String pdescription = pinfo.getDescription();
-
-            // Generate a name if there is none
-            if (pname == null)
-               pname = "arg#" + i;
-            Fields fields =  new DefaultFieldsImpl(pname);
-            if (pdescription != null)
-               fields.setField(Fields.DESCRIPTION, pdescription);
-            MetaMapper[] paramMapper = {null};
-            Class<?> paramType = loadTypeClass(pinfo.getType(), mbeanLoader);
-            MetaType metaType = getMetaType(pinfo, paramType, metaData, true, null, paramMapper);
-            fields.setField(Fields.META_TYPE, metaType);
-
-
-            ManagedParameterImpl mp = new ManagedParameterImpl(fields);
-            if(paramMapper[0] != null)
-               mp.setTransientAttachment(MetaMapper.class.getName(), paramMapper[0]);
-            mparams.add(mp);
-         }
-      }
-      ManagedParameter[] parameters = new ManagedParameter[mparams.size()];
-      mparams.toArray(parameters);
-
-      ManagedOperationImpl op = new ManagedOperationImpl(name, description, impact, parameters, returnType);
-      if(returnTypeMapper[0] != null)
-         op.setTransientAttachment(MetaMapper.class.getName(), returnTypeMapper[0]);
-      return op;
-   }
-
-   protected Class<?> loadTypeClass(String propertyType, ClassLoader loader)
-      throws ClassNotFoundException
-   {
-      Class<?> type = null;
-      // Check for a primitive type
-      if(propertyType.equals("byte"))
-         type = byte.class;
-      else if(propertyType.equals("char"))
-         type = char.class;
-      else if(propertyType.equals("short"))
-         type = short.class;
-      else if(propertyType.equals("int"))
-         type = int.class;
-      else if(propertyType.equals("long"))
-         type = long.class;
-      else if(propertyType.equals("float"))
-         type = float.class;
-      else if(propertyType.equals("double"))
-         type = double.class;
-      else if(propertyType.equals("void"))
-         type = void.class;
-      else if(propertyType.equals("boolean"))
-         type = boolean.class;
-
-      else
-      {
-         type = loader.loadClass(propertyType);
-      }
-      return type;
-
-   }
-}

Copied: trunk/profileservice/src/main/java/org/jboss/profileservice/management/MBeanManagedObjectFactory.java (from rev 97697, tags/JBoss_6_0_0_M1/profileservice/src/main/org/jboss/profileservice/management/MBeanManagedObjectFactory.java)
===================================================================
--- trunk/profileservice/src/main/java/org/jboss/profileservice/management/MBeanManagedObjectFactory.java	                        (rev 0)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/management/MBeanManagedObjectFactory.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -0,0 +1,595 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.profileservice.management;
+
+import java.io.Serializable;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import javax.management.Descriptor;
+import javax.management.DescriptorAccess;
+import javax.management.MBeanAttributeInfo;
+import javax.management.MBeanFeatureInfo;
+import javax.management.MBeanInfo;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanParameterInfo;
+import javax.management.ObjectName;
+
+import org.jboss.logging.Logger;
+import org.jboss.managed.api.Fields;
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.api.ManagedOperation;
+import org.jboss.managed.api.ManagedParameter;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.managed.api.ManagedOperation.Impact;
+import org.jboss.managed.api.annotation.ActivationPolicy;
+import org.jboss.managed.api.annotation.DefaultValueBuilderFactory;
+import org.jboss.managed.api.annotation.FieldsFactory;
+import org.jboss.managed.api.annotation.ManagementConstants;
+import org.jboss.managed.api.annotation.ManagementObjectID;
+import org.jboss.managed.api.annotation.ManagementObjectRef;
+import org.jboss.managed.api.annotation.ManagementOperation;
+import org.jboss.managed.api.annotation.ManagementProperty;
+import org.jboss.managed.api.annotation.ManagementPropertyFactory;
+import org.jboss.managed.api.annotation.ManagementRuntimeRef;
+import org.jboss.managed.api.annotation.Masked;
+import org.jboss.managed.api.annotation.RunStateProperty;
+import org.jboss.managed.api.annotation.ViewUse;
+import org.jboss.managed.plugins.DefaultFieldsImpl;
+import org.jboss.managed.plugins.ManagedObjectImpl;
+import org.jboss.managed.plugins.ManagedOperationImpl;
+import org.jboss.managed.plugins.ManagedParameterImpl;
+import org.jboss.managed.plugins.ManagedPropertyImpl;
+import org.jboss.managed.plugins.factory.AbstractManagedObjectFactory;
+import org.jboss.metadata.spi.MetaData;
+import org.jboss.metatype.api.annotations.MetaMapping;
+import org.jboss.metatype.api.annotations.MetaMappingFactory;
+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.types.MetaTypeFactory;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.spi.values.DefaultValueBuilder;
+import org.jboss.metatype.spi.values.MetaMapper;
+import org.jboss.metatype.spi.values.MetaMapperFactory;
+
+/**
+ * A type of ManagedObject factory that generates a ManagedObject from an MBean
+ * MBeanInfo.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class MBeanManagedObjectFactory
+{
+   private static Logger log = Logger.getLogger(MBeanManagedObjectFactory.class);
+   /** The meta type factory */
+   private MetaTypeFactory metaTypeFactory = MetaTypeFactory.getInstance();
+
+   public MetaTypeFactory getMetaTypeFactory()
+   {
+      return metaTypeFactory;
+   }
+   public void setMetaTypeFactory(MetaTypeFactory metaTypeFactory)
+   {
+      this.metaTypeFactory = metaTypeFactory;
+   }
+
+   /**
+    * Builds a ManagedObject from the MBeanInfo.
+    * TODO: none of the org.jboss.managed.api.annotation.* annotations are
+    * taken from the MBeanInfo. The descriptor feature could be used for this.
+    *
+    * @param mbean
+    * @param info
+    * @param mbeanLoader
+    * @param metaData
+    * @return
+    * @throws Exception
+    */
+
+   public ManagedObject getManagedObject(ObjectName mbean, MBeanInfo info,
+         ClassLoader mbeanLoader, MetaData metaData)
+      throws Exception
+   {
+      return getManagedObject(mbean, info, mbeanLoader, metaData, null, null);
+   }
+
+   // FIXME - Hack until metadata mechanism is provided
+   public ManagedObject getManagedObject(ObjectName mbean, MBeanInfo info,
+         ClassLoader mbeanLoader, MetaData metaData, ViewUse[] defaultViewUse, Map<String, String> propertyMetaMappings)
+      throws Exception
+   {
+      boolean trace = log.isTraceEnabled();
+
+      // Process the ManagementObject fields
+      boolean isRuntime = false;
+      String name = mbean.getCanonicalName();
+      String nameType = null;
+      String attachmentName = null;
+      Class<? extends Fields> moFieldsFactory = null;
+      Class<? extends ManagedProperty> moPropertyFactory = null;
+
+      // Build the ManagedProperties
+      Set<ManagedProperty> properties = new HashSet<ManagedProperty>();
+
+      MBeanAttributeInfo[] attributes = info.getAttributes();
+      for(MBeanAttributeInfo propertyInfo : attributes)
+      {
+
+            ManagementProperty managementProperty = getAnnotation(ManagementProperty.class, propertyInfo, metaData);
+            ManagementObjectID id = getAnnotation(ManagementObjectID.class, propertyInfo, metaData);
+            ManagementObjectRef ref = getAnnotation(ManagementObjectRef.class, propertyInfo, metaData);
+            ManagementRuntimeRef runtimeRef = getAnnotation(ManagementRuntimeRef.class, propertyInfo, metaData);
+            RunStateProperty rsp = getAnnotation(RunStateProperty.class, propertyInfo, metaData);
+            Masked masked = getAnnotation(Masked.class, propertyInfo, metaData);
+            DefaultValueBuilderFactory defaultsFactory = getAnnotation(DefaultValueBuilderFactory.class, propertyInfo, metaData);
+            HashMap<String, Annotation> propAnnotations = new HashMap<String, Annotation>();
+            if (managementProperty != null)
+               propAnnotations.put(ManagementProperty.class.getName(), managementProperty);
+            if (id != null)
+            {
+               propAnnotations.put(ManagementObjectID.class.getName(), id);
+               // This overrides the MO nameType
+               nameType = id.type();
+            }
+            if (ref != null)
+               propAnnotations.put(ManagementObjectRef.class.getName(), ref);
+            if (runtimeRef != null)
+               propAnnotations.put(ManagementRuntimeRef.class.getName(), runtimeRef);
+            if (rsp != null)
+               propAnnotations.put(RunStateProperty.class.getName(), rsp);
+            if (masked != null)
+               propAnnotations.put(Masked.class.getName(), masked);
+
+            // Check whether this property should be included
+            boolean includeProperty = propertyInfo.isReadable() | propertyInfo.isWritable();
+
+            if (includeProperty)
+            {
+               Fields fields = null;
+               Class<? extends Fields> factory = moFieldsFactory;
+               FieldsFactory ff = getAnnotation(FieldsFactory.class, propertyInfo, metaData);
+               if(ff != null)
+                  factory = ff.value();
+               if (factory != null)
+               {
+                  try
+                  {
+                     fields = factory.newInstance();
+                  }
+                  catch (Exception e)
+                  {
+                     log.debug("Failed to created Fields", e);
+                  }
+               }
+               if (fields == null)
+                  fields = new DefaultFieldsImpl();
+
+               if( propertyInfo instanceof Serializable )
+               {
+                  Serializable pinfo = Serializable.class.cast(propertyInfo);
+                  fields.setField(Fields.PROPERTY_INFO, pinfo);
+               }
+
+               String propertyName = propertyInfo.getName();
+               if (managementProperty != null)
+                  propertyName = managementProperty.name();
+               if( propertyName.length() == 0 )
+                  propertyName = propertyInfo.getName();
+               fields.setField(Fields.NAME, propertyName);
+
+               // This should probably always the the propertyInfo name?
+               String mappedName = propertyInfo.getName();
+               if (managementProperty != null)
+                  mappedName = managementProperty.mappedName();
+               if( mappedName.length() == 0 )
+                  mappedName = propertyInfo.getName();
+               fields.setField(Fields.MAPPED_NAME, mappedName);
+
+               String description = ManagementConstants.GENERATED;
+               if (managementProperty != null)
+                  description = managementProperty.description();
+               if (description.equals(ManagementConstants.GENERATED))
+                  description = propertyName;
+               fields.setField(Fields.DESCRIPTION, description);
+
+               if (trace)
+               {
+                  log.trace("Building MangedProperty(name="+propertyName
+                        +",mappedName="+mappedName
+                        +") ,annotations="+propAnnotations);
+               }
+
+               boolean mandatory = false;
+               if (managementProperty != null)
+                  mandatory = managementProperty.mandatory();
+               if (mandatory)
+                  fields.setField(Fields.MANDATORY, Boolean.TRUE);
+
+               boolean readOnly = propertyInfo.isWritable() == false;
+               if (readOnly == false && managementProperty != null)
+                  readOnly = managementProperty.readOnly();
+               if (readOnly)
+                  fields.setField(Fields.READ_ONLY, Boolean.TRUE);
+
+               boolean managed = false;
+               if (managementProperty != null)
+                  managed = managementProperty.managed();
+               // View Use
+               if (managementProperty != null)
+               {
+                  ViewUse[] use = managementProperty.use();
+                  fields.setField(Fields.VIEW_USE, use);
+               }
+               else if (defaultViewUse != null)
+               {
+                  fields.setField(Fields.VIEW_USE, defaultViewUse);
+               }
+               // ActivationPolicy
+               ActivationPolicy apolicy = ActivationPolicy.IMMEDIATE;
+               if (managementProperty != null)
+               {
+                  apolicy = managementProperty.activationPolicy();
+               }
+               fields.setField(Fields.ACTIVATION_POLICY, apolicy);
+               // The managed property type
+               MetaMapper[] mapperReturn = {null};
+               String propertyType = propertyInfo.getType();
+               MetaType metaType = null;
+               Class<?> type = null;
+               try
+               {
+                  type = loadTypeClass(propertyType, mbeanLoader);
+                  metaType = this.getMetaType(propertyInfo, type, metaData, false, propertyMetaMappings, mapperReturn);
+               }
+               catch(Exception e)
+               {
+                  log.debug("Failed to create ManagedProperty on failure to load type:"+propertyType+", for property: "+propertyInfo.getName());
+                  continue;
+               }
+
+               // Determine meta type based on property type
+               if(metaType == null)
+               {
+                  if (managed)
+                  {
+                     if(type.isArray())
+                        metaType = new ArrayMetaType(1, AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE);
+                     else if (Collection.class.isAssignableFrom(type))
+                        metaType = new CollectionMetaType(type.getName(), AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE);
+                     else
+                        metaType = AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE;
+                  }
+                  else
+                  {
+                     metaType = metaTypeFactory.resolve(type);
+                  }
+               }
+               fields.setField(Fields.META_TYPE, metaType);
+
+               // Default value
+               if(managementProperty != null)
+               {
+                  String defaultValue = managementProperty.defaultValue();
+                  if(defaultValue.length() > 0)
+                  {
+                     try
+                     {
+                       // Check for a DefaultValueBuilderFactory
+                        DefaultValueBuilder builder = null;
+                        if(defaultsFactory != null)
+                        {
+                              Class<? extends DefaultValueBuilder> factoryClass = defaultsFactory.value();
+                              builder = factoryClass.newInstance();
+                        }
+                        if(builder != null)
+                        {
+                           MetaValue defaultMV = builder.buildMetaValue(defaultValue);
+                           if(defaultMV != null)
+                              fields.setField(Fields.DEFAULT_VALUE, defaultMV);
+                        }
+                        else
+                        {
+                           log.warn("Failed to find DefaultValueBuilder for type: "+metaType);
+                        }
+                     }
+                     catch(Exception e)
+                     {
+                        log.warn("Failed to create default value for: "+propertyInfo, e);
+                     }
+                  }
+               }
+
+               // Property annotations
+               if (propAnnotations.isEmpty() == false)
+                  fields.setField(Fields.ANNOTATIONS, propAnnotations);
+
+               ManagedProperty property = null;
+               Class<? extends ManagedProperty> mpClass = moPropertyFactory;
+               ManagementPropertyFactory mpf = getAnnotation(ManagementPropertyFactory.class, propertyInfo, metaData);
+               if (mpf != null)
+                  mpClass = mpf.value();
+               if (mpClass != null)
+                  property = AbstractManagedObjectFactory.createManagedProperty(mpClass, fields);
+               if (property == null)
+                  property = new ManagedPropertyImpl(fields);
+               // Pass the MetaMapper as an attachment
+               if (mapperReturn[0] != null)
+                  property.setTransientAttachment(MetaMapper.class.getName(), mapperReturn[0]);
+               properties.add(property);
+            }
+            else if (trace)
+               log.trace("Ignoring property: " + propertyInfo);
+      }
+
+      /* TODO: Operations. In general the bean metadata does not contain
+         operation information.
+      */
+      Set<ManagedOperation> operations = new HashSet<ManagedOperation>();
+
+      MBeanOperationInfo[] methodInfos = info.getOperations();
+      if (methodInfos != null && methodInfos.length > 0)
+      {
+         for (MBeanOperationInfo methodInfo : methodInfos)
+         {
+            ManagementOperation managementOp = getAnnotation(ManagementOperation.class, methodInfo, metaData);
+            try
+            {
+               ManagedOperation op = getManagedOperation(methodInfo, managementOp, mbeanLoader, metaData);
+               operations.add(op);
+            }
+            catch(Exception e)
+            {
+               log.debug("Failed to create ManagedOperation for: "+methodInfo.getName(), e);
+            }
+         }
+      }
+
+      ManagedObjectImpl result = new ManagedObjectImpl(mbean.getCanonicalName(), properties);
+      // TODO
+      Map<String, Annotation> empty = Collections.emptyMap();
+      result.setAnnotations(empty);
+      // Set the component name to name if this is a runtime MO with a name specified
+      result.setComponentName(name);
+      if (nameType != null)
+         result.setNameType(nameType);
+      if (attachmentName != null)
+         result.setAttachmentName(attachmentName);
+      if (operations.size() > 0 )
+         result.setOperations(operations);
+      for (ManagedProperty property : properties)
+         property.setManagedObject(result);
+      result.setTransientAttachment(MBeanInfo.class.getName(), info);
+
+      // Marker for associating the correct dispatcher
+      result.setTransientAttachment(MBeanRuntimeComponentDispatcher.class.getName(), true);
+      return result;
+   }
+
+   protected <X extends Annotation> X getAnnotation(Class<X> annotationType,
+         MBeanFeatureInfo info, MetaData metaData)
+   {
+      X annotation = null;
+      if(metaData != null)
+      {
+         annotation = metaData.getAnnotation(annotationType);
+         if(annotation == null && info instanceof DescriptorAccess)
+         {
+            DescriptorAccess daccess = (DescriptorAccess) info;
+            Descriptor descriptor = daccess.getDescriptor();
+            annotation = getAnnotation(annotationType, descriptor);
+         }
+      }
+      return annotation;
+   }
+   protected <X extends Annotation> X getAnnotation(Class<X> annotationType,
+         Descriptor descriptor)
+   {
+      // TODO...
+      return null;
+   }
+
+   /**
+    * Get the MetaType for info by looking for MetaMapping/MetaMappingFactory
+    * annotations in addition to the info type.
+    *
+    * @param methodInfo
+    * @param metaData
+    * @return the MetaType for info's type
+    */
+   protected MetaType getMetaType(MBeanFeatureInfo info, Type infoType, MetaData metaData,
+         boolean useTypeFactory, Map<String, String> propertyMetaMappings, MetaMapper[] mapperReturn)
+   {
+      MetaType returnType = null;
+      // First look for meta mappings
+      MetaMapper<?> metaMapper = null;
+      MetaMapping metaMapping = getAnnotation(MetaMapping.class, info, metaData);
+      MetaMappingFactory metaMappingFactory = getAnnotation(MetaMappingFactory.class, info, metaData);
+      if(metaMappingFactory != null)
+      {
+         Class<? extends MetaMapperFactory<?>> mmfClass = metaMappingFactory.value();
+         try
+         {
+            MetaMapperFactory<?> mmf = mmfClass.newInstance();
+            String[] args = metaMappingFactory.args();
+            if(args.length > 0)
+               metaMapper = mmf.newInstance(args);
+            else
+               metaMapper = mmf.newInstance();
+         }
+         catch(Exception e)
+         {
+            log.debug("Failed to create MetaMapperFactory: "+metaMappingFactory, e);
+         }
+      }
+      if(metaMapping != null)
+      {
+         // Use the mapping for the type
+         Class<? extends MetaMapper<?>> mapperClass = metaMapping.value();
+         try
+         {
+            metaMapper = mapperClass.newInstance();
+         }
+         catch(Exception e)
+         {
+            log.debug("Failed to create MetaMapper: "+metaMapping, e);
+         }
+      }
+
+      if (info instanceof MBeanAttributeInfo && propertyMetaMappings != null)
+      {
+         String className = propertyMetaMappings.get(info.getName());
+         if (className != null)
+         {
+            try
+            {
+               // Use the same loader of the profile service
+               metaMapper = (MetaMapper<?>)Class.forName(className).newInstance();
+            }
+            catch (Exception e)
+            {
+               log.debug("Failed to create MetaMapper: " + className + " for property: " + info.getName());
+            }
+         }
+      }
+
+      if(metaMapper != null)
+      {
+         returnType = metaMapper.getMetaType();
+         // Return the MetaMapper
+         if(mapperReturn != null && mapperReturn.length > 0)
+            mapperReturn[0] = metaMapper;
+      }
+
+      if(returnType == null && useTypeFactory)
+      {
+         // Use the type factory to convert the info type
+         returnType = metaTypeFactory.resolve(infoType);
+      }
+      return returnType;
+   }
+
+   protected ManagedOperation getManagedOperation(MBeanOperationInfo methodInfo,
+         ManagementOperation opAnnotation, ClassLoader mbeanLoader, MetaData metaData)
+      throws Exception
+   {
+      String name = methodInfo.getName();
+      String description = opAnnotation != null ? opAnnotation.description() : name;
+      Impact impact = Impact.Unknown;
+      switch(methodInfo.getImpact())
+      {
+         case MBeanOperationInfo.ACTION:
+            impact = Impact.WriteOnly;
+            break;
+         case MBeanOperationInfo.ACTION_INFO:
+            impact = Impact.ReadWrite;
+            break;
+         case MBeanOperationInfo.INFO:
+            impact = Impact.ReadOnly;
+            break;
+         case MBeanOperationInfo.UNKNOWN:
+            impact = Impact.Unknown;
+            break;
+      }
+      // The op return type
+      MetaMapper[] returnTypeMapper = {null};
+      Class<?> returnTypeClass = loadTypeClass(methodInfo.getReturnType(), mbeanLoader);
+      MetaType returnType = getMetaType(methodInfo, returnTypeClass, metaData, true, null, returnTypeMapper);
+
+      // Process the op parameters
+      ArrayList<ManagedParameter> mparams = new ArrayList<ManagedParameter>();
+      MBeanParameterInfo[] paramInfo = methodInfo.getSignature();
+      if( paramInfo != null )
+      {
+         for(int i = 0; i < paramInfo.length; i ++)
+         {
+            MBeanParameterInfo pinfo = paramInfo[i];
+            String pname = pinfo.getName();
+            String pdescription = pinfo.getDescription();
+
+            // Generate a name if there is none
+            if (pname == null)
+               pname = "arg#" + i;
+            Fields fields =  new DefaultFieldsImpl(pname);
+            if (pdescription != null)
+               fields.setField(Fields.DESCRIPTION, pdescription);
+            MetaMapper[] paramMapper = {null};
+            Class<?> paramType = loadTypeClass(pinfo.getType(), mbeanLoader);
+            MetaType metaType = getMetaType(pinfo, paramType, metaData, true, null, paramMapper);
+            fields.setField(Fields.META_TYPE, metaType);
+
+
+            ManagedParameterImpl mp = new ManagedParameterImpl(fields);
+            if(paramMapper[0] != null)
+               mp.setTransientAttachment(MetaMapper.class.getName(), paramMapper[0]);
+            mparams.add(mp);
+         }
+      }
+      ManagedParameter[] parameters = new ManagedParameter[mparams.size()];
+      mparams.toArray(parameters);
+
+      ManagedOperationImpl op = new ManagedOperationImpl(name, description, impact, parameters, returnType);
+      if(returnTypeMapper[0] != null)
+         op.setTransientAttachment(MetaMapper.class.getName(), returnTypeMapper[0]);
+      return op;
+   }
+
+   protected Class<?> loadTypeClass(String propertyType, ClassLoader loader)
+      throws ClassNotFoundException
+   {
+      Class<?> type = null;
+      // Check for a primitive type
+      if(propertyType.equals("byte"))
+         type = byte.class;
+      else if(propertyType.equals("char"))
+         type = char.class;
+      else if(propertyType.equals("short"))
+         type = short.class;
+      else if(propertyType.equals("int"))
+         type = int.class;
+      else if(propertyType.equals("long"))
+         type = long.class;
+      else if(propertyType.equals("float"))
+         type = float.class;
+      else if(propertyType.equals("double"))
+         type = double.class;
+      else if(propertyType.equals("void"))
+         type = void.class;
+      else if(propertyType.equals("boolean"))
+         type = boolean.class;
+
+      else
+      {
+         type = loader.loadClass(propertyType);
+      }
+      return type;
+
+   }
+}

Deleted: trunk/profileservice/src/main/java/org/jboss/profileservice/management/MBeanRuntimeComponentDispatcher.java
===================================================================
--- trunk/profileservice/src/main/java/org/jboss/profileservice/management/MBeanRuntimeComponentDispatcher.java	2009-12-10 16:45:13 UTC (rev 97698)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/management/MBeanRuntimeComponentDispatcher.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -1,227 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, 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.management;
-
-import java.lang.reflect.UndeclaredThrowableException;
-import java.util.Arrays;
-
-import javax.management.Attribute;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-
-import org.jboss.dependency.spi.ControllerState;
-import org.jboss.deployers.spi.management.ContextStateMapper;
-import org.jboss.managed.api.ManagedOperation;
-import org.jboss.managed.api.ManagedParameter;
-import org.jboss.managed.api.ManagedProperty;
-import org.jboss.metatype.api.values.EnumValueSupport;
-import org.jboss.metatype.api.values.MetaValue;
-import org.jboss.metatype.api.values.MetaValueFactory;
-import org.jboss.metatype.spi.values.MetaMapper;
-import org.jboss.profileservice.spi.types.ControllerStateMetaType;
-
-/**
- * MBean runtime component dispatcher.
- *
- * @author Jason T. Greene
- * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
- * @author Scott.Stark at jboss.org
- */
-public class MBeanRuntimeComponentDispatcher extends AbstractRuntimeComponentDispatcher
-{
-   private final MBeanServer mbeanServer;
-
-   public MBeanRuntimeComponentDispatcher(MBeanServer mbeanServer)
-   {
-      this(mbeanServer, null);
-   }
-
-   public MBeanRuntimeComponentDispatcher(MBeanServer mbeanServer, MetaValueFactory valueFactory)
-   {
-      super(valueFactory);
-      if (mbeanServer == null)
-         throw new IllegalArgumentException("Null MBean Server");
-
-      this.mbeanServer = mbeanServer;
-   }
-
-   public void start()
-   {
-   }
-
-   public MetaValue get(Object componentName, String propertyName)
-   {
-      ManagedProperty prop = AbstractRuntimeComponentDispatcher.getActiveProperty();
-      
-      if(propertyName.equals("state") && prop.getMetaType().equals(ControllerStateMetaType.TYPE))
-      {
-         String stateString = getState(componentName);
-         EnumValueSupport state = new EnumValueSupport(ControllerStateMetaType.TYPE, stateString);
-         return state;
-      }
-      
-      try
-      {
-         Object value = mbeanServer.getAttribute(new ObjectName(componentName.toString()), propertyName);
-         MetaValue mvalue = null;
-         if(value != null)
-         {
-            if(prop != null)
-            {
-               MetaMapper mapper = prop.getTransientAttachment(MetaMapper.class);
-               if(mapper != null)
-                  mvalue = mapper.createMetaValue(prop.getMetaType(), value);
-               else
-                  mvalue = create(value);
-            }
-            else
-            {
-               mvalue = create(value);
-            }
-         }
-         return mvalue;
-      }
-      catch (Throwable t)
-      {
-         throw new UndeclaredThrowableException(t, "Failed to get property '" + propertyName + "' on component '" + componentName + "'.");
-      }
-   }
-
-   public void set(Object componentName, String propertyName, MetaValue value)
-   {
-      try
-      {
-         ManagedProperty prop = AbstractRuntimeComponentDispatcher.getActiveProperty();
-         Object uvalue = null;
-         if(prop != null)
-         {
-            MetaMapper mapper = prop.getTransientAttachment(MetaMapper.class);
-            if(mapper != null)
-               uvalue = mapper.unwrapMetaValue(value);
-            else
-               uvalue = unwrap(value);
-         }
-         else
-         {
-            uvalue = unwrap(value);
-         }
-
-         mbeanServer.setAttribute(new ObjectName(componentName.toString()), new Attribute(propertyName, uvalue));
-      }
-      catch (Throwable t)
-      {
-         throw new UndeclaredThrowableException(t, "Failed to set property '" + propertyName + "' on component '" + componentName + "' to value [" + value + "].");
-      }
-   }
-
-   public Object invoke(Object componentName, String methodName, MetaValue... param)
-   {
-      try
-      {
-         ManagedOperation op = AbstractRuntimeComponentDispatcher.getActiveOperation();
-         String[] sig = new String[param.length];
-         Object[] args = new Object[param.length];
-         if(op != null)
-         {
-            ManagedParameter[] params = op.getParameters();
-            if(params != null &&  params.length == param.length)
-            {
-               for(int i=0; i < param.length; i++)
-               {
-                  ManagedParameter mp = params[i];
-                  MetaMapper<?> mapper = mp.getTransientAttachment(MetaMapper.class);
-                  if(mapper != null)
-                     args[i] = mapper.unwrapMetaValue(param[i]);
-                  else
-                     args[i] = unwrap(param[i]);
-                  //
-                  sig[i] = mp.getMetaType().getTypeName();
-               }
-            }
-            else
-            {
-               args = toArguments(param);
-               sig = toSignature(param);
-            }
-         }
-         else
-         {
-            args = toArguments(param);
-            sig = toSignature(param);
-         }
-         // Invoke
-         Object value = mbeanServer.invoke(new ObjectName(componentName.toString()), methodName, args, sig);
-         MetaValue mvalue = null;
-         if (value != null)
-         {
-            // Look for a return type MetaMapper
-            MetaMapper returnTypeMapper = op.getTransientAttachment(MetaMapper.class);
-            if (returnTypeMapper != null)
-               mvalue = returnTypeMapper.createMetaValue(op.getReturnType(), value);
-            else
-               mvalue = create(value);
-         }
-         return mvalue;
-      }
-      catch (Throwable t)
-      {
-         throw new UndeclaredThrowableException(t, "Failed to invoke method '" + methodName + "' on component '" + componentName + "' with parameters " + Arrays.asList(param) + ".");
-      }
-   }
-
-   public String getState(Object name)
-   {
-      try
-      {
-         if (mbeanServer.isRegistered(new ObjectName(name.toString())))
-            return ControllerState.INSTALLED.getStateString();
-      }
-      catch (Exception e)
-      {
-         // Failure = Not installed
-      }
-      
-      return ControllerState.NOT_INSTALLED.getStateString();
-   }
-
-   public <T extends Enum<?>> T mapControllerState(Object name, ContextStateMapper<T> mapper)
-   {
-      if(name == null)
-         throw new IllegalArgumentException("null name");
-      if(mapper == null)
-         throw new IllegalArgumentException("null mapper");
-
-      ControllerState current = ControllerState.NOT_INSTALLED;
-      
-      try
-      {
-         if (mbeanServer.isRegistered(new ObjectName(name.toString())))
-            current = ControllerState.INSTALLED;
-      }
-      catch (Exception e)
-      {
-         // Failure = Not installed
-      }
-      
-      return mapper.map(current, ControllerState.INSTALLED);
-   }
-}

Copied: trunk/profileservice/src/main/java/org/jboss/profileservice/management/MBeanRuntimeComponentDispatcher.java (from rev 97697, tags/JBoss_6_0_0_M1/profileservice/src/main/org/jboss/profileservice/management/MBeanRuntimeComponentDispatcher.java)
===================================================================
--- trunk/profileservice/src/main/java/org/jboss/profileservice/management/MBeanRuntimeComponentDispatcher.java	                        (rev 0)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/management/MBeanRuntimeComponentDispatcher.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -0,0 +1,227 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.management;
+
+import java.lang.reflect.UndeclaredThrowableException;
+import java.util.Arrays;
+
+import javax.management.Attribute;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.deployers.spi.management.ContextStateMapper;
+import org.jboss.managed.api.ManagedOperation;
+import org.jboss.managed.api.ManagedParameter;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.metatype.api.values.EnumValueSupport;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.MetaValueFactory;
+import org.jboss.metatype.spi.values.MetaMapper;
+import org.jboss.profileservice.spi.types.ControllerStateMetaType;
+
+/**
+ * MBean runtime component dispatcher.
+ *
+ * @author Jason T. Greene
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ * @author Scott.Stark at jboss.org
+ */
+public class MBeanRuntimeComponentDispatcher extends AbstractRuntimeComponentDispatcher
+{
+   private final MBeanServer mbeanServer;
+
+   public MBeanRuntimeComponentDispatcher(MBeanServer mbeanServer)
+   {
+      this(mbeanServer, null);
+   }
+
+   public MBeanRuntimeComponentDispatcher(MBeanServer mbeanServer, MetaValueFactory valueFactory)
+   {
+      super(valueFactory);
+      if (mbeanServer == null)
+         throw new IllegalArgumentException("Null MBean Server");
+
+      this.mbeanServer = mbeanServer;
+   }
+
+   public void start()
+   {
+   }
+
+   public MetaValue get(Object componentName, String propertyName)
+   {
+      ManagedProperty prop = AbstractRuntimeComponentDispatcher.getActiveProperty();
+      
+      if(propertyName.equals("state") && prop.getMetaType().equals(ControllerStateMetaType.TYPE))
+      {
+         String stateString = getState(componentName);
+         EnumValueSupport state = new EnumValueSupport(ControllerStateMetaType.TYPE, stateString);
+         return state;
+      }
+      
+      try
+      {
+         Object value = mbeanServer.getAttribute(new ObjectName(componentName.toString()), propertyName);
+         MetaValue mvalue = null;
+         if(value != null)
+         {
+            if(prop != null)
+            {
+               MetaMapper mapper = prop.getTransientAttachment(MetaMapper.class);
+               if(mapper != null)
+                  mvalue = mapper.createMetaValue(prop.getMetaType(), value);
+               else
+                  mvalue = create(value);
+            }
+            else
+            {
+               mvalue = create(value);
+            }
+         }
+         return mvalue;
+      }
+      catch (Throwable t)
+      {
+         throw new UndeclaredThrowableException(t, "Failed to get property '" + propertyName + "' on component '" + componentName + "'.");
+      }
+   }
+
+   public void set(Object componentName, String propertyName, MetaValue value)
+   {
+      try
+      {
+         ManagedProperty prop = AbstractRuntimeComponentDispatcher.getActiveProperty();
+         Object uvalue = null;
+         if(prop != null)
+         {
+            MetaMapper mapper = prop.getTransientAttachment(MetaMapper.class);
+            if(mapper != null)
+               uvalue = mapper.unwrapMetaValue(value);
+            else
+               uvalue = unwrap(value);
+         }
+         else
+         {
+            uvalue = unwrap(value);
+         }
+
+         mbeanServer.setAttribute(new ObjectName(componentName.toString()), new Attribute(propertyName, uvalue));
+      }
+      catch (Throwable t)
+      {
+         throw new UndeclaredThrowableException(t, "Failed to set property '" + propertyName + "' on component '" + componentName + "' to value [" + value + "].");
+      }
+   }
+
+   public Object invoke(Object componentName, String methodName, MetaValue... param)
+   {
+      try
+      {
+         ManagedOperation op = AbstractRuntimeComponentDispatcher.getActiveOperation();
+         String[] sig = new String[param.length];
+         Object[] args = new Object[param.length];
+         if(op != null)
+         {
+            ManagedParameter[] params = op.getParameters();
+            if(params != null &&  params.length == param.length)
+            {
+               for(int i=0; i < param.length; i++)
+               {
+                  ManagedParameter mp = params[i];
+                  MetaMapper<?> mapper = mp.getTransientAttachment(MetaMapper.class);
+                  if(mapper != null)
+                     args[i] = mapper.unwrapMetaValue(param[i]);
+                  else
+                     args[i] = unwrap(param[i]);
+                  //
+                  sig[i] = mp.getMetaType().getTypeName();
+               }
+            }
+            else
+            {
+               args = toArguments(param);
+               sig = toSignature(param);
+            }
+         }
+         else
+         {
+            args = toArguments(param);
+            sig = toSignature(param);
+         }
+         // Invoke
+         Object value = mbeanServer.invoke(new ObjectName(componentName.toString()), methodName, args, sig);
+         MetaValue mvalue = null;
+         if (value != null)
+         {
+            // Look for a return type MetaMapper
+            MetaMapper returnTypeMapper = op.getTransientAttachment(MetaMapper.class);
+            if (returnTypeMapper != null)
+               mvalue = returnTypeMapper.createMetaValue(op.getReturnType(), value);
+            else
+               mvalue = create(value);
+         }
+         return mvalue;
+      }
+      catch (Throwable t)
+      {
+         throw new UndeclaredThrowableException(t, "Failed to invoke method '" + methodName + "' on component '" + componentName + "' with parameters " + Arrays.asList(param) + ".");
+      }
+   }
+
+   public String getState(Object name)
+   {
+      try
+      {
+         if (mbeanServer.isRegistered(new ObjectName(name.toString())))
+            return ControllerState.INSTALLED.getStateString();
+      }
+      catch (Exception e)
+      {
+         // Failure = Not installed
+      }
+      
+      return ControllerState.NOT_INSTALLED.getStateString();
+   }
+
+   public <T extends Enum<?>> T mapControllerState(Object name, ContextStateMapper<T> mapper)
+   {
+      if(name == null)
+         throw new IllegalArgumentException("null name");
+      if(mapper == null)
+         throw new IllegalArgumentException("null mapper");
+
+      ControllerState current = ControllerState.NOT_INSTALLED;
+      
+      try
+      {
+         if (mbeanServer.isRegistered(new ObjectName(name.toString())))
+            current = ControllerState.INSTALLED;
+      }
+      catch (Exception e)
+      {
+         // Failure = Not installed
+      }
+      
+      return mapper.map(current, ControllerState.INSTALLED);
+   }
+}

Modified: trunk/profileservice/src/main/java/org/jboss/profileservice/management/ManagementViewImpl.java
===================================================================
--- trunk/profileservice/src/main/java/org/jboss/profileservice/management/ManagementViewImpl.java	2009-12-10 16:45:13 UTC (rev 97698)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/management/ManagementViewImpl.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -997,7 +997,8 @@
    public void setProfileService(ProfileService ps)
    {
       this.ps = ps;
-      log.debug("setProfileService: "+ps);
+      if(log.isTraceEnabled())
+         log.trace("setProfileService: "+ps);
    }
 
    public ManagedOperationProxyFactory getProxyFactory()
@@ -1028,7 +1029,8 @@
    public void setMainDeployer(MainDeployer mainDeployer)
    {
       this.mainDeployer = mainDeployer;
-      log.debug("setMainDeployer: "+mainDeployer);
+      if(log.isTraceEnabled())
+         log.trace("setMainDeployer: "+mainDeployer);
    }
 
    public MetaValueFactory getMetaValueFactory()
@@ -1119,12 +1121,16 @@
    }
 
    public Set<String> getMatchingDeploymentName(String regex)
-      throws NoSuchDeploymentException
    {
       SecurityManager sm = System.getSecurityManager();
       if(sm != null)
+      {
          sm.checkPermission(MV_RUNTIME_PERMISSION);
-
+      }
+      if(regex == null)
+      {
+         throw new IllegalArgumentException("null regex");
+      }
       Set<String> names = getDeploymentNames();
       HashSet<String> matches = new HashSet<String>();
       Pattern p = Pattern.compile(regex);
@@ -1132,26 +1138,36 @@
       {
          Matcher m = p.matcher(name);
          if( m.matches() )
+         {
             matches.add(name);
+         }
       }
-      if( matches.size() == 0 )
-      {
-         formatter.applyPattern(i18n.getString("ManagementView.NoSuchDeploymentException")); //$NON-NLS-1$
-         Object[] args = {regex};
-         String msg = formatter.format(args);
-         throw new NoSuchDeploymentException(msg);
-      }
       return matches;
    }
+   
    public Set<ManagedDeployment> getMatchingDeployments(String name, NameMatcher<ManagedDeployment> matcher)
-      throws NoSuchDeploymentException, Exception
    {
       SecurityManager sm = System.getSecurityManager();
       if(sm != null)
+      {
          sm.checkPermission(MV_RUNTIME_PERMISSION);
-
+      }
+      if(name == null)
+      {
+         throw new IllegalArgumentException("null deployment name");
+      }
+      if(matcher == null)
+      {
+         throw new IllegalArgumentException("null deployment matcher");
+      }
       Set<ManagedDeployment> matches = new HashSet<ManagedDeployment>();
-      // TODO
+      for(ManagedDeployment deployment : this.managedDeployments.values())
+      {
+         if(matcher.matches(deployment, name))
+         {
+            matches.add(deployment);
+         }
+      }
       return matches;
    }
 

Deleted: trunk/profileservice/src/main/java/org/jboss/profileservice/management/PlatformMBeanIDC.java
===================================================================
--- trunk/profileservice/src/main/java/org/jboss/profileservice/management/PlatformMBeanIDC.java	2009-12-10 16:45:13 UTC (rev 97698)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/management/PlatformMBeanIDC.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -1,82 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.profileservice.management;
-
-import javax.management.Attribute;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-
-import org.jboss.dependency.spi.ControllerState;
-import org.jboss.dependency.spi.dispatch.InvokeDispatchContext;
-import org.jboss.kernel.plugins.registry.AbstractKernelRegistryEntry;
-
-/**
- * An extension of AbstractKernelRegistryEntry that implements InvokeDispatchContext
- * to handle access to the platform mbeans.
- * 
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public class PlatformMBeanIDC extends AbstractKernelRegistryEntry
-   implements InvokeDispatchContext
-{
-   private MBeanServer server;
-   private ObjectName objectName;
-
-   
-   public PlatformMBeanIDC(MBeanServer server, ObjectName objectName,
-         Object mbean)
-   {
-      super(objectName.getCanonicalName(), mbean);
-      this.server = server;
-      this.objectName = objectName;
-   }
-
-   public ClassLoader getClassLoader() throws Throwable
-   {
-      return server.getClassLoaderFor(objectName);
-   }
-
-   public Object invoke(String operationName, Object[] parameters, String[] signature)
-         throws Throwable
-   {
-      return server.invoke(objectName, operationName, parameters, signature);
-   }
-
-   public Object get(String name) throws Throwable
-   {
-      return server.getAttribute(objectName, name);
-   }
-
-   public void set(String name, Object value) throws Throwable
-   {
-      Attribute attribute = new Attribute(name, value);
-      server.setAttribute(objectName, attribute);
-   }
-
-   @Override
-   public ControllerState getState()
-   {
-      return ControllerState.INSTALLED;
-   }
-   
-}

Copied: trunk/profileservice/src/main/java/org/jboss/profileservice/management/PlatformMBeanIDC.java (from rev 97697, tags/JBoss_6_0_0_M1/profileservice/src/main/org/jboss/profileservice/management/PlatformMBeanIDC.java)
===================================================================
--- trunk/profileservice/src/main/java/org/jboss/profileservice/management/PlatformMBeanIDC.java	                        (rev 0)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/management/PlatformMBeanIDC.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.profileservice.management;
+
+import javax.management.Attribute;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.dependency.spi.dispatch.InvokeDispatchContext;
+import org.jboss.kernel.plugins.registry.AbstractKernelRegistryEntry;
+
+/**
+ * An extension of AbstractKernelRegistryEntry that implements InvokeDispatchContext
+ * to handle access to the platform mbeans.
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class PlatformMBeanIDC extends AbstractKernelRegistryEntry
+   implements InvokeDispatchContext
+{
+   private MBeanServer server;
+   private ObjectName objectName;
+
+   
+   public PlatformMBeanIDC(MBeanServer server, ObjectName objectName,
+         Object mbean)
+   {
+      super(objectName.getCanonicalName(), mbean);
+      this.server = server;
+      this.objectName = objectName;
+   }
+
+   public ClassLoader getClassLoader() throws Throwable
+   {
+      return server.getClassLoaderFor(objectName);
+   }
+
+   public Object invoke(String operationName, Object[] parameters, String[] signature)
+         throws Throwable
+   {
+      return server.invoke(objectName, operationName, parameters, signature);
+   }
+
+   public Object get(String name) throws Throwable
+   {
+      return server.getAttribute(objectName, name);
+   }
+
+   public void set(String name, Object value) throws Throwable
+   {
+      Attribute attribute = new Attribute(name, value);
+      server.setAttribute(objectName, attribute);
+   }
+
+   @Override
+   public ControllerState getState()
+   {
+      return ControllerState.INSTALLED;
+   }
+   
+}

Deleted: trunk/profileservice/src/main/java/org/jboss/profileservice/management/PlatformMBeanKernelRegistryPlugin.java
===================================================================
--- trunk/profileservice/src/main/java/org/jboss/profileservice/management/PlatformMBeanKernelRegistryPlugin.java	2009-12-10 16:45:13 UTC (rev 97698)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/management/PlatformMBeanKernelRegistryPlugin.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -1,182 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.profileservice.management;
-
-import java.lang.management.ClassLoadingMXBean;
-import java.lang.management.CompilationMXBean;
-import java.lang.management.GarbageCollectorMXBean;
-import java.lang.management.ManagementFactory;
-import java.lang.management.MemoryMXBean;
-import java.lang.management.MemoryManagerMXBean;
-import java.lang.management.MemoryPoolMXBean;
-import java.lang.management.OperatingSystemMXBean;
-import java.lang.management.RuntimeMXBean;
-import java.lang.management.ThreadMXBean;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.management.InstanceNotFoundException;
-import javax.management.MBeanServer;
-import javax.management.ObjectInstance;
-import javax.management.ObjectName;
-
-import org.jboss.kernel.spi.registry.KernelRegistryEntry;
-import org.jboss.kernel.spi.registry.KernelRegistryPlugin;
-import org.jboss.system.ServiceController;
-
-/**
- * A KernelRegistryPlugin that make the j2se platform mbeans visible.
- * 
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public class PlatformMBeanKernelRegistryPlugin implements KernelRegistryPlugin
-{
-   private Map<String, KernelRegistryEntry> mbeans = new HashMap<String, KernelRegistryEntry>();
-   /** The service controller */
-   private ServiceController serviceController;
-   private MBeanServer mbeanServer;
-   
-   public ServiceController getServiceController()
-   {
-      return serviceController;
-   }
-   public void setServiceController(ServiceController serviceController)
-   {
-      this.serviceController = serviceController;
-   }
-
-   public MBeanServer getMbeanServer()
-   {
-      return mbeanServer;
-   }
-   public void setMbeanServer(MBeanServer mbeanServer)
-   {
-      this.mbeanServer = mbeanServer;
-   }
-
-   public KernelRegistryEntry getEntry(Object name)
-   {
-      String key;
-      ObjectName oname = null;
-      if(name instanceof ObjectName)
-      {
-         oname = ObjectName.class.cast(name);
-         key = oname.getCanonicalName();
-      }
-      else
-         key = name.toString();
-      KernelRegistryEntry entry = mbeans.get(key);
-      // If
-      if(entry == null && oname != null)
-      {
-         System.out.println("Searching for MBean: "+oname);
-         try
-         {
-            ObjectInstance oi = mbeanServer.getObjectInstance(oname);
-            System.out.println("Found "+oname+", "+oi.getClassName());
-         }
-         catch (InstanceNotFoundException e)
-         {
-            e.printStackTrace();
-         }
-      }
-      return entry;
-   }
-
-   public void start()
-      throws Throwable
-   {
-      MBeanServer server = ManagementFactory.getPlatformMBeanServer();
-
-      // ClassLoadingMXBean
-      ClassLoadingMXBean clmbean = ManagementFactory.getClassLoadingMXBean();
-      ObjectName clname = new ObjectName(ManagementFactory.CLASS_LOADING_MXBEAN_NAME);
-      PlatformMBeanIDC clidc = new PlatformMBeanIDC(server, clname, clmbean);
-      mbeans.put(clname.getCanonicalName(), clidc);
-
-      // CompilationMXBean
-      CompilationMXBean cmbean = ManagementFactory.getCompilationMXBean();
-      ObjectName cmname = new ObjectName(ManagementFactory.COMPILATION_MXBEAN_NAME);
-      PlatformMBeanIDC cmidc = new PlatformMBeanIDC(server, cmname, cmbean);
-      mbeans.put(cmname.getCanonicalName(), cmidc);
-
-      // GarbageCollectorMXBeans
-      List<GarbageCollectorMXBean> gcbeans = ManagementFactory.getGarbageCollectorMXBeans();
-      for(GarbageCollectorMXBean mbean : gcbeans)
-      {
-         String name = mbean.getName();
-         ObjectName oname = new ObjectName(ManagementFactory.GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE+name);
-         String cname = oname.getCanonicalName();
-         PlatformMBeanIDC gcidc = new PlatformMBeanIDC(server, oname, mbean);
-         mbeans.put(cname, gcidc);
-      }
-      // getMemoryManagerMXBeans
-      List<MemoryManagerMXBean> mmbeans = ManagementFactory.getMemoryManagerMXBeans();
-      for(MemoryManagerMXBean mbean : mmbeans)
-      {
-         String name = mbean.getName();
-         ObjectName oname = new ObjectName(ManagementFactory.MEMORY_MANAGER_MXBEAN_DOMAIN_TYPE+name);
-         String cname = oname.getCanonicalName();
-         PlatformMBeanIDC mmidc = new PlatformMBeanIDC(server, oname, mbean);
-         mbeans.put(cname, mmidc);
-      }
-      // MemoryMXBean
-      MemoryMXBean mxbean = ManagementFactory.getMemoryMXBean();
-      ObjectName mxname = new ObjectName(ManagementFactory.MEMORY_MXBEAN_NAME);
-      PlatformMBeanIDC mxidc = new PlatformMBeanIDC(server, mxname, mxbean);
-      mbeans.put(mxname.getCanonicalName(), mxidc);
-      
-      // MemoryPoolMXBeans
-      List<MemoryPoolMXBean> mpbeans = ManagementFactory.getMemoryPoolMXBeans();
-      for(MemoryPoolMXBean mbean : mpbeans)
-      {
-         String name = mbean.getName();
-         ObjectName oname = new ObjectName(ManagementFactory.MEMORY_POOL_MXBEAN_DOMAIN_TYPE+name);
-         String cname = oname.getCanonicalName();
-         PlatformMBeanIDC mpidc = new PlatformMBeanIDC(server, oname, mbean);
-         mbeans.put(cname, mpidc);
-      }
-      // OperatingSystemMXBean
-      OperatingSystemMXBean osbean = ManagementFactory.getOperatingSystemMXBean();
-      ObjectName osname = new ObjectName(ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME);
-      PlatformMBeanIDC osidc = new PlatformMBeanIDC(server, osname, osbean);
-      mbeans.put(osname.getCanonicalName(), osidc);
-
-      // RuntimeMXBean
-      RuntimeMXBean rtbean = ManagementFactory.getRuntimeMXBean();
-      ObjectName rtname = new ObjectName(ManagementFactory.RUNTIME_MXBEAN_NAME);
-      PlatformMBeanIDC rtidc = new PlatformMBeanIDC(server, rtname, rtbean);
-      mbeans.put(rtname.getCanonicalName(), rtidc);
-
-      // ThreadMXBean
-      ThreadMXBean tbean = ManagementFactory.getThreadMXBean();
-      ObjectName tname = new ObjectName(ManagementFactory.THREAD_MXBEAN_NAME);
-      PlatformMBeanIDC tidc = new PlatformMBeanIDC(server, tname, tbean);
-      mbeans.put(tname.getCanonicalName(), tidc);
-   }
-   public void stop()
-   {
-      
-   }
-}

Copied: trunk/profileservice/src/main/java/org/jboss/profileservice/management/PlatformMBeanKernelRegistryPlugin.java (from rev 97697, tags/JBoss_6_0_0_M1/profileservice/src/main/org/jboss/profileservice/management/PlatformMBeanKernelRegistryPlugin.java)
===================================================================
--- trunk/profileservice/src/main/java/org/jboss/profileservice/management/PlatformMBeanKernelRegistryPlugin.java	                        (rev 0)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/management/PlatformMBeanKernelRegistryPlugin.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -0,0 +1,182 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.profileservice.management;
+
+import java.lang.management.ClassLoadingMXBean;
+import java.lang.management.CompilationMXBean;
+import java.lang.management.GarbageCollectorMXBean;
+import java.lang.management.ManagementFactory;
+import java.lang.management.MemoryMXBean;
+import java.lang.management.MemoryManagerMXBean;
+import java.lang.management.MemoryPoolMXBean;
+import java.lang.management.OperatingSystemMXBean;
+import java.lang.management.RuntimeMXBean;
+import java.lang.management.ThreadMXBean;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.management.InstanceNotFoundException;
+import javax.management.MBeanServer;
+import javax.management.ObjectInstance;
+import javax.management.ObjectName;
+
+import org.jboss.kernel.spi.registry.KernelRegistryEntry;
+import org.jboss.kernel.spi.registry.KernelRegistryPlugin;
+import org.jboss.system.ServiceController;
+
+/**
+ * A KernelRegistryPlugin that make the j2se platform mbeans visible.
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class PlatformMBeanKernelRegistryPlugin implements KernelRegistryPlugin
+{
+   private Map<String, KernelRegistryEntry> mbeans = new HashMap<String, KernelRegistryEntry>();
+   /** The service controller */
+   private ServiceController serviceController;
+   private MBeanServer mbeanServer;
+   
+   public ServiceController getServiceController()
+   {
+      return serviceController;
+   }
+   public void setServiceController(ServiceController serviceController)
+   {
+      this.serviceController = serviceController;
+   }
+
+   public MBeanServer getMbeanServer()
+   {
+      return mbeanServer;
+   }
+   public void setMbeanServer(MBeanServer mbeanServer)
+   {
+      this.mbeanServer = mbeanServer;
+   }
+
+   public KernelRegistryEntry getEntry(Object name)
+   {
+      String key;
+      ObjectName oname = null;
+      if(name instanceof ObjectName)
+      {
+         oname = ObjectName.class.cast(name);
+         key = oname.getCanonicalName();
+      }
+      else
+         key = name.toString();
+      KernelRegistryEntry entry = mbeans.get(key);
+      // If
+      if(entry == null && oname != null)
+      {
+         System.out.println("Searching for MBean: "+oname);
+         try
+         {
+            ObjectInstance oi = mbeanServer.getObjectInstance(oname);
+            System.out.println("Found "+oname+", "+oi.getClassName());
+         }
+         catch (InstanceNotFoundException e)
+         {
+            e.printStackTrace();
+         }
+      }
+      return entry;
+   }
+
+   public void start()
+      throws Throwable
+   {
+      MBeanServer server = ManagementFactory.getPlatformMBeanServer();
+
+      // ClassLoadingMXBean
+      ClassLoadingMXBean clmbean = ManagementFactory.getClassLoadingMXBean();
+      ObjectName clname = new ObjectName(ManagementFactory.CLASS_LOADING_MXBEAN_NAME);
+      PlatformMBeanIDC clidc = new PlatformMBeanIDC(server, clname, clmbean);
+      mbeans.put(clname.getCanonicalName(), clidc);
+
+      // CompilationMXBean
+      CompilationMXBean cmbean = ManagementFactory.getCompilationMXBean();
+      ObjectName cmname = new ObjectName(ManagementFactory.COMPILATION_MXBEAN_NAME);
+      PlatformMBeanIDC cmidc = new PlatformMBeanIDC(server, cmname, cmbean);
+      mbeans.put(cmname.getCanonicalName(), cmidc);
+
+      // GarbageCollectorMXBeans
+      List<GarbageCollectorMXBean> gcbeans = ManagementFactory.getGarbageCollectorMXBeans();
+      for(GarbageCollectorMXBean mbean : gcbeans)
+      {
+         String name = mbean.getName();
+         ObjectName oname = new ObjectName(ManagementFactory.GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE+name);
+         String cname = oname.getCanonicalName();
+         PlatformMBeanIDC gcidc = new PlatformMBeanIDC(server, oname, mbean);
+         mbeans.put(cname, gcidc);
+      }
+      // getMemoryManagerMXBeans
+      List<MemoryManagerMXBean> mmbeans = ManagementFactory.getMemoryManagerMXBeans();
+      for(MemoryManagerMXBean mbean : mmbeans)
+      {
+         String name = mbean.getName();
+         ObjectName oname = new ObjectName(ManagementFactory.MEMORY_MANAGER_MXBEAN_DOMAIN_TYPE+name);
+         String cname = oname.getCanonicalName();
+         PlatformMBeanIDC mmidc = new PlatformMBeanIDC(server, oname, mbean);
+         mbeans.put(cname, mmidc);
+      }
+      // MemoryMXBean
+      MemoryMXBean mxbean = ManagementFactory.getMemoryMXBean();
+      ObjectName mxname = new ObjectName(ManagementFactory.MEMORY_MXBEAN_NAME);
+      PlatformMBeanIDC mxidc = new PlatformMBeanIDC(server, mxname, mxbean);
+      mbeans.put(mxname.getCanonicalName(), mxidc);
+      
+      // MemoryPoolMXBeans
+      List<MemoryPoolMXBean> mpbeans = ManagementFactory.getMemoryPoolMXBeans();
+      for(MemoryPoolMXBean mbean : mpbeans)
+      {
+         String name = mbean.getName();
+         ObjectName oname = new ObjectName(ManagementFactory.MEMORY_POOL_MXBEAN_DOMAIN_TYPE+name);
+         String cname = oname.getCanonicalName();
+         PlatformMBeanIDC mpidc = new PlatformMBeanIDC(server, oname, mbean);
+         mbeans.put(cname, mpidc);
+      }
+      // OperatingSystemMXBean
+      OperatingSystemMXBean osbean = ManagementFactory.getOperatingSystemMXBean();
+      ObjectName osname = new ObjectName(ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME);
+      PlatformMBeanIDC osidc = new PlatformMBeanIDC(server, osname, osbean);
+      mbeans.put(osname.getCanonicalName(), osidc);
+
+      // RuntimeMXBean
+      RuntimeMXBean rtbean = ManagementFactory.getRuntimeMXBean();
+      ObjectName rtname = new ObjectName(ManagementFactory.RUNTIME_MXBEAN_NAME);
+      PlatformMBeanIDC rtidc = new PlatformMBeanIDC(server, rtname, rtbean);
+      mbeans.put(rtname.getCanonicalName(), rtidc);
+
+      // ThreadMXBean
+      ThreadMXBean tbean = ManagementFactory.getThreadMXBean();
+      ObjectName tname = new ObjectName(ManagementFactory.THREAD_MXBEAN_NAME);
+      PlatformMBeanIDC tidc = new PlatformMBeanIDC(server, tname, tbean);
+      mbeans.put(tname.getCanonicalName(), tidc);
+   }
+   public void stop()
+   {
+      
+   }
+}

Deleted: trunk/profileservice/src/main/java/org/jboss/profileservice/management/ProxyManagedDeploymentFactory.java
===================================================================
--- trunk/profileservice/src/main/java/org/jboss/profileservice/management/ProxyManagedDeploymentFactory.java	2009-12-10 16:45:13 UTC (rev 97698)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/management/ProxyManagedDeploymentFactory.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -1,238 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.profileservice.management;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-import javax.management.AttributeNotFoundException;
-import javax.management.InstanceNotFoundException;
-import javax.management.MBeanException;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-import javax.management.ReflectionException;
-
-import org.jboss.profileservice.spi.ManagedMBeanDeploymentFactory;
-
-/**
- * A ManagedDeploymentFactory that acts as a facade on top of mbean deployments
- * given by an ObjectName pattern.
- *
- * @author Scott.Stark at jboss.org
- * @author Jason T. Greene
- * @version $Revision: 89854 $
- */
-public class ProxyManagedDeploymentFactory implements ManagedMBeanDeploymentFactory
-{
-   /** Name under which the factory will be registered */
-   private String factoryName;
-
-   /** The map of patterns to locate root mbeans that go into the deployment ManagedObject set */
-   private Set<ProxyDeploymentInfo> rootMOPatterns;
-
-   /** The default view to expose fields as */
-   private String defaultViewUse;
-
-   /** The global property to meta-mapper configuration */
-   private Map<String, String> propertyMetaMappings;
-
-   public String getFactoryName()
-   {
-      return factoryName;
-   }
-   public void setFactoryName(String factoryName)
-   {
-      this.factoryName = factoryName;
-   }
-
-   public Set<ProxyDeploymentInfo> getRootMOPatterns()
-   {
-      return rootMOPatterns;
-   }
-   public void setRootMOPatterns(Set<ProxyDeploymentInfo> rootMOPatterns)
-   {
-      this.rootMOPatterns = rootMOPatterns;
-   }
-
-   public String getDefaultViewUse()
-   {
-      return this.defaultViewUse;
-   }
-
-   public void setDefaultViewUse(String defaultViewUse)
-   {
-      this.defaultViewUse = defaultViewUse;
-   }
-
-   public Map<String, String> getPropertyMetaMappings()
-   {
-      return propertyMetaMappings;
-   }
-
-   public void setPropertyMetaMappings(Map<String, String> propertyMappings)
-   {
-      this.propertyMetaMappings = propertyMappings;
-   }
-
-
-
-   public Collection<MBeanDeployment> getDeployments(MBeanServer mbeanServer)
-   {
-      Map<String, MBeanDeployment> tmp = new HashMap<String, MBeanDeployment>();
-      if(this.rootMOPatterns == null)
-         return tmp.values();
-
-      for(ProxyDeploymentInfo info : rootMOPatterns)
-      {
-      Set<ObjectName> names = mbeanServer.queryNames(info.getPattern(), null);
-      if(names != null)
-      {
-         for(ObjectName name : names)
-         {
-            if (hasExcludedNameKey(info, name))
-               continue;
-
-            String dname = info.getNameBuilder().getName(name, mbeanServer);
-            MBeanDeployment deployment = tmp.get(dname);
-            if(deployment == null)
-            {
-               deployment = new MBeanDeployment(dname);
-               tmp.put(dname, deployment);
-            }
-            String compType = info.getCompType();
-            String compSubtype = null;
-
-            if (info.getSubtypeAttribute() != null)
-            {
-               try
-               {
-                  compSubtype = (String) mbeanServer.getAttribute(name, info.getSubtypeAttribute());
-               }
-               catch (Exception e)
-               {
-                  // EAT
-               }
-            }
-
-            if (compSubtype == null)
-               compSubtype = info.getCompSubtype();
-
-
-            MBeanComponent rootComp = new MBeanComponent(name, compType, compSubtype);
-            deployment.addComponent(rootComp);
-            Map<String, String> componentInfo = info.getComponentInfo();
-            if(componentInfo != null)
-            {
-               for(Map.Entry<String, String> comp : componentInfo.entrySet())
-               {
-                  String compPropertyName = comp.getKey();
-                  String compTypeInfo = comp.getValue();
-                  try
-                  {
-                     // Query for the attribute containing names of child components
-                     Object attribute = mbeanServer.getAttribute(name, compPropertyName);
-                     // Type:Subtype is the format
-                     String[] compTypeParts = compTypeInfo.split(":");
-                     processComponents(attribute, compTypeParts[0], compTypeParts[1], deployment);
-                  }
-                  catch(Exception e)
-                  {
-                     // EAT
-                  }
-               }
-            }
-         }
-      }
-      }
-      return tmp.values();
-   }
-
-   private boolean hasExcludedNameKey(ProxyDeploymentInfo info, ObjectName name)
-   {
-      Set<String> excludedKeys = info.getExcludedKeys();
-      for (Object key : name.getKeyPropertyList().keySet())
-      {
-         if (excludedKeys.contains(key))
-            return true;
-      }
-
-      return false;
-   }
-   /**
-    * Generate MBeanComponents for each name given by the attribute value. This
-    * processes the attribute value as an array or collection of strings or
-    * ObjectNames referencing other mbeans that are child type of components.
-    * @param attribute - the value containing the names of child components
-    * @param type - the child component type
-    * @param subtype - the child component subtype
-    * @param deployment - the deployment to add the component to
-    * @throws Exception - thrown on failure to parse a component name
-    */
-   private void processComponents(Object attribute, String type, String subtype, MBeanDeployment deployment)
-      throws Exception
-   {
-      if(attribute instanceof String[])
-      {
-         String[] names = (String[]) attribute;
-         for(String name : names)
-         {
-            ObjectName compName = new ObjectName(name);
-            MBeanComponent comp = new MBeanComponent(compName, type , subtype);
-            deployment.addComponent(comp);
-         }
-      }
-      else if(attribute instanceof ObjectName[])
-      {
-         ObjectName[] names = (ObjectName[]) attribute;
-         for(ObjectName compName : names)
-         {
-            MBeanComponent comp = new MBeanComponent(compName, type , subtype);
-            deployment.addComponent(comp);
-         }
-      }
-      else if(attribute instanceof Collection)
-      {
-         Collection names = (Collection) attribute;
-         for(Object name : names)
-         {
-            MBeanComponent comp = null;
-            ObjectName compName = null;
-            if(name instanceof ObjectName)
-            {
-               compName = (ObjectName) name;
-            }
-            else
-            {
-               compName = new ObjectName(name.toString());
-
-            }
-            comp = new MBeanComponent(compName, type , subtype);
-            deployment.addComponent(comp);
-         }
-      }
-   }
-
-
-}

Copied: trunk/profileservice/src/main/java/org/jboss/profileservice/management/ProxyManagedDeploymentFactory.java (from rev 97697, tags/JBoss_6_0_0_M1/profileservice/src/main/org/jboss/profileservice/management/ProxyManagedDeploymentFactory.java)
===================================================================
--- trunk/profileservice/src/main/java/org/jboss/profileservice/management/ProxyManagedDeploymentFactory.java	                        (rev 0)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/management/ProxyManagedDeploymentFactory.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -0,0 +1,238 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.profileservice.management;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import javax.management.AttributeNotFoundException;
+import javax.management.InstanceNotFoundException;
+import javax.management.MBeanException;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import javax.management.ReflectionException;
+
+import org.jboss.profileservice.spi.ManagedMBeanDeploymentFactory;
+
+/**
+ * A ManagedDeploymentFactory that acts as a facade on top of mbean deployments
+ * given by an ObjectName pattern.
+ *
+ * @author Scott.Stark at jboss.org
+ * @author Jason T. Greene
+ * @version $Revision$
+ */
+public class ProxyManagedDeploymentFactory implements ManagedMBeanDeploymentFactory
+{
+   /** Name under which the factory will be registered */
+   private String factoryName;
+
+   /** The map of patterns to locate root mbeans that go into the deployment ManagedObject set */
+   private Set<ProxyDeploymentInfo> rootMOPatterns;
+
+   /** The default view to expose fields as */
+   private String defaultViewUse;
+
+   /** The global property to meta-mapper configuration */
+   private Map<String, String> propertyMetaMappings;
+
+   public String getFactoryName()
+   {
+      return factoryName;
+   }
+   public void setFactoryName(String factoryName)
+   {
+      this.factoryName = factoryName;
+   }
+
+   public Set<ProxyDeploymentInfo> getRootMOPatterns()
+   {
+      return rootMOPatterns;
+   }
+   public void setRootMOPatterns(Set<ProxyDeploymentInfo> rootMOPatterns)
+   {
+      this.rootMOPatterns = rootMOPatterns;
+   }
+
+   public String getDefaultViewUse()
+   {
+      return this.defaultViewUse;
+   }
+
+   public void setDefaultViewUse(String defaultViewUse)
+   {
+      this.defaultViewUse = defaultViewUse;
+   }
+
+   public Map<String, String> getPropertyMetaMappings()
+   {
+      return propertyMetaMappings;
+   }
+
+   public void setPropertyMetaMappings(Map<String, String> propertyMappings)
+   {
+      this.propertyMetaMappings = propertyMappings;
+   }
+
+
+
+   public Collection<MBeanDeployment> getDeployments(MBeanServer mbeanServer)
+   {
+      Map<String, MBeanDeployment> tmp = new HashMap<String, MBeanDeployment>();
+      if(this.rootMOPatterns == null)
+         return tmp.values();
+
+      for(ProxyDeploymentInfo info : rootMOPatterns)
+      {
+      Set<ObjectName> names = mbeanServer.queryNames(info.getPattern(), null);
+      if(names != null)
+      {
+         for(ObjectName name : names)
+         {
+            if (hasExcludedNameKey(info, name))
+               continue;
+
+            String dname = info.getNameBuilder().getName(name, mbeanServer);
+            MBeanDeployment deployment = tmp.get(dname);
+            if(deployment == null)
+            {
+               deployment = new MBeanDeployment(dname);
+               tmp.put(dname, deployment);
+            }
+            String compType = info.getCompType();
+            String compSubtype = null;
+
+            if (info.getSubtypeAttribute() != null)
+            {
+               try
+               {
+                  compSubtype = (String) mbeanServer.getAttribute(name, info.getSubtypeAttribute());
+               }
+               catch (Exception e)
+               {
+                  // EAT
+               }
+            }
+
+            if (compSubtype == null)
+               compSubtype = info.getCompSubtype();
+
+
+            MBeanComponent rootComp = new MBeanComponent(name, compType, compSubtype);
+            deployment.addComponent(rootComp);
+            Map<String, String> componentInfo = info.getComponentInfo();
+            if(componentInfo != null)
+            {
+               for(Map.Entry<String, String> comp : componentInfo.entrySet())
+               {
+                  String compPropertyName = comp.getKey();
+                  String compTypeInfo = comp.getValue();
+                  try
+                  {
+                     // Query for the attribute containing names of child components
+                     Object attribute = mbeanServer.getAttribute(name, compPropertyName);
+                     // Type:Subtype is the format
+                     String[] compTypeParts = compTypeInfo.split(":");
+                     processComponents(attribute, compTypeParts[0], compTypeParts[1], deployment);
+                  }
+                  catch(Exception e)
+                  {
+                     // EAT
+                  }
+               }
+            }
+         }
+      }
+      }
+      return tmp.values();
+   }
+
+   private boolean hasExcludedNameKey(ProxyDeploymentInfo info, ObjectName name)
+   {
+      Set<String> excludedKeys = info.getExcludedKeys();
+      for (Object key : name.getKeyPropertyList().keySet())
+      {
+         if (excludedKeys.contains(key))
+            return true;
+      }
+
+      return false;
+   }
+   /**
+    * Generate MBeanComponents for each name given by the attribute value. This
+    * processes the attribute value as an array or collection of strings or
+    * ObjectNames referencing other mbeans that are child type of components.
+    * @param attribute - the value containing the names of child components
+    * @param type - the child component type
+    * @param subtype - the child component subtype
+    * @param deployment - the deployment to add the component to
+    * @throws Exception - thrown on failure to parse a component name
+    */
+   private void processComponents(Object attribute, String type, String subtype, MBeanDeployment deployment)
+      throws Exception
+   {
+      if(attribute instanceof String[])
+      {
+         String[] names = (String[]) attribute;
+         for(String name : names)
+         {
+            ObjectName compName = new ObjectName(name);
+            MBeanComponent comp = new MBeanComponent(compName, type , subtype);
+            deployment.addComponent(comp);
+         }
+      }
+      else if(attribute instanceof ObjectName[])
+      {
+         ObjectName[] names = (ObjectName[]) attribute;
+         for(ObjectName compName : names)
+         {
+            MBeanComponent comp = new MBeanComponent(compName, type , subtype);
+            deployment.addComponent(comp);
+         }
+      }
+      else if(attribute instanceof Collection)
+      {
+         Collection names = (Collection) attribute;
+         for(Object name : names)
+         {
+            MBeanComponent comp = null;
+            ObjectName compName = null;
+            if(name instanceof ObjectName)
+            {
+               compName = (ObjectName) name;
+            }
+            else
+            {
+               compName = new ObjectName(name.toString());
+
+            }
+            comp = new MBeanComponent(compName, type , subtype);
+            deployment.addComponent(comp);
+         }
+      }
+   }
+
+
+}

Copied: trunk/profileservice/src/main/java/org/jboss/profileservice/management/client (from rev 97697, tags/JBoss_6_0_0_M1/profileservice/src/main/org/jboss/profileservice/management/client)

Deleted: trunk/profileservice/src/main/java/org/jboss/profileservice/management/client/ManagedComponentDelegate.java
===================================================================
--- tags/JBoss_6_0_0_M1/profileservice/src/main/org/jboss/profileservice/management/client/ManagedComponentDelegate.java	2009-12-10 15:49:13 UTC (rev 97697)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/management/client/ManagedComponentDelegate.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -1,144 +0,0 @@
-/*
- * 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.management.client;
-
-import java.lang.annotation.Annotation;
-import java.util.Map;
-import java.util.Set;
-
-import org.jboss.deployers.spi.management.DelegatingComponentDispatcher;
-import org.jboss.managed.api.ComponentType;
-import org.jboss.managed.api.ManagedCommon;
-import org.jboss.managed.api.ManagedDeployment;
-import org.jboss.managed.api.ManagedOperation;
-import org.jboss.managed.api.ManagedProperty;
-import org.jboss.managed.api.MutableManagedComponent;
-import org.jboss.managed.api.RunState;
-
-/**
- * A ManagedComponent used to proxy and dispatch the RunState on request.
- * 
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public class ManagedComponentDelegate implements MutableManagedComponent
-{
-
-   /** The serialVersionUID */
-   private static final long serialVersionUID = 1L;   
-   private Object componentName;
-   private MutableManagedComponent delegate;
-   private DelegatingComponentDispatcher dispatcher;
-   
-   public ManagedComponentDelegate(Object componentName, MutableManagedComponent delegate, DelegatingComponentDispatcher dispatcher)
-   {
-      this.componentName = componentName;
-      this.delegate = delegate;
-      this.dispatcher = dispatcher;
-   }
-   
-   public Map<String, Annotation> getAnnotations()
-   {
-      return delegate.getAnnotations();
-   }
-
-   public ManagedDeployment getDeployment()
-   {
-      return delegate.getDeployment();
-   }
-
-   public RunState getRunState()
-   {
-      return dispatcher.updateRunState(componentName);
-   }
-
-   public void setRunState(RunState runState)
-   {
-      delegate.setRunState(runState);
-   }
-   
-   public ComponentType getType()
-   {
-      return delegate.getType();
-   }
-
-   public boolean update()
-   {
-      return delegate.update();
-   }
-
-   public String getAttachmentName()
-   {
-      return delegate.getAttachmentName();
-   }
-
-   public Object getComponentName()
-   {
-      return delegate.getComponentName();
-   }
-
-   public String getName()
-   {
-      return delegate.getName();
-   }
-
-   public String getNameType()
-   {
-      return delegate.getNameType();
-   }
-
-   public Set<ManagedOperation> getOperations()
-   {
-      return delegate.getOperations();
-   }
-
-   public void setOperations(Set<ManagedOperation> operations)
-   {
-      delegate.setOperations(operations);
-   }
-   
-   public ManagedCommon getParent()
-   {
-      return delegate.getParent();
-   }
-   
-   public ManagedProperty getProperty(String name)
-   {
-      return delegate.getProperty(name);
-   }
-   
-   public Map<String, ManagedProperty> getProperties()
-   {
-      return delegate.getProperties();
-   }
-
-   public void setProperties(Map<String, ManagedProperty> properties)
-   {
-      delegate.setProperties(properties);
-   }
-
-   public Set<String> getPropertyNames()
-   {
-      return delegate.getPropertyNames();
-   }
-
-}

Copied: trunk/profileservice/src/main/java/org/jboss/profileservice/management/client/ManagedComponentDelegate.java (from rev 97697, tags/JBoss_6_0_0_M1/profileservice/src/main/org/jboss/profileservice/management/client/ManagedComponentDelegate.java)
===================================================================
--- trunk/profileservice/src/main/java/org/jboss/profileservice/management/client/ManagedComponentDelegate.java	                        (rev 0)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/management/client/ManagedComponentDelegate.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -0,0 +1,144 @@
+/*
+ * 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.management.client;
+
+import java.lang.annotation.Annotation;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.deployers.spi.management.DelegatingComponentDispatcher;
+import org.jboss.managed.api.ComponentType;
+import org.jboss.managed.api.ManagedCommon;
+import org.jboss.managed.api.ManagedDeployment;
+import org.jboss.managed.api.ManagedOperation;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.managed.api.MutableManagedComponent;
+import org.jboss.managed.api.RunState;
+
+/**
+ * A ManagedComponent used to proxy and dispatch the RunState on request.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class ManagedComponentDelegate implements MutableManagedComponent
+{
+
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 1L;   
+   private Object componentName;
+   private MutableManagedComponent delegate;
+   private DelegatingComponentDispatcher dispatcher;
+   
+   public ManagedComponentDelegate(Object componentName, MutableManagedComponent delegate, DelegatingComponentDispatcher dispatcher)
+   {
+      this.componentName = componentName;
+      this.delegate = delegate;
+      this.dispatcher = dispatcher;
+   }
+   
+   public Map<String, Annotation> getAnnotations()
+   {
+      return delegate.getAnnotations();
+   }
+
+   public ManagedDeployment getDeployment()
+   {
+      return delegate.getDeployment();
+   }
+
+   public RunState getRunState()
+   {
+      return dispatcher.updateRunState(componentName);
+   }
+
+   public void setRunState(RunState runState)
+   {
+      delegate.setRunState(runState);
+   }
+   
+   public ComponentType getType()
+   {
+      return delegate.getType();
+   }
+
+   public boolean update()
+   {
+      return delegate.update();
+   }
+
+   public String getAttachmentName()
+   {
+      return delegate.getAttachmentName();
+   }
+
+   public Object getComponentName()
+   {
+      return delegate.getComponentName();
+   }
+
+   public String getName()
+   {
+      return delegate.getName();
+   }
+
+   public String getNameType()
+   {
+      return delegate.getNameType();
+   }
+
+   public Set<ManagedOperation> getOperations()
+   {
+      return delegate.getOperations();
+   }
+
+   public void setOperations(Set<ManagedOperation> operations)
+   {
+      delegate.setOperations(operations);
+   }
+   
+   public ManagedCommon getParent()
+   {
+      return delegate.getParent();
+   }
+   
+   public ManagedProperty getProperty(String name)
+   {
+      return delegate.getProperty(name);
+   }
+   
+   public Map<String, ManagedProperty> getProperties()
+   {
+      return delegate.getProperties();
+   }
+
+   public void setProperties(Map<String, ManagedProperty> properties)
+   {
+      delegate.setProperties(properties);
+   }
+
+   public Set<String> getPropertyNames()
+   {
+      return delegate.getPropertyNames();
+   }
+
+}

Deleted: trunk/profileservice/src/main/java/org/jboss/profileservice/management/client/ManagedOperationDelegate.java
===================================================================
--- tags/JBoss_6_0_0_M1/profileservice/src/main/org/jboss/profileservice/management/client/ManagedOperationDelegate.java	2009-12-10 15:49:13 UTC (rev 97697)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/management/client/ManagedOperationDelegate.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -1,110 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.profileservice.management.client;
-
-import org.jboss.deployers.spi.management.DelegatingComponentDispatcher;
-import org.jboss.managed.api.ManagedOperation;
-import org.jboss.managed.api.ManagedParameter;
-import org.jboss.metatype.api.types.MetaType;
-import org.jboss.metatype.api.values.MetaValue;
-
-/**
- * <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public class ManagedOperationDelegate
-   implements ManagedOperation
-{
-   /** The serialVersionUID */
-   private static final long serialVersionUID = 2031110731596810579L;
-   private long opID;
-   private Object componentName;
-   private ManagedOperation delegate;
-   private DelegatingComponentDispatcher dispatcherProxy;
-
-   public ManagedOperationDelegate(long opID, ManagedOperation delegate, Object componentName,
-         DelegatingComponentDispatcher dispatcherProxy)
-   {
-      if (delegate == null)
-         throw new IllegalArgumentException("Null delegate.");
-      this.opID = opID;
-      this.delegate = delegate;
-      this.componentName = componentName;
-      this.dispatcherProxy = dispatcherProxy;
-   }
-
-   public long getOpID()
-   {
-      return opID;
-   }
-
-   public MetaValue invoke(MetaValue... metaValues)
-   {
-      return dispatcherProxy.invoke(opID, componentName, delegate.getName(), metaValues);
-   }
-
-   public String getDescription()
-   {
-      return delegate.getDescription();
-   }
-
-   public String getName()
-   {
-      return delegate.getName();
-   }
-
-   public Impact getImpact()
-   {
-      return delegate.getImpact();
-   }
-
-   public MetaType getReturnType()
-   {
-      return delegate.getReturnType();
-   }
-
-   public ManagedParameter[] getParameters()
-   {
-      return delegate.getParameters();
-   }
-   
-   public String[] getReflectionSignature()
-   {
-      return delegate.getReflectionSignature();
-   }
-
-   public <T> T getTransientAttachment(Class<T> expectedType)
-   {
-      return delegate.getTransientAttachment(expectedType);
-   }
-
-   public Object getTransientAttachment(String name)
-   {
-      return delegate.getTransientAttachment(name);
-   }
-
-   public void setTransientAttachment(String name, Object attachment)
-   {
-      delegate.setTransientAttachment(name, attachment);
-   }
-}

Copied: trunk/profileservice/src/main/java/org/jboss/profileservice/management/client/ManagedOperationDelegate.java (from rev 97697, tags/JBoss_6_0_0_M1/profileservice/src/main/org/jboss/profileservice/management/client/ManagedOperationDelegate.java)
===================================================================
--- trunk/profileservice/src/main/java/org/jboss/profileservice/management/client/ManagedOperationDelegate.java	                        (rev 0)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/management/client/ManagedOperationDelegate.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -0,0 +1,110 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.profileservice.management.client;
+
+import org.jboss.deployers.spi.management.DelegatingComponentDispatcher;
+import org.jboss.managed.api.ManagedOperation;
+import org.jboss.managed.api.ManagedParameter;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.values.MetaValue;
+
+/**
+ * <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class ManagedOperationDelegate
+   implements ManagedOperation
+{
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 2031110731596810579L;
+   private long opID;
+   private Object componentName;
+   private ManagedOperation delegate;
+   private DelegatingComponentDispatcher dispatcherProxy;
+
+   public ManagedOperationDelegate(long opID, ManagedOperation delegate, Object componentName,
+         DelegatingComponentDispatcher dispatcherProxy)
+   {
+      if (delegate == null)
+         throw new IllegalArgumentException("Null delegate.");
+      this.opID = opID;
+      this.delegate = delegate;
+      this.componentName = componentName;
+      this.dispatcherProxy = dispatcherProxy;
+   }
+
+   public long getOpID()
+   {
+      return opID;
+   }
+
+   public MetaValue invoke(MetaValue... metaValues)
+   {
+      return dispatcherProxy.invoke(opID, componentName, delegate.getName(), metaValues);
+   }
+
+   public String getDescription()
+   {
+      return delegate.getDescription();
+   }
+
+   public String getName()
+   {
+      return delegate.getName();
+   }
+
+   public Impact getImpact()
+   {
+      return delegate.getImpact();
+   }
+
+   public MetaType getReturnType()
+   {
+      return delegate.getReturnType();
+   }
+
+   public ManagedParameter[] getParameters()
+   {
+      return delegate.getParameters();
+   }
+   
+   public String[] getReflectionSignature()
+   {
+      return delegate.getReflectionSignature();
+   }
+
+   public <T> T getTransientAttachment(Class<T> expectedType)
+   {
+      return delegate.getTransientAttachment(expectedType);
+   }
+
+   public Object getTransientAttachment(String name)
+   {
+      return delegate.getTransientAttachment(name);
+   }
+
+   public void setTransientAttachment(String name, Object attachment)
+   {
+      delegate.setTransientAttachment(name, attachment);
+   }
+}

Deleted: trunk/profileservice/src/main/java/org/jboss/profileservice/management/client/ManagedPropertyDelegate.java
===================================================================
--- tags/JBoss_6_0_0_M1/profileservice/src/main/org/jboss/profileservice/management/client/ManagedPropertyDelegate.java	2009-12-10 15:49:13 UTC (rev 97697)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/management/client/ManagedPropertyDelegate.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -1,229 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.profileservice.management.client;
-
-import java.io.Serializable;
-import java.lang.annotation.Annotation;
-import java.util.Collection;
-import java.util.Map;
-import java.util.Set;
-
-import org.jboss.deployers.spi.management.DelegatingComponentDispatcher;
-import org.jboss.managed.api.Fields;
-import org.jboss.managed.api.ManagedObject;
-import org.jboss.managed.api.ManagedProperty;
-import org.jboss.managed.api.annotation.ActivationPolicy;
-import org.jboss.managed.api.annotation.ViewUse;
-import org.jboss.metatype.api.types.MetaType;
-import org.jboss.metatype.api.values.MetaValue;
-
-/**
- * A ManagedProperty delegate used as the target of the ManagedProperty
- * proxies used for runtime managed objects statistics.
- * 
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public class ManagedPropertyDelegate implements ManagedProperty
-{
-   private final static long serialVersionUID = 1;
-   private long propID;
-   private Object componentName;
-   private ManagedProperty delegate;
-   private DelegatingComponentDispatcher dispatcher;
-   
-   public ManagedPropertyDelegate(long propID, ManagedProperty delegate,
-         Object componentName, DelegatingComponentDispatcher dispatcher)
-   {
-      super();
-      this.propID = propID;
-      this.delegate = delegate;
-      this.dispatcher = dispatcher;
-      this.componentName = componentName;
-   }
-
-   public String checkValidValue(MetaValue value)
-   {
-      return delegate.checkValidValue(value);
-   }
-
-   public ManagedProperty copy()
-   {
-      return delegate.copy();
-   }
-
-   public Map<String, Annotation> getAnnotations()
-   {
-      return delegate.getAnnotations();
-   }
-
-   public String getDescription()
-   {
-      return delegate.getDescription();
-   }
-
-   public <T> T getField(String fieldName, Class<T> expected)
-   {
-      return delegate.getField(fieldName, expected);
-   }
-
-   public Fields getFields()
-   {
-      return delegate.getFields();
-   }
-
-   public Set<MetaValue> getLegalValues()
-   {
-      return delegate.getLegalValues();
-   }
-
-   public MetaValue getDefaultValue()
-   {
-      return delegate.getDefaultValue();
-   }
-
-   public ManagedObject getManagedObject()
-   {
-      return delegate.getManagedObject();
-   }
-
-   public String getMappedName()
-   {
-      return delegate.getMappedName();
-   }
-
-   public Comparable<? extends MetaValue> getMaximumValue()
-   {
-      return delegate.getMaximumValue();
-   }
-
-   public MetaType getMetaType()
-   {
-      return delegate.getMetaType();
-   }
-
-   public Comparable<? extends MetaValue> getMinimumValue()
-   {
-      return delegate.getMinimumValue();
-   }
-
-   public String getName()
-   {
-      return delegate.getName();
-   }
-
-   public ManagedObject getTargetManagedObject()
-   {
-      return delegate.getTargetManagedObject();
-   }
-
-   public <T> T getTransientAttachment(Class<T> expectedType)
-   {
-      return delegate.getTransientAttachment(expectedType);
-   }
-
-   public Object getTransientAttachment(String name)
-   {
-      return delegate.getTransientAttachment(name);
-   }
-
-   public MetaValue getValue()
-   {
-      return dispatcher.get(propID, componentName, getMappedName());
-   }
-
-   public Collection<String> getAdminViewUses()
-   {
-      return delegate.getAdminViewUses();
-   }
-
-   public boolean hasAnnotation(String key)
-   {
-      return delegate.hasAnnotation(key);
-   }
-
-   public boolean hasViewUse(ViewUse use)
-   {
-      return delegate.hasViewUse(use);
-   }
-
-   public ActivationPolicy getActivationPolicy()
-   {
-      return delegate.getActivationPolicy();
-   }
-
-   public void setModified(boolean flag)
-   {
-      delegate.setModified(flag);
-   }
-
-   public boolean isMandatory()
-   {
-      return delegate.isMandatory();
-   }
-
-   public boolean isReadOnly()
-   {
-      return delegate.isReadOnly();
-   }
-
-   public boolean isModified()
-   {
-      return delegate.isModified();
-   }
-
-   public boolean isRemoved()
-   {
-      return delegate.isRemoved();
-   }
-
-   public void setField(String fieldName, Serializable value)
-   {
-      delegate.setField(fieldName, value);
-   }
-
-   public void setManagedObject(ManagedObject managedObject)
-   {
-      delegate.setManagedObject(managedObject);
-   }
-
-   public void setRemoved(boolean flag)
-   {
-      delegate.setRemoved(flag);
-   }
-
-   public void setTargetManagedObject(ManagedObject target)
-   {
-      delegate.setTargetManagedObject(target);
-   }
-
-   public void setTransientAttachment(String name, Object attachment)
-   {
-      delegate.setTransientAttachment(name, attachment);
-   }
-
-   public void setValue(MetaValue value)
-   {
-      delegate.setValue(value);
-   }
-   
-}

Copied: trunk/profileservice/src/main/java/org/jboss/profileservice/management/client/ManagedPropertyDelegate.java (from rev 97697, tags/JBoss_6_0_0_M1/profileservice/src/main/org/jboss/profileservice/management/client/ManagedPropertyDelegate.java)
===================================================================
--- trunk/profileservice/src/main/java/org/jboss/profileservice/management/client/ManagedPropertyDelegate.java	                        (rev 0)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/management/client/ManagedPropertyDelegate.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -0,0 +1,229 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.profileservice.management.client;
+
+import java.io.Serializable;
+import java.lang.annotation.Annotation;
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.deployers.spi.management.DelegatingComponentDispatcher;
+import org.jboss.managed.api.Fields;
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.managed.api.annotation.ActivationPolicy;
+import org.jboss.managed.api.annotation.ViewUse;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.values.MetaValue;
+
+/**
+ * A ManagedProperty delegate used as the target of the ManagedProperty
+ * proxies used for runtime managed objects statistics.
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class ManagedPropertyDelegate implements ManagedProperty
+{
+   private final static long serialVersionUID = 1;
+   private long propID;
+   private Object componentName;
+   private ManagedProperty delegate;
+   private DelegatingComponentDispatcher dispatcher;
+   
+   public ManagedPropertyDelegate(long propID, ManagedProperty delegate,
+         Object componentName, DelegatingComponentDispatcher dispatcher)
+   {
+      super();
+      this.propID = propID;
+      this.delegate = delegate;
+      this.dispatcher = dispatcher;
+      this.componentName = componentName;
+   }
+
+   public String checkValidValue(MetaValue value)
+   {
+      return delegate.checkValidValue(value);
+   }
+
+   public ManagedProperty copy()
+   {
+      return delegate.copy();
+   }
+
+   public Map<String, Annotation> getAnnotations()
+   {
+      return delegate.getAnnotations();
+   }
+
+   public String getDescription()
+   {
+      return delegate.getDescription();
+   }
+
+   public <T> T getField(String fieldName, Class<T> expected)
+   {
+      return delegate.getField(fieldName, expected);
+   }
+
+   public Fields getFields()
+   {
+      return delegate.getFields();
+   }
+
+   public Set<MetaValue> getLegalValues()
+   {
+      return delegate.getLegalValues();
+   }
+
+   public MetaValue getDefaultValue()
+   {
+      return delegate.getDefaultValue();
+   }
+
+   public ManagedObject getManagedObject()
+   {
+      return delegate.getManagedObject();
+   }
+
+   public String getMappedName()
+   {
+      return delegate.getMappedName();
+   }
+
+   public Comparable<? extends MetaValue> getMaximumValue()
+   {
+      return delegate.getMaximumValue();
+   }
+
+   public MetaType getMetaType()
+   {
+      return delegate.getMetaType();
+   }
+
+   public Comparable<? extends MetaValue> getMinimumValue()
+   {
+      return delegate.getMinimumValue();
+   }
+
+   public String getName()
+   {
+      return delegate.getName();
+   }
+
+   public ManagedObject getTargetManagedObject()
+   {
+      return delegate.getTargetManagedObject();
+   }
+
+   public <T> T getTransientAttachment(Class<T> expectedType)
+   {
+      return delegate.getTransientAttachment(expectedType);
+   }
+
+   public Object getTransientAttachment(String name)
+   {
+      return delegate.getTransientAttachment(name);
+   }
+
+   public MetaValue getValue()
+   {
+      return dispatcher.get(propID, componentName, getMappedName());
+   }
+
+   public Collection<String> getAdminViewUses()
+   {
+      return delegate.getAdminViewUses();
+   }
+
+   public boolean hasAnnotation(String key)
+   {
+      return delegate.hasAnnotation(key);
+   }
+
+   public boolean hasViewUse(ViewUse use)
+   {
+      return delegate.hasViewUse(use);
+   }
+
+   public ActivationPolicy getActivationPolicy()
+   {
+      return delegate.getActivationPolicy();
+   }
+
+   public void setModified(boolean flag)
+   {
+      delegate.setModified(flag);
+   }
+
+   public boolean isMandatory()
+   {
+      return delegate.isMandatory();
+   }
+
+   public boolean isReadOnly()
+   {
+      return delegate.isReadOnly();
+   }
+
+   public boolean isModified()
+   {
+      return delegate.isModified();
+   }
+
+   public boolean isRemoved()
+   {
+      return delegate.isRemoved();
+   }
+
+   public void setField(String fieldName, Serializable value)
+   {
+      delegate.setField(fieldName, value);
+   }
+
+   public void setManagedObject(ManagedObject managedObject)
+   {
+      delegate.setManagedObject(managedObject);
+   }
+
+   public void setRemoved(boolean flag)
+   {
+      delegate.setRemoved(flag);
+   }
+
+   public void setTargetManagedObject(ManagedObject target)
+   {
+      delegate.setTargetManagedObject(target);
+   }
+
+   public void setTransientAttachment(String name, Object attachment)
+   {
+      delegate.setTransientAttachment(name, attachment);
+   }
+
+   public void setValue(MetaValue value)
+   {
+      delegate.setValue(value);
+   }
+   
+}

Deleted: trunk/profileservice/src/main/java/org/jboss/profileservice/management/client/package.html
===================================================================
--- tags/JBoss_6_0_0_M1/profileservice/src/main/org/jboss/profileservice/management/client/package.html	2009-12-10 15:49:13 UTC (rev 97697)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/management/client/package.html	2009-12-10 17:35:48 UTC (rev 97699)
@@ -1,54 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
-  <head>
-    <!-- $Id: package.html 71554 2008-04-01 13:25:40Z adrian at jboss.org $ -->
-    <!--
-/*
- * 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.
- */
-    -->
-  </head>
-
-  <body bgcolor="white">
-    <h1>Profile Service Client Classes</h1>
-<p>This package contains the classes associated with the profile service
-implementation that need to be in client classpaths.
-</p>
-
-    <h2>Package Specification</h2>
-    <ul>
-      <li><a href="javascript: alert('not available')">Not Available</a>
-    </ul>
-      
-    <h2>Related Documentation</h2>
-    <ul>
-      <li><a href="javascript: alert('not available')">Not Available</a>
-    </ul>
-
-    <h2>Package Status</h2>
-    <ul>
-      <li><font color="green"><b>STABLE</b></font>
-    </ul>
-
-    <!-- Put @see and @since tags down here. -->
-
-  </body>
-</html>

Copied: trunk/profileservice/src/main/java/org/jboss/profileservice/management/client/package.html (from rev 97697, tags/JBoss_6_0_0_M1/profileservice/src/main/org/jboss/profileservice/management/client/package.html)
===================================================================
--- trunk/profileservice/src/main/java/org/jboss/profileservice/management/client/package.html	                        (rev 0)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/management/client/package.html	2009-12-10 17:35:48 UTC (rev 97699)
@@ -0,0 +1,54 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+  <head>
+    <!-- $Id: package.html 71554 2008-04-01 13:25:40Z adrian at jboss.org $ -->
+    <!--
+/*
+ * 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.
+ */
+    -->
+  </head>
+
+  <body bgcolor="white">
+    <h1>Profile Service Client Classes</h1>
+<p>This package contains the classes associated with the profile service
+implementation that need to be in client classpaths.
+</p>
+
+    <h2>Package Specification</h2>
+    <ul>
+      <li><a href="javascript: alert('not available')">Not Available</a>
+    </ul>
+      
+    <h2>Related Documentation</h2>
+    <ul>
+      <li><a href="javascript: alert('not available')">Not Available</a>
+    </ul>
+
+    <h2>Package Status</h2>
+    <ul>
+      <li><font color="green"><b>STABLE</b></font>
+    </ul>
+
+    <!-- Put @see and @since tags down here. -->
+
+  </body>
+</html>

Copied: trunk/profileservice/src/main/java/org/jboss/profileservice/management/client/upload (from rev 97697, tags/JBoss_6_0_0_M1/profileservice/src/main/org/jboss/profileservice/management/client/upload)

Deleted: trunk/profileservice/src/main/java/org/jboss/profileservice/management/client/upload/DeploymentProgressImpl.java
===================================================================
--- tags/JBoss_6_0_0_M1/profileservice/src/main/org/jboss/profileservice/management/client/upload/DeploymentProgressImpl.java	2009-12-10 15:49:13 UTC (rev 97697)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/management/client/upload/DeploymentProgressImpl.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -1,434 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.profileservice.management.client.upload;
-
-import java.io.Serializable;
-import java.util.List;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-import org.jboss.deployers.spi.management.deploy.DeploymentID;
-import org.jboss.deployers.spi.management.deploy.DeploymentProgress;
-import org.jboss.deployers.spi.management.deploy.DeploymentStatus;
-import org.jboss.deployers.spi.management.deploy.DeploymentTarget;
-import org.jboss.deployers.spi.management.deploy.ProgressEvent;
-import org.jboss.deployers.spi.management.deploy.ProgressListener;
-import org.jboss.deployers.spi.management.deploy.DeploymentStatus.CommandType;
-import org.jboss.deployers.spi.management.deploy.DeploymentStatus.StateType;
-
-/**
- * The deployment progress.
- * 
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public class DeploymentProgressImpl implements DeploymentProgress, Serializable
-{
-   private static final long serialVersionUID = 1;
-
-   /** The client side listeners */
-   private transient CopyOnWriteArrayList<ProgressListener> listeners = new CopyOnWriteArrayList<ProgressListener>();
-   private transient DeploymentStatus currentStatus;
-   private transient boolean isCancelled;
-   /** The targets to distribute to */
-   private List<DeploymentTarget> targets;
-   /** The deployment being distributed */
-   private DeploymentID deployment;
-   private CommandType command;
-
-   public DeploymentProgressImpl(List<DeploymentTarget> targets, DeploymentID deployment, CommandType command)
-   {
-      this.targets = targets;
-      this.deployment = deployment;
-      this.command = command;
-   }
-
-   public synchronized void addProgressListener(ProgressListener listener)
-   {
-      if(listeners == null)
-         listeners = new CopyOnWriteArrayList<ProgressListener>();
-      listeners.add(listener);
-   }
-   public void removeProgressListener(ProgressListener listener)
-   {
-      listeners.remove(listener);
-   }
-
-   /**
-    * Begins the deployment command process
-    */
-   public void run()
-   {
-      switch(command)
-      {
-         case DISTRIBUTE:
-            distribute();
-            break;
-         case PREPARE:
-            prepare();
-            break;
-         case START:
-            start();
-            break;
-         case STOP:
-            stop();
-            break;
-         case REMOVE:
-            remove();
-            break;
-         case REDEPLOY:
-            redeploy();
-            break;
-         default:
-            throw new IllegalStateException(command+" is not currently handled");
-      }
-   }
-
-   public void cancel()
-   {
-      isCancelled = true;
-   }
-
-   public DeploymentStatus getDeploymentStatus()
-   {
-      return currentStatus;
-   }
-
-   public DeploymentID getDeploymentID()
-   {
-      return deployment;
-   }
-
-   public List<DeploymentTarget> getDeploymentTargets()
-   {
-      return targets;
-   }
-
-   /**
-    * 
-    * @param event
-    */
-   protected void notify(ProgressEvent event)
-   {
-      if(listeners == null)
-         return;
-
-      for(ProgressListener listener : listeners)
-      {
-         try
-         {
-            listener.progressEvent(event);
-         }
-         catch(Throwable ignore)
-         {
-         }
-      }
-   }
-
-   protected void distribute()
-   {
-      SerializableDeploymentStatus status = new SerializableDeploymentStatus(command, StateType.DEPLOYING);
-      status.setMessage("Running distribute to: "+targets);
-      status.setRunning(true);
-      currentStatus = status;
-      ProgressEvent event =  new ProgressEvent(deployment, currentStatus);
-      notify(event);
-      for(DeploymentTarget target : targets)
-      {
-         if(isCancelled)
-         {
-            status = new SerializableDeploymentStatus(command, StateType.CANCELLED);
-            status.setMessage("Distribute has been cancelled");
-            currentStatus = status;
-            event =  new ProgressEvent(deployment, currentStatus);
-            notify(event);
-            break;
-         }
-
-         try
-         {
-            // TODO, percent complete info in upload and overall distribute
-            status = new SerializableDeploymentStatus(command, StateType.UPLOADING);
-            status.setTarget(target);
-            status.setRunning(true);
-            status.setMessage("Begining distribute to target: "+target);
-            currentStatus = status;
-            event =  new ProgressEvent(deployment, currentStatus);
-            notify(event);
-
-            // TODO, cancellation of in progress distribution
-            target.distribute(deployment);
-            status = new SerializableDeploymentStatus(command, StateType.DEPLOYING);
-            status.setTarget(target);
-            status.setMessage("Completed distribute to target: "+target);
-            currentStatus = status;
-            event =  new ProgressEvent(deployment, currentStatus);
-            notify(event);
-         }
-         catch(Exception e)
-         {
-            status = new SerializableDeploymentStatus(command, StateType.FAILED);
-            status.setTarget(target);
-            status.setFailure(e);
-            status.setFailed(true);
-            currentStatus = status;
-            ProgressEvent error = new ProgressEvent(deployment, currentStatus);
-            notify(error);
-            break;
-         }
-      }
-
-      if(currentStatus.isFailed() == false)
-      {
-         status = new SerializableDeploymentStatus(command, StateType.COMPLETED);
-         status.setMessage("Completed distribute to all targets");
-         status.setCompleted(true);
-         currentStatus = status;
-         event =  new ProgressEvent(deployment, currentStatus);
-         notify(event);         
-      }
-   }
-
-   protected void start()
-   {
-      SerializableDeploymentStatus status = new SerializableDeploymentStatus(command, StateType.RUNNING);
-      status.setMessage("Running start to: "+targets);
-      status.setRunning(true);
-      currentStatus = status;
-      ProgressEvent event =  new ProgressEvent(deployment, currentStatus);
-      notify(event);
-      for(DeploymentTarget target : targets)
-      {
-         if(isCancelled)
-         {
-            status = new SerializableDeploymentStatus(command, StateType.CANCELLED);
-            status.setMessage("Start has been cancelled");
-            currentStatus = status;
-            event =  new ProgressEvent(deployment, currentStatus);
-            notify(event);
-            break;
-         }
-
-         try
-         {
-            target.start(deployment);
-            status = new SerializableDeploymentStatus(command, StateType.COMPLETED);
-            status.setTarget(target);
-            status.setMessage("Completed start for target: "+target);
-            status.setCompleted(true);
-            currentStatus = status;
-            event =  new ProgressEvent(deployment, currentStatus);
-            notify(event);
-         }
-         catch(Exception e)
-         {
-            status = new SerializableDeploymentStatus(command, StateType.FAILED);
-            status.setTarget(target);
-            status.setFailure(e);
-            status.setFailed(true);
-            currentStatus = status;
-            ProgressEvent error = new ProgressEvent(deployment, currentStatus);
-            notify(error);
-            break;
-         }
-      }
-   }
-
-   protected void stop()
-   {
-      SerializableDeploymentStatus status = new SerializableDeploymentStatus(command, StateType.RUNNING);
-      status.setMessage("Running stop to: "+targets);
-      status.setRunning(true);
-      currentStatus = status;
-      ProgressEvent event =  new ProgressEvent(deployment, currentStatus);
-      notify(event);
-      for(DeploymentTarget target : targets)
-      {
-         if(isCancelled)
-         {
-            status = new SerializableDeploymentStatus(command, StateType.CANCELLED);
-            status.setMessage("Stop has been cancelled");
-            currentStatus = status;
-            event =  new ProgressEvent(deployment, currentStatus);
-            notify(event);
-            break;
-         }
-
-         try
-         {
-            target.stop(deployment);
-            status = new SerializableDeploymentStatus(command, StateType.COMPLETED);
-            status.setTarget(target);
-            status.setMessage("Completed stop for target: "+target);
-            status.setCompleted(true);
-            currentStatus = status;
-            event =  new ProgressEvent(deployment, currentStatus);
-            notify(event);
-         }
-         catch(Exception e)
-         {
-            status = new SerializableDeploymentStatus(command, StateType.FAILED);
-            status.setTarget(target);
-            status.setFailure(e);
-            status.setFailed(true);
-            currentStatus = status;
-            ProgressEvent error = new ProgressEvent(deployment, currentStatus);
-            notify(error);
-            break;
-         }
-      }
-   }
-
-   protected void remove()
-   {
-      SerializableDeploymentStatus status = new SerializableDeploymentStatus(command, StateType.RUNNING);
-      status.setMessage("Running undeploy to: "+targets);
-      status.setRunning(true);
-      currentStatus = status;
-      ProgressEvent event =  new ProgressEvent(deployment, currentStatus);
-      notify(event);
-      for(DeploymentTarget target : targets)
-      {
-         if(isCancelled)
-         {
-            status = new SerializableDeploymentStatus(command, StateType.CANCELLED);
-            status.setMessage("Undeploy has been cancelled");
-            currentStatus = status;
-            event =  new ProgressEvent(deployment, currentStatus);
-            notify(event);
-            break;
-         }
-
-         try
-         {
-            target.remove(deployment);
-            status = new SerializableDeploymentStatus(command, StateType.COMPLETED);
-            status.setTarget(target);
-            status.setMessage("Completed undeploy for target: "+target);
-            status.setCompleted(true);
-            currentStatus = status;
-            event =  new ProgressEvent(deployment, currentStatus);
-            notify(event);
-         }
-         catch(Exception e)
-         {
-            status = new SerializableDeploymentStatus(command, StateType.FAILED);
-            status.setTarget(target);
-            status.setFailure(e);
-            status.setFailed(true);
-            currentStatus = status;
-            ProgressEvent error = new ProgressEvent(deployment, currentStatus);
-            notify(error);
-            break;
-         }
-      }
-   }
-   
-   protected void redeploy()
-   {
-      SerializableDeploymentStatus status = new SerializableDeploymentStatus(command, StateType.RUNNING);
-      status.setMessage("Running redeploy to: "+targets);
-      status.setRunning(true);
-      currentStatus = status;
-      ProgressEvent event =  new ProgressEvent(deployment, currentStatus);
-      notify(event);
-      for(DeploymentTarget target : targets)
-      {
-         if(isCancelled)
-         {
-            status = new SerializableDeploymentStatus(command, StateType.CANCELLED);
-            status.setMessage("Redeploy has been cancelled");
-            currentStatus = status;
-            event =  new ProgressEvent(deployment, currentStatus);
-            notify(event);
-            break;
-         }
-
-         try
-         {
-            target.redeploy(deployment);
-            status = new SerializableDeploymentStatus(command, StateType.COMPLETED);
-            status.setTarget(target);
-            status.setMessage("Completed redeploy for target: "+target);
-            status.setCompleted(true);
-            currentStatus = status;
-            event =  new ProgressEvent(deployment, currentStatus);
-            notify(event);
-         }
-         catch(Exception e)
-         {
-            status = new SerializableDeploymentStatus(command, StateType.FAILED);
-            status.setTarget(target);
-            status.setFailure(e);
-            status.setFailed(true);
-            currentStatus = status;
-            ProgressEvent error = new ProgressEvent(deployment, currentStatus);
-            notify(error);
-            break;
-         }
-      }
-   }
-   
-   protected void prepare()
-   {
-      SerializableDeploymentStatus status = new SerializableDeploymentStatus(command, StateType.RUNNING);
-      status.setMessage("Running prepare to: "+targets);
-      status.setRunning(true);
-      currentStatus = status;
-      ProgressEvent event =  new ProgressEvent(deployment, currentStatus);
-      notify(event);
-      for(DeploymentTarget target : targets)
-      {
-         if(isCancelled)
-         {
-            status = new SerializableDeploymentStatus(command, StateType.CANCELLED);
-            status.setMessage("Prepare has been cancelled");
-            currentStatus = status;
-            event =  new ProgressEvent(deployment, currentStatus);
-            notify(event);
-            break;
-         }
-
-         try
-         {
-            target.prepare(deployment);
-            status = new SerializableDeploymentStatus(command, StateType.COMPLETED);
-            status.setTarget(target);
-            status.setMessage("Completed prepare for target: "+target);
-            status.setCompleted(true);
-            currentStatus = status;
-            event =  new ProgressEvent(deployment, currentStatus);
-            notify(event);
-         }
-         catch(Exception e)
-         {
-            status = new SerializableDeploymentStatus(command, StateType.FAILED);
-            status.setTarget(target);
-            status.setFailure(e);
-            status.setFailed(true);
-            currentStatus = status;
-            ProgressEvent error = new ProgressEvent(deployment, currentStatus);
-            notify(error);
-            break;
-         }
-      }
-   }
-}

Copied: trunk/profileservice/src/main/java/org/jboss/profileservice/management/client/upload/DeploymentProgressImpl.java (from rev 97697, tags/JBoss_6_0_0_M1/profileservice/src/main/org/jboss/profileservice/management/client/upload/DeploymentProgressImpl.java)
===================================================================
--- trunk/profileservice/src/main/java/org/jboss/profileservice/management/client/upload/DeploymentProgressImpl.java	                        (rev 0)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/management/client/upload/DeploymentProgressImpl.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -0,0 +1,434 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.profileservice.management.client.upload;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import org.jboss.deployers.spi.management.deploy.DeploymentID;
+import org.jboss.deployers.spi.management.deploy.DeploymentProgress;
+import org.jboss.deployers.spi.management.deploy.DeploymentStatus;
+import org.jboss.deployers.spi.management.deploy.DeploymentTarget;
+import org.jboss.deployers.spi.management.deploy.ProgressEvent;
+import org.jboss.deployers.spi.management.deploy.ProgressListener;
+import org.jboss.deployers.spi.management.deploy.DeploymentStatus.CommandType;
+import org.jboss.deployers.spi.management.deploy.DeploymentStatus.StateType;
+
+/**
+ * The deployment progress.
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class DeploymentProgressImpl implements DeploymentProgress, Serializable
+{
+   private static final long serialVersionUID = 1;
+
+   /** The client side listeners */
+   private transient CopyOnWriteArrayList<ProgressListener> listeners = new CopyOnWriteArrayList<ProgressListener>();
+   private transient DeploymentStatus currentStatus;
+   private transient boolean isCancelled;
+   /** The targets to distribute to */
+   private List<DeploymentTarget> targets;
+   /** The deployment being distributed */
+   private DeploymentID deployment;
+   private CommandType command;
+
+   public DeploymentProgressImpl(List<DeploymentTarget> targets, DeploymentID deployment, CommandType command)
+   {
+      this.targets = targets;
+      this.deployment = deployment;
+      this.command = command;
+   }
+
+   public synchronized void addProgressListener(ProgressListener listener)
+   {
+      if(listeners == null)
+         listeners = new CopyOnWriteArrayList<ProgressListener>();
+      listeners.add(listener);
+   }
+   public void removeProgressListener(ProgressListener listener)
+   {
+      listeners.remove(listener);
+   }
+
+   /**
+    * Begins the deployment command process
+    */
+   public void run()
+   {
+      switch(command)
+      {
+         case DISTRIBUTE:
+            distribute();
+            break;
+         case PREPARE:
+            prepare();
+            break;
+         case START:
+            start();
+            break;
+         case STOP:
+            stop();
+            break;
+         case REMOVE:
+            remove();
+            break;
+         case REDEPLOY:
+            redeploy();
+            break;
+         default:
+            throw new IllegalStateException(command+" is not currently handled");
+      }
+   }
+
+   public void cancel()
+   {
+      isCancelled = true;
+   }
+
+   public DeploymentStatus getDeploymentStatus()
+   {
+      return currentStatus;
+   }
+
+   public DeploymentID getDeploymentID()
+   {
+      return deployment;
+   }
+
+   public List<DeploymentTarget> getDeploymentTargets()
+   {
+      return targets;
+   }
+
+   /**
+    * 
+    * @param event
+    */
+   protected void notify(ProgressEvent event)
+   {
+      if(listeners == null)
+         return;
+
+      for(ProgressListener listener : listeners)
+      {
+         try
+         {
+            listener.progressEvent(event);
+         }
+         catch(Throwable ignore)
+         {
+         }
+      }
+   }
+
+   protected void distribute()
+   {
+      SerializableDeploymentStatus status = new SerializableDeploymentStatus(command, StateType.DEPLOYING);
+      status.setMessage("Running distribute to: "+targets);
+      status.setRunning(true);
+      currentStatus = status;
+      ProgressEvent event =  new ProgressEvent(deployment, currentStatus);
+      notify(event);
+      for(DeploymentTarget target : targets)
+      {
+         if(isCancelled)
+         {
+            status = new SerializableDeploymentStatus(command, StateType.CANCELLED);
+            status.setMessage("Distribute has been cancelled");
+            currentStatus = status;
+            event =  new ProgressEvent(deployment, currentStatus);
+            notify(event);
+            break;
+         }
+
+         try
+         {
+            // TODO, percent complete info in upload and overall distribute
+            status = new SerializableDeploymentStatus(command, StateType.UPLOADING);
+            status.setTarget(target);
+            status.setRunning(true);
+            status.setMessage("Begining distribute to target: "+target);
+            currentStatus = status;
+            event =  new ProgressEvent(deployment, currentStatus);
+            notify(event);
+
+            // TODO, cancellation of in progress distribution
+            target.distribute(deployment);
+            status = new SerializableDeploymentStatus(command, StateType.DEPLOYING);
+            status.setTarget(target);
+            status.setMessage("Completed distribute to target: "+target);
+            currentStatus = status;
+            event =  new ProgressEvent(deployment, currentStatus);
+            notify(event);
+         }
+         catch(Exception e)
+         {
+            status = new SerializableDeploymentStatus(command, StateType.FAILED);
+            status.setTarget(target);
+            status.setFailure(e);
+            status.setFailed(true);
+            currentStatus = status;
+            ProgressEvent error = new ProgressEvent(deployment, currentStatus);
+            notify(error);
+            break;
+         }
+      }
+
+      if(currentStatus.isFailed() == false)
+      {
+         status = new SerializableDeploymentStatus(command, StateType.COMPLETED);
+         status.setMessage("Completed distribute to all targets");
+         status.setCompleted(true);
+         currentStatus = status;
+         event =  new ProgressEvent(deployment, currentStatus);
+         notify(event);         
+      }
+   }
+
+   protected void start()
+   {
+      SerializableDeploymentStatus status = new SerializableDeploymentStatus(command, StateType.RUNNING);
+      status.setMessage("Running start to: "+targets);
+      status.setRunning(true);
+      currentStatus = status;
+      ProgressEvent event =  new ProgressEvent(deployment, currentStatus);
+      notify(event);
+      for(DeploymentTarget target : targets)
+      {
+         if(isCancelled)
+         {
+            status = new SerializableDeploymentStatus(command, StateType.CANCELLED);
+            status.setMessage("Start has been cancelled");
+            currentStatus = status;
+            event =  new ProgressEvent(deployment, currentStatus);
+            notify(event);
+            break;
+         }
+
+         try
+         {
+            target.start(deployment);
+            status = new SerializableDeploymentStatus(command, StateType.COMPLETED);
+            status.setTarget(target);
+            status.setMessage("Completed start for target: "+target);
+            status.setCompleted(true);
+            currentStatus = status;
+            event =  new ProgressEvent(deployment, currentStatus);
+            notify(event);
+         }
+         catch(Exception e)
+         {
+            status = new SerializableDeploymentStatus(command, StateType.FAILED);
+            status.setTarget(target);
+            status.setFailure(e);
+            status.setFailed(true);
+            currentStatus = status;
+            ProgressEvent error = new ProgressEvent(deployment, currentStatus);
+            notify(error);
+            break;
+         }
+      }
+   }
+
+   protected void stop()
+   {
+      SerializableDeploymentStatus status = new SerializableDeploymentStatus(command, StateType.RUNNING);
+      status.setMessage("Running stop to: "+targets);
+      status.setRunning(true);
+      currentStatus = status;
+      ProgressEvent event =  new ProgressEvent(deployment, currentStatus);
+      notify(event);
+      for(DeploymentTarget target : targets)
+      {
+         if(isCancelled)
+         {
+            status = new SerializableDeploymentStatus(command, StateType.CANCELLED);
+            status.setMessage("Stop has been cancelled");
+            currentStatus = status;
+            event =  new ProgressEvent(deployment, currentStatus);
+            notify(event);
+            break;
+         }
+
+         try
+         {
+            target.stop(deployment);
+            status = new SerializableDeploymentStatus(command, StateType.COMPLETED);
+            status.setTarget(target);
+            status.setMessage("Completed stop for target: "+target);
+            status.setCompleted(true);
+            currentStatus = status;
+            event =  new ProgressEvent(deployment, currentStatus);
+            notify(event);
+         }
+         catch(Exception e)
+         {
+            status = new SerializableDeploymentStatus(command, StateType.FAILED);
+            status.setTarget(target);
+            status.setFailure(e);
+            status.setFailed(true);
+            currentStatus = status;
+            ProgressEvent error = new ProgressEvent(deployment, currentStatus);
+            notify(error);
+            break;
+         }
+      }
+   }
+
+   protected void remove()
+   {
+      SerializableDeploymentStatus status = new SerializableDeploymentStatus(command, StateType.RUNNING);
+      status.setMessage("Running undeploy to: "+targets);
+      status.setRunning(true);
+      currentStatus = status;
+      ProgressEvent event =  new ProgressEvent(deployment, currentStatus);
+      notify(event);
+      for(DeploymentTarget target : targets)
+      {
+         if(isCancelled)
+         {
+            status = new SerializableDeploymentStatus(command, StateType.CANCELLED);
+            status.setMessage("Undeploy has been cancelled");
+            currentStatus = status;
+            event =  new ProgressEvent(deployment, currentStatus);
+            notify(event);
+            break;
+         }
+
+         try
+         {
+            target.remove(deployment);
+            status = new SerializableDeploymentStatus(command, StateType.COMPLETED);
+            status.setTarget(target);
+            status.setMessage("Completed undeploy for target: "+target);
+            status.setCompleted(true);
+            currentStatus = status;
+            event =  new ProgressEvent(deployment, currentStatus);
+            notify(event);
+         }
+         catch(Exception e)
+         {
+            status = new SerializableDeploymentStatus(command, StateType.FAILED);
+            status.setTarget(target);
+            status.setFailure(e);
+            status.setFailed(true);
+            currentStatus = status;
+            ProgressEvent error = new ProgressEvent(deployment, currentStatus);
+            notify(error);
+            break;
+         }
+      }
+   }
+   
+   protected void redeploy()
+   {
+      SerializableDeploymentStatus status = new SerializableDeploymentStatus(command, StateType.RUNNING);
+      status.setMessage("Running redeploy to: "+targets);
+      status.setRunning(true);
+      currentStatus = status;
+      ProgressEvent event =  new ProgressEvent(deployment, currentStatus);
+      notify(event);
+      for(DeploymentTarget target : targets)
+      {
+         if(isCancelled)
+         {
+            status = new SerializableDeploymentStatus(command, StateType.CANCELLED);
+            status.setMessage("Redeploy has been cancelled");
+            currentStatus = status;
+            event =  new ProgressEvent(deployment, currentStatus);
+            notify(event);
+            break;
+         }
+
+         try
+         {
+            target.redeploy(deployment);
+            status = new SerializableDeploymentStatus(command, StateType.COMPLETED);
+            status.setTarget(target);
+            status.setMessage("Completed redeploy for target: "+target);
+            status.setCompleted(true);
+            currentStatus = status;
+            event =  new ProgressEvent(deployment, currentStatus);
+            notify(event);
+         }
+         catch(Exception e)
+         {
+            status = new SerializableDeploymentStatus(command, StateType.FAILED);
+            status.setTarget(target);
+            status.setFailure(e);
+            status.setFailed(true);
+            currentStatus = status;
+            ProgressEvent error = new ProgressEvent(deployment, currentStatus);
+            notify(error);
+            break;
+         }
+      }
+   }
+   
+   protected void prepare()
+   {
+      SerializableDeploymentStatus status = new SerializableDeploymentStatus(command, StateType.RUNNING);
+      status.setMessage("Running prepare to: "+targets);
+      status.setRunning(true);
+      currentStatus = status;
+      ProgressEvent event =  new ProgressEvent(deployment, currentStatus);
+      notify(event);
+      for(DeploymentTarget target : targets)
+      {
+         if(isCancelled)
+         {
+            status = new SerializableDeploymentStatus(command, StateType.CANCELLED);
+            status.setMessage("Prepare has been cancelled");
+            currentStatus = status;
+            event =  new ProgressEvent(deployment, currentStatus);
+            notify(event);
+            break;
+         }
+
+         try
+         {
+            target.prepare(deployment);
+            status = new SerializableDeploymentStatus(command, StateType.COMPLETED);
+            status.setTarget(target);
+            status.setMessage("Completed prepare for target: "+target);
+            status.setCompleted(true);
+            currentStatus = status;
+            event =  new ProgressEvent(deployment, currentStatus);
+            notify(event);
+         }
+         catch(Exception e)
+         {
+            status = new SerializableDeploymentStatus(command, StateType.FAILED);
+            status.setTarget(target);
+            status.setFailure(e);
+            status.setFailed(true);
+            currentStatus = status;
+            ProgressEvent error = new ProgressEvent(deployment, currentStatus);
+            notify(error);
+            break;
+         }
+      }
+   }
+}

Deleted: trunk/profileservice/src/main/java/org/jboss/profileservice/management/client/upload/SerializableDeploymentID.java
===================================================================
--- tags/JBoss_6_0_0_M1/profileservice/src/main/org/jboss/profileservice/management/client/upload/SerializableDeploymentID.java	2009-12-10 15:49:13 UTC (rev 97697)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/management/client/upload/SerializableDeploymentID.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -1,192 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.profileservice.management.client.upload;
-
-import java.io.InputStream;
-import java.io.Serializable;
-import java.net.URL;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.jboss.deployers.spi.management.deploy.DeploymentID;
-import org.jboss.profileservice.spi.DeploymentOption;
-import org.jboss.profileservice.spi.ProfileKey;
-
-/**
- * A serializable DeploymentID implementation.
- * 
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public class SerializableDeploymentID implements DeploymentID, Serializable
-{
-   private static final long serialVersionUID = 1;
-
-   /** An InputStream to use to copy the contents */
-   private transient InputStream contentIS;
-   private Set<DeploymentOption> options;
-   private String[] deploymentNames;
-   private String[] repositoryNames;
-   private ProfileKey profileKey;
-   private String description;
-   private URL contentURL;
-   private boolean copyContent;
-
-   public SerializableDeploymentID(DeploymentID deployment)
-   {
-      this(deployment.getNames(), deployment.getProfile(), deployment.getDescription(), deployment.getDeploymentOptions());         
-   }
-   
-   public SerializableDeploymentID(String name, ProfileKey profileKey, String description)
-   {
-      this(new String[]{name}, profileKey, description);
-   }
-   
-   public SerializableDeploymentID(String[] names, ProfileKey profileKey, String description)
-   {
-      this(names, profileKey, description, new DeploymentOption[0]);
-   }
-   
-   public SerializableDeploymentID(String[] names, ProfileKey profileKey, String description, DeploymentOption... options)
-   {
-      this.deploymentNames = names;
-      this.profileKey = profileKey;
-      this.description = description;
-      this.copyContent = true; // by default we copy content
-      this.options = new HashSet<DeploymentOption>();
-      if(options != null && options.length > 0)
-      {
-         for(DeploymentOption option : options)
-            addDeploymentOption(option);
-      }  
-   }
-
-   public String[] getNames()
-   {
-      return deploymentNames;
-   }
-
-   public String[] getRepositoryNames()
-   {
-      if(repositoryNames == null)
-         repositoryNames = deploymentNames;
-      return repositoryNames;
-   }
-   public void setRepositoryNames(String[] names)
-   {
-      this.repositoryNames = names;
-   }
-
-   /**
-    * The target profile for the deployment.
-    * For further use.
-    */
-   public ProfileKey getProfile()
-   {
-      return this.profileKey;
-   }
-   
-   public String getDescription()
-   {
-      return description;
-   }
-
-   public URL getContentURL()
-   {
-      return contentURL;
-   }
-   public void setContentURL(URL contentURL)
-   {
-      this.contentURL = contentURL;
-   }
-
-   public boolean isCopyContent()
-   {
-      return copyContent;
-   }
-   public void setCopyContent(boolean copyContent)
-   {
-      this.copyContent = copyContent;
-   }
-
-   /**
-    * An optional deployment archive content stream for the top-level
-    * deployment.
-    * 
-    * @return the archive input stream if it exists
-    */
-   public InputStream getContentIS()
-   {
-      return contentIS;
-   }
-   /**
-    * 
-    * @param contentIS
-    */
-   public void setContentIS(InputStream contentIS)
-   {
-      this.contentIS = contentIS;
-   }
-
-   public void addDeploymentOption(DeploymentOption option)
-   {
-      if(option == null)
-         throw new IllegalArgumentException("null option");
-      this.options.add(option);
-   }
-
-   public DeploymentOption[] getDeploymentOptions()
-   {
-      return this.options.toArray(new DeploymentOption[this.options.size()]);
-   }
-
-   public boolean hasDeploymentOption(DeploymentOption option)
-   {
-      if(option == null)
-         throw new IllegalArgumentException("null option");
-      return this.options.contains(option);
-   }
-
-   public boolean removeDeploymentOption(DeploymentOption option)
-   {
-      return this.options.remove(option);
-   }
-   
-   public String toString()
-   {
-      StringBuffer buffer = new StringBuffer();
-      buffer.append("names=").append(Arrays.toString(getNames()));
-      // Only add the repositoryNames if it differs from deploymentNames
-      if(getRepositoryNames() != getNames())
-         buffer.append(", repositoryNames=").append(Arrays.toString(getRepositoryNames()));
-      // Only log copyContent when the contentURL is set
-      if(getContentURL() != null)
-         buffer.append(", copyContent=").append(copyContent);
-      if(description != null)
-         buffer.append(", description=").append(description);
-      if(options != null && options.isEmpty() == false)
-         buffer.append(", options=").append(options);
-      return buffer.toString();
-   }
-
-}

Copied: trunk/profileservice/src/main/java/org/jboss/profileservice/management/client/upload/SerializableDeploymentID.java (from rev 97697, tags/JBoss_6_0_0_M1/profileservice/src/main/org/jboss/profileservice/management/client/upload/SerializableDeploymentID.java)
===================================================================
--- trunk/profileservice/src/main/java/org/jboss/profileservice/management/client/upload/SerializableDeploymentID.java	                        (rev 0)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/management/client/upload/SerializableDeploymentID.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -0,0 +1,192 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.profileservice.management.client.upload;
+
+import java.io.InputStream;
+import java.io.Serializable;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jboss.deployers.spi.management.deploy.DeploymentID;
+import org.jboss.profileservice.spi.DeploymentOption;
+import org.jboss.profileservice.spi.ProfileKey;
+
+/**
+ * A serializable DeploymentID implementation.
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class SerializableDeploymentID implements DeploymentID, Serializable
+{
+   private static final long serialVersionUID = 1;
+
+   /** An InputStream to use to copy the contents */
+   private transient InputStream contentIS;
+   private Set<DeploymentOption> options;
+   private String[] deploymentNames;
+   private String[] repositoryNames;
+   private ProfileKey profileKey;
+   private String description;
+   private URL contentURL;
+   private boolean copyContent;
+
+   public SerializableDeploymentID(DeploymentID deployment)
+   {
+      this(deployment.getNames(), deployment.getProfile(), deployment.getDescription(), deployment.getDeploymentOptions());         
+   }
+   
+   public SerializableDeploymentID(String name, ProfileKey profileKey, String description)
+   {
+      this(new String[]{name}, profileKey, description);
+   }
+   
+   public SerializableDeploymentID(String[] names, ProfileKey profileKey, String description)
+   {
+      this(names, profileKey, description, new DeploymentOption[0]);
+   }
+   
+   public SerializableDeploymentID(String[] names, ProfileKey profileKey, String description, DeploymentOption... options)
+   {
+      this.deploymentNames = names;
+      this.profileKey = profileKey;
+      this.description = description;
+      this.copyContent = true; // by default we copy content
+      this.options = new HashSet<DeploymentOption>();
+      if(options != null && options.length > 0)
+      {
+         for(DeploymentOption option : options)
+            addDeploymentOption(option);
+      }  
+   }
+
+   public String[] getNames()
+   {
+      return deploymentNames;
+   }
+
+   public String[] getRepositoryNames()
+   {
+      if(repositoryNames == null)
+         repositoryNames = deploymentNames;
+      return repositoryNames;
+   }
+   public void setRepositoryNames(String[] names)
+   {
+      this.repositoryNames = names;
+   }
+
+   /**
+    * The target profile for the deployment.
+    * For further use.
+    */
+   public ProfileKey getProfile()
+   {
+      return this.profileKey;
+   }
+   
+   public String getDescription()
+   {
+      return description;
+   }
+
+   public URL getContentURL()
+   {
+      return contentURL;
+   }
+   public void setContentURL(URL contentURL)
+   {
+      this.contentURL = contentURL;
+   }
+
+   public boolean isCopyContent()
+   {
+      return copyContent;
+   }
+   public void setCopyContent(boolean copyContent)
+   {
+      this.copyContent = copyContent;
+   }
+
+   /**
+    * An optional deployment archive content stream for the top-level
+    * deployment.
+    * 
+    * @return the archive input stream if it exists
+    */
+   public InputStream getContentIS()
+   {
+      return contentIS;
+   }
+   /**
+    * 
+    * @param contentIS
+    */
+   public void setContentIS(InputStream contentIS)
+   {
+      this.contentIS = contentIS;
+   }
+
+   public void addDeploymentOption(DeploymentOption option)
+   {
+      if(option == null)
+         throw new IllegalArgumentException("null option");
+      this.options.add(option);
+   }
+
+   public DeploymentOption[] getDeploymentOptions()
+   {
+      return this.options.toArray(new DeploymentOption[this.options.size()]);
+   }
+
+   public boolean hasDeploymentOption(DeploymentOption option)
+   {
+      if(option == null)
+         throw new IllegalArgumentException("null option");
+      return this.options.contains(option);
+   }
+
+   public boolean removeDeploymentOption(DeploymentOption option)
+   {
+      return this.options.remove(option);
+   }
+   
+   public String toString()
+   {
+      StringBuffer buffer = new StringBuffer();
+      buffer.append("names=").append(Arrays.toString(getNames()));
+      // Only add the repositoryNames if it differs from deploymentNames
+      if(getRepositoryNames() != getNames())
+         buffer.append(", repositoryNames=").append(Arrays.toString(getRepositoryNames()));
+      // Only log copyContent when the contentURL is set
+      if(getContentURL() != null)
+         buffer.append(", copyContent=").append(copyContent);
+      if(description != null)
+         buffer.append(", description=").append(description);
+      if(options != null && options.isEmpty() == false)
+         buffer.append(", options=").append(options);
+      return buffer.toString();
+   }
+
+}

Deleted: trunk/profileservice/src/main/java/org/jboss/profileservice/management/client/upload/SerializableDeploymentStatus.java
===================================================================
--- tags/JBoss_6_0_0_M1/profileservice/src/main/org/jboss/profileservice/management/client/upload/SerializableDeploymentStatus.java	2009-12-10 15:49:13 UTC (rev 97697)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/management/client/upload/SerializableDeploymentStatus.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -1,153 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.profileservice.management.client.upload;
-
-import java.io.PrintWriter;
-import java.io.Serializable;
-import java.io.StringWriter;
-
-import org.jboss.deployers.spi.management.deploy.DeploymentStatus;
-import org.jboss.deployers.spi.management.deploy.DeploymentTarget;
-
-/**
- * Simple javabean impl of DeploymentStatus
- * 
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public class SerializableDeploymentStatus implements DeploymentStatus,
-      Serializable
-{
-   private static final long serialVersionUID = 1;
-
-   private CommandType command;
-   private Exception failure;
-   private String message;
-   private StateType state;
-   private DeploymentTarget target;
-   private boolean isCompleted;
-   private boolean isFailed;
-   private boolean isRunning;
-
-   public SerializableDeploymentStatus(CommandType command, StateType state)
-   {
-      this.command = command;
-      this.state = state;
-   }
-
-   public CommandType getCommand()
-   {
-      return command;
-   }
-   public void setCommand(CommandType command)
-   {
-      this.command = command;
-   }
-   
-   public DeploymentTarget getTarget()
-   {
-      return target;
-   }
-   public void setTarget(DeploymentTarget target)
-   {
-      this.target = target;
-   }
-
-   public Exception getFailure()
-   {
-      return failure;
-   }
-   public void setFailure(Exception failure)
-   {
-      this.failure = failure;
-   }
-   public String getMessage()
-   {
-      return message;
-   }
-   public void setMessage(String message)
-   {
-      this.message = message;
-   }
-   public StateType getState()
-   {
-      return state;
-   }
-   public void setState(StateType state)
-   {
-      this.state = state;
-   }
-   public boolean isCompleted()
-   {
-      return isCompleted;
-   }
-   public void setCompleted(boolean isCompleted)
-   {
-      this.isCompleted = isCompleted;
-   }
-   public boolean isFailed()
-   {
-      return isFailed;
-   }
-   public void setFailed(boolean isFailed)
-   {
-      this.isFailed = isFailed;
-   }
-   public boolean isRunning()
-   {
-      return isRunning;
-   }
-   public void setRunning(boolean isRunning)
-   {
-      this.isRunning = isRunning;
-   }
-
-   @Override
-   public String toString()
-   {
-      StringBuffer tmp = new StringBuffer("DeploymentStatus(");
-      tmp.append("command=");
-      tmp.append(command);
-      tmp.append(",state=");
-      tmp.append(state);
-      tmp.append(",message=");
-      tmp.append(message);
-      tmp.append(",isCompleted=");
-      tmp.append(isCompleted);
-      tmp.append(",isRunning=");
-      tmp.append(isRunning);
-      tmp.append(",isFailed=");
-      tmp.append(isFailed);
-
-      if(failure != null)
-      {
-         StringWriter sw = new StringWriter();
-         PrintWriter pw = new PrintWriter(sw);
-         failure.printStackTrace(pw);
-         tmp.append(",failure:\n");
-         tmp.append(sw.toString());
-      }
-      tmp.append(")");
-      return tmp.toString();
-   }
-
-}

Copied: trunk/profileservice/src/main/java/org/jboss/profileservice/management/client/upload/SerializableDeploymentStatus.java (from rev 97697, tags/JBoss_6_0_0_M1/profileservice/src/main/org/jboss/profileservice/management/client/upload/SerializableDeploymentStatus.java)
===================================================================
--- trunk/profileservice/src/main/java/org/jboss/profileservice/management/client/upload/SerializableDeploymentStatus.java	                        (rev 0)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/management/client/upload/SerializableDeploymentStatus.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -0,0 +1,153 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.profileservice.management.client.upload;
+
+import java.io.PrintWriter;
+import java.io.Serializable;
+import java.io.StringWriter;
+
+import org.jboss.deployers.spi.management.deploy.DeploymentStatus;
+import org.jboss.deployers.spi.management.deploy.DeploymentTarget;
+
+/**
+ * Simple javabean impl of DeploymentStatus
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class SerializableDeploymentStatus implements DeploymentStatus,
+      Serializable
+{
+   private static final long serialVersionUID = 1;
+
+   private CommandType command;
+   private Exception failure;
+   private String message;
+   private StateType state;
+   private DeploymentTarget target;
+   private boolean isCompleted;
+   private boolean isFailed;
+   private boolean isRunning;
+
+   public SerializableDeploymentStatus(CommandType command, StateType state)
+   {
+      this.command = command;
+      this.state = state;
+   }
+
+   public CommandType getCommand()
+   {
+      return command;
+   }
+   public void setCommand(CommandType command)
+   {
+      this.command = command;
+   }
+   
+   public DeploymentTarget getTarget()
+   {
+      return target;
+   }
+   public void setTarget(DeploymentTarget target)
+   {
+      this.target = target;
+   }
+
+   public Exception getFailure()
+   {
+      return failure;
+   }
+   public void setFailure(Exception failure)
+   {
+      this.failure = failure;
+   }
+   public String getMessage()
+   {
+      return message;
+   }
+   public void setMessage(String message)
+   {
+      this.message = message;
+   }
+   public StateType getState()
+   {
+      return state;
+   }
+   public void setState(StateType state)
+   {
+      this.state = state;
+   }
+   public boolean isCompleted()
+   {
+      return isCompleted;
+   }
+   public void setCompleted(boolean isCompleted)
+   {
+      this.isCompleted = isCompleted;
+   }
+   public boolean isFailed()
+   {
+      return isFailed;
+   }
+   public void setFailed(boolean isFailed)
+   {
+      this.isFailed = isFailed;
+   }
+   public boolean isRunning()
+   {
+      return isRunning;
+   }
+   public void setRunning(boolean isRunning)
+   {
+      this.isRunning = isRunning;
+   }
+
+   @Override
+   public String toString()
+   {
+      StringBuffer tmp = new StringBuffer("DeploymentStatus(");
+      tmp.append("command=");
+      tmp.append(command);
+      tmp.append(",state=");
+      tmp.append(state);
+      tmp.append(",message=");
+      tmp.append(message);
+      tmp.append(",isCompleted=");
+      tmp.append(isCompleted);
+      tmp.append(",isRunning=");
+      tmp.append(isRunning);
+      tmp.append(",isFailed=");
+      tmp.append(isFailed);
+
+      if(failure != null)
+      {
+         StringWriter sw = new StringWriter();
+         PrintWriter pw = new PrintWriter(sw);
+         failure.printStackTrace(pw);
+         tmp.append(",failure:\n");
+         tmp.append(sw.toString());
+      }
+      tmp.append(")");
+      return tmp.toString();
+   }
+
+}

Deleted: trunk/profileservice/src/main/java/org/jboss/profileservice/management/client/upload/StreamingDeploymentTarget.java
===================================================================
--- tags/JBoss_6_0_0_M1/profileservice/src/main/org/jboss/profileservice/management/client/upload/StreamingDeploymentTarget.java	2009-12-10 15:49:13 UTC (rev 97697)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/management/client/upload/StreamingDeploymentTarget.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -1,315 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.profileservice.management.client.upload;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Serializable;
-import java.net.URL;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.jboss.aop.joinpoint.InvocationResponse;
-import org.jboss.deployers.spi.management.deploy.DeploymentID;
-import org.jboss.deployers.spi.management.deploy.DeploymentTarget;
-import org.jboss.logging.Logger;
-import org.jboss.remoting.Client;
-import org.jboss.remoting.InvokerLocator;
-
-/**
- * An implementation of DeploymentTarget that uses remoting for streaming
- * content in distribute, and basic rpc for the other methods.
- * 
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public class StreamingDeploymentTarget
-   implements DeploymentTarget, Serializable
-{
-   private static final long serialVersionUID = 1;
-   private static final Logger log = Logger.getLogger(StreamingDeploymentTarget.class);
-
-   /** The deployment target locator */
-   private InvokerLocator locator;
-   private String name;
-   private String subsystem;
-
-   /**
-    * Create a target given a remoting locator 
-    * @param locator -
-    * @param name - 
-    * @param subsystem - 
-    */
-   public StreamingDeploymentTarget(InvokerLocator locator, String name, String subsystem)
-   {
-      log.debug("new StreamingTarget: " + locator);
-      this.name = name;
-      this.subsystem = subsystem;
-      this.locator = locator;
-   }
-   
-   public String getDescription()
-   {
-      return name + "(" + locator + ")";
-   }
-
-   public String getName()
-   {
-      return name;
-   }
-
-   public InvokerLocator getInvokerLocator()
-   {
-      return locator;
-   }
-
-   /**
-    * Distribute a deployment to the profile targets.
-    *
-    * @param deployment - the encapsulation of the deployment to distribute
-    * @throws Exception for any error
-    */
-   public void distribute(DeploymentID deployment) throws Exception
-   {
-      Client client = getClient();
-      try
-      {
-         log.debug("Begin distribute: " + deployment);
-         String[] rnames;
-         if (deployment.isCopyContent())
-         {
-            URL contentURL = deployment.getContentURL();
-            SerializableDeploymentID sdtID = new SerializableDeploymentID(deployment);
-            InputStream contentIS = contentURL.openStream();
-            sdtID.setContentIS(contentIS);
-            String repositoryName = transferDeployment(client, sdtID);
-            rnames = new String[]{repositoryName};
-         }
-         else
-         {
-            rnames = (String[])invoke(client, "distribute", createArgs(deployment));
-         }
-         // Update the repository names on the deployment
-         deployment.setRepositoryNames(rnames);
-         log.debug("End distribute, repositoryNames: "+ Arrays.asList(rnames));
-      }
-      finally
-      {
-         client.disconnect();
-      }
-   }
-
-   public String[] getRepositoryNames(DeploymentID dtID) throws Exception
-   {
-      Client client = getClient();
-      try
-      {
-         log.debug("Begin getRepositoryNames: " + Arrays.asList(dtID.getNames()));
-         String[] rnames = (String[]) invoke(client, "getRepositoryNames", createArgs(dtID));
-         log.debug("End getRepositoryNames: " + Arrays.asList(rnames));
-         return rnames;
-      }
-      finally
-      {
-         client.disconnect();
-      }
-   }
-
-   public void redeploy(DeploymentID dtID) throws Exception
-   {
-      Client client = getClient();
-      try
-      {
-         log.debug("Begin redeploy: " + dtID);
-         invoke(client, "redeploy", createArgs(dtID));
-         log.debug("End redeploy: "+dtID);
-      }
-      finally
-      {
-         client.disconnect();
-      }
-   }
-
-   public void prepare(DeploymentID dtID) throws Exception
-   {
-      Client client = getClient();
-      try
-      {
-         log.debug("Begin prepare: " + dtID);
-         invoke(client, "prepare", createArgs(dtID));
-         log.debug("End prepare: "+dtID);
-      }
-      finally
-      {
-         client.disconnect();
-      }
-   }
-
-   /**
-    * Create the client args.
-    *
-    * @param dtID the deployment id
-    * @return args map
-    */
-   protected Map<?, ?> createArgs(DeploymentID dtID)
-   {
-      return new HashMap<Object, Object>(Collections.singletonMap("DeploymentTargetID", dtID));
-   }
-
-   /**
-    * Start a given deployment(s)
-    */
-   public void start(DeploymentID dtID) throws Exception
-   {
-      Client client = getClient();
-      try
-      {
-         log.debug("Start: " + dtID);
-         invoke(client, "start", createArgs(dtID));
-         log.debug("End start: "+dtID);
-      }
-      finally
-      {
-         client.disconnect();
-      }
-   }
-
-   /**
-    * Stop a given module
-    */
-   public void stop(DeploymentID dtID) throws Exception
-   {
-      Client client = getClient();
-      try
-      {
-         log.debug("Begin stop: " + dtID);
-         invoke(client, "stop", createArgs(dtID));
-         log.debug("End stop");
-      }
-      finally
-      {
-         client.disconnect();
-      }
-   }
-   
-   /**
-    * Remove a given module.
-    * 
-    * @param dtID the deployment id
-    * @throws Exception
-    */
-   public void remove(DeploymentID dtID) throws Exception
-   {
-      Client client = getClient();
-      try
-      {
-         log.debug("Begin remove: " + dtID);
-         invoke(client, "remove", createArgs(dtID));
-         log.debug("End remove");
-      }
-      finally
-      {
-         client.disconnect();
-      }      
-   }
-
-   public String toString()
-   {
-      StringBuilder tmp = new StringBuilder();
-      tmp.append("name=");
-      tmp.append(name);
-      tmp.append(", locator=");
-      tmp.append(locator);
-      tmp.append(", subsystem=");
-      tmp.append(subsystem);
-      return tmp.toString();
-   }
-
-   /**
-    * Get the remoting client connection
-    * @return
-    * @throws Exception
-    */
-   private Client getClient() throws Exception
-   {
-      log.debug("Calling remoting server with locator of: " + locator);
-
-      Client remotingClient = new Client(locator, subsystem);
-      remotingClient.connect();
-      return remotingClient;
-   }
-
-   /**
-    * Stream a deployment to the server
-    * 
-    * @param client - the remoting client
-    * @param sdtID - the deployment content encapsulation
-    * @return the profile service repository unique name
-    * @throws Exception
-    */
-   private String transferDeployment(Client client, SerializableDeploymentID sdtID) throws Exception
-   {
-      InputStream is = sdtID.getContentIS();
-      try
-      {
-         // This return value depends on the proxy type
-         InvocationResponse response = (InvocationResponse) client.invoke(is, sdtID);
-         return (String) response.getResponse();
-      }
-      catch(Error e)
-      {
-         throw new RuntimeException(e);
-      }
-      catch(Throwable e)
-      {
-         throw new RuntimeException(e);         
-      }
-      finally
-      {
-         try
-         {
-            is.close();
-         }
-         catch (IOException ignored)
-         {
-         }
-      }
-   }
-
-   private Object invoke(Client client, String name, Map<?, ?> args) throws Exception
-   {
-      try
-      {
-         return client.invoke(name, args);
-      }
-      catch(Error e)
-      {
-         throw new RuntimeException(e);
-      }
-      catch(Throwable e)
-      {
-         throw new RuntimeException(e);
-      }      
-   }
-}

Copied: trunk/profileservice/src/main/java/org/jboss/profileservice/management/client/upload/StreamingDeploymentTarget.java (from rev 97697, tags/JBoss_6_0_0_M1/profileservice/src/main/org/jboss/profileservice/management/client/upload/StreamingDeploymentTarget.java)
===================================================================
--- trunk/profileservice/src/main/java/org/jboss/profileservice/management/client/upload/StreamingDeploymentTarget.java	                        (rev 0)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/management/client/upload/StreamingDeploymentTarget.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -0,0 +1,315 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.profileservice.management.client.upload;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.aop.joinpoint.InvocationResponse;
+import org.jboss.deployers.spi.management.deploy.DeploymentID;
+import org.jboss.deployers.spi.management.deploy.DeploymentTarget;
+import org.jboss.logging.Logger;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.InvokerLocator;
+
+/**
+ * An implementation of DeploymentTarget that uses remoting for streaming
+ * content in distribute, and basic rpc for the other methods.
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class StreamingDeploymentTarget
+   implements DeploymentTarget, Serializable
+{
+   private static final long serialVersionUID = 1;
+   private static final Logger log = Logger.getLogger(StreamingDeploymentTarget.class);
+
+   /** The deployment target locator */
+   private InvokerLocator locator;
+   private String name;
+   private String subsystem;
+
+   /**
+    * Create a target given a remoting locator 
+    * @param locator -
+    * @param name - 
+    * @param subsystem - 
+    */
+   public StreamingDeploymentTarget(InvokerLocator locator, String name, String subsystem)
+   {
+      log.debug("new StreamingTarget: " + locator);
+      this.name = name;
+      this.subsystem = subsystem;
+      this.locator = locator;
+   }
+   
+   public String getDescription()
+   {
+      return name + "(" + locator + ")";
+   }
+
+   public String getName()
+   {
+      return name;
+   }
+
+   public InvokerLocator getInvokerLocator()
+   {
+      return locator;
+   }
+
+   /**
+    * Distribute a deployment to the profile targets.
+    *
+    * @param deployment - the encapsulation of the deployment to distribute
+    * @throws Exception for any error
+    */
+   public void distribute(DeploymentID deployment) throws Exception
+   {
+      Client client = getClient();
+      try
+      {
+         log.debug("Begin distribute: " + deployment);
+         String[] rnames;
+         if (deployment.isCopyContent())
+         {
+            URL contentURL = deployment.getContentURL();
+            SerializableDeploymentID sdtID = new SerializableDeploymentID(deployment);
+            InputStream contentIS = contentURL.openStream();
+            sdtID.setContentIS(contentIS);
+            String repositoryName = transferDeployment(client, sdtID);
+            rnames = new String[]{repositoryName};
+         }
+         else
+         {
+            rnames = (String[])invoke(client, "distribute", createArgs(deployment));
+         }
+         // Update the repository names on the deployment
+         deployment.setRepositoryNames(rnames);
+         log.debug("End distribute, repositoryNames: "+ Arrays.asList(rnames));
+      }
+      finally
+      {
+         client.disconnect();
+      }
+   }
+
+   public String[] getRepositoryNames(DeploymentID dtID) throws Exception
+   {
+      Client client = getClient();
+      try
+      {
+         log.debug("Begin getRepositoryNames: " + Arrays.asList(dtID.getNames()));
+         String[] rnames = (String[]) invoke(client, "getRepositoryNames", createArgs(dtID));
+         log.debug("End getRepositoryNames: " + Arrays.asList(rnames));
+         return rnames;
+      }
+      finally
+      {
+         client.disconnect();
+      }
+   }
+
+   public void redeploy(DeploymentID dtID) throws Exception
+   {
+      Client client = getClient();
+      try
+      {
+         log.debug("Begin redeploy: " + dtID);
+         invoke(client, "redeploy", createArgs(dtID));
+         log.debug("End redeploy: "+dtID);
+      }
+      finally
+      {
+         client.disconnect();
+      }
+   }
+
+   public void prepare(DeploymentID dtID) throws Exception
+   {
+      Client client = getClient();
+      try
+      {
+         log.debug("Begin prepare: " + dtID);
+         invoke(client, "prepare", createArgs(dtID));
+         log.debug("End prepare: "+dtID);
+      }
+      finally
+      {
+         client.disconnect();
+      }
+   }
+
+   /**
+    * Create the client args.
+    *
+    * @param dtID the deployment id
+    * @return args map
+    */
+   protected Map<?, ?> createArgs(DeploymentID dtID)
+   {
+      return new HashMap<Object, Object>(Collections.singletonMap("DeploymentTargetID", dtID));
+   }
+
+   /**
+    * Start a given deployment(s)
+    */
+   public void start(DeploymentID dtID) throws Exception
+   {
+      Client client = getClient();
+      try
+      {
+         log.debug("Start: " + dtID);
+         invoke(client, "start", createArgs(dtID));
+         log.debug("End start: "+dtID);
+      }
+      finally
+      {
+         client.disconnect();
+      }
+   }
+
+   /**
+    * Stop a given module
+    */
+   public void stop(DeploymentID dtID) throws Exception
+   {
+      Client client = getClient();
+      try
+      {
+         log.debug("Begin stop: " + dtID);
+         invoke(client, "stop", createArgs(dtID));
+         log.debug("End stop");
+      }
+      finally
+      {
+         client.disconnect();
+      }
+   }
+   
+   /**
+    * Remove a given module.
+    * 
+    * @param dtID the deployment id
+    * @throws Exception
+    */
+   public void remove(DeploymentID dtID) throws Exception
+   {
+      Client client = getClient();
+      try
+      {
+         log.debug("Begin remove: " + dtID);
+         invoke(client, "remove", createArgs(dtID));
+         log.debug("End remove");
+      }
+      finally
+      {
+         client.disconnect();
+      }      
+   }
+
+   public String toString()
+   {
+      StringBuilder tmp = new StringBuilder();
+      tmp.append("name=");
+      tmp.append(name);
+      tmp.append(", locator=");
+      tmp.append(locator);
+      tmp.append(", subsystem=");
+      tmp.append(subsystem);
+      return tmp.toString();
+   }
+
+   /**
+    * Get the remoting client connection
+    * @return
+    * @throws Exception
+    */
+   private Client getClient() throws Exception
+   {
+      log.debug("Calling remoting server with locator of: " + locator);
+
+      Client remotingClient = new Client(locator, subsystem);
+      remotingClient.connect();
+      return remotingClient;
+   }
+
+   /**
+    * Stream a deployment to the server
+    * 
+    * @param client - the remoting client
+    * @param sdtID - the deployment content encapsulation
+    * @return the profile service repository unique name
+    * @throws Exception
+    */
+   private String transferDeployment(Client client, SerializableDeploymentID sdtID) throws Exception
+   {
+      InputStream is = sdtID.getContentIS();
+      try
+      {
+         // This return value depends on the proxy type
+         InvocationResponse response = (InvocationResponse) client.invoke(is, sdtID);
+         return (String) response.getResponse();
+      }
+      catch(Error e)
+      {
+         throw new RuntimeException(e);
+      }
+      catch(Throwable e)
+      {
+         throw new RuntimeException(e);         
+      }
+      finally
+      {
+         try
+         {
+            is.close();
+         }
+         catch (IOException ignored)
+         {
+         }
+      }
+   }
+
+   private Object invoke(Client client, String name, Map<?, ?> args) throws Exception
+   {
+      try
+      {
+         return client.invoke(name, args);
+      }
+      catch(Error e)
+      {
+         throw new RuntimeException(e);
+      }
+      catch(Throwable e)
+      {
+         throw new RuntimeException(e);
+      }      
+   }
+}

Deleted: trunk/profileservice/src/main/java/org/jboss/profileservice/management/mbean/EJBInvocationStatsMapper.java
===================================================================
--- trunk/profileservice/src/main/java/org/jboss/profileservice/management/mbean/EJBInvocationStatsMapper.java	2009-12-10 16:45:13 UTC (rev 97698)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/management/mbean/EJBInvocationStatsMapper.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -1,145 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, 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.management.mbean;
-
-import java.lang.reflect.Type;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.jboss.metatype.api.types.CompositeMetaType;
-import org.jboss.metatype.api.types.ImmutableCompositeMetaType;
-import org.jboss.metatype.api.types.MapCompositeMetaType;
-import org.jboss.metatype.api.types.MetaType;
-import org.jboss.metatype.api.types.SimpleMetaType;
-import org.jboss.metatype.api.values.MapCompositeValueSupport;
-import org.jboss.metatype.api.values.MetaValue;
-import org.jboss.metatype.api.values.SimpleValueSupport;
-import org.jboss.metatype.spi.values.MetaMapper;
-
-/**
- * {@link MetaMapper} for detyped EJB invocation statistics.
- *
- * @author Jason T. Greene
- */
-public class EJBInvocationStatsMapper extends MetaMapper<Map<String, Map<String, Long>>>
-{
-   public static final CompositeMetaType TYPE;
-   public static final CompositeMetaType METHOD_STATS_TYPE;
-   private static String[] rootItemNames;
-   private static MapCompositeMetaType METHOD_STATS_MAP_TYPE;
-
-   static
-   {
-      String[] methodItemNames = {
-            "count",
-            "minTime",
-            "maxTime",
-            "totalTime"
-      };
-      String[] methodItemDescriptions = {
-            "the number of invocations",
-            "the minimum invocation time",
-            "the maximum invocation time",
-            "the total invocation time",
-      };
-      MetaType[] methodItemTypes = {
-            SimpleMetaType.LONG,
-            SimpleMetaType.LONG,
-            SimpleMetaType.LONG,
-            SimpleMetaType.LONG,
-      };
-      METHOD_STATS_TYPE = new ImmutableCompositeMetaType("MethodStatistics",
-            "Method invocation statistics",
-            methodItemNames, methodItemDescriptions, methodItemTypes);
-
-      METHOD_STATS_MAP_TYPE = new MapCompositeMetaType(METHOD_STATS_TYPE);
-
-      rootItemNames = new String[] {
-            "concurrentCalls",
-            "maxConcurrentCalls",
-            "lastResetTime",
-            "methodStats"
-      };
-
-      String[] rootItemDescriptions = {
-            "the number of concurrent invocations",
-            "the maximum number of concurrent invocations",
-            "last time statistics were reset",
-            "method statistics",
-      };
-      MetaType[] rootItemTypes = {
-            SimpleMetaType.LONG,
-            SimpleMetaType.LONG,
-            SimpleMetaType.LONG,
-            METHOD_STATS_MAP_TYPE
-      };
-
-      TYPE = new ImmutableCompositeMetaType("InvocationStatistics",
-            "EJB invocation statistics",
-            rootItemNames, rootItemDescriptions, rootItemTypes);
-   }
-
-   @Override
-   public MetaType getMetaType()
-   {
-      return TYPE;
-   }
-
-   @Override
-   public Type mapToType()
-   {
-      return Map.class;
-   }
-
-   @Override
-   public MetaValue createMetaValue(MetaType metaType, Map<String, Map<String, Long>> object)
-   {
-      Map<String, MetaValue> methodMap = new HashMap<String, MetaValue>();
-      for (Map.Entry<String, Map<String, Long>> entry: object.entrySet())
-      {
-         if (entry.getKey().charAt(0) == '#')
-            continue;
-
-         MapCompositeValueSupport cvs = new MapCompositeValueSupport(METHOD_STATS_TYPE);
-         for (String name : METHOD_STATS_TYPE.itemSet())
-            cvs.put(name, SimpleValueSupport.wrap(entry.getValue().get(name)));
-
-         methodMap.put(entry.getKey(), cvs);
-      }
-
-      MapCompositeValueSupport root = new MapCompositeValueSupport(TYPE);
-      for (int i = 0; i < 3; i++)
-         root.put(rootItemNames[i], SimpleValueSupport.wrap(object.get("#Global").get(rootItemNames[i])));
-
-      root.put(rootItemNames[3], new MapCompositeValueSupport(methodMap, METHOD_STATS_MAP_TYPE));
-
-      return root;
-   }
-
-   @Override
-   public Map<String, Map<String, Long>> unwrapMetaValue(MetaValue metaValue)
-   {
-      // This is read-only, so not needed
-      return null;
-   }
-}

Copied: trunk/profileservice/src/main/java/org/jboss/profileservice/management/mbean/EJBInvocationStatsMapper.java (from rev 97697, tags/JBoss_6_0_0_M1/profileservice/src/main/org/jboss/profileservice/management/mbean/EJBInvocationStatsMapper.java)
===================================================================
--- trunk/profileservice/src/main/java/org/jboss/profileservice/management/mbean/EJBInvocationStatsMapper.java	                        (rev 0)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/management/mbean/EJBInvocationStatsMapper.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -0,0 +1,145 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.management.mbean;
+
+import java.lang.reflect.Type;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.metatype.api.types.CompositeMetaType;
+import org.jboss.metatype.api.types.ImmutableCompositeMetaType;
+import org.jboss.metatype.api.types.MapCompositeMetaType;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.MapCompositeValueSupport;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.metatype.spi.values.MetaMapper;
+
+/**
+ * {@link MetaMapper} for detyped EJB invocation statistics.
+ *
+ * @author Jason T. Greene
+ */
+public class EJBInvocationStatsMapper extends MetaMapper<Map<String, Map<String, Long>>>
+{
+   public static final CompositeMetaType TYPE;
+   public static final CompositeMetaType METHOD_STATS_TYPE;
+   private static String[] rootItemNames;
+   private static MapCompositeMetaType METHOD_STATS_MAP_TYPE;
+
+   static
+   {
+      String[] methodItemNames = {
+            "count",
+            "minTime",
+            "maxTime",
+            "totalTime"
+      };
+      String[] methodItemDescriptions = {
+            "the number of invocations",
+            "the minimum invocation time",
+            "the maximum invocation time",
+            "the total invocation time",
+      };
+      MetaType[] methodItemTypes = {
+            SimpleMetaType.LONG,
+            SimpleMetaType.LONG,
+            SimpleMetaType.LONG,
+            SimpleMetaType.LONG,
+      };
+      METHOD_STATS_TYPE = new ImmutableCompositeMetaType("MethodStatistics",
+            "Method invocation statistics",
+            methodItemNames, methodItemDescriptions, methodItemTypes);
+
+      METHOD_STATS_MAP_TYPE = new MapCompositeMetaType(METHOD_STATS_TYPE);
+
+      rootItemNames = new String[] {
+            "concurrentCalls",
+            "maxConcurrentCalls",
+            "lastResetTime",
+            "methodStats"
+      };
+
+      String[] rootItemDescriptions = {
+            "the number of concurrent invocations",
+            "the maximum number of concurrent invocations",
+            "last time statistics were reset",
+            "method statistics",
+      };
+      MetaType[] rootItemTypes = {
+            SimpleMetaType.LONG,
+            SimpleMetaType.LONG,
+            SimpleMetaType.LONG,
+            METHOD_STATS_MAP_TYPE
+      };
+
+      TYPE = new ImmutableCompositeMetaType("InvocationStatistics",
+            "EJB invocation statistics",
+            rootItemNames, rootItemDescriptions, rootItemTypes);
+   }
+
+   @Override
+   public MetaType getMetaType()
+   {
+      return TYPE;
+   }
+
+   @Override
+   public Type mapToType()
+   {
+      return Map.class;
+   }
+
+   @Override
+   public MetaValue createMetaValue(MetaType metaType, Map<String, Map<String, Long>> object)
+   {
+      Map<String, MetaValue> methodMap = new HashMap<String, MetaValue>();
+      for (Map.Entry<String, Map<String, Long>> entry: object.entrySet())
+      {
+         if (entry.getKey().charAt(0) == '#')
+            continue;
+
+         MapCompositeValueSupport cvs = new MapCompositeValueSupport(METHOD_STATS_TYPE);
+         for (String name : METHOD_STATS_TYPE.itemSet())
+            cvs.put(name, SimpleValueSupport.wrap(entry.getValue().get(name)));
+
+         methodMap.put(entry.getKey(), cvs);
+      }
+
+      MapCompositeValueSupport root = new MapCompositeValueSupport(TYPE);
+      for (int i = 0; i < 3; i++)
+         root.put(rootItemNames[i], SimpleValueSupport.wrap(object.get("#Global").get(rootItemNames[i])));
+
+      root.put(rootItemNames[3], new MapCompositeValueSupport(methodMap, METHOD_STATS_MAP_TYPE));
+
+      return root;
+   }
+
+   @Override
+   public Map<String, Map<String, Long>> unwrapMetaValue(MetaValue metaValue)
+   {
+      // This is read-only, so not needed
+      return null;
+   }
+}

Deleted: trunk/profileservice/src/main/java/org/jboss/profileservice/management/upload/remoting/SecurityActions.java
===================================================================
--- trunk/profileservice/src/main/java/org/jboss/profileservice/management/upload/remoting/SecurityActions.java	2009-12-10 16:45:13 UTC (rev 97698)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/management/upload/remoting/SecurityActions.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -1,93 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.profileservice.management.upload.remoting;
-
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-
-import org.jboss.security.ISecurityManagement;
-import org.jboss.security.SecurityContext;
-import org.jboss.security.SecurityContextAssociation;
-import org.jboss.security.SecurityContextFactory;
- 
-/**
- *  Privileged Blocks
- *  @author Anil.Saldhana at redhat.com
- *  @author Scott.Stark at jboss.org 
- *  @version $Revision: 85526 $
- */
-class SecurityActions
-{
-   static SecurityContext createAndSetSecurityContext(final String domain) throws PrivilegedActionException
-   {
-      return AccessController.doPrivileged(new PrivilegedExceptionAction<SecurityContext>()
-      { 
-         public SecurityContext run() throws Exception
-         {
-            SecurityContext sc =  SecurityContextFactory.createSecurityContext(domain); 
-            setSecurityContext(sc);
-            return sc;
-         }}
-      );
-   }
-
-   static void setSecurityContext(final SecurityContext sc)
-   {
-      AccessController.doPrivileged(new PrivilegedAction<Object>()
-      { 
-         public Object run()
-         {
-            SecurityContextAssociation.setSecurityContext(sc);
-            return null;
-         }}
-      );
-   }
-   static void setSecurityManagement(final SecurityContext sc, final ISecurityManagement sm)
-   {
-      AccessController.doPrivileged(new PrivilegedAction<Object>()
-      { 
-         public Object run()
-         {
-            sc.setSecurityManagement(sm);
-            return null;
-         }}
-      );
-   }
-   static String trace(final SecurityContext sc)
-   {
-      return AccessController.doPrivileged(new PrivilegedAction<String>()
-      { 
-         public String run()
-         {
-            StringBuilder sb = new StringBuilder();
-            sb.append(" Principal = " + sc.getUtil().getUserPrincipal());
-            sb.append(" Subject:"+sc.getUtil().getSubject());
-            sb.append(" Incoming run as:"+sc.getIncomingRunAs());
-            sb.append(" Outgoing run as:"+sc.getOutgoingRunAs());
-            return sb.toString();
-         }
-      }
-      );
-   }
-}

Copied: trunk/profileservice/src/main/java/org/jboss/profileservice/management/upload/remoting/SecurityActions.java (from rev 97697, tags/JBoss_6_0_0_M1/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/SecurityActions.java)
===================================================================
--- trunk/profileservice/src/main/java/org/jboss/profileservice/management/upload/remoting/SecurityActions.java	                        (rev 0)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/management/upload/remoting/SecurityActions.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -0,0 +1,93 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.profileservice.management.upload.remoting;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+import org.jboss.security.ISecurityManagement;
+import org.jboss.security.SecurityContext;
+import org.jboss.security.SecurityContextAssociation;
+import org.jboss.security.SecurityContextFactory;
+ 
+/**
+ *  Privileged Blocks
+ *  @author Anil.Saldhana at redhat.com
+ *  @author Scott.Stark at jboss.org 
+ *  @version $Revision: 85526 $
+ */
+class SecurityActions
+{
+   static SecurityContext createAndSetSecurityContext(final String domain) throws PrivilegedActionException
+   {
+      return AccessController.doPrivileged(new PrivilegedExceptionAction<SecurityContext>()
+      { 
+         public SecurityContext run() throws Exception
+         {
+            SecurityContext sc =  SecurityContextFactory.createSecurityContext(domain); 
+            setSecurityContext(sc);
+            return sc;
+         }}
+      );
+   }
+
+   static void setSecurityContext(final SecurityContext sc)
+   {
+      AccessController.doPrivileged(new PrivilegedAction<Object>()
+      { 
+         public Object run()
+         {
+            SecurityContextAssociation.setSecurityContext(sc);
+            return null;
+         }}
+      );
+   }
+   static void setSecurityManagement(final SecurityContext sc, final ISecurityManagement sm)
+   {
+      AccessController.doPrivileged(new PrivilegedAction<Object>()
+      { 
+         public Object run()
+         {
+            sc.setSecurityManagement(sm);
+            return null;
+         }}
+      );
+   }
+   static String trace(final SecurityContext sc)
+   {
+      return AccessController.doPrivileged(new PrivilegedAction<String>()
+      { 
+         public String run()
+         {
+            StringBuilder sb = new StringBuilder();
+            sb.append(" Principal = " + sc.getUtil().getUserPrincipal());
+            sb.append(" Subject:"+sc.getUtil().getSubject());
+            sb.append(" Incoming run as:"+sc.getIncomingRunAs());
+            sb.append(" Outgoing run as:"+sc.getOutgoingRunAs());
+            return sb.toString();
+         }
+      }
+      );
+   }
+}

Copied: trunk/profileservice/src/main/java/org/jboss/profileservice/management/views (from rev 97697, tags/JBoss_6_0_0_M1/profileservice/src/main/org/jboss/profileservice/management/views)

Deleted: trunk/profileservice/src/main/java/org/jboss/profileservice/management/views/AbstractManagedDeploymentView.java
===================================================================
--- tags/JBoss_6_0_0_M1/profileservice/src/main/org/jboss/profileservice/management/views/AbstractManagedDeploymentView.java	2009-12-10 15:49:13 UTC (rev 97697)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/management/views/AbstractManagedDeploymentView.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -1,526 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, 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.management.views;
-
-import java.lang.annotation.Annotation;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
-
-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.spi.NoSuchDeploymentException;
-
-/**
- * A abstract managed deployment view.
- * 
- * @author Scott.Stark at jboss.org
- * @author adrian at jboss.org
- * @author ales.justin at jboss.org
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * 
- * @version $Revision$
- */
-public abstract class AbstractManagedDeploymentView
-{
-   
-   /** The logger. */
-   private static final Logger log = Logger.getLogger(AbstractManagedDeploymentView.class);
-
-   /** An index of ManagedComponent by ComponentType */
-   private Map<ComponentType, Set<ManagedComponent>> compByCompType = new HashMap<ComponentType, Set<ManagedComponent>>();
-   
-   /** 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>();
-   
-   /** The deployment name to ManagedDeployment map */
-   private Map<String, ManagedDeployment> managedDeployments = new TreeMap<String, ManagedDeployment>();   
-   
-   /** The root deployments to resolve the deployment name. */
-   private List<String> rootDeployments = new ArrayList<String>();  
-
-   /**
-    * Process managed deployment.
-    *
-    * @param md the managed deployment
-    * @param profile the associated profile key 
-    * @param state the deployment state
-    * @param level depth level
-    * @param trace is trace enabled
-    * @throws Exception for any error
-    */
-   protected void processManagedDeployment(ManagedDeployment md, DeploymentState state, int level, boolean trace) throws Exception
-   {
-      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);
-      }
-      managedDeployments.put(name, md);
-      
-      // Add root deployments
-      if(level == 0)
-         this.rootDeployments.add(name);
-      
-      // 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, trace);
-         }
-      }
-   }
-   
-   /**
-    * Get the deployment names for a given type.
-    * 
-    * @param type the deployment type
-    * @return the matching deployments
-    */
-   public Set<String> getDeploymentNamesForType(String type)
-   {
-      boolean trace = log.isTraceEnabled();
-      HashSet<String> matches = new HashSet<String>();
-      for(ManagedDeployment md : managedDeployments.values())
-      {
-         String name = md.getName();
-         Set<String> types = md.getTypes();
-         if(types != null)
-         {
-            if(types.contains(type))
-            {
-               if(trace)
-                  log.trace(name+" matches type: "+type+", types:"+types);
-               matches.add(name);
-            }
-         }
-      }
-      return matches;
-   }
-   
-   /**
-    * Get the deployments for a given type.
-    * 
-    * @param type the deployment type.
-    * @return the matching deployments
-    */
-   public Set<ManagedDeployment> getDeploymentsForType(String type)
-   {
-      Set<String> names = getDeploymentNamesForType(type);
-      HashSet<ManagedDeployment> mds = new HashSet<ManagedDeployment>();
-      for(String name : names)
-      {
-         ManagedDeployment md = this.managedDeployments.get(name);
-         mds.add(md);
-      }
-      return mds;
-   }
-   
-   public Set<ComponentType> getComponentTypes()
-   {
-      return compByCompType.keySet();      
-   }
-
-   /**
-    * Get component for a given type.
-    * 
-    * @param type the component type
-    * @return a set of matching components
-    */
-   public Set<ManagedComponent> getComponentsForType(ComponentType type)
-   {
-      Set<ManagedComponent> comps = compByCompType.get(type);
-      if(comps == null)
-         comps = Collections.emptySet();
-      return comps;
-   }
-   
-   /**
-    * Get the deployment names.
-    * 
-    * @return the deployment names
-    */
-   public Set<String> getDeploymentNames()
-   {
-      return this.managedDeployments.keySet();
-   }
-   
-   /**
-    * Find a deployment.
-    * 
-    * @param name
-    * @return
-    * @throws NoSuchDeploymentException
-    */
-   public Collection<ManagedDeployment> getDeployment(String name) throws NoSuchDeploymentException
-   {
-      if(name == null)
-         throw new IllegalArgumentException("Null deployment name");
-
-      List<ManagedDeployment> deployments = new ArrayList<ManagedDeployment>();
-      // Check the file name
-      
-      if(this.managedDeployments.containsKey(name))
-      {
-         ManagedDeployment md = this.managedDeployments.get(name);
-         if(md != null)
-            deployments.add(md);
-      }
-      else
-      {
-         // Look for a simple name
-         for(String deployment : this.rootDeployments)
-         {
-            String fixedDeploymentName = deployment;
-            if(deployment.endsWith("/"))
-               fixedDeploymentName = deployment.substring(0, deployment.length() - 1);
-
-            if(fixedDeploymentName.endsWith(name))
-            {
-               ManagedDeployment md = this.managedDeployments.get(deployment);
-               if(md != null)
-                  deployments.add(md);
-            }
-         }  
-      }
-      return deployments;
-   }
-   
-   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;
-   
-   /**
-    * Process managed object.
-    *
-    * @param mo the managed object
-    * @param md the managed deployment
-    */
-   protected void processManagedObject(ManagedObject mo, ManagedDeployment md)
-      throws Exception
-   {
-      String key = mo.getName() + "/" + mo.getNameType();
-      if(mo.getName().equals("org.jboss.security.plugins.SecurityConfig"))
-         log.info("Saw SecurityConfig MO");
-      log.debug("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)
-         {
-            log.debug("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
-         ManagedComponent comp = md.getComponent(mo.getName());
-         if (comp != null)
-         {
-            RunState state = updateRunState(mo, comp);
-            log.debug("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
-            ManagedComponent comp = md.getComponent(mo.getName());
-            if (comp != null)
-            {
-               RunState state = updateRunState(runtimeMO, comp);
-               log.debug("Updated component: "+comp+" run state to: "+state);
-            }
-         }
-      }
-
-      // Update the MO registry
-      // TODO - does this make sense? In case of a MetaType.isCollection we could get different results then
-//      ManagedObject prevMO = moRegistry.put(key, mo);
-//      if( prevMO != null )
-//      {
-//         // This should only matter for ManagedObjects that have a ManagementObjectID
-//         log.debug("Duplicate mo for key: "+key+", prevMO: "+prevMO);
-//         return;
-//      }
-      // Check for unresolved refs
-      checkForReferences(key, mo);
-
-      // Map any existing ManagedComponent types
-      for(ManagedComponent comp : md.getComponents().values())
-      {
-         log.debug("Updating ManagementComponent: "+comp);
-         ComponentType type = comp.getType();
-         Set<ManagedComponent> typeComps = compByCompType.get(type);
-         if (typeComps == null)
-         {
-            typeComps = new HashSet<ManagedComponent>();
-            compByCompType.put(type, typeComps);
-         }
-         typeComps.add(comp);
-      }
-
-      // Create ManagedComponents for ManagedObjects annotated with ManagementComponent
-      ManagementComponent mc = (ManagementComponent) moAnns.get(ManagementComponent.class.getName());
-      if (mc != null && md.getComponent(mo.getName()) == null)
-      {
-         ComponentType type = new ComponentType(mc.type(), mc.subtype());
-         ManagedComponentImpl comp = new ManagedComponentImpl(type, md, mo);
-         md.addComponent(mo.getName(), comp);
-         log.debug("Processing ManagementComponent("+mo.getName()+"): "+comp);
-         Set<ManagedComponent> typeComps = compByCompType.get(type);
-         if (typeComps == null)
-         {
-            typeComps = new HashSet<ManagedComponent>();
-            compByCompType.put(type, typeComps);
-         }
-         typeComps.add(comp);
-         updateRunState(null, comp);
-      }
-
-      // Scan for @ManagementObjectRef
-      for(ManagedProperty prop : mo.getProperties().values())
-      {
-         log.debug("Checking property: "+prop);
-         // 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();
-               log.debug("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()
-               log.debug("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)
-               {
-                  log.debug("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);
-         }
-         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);
-            }
-         }
-         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);
-                  }
-               }
-            }
-         }
-      }
-   }
-
-   /**
-    * 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.debug("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) 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);
-      }
-   }
-   
-}

Copied: trunk/profileservice/src/main/java/org/jboss/profileservice/management/views/AbstractManagedDeploymentView.java (from rev 97697, tags/JBoss_6_0_0_M1/profileservice/src/main/org/jboss/profileservice/management/views/AbstractManagedDeploymentView.java)
===================================================================
--- trunk/profileservice/src/main/java/org/jboss/profileservice/management/views/AbstractManagedDeploymentView.java	                        (rev 0)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/management/views/AbstractManagedDeploymentView.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -0,0 +1,526 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.management.views;
+
+import java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+
+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.spi.NoSuchDeploymentException;
+
+/**
+ * A abstract managed deployment view.
+ * 
+ * @author Scott.Stark at jboss.org
+ * @author adrian at jboss.org
+ * @author ales.justin at jboss.org
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * 
+ * @version $Revision$
+ */
+public abstract class AbstractManagedDeploymentView
+{
+   
+   /** The logger. */
+   private static final Logger log = Logger.getLogger(AbstractManagedDeploymentView.class);
+
+   /** An index of ManagedComponent by ComponentType */
+   private Map<ComponentType, Set<ManagedComponent>> compByCompType = new HashMap<ComponentType, Set<ManagedComponent>>();
+   
+   /** 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>();
+   
+   /** The deployment name to ManagedDeployment map */
+   private Map<String, ManagedDeployment> managedDeployments = new TreeMap<String, ManagedDeployment>();   
+   
+   /** The root deployments to resolve the deployment name. */
+   private List<String> rootDeployments = new ArrayList<String>();  
+
+   /**
+    * Process managed deployment.
+    *
+    * @param md the managed deployment
+    * @param profile the associated profile key 
+    * @param state the deployment state
+    * @param level depth level
+    * @param trace is trace enabled
+    * @throws Exception for any error
+    */
+   protected void processManagedDeployment(ManagedDeployment md, DeploymentState state, int level, boolean trace) throws Exception
+   {
+      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);
+      }
+      managedDeployments.put(name, md);
+      
+      // Add root deployments
+      if(level == 0)
+         this.rootDeployments.add(name);
+      
+      // 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, trace);
+         }
+      }
+   }
+   
+   /**
+    * Get the deployment names for a given type.
+    * 
+    * @param type the deployment type
+    * @return the matching deployments
+    */
+   public Set<String> getDeploymentNamesForType(String type)
+   {
+      boolean trace = log.isTraceEnabled();
+      HashSet<String> matches = new HashSet<String>();
+      for(ManagedDeployment md : managedDeployments.values())
+      {
+         String name = md.getName();
+         Set<String> types = md.getTypes();
+         if(types != null)
+         {
+            if(types.contains(type))
+            {
+               if(trace)
+                  log.trace(name+" matches type: "+type+", types:"+types);
+               matches.add(name);
+            }
+         }
+      }
+      return matches;
+   }
+   
+   /**
+    * Get the deployments for a given type.
+    * 
+    * @param type the deployment type.
+    * @return the matching deployments
+    */
+   public Set<ManagedDeployment> getDeploymentsForType(String type)
+   {
+      Set<String> names = getDeploymentNamesForType(type);
+      HashSet<ManagedDeployment> mds = new HashSet<ManagedDeployment>();
+      for(String name : names)
+      {
+         ManagedDeployment md = this.managedDeployments.get(name);
+         mds.add(md);
+      }
+      return mds;
+   }
+   
+   public Set<ComponentType> getComponentTypes()
+   {
+      return compByCompType.keySet();      
+   }
+
+   /**
+    * Get component for a given type.
+    * 
+    * @param type the component type
+    * @return a set of matching components
+    */
+   public Set<ManagedComponent> getComponentsForType(ComponentType type)
+   {
+      Set<ManagedComponent> comps = compByCompType.get(type);
+      if(comps == null)
+         comps = Collections.emptySet();
+      return comps;
+   }
+   
+   /**
+    * Get the deployment names.
+    * 
+    * @return the deployment names
+    */
+   public Set<String> getDeploymentNames()
+   {
+      return this.managedDeployments.keySet();
+   }
+   
+   /**
+    * Find a deployment.
+    * 
+    * @param name
+    * @return
+    * @throws NoSuchDeploymentException
+    */
+   public Collection<ManagedDeployment> getDeployment(String name) throws NoSuchDeploymentException
+   {
+      if(name == null)
+         throw new IllegalArgumentException("Null deployment name");
+
+      List<ManagedDeployment> deployments = new ArrayList<ManagedDeployment>();
+      // Check the file name
+      
+      if(this.managedDeployments.containsKey(name))
+      {
+         ManagedDeployment md = this.managedDeployments.get(name);
+         if(md != null)
+            deployments.add(md);
+      }
+      else
+      {
+         // Look for a simple name
+         for(String deployment : this.rootDeployments)
+         {
+            String fixedDeploymentName = deployment;
+            if(deployment.endsWith("/"))
+               fixedDeploymentName = deployment.substring(0, deployment.length() - 1);
+
+            if(fixedDeploymentName.endsWith(name))
+            {
+               ManagedDeployment md = this.managedDeployments.get(deployment);
+               if(md != null)
+                  deployments.add(md);
+            }
+         }  
+      }
+      return deployments;
+   }
+   
+   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;
+   
+   /**
+    * Process managed object.
+    *
+    * @param mo the managed object
+    * @param md the managed deployment
+    */
+   protected void processManagedObject(ManagedObject mo, ManagedDeployment md)
+      throws Exception
+   {
+      String key = mo.getName() + "/" + mo.getNameType();
+      if(mo.getName().equals("org.jboss.security.plugins.SecurityConfig"))
+         log.info("Saw SecurityConfig MO");
+      log.debug("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)
+         {
+            log.debug("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
+         ManagedComponent comp = md.getComponent(mo.getName());
+         if (comp != null)
+         {
+            RunState state = updateRunState(mo, comp);
+            log.debug("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
+            ManagedComponent comp = md.getComponent(mo.getName());
+            if (comp != null)
+            {
+               RunState state = updateRunState(runtimeMO, comp);
+               log.debug("Updated component: "+comp+" run state to: "+state);
+            }
+         }
+      }
+
+      // Update the MO registry
+      // TODO - does this make sense? In case of a MetaType.isCollection we could get different results then
+//      ManagedObject prevMO = moRegistry.put(key, mo);
+//      if( prevMO != null )
+//      {
+//         // This should only matter for ManagedObjects that have a ManagementObjectID
+//         log.debug("Duplicate mo for key: "+key+", prevMO: "+prevMO);
+//         return;
+//      }
+      // Check for unresolved refs
+      checkForReferences(key, mo);
+
+      // Map any existing ManagedComponent types
+      for(ManagedComponent comp : md.getComponents().values())
+      {
+         log.debug("Updating ManagementComponent: "+comp);
+         ComponentType type = comp.getType();
+         Set<ManagedComponent> typeComps = compByCompType.get(type);
+         if (typeComps == null)
+         {
+            typeComps = new HashSet<ManagedComponent>();
+            compByCompType.put(type, typeComps);
+         }
+         typeComps.add(comp);
+      }
+
+      // Create ManagedComponents for ManagedObjects annotated with ManagementComponent
+      ManagementComponent mc = (ManagementComponent) moAnns.get(ManagementComponent.class.getName());
+      if (mc != null && md.getComponent(mo.getName()) == null)
+      {
+         ComponentType type = new ComponentType(mc.type(), mc.subtype());
+         ManagedComponentImpl comp = new ManagedComponentImpl(type, md, mo);
+         md.addComponent(mo.getName(), comp);
+         log.debug("Processing ManagementComponent("+mo.getName()+"): "+comp);
+         Set<ManagedComponent> typeComps = compByCompType.get(type);
+         if (typeComps == null)
+         {
+            typeComps = new HashSet<ManagedComponent>();
+            compByCompType.put(type, typeComps);
+         }
+         typeComps.add(comp);
+         updateRunState(null, comp);
+      }
+
+      // Scan for @ManagementObjectRef
+      for(ManagedProperty prop : mo.getProperties().values())
+      {
+         log.debug("Checking property: "+prop);
+         // 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();
+               log.debug("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()
+               log.debug("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)
+               {
+                  log.debug("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);
+         }
+         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);
+            }
+         }
+         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);
+                  }
+               }
+            }
+         }
+      }
+   }
+
+   /**
+    * 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.debug("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) 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);
+      }
+   }
+   
+}

Deleted: trunk/profileservice/src/main/java/org/jboss/profileservice/management/views/AbstractProfileView.java
===================================================================
--- tags/JBoss_6_0_0_M1/profileservice/src/main/org/jboss/profileservice/management/views/AbstractProfileView.java	2009-12-10 15:49:13 UTC (rev 97697)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/management/views/AbstractProfileView.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -1,285 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, 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.management.views;
-
-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.management.AbstractRuntimeComponentDispatcher;
-import org.jboss.profileservice.management.ManagedOperationProxyFactory;
-import org.jboss.profileservice.spi.Profile;
-import org.jboss.profileservice.spi.ProfileKey;
-
-/**
- * A abstract profile view. 
- * 
- * @author Scott.Stark at jboss.org
- * @author adrian at jboss.org
- * @author ales.justin at jboss.org
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * 
- * @version $Revision$
- */
-public abstract class AbstractProfileView extends AbstractManagedDeploymentView
-{
-   
-   /** The logger. */
-   private static final Logger log = Logger.getLogger(AbstractProfileView.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 ManagedOperationProxyFactory 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 ContextStateMapper<RunState>(runStateMappings,
-            RunState.STARTING, RunState.STOPPED, RunState.FAILED, RunState.UNKNOWN);
-
-      Map<String, DeploymentState> deploymentMappings = new HashMap<String, DeploymentState>();
-      deploymentMappings.put("**ERROR**", DeploymentState.FAILED);
-      deploymentMappings.put("Not Installed", DeploymentState.STOPPED);
-      deploymentMappings.put("Installed", DeploymentState.STARTED);
-
-      deploymentStateMapper = new ContextStateMapper<DeploymentState>(deploymentMappings,
-            DeploymentState.STARTING, DeploymentState.STOPPING, DeploymentState.FAILED, DeploymentState.UNKNOWN);         
-   }
-   
-   public AbstractProfileView(ManagedOperationProxyFactory 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 abstract boolean hasBeenModified(Profile profile);
-   
-   public abstract ProfileKey getProfileKey();
-   
-   protected void processRootManagedDeployment(ManagedDeployment md, boolean trace) throws Exception
-   {
-      DeploymentState state = getDeploymentState(md);
-      processManagedDeployment(md, state, 0, trace);      
-   }
-
-   @Override
-   protected void mergeRuntimeMO(ManagedObject mo, ManagedObject runtimeMO)
-      throws Exception
-   {
-      Map<String, ManagedProperty> runtimeProps = runtimeMO.getProperties();
-      Set<ManagedOperation> runtimeOps = runtimeMO.getOperations();
-      // Get the runtime MO component name
-      Object componentName = runtimeMO.getComponentName();
-      log.debug("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)
-      {
-         log.debug("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
-               {
-                  AbstractRuntimeComponentDispatcher.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);
-         }
-         
-         log.debug("Properties after:"+props);
-      }
-      if (runtimeOps != null && runtimeOps.size() > 0)
-      {
-         log.debug("Ops before:"+ops);
-         runtimeOps = createOperationProxies(runtimeMO, runtimeOps);
-         ops.addAll(runtimeOps);
-         log.debug("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
-      return proxyFactory.createOperationProxies(ops, componentName);
-   }
-
-   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
-            AbstractRuntimeComponentDispatcher xdispatcher = (AbstractRuntimeComponentDispatcher) dispatcher;
-            state = xdispatcher.mapControllerState(name, mapper);            
-         }
-         catch(Exception e)
-         {
-            state = mapper.getErrorState();
-         }
-      }
-      return state;      
-   }
-
-}
-

Copied: trunk/profileservice/src/main/java/org/jboss/profileservice/management/views/AbstractProfileView.java (from rev 97697, tags/JBoss_6_0_0_M1/profileservice/src/main/org/jboss/profileservice/management/views/AbstractProfileView.java)
===================================================================
--- trunk/profileservice/src/main/java/org/jboss/profileservice/management/views/AbstractProfileView.java	                        (rev 0)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/management/views/AbstractProfileView.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -0,0 +1,285 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.management.views;
+
+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.management.AbstractRuntimeComponentDispatcher;
+import org.jboss.profileservice.management.ManagedOperationProxyFactory;
+import org.jboss.profileservice.spi.Profile;
+import org.jboss.profileservice.spi.ProfileKey;
+
+/**
+ * A abstract profile view. 
+ * 
+ * @author Scott.Stark at jboss.org
+ * @author adrian at jboss.org
+ * @author ales.justin at jboss.org
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * 
+ * @version $Revision$
+ */
+public abstract class AbstractProfileView extends AbstractManagedDeploymentView
+{
+   
+   /** The logger. */
+   private static final Logger log = Logger.getLogger(AbstractProfileView.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 ManagedOperationProxyFactory 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 ContextStateMapper<RunState>(runStateMappings,
+            RunState.STARTING, RunState.STOPPED, RunState.FAILED, RunState.UNKNOWN);
+
+      Map<String, DeploymentState> deploymentMappings = new HashMap<String, DeploymentState>();
+      deploymentMappings.put("**ERROR**", DeploymentState.FAILED);
+      deploymentMappings.put("Not Installed", DeploymentState.STOPPED);
+      deploymentMappings.put("Installed", DeploymentState.STARTED);
+
+      deploymentStateMapper = new ContextStateMapper<DeploymentState>(deploymentMappings,
+            DeploymentState.STARTING, DeploymentState.STOPPING, DeploymentState.FAILED, DeploymentState.UNKNOWN);         
+   }
+   
+   public AbstractProfileView(ManagedOperationProxyFactory 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 abstract boolean hasBeenModified(Profile profile);
+   
+   public abstract ProfileKey getProfileKey();
+   
+   protected void processRootManagedDeployment(ManagedDeployment md, boolean trace) throws Exception
+   {
+      DeploymentState state = getDeploymentState(md);
+      processManagedDeployment(md, state, 0, trace);      
+   }
+
+   @Override
+   protected void mergeRuntimeMO(ManagedObject mo, ManagedObject runtimeMO)
+      throws Exception
+   {
+      Map<String, ManagedProperty> runtimeProps = runtimeMO.getProperties();
+      Set<ManagedOperation> runtimeOps = runtimeMO.getOperations();
+      // Get the runtime MO component name
+      Object componentName = runtimeMO.getComponentName();
+      log.debug("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)
+      {
+         log.debug("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
+               {
+                  AbstractRuntimeComponentDispatcher.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);
+         }
+         
+         log.debug("Properties after:"+props);
+      }
+      if (runtimeOps != null && runtimeOps.size() > 0)
+      {
+         log.debug("Ops before:"+ops);
+         runtimeOps = createOperationProxies(runtimeMO, runtimeOps);
+         ops.addAll(runtimeOps);
+         log.debug("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
+      return proxyFactory.createOperationProxies(ops, componentName);
+   }
+
+   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
+            AbstractRuntimeComponentDispatcher xdispatcher = (AbstractRuntimeComponentDispatcher) dispatcher;
+            state = xdispatcher.mapControllerState(name, mapper);            
+         }
+         catch(Exception e)
+         {
+            state = mapper.getErrorState();
+         }
+      }
+      return state;      
+   }
+
+}
+

Deleted: trunk/profileservice/src/main/java/org/jboss/profileservice/management/views/BootstrapProfileView.java
===================================================================
--- tags/JBoss_6_0_0_M1/profileservice/src/main/org/jboss/profileservice/management/views/BootstrapProfileView.java	2009-12-10 15:49:13 UTC (rev 97697)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/management/views/BootstrapProfileView.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -1,86 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, 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.management.views;
-
-import java.util.Collection;
-
-import org.jboss.logging.Logger;
-import org.jboss.managed.api.DeploymentState;
-import org.jboss.managed.api.ManagedDeployment;
-import org.jboss.profileservice.management.ManagedOperationProxyFactory;
-import org.jboss.profileservice.spi.Profile;
-import org.jboss.profileservice.spi.ProfileKey;
-
-/**
- * The bootstrap deployment view.
- * 
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public class BootstrapProfileView extends AbstractProfileView
-{
-
-   /** The logger. */
-   private static final Logger log = Logger.getLogger(BootstrapProfileView.class);
-   
-   /** A fake profile key. */
-   private static final ProfileKey key = new ProfileKey(BootstrapProfileView.class.getName());
-   
-   public BootstrapProfileView(ManagedOperationProxyFactory proxyFactory, Collection<ManagedDeployment> deployments)
-   {
-      super(proxyFactory);
-      // Load the bootstrap deployments
-      load(deployments);
-   }
-   
-   @Override
-   public ProfileKey getProfileKey()
-   {
-      return key;
-   }
-   
-   @Override
-   public boolean hasBeenModified(Profile profile)
-   {
-      return false;
-   }
-
-   protected void load(Collection<ManagedDeployment> deployments)
-   {
-      if(deployments == null)
-         throw new IllegalArgumentException("null deployments.");
-      
-      for(ManagedDeployment deployment : deployments)
-      {
-         try
-         {
-            processManagedDeployment(deployment, DeploymentState.STARTED, 0, false);
-         }
-         catch(Exception e)
-         {
-            log.debug("Failed to process managed deployment " + deployment);
-         }
-      }
-   }
-   
-}
-

Copied: trunk/profileservice/src/main/java/org/jboss/profileservice/management/views/BootstrapProfileView.java (from rev 97697, tags/JBoss_6_0_0_M1/profileservice/src/main/org/jboss/profileservice/management/views/BootstrapProfileView.java)
===================================================================
--- trunk/profileservice/src/main/java/org/jboss/profileservice/management/views/BootstrapProfileView.java	                        (rev 0)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/management/views/BootstrapProfileView.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -0,0 +1,86 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.management.views;
+
+import java.util.Collection;
+
+import org.jboss.logging.Logger;
+import org.jboss.managed.api.DeploymentState;
+import org.jboss.managed.api.ManagedDeployment;
+import org.jboss.profileservice.management.ManagedOperationProxyFactory;
+import org.jboss.profileservice.spi.Profile;
+import org.jboss.profileservice.spi.ProfileKey;
+
+/**
+ * The bootstrap deployment view.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class BootstrapProfileView extends AbstractProfileView
+{
+
+   /** The logger. */
+   private static final Logger log = Logger.getLogger(BootstrapProfileView.class);
+   
+   /** A fake profile key. */
+   private static final ProfileKey key = new ProfileKey(BootstrapProfileView.class.getName());
+   
+   public BootstrapProfileView(ManagedOperationProxyFactory proxyFactory, Collection<ManagedDeployment> deployments)
+   {
+      super(proxyFactory);
+      // Load the bootstrap deployments
+      load(deployments);
+   }
+   
+   @Override
+   public ProfileKey getProfileKey()
+   {
+      return key;
+   }
+   
+   @Override
+   public boolean hasBeenModified(Profile profile)
+   {
+      return false;
+   }
+
+   protected void load(Collection<ManagedDeployment> deployments)
+   {
+      if(deployments == null)
+         throw new IllegalArgumentException("null deployments.");
+      
+      for(ManagedDeployment deployment : deployments)
+      {
+         try
+         {
+            processManagedDeployment(deployment, DeploymentState.STARTED, 0, false);
+         }
+         catch(Exception e)
+         {
+            log.debug("Failed to process managed deployment " + deployment);
+         }
+      }
+   }
+   
+}
+

Deleted: trunk/profileservice/src/main/java/org/jboss/profileservice/management/views/MBeanProfileView.java
===================================================================
--- tags/JBoss_6_0_0_M1/profileservice/src/main/org/jboss/profileservice/management/views/MBeanProfileView.java	2009-12-10 15:49:13 UTC (rev 97697)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/management/views/MBeanProfileView.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -1,175 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, 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.management.views;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.management.MBeanInfo;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-
-import org.jboss.annotation.factory.AnnotationCreator;
-import org.jboss.logging.Logger;
-import org.jboss.managed.api.DeploymentState;
-import org.jboss.managed.api.ManagedObject;
-import org.jboss.managed.api.annotation.ManagementComponent;
-import org.jboss.managed.api.annotation.ManagementObject;
-import org.jboss.managed.api.annotation.ViewUse;
-import org.jboss.managed.plugins.ManagedDeploymentImpl;
-import org.jboss.metadata.spi.MetaData;
-import org.jboss.profileservice.management.MBeanManagedObjectFactory;
-import org.jboss.profileservice.management.ManagedOperationProxyFactory;
-import org.jboss.profileservice.spi.ManagedMBeanDeploymentFactory;
-import org.jboss.profileservice.spi.Profile;
-import org.jboss.profileservice.spi.ProfileKey;
-import org.jboss.profileservice.spi.ManagedMBeanDeploymentFactory.MBeanComponent;
-import org.jboss.profileservice.spi.ManagedMBeanDeploymentFactory.MBeanDeployment;
-
-/**
- * @author Scott.Stark at jboss.org
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public class MBeanProfileView extends AbstractProfileView
-{
-
-   /** The logger. */
-   private static final Logger log = Logger.getLogger(MBeanProfileView.class);
-
-   /** A fake profile key. */
-   private static final ProfileKey key = new ProfileKey(MBeanProfileView.class.getName());
-
-   /** */
-   private HashMap<String, ManagedMBeanDeploymentFactory> mdfs =
-      new HashMap<String, ManagedMBeanDeploymentFactory>();
-   private MBeanServer mbeanServer;
-   private MBeanManagedObjectFactory mbeanMOFactory = new MBeanManagedObjectFactory();
-
-   public MBeanProfileView(ManagedOperationProxyFactory proxyFactory)
-   {
-      super(proxyFactory);
-   }
-
-   public MBeanServer getMbeanServer()
-   {
-      return mbeanServer;
-   }
-
-   public void setMbeanServer(MBeanServer mbeanServer)
-   {
-      this.mbeanServer = mbeanServer;
-   }
-
-   public void addManagedMBeanDeployments(ManagedMBeanDeploymentFactory factory)
-   {
-      log.info("addManagedDeployment, "+factory);
-      String name = factory.getFactoryName();
-      this.mdfs.put(name, factory);
-   }
-   public void removeManagedMBeanDeployments(ManagedMBeanDeploymentFactory factory)
-   {
-      log.info("removeManagedDeployment, "+factory);
-      String name = factory.getFactoryName();
-      this.mdfs.remove(name);
-   }
-
-   @Override
-   public ProfileKey getProfileKey()
-   {
-      return key;
-   }
-
-   protected void load()
-   {
-      boolean trace = log.isTraceEnabled();
-      // Process mbean components that need to be exposed as ManagedDeployment/ManagedComponent
-      for(ManagedMBeanDeploymentFactory mdf : mdfs.values())
-      {
-         log.debug("Processing deployments for factory: "+mdf.getFactoryName());
-         Collection<MBeanDeployment> deployments = mdf.getDeployments(mbeanServer);
-         for(MBeanDeployment md : deployments)
-         {
-            log.debug("Saw MBeanDeployment: "+md);
-            HashMap<String, ManagedObject> unitMOs = new HashMap<String, ManagedObject>();
-            Collection<MBeanComponent> components = md.getComponents();
-            if(components != null)
-            {
-               for(MBeanComponent comp : components)
-               {
-                  log.debug("Saw MBeanComponent: "+comp);
-                  try
-                  {
-                     ManagedObject mo = createManagedObject(comp.getName(), mdf.getDefaultViewUse(), mdf.getPropertyMetaMappings());
-                     // Add a ManagementComponent annotation
-                     String annotationExpr = "@org.jboss.managed.api.annotation.ManagementObject("
-                        + "name=\""+comp.getName()+"\","
-                        + "componentType=@org.jboss.managed.api.annotation.ManagementComponent(type=\""
-                        + comp.getType()+"\",subtype=\""+comp.getSubtype()+"\")"
-                        + ")";
-                     // System.err.println(annotationExpr);
-                     ManagementObject moAnn = (ManagementObject) AnnotationCreator.createAnnotation(
-                           annotationExpr, ManagementObject.class);
-                     // Bot the ManagementObject and ManagementComponent annotation need to be in the MO annotations
-                     mo.getAnnotations().put(ManagementObject.class.getName(), moAnn);
-                     ManagementComponent mcAnn = moAnn.componentType();
-                     mo.getAnnotations().put(ManagementComponent.class.getName(), mcAnn);
-                     unitMOs.put(comp.getName().getCanonicalName(), mo);
-                  }
-                  catch(Exception e)
-                  {
-                     log.warn("Failed to create ManagedObject for: "+comp, e);
-                  }
-               }
-            }
-            ManagedDeploymentImpl mdi = new ManagedDeploymentImpl(md.getName(), md.getName(), null, unitMOs);
-            try
-            {
-               processManagedDeployment(mdi, DeploymentState.STARTED, 0, trace);
-            }
-            catch(Exception e)
-            {
-               log.warn("Failed to process ManagedDeployment for: " + md.getName(), e);
-            }
-         }
-      }
-   }
-
-   private ManagedObject createManagedObject(ObjectName mbean, String defaultViewUse, Map<String, String> propertyMetaMappings) throws Exception
-   {
-      MBeanInfo info = mbeanServer.getMBeanInfo(mbean);
-      ClassLoader mbeanLoader = mbeanServer.getClassLoaderFor(mbean);
-      MetaData metaData = null;
-      ViewUse[] viewUse = defaultViewUse == null ? null : new ViewUse[] { ViewUse.valueOf(defaultViewUse) };
-      ManagedObject mo = mbeanMOFactory.getManagedObject(mbean, info, mbeanLoader, metaData, viewUse, propertyMetaMappings);
-      return mo;
-   }
-
-   @Override
-   public boolean hasBeenModified(Profile profile)
-   {
-      return false;
-   }
-
-}
-

Copied: trunk/profileservice/src/main/java/org/jboss/profileservice/management/views/MBeanProfileView.java (from rev 97697, tags/JBoss_6_0_0_M1/profileservice/src/main/org/jboss/profileservice/management/views/MBeanProfileView.java)
===================================================================
--- trunk/profileservice/src/main/java/org/jboss/profileservice/management/views/MBeanProfileView.java	                        (rev 0)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/management/views/MBeanProfileView.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -0,0 +1,175 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.management.views;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.management.MBeanInfo;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.jboss.annotation.factory.AnnotationCreator;
+import org.jboss.logging.Logger;
+import org.jboss.managed.api.DeploymentState;
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.api.annotation.ManagementComponent;
+import org.jboss.managed.api.annotation.ManagementObject;
+import org.jboss.managed.api.annotation.ViewUse;
+import org.jboss.managed.plugins.ManagedDeploymentImpl;
+import org.jboss.metadata.spi.MetaData;
+import org.jboss.profileservice.management.MBeanManagedObjectFactory;
+import org.jboss.profileservice.management.ManagedOperationProxyFactory;
+import org.jboss.profileservice.spi.ManagedMBeanDeploymentFactory;
+import org.jboss.profileservice.spi.Profile;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.ManagedMBeanDeploymentFactory.MBeanComponent;
+import org.jboss.profileservice.spi.ManagedMBeanDeploymentFactory.MBeanDeployment;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class MBeanProfileView extends AbstractProfileView
+{
+
+   /** The logger. */
+   private static final Logger log = Logger.getLogger(MBeanProfileView.class);
+
+   /** A fake profile key. */
+   private static final ProfileKey key = new ProfileKey(MBeanProfileView.class.getName());
+
+   /** */
+   private HashMap<String, ManagedMBeanDeploymentFactory> mdfs =
+      new HashMap<String, ManagedMBeanDeploymentFactory>();
+   private MBeanServer mbeanServer;
+   private MBeanManagedObjectFactory mbeanMOFactory = new MBeanManagedObjectFactory();
+
+   public MBeanProfileView(ManagedOperationProxyFactory proxyFactory)
+   {
+      super(proxyFactory);
+   }
+
+   public MBeanServer getMbeanServer()
+   {
+      return mbeanServer;
+   }
+
+   public void setMbeanServer(MBeanServer mbeanServer)
+   {
+      this.mbeanServer = mbeanServer;
+   }
+
+   public void addManagedMBeanDeployments(ManagedMBeanDeploymentFactory factory)
+   {
+      log.info("addManagedDeployment, "+factory);
+      String name = factory.getFactoryName();
+      this.mdfs.put(name, factory);
+   }
+   public void removeManagedMBeanDeployments(ManagedMBeanDeploymentFactory factory)
+   {
+      log.info("removeManagedDeployment, "+factory);
+      String name = factory.getFactoryName();
+      this.mdfs.remove(name);
+   }
+
+   @Override
+   public ProfileKey getProfileKey()
+   {
+      return key;
+   }
+
+   protected void load()
+   {
+      boolean trace = log.isTraceEnabled();
+      // Process mbean components that need to be exposed as ManagedDeployment/ManagedComponent
+      for(ManagedMBeanDeploymentFactory mdf : mdfs.values())
+      {
+         log.debug("Processing deployments for factory: "+mdf.getFactoryName());
+         Collection<MBeanDeployment> deployments = mdf.getDeployments(mbeanServer);
+         for(MBeanDeployment md : deployments)
+         {
+            log.debug("Saw MBeanDeployment: "+md);
+            HashMap<String, ManagedObject> unitMOs = new HashMap<String, ManagedObject>();
+            Collection<MBeanComponent> components = md.getComponents();
+            if(components != null)
+            {
+               for(MBeanComponent comp : components)
+               {
+                  log.debug("Saw MBeanComponent: "+comp);
+                  try
+                  {
+                     ManagedObject mo = createManagedObject(comp.getName(), mdf.getDefaultViewUse(), mdf.getPropertyMetaMappings());
+                     // Add a ManagementComponent annotation
+                     String annotationExpr = "@org.jboss.managed.api.annotation.ManagementObject("
+                        + "name=\""+comp.getName()+"\","
+                        + "componentType=@org.jboss.managed.api.annotation.ManagementComponent(type=\""
+                        + comp.getType()+"\",subtype=\""+comp.getSubtype()+"\")"
+                        + ")";
+                     // System.err.println(annotationExpr);
+                     ManagementObject moAnn = (ManagementObject) AnnotationCreator.createAnnotation(
+                           annotationExpr, ManagementObject.class);
+                     // Bot the ManagementObject and ManagementComponent annotation need to be in the MO annotations
+                     mo.getAnnotations().put(ManagementObject.class.getName(), moAnn);
+                     ManagementComponent mcAnn = moAnn.componentType();
+                     mo.getAnnotations().put(ManagementComponent.class.getName(), mcAnn);
+                     unitMOs.put(comp.getName().getCanonicalName(), mo);
+                  }
+                  catch(Exception e)
+                  {
+                     log.warn("Failed to create ManagedObject for: "+comp, e);
+                  }
+               }
+            }
+            ManagedDeploymentImpl mdi = new ManagedDeploymentImpl(md.getName(), md.getName(), null, unitMOs);
+            try
+            {
+               processManagedDeployment(mdi, DeploymentState.STARTED, 0, trace);
+            }
+            catch(Exception e)
+            {
+               log.warn("Failed to process ManagedDeployment for: " + md.getName(), e);
+            }
+         }
+      }
+   }
+
+   private ManagedObject createManagedObject(ObjectName mbean, String defaultViewUse, Map<String, String> propertyMetaMappings) throws Exception
+   {
+      MBeanInfo info = mbeanServer.getMBeanInfo(mbean);
+      ClassLoader mbeanLoader = mbeanServer.getClassLoaderFor(mbean);
+      MetaData metaData = null;
+      ViewUse[] viewUse = defaultViewUse == null ? null : new ViewUse[] { ViewUse.valueOf(defaultViewUse) };
+      ManagedObject mo = mbeanMOFactory.getManagedObject(mbean, info, mbeanLoader, metaData, viewUse, propertyMetaMappings);
+      return mo;
+   }
+
+   @Override
+   public boolean hasBeenModified(Profile profile)
+   {
+      return false;
+   }
+
+}
+

Deleted: trunk/profileservice/src/main/java/org/jboss/profileservice/management/views/PlatformMbeansView.java
===================================================================
--- tags/JBoss_6_0_0_M1/profileservice/src/main/org/jboss/profileservice/management/views/PlatformMbeansView.java	2009-12-10 15:49:13 UTC (rev 97697)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/management/views/PlatformMbeansView.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -1,101 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, 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.management.views;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.jboss.managed.api.DeploymentState;
-import org.jboss.managed.api.ManagedDeployment;
-import org.jboss.managed.api.ManagedObject;
-import org.jboss.managed.api.factory.ManagedObjectFactory;
-import org.jboss.managed.plugins.ManagedDeploymentImpl;
-import org.jboss.managed.plugins.jmx.ManagementFactoryUtils;
-import org.jboss.profileservice.management.ManagedOperationProxyFactory;
-import org.jboss.profileservice.spi.Profile;
-import org.jboss.profileservice.spi.ProfileKey;
-
-/**
- * The PlatformMBean management view.
- * 
- * @author Scott.Stark at jboss.org
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * 
- * @version $Revision$
- */
-public class PlatformMbeansView extends AbstractProfileView
-{
-
-   /** The managed object factory. */
-   private static final ManagedObjectFactory managedObjFactory = ManagedObjectFactory.getInstance();
-   
-   /** A fake profile key. */
-   private static final ProfileKey key = new ProfileKey(PlatformMbeansView.class.getName());
-   
-   
-   protected static ManagedDeployment getDeployment()
-   {
-      Map<String, ManagedObject> platformMBeanMOs = ManagementFactoryUtils.getPlatformMBeanMOs(managedObjFactory);
-      ManagedDeploymentImpl platformMBeans = new ManagedDeploymentImpl("JDK PlatformMBeans", "PlatformMBeans", null,
-            platformMBeanMOs);
-      List<ManagedObject> gcMbeans = ManagementFactoryUtils.getGarbageCollectorMXBeans(managedObjFactory);
-      Map<String, ManagedObject> gcMOs = new HashMap<String, ManagedObject>();
-      for (ManagedObject mo : gcMbeans)
-         gcMOs.put(mo.getName(), mo);
-      List<ManagedObject> mmMbeans = ManagementFactoryUtils.getMemoryManagerMXBeans(managedObjFactory);
-      Map<String, ManagedObject> mmMOs = new HashMap<String, ManagedObject>();
-      for (ManagedObject mo : mmMbeans)
-         mmMOs.put(mo.getName(), mo);
-      List<ManagedObject> mpoolMBeans = ManagementFactoryUtils.getMemoryPoolMXBeans(managedObjFactory);
-      Map<String, ManagedObject> mpoolMOs = new HashMap<String, ManagedObject>();
-      for (ManagedObject mo : mpoolMBeans)
-         mpoolMOs.put(mo.getName(), mo);
-      ManagedDeploymentImpl gcMD = new ManagedDeploymentImpl("GarbageCollectorMXBeans", "GarbageCollectorMXBeans",
-            null, gcMOs);
-      platformMBeans.getChildren().add(gcMD);
-      ManagedDeploymentImpl mmMD = new ManagedDeploymentImpl("MemoryManagerMXBeans", "MemoryManagerMXBeans", null, mmMOs);
-      platformMBeans.getChildren().add(mmMD);
-      ManagedDeploymentImpl mpoolMD = new ManagedDeploymentImpl("MemoryPoolMXBeans", "MemoryPoolMXBeans", null, mpoolMOs);
-      platformMBeans.getChildren().add(mpoolMD);
-      return platformMBeans;
-   }
-   
-   public PlatformMbeansView(ManagedOperationProxyFactory proxyFactory) throws Exception
-   {
-      super(proxyFactory);
-      processManagedDeployment(getDeployment(), DeploymentState.STARTED, 0, false);
-   }
-
-   @Override
-   public ProfileKey getProfileKey()
-   {
-      return key;
-   }
-   
-   @Override
-   public boolean hasBeenModified(Profile profile)
-   {
-      return false;
-   }
-}
-

Copied: trunk/profileservice/src/main/java/org/jboss/profileservice/management/views/PlatformMbeansView.java (from rev 97697, tags/JBoss_6_0_0_M1/profileservice/src/main/org/jboss/profileservice/management/views/PlatformMbeansView.java)
===================================================================
--- trunk/profileservice/src/main/java/org/jboss/profileservice/management/views/PlatformMbeansView.java	                        (rev 0)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/management/views/PlatformMbeansView.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -0,0 +1,101 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.management.views;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.managed.api.DeploymentState;
+import org.jboss.managed.api.ManagedDeployment;
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.api.factory.ManagedObjectFactory;
+import org.jboss.managed.plugins.ManagedDeploymentImpl;
+import org.jboss.managed.plugins.jmx.ManagementFactoryUtils;
+import org.jboss.profileservice.management.ManagedOperationProxyFactory;
+import org.jboss.profileservice.spi.Profile;
+import org.jboss.profileservice.spi.ProfileKey;
+
+/**
+ * The PlatformMBean management view.
+ * 
+ * @author Scott.Stark at jboss.org
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * 
+ * @version $Revision$
+ */
+public class PlatformMbeansView extends AbstractProfileView
+{
+
+   /** The managed object factory. */
+   private static final ManagedObjectFactory managedObjFactory = ManagedObjectFactory.getInstance();
+   
+   /** A fake profile key. */
+   private static final ProfileKey key = new ProfileKey(PlatformMbeansView.class.getName());
+   
+   
+   protected static ManagedDeployment getDeployment()
+   {
+      Map<String, ManagedObject> platformMBeanMOs = ManagementFactoryUtils.getPlatformMBeanMOs(managedObjFactory);
+      ManagedDeploymentImpl platformMBeans = new ManagedDeploymentImpl("JDK PlatformMBeans", "PlatformMBeans", null,
+            platformMBeanMOs);
+      List<ManagedObject> gcMbeans = ManagementFactoryUtils.getGarbageCollectorMXBeans(managedObjFactory);
+      Map<String, ManagedObject> gcMOs = new HashMap<String, ManagedObject>();
+      for (ManagedObject mo : gcMbeans)
+         gcMOs.put(mo.getName(), mo);
+      List<ManagedObject> mmMbeans = ManagementFactoryUtils.getMemoryManagerMXBeans(managedObjFactory);
+      Map<String, ManagedObject> mmMOs = new HashMap<String, ManagedObject>();
+      for (ManagedObject mo : mmMbeans)
+         mmMOs.put(mo.getName(), mo);
+      List<ManagedObject> mpoolMBeans = ManagementFactoryUtils.getMemoryPoolMXBeans(managedObjFactory);
+      Map<String, ManagedObject> mpoolMOs = new HashMap<String, ManagedObject>();
+      for (ManagedObject mo : mpoolMBeans)
+         mpoolMOs.put(mo.getName(), mo);
+      ManagedDeploymentImpl gcMD = new ManagedDeploymentImpl("GarbageCollectorMXBeans", "GarbageCollectorMXBeans",
+            null, gcMOs);
+      platformMBeans.getChildren().add(gcMD);
+      ManagedDeploymentImpl mmMD = new ManagedDeploymentImpl("MemoryManagerMXBeans", "MemoryManagerMXBeans", null, mmMOs);
+      platformMBeans.getChildren().add(mmMD);
+      ManagedDeploymentImpl mpoolMD = new ManagedDeploymentImpl("MemoryPoolMXBeans", "MemoryPoolMXBeans", null, mpoolMOs);
+      platformMBeans.getChildren().add(mpoolMD);
+      return platformMBeans;
+   }
+   
+   public PlatformMbeansView(ManagedOperationProxyFactory proxyFactory) throws Exception
+   {
+      super(proxyFactory);
+      processManagedDeployment(getDeployment(), DeploymentState.STARTED, 0, false);
+   }
+
+   @Override
+   public ProfileKey getProfileKey()
+   {
+      return key;
+   }
+   
+   @Override
+   public boolean hasBeenModified(Profile profile)
+   {
+      return false;
+   }
+}
+

Deleted: trunk/profileservice/src/main/java/org/jboss/profileservice/management/views/ProfileView.java
===================================================================
--- tags/JBoss_6_0_0_M1/profileservice/src/main/org/jboss/profileservice/management/views/ProfileView.java	2009-12-10 15:49:13 UTC (rev 97697)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/management/views/ProfileView.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -1,166 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, 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.management.views;
-
-import java.util.Collection;
-import java.util.HashSet;
-
-import org.jboss.deployers.client.spi.main.MainDeployer;
-import org.jboss.deployers.spi.DeploymentException;
-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.management.ManagedOperationProxyFactory;
-import org.jboss.profileservice.spi.Profile;
-import org.jboss.profileservice.spi.ProfileDeployment;
-import org.jboss.profileservice.spi.ProfileKey;
-import org.jboss.system.server.profileservice.repository.AbstractProfileDeployment;
-
-/**
- * The profile view.
- * 
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public class ProfileView extends AbstractProfileView
-{
-
-   /** The logger. */
-   private static final Logger log = Logger.getLogger(ProfileView.class);
-   
-   /** The main deployer. */
-   private final MainDeployer mainDeployer;
-   
-   /** The profile key. */
-   private final ProfileKey key;
-   
-   /** The last modified. */
-   private final long lastModified;
-   
-   public ProfileView(Profile profile, ManagedOperationProxyFactory proxyFactory, MainDeployer mainDeployer)
-   {
-      super(proxyFactory);
-      if(profile == null)
-         throw new IllegalArgumentException("null profile");
-      if(profile.getKey() == null)
-         throw new IllegalArgumentException("null profile key");
-      if(mainDeployer == null)
-         throw new IllegalArgumentException("null main deployer");
-      //
-      this.key = profile.getKey();
-      this.mainDeployer = mainDeployer;
-      this.lastModified = profile.getLastModified();
-      // Load the deployments
-      load(profile.getDeployments());
-   }
-   
-   public ProfileKey getProfileKey()
-   {
-      return this.key;
-   }
-   
-   protected void load(Collection<ProfileDeployment> deployments)
-   {
-      if(deployments == null)
-         throw new IllegalArgumentException("null deployments.");
-      
-      boolean trace = log.isTraceEnabled();
-      for(ProfileDeployment deployment : deployments)
-      {
-         try
-         {
-            try
-            {
-               ManagedDeployment md = mainDeployer.getManagedDeployment(deployment.getName());
-               processRootManagedDeployment(md, trace);
-               
-               // Cache the deployment types
-               if(md.getTypes() != null && md.getTypes().isEmpty() == false)
-                  ((AbstractProfileDeployment)deployment)
-                     .addTransientAttachment(KnownDeploymentTypes.class.getName(), md.getTypes());
-            }
-            catch(DeploymentException e)
-            {
-               // FIXME Assume a undeployed (stopped) deployment
-               ManagedDeployment md = createStoppedManagedDeployment(deployment);
-               processManagedDeployment(md, DeploymentState.STOPPED, 0, trace);
-            }
-         }
-         catch(Exception e)
-         {
-            log.debug("Failed to create ManagedDeployment for: " + deployment.getName(), e);
-         }
-      }
-   }
-   
-   @SuppressWarnings("unchecked")
-   protected ManagedDeployment createStoppedManagedDeployment(ProfileDeployment deployment)
-   {
-      String deploymentName = deployment.getName();
-      ManagedDeployment md = new ManagedDeploymentImpl(deploymentName,
-            deployment.getRoot().getName());
-      
-      // Try to get the cached deployment type 
-      Collection<String> deploymentTypes = ((AbstractProfileDeployment)deployment)
-         .getTransientAttachment(KnownDeploymentTypes.class.getName(), Collection.class);
-      
-      if(deploymentTypes != null && deploymentTypes.isEmpty() == false)
-      {
-         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);
-         }  
-      }
-      return md;
-   }
-   
-   @Override
-   protected void processManagedDeployment(ManagedDeployment md, DeploymentState state, int level, boolean trace)
-         throws Exception
-   {
-      super.processManagedDeployment(md, state, level, trace);
-      // Set the profile key
-      md.setAttachment(ProfileKey.class.getName(), getProfileKey());
-   }
-
-   @Override
-   public boolean hasBeenModified(Profile profile)
-   {
-      if(profile == null)
-         throw new IllegalArgumentException("null profile.");
-      
-      return this.lastModified < profile.getLastModified();
-   }
-   
-}
-

Copied: trunk/profileservice/src/main/java/org/jboss/profileservice/management/views/ProfileView.java (from rev 97697, tags/JBoss_6_0_0_M1/profileservice/src/main/org/jboss/profileservice/management/views/ProfileView.java)
===================================================================
--- trunk/profileservice/src/main/java/org/jboss/profileservice/management/views/ProfileView.java	                        (rev 0)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/management/views/ProfileView.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -0,0 +1,166 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.management.views;
+
+import java.util.Collection;
+import java.util.HashSet;
+
+import org.jboss.deployers.client.spi.main.MainDeployer;
+import org.jboss.deployers.spi.DeploymentException;
+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.management.ManagedOperationProxyFactory;
+import org.jboss.profileservice.spi.Profile;
+import org.jboss.profileservice.spi.ProfileDeployment;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.system.server.profileservice.repository.AbstractProfileDeployment;
+
+/**
+ * The profile view.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class ProfileView extends AbstractProfileView
+{
+
+   /** The logger. */
+   private static final Logger log = Logger.getLogger(ProfileView.class);
+   
+   /** The main deployer. */
+   private final MainDeployer mainDeployer;
+   
+   /** The profile key. */
+   private final ProfileKey key;
+   
+   /** The last modified. */
+   private final long lastModified;
+   
+   public ProfileView(Profile profile, ManagedOperationProxyFactory proxyFactory, MainDeployer mainDeployer)
+   {
+      super(proxyFactory);
+      if(profile == null)
+         throw new IllegalArgumentException("null profile");
+      if(profile.getKey() == null)
+         throw new IllegalArgumentException("null profile key");
+      if(mainDeployer == null)
+         throw new IllegalArgumentException("null main deployer");
+      //
+      this.key = profile.getKey();
+      this.mainDeployer = mainDeployer;
+      this.lastModified = profile.getLastModified();
+      // Load the deployments
+      load(profile.getDeployments());
+   }
+   
+   public ProfileKey getProfileKey()
+   {
+      return this.key;
+   }
+   
+   protected void load(Collection<ProfileDeployment> deployments)
+   {
+      if(deployments == null)
+         throw new IllegalArgumentException("null deployments.");
+      
+      boolean trace = log.isTraceEnabled();
+      for(ProfileDeployment deployment : deployments)
+      {
+         try
+         {
+            try
+            {
+               ManagedDeployment md = mainDeployer.getManagedDeployment(deployment.getName());
+               processRootManagedDeployment(md, trace);
+               
+               // Cache the deployment types
+               if(md.getTypes() != null && md.getTypes().isEmpty() == false)
+                  ((AbstractProfileDeployment)deployment)
+                     .addTransientAttachment(KnownDeploymentTypes.class.getName(), md.getTypes());
+            }
+            catch(DeploymentException e)
+            {
+               // FIXME Assume a undeployed (stopped) deployment
+               ManagedDeployment md = createStoppedManagedDeployment(deployment);
+               processManagedDeployment(md, DeploymentState.STOPPED, 0, trace);
+            }
+         }
+         catch(Exception e)
+         {
+            log.debug("Failed to create ManagedDeployment for: " + deployment.getName(), e);
+         }
+      }
+   }
+   
+   @SuppressWarnings("unchecked")
+   protected ManagedDeployment createStoppedManagedDeployment(ProfileDeployment deployment)
+   {
+      String deploymentName = deployment.getName();
+      ManagedDeployment md = new ManagedDeploymentImpl(deploymentName,
+            deployment.getRoot().getName());
+      
+      // Try to get the cached deployment type 
+      Collection<String> deploymentTypes = ((AbstractProfileDeployment)deployment)
+         .getTransientAttachment(KnownDeploymentTypes.class.getName(), Collection.class);
+      
+      if(deploymentTypes != null && deploymentTypes.isEmpty() == false)
+      {
+         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);
+         }  
+      }
+      return md;
+   }
+   
+   @Override
+   protected void processManagedDeployment(ManagedDeployment md, DeploymentState state, int level, boolean trace)
+         throws Exception
+   {
+      super.processManagedDeployment(md, state, level, trace);
+      // Set the profile key
+      md.setAttachment(ProfileKey.class.getName(), getProfileKey());
+   }
+
+   @Override
+   public boolean hasBeenModified(Profile profile)
+   {
+      if(profile == null)
+         throw new IllegalArgumentException("null profile.");
+      
+      return this.lastModified < profile.getLastModified();
+   }
+   
+}
+

Deleted: trunk/profileservice/src/main/java/org/jboss/profileservice/remoting/BasicInvocation.java
===================================================================
--- trunk/profileservice/src/main/java/org/jboss/profileservice/remoting/BasicInvocation.java	2009-12-10 16:45:13 UTC (rev 97698)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/remoting/BasicInvocation.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -1,47 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, 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.remoting;
-
-import org.jboss.aop.advice.Interceptor;
-import org.jboss.aop.joinpoint.Invocation;
-import org.jboss.aop.joinpoint.InvocationBase;
-
-/**
- * @author Scott.Stark at jboss.org
- * @version $Revision:$
- */
-public class BasicInvocation extends InvocationBase
-{
-
-   public Invocation copy()
-   {
-      // TODO Auto-generated method stub
-      return null;
-   }
-
-   public Invocation getWrapper(Interceptor[] newchain)
-   {
-      // TODO Auto-generated method stub
-      return null;
-   }
-
-}

Copied: trunk/profileservice/src/main/java/org/jboss/profileservice/remoting/BasicInvocation.java (from rev 97697, tags/JBoss_6_0_0_M1/profileservice/src/main/org/jboss/profileservice/remoting/BasicInvocation.java)
===================================================================
--- trunk/profileservice/src/main/java/org/jboss/profileservice/remoting/BasicInvocation.java	                        (rev 0)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/remoting/BasicInvocation.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.remoting;
+
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.aop.joinpoint.InvocationBase;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class BasicInvocation extends InvocationBase
+{
+
+   public Invocation copy()
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   public Invocation getWrapper(Interceptor[] newchain)
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+}

Deleted: trunk/profileservice/src/main/java/org/jboss/profileservice/remoting/InstanceInterceptor.java
===================================================================
--- trunk/profileservice/src/main/java/org/jboss/profileservice/remoting/InstanceInterceptor.java	2009-12-10 16:45:13 UTC (rev 97698)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/remoting/InstanceInterceptor.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -1,71 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, 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.remoting;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-import org.jboss.aop.advice.Interceptor;
-import org.jboss.aop.joinpoint.Invocation;
-import org.jboss.aop.joinpoint.MethodInvocation;
-
-/**
- * @author Scott.Stark at jboss.org
- * @version $Revision:$
- */
-public class InstanceInterceptor implements Interceptor
-{
-   private String name;
-   private Object target;
-
-   InstanceInterceptor(String name, Object target)
-   {
-      this.name = name;
-      this.target = target;
-   }
-   public String getName()
-   {
-      return name;
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.aop.advice.Interceptor#invoke(org.jboss.aop.joinpoint.Invocation)
-    */
-   public Object invoke(Invocation invocation) throws Throwable
-   {
-      MethodInvocation mi = (MethodInvocation) invocation;
-      Method m  = mi.getActualMethod();
-      Object[] args = mi.getArguments();
-      
-      Object value = null;
-      try
-      {
-         m.invoke(target, args);
-      }
-      catch(InvocationTargetException ite)
-      {
-         throw ite.getCause();
-      }
-      return value;
-   }
-
-}

Copied: trunk/profileservice/src/main/java/org/jboss/profileservice/remoting/InstanceInterceptor.java (from rev 97697, tags/JBoss_6_0_0_M1/profileservice/src/main/org/jboss/profileservice/remoting/InstanceInterceptor.java)
===================================================================
--- trunk/profileservice/src/main/java/org/jboss/profileservice/remoting/InstanceInterceptor.java	                        (rev 0)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/remoting/InstanceInterceptor.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.remoting;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.aop.joinpoint.MethodInvocation;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class InstanceInterceptor implements Interceptor
+{
+   private String name;
+   private Object target;
+
+   InstanceInterceptor(String name, Object target)
+   {
+      this.name = name;
+      this.target = target;
+   }
+   public String getName()
+   {
+      return name;
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.aop.advice.Interceptor#invoke(org.jboss.aop.joinpoint.Invocation)
+    */
+   public Object invoke(Invocation invocation) throws Throwable
+   {
+      MethodInvocation mi = (MethodInvocation) invocation;
+      Method m  = mi.getActualMethod();
+      Object[] args = mi.getArguments();
+      
+      Object value = null;
+      try
+      {
+         m.invoke(target, args);
+      }
+      catch(InvocationTargetException ite)
+      {
+         throw ite.getCause();
+      }
+      return value;
+   }
+
+}

Deleted: trunk/profileservice/src/main/java/org/jboss/profileservice/remoting/PojiMethodInvocation.java
===================================================================
--- trunk/profileservice/src/main/java/org/jboss/profileservice/remoting/PojiMethodInvocation.java	2009-12-10 16:45:13 UTC (rev 97698)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/remoting/PojiMethodInvocation.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -1,276 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, 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.remoting;
-
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Method;
-import java.util.Map;
-
-import org.jboss.aop.Advisor;
-import org.jboss.aop.advice.Interceptor;
-import org.jboss.aop.joinpoint.Invocation;
-import org.jboss.aop.joinpoint.MethodInvocation;
-import org.jboss.aop.metadata.MetaDataResolver;
-import org.jboss.aop.metadata.SimpleMetaData;
-
-
-/**
- * @author Scott.Stark at jboss.org
- * @version $Revision:$
- */
-public class PojiMethodInvocation extends MethodInvocation
-{
-   private MethodInvocation delegate;
-   private Method method;
-
-   public PojiMethodInvocation(MethodInvocation delegate, Method method)
-   {
-      super();
-      this.delegate = delegate;
-      this.method = method;
-   }
-
-   public void addResponseAttachment(Object key, Object val)
-   {
-      delegate.addResponseAttachment(key, val);
-   }
-
-   public Invocation copy()
-   {
-      return delegate.copy();
-   }
-
-   public boolean equals(Object obj)
-   {
-      return delegate.equals(obj);
-   }
-
-   public Method getActualMethod()
-   {
-      return method;
-   }
-
-   public Advisor getAdvisor()
-   {
-      return delegate.getAdvisor();
-   }
-
-   public Object[] getArguments()
-   {
-      return delegate.getArguments();
-   }
-
-   public int getCurrentInterceptor()
-   {
-      return delegate.getCurrentInterceptor();
-   }
-
-   public MetaDataResolver getInstanceResolver()
-   {
-      return delegate.getInstanceResolver();
-   }
-
-   public Interceptor[] getInterceptors()
-   {
-      return delegate.getInterceptors();
-   }
-
-   public SimpleMetaData getMetaData()
-   {
-      return delegate.getMetaData();
-   }
-
-   public Object getMetaData(Object group, Object attr)
-   {
-      return delegate.getMetaData(group, attr);
-   }
-
-   public Method getMethod()
-   {
-      return method;
-   }
-
-   public long getMethodHash()
-   {
-      return delegate.getMethodHash();
-   }
-
-   public Object getResponseAttachment(Object key)
-   {
-      return delegate.getResponseAttachment(key);
-   }
-
-   public Map<Object, Object> getResponseContextInfo()
-   {
-      return delegate.getResponseContextInfo();
-   }
-
-   public Object getTargetObject()
-   {
-      return delegate.getTargetObject();
-   }
-
-   public Invocation getWrapper(Interceptor[] newchain)
-   {
-      return delegate.getWrapper(newchain);
-   }
-
-   public int hashCode()
-   {
-      return delegate.hashCode();
-   }
-
-   public Object invokeNext() throws Throwable
-   {
-      interceptors = delegate.getInterceptors();
-      currentInterceptor = delegate.getCurrentInterceptor();
-      if (interceptors != null && currentInterceptor < interceptors.length)
-      {
-         try
-         {
-            return interceptors[currentInterceptor++].invoke(this);
-         }
-         finally
-         {
-            // so that interceptors like clustering can reinvoke down the chain
-            currentInterceptor--;
-         }
-      }
-
-      return invokeTarget();
-   }
-
-   public Object invokeNext(Interceptor[] newInterceptors) throws Throwable
-   {
-      // Save the old stack position
-      Interceptor[] oldInterceptors = interceptors;
-      int oldCurrentInterceptor = currentInterceptor;
-
-      // Start the new stack
-      interceptors = newInterceptors;
-      currentInterceptor = 0;
-
-      // Invoke the new stack
-      try
-      {
-         return invokeNext();
-      }
-      finally
-      {
-         // Restore the old stack
-         interceptors = oldInterceptors;
-         currentInterceptor = oldCurrentInterceptor;
-      }
-   }
-
-   public Object invokeTarget() throws Throwable
-   {
-      return null;
-   }
-
-   public void readExternal(ObjectInput in) throws IOException,
-         ClassNotFoundException
-   {
-      delegate.readExternal(in);
-   }
-
-   public Object resolveAnnotation(Class<? extends Annotation> annotation)
-   {
-      return delegate.resolveAnnotation(annotation);
-   }
-
-   public Object resolveAnnotation(Class<? extends Annotation>[] annotations)
-   {
-      return delegate.resolveAnnotation(annotations);
-   }
-
-   public Object resolveClassAnnotation(Class<? extends Annotation> annotation)
-   {
-      return delegate.resolveClassAnnotation(annotation);
-   }
-
-   public Object resolveClassMetaData(Object key, Object attr)
-   {
-      return delegate.resolveClassMetaData(key, attr);
-   }
-
-   public <T extends Annotation> T resolveTypedAnnotation(Class<T> annotation)
-   {
-      return delegate.resolveTypedAnnotation(annotation);
-   }
-
-   public <T extends Annotation> T resolveTypedAnnotation(Class<T>[] annotations)
-   {
-      return delegate.resolveTypedAnnotation(annotations);
-   }
-
-   public <T extends Annotation> T resolveTypedClassAnnotation(
-         Class<T> annotation)
-   {
-      return delegate.resolveTypedClassAnnotation(annotation);
-   }
-
-   public void setAdvisor(Advisor advisor)
-   {
-      delegate.setAdvisor(advisor);
-   }
-
-   public void setArguments(Object[] arguments)
-   {
-      delegate.setArguments(arguments);
-   }
-
-   public void setInstanceResolver(MetaDataResolver instanceResolver)
-   {
-      delegate.setInstanceResolver(instanceResolver);
-   }
-
-   public void setMetaData(SimpleMetaData data)
-   {
-      delegate.setMetaData(data);
-   }
-
-   public void setResponseContextInfo(Map<Object, Object> responseContextInfo)
-   {
-      delegate.setResponseContextInfo(responseContextInfo);
-   }
-
-   public void setTargetObject(Object targetObject)
-   {
-      delegate.setTargetObject(targetObject);
-   }
-
-   public String toString()
-   {
-      return delegate.toString();
-   }
-
-   public void writeExternal(ObjectOutput out) throws IOException
-   {
-      delegate.writeExternal(out);
-   }
-
-   
-}

Copied: trunk/profileservice/src/main/java/org/jboss/profileservice/remoting/PojiMethodInvocation.java (from rev 97697, tags/JBoss_6_0_0_M1/profileservice/src/main/org/jboss/profileservice/remoting/PojiMethodInvocation.java)
===================================================================
--- trunk/profileservice/src/main/java/org/jboss/profileservice/remoting/PojiMethodInvocation.java	                        (rev 0)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/remoting/PojiMethodInvocation.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -0,0 +1,276 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.remoting;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.util.Map;
+
+import org.jboss.aop.Advisor;
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.aop.joinpoint.MethodInvocation;
+import org.jboss.aop.metadata.MetaDataResolver;
+import org.jboss.aop.metadata.SimpleMetaData;
+
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class PojiMethodInvocation extends MethodInvocation
+{
+   private MethodInvocation delegate;
+   private Method method;
+
+   public PojiMethodInvocation(MethodInvocation delegate, Method method)
+   {
+      super();
+      this.delegate = delegate;
+      this.method = method;
+   }
+
+   public void addResponseAttachment(Object key, Object val)
+   {
+      delegate.addResponseAttachment(key, val);
+   }
+
+   public Invocation copy()
+   {
+      return delegate.copy();
+   }
+
+   public boolean equals(Object obj)
+   {
+      return delegate.equals(obj);
+   }
+
+   public Method getActualMethod()
+   {
+      return method;
+   }
+
+   public Advisor getAdvisor()
+   {
+      return delegate.getAdvisor();
+   }
+
+   public Object[] getArguments()
+   {
+      return delegate.getArguments();
+   }
+
+   public int getCurrentInterceptor()
+   {
+      return delegate.getCurrentInterceptor();
+   }
+
+   public MetaDataResolver getInstanceResolver()
+   {
+      return delegate.getInstanceResolver();
+   }
+
+   public Interceptor[] getInterceptors()
+   {
+      return delegate.getInterceptors();
+   }
+
+   public SimpleMetaData getMetaData()
+   {
+      return delegate.getMetaData();
+   }
+
+   public Object getMetaData(Object group, Object attr)
+   {
+      return delegate.getMetaData(group, attr);
+   }
+
+   public Method getMethod()
+   {
+      return method;
+   }
+
+   public long getMethodHash()
+   {
+      return delegate.getMethodHash();
+   }
+
+   public Object getResponseAttachment(Object key)
+   {
+      return delegate.getResponseAttachment(key);
+   }
+
+   public Map<Object, Object> getResponseContextInfo()
+   {
+      return delegate.getResponseContextInfo();
+   }
+
+   public Object getTargetObject()
+   {
+      return delegate.getTargetObject();
+   }
+
+   public Invocation getWrapper(Interceptor[] newchain)
+   {
+      return delegate.getWrapper(newchain);
+   }
+
+   public int hashCode()
+   {
+      return delegate.hashCode();
+   }
+
+   public Object invokeNext() throws Throwable
+   {
+      interceptors = delegate.getInterceptors();
+      currentInterceptor = delegate.getCurrentInterceptor();
+      if (interceptors != null && currentInterceptor < interceptors.length)
+      {
+         try
+         {
+            return interceptors[currentInterceptor++].invoke(this);
+         }
+         finally
+         {
+            // so that interceptors like clustering can reinvoke down the chain
+            currentInterceptor--;
+         }
+      }
+
+      return invokeTarget();
+   }
+
+   public Object invokeNext(Interceptor[] newInterceptors) throws Throwable
+   {
+      // Save the old stack position
+      Interceptor[] oldInterceptors = interceptors;
+      int oldCurrentInterceptor = currentInterceptor;
+
+      // Start the new stack
+      interceptors = newInterceptors;
+      currentInterceptor = 0;
+
+      // Invoke the new stack
+      try
+      {
+         return invokeNext();
+      }
+      finally
+      {
+         // Restore the old stack
+         interceptors = oldInterceptors;
+         currentInterceptor = oldCurrentInterceptor;
+      }
+   }
+
+   public Object invokeTarget() throws Throwable
+   {
+      return null;
+   }
+
+   public void readExternal(ObjectInput in) throws IOException,
+         ClassNotFoundException
+   {
+      delegate.readExternal(in);
+   }
+
+   public Object resolveAnnotation(Class<? extends Annotation> annotation)
+   {
+      return delegate.resolveAnnotation(annotation);
+   }
+
+   public Object resolveAnnotation(Class<? extends Annotation>[] annotations)
+   {
+      return delegate.resolveAnnotation(annotations);
+   }
+
+   public Object resolveClassAnnotation(Class<? extends Annotation> annotation)
+   {
+      return delegate.resolveClassAnnotation(annotation);
+   }
+
+   public Object resolveClassMetaData(Object key, Object attr)
+   {
+      return delegate.resolveClassMetaData(key, attr);
+   }
+
+   public <T extends Annotation> T resolveTypedAnnotation(Class<T> annotation)
+   {
+      return delegate.resolveTypedAnnotation(annotation);
+   }
+
+   public <T extends Annotation> T resolveTypedAnnotation(Class<T>[] annotations)
+   {
+      return delegate.resolveTypedAnnotation(annotations);
+   }
+
+   public <T extends Annotation> T resolveTypedClassAnnotation(
+         Class<T> annotation)
+   {
+      return delegate.resolveTypedClassAnnotation(annotation);
+   }
+
+   public void setAdvisor(Advisor advisor)
+   {
+      delegate.setAdvisor(advisor);
+   }
+
+   public void setArguments(Object[] arguments)
+   {
+      delegate.setArguments(arguments);
+   }
+
+   public void setInstanceResolver(MetaDataResolver instanceResolver)
+   {
+      delegate.setInstanceResolver(instanceResolver);
+   }
+
+   public void setMetaData(SimpleMetaData data)
+   {
+      delegate.setMetaData(data);
+   }
+
+   public void setResponseContextInfo(Map<Object, Object> responseContextInfo)
+   {
+      delegate.setResponseContextInfo(responseContextInfo);
+   }
+
+   public void setTargetObject(Object targetObject)
+   {
+      delegate.setTargetObject(targetObject);
+   }
+
+   public String toString()
+   {
+      return delegate.toString();
+   }
+
+   public void writeExternal(ObjectOutput out) throws IOException
+   {
+      delegate.writeExternal(out);
+   }
+
+   
+}

Deleted: trunk/profileservice/src/main/java/org/jboss/profileservice/remoting/SecurityContainer.java
===================================================================
--- trunk/profileservice/src/main/java/org/jboss/profileservice/remoting/SecurityContainer.java	2009-12-10 16:45:13 UTC (rev 97698)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/remoting/SecurityContainer.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -1,89 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, 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.remoting;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.List;
-
-import org.jboss.aop.advice.Interceptor;
-import org.jboss.aop.joinpoint.Invocation;
-import org.jboss.aop.joinpoint.MethodInvocation;
-
-/**
- * A poji proxy invocation handler that implements a simple security
- * container using aop interceptors.
- * 
- * @author Scott.Stark at jboss.org
- * @version $Revision:$
- */
-public class SecurityContainer implements InvocationHandler
-{
-   private static ThreadLocal<Invocation> activeInvocation
-      = new ThreadLocal<Invocation>();
-   private List<Interceptor> interceptors;
-   private Object target;
-
-   SecurityContainer(List<Interceptor> interceptors, Object target)
-   {
-      this.interceptors = interceptors;
-      this.target = target;
-   }
-
-   public static void setInvocation(Invocation inv)
-   {
-      activeInvocation.set(inv);
-   }
-
-   public Object invoke(Object proxy, Method method, Object[] args)
-         throws Throwable
-   {
-      // Get the invocation the handler set
-      Invocation inv = activeInvocation.get();
-      if(inv instanceof MethodInvocation)
-      {
-         // Need to set the target since this is not a true aop proxy
-         MethodInvocation mi = (MethodInvocation) inv;
-         mi.setTargetObject(target);
-         // Override the method to the poji proxy method to return the invocation method
-         inv = new PojiMethodInvocation(mi, method);
-      }
-
-      // run through the interceptors
-      for(Interceptor i : interceptors)
-      {
-         i.invoke(inv);
-      }
-
-      // Perform the invocation on the target
-      try
-      {
-         return method.invoke(target, args);
-      }
-      catch(InvocationTargetException ite)
-      {
-         throw ite.getTargetException();
-      }
-   }
-
-}

Copied: trunk/profileservice/src/main/java/org/jboss/profileservice/remoting/SecurityContainer.java (from rev 97697, tags/JBoss_6_0_0_M1/profileservice/src/main/org/jboss/profileservice/remoting/SecurityContainer.java)
===================================================================
--- trunk/profileservice/src/main/java/org/jboss/profileservice/remoting/SecurityContainer.java	                        (rev 0)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/remoting/SecurityContainer.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -0,0 +1,89 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.remoting;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.List;
+
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.aop.joinpoint.MethodInvocation;
+
+/**
+ * A poji proxy invocation handler that implements a simple security
+ * container using aop interceptors.
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class SecurityContainer implements InvocationHandler
+{
+   private static ThreadLocal<Invocation> activeInvocation
+      = new ThreadLocal<Invocation>();
+   private List<Interceptor> interceptors;
+   private Object target;
+
+   SecurityContainer(List<Interceptor> interceptors, Object target)
+   {
+      this.interceptors = interceptors;
+      this.target = target;
+   }
+
+   public static void setInvocation(Invocation inv)
+   {
+      activeInvocation.set(inv);
+   }
+
+   public Object invoke(Object proxy, Method method, Object[] args)
+         throws Throwable
+   {
+      // Get the invocation the handler set
+      Invocation inv = activeInvocation.get();
+      if(inv instanceof MethodInvocation)
+      {
+         // Need to set the target since this is not a true aop proxy
+         MethodInvocation mi = (MethodInvocation) inv;
+         mi.setTargetObject(target);
+         // Override the method to the poji proxy method to return the invocation method
+         inv = new PojiMethodInvocation(mi, method);
+      }
+
+      // run through the interceptors
+      for(Interceptor i : interceptors)
+      {
+         i.invoke(inv);
+      }
+
+      // Perform the invocation on the target
+      try
+      {
+         return method.invoke(target, args);
+      }
+      catch(InvocationTargetException ite)
+      {
+         throw ite.getTargetException();
+      }
+   }
+
+}

Copied: trunk/profileservice/src/main/java/org/jboss/profileservice/spi (from rev 97697, tags/JBoss_6_0_0_M1/profileservice/src/main/org/jboss/profileservice/spi)

Deleted: trunk/profileservice/src/main/java/org/jboss/profileservice/spi/MBeanDeploymentNameBuilder.java
===================================================================
--- tags/JBoss_6_0_0_M1/profileservice/src/main/org/jboss/profileservice/spi/MBeanDeploymentNameBuilder.java	2009-12-10 15:49:13 UTC (rev 97697)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/spi/MBeanDeploymentNameBuilder.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -1,43 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, 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.spi;
-
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-
-/**
- * An spi for mapping mbean names to a deployment name.
- * 
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public interface MBeanDeploymentNameBuilder
-{
-   /**
-    * Generate a deployment name from a given mbean name.
-    * 
-    * @param name - an mbean name of a ManagedObject to include in the deployment
-    * @param server - the MBeanServer under which name is registered
-    * @return - the name of the deployment the mbean should belong to
-    */
-   public String getName(ObjectName name, MBeanServer server);
-}

Copied: trunk/profileservice/src/main/java/org/jboss/profileservice/spi/MBeanDeploymentNameBuilder.java (from rev 97697, tags/JBoss_6_0_0_M1/profileservice/src/main/org/jboss/profileservice/spi/MBeanDeploymentNameBuilder.java)
===================================================================
--- trunk/profileservice/src/main/java/org/jboss/profileservice/spi/MBeanDeploymentNameBuilder.java	                        (rev 0)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/spi/MBeanDeploymentNameBuilder.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.spi;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+/**
+ * An spi for mapping mbean names to a deployment name.
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public interface MBeanDeploymentNameBuilder
+{
+   /**
+    * Generate a deployment name from a given mbean name.
+    * 
+    * @param name - an mbean name of a ManagedObject to include in the deployment
+    * @param server - the MBeanServer under which name is registered
+    * @return - the name of the deployment the mbean should belong to
+    */
+   public String getName(ObjectName name, MBeanServer server);
+}

Deleted: trunk/profileservice/src/main/java/org/jboss/profileservice/spi/ManagedMBeanDeploymentFactory.java
===================================================================
--- tags/JBoss_6_0_0_M1/profileservice/src/main/org/jboss/profileservice/spi/ManagedMBeanDeploymentFactory.java	2009-12-10 15:49:13 UTC (rev 97697)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/spi/ManagedMBeanDeploymentFactory.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -1,109 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, 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.spi;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Map;
-
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-
-import org.jboss.managed.api.ManagedDeployment;
-import org.jboss.managed.api.annotation.ViewUse;
-
-/**
- * @author Scott.Stark at jboss.org
- * @version $Revision:$
- */
-public interface ManagedMBeanDeploymentFactory
-{
-   public static class MBeanDeployment
-   {
-      String name;
-      Collection <MBeanComponent> components;
-      public MBeanDeployment(String name)
-      {
-         this(name, new ArrayList<MBeanComponent>());
-      }
-      public MBeanDeployment(String name, Collection <MBeanComponent> components)
-      {
-         this.name = name;
-         this.components = components;
-      }
-      public String getName()
-      {
-         return name;
-      }
-      public Collection<MBeanComponent> getComponents()
-      {
-         return components;
-      }
-      public void setComponents(Collection<MBeanComponent> components)
-      {
-         this.components = components;
-      }
-      public synchronized void addComponent(MBeanComponent comp)
-      {
-         if(components == null)
-            components = new ArrayList<MBeanComponent>();
-         components.add(comp);
-      }
-      public String toString()
-      {
-         return "MBeanDeployment("+name+"), "+components;
-      }
-   }
-   public static class MBeanComponent
-   {
-      String type;
-      String subtype;
-      ObjectName name;
-      public MBeanComponent(ObjectName name, String type, String subtype)
-      {
-         super();
-         this.type = type;
-         this.subtype = subtype;
-         this.name = name;
-      }
-      public ObjectName getName()
-      {
-         return name;
-      }
-      public String getType()
-      {
-         return type;
-      }
-      public String getSubtype()
-      {
-         return subtype;
-      }
-      public String toString()
-      {
-         return "MBeanComponent("+name+","+type+","+subtype+")";
-      }
-   }
-   public String getFactoryName();
-   public Collection<MBeanDeployment> getDeployments(MBeanServer mbeanServer);
-   public String getDefaultViewUse();
-   public Map<String, String> getPropertyMetaMappings();
-}

Copied: trunk/profileservice/src/main/java/org/jboss/profileservice/spi/ManagedMBeanDeploymentFactory.java (from rev 97697, tags/JBoss_6_0_0_M1/profileservice/src/main/org/jboss/profileservice/spi/ManagedMBeanDeploymentFactory.java)
===================================================================
--- trunk/profileservice/src/main/java/org/jboss/profileservice/spi/ManagedMBeanDeploymentFactory.java	                        (rev 0)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/spi/ManagedMBeanDeploymentFactory.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -0,0 +1,109 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.spi;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Map;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.jboss.managed.api.ManagedDeployment;
+import org.jboss.managed.api.annotation.ViewUse;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public interface ManagedMBeanDeploymentFactory
+{
+   public static class MBeanDeployment
+   {
+      String name;
+      Collection <MBeanComponent> components;
+      public MBeanDeployment(String name)
+      {
+         this(name, new ArrayList<MBeanComponent>());
+      }
+      public MBeanDeployment(String name, Collection <MBeanComponent> components)
+      {
+         this.name = name;
+         this.components = components;
+      }
+      public String getName()
+      {
+         return name;
+      }
+      public Collection<MBeanComponent> getComponents()
+      {
+         return components;
+      }
+      public void setComponents(Collection<MBeanComponent> components)
+      {
+         this.components = components;
+      }
+      public synchronized void addComponent(MBeanComponent comp)
+      {
+         if(components == null)
+            components = new ArrayList<MBeanComponent>();
+         components.add(comp);
+      }
+      public String toString()
+      {
+         return "MBeanDeployment("+name+"), "+components;
+      }
+   }
+   public static class MBeanComponent
+   {
+      String type;
+      String subtype;
+      ObjectName name;
+      public MBeanComponent(ObjectName name, String type, String subtype)
+      {
+         super();
+         this.type = type;
+         this.subtype = subtype;
+         this.name = name;
+      }
+      public ObjectName getName()
+      {
+         return name;
+      }
+      public String getType()
+      {
+         return type;
+      }
+      public String getSubtype()
+      {
+         return subtype;
+      }
+      public String toString()
+      {
+         return "MBeanComponent("+name+","+type+","+subtype+")";
+      }
+   }
+   public String getFactoryName();
+   public Collection<MBeanDeployment> getDeployments(MBeanServer mbeanServer);
+   public String getDefaultViewUse();
+   public Map<String, String> getPropertyMetaMappings();
+}

Copied: trunk/profileservice/src/main/java/org/jboss/profileservice/web (from rev 97697, tags/JBoss_6_0_0_M1/profileservice/src/main/org/jboss/profileservice/web)

Deleted: trunk/profileservice/src/main/java/org/jboss/profileservice/web/DebugServlet.java
===================================================================
--- tags/JBoss_6_0_0_M1/profileservice/src/main/org/jboss/profileservice/web/DebugServlet.java	2009-12-10 15:49:13 UTC (rev 97697)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/web/DebugServlet.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -1,162 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, 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.web;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.Arrays;
-import java.util.Map;
-import java.util.Set;
-
-import javax.annotation.Resource;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.jboss.deployers.spi.management.ManagementView;
-import org.jboss.managed.api.ManagedComponent;
-import org.jboss.managed.api.ManagedDeployment;
-
-/**
- * @author Scott.Stark at jboss.org
- * @version $Revision:$
- */
-public class DebugServlet extends HttpServlet
-{
-   private static final long serialVersionUID = 1;
-   @Resource(mappedName="java:ManagementView")
-   private ManagementView mgtView;
-   enum Operations {
-      listDeploymentTree,
-      listOperations
-   };
-
-   
-   @Override
-   public void init(ServletConfig config) throws ServletException
-   {
-      super.init(config);
-      if(mgtView == null)
-      {
-         try
-         {
-            InitialContext ctx = new InitialContext();
-            mgtView = (ManagementView) ctx.lookup("java:ManagementView");
-         }
-         catch (NamingException e)
-         {
-            throw new ServletException("Failed to lookup ManagementView", e);
-         }
-      }
-   }
-
-   @Override
-   protected void doGet(HttpServletRequest req, HttpServletResponse resp)
-         throws ServletException, IOException
-   {
-      if(mgtView == null)
-         throw new ServletException("The ManagementView has not been injected");
-      String op = req.getParameter("op");
-      if(op == null)
-         op = "listOperations";
-      Operations theOP = Enum.valueOf(Operations.class, "listDeploymentTree");
-      String opResult = "";
-      super.log("op="+op);
-      switch(theOP)
-      {
-         case listDeploymentTree:
-            opResult = listDeploymentTree();
-         break;
-         case listOperations:
-            opResult = listOperations();
-            break;
-         default:
-            throw new ServletException("Unknown op: "+op+", valid ops: "+Operations.values());
-      }
-      
-      PrintWriter pw = resp.getWriter();
-      pw.write("<h1>");
-      pw.write(theOP+" Results");
-      pw.write("</h1>");
-      pw.write("<pre>");
-      pw.write(opResult);
-      pw.write("</pre>");
-   }
-
-   protected String listDeploymentTree()
-      throws ServletException
-   {
-      StringBuilder tmp = new StringBuilder();
-      try
-      {
-         mgtView.load();
-         Set<String> names = mgtView.getDeploymentNames();
-         for(String name : names)
-         {
-            ManagedDeployment md = mgtView.getDeployment(name);
-            tmp.append("ManagedDeployment: ");
-            tmp.append(md.getName());
-            tmp.append('\n');
-            Map<String, ManagedComponent> mcs = md.getComponents();
-            if(mcs != null)
-            {
-               for(ManagedComponent mc : mcs.values())
-               {
-                  tmp.append("+++ ManagedComponent(name=");
-                  tmp.append(mc.getName());
-                  tmp.append(", type=(");
-                  tmp.append(mc.getType());
-                  tmp.append("), compName=");
-                  tmp.append(mc.getComponentName());
-                  tmp.append(", attachment: ");
-                  tmp.append(mc.getAttachmentName());
-                  tmp.append("\n++++++ properties: ");
-                  tmp.append(mc.getPropertyNames());
-                  tmp.append('\n');
-               }
-            }
-         }
-      }
-      catch(Exception e)
-      {
-         throw new ServletException("listDeploymentTree failure", e);
-      }
-      return tmp.toString();
-   }
-   protected String listOperations()
-   {
-      StringBuilder tmp = new StringBuilder();
-      tmp.append("Available operations: ");
-      tmp.append("<ul>");
-      for(Operations op : Operations.values())
-      {
-         tmp.append("<li>");
-         tmp.append(op.name());
-         tmp.append("</li>\n");
-      }
-      return tmp.toString();
-   }
-}

Copied: trunk/profileservice/src/main/java/org/jboss/profileservice/web/DebugServlet.java (from rev 97697, tags/JBoss_6_0_0_M1/profileservice/src/main/org/jboss/profileservice/web/DebugServlet.java)
===================================================================
--- trunk/profileservice/src/main/java/org/jboss/profileservice/web/DebugServlet.java	                        (rev 0)
+++ trunk/profileservice/src/main/java/org/jboss/profileservice/web/DebugServlet.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -0,0 +1,162 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.web;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Arrays;
+import java.util.Map;
+import java.util.Set;
+
+import javax.annotation.Resource;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.jboss.deployers.spi.management.ManagementView;
+import org.jboss.managed.api.ManagedComponent;
+import org.jboss.managed.api.ManagedDeployment;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class DebugServlet extends HttpServlet
+{
+   private static final long serialVersionUID = 1;
+   @Resource(mappedName="java:ManagementView")
+   private ManagementView mgtView;
+   enum Operations {
+      listDeploymentTree,
+      listOperations
+   };
+
+   
+   @Override
+   public void init(ServletConfig config) throws ServletException
+   {
+      super.init(config);
+      if(mgtView == null)
+      {
+         try
+         {
+            InitialContext ctx = new InitialContext();
+            mgtView = (ManagementView) ctx.lookup("java:ManagementView");
+         }
+         catch (NamingException e)
+         {
+            throw new ServletException("Failed to lookup ManagementView", e);
+         }
+      }
+   }
+
+   @Override
+   protected void doGet(HttpServletRequest req, HttpServletResponse resp)
+         throws ServletException, IOException
+   {
+      if(mgtView == null)
+         throw new ServletException("The ManagementView has not been injected");
+      String op = req.getParameter("op");
+      if(op == null)
+         op = "listOperations";
+      Operations theOP = Enum.valueOf(Operations.class, "listDeploymentTree");
+      String opResult = "";
+      super.log("op="+op);
+      switch(theOP)
+      {
+         case listDeploymentTree:
+            opResult = listDeploymentTree();
+         break;
+         case listOperations:
+            opResult = listOperations();
+            break;
+         default:
+            throw new ServletException("Unknown op: "+op+", valid ops: "+Operations.values());
+      }
+      
+      PrintWriter pw = resp.getWriter();
+      pw.write("<h1>");
+      pw.write(theOP+" Results");
+      pw.write("</h1>");
+      pw.write("<pre>");
+      pw.write(opResult);
+      pw.write("</pre>");
+   }
+
+   protected String listDeploymentTree()
+      throws ServletException
+   {
+      StringBuilder tmp = new StringBuilder();
+      try
+      {
+         mgtView.load();
+         Set<String> names = mgtView.getDeploymentNames();
+         for(String name : names)
+         {
+            ManagedDeployment md = mgtView.getDeployment(name);
+            tmp.append("ManagedDeployment: ");
+            tmp.append(md.getName());
+            tmp.append('\n');
+            Map<String, ManagedComponent> mcs = md.getComponents();
+            if(mcs != null)
+            {
+               for(ManagedComponent mc : mcs.values())
+               {
+                  tmp.append("+++ ManagedComponent(name=");
+                  tmp.append(mc.getName());
+                  tmp.append(", type=(");
+                  tmp.append(mc.getType());
+                  tmp.append("), compName=");
+                  tmp.append(mc.getComponentName());
+                  tmp.append(", attachment: ");
+                  tmp.append(mc.getAttachmentName());
+                  tmp.append("\n++++++ properties: ");
+                  tmp.append(mc.getPropertyNames());
+                  tmp.append('\n');
+               }
+            }
+         }
+      }
+      catch(Exception e)
+      {
+         throw new ServletException("listDeploymentTree failure", e);
+      }
+      return tmp.toString();
+   }
+   protected String listOperations()
+   {
+      StringBuilder tmp = new StringBuilder();
+      tmp.append("Available operations: ");
+      tmp.append("<ul>");
+      for(Operations op : Operations.values())
+      {
+         tmp.append("<li>");
+         tmp.append(op.name());
+         tmp.append("</li>\n");
+      }
+      return tmp.toString();
+   }
+}

Deleted: trunk/profileservice/src/test/java/org/jboss/test/ps/DomainMetaDataTest.java
===================================================================
--- trunk/profileservice/src/test/java/org/jboss/test/ps/DomainMetaDataTest.java	2009-12-10 16:45:13 UTC (rev 97698)
+++ trunk/profileservice/src/test/java/org/jboss/test/ps/DomainMetaDataTest.java	2009-12-10 17:35:48 UTC (rev 97699)
@@ -1,101 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.ps;
-
-import java.io.File;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import org.jboss.profileservice.domain.DomainMetaData;
-import org.jboss.profileservice.domain.resources.ResourcesMetaData;
-import org.jboss.profileservice.spi.metadata.ProfileMetaData;
-import org.jboss.system.server.profile.repository.metadata.CapabilityMetaData;
-import org.jboss.system.server.profile.repository.metadata.FilteredProfileMetaData;
-import org.jboss.system.server.profile.repository.metadata.ProfilesMetaData;
-import org.jboss.system.server.profile.repository.metadata.RequirementMetaData;
-import org.jboss.xb.binding.Unmarshaller;
-import org.jboss.xb.binding.UnmarshallerFactory;
-import org.jboss.xb.binding.sunday.unmarshalling.DefaultSchemaResolver;
-import org.jboss.xb.builder.JBossXBBuilder;
-import org.junit.Test;
-import org.junit.Assert;
-
-/**
- * @author Scott.Stark at jboss.org
- * @version $Revision:$
- */
-public class DomainMetaDataTest
-{
-   private static final DefaultSchemaResolver resolver = new DefaultSchemaResolver();
-   
-   static
-   {
-      // Add schema bindings
-      resolver.addClassBinding("urn:jboss:profileservice:profiles:1.0", ProfilesMetaData.class);
-      resolver.addClassBinding("urn:jboss:profileservice:domain:1.0", DomainMetaData.class);
-      resolver.addClassBinding("urn:jboss:profileservice:domain:resources:1.0", ResourcesMetaData.class);
-   }
-
-   @Test
-   public void testParsingDomain1() throws Exception
-   {
-      JBossXBBuilder.setUseUnorderedSequence(true);
-      File f = new File("src/test/resources/xml/domain1.xml");
-      Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
-      DomainMetaData domain = (DomainMetaData) unmarshaller.unmarshal(f.toURL().openStream(), resolver);
-      System.out.println("Unmarshalled domain: "+domain);
-      ProfilesMetaData profileMD = domain.getProfiles();
-      List<ProfileMetaData> profiles = profileMD.getProfiles();
-      Assert.assertEquals(3, profiles.size());
-      HashMap<String, ProfileMetaData> profileMap = new HashMap<String, ProfileMetaData>();
-      for(ProfileMetaData pmd : profiles)
-         profileMap.put(pmd.getName(), pmd);
-      // immutable
-      ProfileMetaData immutable = profileMap.get("immutable");
-      Assert.assertTrue(immutable instanceof FilteredProfileMetaData);
-      FilteredProfileMetaData immutableFP = (FilteredProfileMetaData) immutable;
-      Collection<RequirementMetaData> immutableReqs = immutableFP.getRequirements();
-      Assert.assertEquals(1, immutableReqs.size());
-      RequirementMetaData ejb3Req = immutableReqs.iterator().next();
-      Assert.assertEquals("ejb3", ejb3Req.getName());
-      Assert.assertEquals("ejb3", ejb3Req.getFilter());
-      // ejb3-profile
-      ProfileMetaData ejb3 = profileMap.get("ejb3-profile");
-      Assert.assertTrue(ejb3 instanceof FilteredProfileMetaData);
-      FilteredProfileMetaData ejb3FP = (FilteredProfileMetaData) ejb3;
-      Collection<CapabilityMetaData> ejb3Caps = ejb3FP.getCapabilities();
-      Assert.assertEquals(1, ejb3Caps.size());
-      CapabilityMetaData ejb3Cap = ejb3Caps.iterator().next();
-      Assert.assertEquals("ejb3", ejb3Cap.getName());
-      Map<String, String> ejb3Props = ejb3Cap.getProperties();
-      Assert.assertEquals("value1", ejb3Props.get("key1"));
-      Assert.assertEquals("value2", ejb3Props.get("key2"));
-      
-      // mutable
-      ProfileMetaData mutable = profileMap.get("mutable");
-      ResourcesMetaData resources = domain.getResources();
-   }
-   
-}




More information about the jboss-cvs-commits mailing list