[jboss-cvs] JBossAS SVN: r89429 - in trunk: connector/src/main/org/jboss/resource/deployers/management and 27 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue May 26 06:14:36 EDT 2009


Author: emuckenhuber
Date: 2009-05-26 06:14:36 -0400 (Tue, 26 May 2009)
New Revision: 89429

Added:
   trunk/connector/src/main/org/jboss/resource/deployers/management/MCFDGComponentMapper.java
   trunk/system-jmx/src/main/org/jboss/system/deployers/managed/ServiceDeploymentComponentMapper.java
   trunk/system/src/main/org/jboss/deployers/plugins/managed/KernelDeploymentComponentMapper.java
   trunk/system/src/main/org/jboss/system/server/profileservice/persistence/AbstractManagedObjectPersistence.java
   trunk/system/src/main/org/jboss/system/server/profileservice/persistence/AbstractManagedObjectRecreation.java
   trunk/system/src/main/org/jboss/system/server/profileservice/persistence/AbstractPersistenceFactory.java
   trunk/system/src/main/org/jboss/system/server/profileservice/persistence/AbstractValueRecreation.java
   trunk/system/src/main/org/jboss/system/server/profileservice/persistence/DefaultManagedObjectPersistencePlugin.java
   trunk/system/src/main/org/jboss/system/server/profileservice/persistence/DefaultPersistenceDelegate.java
   trunk/system/src/main/org/jboss/system/server/profileservice/persistence/DefaultRecreationDelegate.java
   trunk/system/src/main/org/jboss/system/server/profileservice/persistence/ManagedObjectRecreationHelper.java
   trunk/system/src/main/org/jboss/system/server/profileservice/persistence/PersistenceConstants.java
   trunk/system/src/main/org/jboss/system/server/profileservice/persistence/PersistenceFactory.java
   trunk/system/src/main/org/jboss/system/server/profileservice/persistence/component/
   trunk/system/src/main/org/jboss/system/server/profileservice/persistence/component/AbstractComponentMapper.java
   trunk/system/src/main/org/jboss/system/server/profileservice/persistence/component/ComponentMapper.java
   trunk/system/src/main/org/jboss/system/server/profileservice/persistence/component/ComponentMapperRegistry.java
   trunk/system/src/main/org/jboss/system/server/profileservice/persistence/deployer/PersistenceModificationChecker.java
   trunk/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistedComponent.java
   trunk/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistenceRoot.java
   trunk/system/src/tests/org/jboss/test/server/profileservice/component/
   trunk/system/src/tests/org/jboss/test/server/profileservice/component/persistence/
   trunk/system/src/tests/org/jboss/test/server/profileservice/component/persistence/support/
   trunk/system/src/tests/org/jboss/test/server/profileservice/component/persistence/support/CompositeMetaData.java
   trunk/system/src/tests/org/jboss/test/server/profileservice/component/persistence/support/TestComponent.java
   trunk/system/src/tests/org/jboss/test/server/profileservice/component/persistence/support/TestComponentMapper.java
   trunk/system/src/tests/org/jboss/test/server/profileservice/component/persistence/support/TestDeployment.java
   trunk/system/src/tests/org/jboss/test/server/profileservice/component/persistence/support/TestMgtComponentImpl.java
   trunk/system/src/tests/org/jboss/test/server/profileservice/component/persistence/test/
   trunk/system/src/tests/org/jboss/test/server/profileservice/component/persistence/test/AbstractComponentMapperTest.java
   trunk/system/src/tests/org/jboss/test/server/profileservice/component/persistence/test/ComponentMapperUnitTestCase.java
   trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/support/TestMgtComponentImpl.java
   trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/test/ServiceBindingMgrPersistenceFormatTestCase.java
Removed:
   trunk/system/src/main/org/jboss/system/server/profileservice/persistence/AbstractManagedObjectPersistencePlugin.java
   trunk/system/src/main/org/jboss/system/server/profileservice/persistence/DefaultManagedObjectPlugin.java
   trunk/system/src/main/org/jboss/system/server/profileservice/persistence/ManagedGenericOverrideHandler.java
   trunk/system/src/main/org/jboss/system/server/profileservice/persistence/ManagedObjectOverride.java
   trunk/system/src/main/org/jboss/system/server/profileservice/persistence/ManagedObjectPeristenceHandler.java
   trunk/system/src/main/org/jboss/system/server/profileservice/persistence/ManagedObjectRecreation.java
   trunk/system/src/main/org/jboss/system/server/profileservice/persistence/ManagedObjectRemoveHandler.java
Modified:
   trunk/component-matrix/pom.xml
   trunk/profileservice/.classpath
   trunk/profileservice/src/main/org/jboss/profileservice/management/AbstractRuntimeComponentDispatcher.java
   trunk/profileservice/src/main/org/jboss/profileservice/management/MBeanManagedObjectFactory.java
   trunk/profileservice/src/main/org/jboss/profileservice/management/ManagedPropertyDelegate.java
   trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java
   trunk/profileservice/src/main/org/jboss/profileservice/management/TempManagedComponentImpl.java
   trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentManagerImpl.java
   trunk/profileservice/src/main/org/jboss/profileservice/management/upload/SerializableDeploymentID.java
   trunk/profileservice/src/main/org/jboss/profileservice/management/upload/SerializableDeploymentStatus.java
   trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/AbstractDeployHandler.java
   trunk/server/src/etc/conf/all/bootstrap/profile.xml
   trunk/server/src/etc/conf/default/bootstrap/profile.xml
   trunk/system-jmx/src/main/org/jboss/system/deployers/managed/ServiceMetaDataICF.java
   trunk/system/.classpath
   trunk/system/src/main/org/jboss/deployers/plugins/managed/BeanMetaDataICF.java
   trunk/system/src/main/org/jboss/deployers/plugins/managed/DefaultManagedObjectCreator.java
   trunk/system/src/main/org/jboss/deployers/plugins/managed/KernelDeploymentManagedObjectCreator.java
   trunk/system/src/main/org/jboss/deployers/plugins/managed/TypedManagedDeploymentCreator.java
   trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/FilteredProfileMetaData.java
   trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/HotDeploymentProfileMetaData.java
   trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/ProfilesMetaData.java
   trunk/system/src/main/org/jboss/system/server/profileservice/attachments/AttachmentMetaData.java
   trunk/system/src/main/org/jboss/system/server/profileservice/attachments/AttachmentStore.java
   trunk/system/src/main/org/jboss/system/server/profileservice/attachments/LazyPredeterminedManagedObjects.java
   trunk/system/src/main/org/jboss/system/server/profileservice/attachments/RepositoryAttachmentMetaData.java
   trunk/system/src/main/org/jboss/system/server/profileservice/persistence/AbstractValuePersistence.java
   trunk/system/src/main/org/jboss/system/server/profileservice/persistence/AttachmentPropertyPopulator.java
   trunk/system/src/main/org/jboss/system/server/profileservice/persistence/DelegatingPersistencePlugin.java
   trunk/system/src/main/org/jboss/system/server/profileservice/persistence/ManagedObjectPersistencePlugin.java
   trunk/system/src/main/org/jboss/system/server/profileservice/persistence/deployer/ProfileServicePersistenceDeployer.java
   trunk/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistedCompositeValue.java
   trunk/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistedGenericValue.java
   trunk/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistedManagedObject.java
   trunk/system/src/main/org/jboss/system/server/profileservice/persistence/xml/package-info.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractAttachmentStore.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileDeployment.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractVFSProfileSource.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/BasicDeploymentRepository.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/JAXBAttachmentSerializer.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/MainDeployerAdapter.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/clustered/ClusteredDeploymentRepository.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/clustered/ImmutableClusteredDeploymentRepository.java
   trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/support/GenericSupportMetaData.java
   trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/support/TestMetaData.java
   trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/test/AbstractPersistenceFormatTest.java
   trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/test/ArrayValueUnitTestCase.java
   trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/test/BasicPersistenceFormatUnitTestCase.java
   trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/test/CollectionValueUnitTestCase.java
   trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/test/GenericValueUnitTestCase.java
   trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/test/MapCompositeUnitTestCase.java
   trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/test/ObjectNameUnitTestCase.java
   trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/test/TableValueUnitTestCase.java
   trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/test/TestNestedPeristenceFormatUnitTestCase.java
   trunk/system/src/tests/org/jboss/test/server/profileservice/support/MockAttachmentStore.java
   trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/support/SimpleAnnotatedBean.java
   trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/test/AbstractPersistenceFormatTest.java
   trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/test/JBossBeansPersistenceFormatTestCase.java
   trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/test/JBossServicePersistenceFormatTestCase.java
   trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/test/JMSDestinationPersistenceFormatTestCase.java
   trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/test/LocalDataSourcePersistenceFormatTestCase.java
Log:
update jboss-man to 2.1.0.SP1, jboss-integration to 5.1.0.GA, sync attachment persistence with 5_x and get the all config starting again.

Modified: trunk/component-matrix/pom.xml
===================================================================
--- trunk/component-matrix/pom.xml	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/component-matrix/pom.xml	2009-05-26 10:14:36 UTC (rev 89429)
@@ -73,12 +73,12 @@
     <version.org.jboss.ejb3.proxy.clustered.client>1.0.1</version.org.jboss.ejb3.proxy.clustered.client>
     <version.org.jboss.ejb3.security.client>1.0.0</version.org.jboss.ejb3.security.client>
     <version.org.jboss.ejb3>1.1.5</version.org.jboss.ejb3>
-    <version.org.jboss.integration>5.1.0.CR4</version.org.jboss.integration>
+    <version.org.jboss.integration>5.1.0.GA</version.org.jboss.integration>
     <version.org.jboss.jbossxb>2.0.0.GA</version.org.jboss.jbossxb>
     <version.org.jboss.jpa>1.0.0</version.org.jboss.jpa>
     <version.org.jboss.logbridge>1.0.0.CR3</version.org.jboss.logbridge>
     <version.org.jboss.logmanager>1.0.0.CR3</version.org.jboss.logmanager>
-    <version.org.jboss.man>2.1.0.CR8</version.org.jboss.man>
+    <version.org.jboss.man>2.1.0.SP1</version.org.jboss.man>
     <version.org.jboss.mdr>2.0.1.GA</version.org.jboss.mdr>
     <version.org.jboss.metadata>1.0.0.CR16</version.org.jboss.metadata>
     <version.org.jboss.microcontainer>2.0.4.GA</version.org.jboss.microcontainer>

Added: trunk/connector/src/main/org/jboss/resource/deployers/management/MCFDGComponentMapper.java
===================================================================
--- trunk/connector/src/main/org/jboss/resource/deployers/management/MCFDGComponentMapper.java	                        (rev 0)
+++ trunk/connector/src/main/org/jboss/resource/deployers/management/MCFDGComponentMapper.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -0,0 +1,105 @@
+/*
+ * 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.resource.deployers.management;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.resource.metadata.mcf.ManagedConnectionFactoryDeploymentGroup;
+import org.jboss.resource.metadata.mcf.ManagedConnectionFactoryDeploymentMetaData;
+import org.jboss.system.server.profileservice.persistence.PersistenceFactory;
+import org.jboss.system.server.profileservice.persistence.component.AbstractComponentMapper;
+import org.jboss.system.server.profileservice.persistence.xml.PersistedComponent;
+
+/**
+ * A ManagedConnectionFactoryDeploymentMetaData persistence ComponentMapper.
+ * This will handle the persistence operations for the MCFDeploymentMetaData.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class MCFDGComponentMapper extends AbstractComponentMapper
+{
+
+   public MCFDGComponentMapper(PersistenceFactory persistenceFactory)
+   {
+      super(persistenceFactory);
+   }
+
+   @Override
+   protected void setComponentName(PersistedComponent component, ManagedObject mo)
+   {
+       ManagedConnectionFactoryDeploymentMetaData metaData =
+          (ManagedConnectionFactoryDeploymentMetaData) mo.getAttachment();
+       // Set the current name;
+       component.setName(metaData.getJndiName());
+   }
+   
+   @Override
+   protected ManagedObject getComponent(Object attachment, PersistedComponent component, boolean create)
+   {
+      ManagedConnectionFactoryDeploymentGroup deployment = (ManagedConnectionFactoryDeploymentGroup) attachment;
+      ManagedConnectionFactoryDeploymentMetaData metaData = null;
+      if(deployment.getDeployments() != null && deployment.getDeployments().isEmpty() == false)
+      {
+         for(ManagedConnectionFactoryDeploymentMetaData md : deployment.getDeployments())
+         {
+            if(md.getJndiName().equals(component.getOriginalName()))
+            {
+               metaData = md;
+               break;
+            }
+         }
+      }
+      if(metaData == null && create)
+      {
+         // TODO create new attachment
+      }
+      if(metaData == null)
+         throw new IllegalStateException("could not find deployment " + component.getOriginalName());
+      return getMOF().initManagedObject(metaData, null);
+   }
+
+   @Override
+   protected void removeComponent(Object attachment, PersistedComponent component)
+   {
+      ManagedConnectionFactoryDeploymentGroup deployment = (ManagedConnectionFactoryDeploymentGroup) attachment;
+      if(deployment.getDeployments() != null && deployment.getDeployments().isEmpty() == false)
+      {
+         List<ManagedConnectionFactoryDeploymentMetaData> deployments = new ArrayList<ManagedConnectionFactoryDeploymentMetaData>();
+         for(ManagedConnectionFactoryDeploymentMetaData md : deployment.getDeployments())
+         {
+            if(md.getJndiName().equals(component.getOriginalName()) == false)
+               deployments.add(md);
+         }
+         deployment.setDeployments(deployments);
+      }
+   }
+
+   public String getType()
+   {
+      return ManagedConnectionFactoryDeploymentGroup.class.getName();
+   }
+
+}
+

Modified: trunk/profileservice/.classpath
===================================================================
--- trunk/profileservice/.classpath	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/profileservice/.classpath	2009-05-26 10:14:36 UTC (rev 89429)
@@ -1,129 +1,130 @@
+<?xml version="1.0" encoding="UTF-8"?>
 <classpath>
-  <classpathentry kind="src" path="src/main"/>
-  <classpathentry kind="src" path="src/test/resources" output="target/test-classes" excluding="**/*.java"/>
-  <classpathentry kind="output" path="target/classes"/>
-  <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
-  <classpathentry kind="var" path="M2_REPO/javax/activation/activation/1.1/activation-1.1.jar" sourcepath="M2_REPO/javax/activation/activation/1.1/activation-1.1-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/apache/ant/ant/1.7.1/ant-1.7.1.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/apache/ant/ant-junit/1.7.0/ant-junit-1.7.0.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/apache/ant/ant-launcher/1.7.1/ant-launcher-1.7.1.jar"/>
-  <classpathentry kind="var" path="M2_REPO/antlr/antlr/2.7.6-brew/antlr-2.7.6-brew.jar"/>
-  <classpathentry kind="var" path="M2_REPO/bcel/bcel/5.1/bcel-5.1.jar" sourcepath="M2_REPO/bcel/bcel/5.1/bcel-5.1-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/beanshell/bsh/1.3.0/bsh-1.3.0.jar"/>
-  <classpathentry kind="var" path="M2_REPO/commons-collections/commons-collections/3.1/commons-collections-3.1.jar" sourcepath="M2_REPO/commons-collections/commons-collections/3.1/commons-collections-3.1-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/commons-logging/commons-logging/1.1.0.jboss/commons-logging-1.1.0.jboss.jar"/>
-  <classpathentry kind="var" path="M2_REPO/oswego-concurrent/concurrent/1.3.4-jboss-update1/concurrent-1.3.4-jboss-update1.jar" sourcepath="M2_REPO/oswego-concurrent/concurrent/1.3.4-jboss-update1/concurrent-1.3.4-jboss-update1-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar" sourcepath="M2_REPO/dom4j/dom4j/1.6.1/dom4j-1.6.1-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/wutka-dtdparser/dtdparser121/1.2.1/dtdparser121-1.2.1.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/hibernate/ejb3-persistence/1.0.2.GA/ejb3-persistence-1.0.2.GA.jar" sourcepath="M2_REPO/org/hibernate/ejb3-persistence/1.0.2.GA/ejb3-persistence-1.0.2.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/gnu-getopt/getopt/1.0.12-brew/getopt-1.0.12-brew.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/hibernate/hibernate-annotations/3.4.0.GA/hibernate-annotations-3.4.0.GA.jar" sourcepath="M2_REPO/org/hibernate/hibernate-annotations/3.4.0.GA/hibernate-annotations-3.4.0.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/hibernate/hibernate-commons-annotations/3.1.0.GA/hibernate-commons-annotations-3.1.0.GA.jar" sourcepath="M2_REPO/org/hibernate/hibernate-commons-annotations/3.1.0.GA/hibernate-commons-annotations-3.1.0.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/hibernate/hibernate-core/3.3.1.GA/hibernate-core-3.3.1.GA.jar" sourcepath="M2_REPO/org/hibernate/hibernate-core/3.3.1.GA/hibernate-core-3.3.1.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/hibernate/hibernate-entitymanager/3.4.0.GA/hibernate-entitymanager-3.4.0.GA.jar" sourcepath="M2_REPO/org/hibernate/hibernate-entitymanager/3.4.0.GA/hibernate-entitymanager-3.4.0.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/javax/security/jacc/1.0/jacc-1.0.jar"/>
-  <classpathentry kind="var" path="M2_REPO/javassist/javassist/3.9.0.GA/javassist-3.9.0.GA.jar" sourcepath="M2_REPO/javassist/javassist/3.9.0.GA/javassist-3.9.0.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/sun-jaxb/jaxb-api/2.1.9/jaxb-api-2.1.9.jar" sourcepath="M2_REPO/sun-jaxb/jaxb-api/2.1.9/jaxb-api-2.1.9-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/sun-jaxws/jaxws-api/2.1.1/jaxws-api-2.1.1.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/aop/jboss-aop/2.1.0.CR2/jboss-aop-2.1.0.CR2.jar" sourcepath="M2_REPO/org/jboss/aop/jboss-aop/2.1.0.CR2/jboss-aop-2.1.0.CR2-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/aop/jboss-aop-asintegration-core/2.1.0.CR2/jboss-aop-asintegration-core-2.1.0.CR2.jar" sourcepath="M2_REPO/org/jboss/aop/jboss-aop-asintegration-core/2.1.0.CR2/jboss-aop-asintegration-core-2.1.0.CR2-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/aop/jboss-aop-asintegration-jmx/2.1.0.CR2/jboss-aop-asintegration-jmx-2.1.0.CR2.jar" sourcepath="M2_REPO/org/jboss/aop/jboss-aop-asintegration-jmx/2.1.0.CR2/jboss-aop-asintegration-jmx-2.1.0.CR2-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/aop/jboss-aop-asintegration-mc/2.1.0.CR2/jboss-aop-asintegration-mc-2.1.0.CR2.jar" sourcepath="M2_REPO/org/jboss/aop/jboss-aop-asintegration-mc/2.1.0.CR2/jboss-aop-asintegration-mc-2.1.0.CR2-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/aop/jboss-aop-aspects/2.1.0.CR2/jboss-aop-aspects-2.1.0.CR2.jar" sourcepath="M2_REPO/org/jboss/aop/jboss-aop-aspects/2.1.0.CR2/jboss-aop-aspects-2.1.0.CR2-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/microcontainer/jboss-aop-mc-int/2.0.4.GA/jboss-aop-mc-int-2.0.4.GA.jar" sourcepath="M2_REPO/org/jboss/microcontainer/jboss-aop-mc-int/2.0.4.GA/jboss-aop-mc-int-2.0.4.GA-sources.jar"/>
-  <classpathentry kind="src" path="/jboss-as-aspects"/>
-  <classpathentry kind="src" path="/jboss-as-system"/>
-  <classpathentry kind="src" path="/jboss-as-system-jmx"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/bootstrap/jboss-bootstrap/1.0.0-Beta-2/jboss-bootstrap-1.0.0-Beta-2.jar" sourcepath="M2_REPO/org/jboss/bootstrap/jboss-bootstrap/1.0.0-Beta-2/jboss-bootstrap-1.0.0-Beta-2-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/cl/jboss-classloader/2.0.3.GA/jboss-classloader-2.0.3.GA.jar" sourcepath="M2_REPO/org/jboss/cl/jboss-classloader/2.0.3.GA/jboss-classloader-2.0.3.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/cl/jboss-classloading/2.0.3.GA/jboss-classloading-2.0.3.GA.jar" sourcepath="M2_REPO/org/jboss/cl/jboss-classloading/2.0.3.GA/jboss-classloading-2.0.3.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/integration/jboss-classloading-spi/5.1.0.CR4/jboss-classloading-spi-5.1.0.CR4.jar" sourcepath="M2_REPO/org/jboss/integration/jboss-classloading-spi/5.1.0.CR4/jboss-classloading-spi-5.1.0.CR4-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/cl/jboss-classloading-vfs/2.0.3.GA/jboss-classloading-vfs-2.0.3.GA.jar" sourcepath="M2_REPO/org/jboss/cl/jboss-classloading-vfs/2.0.3.GA/jboss-classloading-vfs-2.0.3.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-common-core/2.2.12.GA/jboss-common-core-2.2.12.GA.jar" sourcepath="M2_REPO/org/jboss/jboss-common-core/2.2.12.GA/jboss-common-core-2.2.12.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/aspects/jboss-current-invocation-aspects/1.0.0.GA/jboss-current-invocation-aspects-1.0.0.GA.jar" sourcepath="M2_REPO/org/jboss/aspects/jboss-current-invocation-aspects/1.0.0.GA/jboss-current-invocation-aspects-1.0.0.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/microcontainer/jboss-dependency/2.0.4.GA/jboss-dependency-2.0.4.GA.jar" sourcepath="M2_REPO/org/jboss/microcontainer/jboss-dependency/2.0.4.GA/jboss-dependency-2.0.4.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/deployers/jboss-deployers-client/2.0.5.GA/jboss-deployers-client-2.0.5.GA.jar" sourcepath="M2_REPO/org/jboss/deployers/jboss-deployers-client/2.0.5.GA/jboss-deployers-client-2.0.5.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/deployers/jboss-deployers-client-spi/2.0.5.GA/jboss-deployers-client-spi-2.0.5.GA.jar" sourcepath="M2_REPO/org/jboss/deployers/jboss-deployers-client-spi/2.0.5.GA/jboss-deployers-client-spi-2.0.5.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/deployers/jboss-deployers-core/2.0.5.GA/jboss-deployers-core-2.0.5.GA.jar" sourcepath="M2_REPO/org/jboss/deployers/jboss-deployers-core/2.0.5.GA/jboss-deployers-core-2.0.5.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/deployers/jboss-deployers-core-spi/2.0.5.GA/jboss-deployers-core-spi-2.0.5.GA.jar" sourcepath="M2_REPO/org/jboss/deployers/jboss-deployers-core-spi/2.0.5.GA/jboss-deployers-core-spi-2.0.5.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/deployers/jboss-deployers-impl/2.0.5.GA/jboss-deployers-impl-2.0.5.GA.jar" sourcepath="M2_REPO/org/jboss/deployers/jboss-deployers-impl/2.0.5.GA/jboss-deployers-impl-2.0.5.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/deployers/jboss-deployers-spi/2.0.5.GA/jboss-deployers-spi-2.0.5.GA.jar" sourcepath="M2_REPO/org/jboss/deployers/jboss-deployers-spi/2.0.5.GA/jboss-deployers-spi-2.0.5.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/deployers/jboss-deployers-structure-spi/2.0.5.GA/jboss-deployers-structure-spi-2.0.5.GA.jar" sourcepath="M2_REPO/org/jboss/deployers/jboss-deployers-structure-spi/2.0.5.GA/jboss-deployers-structure-spi-2.0.5.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/deployers/jboss-deployers-vfs/2.0.5.GA/jboss-deployers-vfs-2.0.5.GA.jar" sourcepath="M2_REPO/org/jboss/deployers/jboss-deployers-vfs/2.0.5.GA/jboss-deployers-vfs-2.0.5.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/deployers/jboss-deployers-vfs-spi/2.0.5.GA/jboss-deployers-vfs-spi-2.0.5.GA.jar" sourcepath="M2_REPO/org/jboss/deployers/jboss-deployers-vfs-spi/2.0.5.GA/jboss-deployers-vfs-spi-2.0.5.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/javaee/jboss-ejb-api/3.0.0.GA/jboss-ejb-api-3.0.0.GA.jar" sourcepath="M2_REPO/org/jboss/javaee/jboss-ejb-api/3.0.0.GA/jboss-ejb-api-3.0.0.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/ejb3/jboss-ejb3-as-int/1.1.5/jboss-ejb3-as-int-1.1.5.jar" sourcepath="M2_REPO/org/jboss/ejb3/jboss-ejb3-as-int/1.1.5/jboss-ejb3-as-int-1.1.5-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/ejb3/jboss-ejb3-cache/1.0.0/jboss-ejb3-cache-1.0.0.jar" sourcepath="M2_REPO/org/jboss/ejb3/jboss-ejb3-cache/1.0.0/jboss-ejb3-cache-1.0.0-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/ejb3/jboss-ejb3-common/1.0.0/jboss-ejb3-common-1.0.0.jar" sourcepath="M2_REPO/org/jboss/ejb3/jboss-ejb3-common/1.0.0/jboss-ejb3-common-1.0.0-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/ejb3/jboss-ejb3-core/1.1.5/jboss-ejb3-core-1.1.5.jar" sourcepath="M2_REPO/org/jboss/ejb3/jboss-ejb3-core/1.1.5/jboss-ejb3-core-1.1.5-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/ejb3/jboss-ejb3-deployers/1.0.0/jboss-ejb3-deployers-1.0.0.jar" sourcepath="M2_REPO/org/jboss/ejb3/jboss-ejb3-deployers/1.0.0/jboss-ejb3-deployers-1.0.0-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/ejb3/jboss-ejb3-endpoint/0.1.0/jboss-ejb3-endpoint-0.1.0.jar" sourcepath="M2_REPO/org/jboss/ejb3/jboss-ejb3-endpoint/0.1.0/jboss-ejb3-endpoint-0.1.0-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/ejb3/jboss-ejb3-ext-api/1.0.0/jboss-ejb3-ext-api-1.0.0.jar" sourcepath="M2_REPO/org/jboss/ejb3/jboss-ejb3-ext-api/1.0.0/jboss-ejb3-ext-api-1.0.0-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/ejb3/jboss-ejb3-ext-api-impl/1.0.0/jboss-ejb3-ext-api-impl-1.0.0.jar" sourcepath="M2_REPO/org/jboss/ejb3/jboss-ejb3-ext-api-impl/1.0.0/jboss-ejb3-ext-api-impl-1.0.0-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/ejb3/jboss-ejb3-interceptors/1.0.2/jboss-ejb3-interceptors-1.0.2.jar" sourcepath="M2_REPO/org/jboss/ejb3/jboss-ejb3-interceptors/1.0.2/jboss-ejb3-interceptors-1.0.2-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/ejb3/jboss-ejb3-mc-int/1.0.1/jboss-ejb3-mc-int-1.0.1.jar" sourcepath="M2_REPO/org/jboss/ejb3/jboss-ejb3-mc-int/1.0.1/jboss-ejb3-mc-int-1.0.1-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/ejb3/jboss-ejb3-metadata/1.0.0/jboss-ejb3-metadata-1.0.0.jar" sourcepath="M2_REPO/org/jboss/ejb3/jboss-ejb3-metadata/1.0.0/jboss-ejb3-metadata-1.0.0-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/ejb3/jboss-ejb3-proxy-clustered/1.0.1/jboss-ejb3-proxy-clustered-1.0.1.jar" sourcepath="M2_REPO/org/jboss/ejb3/jboss-ejb3-proxy-clustered/1.0.1/jboss-ejb3-proxy-clustered-1.0.1-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/ejb3/jboss-ejb3-proxy-impl/1.0.2/jboss-ejb3-proxy-impl-1.0.2.jar" sourcepath="M2_REPO/org/jboss/ejb3/jboss-ejb3-proxy-impl/1.0.2/jboss-ejb3-proxy-impl-1.0.2-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/ejb3/jboss-ejb3-proxy-spi/1.0.0/jboss-ejb3-proxy-spi-1.0.0.jar" sourcepath="M2_REPO/org/jboss/ejb3/jboss-ejb3-proxy-spi/1.0.0/jboss-ejb3-proxy-spi-1.0.0-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/ejb3/jboss-ejb3-security/1.0.0/jboss-ejb3-security-1.0.0.jar" sourcepath="M2_REPO/org/jboss/ejb3/jboss-ejb3-security/1.0.0/jboss-ejb3-security-1.0.0-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/ejb3/jboss-ejb3-timerservice-spi/1.0.0/jboss-ejb3-timerservice-spi-1.0.0.jar" sourcepath="M2_REPO/org/jboss/ejb3/jboss-ejb3-timerservice-spi/1.0.0/jboss-ejb3-timerservice-spi-1.0.0-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/ejb3/jboss-ejb3-transactions/1.0.0/jboss-ejb3-transactions-1.0.0.jar" sourcepath="M2_REPO/org/jboss/ejb3/jboss-ejb3-transactions/1.0.0/jboss-ejb3-transactions-1.0.0-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/cluster/jboss-ha-client/1.1.1.GA/jboss-ha-client-1.1.1.GA.jar" sourcepath="M2_REPO/org/jboss/cluster/jboss-ha-client/1.1.1.GA/jboss-ha-client-1.1.1.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/cluster/jboss-ha-server-api/1.1.1.GA/jboss-ha-server-api-1.1.1.GA.jar" sourcepath="M2_REPO/org/jboss/cluster/jboss-ha-server-api/1.1.1.GA/jboss-ha-server-api-1.1.1.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/mx/jboss-j2se/6.0.0.Beta1/jboss-j2se-6.0.0.Beta1.jar" sourcepath="M2_REPO/org/jboss/mx/jboss-j2se/6.0.0.Beta1/jboss-j2se-6.0.0.Beta1-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/mx/jboss-j2se/6.0.0.Beta1/jboss-j2se-6.0.0.Beta1-tests.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/javaee/jboss-jacc-api/1.1.0.GA_SP1/jboss-jacc-api-1.1.0.GA_SP1.jar" sourcepath="M2_REPO/org/jboss/javaee/jboss-jacc-api/1.1.0.GA_SP1/jboss-jacc-api-1.1.0.GA_SP1-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/javaee/jboss-jaspi-api/1.0.0.GA/jboss-jaspi-api-1.0.0.GA.jar" sourcepath="M2_REPO/org/jboss/javaee/jboss-jaspi-api/1.0.0.GA/jboss-jaspi-api-1.0.0.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/javaee/jboss-jca-api/1.5.0.GA/jboss-jca-api-1.5.0.GA.jar" sourcepath="M2_REPO/org/jboss/javaee/jboss-jca-api/1.5.0.GA/jboss-jca-api-1.5.0.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/integration/jboss-jca-spi/5.0.3.GA/jboss-jca-spi-5.0.3.GA.jar" sourcepath="M2_REPO/org/jboss/integration/jboss-jca-spi/5.0.3.GA/jboss-jca-spi-5.0.3.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/javaee/jboss-jms-api/1.1.0.GA/jboss-jms-api-1.1.0.GA.jar" sourcepath="M2_REPO/org/jboss/javaee/jboss-jms-api/1.1.0.GA/jboss-jms-api-1.1.0.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/mx/jboss-jmx/6.0.0.Beta1/jboss-jmx-6.0.0.Beta1.jar" sourcepath="M2_REPO/org/jboss/mx/jboss-jmx/6.0.0.Beta1/jboss-jmx-6.0.0.Beta1-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/jpa/jboss-jpa-deployers/1.0.0/jboss-jpa-deployers-1.0.0.jar" sourcepath="M2_REPO/org/jboss/jpa/jboss-jpa-deployers/1.0.0/jboss-jpa-deployers-1.0.0-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/microcontainer/jboss-kernel/2.0.4.GA/jboss-kernel-2.0.4.GA.jar" sourcepath="M2_REPO/org/jboss/microcontainer/jboss-kernel/2.0.4.GA/jboss-kernel-2.0.4.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/logging/jboss-logging-log4j/2.0.6.GA/jboss-logging-log4j-2.0.6.GA.jar" sourcepath="M2_REPO/org/jboss/logging/jboss-logging-log4j/2.0.6.GA/jboss-logging-log4j-2.0.6.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/logging/jboss-logging-spi/2.0.5.GA/jboss-logging-spi-2.0.5.GA.jar" sourcepath="M2_REPO/org/jboss/logging/jboss-logging-spi/2.0.5.GA/jboss-logging-spi-2.0.5.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/man/jboss-managed/2.1.0.CR8/jboss-managed-2.1.0.CR8.jar" sourcepath="M2_REPO/org/jboss/man/jboss-managed/2.1.0.CR8/jboss-managed-2.1.0.CR8-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/mx/jboss-mbeans/6.0.0.Beta1/jboss-mbeans-6.0.0.Beta1.jar" sourcepath="M2_REPO/org/jboss/mx/jboss-mbeans/6.0.0.Beta1/jboss-mbeans-6.0.0.Beta1-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-mdr/2.0.1.GA/jboss-mdr-2.0.1.GA.jar" sourcepath="M2_REPO/org/jboss/jboss-mdr/2.0.1.GA/jboss-mdr-2.0.1.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/metadata/jboss-metadata/1.0.0.CR16/jboss-metadata-1.0.0.CR16.jar" sourcepath="M2_REPO/org/jboss/metadata/jboss-metadata/1.0.0.CR16/jboss-metadata-1.0.0.CR16-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/man/jboss-metatype/2.1.0.CR8/jboss-metatype-2.1.0.CR8.jar" sourcepath="M2_REPO/org/jboss/man/jboss-metatype/2.1.0.CR8/jboss-metatype-2.1.0.CR8-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/jboss/profiler/jvmti/jboss-profiler-jvmti/1.0.0.CR5/jboss-profiler-jvmti-1.0.0.CR5.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/integration/jboss-profileservice-spi/5.1.0.CR4/jboss-profileservice-spi-5.1.0.CR4.jar" sourcepath="M2_REPO/org/jboss/integration/jboss-profileservice-spi/5.1.0.CR4/jboss-profileservice-spi-5.1.0.CR4-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-reflect/2.0.2.GA/jboss-reflect-2.0.2.GA.jar" sourcepath="M2_REPO/org/jboss/jboss-reflect/2.0.2.GA/jboss-reflect-2.0.2.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/remoting/jboss-remoting/2.5.0.SP2/jboss-remoting-2.5.0.SP2.jar" sourcepath="M2_REPO/org/jboss/remoting/jboss-remoting/2.5.0.SP2/jboss-remoting-2.5.0.SP2-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/aspects/jboss-remoting-aspects/1.0.1.GA/jboss-remoting-aspects-1.0.1.GA.jar" sourcepath="M2_REPO/org/jboss/aspects/jboss-remoting-aspects/1.0.1.GA/jboss-remoting-aspects-1.0.1.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/aspects/jboss-security-aspects/1.0.0.GA/jboss-security-aspects-1.0.0.GA.jar" sourcepath="M2_REPO/org/jboss/aspects/jboss-security-aspects/1.0.0.GA/jboss-security-aspects-1.0.0.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/security/jboss-security-spi/2.1.0.20090318/jboss-security-spi-2.1.0.20090318.jar" sourcepath="M2_REPO/org/jboss/security/jboss-security-spi/2.1.0.20090318/jboss-security-spi-2.1.0.20090318-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/jboss/jboss-serialization/1.0.3.GA/jboss-serialization-1.0.3.GA.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/jbossas/jboss-server-manager/1.0.2.GA/jboss-server-manager-1.0.2.GA.jar" sourcepath="M2_REPO/org/jboss/jbossas/jboss-server-manager/1.0.2.GA/jboss-server-manager-1.0.2.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/test/jboss-test/1.1.4.GA/jboss-test-1.1.4.GA.jar" sourcepath="M2_REPO/org/jboss/test/jboss-test/1.1.4.GA/jboss-test-1.1.4.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/javaee/jboss-transaction-api/1.0.1.GA/jboss-transaction-api-1.0.1.GA.jar" sourcepath="M2_REPO/org/jboss/javaee/jboss-transaction-api/1.0.1.GA/jboss-transaction-api-1.0.1.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/aspects/jboss-transaction-aspects/1.0.0.GA/jboss-transaction-aspects-1.0.0.GA.jar" sourcepath="M2_REPO/org/jboss/aspects/jboss-transaction-aspects/1.0.0.GA/jboss-transaction-aspects-1.0.0.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/integration/jboss-transaction-spi/5.1.0.CR4/jboss-transaction-spi-5.1.0.CR4.jar" sourcepath="M2_REPO/org/jboss/integration/jboss-transaction-spi/5.1.0.CR4/jboss-transaction-spi-5.1.0.CR4-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-vfs/2.1.0.GA/jboss-vfs-2.1.0.GA.jar" sourcepath="M2_REPO/org/jboss/jboss-vfs/2.1.0.GA/jboss-vfs-2.1.0.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/cache/jbosscache-core/3.1.0.GA/jbosscache-core-3.1.0.GA.jar" sourcepath="M2_REPO/org/jboss/cache/jbosscache-core/3.1.0.GA/jbosscache-core-3.1.0.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/security/jbosssx/2.1.0.20090318/jbosssx-2.1.0.20090318.jar" sourcepath="M2_REPO/org/jboss/security/jbosssx/2.1.0.20090318/jbosssx-2.1.0.20090318-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/security/jbosssx-client/2.1.0.20090318/jbosssx-client-2.1.0.20090318.jar" sourcepath="M2_REPO/org/jboss/security/jbosssx-client/2.1.0.20090318/jbosssx-client-2.1.0.20090318-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/ws/native/jbossws-native-jaxrpc/3.1.2.GA/jbossws-native-jaxrpc-3.1.2.GA.jar" sourcepath="M2_REPO/org/jboss/ws/native/jbossws-native-jaxrpc/3.1.2.GA/jbossws-native-jaxrpc-3.1.2.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/ws/native/jbossws-native-saaj/3.1.2.GA/jbossws-native-saaj-3.1.2.GA.jar" sourcepath="M2_REPO/org/jboss/ws/native/jbossws-native-saaj/3.1.2.GA/jbossws-native-saaj-3.1.2.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/ws/jbossws-spi/1.1.2.GA/jbossws-spi-1.1.2.GA.jar" sourcepath="M2_REPO/org/jboss/ws/jbossws-spi/1.1.2.GA/jbossws-spi-1.1.2.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/jbossxb/2.0.0.GA/jbossxb-2.0.0.GA.jar" sourcepath="M2_REPO/org/jboss/jbossxb/2.0.0.GA/jbossxb-2.0.0.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/jgroups/jgroups/2.6.10.GA/jgroups-2.6.10.GA.jar" sourcepath="M2_REPO/jgroups/jgroups/2.6.10.GA/jgroups-2.6.10.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/naming/jnp-client/5.0.3.GA/jnp-client-5.0.3.GA.jar" sourcepath="M2_REPO/org/jboss/naming/jnp-client/5.0.3.GA/jnp-client-5.0.3.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/naming/jnpserver/5.0.3.GA/jnpserver-5.0.3.GA.jar" sourcepath="M2_REPO/org/jboss/naming/jnpserver/5.0.3.GA/jnpserver-5.0.3.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/aop/jrockit-pluggable-instrumentor/2.1.0.CR2/jrockit-pluggable-instrumentor-2.1.0.CR2.jar" sourcepath="M2_REPO/org/jboss/aop/jrockit-pluggable-instrumentor/2.1.0.CR2/jrockit-pluggable-instrumentor-2.1.0.CR2-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/sun-jaxws/jsr181-api/2.1.1/jsr181-api-2.1.1.jar"/>
-  <classpathentry kind="var" path="M2_REPO/javax/transaction/jta/1.1/jta-1.1.jar" sourcepath="M2_REPO/javax/transaction/jta/1.1/jta-1.1-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/junit/junit/3.8.2/junit-3.8.2.jar" sourcepath="M2_REPO/junit/junit/3.8.2/junit-3.8.2-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/log4j/log4j/1.2.14/log4j-1.2.14.jar" sourcepath="M2_REPO/log4j/log4j/1.2.14/log4j-1.2.14-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/aop/pluggable-instrumentor/2.1.0.CR2/pluggable-instrumentor-2.1.0.CR2.jar" sourcepath="M2_REPO/org/jboss/aop/pluggable-instrumentor/2.1.0.CR2/pluggable-instrumentor-2.1.0.CR2-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/qdox/qdox/1.6.1/qdox-1.6.1.jar" sourcepath="M2_REPO/qdox/qdox/1.6.1/qdox-1.6.1-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/quartz/quartz/1.5.2/quartz-1.5.2.jar" sourcepath="M2_REPO/quartz/quartz/1.5.2/quartz-1.5.2-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/jboss/web/servlet-api/2.1.2.GA/servlet-api-2.1.2.GA.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-api/1.5.0/slf4j-api-1.5.0.jar" sourcepath="M2_REPO/org/slf4j/slf4j-api/1.5.0/slf4j-api-1.5.0-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/stax/stax-api/1.0/stax-api-1.0.jar"/>
-  <classpathentry kind="var" path="M2_REPO/trove/trove/1.0.2/trove-1.0.2.jar"/>
-  <classpathentry kind="var" path="M2_REPO/apache-xerces/xercesImpl/2.9.1/xercesImpl-2.9.1.jar"/>
-  <classpathentry kind="var" path="M2_REPO/apache-xerces/xml-apis/2.9.1/xml-apis-2.9.1.jar"/>
-</classpath>
\ No newline at end of file
+	<classpathentry kind="src" path="src/main"/>
+	<classpathentry excluding="**/*.java" kind="src" output="target/test-classes" path="src/test/resources"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="var" path="M2_REPO/javax/activation/activation/1.1/activation-1.1.jar" sourcepath="M2_REPO/javax/activation/activation/1.1/activation-1.1-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/apache/ant/ant/1.7.1/ant-1.7.1.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/apache/ant/ant-junit/1.7.0/ant-junit-1.7.0.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/apache/ant/ant-launcher/1.7.1/ant-launcher-1.7.1.jar"/>
+	<classpathentry kind="var" path="M2_REPO/antlr/antlr/2.7.6-brew/antlr-2.7.6-brew.jar"/>
+	<classpathentry kind="var" path="M2_REPO/bcel/bcel/5.1/bcel-5.1.jar" sourcepath="M2_REPO/bcel/bcel/5.1/bcel-5.1-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/beanshell/bsh/1.3.0/bsh-1.3.0.jar"/>
+	<classpathentry kind="var" path="M2_REPO/commons-collections/commons-collections/3.1/commons-collections-3.1.jar" sourcepath="M2_REPO/commons-collections/commons-collections/3.1/commons-collections-3.1-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/commons-logging/commons-logging/1.1.0.jboss/commons-logging-1.1.0.jboss.jar"/>
+	<classpathentry kind="var" path="M2_REPO/oswego-concurrent/concurrent/1.3.4-jboss-update1/concurrent-1.3.4-jboss-update1.jar" sourcepath="M2_REPO/oswego-concurrent/concurrent/1.3.4-jboss-update1/concurrent-1.3.4-jboss-update1-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar" sourcepath="M2_REPO/dom4j/dom4j/1.6.1/dom4j-1.6.1-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/wutka-dtdparser/dtdparser121/1.2.1/dtdparser121-1.2.1.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/hibernate/ejb3-persistence/1.0.2.GA/ejb3-persistence-1.0.2.GA.jar" sourcepath="M2_REPO/org/hibernate/ejb3-persistence/1.0.2.GA/ejb3-persistence-1.0.2.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/gnu-getopt/getopt/1.0.12-brew/getopt-1.0.12-brew.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/hibernate/hibernate-annotations/3.4.0.GA/hibernate-annotations-3.4.0.GA.jar" sourcepath="M2_REPO/org/hibernate/hibernate-annotations/3.4.0.GA/hibernate-annotations-3.4.0.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/hibernate/hibernate-commons-annotations/3.1.0.GA/hibernate-commons-annotations-3.1.0.GA.jar" sourcepath="M2_REPO/org/hibernate/hibernate-commons-annotations/3.1.0.GA/hibernate-commons-annotations-3.1.0.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/hibernate/hibernate-core/3.3.1.GA/hibernate-core-3.3.1.GA.jar" sourcepath="M2_REPO/org/hibernate/hibernate-core/3.3.1.GA/hibernate-core-3.3.1.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/hibernate/hibernate-entitymanager/3.4.0.GA/hibernate-entitymanager-3.4.0.GA.jar" sourcepath="M2_REPO/org/hibernate/hibernate-entitymanager/3.4.0.GA/hibernate-entitymanager-3.4.0.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/javax/security/jacc/1.0/jacc-1.0.jar"/>
+	<classpathentry kind="var" path="M2_REPO/javassist/javassist/3.9.0.GA/javassist-3.9.0.GA.jar" sourcepath="M2_REPO/javassist/javassist/3.9.0.GA/javassist-3.9.0.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/sun-jaxb/jaxb-api/2.1.9/jaxb-api-2.1.9.jar" sourcepath="M2_REPO/sun-jaxb/jaxb-api/2.1.9/jaxb-api-2.1.9-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/sun-jaxws/jaxws-api/2.1.1/jaxws-api-2.1.1.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/aop/jboss-aop/2.1.0.CR2/jboss-aop-2.1.0.CR2.jar" sourcepath="M2_REPO/org/jboss/aop/jboss-aop/2.1.0.CR2/jboss-aop-2.1.0.CR2-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/aop/jboss-aop-asintegration-core/2.1.0.CR2/jboss-aop-asintegration-core-2.1.0.CR2.jar" sourcepath="M2_REPO/org/jboss/aop/jboss-aop-asintegration-core/2.1.0.CR2/jboss-aop-asintegration-core-2.1.0.CR2-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/aop/jboss-aop-asintegration-jmx/2.1.0.CR2/jboss-aop-asintegration-jmx-2.1.0.CR2.jar" sourcepath="M2_REPO/org/jboss/aop/jboss-aop-asintegration-jmx/2.1.0.CR2/jboss-aop-asintegration-jmx-2.1.0.CR2-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/aop/jboss-aop-asintegration-mc/2.1.0.CR2/jboss-aop-asintegration-mc-2.1.0.CR2.jar" sourcepath="M2_REPO/org/jboss/aop/jboss-aop-asintegration-mc/2.1.0.CR2/jboss-aop-asintegration-mc-2.1.0.CR2-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/aop/jboss-aop-aspects/2.1.0.CR2/jboss-aop-aspects-2.1.0.CR2.jar" sourcepath="M2_REPO/org/jboss/aop/jboss-aop-aspects/2.1.0.CR2/jboss-aop-aspects-2.1.0.CR2-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/microcontainer/jboss-aop-mc-int/2.0.4.GA/jboss-aop-mc-int-2.0.4.GA.jar" sourcepath="M2_REPO/org/jboss/microcontainer/jboss-aop-mc-int/2.0.4.GA/jboss-aop-mc-int-2.0.4.GA-sources.jar"/>
+	<classpathentry kind="src" path="/jboss-as-aspects"/>
+	<classpathentry kind="src" path="/jboss-as-system"/>
+	<classpathentry kind="src" path="/jboss-as-system-jmx"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/bootstrap/jboss-bootstrap/1.0.0-Beta-2/jboss-bootstrap-1.0.0-Beta-2.jar" sourcepath="M2_REPO/org/jboss/bootstrap/jboss-bootstrap/1.0.0-Beta-2/jboss-bootstrap-1.0.0-Beta-2-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/cl/jboss-classloader/2.0.3.GA/jboss-classloader-2.0.3.GA.jar" sourcepath="M2_REPO/org/jboss/cl/jboss-classloader/2.0.3.GA/jboss-classloader-2.0.3.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/cl/jboss-classloading/2.0.3.GA/jboss-classloading-2.0.3.GA.jar" sourcepath="M2_REPO/org/jboss/cl/jboss-classloading/2.0.3.GA/jboss-classloading-2.0.3.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/integration/jboss-classloading-spi/5.1.0.CR4/jboss-classloading-spi-5.1.0.CR4.jar" sourcepath="M2_REPO/org/jboss/integration/jboss-classloading-spi/5.1.0.CR4/jboss-classloading-spi-5.1.0.CR4-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/cl/jboss-classloading-vfs/2.0.3.GA/jboss-classloading-vfs-2.0.3.GA.jar" sourcepath="M2_REPO/org/jboss/cl/jboss-classloading-vfs/2.0.3.GA/jboss-classloading-vfs-2.0.3.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/jboss-common-core/2.2.12.GA/jboss-common-core-2.2.12.GA.jar" sourcepath="M2_REPO/org/jboss/jboss-common-core/2.2.12.GA/jboss-common-core-2.2.12.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/aspects/jboss-current-invocation-aspects/1.0.0.GA/jboss-current-invocation-aspects-1.0.0.GA.jar" sourcepath="M2_REPO/org/jboss/aspects/jboss-current-invocation-aspects/1.0.0.GA/jboss-current-invocation-aspects-1.0.0.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/microcontainer/jboss-dependency/2.0.4.GA/jboss-dependency-2.0.4.GA.jar" sourcepath="M2_REPO/org/jboss/microcontainer/jboss-dependency/2.0.4.GA/jboss-dependency-2.0.4.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/deployers/jboss-deployers-client/2.0.5.GA/jboss-deployers-client-2.0.5.GA.jar" sourcepath="M2_REPO/org/jboss/deployers/jboss-deployers-client/2.0.5.GA/jboss-deployers-client-2.0.5.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/deployers/jboss-deployers-client-spi/2.0.5.GA/jboss-deployers-client-spi-2.0.5.GA.jar" sourcepath="M2_REPO/org/jboss/deployers/jboss-deployers-client-spi/2.0.5.GA/jboss-deployers-client-spi-2.0.5.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/deployers/jboss-deployers-core/2.0.5.GA/jboss-deployers-core-2.0.5.GA.jar" sourcepath="M2_REPO/org/jboss/deployers/jboss-deployers-core/2.0.5.GA/jboss-deployers-core-2.0.5.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/deployers/jboss-deployers-core-spi/2.0.5.GA/jboss-deployers-core-spi-2.0.5.GA.jar" sourcepath="M2_REPO/org/jboss/deployers/jboss-deployers-core-spi/2.0.5.GA/jboss-deployers-core-spi-2.0.5.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/deployers/jboss-deployers-impl/2.0.5.GA/jboss-deployers-impl-2.0.5.GA.jar" sourcepath="M2_REPO/org/jboss/deployers/jboss-deployers-impl/2.0.5.GA/jboss-deployers-impl-2.0.5.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/deployers/jboss-deployers-spi/2.0.5.GA/jboss-deployers-spi-2.0.5.GA.jar" sourcepath="M2_REPO/org/jboss/deployers/jboss-deployers-spi/2.0.5.GA/jboss-deployers-spi-2.0.5.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/deployers/jboss-deployers-structure-spi/2.0.5.GA/jboss-deployers-structure-spi-2.0.5.GA.jar" sourcepath="M2_REPO/org/jboss/deployers/jboss-deployers-structure-spi/2.0.5.GA/jboss-deployers-structure-spi-2.0.5.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/deployers/jboss-deployers-vfs/2.0.5.GA/jboss-deployers-vfs-2.0.5.GA.jar" sourcepath="M2_REPO/org/jboss/deployers/jboss-deployers-vfs/2.0.5.GA/jboss-deployers-vfs-2.0.5.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/deployers/jboss-deployers-vfs-spi/2.0.5.GA/jboss-deployers-vfs-spi-2.0.5.GA.jar" sourcepath="M2_REPO/org/jboss/deployers/jboss-deployers-vfs-spi/2.0.5.GA/jboss-deployers-vfs-spi-2.0.5.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/javaee/jboss-ejb-api/3.0.0.GA/jboss-ejb-api-3.0.0.GA.jar" sourcepath="M2_REPO/org/jboss/javaee/jboss-ejb-api/3.0.0.GA/jboss-ejb-api-3.0.0.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/ejb3/jboss-ejb3-as-int/1.1.5/jboss-ejb3-as-int-1.1.5.jar" sourcepath="M2_REPO/org/jboss/ejb3/jboss-ejb3-as-int/1.1.5/jboss-ejb3-as-int-1.1.5-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/ejb3/jboss-ejb3-cache/1.0.0/jboss-ejb3-cache-1.0.0.jar" sourcepath="M2_REPO/org/jboss/ejb3/jboss-ejb3-cache/1.0.0/jboss-ejb3-cache-1.0.0-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/ejb3/jboss-ejb3-common/1.0.0/jboss-ejb3-common-1.0.0.jar" sourcepath="M2_REPO/org/jboss/ejb3/jboss-ejb3-common/1.0.0/jboss-ejb3-common-1.0.0-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/ejb3/jboss-ejb3-core/1.1.5/jboss-ejb3-core-1.1.5.jar" sourcepath="M2_REPO/org/jboss/ejb3/jboss-ejb3-core/1.1.5/jboss-ejb3-core-1.1.5-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/ejb3/jboss-ejb3-deployers/1.0.0/jboss-ejb3-deployers-1.0.0.jar" sourcepath="M2_REPO/org/jboss/ejb3/jboss-ejb3-deployers/1.0.0/jboss-ejb3-deployers-1.0.0-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/ejb3/jboss-ejb3-endpoint/0.1.0/jboss-ejb3-endpoint-0.1.0.jar" sourcepath="M2_REPO/org/jboss/ejb3/jboss-ejb3-endpoint/0.1.0/jboss-ejb3-endpoint-0.1.0-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/ejb3/jboss-ejb3-ext-api/1.0.0/jboss-ejb3-ext-api-1.0.0.jar" sourcepath="M2_REPO/org/jboss/ejb3/jboss-ejb3-ext-api/1.0.0/jboss-ejb3-ext-api-1.0.0-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/ejb3/jboss-ejb3-ext-api-impl/1.0.0/jboss-ejb3-ext-api-impl-1.0.0.jar" sourcepath="M2_REPO/org/jboss/ejb3/jboss-ejb3-ext-api-impl/1.0.0/jboss-ejb3-ext-api-impl-1.0.0-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/ejb3/jboss-ejb3-interceptors/1.0.2/jboss-ejb3-interceptors-1.0.2.jar" sourcepath="M2_REPO/org/jboss/ejb3/jboss-ejb3-interceptors/1.0.2/jboss-ejb3-interceptors-1.0.2-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/ejb3/jboss-ejb3-mc-int/1.0.1/jboss-ejb3-mc-int-1.0.1.jar" sourcepath="M2_REPO/org/jboss/ejb3/jboss-ejb3-mc-int/1.0.1/jboss-ejb3-mc-int-1.0.1-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/ejb3/jboss-ejb3-metadata/1.0.0/jboss-ejb3-metadata-1.0.0.jar" sourcepath="M2_REPO/org/jboss/ejb3/jboss-ejb3-metadata/1.0.0/jboss-ejb3-metadata-1.0.0-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/ejb3/jboss-ejb3-proxy-clustered/1.0.1/jboss-ejb3-proxy-clustered-1.0.1.jar" sourcepath="M2_REPO/org/jboss/ejb3/jboss-ejb3-proxy-clustered/1.0.1/jboss-ejb3-proxy-clustered-1.0.1-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/ejb3/jboss-ejb3-proxy-impl/1.0.2/jboss-ejb3-proxy-impl-1.0.2.jar" sourcepath="M2_REPO/org/jboss/ejb3/jboss-ejb3-proxy-impl/1.0.2/jboss-ejb3-proxy-impl-1.0.2-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/ejb3/jboss-ejb3-proxy-spi/1.0.0/jboss-ejb3-proxy-spi-1.0.0.jar" sourcepath="M2_REPO/org/jboss/ejb3/jboss-ejb3-proxy-spi/1.0.0/jboss-ejb3-proxy-spi-1.0.0-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/ejb3/jboss-ejb3-security/1.0.0/jboss-ejb3-security-1.0.0.jar" sourcepath="M2_REPO/org/jboss/ejb3/jboss-ejb3-security/1.0.0/jboss-ejb3-security-1.0.0-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/ejb3/jboss-ejb3-timerservice-spi/1.0.0/jboss-ejb3-timerservice-spi-1.0.0.jar" sourcepath="M2_REPO/org/jboss/ejb3/jboss-ejb3-timerservice-spi/1.0.0/jboss-ejb3-timerservice-spi-1.0.0-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/ejb3/jboss-ejb3-transactions/1.0.0/jboss-ejb3-transactions-1.0.0.jar" sourcepath="M2_REPO/org/jboss/ejb3/jboss-ejb3-transactions/1.0.0/jboss-ejb3-transactions-1.0.0-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/cluster/jboss-ha-client/1.1.1.GA/jboss-ha-client-1.1.1.GA.jar" sourcepath="M2_REPO/org/jboss/cluster/jboss-ha-client/1.1.1.GA/jboss-ha-client-1.1.1.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/cluster/jboss-ha-server-api/1.1.1.GA/jboss-ha-server-api-1.1.1.GA.jar" sourcepath="M2_REPO/org/jboss/cluster/jboss-ha-server-api/1.1.1.GA/jboss-ha-server-api-1.1.1.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/mx/jboss-j2se/6.0.0.Beta1/jboss-j2se-6.0.0.Beta1.jar" sourcepath="M2_REPO/org/jboss/mx/jboss-j2se/6.0.0.Beta1/jboss-j2se-6.0.0.Beta1-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/mx/jboss-j2se/6.0.0.Beta1/jboss-j2se-6.0.0.Beta1-tests.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/javaee/jboss-jacc-api/1.1.0.GA_SP1/jboss-jacc-api-1.1.0.GA_SP1.jar" sourcepath="M2_REPO/org/jboss/javaee/jboss-jacc-api/1.1.0.GA_SP1/jboss-jacc-api-1.1.0.GA_SP1-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/javaee/jboss-jaspi-api/1.0.0.GA/jboss-jaspi-api-1.0.0.GA.jar" sourcepath="M2_REPO/org/jboss/javaee/jboss-jaspi-api/1.0.0.GA/jboss-jaspi-api-1.0.0.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/javaee/jboss-jca-api/1.5.0.GA/jboss-jca-api-1.5.0.GA.jar" sourcepath="M2_REPO/org/jboss/javaee/jboss-jca-api/1.5.0.GA/jboss-jca-api-1.5.0.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/integration/jboss-jca-spi/5.0.3.GA/jboss-jca-spi-5.0.3.GA.jar" sourcepath="M2_REPO/org/jboss/integration/jboss-jca-spi/5.0.3.GA/jboss-jca-spi-5.0.3.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/javaee/jboss-jms-api/1.1.0.GA/jboss-jms-api-1.1.0.GA.jar" sourcepath="M2_REPO/org/jboss/javaee/jboss-jms-api/1.1.0.GA/jboss-jms-api-1.1.0.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/mx/jboss-jmx/6.0.0.Beta1/jboss-jmx-6.0.0.Beta1.jar" sourcepath="M2_REPO/org/jboss/mx/jboss-jmx/6.0.0.Beta1/jboss-jmx-6.0.0.Beta1-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/jpa/jboss-jpa-deployers/1.0.0/jboss-jpa-deployers-1.0.0.jar" sourcepath="M2_REPO/org/jboss/jpa/jboss-jpa-deployers/1.0.0/jboss-jpa-deployers-1.0.0-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/microcontainer/jboss-kernel/2.0.4.GA/jboss-kernel-2.0.4.GA.jar" sourcepath="M2_REPO/org/jboss/microcontainer/jboss-kernel/2.0.4.GA/jboss-kernel-2.0.4.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/logging/jboss-logging-log4j/2.0.6.GA/jboss-logging-log4j-2.0.6.GA.jar" sourcepath="M2_REPO/org/jboss/logging/jboss-logging-log4j/2.0.6.GA/jboss-logging-log4j-2.0.6.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/logging/jboss-logging-spi/2.0.5.GA/jboss-logging-spi-2.0.5.GA.jar" sourcepath="M2_REPO/org/jboss/logging/jboss-logging-spi/2.0.5.GA/jboss-logging-spi-2.0.5.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/man/jboss-managed/2.1.0.GA/jboss-managed-2.1.0.GA.jar" sourcepath="/M2_REPO/org/jboss/man/jboss-managed/2.1.0.CR8/jboss-managed-2.1.0.CR8-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/mx/jboss-mbeans/6.0.0.Beta1/jboss-mbeans-6.0.0.Beta1.jar" sourcepath="M2_REPO/org/jboss/mx/jboss-mbeans/6.0.0.Beta1/jboss-mbeans-6.0.0.Beta1-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/jboss-mdr/2.0.1.GA/jboss-mdr-2.0.1.GA.jar" sourcepath="M2_REPO/org/jboss/jboss-mdr/2.0.1.GA/jboss-mdr-2.0.1.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/metadata/jboss-metadata/1.0.0.CR16/jboss-metadata-1.0.0.CR16.jar" sourcepath="M2_REPO/org/jboss/metadata/jboss-metadata/1.0.0.CR16/jboss-metadata-1.0.0.CR16-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/man/jboss-metatype/2.1.0.GA/jboss-metatype-2.1.0.GA.jar" sourcepath="/M2_REPO/org/jboss/man/jboss-metatype/2.1.0.GA/jboss-metatype-2.1.0.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/jboss/profiler/jvmti/jboss-profiler-jvmti/1.0.0.CR5/jboss-profiler-jvmti-1.0.0.CR5.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/integration/jboss-profileservice-spi/5.1.0.GA/jboss-profileservice-spi-5.1.0.GA.jar" sourcepath="/M2_REPO/org/jboss/integration/jboss-profileservice-spi/5.1.0.CR4/jboss-profileservice-spi-5.1.0.CR4-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/jboss-reflect/2.0.2.GA/jboss-reflect-2.0.2.GA.jar" sourcepath="M2_REPO/org/jboss/jboss-reflect/2.0.2.GA/jboss-reflect-2.0.2.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/remoting/jboss-remoting/2.5.0.SP2/jboss-remoting-2.5.0.SP2.jar" sourcepath="M2_REPO/org/jboss/remoting/jboss-remoting/2.5.0.SP2/jboss-remoting-2.5.0.SP2-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/aspects/jboss-remoting-aspects/1.0.1.GA/jboss-remoting-aspects-1.0.1.GA.jar" sourcepath="M2_REPO/org/jboss/aspects/jboss-remoting-aspects/1.0.1.GA/jboss-remoting-aspects-1.0.1.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/aspects/jboss-security-aspects/1.0.0.GA/jboss-security-aspects-1.0.0.GA.jar" sourcepath="M2_REPO/org/jboss/aspects/jboss-security-aspects/1.0.0.GA/jboss-security-aspects-1.0.0.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/security/jboss-security-spi/2.1.0.20090318/jboss-security-spi-2.1.0.20090318.jar" sourcepath="M2_REPO/org/jboss/security/jboss-security-spi/2.1.0.20090318/jboss-security-spi-2.1.0.20090318-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/jboss/jboss-serialization/1.0.3.GA/jboss-serialization-1.0.3.GA.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/jbossas/jboss-server-manager/1.0.2.GA/jboss-server-manager-1.0.2.GA.jar" sourcepath="M2_REPO/org/jboss/jbossas/jboss-server-manager/1.0.2.GA/jboss-server-manager-1.0.2.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/test/jboss-test/1.1.4.GA/jboss-test-1.1.4.GA.jar" sourcepath="M2_REPO/org/jboss/test/jboss-test/1.1.4.GA/jboss-test-1.1.4.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/javaee/jboss-transaction-api/1.0.1.GA/jboss-transaction-api-1.0.1.GA.jar" sourcepath="M2_REPO/org/jboss/javaee/jboss-transaction-api/1.0.1.GA/jboss-transaction-api-1.0.1.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/aspects/jboss-transaction-aspects/1.0.0.GA/jboss-transaction-aspects-1.0.0.GA.jar" sourcepath="M2_REPO/org/jboss/aspects/jboss-transaction-aspects/1.0.0.GA/jboss-transaction-aspects-1.0.0.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/integration/jboss-transaction-spi/5.1.0.GA/jboss-transaction-spi-5.1.0.GA.jar" sourcepath="/M2_REPO/org/jboss/integration/jboss-transaction-spi/5.1.0.CR4/jboss-transaction-spi-5.1.0.CR4-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/jboss-vfs/2.1.0.GA/jboss-vfs-2.1.0.GA.jar" sourcepath="M2_REPO/org/jboss/jboss-vfs/2.1.0.GA/jboss-vfs-2.1.0.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/cache/jbosscache-core/3.1.0.GA/jbosscache-core-3.1.0.GA.jar" sourcepath="M2_REPO/org/jboss/cache/jbosscache-core/3.1.0.GA/jbosscache-core-3.1.0.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/security/jbosssx/2.1.0.20090318/jbosssx-2.1.0.20090318.jar" sourcepath="M2_REPO/org/jboss/security/jbosssx/2.1.0.20090318/jbosssx-2.1.0.20090318-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/security/jbosssx-client/2.1.0.20090318/jbosssx-client-2.1.0.20090318.jar" sourcepath="M2_REPO/org/jboss/security/jbosssx-client/2.1.0.20090318/jbosssx-client-2.1.0.20090318-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/ws/native/jbossws-native-jaxrpc/3.1.2.GA/jbossws-native-jaxrpc-3.1.2.GA.jar" sourcepath="M2_REPO/org/jboss/ws/native/jbossws-native-jaxrpc/3.1.2.GA/jbossws-native-jaxrpc-3.1.2.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/ws/native/jbossws-native-saaj/3.1.2.GA/jbossws-native-saaj-3.1.2.GA.jar" sourcepath="M2_REPO/org/jboss/ws/native/jbossws-native-saaj/3.1.2.GA/jbossws-native-saaj-3.1.2.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/ws/jbossws-spi/1.1.2.GA/jbossws-spi-1.1.2.GA.jar" sourcepath="M2_REPO/org/jboss/ws/jbossws-spi/1.1.2.GA/jbossws-spi-1.1.2.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/jbossxb/2.0.0.GA/jbossxb-2.0.0.GA.jar" sourcepath="M2_REPO/org/jboss/jbossxb/2.0.0.GA/jbossxb-2.0.0.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/jgroups/jgroups/2.6.10.GA/jgroups-2.6.10.GA.jar" sourcepath="M2_REPO/jgroups/jgroups/2.6.10.GA/jgroups-2.6.10.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/naming/jnp-client/5.0.3.GA/jnp-client-5.0.3.GA.jar" sourcepath="M2_REPO/org/jboss/naming/jnp-client/5.0.3.GA/jnp-client-5.0.3.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/naming/jnpserver/5.0.3.GA/jnpserver-5.0.3.GA.jar" sourcepath="M2_REPO/org/jboss/naming/jnpserver/5.0.3.GA/jnpserver-5.0.3.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/aop/jrockit-pluggable-instrumentor/2.1.0.CR2/jrockit-pluggable-instrumentor-2.1.0.CR2.jar" sourcepath="M2_REPO/org/jboss/aop/jrockit-pluggable-instrumentor/2.1.0.CR2/jrockit-pluggable-instrumentor-2.1.0.CR2-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/sun-jaxws/jsr181-api/2.1.1/jsr181-api-2.1.1.jar"/>
+	<classpathentry kind="var" path="M2_REPO/javax/transaction/jta/1.1/jta-1.1.jar" sourcepath="M2_REPO/javax/transaction/jta/1.1/jta-1.1-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/junit/junit/3.8.2/junit-3.8.2.jar" sourcepath="M2_REPO/junit/junit/3.8.2/junit-3.8.2-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/log4j/log4j/1.2.14/log4j-1.2.14.jar" sourcepath="M2_REPO/log4j/log4j/1.2.14/log4j-1.2.14-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/aop/pluggable-instrumentor/2.1.0.CR2/pluggable-instrumentor-2.1.0.CR2.jar" sourcepath="M2_REPO/org/jboss/aop/pluggable-instrumentor/2.1.0.CR2/pluggable-instrumentor-2.1.0.CR2-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/qdox/qdox/1.6.1/qdox-1.6.1.jar" sourcepath="M2_REPO/qdox/qdox/1.6.1/qdox-1.6.1-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/quartz/quartz/1.5.2/quartz-1.5.2.jar" sourcepath="M2_REPO/quartz/quartz/1.5.2/quartz-1.5.2-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/jboss/web/servlet-api/2.1.2.GA/servlet-api-2.1.2.GA.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-api/1.5.0/slf4j-api-1.5.0.jar" sourcepath="M2_REPO/org/slf4j/slf4j-api/1.5.0/slf4j-api-1.5.0-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/stax/stax-api/1.0/stax-api-1.0.jar"/>
+	<classpathentry kind="var" path="M2_REPO/trove/trove/1.0.2/trove-1.0.2.jar"/>
+	<classpathentry kind="var" path="M2_REPO/apache-xerces/xercesImpl/2.9.1/xercesImpl-2.9.1.jar"/>
+	<classpathentry kind="var" path="M2_REPO/apache-xerces/xml-apis/2.9.1/xml-apis-2.9.1.jar"/>
+	<classpathentry kind="output" path="target/classes"/>
+</classpath>

Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/AbstractRuntimeComponentDispatcher.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/AbstractRuntimeComponentDispatcher.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/AbstractRuntimeComponentDispatcher.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -25,10 +25,8 @@
 import org.jboss.deployers.spi.management.RuntimeComponentDispatcher;
 import org.jboss.managed.api.ManagedOperation;
 import org.jboss.managed.api.ManagedProperty;
-import org.jboss.managed.api.TransientAttachments;
 import org.jboss.metatype.api.values.MetaValue;
 import org.jboss.metatype.api.values.MetaValueFactory;
-import org.jboss.metatype.spi.values.MetaMapper;
 
 /**
  * Abstract component dispatcher.
@@ -75,6 +73,16 @@
     * @return state enum value
     */
    public abstract String getState(Object name);
+   
+   /**
+    * Map the state of the component.
+    * 
+    * @param <T> the state enum
+    * @param name the component name
+    * @param mapper the state mapper
+    * @return the mapped state
+    */
+   public abstract <T extends Enum<?>> T mapControllerState(Object name, ContextStateMapper<T> mapper);
 
    /**
     * Create meta value.

Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/MBeanManagedObjectFactory.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/MBeanManagedObjectFactory.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/MBeanManagedObjectFactory.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -84,7 +84,7 @@
  * MBeanInfo.
  *
  * @author Scott.Stark at jboss.org
- * @version $Revision$
+ * @version $Revision:$
  */
 public class MBeanManagedObjectFactory
 {

Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/ManagedPropertyDelegate.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/ManagedPropertyDelegate.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/ManagedPropertyDelegate.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -23,6 +23,7 @@
 
 import java.io.Serializable;
 import java.lang.annotation.Annotation;
+import java.util.Collection;
 import java.util.Map;
 import java.util.Set;
 
@@ -154,6 +155,11 @@
       return propValue;
    }
 
+   public Collection<String> getAdminViewUses()
+   {
+      return delegate.getAdminViewUses();
+   }
+
    public boolean hasAnnotation(String key)
    {
       return delegate.hasAnnotation(key);

Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -24,6 +24,7 @@
 import java.io.IOException;
 import java.io.Serializable;
 import java.lang.annotation.Annotation;
+import java.lang.management.ManagementFactory;
 import java.text.MessageFormat;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -35,6 +36,7 @@
 import java.util.Map;
 import java.util.ResourceBundle;
 import java.util.Set;
+import java.util.TreeSet;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -47,6 +49,7 @@
 import org.jboss.deployers.spi.management.ContextStateMapper;
 import org.jboss.deployers.spi.management.DeploymentTemplate;
 import org.jboss.deployers.spi.management.KnownComponentTypes;
+import org.jboss.deployers.spi.management.KnownDeploymentTypes;
 import org.jboss.deployers.spi.management.ManagementView;
 import org.jboss.deployers.spi.management.NameMatcher;
 import org.jboss.deployers.spi.management.RuntimeComponentDispatcher;
@@ -101,7 +104,7 @@
 
 /**
  * The default ManagementView implementation.
- * 
+ *
  * @author Scott.Stark at jboss.org
  * @author adrian at jboss.org
  * @author ales.justin at jboss.org
@@ -112,17 +115,19 @@
       properties = ManagementProperties.EXPLICIT, description = "The ProfileService ManagementView")
 public class ManagementViewImpl extends AbstractTemplateCreator implements ManagementView
 {
+  
+
    /** The logger. */
    private static Logger log = Logger.getLogger(ManagementViewImpl.class);
    private static final String BUNDLE_NAME = "org.jboss.profileservice.management.messages"; //$NON-NLS-1$
-   
+
    /** The ProfileService for loading profiles */
    private ProfileService ps;
    /** The last modified cache for loaded profiles */
    private Map<ProfileKey, Long> lastModified = new HashMap<ProfileKey, Long>();
    /** Force a reload of ManagementView. */
    private boolean forceReload;
-   
+
    /** The MainDeployer only used to get the ManagedDeployments */
    private MainDeployer mainDeployer;
    /** The attachment store to persist the component changes. */
@@ -130,14 +135,14 @@
 
    /** The deployment templates that have been registered with the MV */
    private HashMap<String, DeploymentTemplate> templates = new HashMap<String, DeploymentTemplate>();
-   
+
    /** 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("");
-   
+
    /** An index of ManagedComponent by ComponentType */
    private HashMap<ComponentType, Set<ManagedComponent>> compByCompType = new HashMap<ComponentType, Set<ManagedComponent>>();
    /** id/type key to ManagedObject map */
@@ -146,22 +151,23 @@
    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 bootstrap deployment name to ManagedDeployment map */
-   private Map<String, ManagedDeployment> bootstrapManagedDeployments = Collections.emptyMap(); 
+   private Map<String, ManagedDeployment> bootstrapManagedDeployments = Collections.emptyMap();
    /** The deployment name to ManagedDeployment map */
-   private Map<String, ManagedDeployment> managedDeployments = new HashMap<String, ManagedDeployment>();   
+   private Map<String, ManagedDeployment> managedDeployments = new HashMap<String, ManagedDeployment>();
    /** The root deployments to resolve the deployment name. */
    private List<String> rootDeployments = new ArrayList<String>();
-   
+
    /** The state mappings. */
    private static final ContextStateMapper<RunState> runStateMapper;
    private static final ContextStateMapper<DeploymentState> deploymentStateMapper;
-   
+
    /** The dispatcher handles ManagedOperation dispatches */
    private RuntimeComponentDispatcher dispatcher;
    /** The managed operation proxy factory. */
    private ManagedOperationProxyFactory proxyFactory;
+
    /** A proxy for pure JMX dispatch */
    private ManagedOperationProxyFactory mbeanProxyFactory;
 
@@ -169,7 +175,6 @@
    private MetaValueFactory metaValueFactory = MetaValueFactory.getInstance();
    /** ManagedObjectFactory used for platform mbean ManagedObjects */
    ManagedObjectFactory managedObjFactory = ManagedObjectFactory.getInstance();
-
    /** A map of ManagedMBeanDeploymentFactory for proxying mbeans into the management layer */
    private HashMap<String, ManagedMBeanDeploymentFactory> mdfs =
       new HashMap<String, ManagedMBeanDeploymentFactory>();
@@ -208,6 +213,7 @@
 
    public ManagementViewImpl() throws IOException
    {
+
       currentLocale = Locale.getDefault();
       formatter.setLocale(currentLocale);
       i18n = ResourceBundle.getBundle(BUNDLE_NAME, currentLocale);
@@ -217,13 +223,13 @@
    {
       // nothing
    }
-   
+
    public void stop()
    {
       // Cleanup on stop
       release();
    }
-   
+
    public synchronized boolean load()
    {
       // If the profile is not modified do nothing
@@ -233,140 +239,230 @@
          return false;
       }
       this.forceReload = false;
-      
+
       // Clear any thread interrupt
       boolean wasInterrupted = Thread.interrupted();
-      try
-      {
-         if(wasInterrupted)
-            log.trace("Cleared interrupted state of calling thread");
+      if(wasInterrupted)
+         log.debug("Cleared interrupted state of calling thread");
 
+      // Cleanup
+      release();
 
+      //
+      boolean trace = log.isTraceEnabled();
 
-         // Cleanup
-         release();
+      // load the profiles
+      loadProfiles(trace);
 
-         //
-         boolean trace = log.isTraceEnabled();
-
-         // load the profiles
-         loadProfiles(trace);
-
-         // Process mbean components that need to be exposed as ManagedDeployment/ManagedComponent
-         for(ManagedMBeanDeploymentFactory mdf : mdfs.values())
+      // 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("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)
             {
-               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)
                {
-                  for(MBeanComponent comp : components)
+                  log.debug("Saw MBeanComponent: "+comp);
+                  try
                   {
-                     log.debug("Saw MBeanComponent: "+comp);
-                     try
-                     {
-                        ManagedObject mo = createManagedObject(comp.getName(), mdf.getDefaultViewUse());
-
-                        String name = comp.getName().getCanonicalName();
-                        ManagementObject moAnn = createMOAnnotation(name, comp.getType(), comp.getSubtype());
-
-                        // Both 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(name, mo);
-                     }
-                     catch(Exception e)
-                     {
-                        log.warn("Failed to create ManagedObject for: "+comp, e);
-                     }
+                     ManagedObject mo = createManagedObject(comp.getName(), mdf.getDefaultViewUse());
+                     
+                     String name = comp.getName().getCanonicalName();
+                     ManagementObject moAnn = createMOAnnotation(name, comp.getType(), comp.getSubtype());
+                     
+                     // Both 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(name, mo);
                   }
+                  catch(Exception e)
+                  {
+                     log.warn("Failed to create ManagedObject for: "+comp, e);
+                  }
                }
-               ManagedDeploymentImpl mdi = new ManagedDeploymentImpl(md.getName(), md.getName(), null, unitMOs);
-               mdi.setTypes(Collections.singleton("external-mbean"));
-               try
-               {
-                  processManagedDeployment(mdi, null, DeploymentState.STARTED, 0, trace);
-               }
-               catch(Exception e)
-               {
-                  log.warn("Failed to process ManagedDeployment for: " + md.getName(), e);
-               }
             }
-         }
-
-         // Process the bootstrap deployments
-         for(ManagedDeployment md : bootstrapManagedDeployments.values())
-         {
+            ManagedDeploymentImpl mdi = new ManagedDeploymentImpl(md.getName(), md.getName(), null, unitMOs);
+            mdi.setTypes(Collections.singleton("external-mbean"));
             try
             {
-               //
-               processManagedDeployment(md, null, DeploymentState.STARTED, 0, trace);
+               processManagedDeployment(mdi, null, DeploymentState.STARTED, 0, trace);
             }
             catch(Exception e)
             {
                log.warn("Failed to process ManagedDeployment for: " + md.getName(), e);
             }
          }
-         if(this.runtimeMOs.size() > 0)
-            log.warn("Failed to merged the following runtime ManagedObjects: "+runtimeMOs);
+      }
 
-         // Now create a ManagedDeployment for the platform beans
-         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);
-
+      // Process the bootstrap deployments
+      for(ManagedDeployment md : bootstrapManagedDeployments.values())
+      {
          try
          {
-            // Create the ManagedComponents
-            processManagedDeployment(platformMBeans, null, DeploymentState.STARTED, 0, trace);
+            //
+            processManagedDeployment(md, null, DeploymentState.STARTED, 0, trace);
          }
          catch(Exception e)
          {
-            log.warn("Failed to process ManagedDeployments for the platform beans", e);
+            log.warn("Failed to process ManagedDeployment for: " + md.getName(), e);
          }
+      }
+      if(this.runtimeMOs.size() > 0)
+         log.warn("Failed to merged the following runtime ManagedObjects: "+runtimeMOs);
 
-         return true;
+      // Now create a ManagedDeployment for the platform beans
+      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);
+
+      try
+      {
+         // Create the ManagedComponents
+         processManagedDeployment(platformMBeans, null, DeploymentState.STARTED, 0, trace);
       }
-      finally
+      catch(Exception e)
       {
-         if(wasInterrupted)
+         log.warn("Failed to process ManagedDeployments for the platform beans", e);
+      }
+
+      if(wasInterrupted)
+      {
+         Thread.currentThread().interrupt();
+         log.debug("Restored interrupted state of calling thread");
+      }
+      return true;
+   }
+
+   @SuppressWarnings("all")
+   private static final class ManagementObjectAnnotationImpl implements ManagementObject, Serializable
+   { 
+      private static final long serialVersionUID=5355799336353299850L;
+      
+      private final String name;
+      private final String type;
+      private final String subtype;
+      
+      @SuppressWarnings("all")
+      private final class ManagementComponentAnnotationImpl implements ManagementComponent, Serializable
+      {
+         private static final long serialVersionUID=5355799336353299850L;
+         
+         public String subtype()
          {
-            Thread.currentThread().interrupt();
-            log.trace("Restored interrupted state of calling thread");
+            return subtype;
          }
+
+         public String type()
+         {
+            return type;
+         }
+
+         public Class<? extends Annotation> annotationType()
+         {
+            return ManagementComponent.class;
+         }
       }
+
+      private ManagementObjectAnnotationImpl(String name, String type, String subtype)
+      {
+         this.name=name;
+         this.type=type;
+         this.subtype=subtype;
+      }
+
+      public String attachmentName()
+      {
+         return "";
+      }
+
+      public ManagementProperty[] classProperties()
+      {
+         return new ManagementProperty[0];
+      }
+
+      public ManagementComponent componentType()
+      {
+         return new ManagementComponentAnnotationImpl();
+      }
+
+      public String description()
+      {
+         return "";
+      }
+
+      public boolean isRuntime()
+      {
+         return true;
+      }
+
+      public String name()
+      {
+         return name;
+      }
+
+      public ManagementOperation[] operations()
+      {
+         return new ManagementOperation[0];
+      }
+
+      public ManagementProperties properties()
+      {
+         return ManagementProperties.ALL;
+      }
+
+      public Class<?> targetInterface()
+      {
+         return Object.class;
+      }
+
+      public String type()
+      {
+         return "";
+      }
+
+      public Class<? extends Annotation> annotationType()
+      {
+         return ManagementObject.class;
+      }
    }
    
+   private ManagementObject createMOAnnotation(final String name, final String type, final String subtype)
+   {
+      return new ManagementObjectAnnotationImpl(name, type, subtype);
+   }
+
    public void reload()
    {
       forceReload = true;
-      load();  
+      load();
    }
-   
+
    public void release()
    {
       // Cleanup
@@ -379,9 +475,9 @@
       this.rootDeployments.clear();
       // Cleanup delegate operations
       this.proxyFactory.clear();
-      
+
    }
-   
+
    protected void loadProfiles(boolean trace)
    {
       log.debug("reloading profiles: "+ this.ps.getActiveProfileKeys());
@@ -400,31 +496,52 @@
             {
                try
                {
-                  ManagedDeployment md = getManagedDeployment(deployment);
-                  processRootManagedDeployment(md, key, trace);
-               }
-               catch(DeploymentException e)
-               {
-                  // FIXME Assume a undeployed (stopped) deployment
-                  String deploymentName = deployment.getName();
-                  ManagedDeployment md = new ManagedDeploymentImpl(deploymentName,
-                        deployment.getRoot().getName());
-                  
-                  int i = deploymentName.lastIndexOf(".");
-                  if(i != -1 && (i + 1) < deploymentName.length())
+                  try
                   {
-                     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);
+                     ManagedDeployment md = getManagedDeployment(deployment);
+                     processRootManagedDeployment(md, key, trace);
+
+                     // TODO update profileservice-spi
+                     // Cache the deployment types
+                     if(md.getTypes() != null && md.getTypes().isEmpty() == false)
+                        ((AbstractProfileDeployment)deployment)
+                           .addTransientAttachment(KnownDeploymentTypes.class.getName(), md.getTypes());
                   }
-                  
-                  processManagedDeployment(md, key, DeploymentState.STOPPED, 0, trace);
+                  catch(DeploymentException e)
+                  {
+                     // FIXME Assume a undeployed (stopped) deployment
+                     String deploymentName = deployment.getName();
+                     ManagedDeployment md = new ManagedDeploymentImpl(deploymentName,
+                           deployment.getRoot().getName());
+
+                     // TODO update profileservice-spi
+                     // Try to get the cached deployment type
+                     Collection<String> deploymentTypes = (Collection<String>) ((AbstractProfileDeployment)deployment)
+                           .getTransientAttachment(KnownDeploymentTypes.class.getName());
+
+                     if(deploymentTypes != null)
+                     {
+                        md.setTypes(new HashSet<String>(deploymentTypes));
+                     }
+                     else
+                     {
+                        int i = deploymentName.lastIndexOf(".");
+                        if(i != -1 && (i + 1) < deploymentName.length())
+                        {
+                           String guessedType = deploymentName.substring(i + 1, deploymentName.length());
+                           if(guessedType.endsWith("/"))
+                              guessedType = guessedType.substring(0, guessedType.length() -1 );
+                           md.setTypes(new HashSet<String>(1));
+                           md.addType(guessedType);
+                        }
+                     }
+
+                     processManagedDeployment(md, key, DeploymentState.STOPPED, 0, trace);
+                  }
                }
                catch(Exception e)
                {
-                  log.debug("Failed to create ManagedDeployment for: " + deployment.getName(), e);
+                  log.warn("Failed to create ManagedDeployment for: " + deployment.getName(), e);
                }
             }
          }
@@ -434,7 +551,7 @@
          }
       }
    }
-   
+
    protected boolean isReload()
    {
       if(forceReload == true)
@@ -447,7 +564,7 @@
       {
          if(this.lastModified.containsKey(key) == false)
             return true;
-         
+
          try
          {
             Profile profile = this.ps.getActiveProfile(key);
@@ -466,21 +583,21 @@
     * get populated to the child deployments as well.
     *
     * @param md the managed deployment
-    * @param profile the associated profile key 
+    * @param profile the associated profile key
     * @param trace is trace enabled
     * @throws Exception for any error
     */
    protected void processRootManagedDeployment(ManagedDeployment md, ProfileKey profile, boolean trace) throws Exception
    {
       DeploymentState state = getDeploymentState(md);
-      processManagedDeployment(md, profile, state, 0, trace);      
+      processManagedDeployment(md, profile, state, 0, trace);
    }
-   
+
    /**
     * Process managed deployment.
     *
     * @param md the managed deployment
-    * @param profile the associated profile key 
+    * @param profile the associated profile key
     * @param state the deployment state
     * @param level depth level
     * @param trace is trace enabled
@@ -494,17 +611,17 @@
       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);
-      
+
       // Associate profile with the deployment
       if(profile != null)
       {
@@ -514,7 +631,7 @@
       // Add root deployments
       if(level == 0)
          this.rootDeployments.add(name);
-      
+
       // Process children
       List<ManagedDeployment> mdChildren = md.getChildren();
       if(mdChildren != null && mdChildren.isEmpty() == false)
@@ -549,7 +666,7 @@
          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)
@@ -574,7 +691,7 @@
          // 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();
@@ -772,7 +889,7 @@
       }
       return state;
    }
-   
+
    protected DeploymentState getDeploymentState(ManagedDeployment md)
    {
       DeploymentState state = md.getDeploymentState();
@@ -786,6 +903,7 @@
       }
       return state;
    }
+
    protected <T extends Enum<?>> T getMappedState(Object name, ContextStateMapper<T> mapper)
    {
       T state = mapper.getErrorState();
@@ -849,7 +967,7 @@
       }
    }
 
-   
+
    public Map<String, ManagedDeployment> getBootstrapManagedDeployments()
    {
       return bootstrapManagedDeployments;
@@ -880,22 +998,22 @@
    {
       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;
@@ -924,7 +1042,7 @@
    {
       this.managedObjFactory = managedObjFactory;
    }
-   
+
    public void setDispatcher(RuntimeComponentDispatcher dispatcher)
    {
       this.dispatcher = dispatcher;
@@ -957,18 +1075,18 @@
     */
    public Set<String> getDeploymentNames()
    {
-      return new HashSet<String>(this.managedDeployments.keySet());
+      return new TreeSet<String>(this.managedDeployments.keySet());
    }
 
    /**
     * Get the names of the deployment in the profile that have the
     * given deployment type.
-    * 
+    *
     * @param type - the deployment type
     */
    public Set<String> getDeploymentNamesForType(String type)
    {
-      HashSet<String> matches = new HashSet<String>();
+      Set<String> matches = new TreeSet<String>();
       for(ManagedDeployment md : managedDeployments.values())
       {
          String name = md.getName();
@@ -977,24 +1095,12 @@
          {
             if(types.contains(type))
             {
-               log.debug(name+" matches type: "+type+", types:"+types);
+               if(log.isTraceEnabled())
+                  log.trace(name+" matches type: "+type+", types:"+types);
                matches.add(name);
             }
          }
       }
-      for(ManagedDeployment md : bootstrapManagedDeployments.values())
-      {
-         String name = md.getName();
-         Set<String> types = md.getTypes();
-         if(types != null)
-         {
-            if(types.contains(type))
-            {
-               log.debug(name+" matches type: "+type+", types:"+types);
-               matches.add(name);
-            }
-         }
-      }
       return matches;
    }
 
@@ -1034,13 +1140,13 @@
 
    public void addManagedMBeanDeployments(ManagedMBeanDeploymentFactory factory)
    {
-      log.info("addManagedDeployment, "+factory);
+      log.debug("addManagedDeployment, "+factory);
       String name = factory.getFactoryName();
       this.mdfs.put(name, factory);
    }
    public void removeManagedMBeanDeployments(ManagedMBeanDeploymentFactory factory)
    {
-      log.info("removeManagedDeployment, "+factory);
+      log.debug("removeManagedDeployment, "+factory);
       String name = factory.getFactoryName();
       this.mdfs.remove(name);
    }
@@ -1060,7 +1166,7 @@
 
    /**
     * Get the managed deployment.
-    * 
+    *
     * @param name the deployment name
     * @throws NoSuchDeploymentException if no matching deployment was found
     */
@@ -1068,7 +1174,7 @@
    {
       if(name == null)
          throw new IllegalArgumentException("Null deployment name");
-      
+
       // Resolve internally.
       ManagedDeployment md = this.managedDeployments.get(name);
       if (md == null)
@@ -1076,7 +1182,7 @@
          // Check the bootstrap deployments
          md = this.bootstrapManagedDeployments.get(name);
       }
-      
+
       // Check the file name
       if(md == null)
       {
@@ -1091,7 +1197,7 @@
                md = this.managedDeployments.get(deployment);
                break;
             }
-         }  
+         }
       }
       // Do not return null
       if (md == null)
@@ -1101,7 +1207,7 @@
    }
 
    /**
-    * 
+    *
     * @param key
     * @param type
     * @return
@@ -1133,7 +1239,7 @@
     *
     * @param key
     * @param type
-    * @return 
+    * @return
     * @throws NoSuchProfileException
     */
    public Set<ManagedComponent> getComponentsForType(ComponentType type)
@@ -1161,7 +1267,7 @@
          comps = Collections.emptySet();
       return comps;
    }
-   
+
    public ManagedComponent getComponent(String name, ComponentType type)
       throws Exception
    {
@@ -1237,7 +1343,7 @@
          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 )
       {
@@ -1249,16 +1355,16 @@
 
       // Create a deployment base from the template
       if( log.isTraceEnabled() )
-         log.trace("applyTemplate, deploymentBaseName="+deploymentBaseName +", info="+info);      
-      
+         log.trace("applyTemplate, deploymentBaseName="+deploymentBaseName +", info="+info);
+
       // Create, distribute and start a deployment template
       String deploymentName = super.applyTemplate(template, deploymentBaseName, info);
-      
+
       // Process the deployment
       ManagedDeployment md = getMainDeployer().getManagedDeployment(deploymentName);
       processRootManagedDeployment(md, getDefaulProfiletKey(), log.isTraceEnabled());
    }
-   
+
    public void process() throws DeploymentException
    {
       //
@@ -1278,7 +1384,7 @@
       // Get the parent
       while( md.getParent() != null )
          md = md.getParent();
-         
+
       String name = md.getName();
       ProfileDeployment compDeployment = getProfileDeployment(name);
       if( compDeployment == null )
@@ -1292,7 +1398,7 @@
       // Apply the managed properties to the server ManagedDeployment/ManagedComponent
       ManagedDeployment compMD = managedDeployments.get(md.getName());
       log.debug("updateComponent, deploymentName="+name+": "+compMD);
-      
+
       ManagedComponent serverComp = null;
       // Find the managed component again
       if(comp.getDeployment().getParent() == null)
@@ -1309,9 +1415,9 @@
             {
                if(serverComp != null)
                   break;
-               
+
                serverComp = child.getComponent(comp.getName());
-            }            
+            }
          }
       }
       if(serverComp == null)
@@ -1368,11 +1474,11 @@
          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);
@@ -1381,11 +1487,11 @@
       }
 
       // Persist the changed values
-      this.store.updateDeployment(compDeployment, serverComp);
+      this.store.updateDeployment(comp.getDeployment().getName(), serverComp);
       // Force reload
       this.forceReload = true;
    }
-   
+
    public void removeComponent(ManagedComponent comp) throws Exception
    {
       if(comp == null)
@@ -1396,7 +1502,7 @@
       // Get the parent
       while( md.getParent() != null )
          md = md.getParent();
-         
+
       String name = md.getName();
       ProfileDeployment profileDeployment = getProfileDeployment(name);
       if( profileDeployment == null )
@@ -1406,11 +1512,11 @@
          String msg = formatter.format(args);
          throw new NoSuchDeploymentException(msg);
       }
-      
+
       // Apply the managed properties to the server ManagedDeployment/ManagedComponent
       ManagedDeployment compMD = managedDeployments.get(md.getName());
       log.debug("updateComponent, deploymentName="+name+": "+compMD);
-      
+
       ManagedComponent serverComp = null;
       // Find the managed component again
       if(comp.getDeployment().getParent() == null)
@@ -1427,9 +1533,9 @@
             {
                if(serverComp != null)
                   break;
-               
+
                serverComp = child.getComponent(comp.getName());
-            }            
+            }
          }
       }
       if(serverComp == null)
@@ -1441,11 +1547,11 @@
          String msg = formatter.format(args);
          throw new IllegalArgumentException(msg);
       }
-      
+
       //
       log.debug("remove component: " + comp + ", deployment: "+ profileDeployment);
       // Remove
-      this.store.removeComponent(profileDeployment, serverComp);
+      this.store.removeComponent(comp.getDeployment().getName(), serverComp);
    }
 
    /**
@@ -1477,12 +1583,12 @@
             prop.setTargetManagedObject(mo);
          }
          unresolvedRefs.remove(key);
-      }      
+      }
    }
 
    /**
     * Merge the and proxy runtime props and ops
-    * 
+    *
     * @param mo - the parent managed object to merge into. May be null if the
     * runtimeMO is a self contained managed object as is the case for runtime
     * components.
@@ -1552,7 +1658,7 @@
             if (prop.getTargetManagedObject() == null)
                prop.setTargetManagedObject(runtimeMO);
          }
-         
+
          log.debug("Properties after:"+props);
       }
       if (runtimeOps != null && runtimeOps.size() > 0)
@@ -1573,7 +1679,7 @@
    {
       if (proxyFactory == null)
          throw new IllegalArgumentException("Missing RuntimeComponentDispatcher.");
-      
+
       // Create the delegate property
       Object componentName = prop.getManagedObject().getComponentName();
 
@@ -1603,14 +1709,14 @@
       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 ManagedObject createManagedObject(ObjectName mbean, String defaultViewUse)
       throws Exception
    {
@@ -1626,127 +1732,42 @@
    {
       return mainDeployer.getManagedDeployment(ctx.getName());
    }
-   
+
    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);
    }
 
-   @SuppressWarnings("all")
-   private static final class ManagementObjectAnnotationImpl implements ManagementObject, Serializable
-   { 
-      private static final long serialVersionUID=5355799336353299850L;
-      
-      private final String name;
-      private final String type;
-      private final String subtype;
-      
-      @SuppressWarnings("all")
-      private final class ManagementComponentAnnotationImpl implements ManagementComponent, Serializable
+   public static void main(String[] args)
+      throws Exception
+   {
+      MBeanServer server = ManagementFactory.getPlatformMBeanServer();
+      ObjectName name = new ObjectName("jboss.management.local:J2EEApplication=null,J2EEServer=Local,j2eeType=WebModule,*");
+      Set<ObjectName> matches = server.queryNames(name, null);
+      for(ObjectName on : matches)
       {
-         private static final long serialVersionUID=5355799336353299850L;
-         
-         public String subtype()
-         {
-            return subtype;
-         }
-
-         public String type()
-         {
-            return type;
-         }
-
-         public Class<? extends Annotation> annotationType()
-         {
-            return ManagementComponent.class;
-         }
+         System.err.println(on);
       }
+   }
 
-      private ManagementObjectAnnotationImpl(String name, String type, String subtype)
-      {
-         this.name=name;
-         this.type=type;
-         this.subtype=subtype;
-      }
-
-      public String attachmentName()
-      {
-         return "";
-      }
-
-      public ManagementProperty[] classProperties()
-      {
-         return new ManagementProperty[0];
-      }
-
-      public ManagementComponent componentType()
-      {
-         return new ManagementComponentAnnotationImpl();
-      }
-
-      public String description()
-      {
-         return "";
-      }
-
-      public boolean isRuntime()
-      {
-         return true;
-      }
-
-      public String name()
-      {
-         return name;
-      }
-
-      public ManagementOperation[] operations()
-      {
-         return new ManagementOperation[0];
-      }
-
-      public ManagementProperties properties()
-      {
-         return ManagementProperties.ALL;
-      }
-
-      public Class<?> targetInterface()
-      {
-         return Object.class;
-      }
-
-      public String type()
-      {
-         return "";
-      }
-
-      public Class<? extends Annotation> annotationType()
-      {
-         return ManagementObject.class;
-      }
-   }
-   
-   private ManagementObject createMOAnnotation(final String name, final String type, final String subtype)
+   public ManagedOperationProxyFactory getMbeanProxyFactory()
    {
-      return new ManagementObjectAnnotationImpl(name, type, subtype);
-   }
-      public ManagedOperationProxyFactory getMbeanProxyFactory()
-   {
       return mbeanProxyFactory;
    }
 

Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/TempManagedComponentImpl.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/TempManagedComponentImpl.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/TempManagedComponentImpl.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -21,6 +21,8 @@
  */ 
 package org.jboss.profileservice.management;
 
+import java.io.ObjectStreamException;
+
 import org.jboss.managed.api.ComponentType;
 import org.jboss.managed.api.ManagedCommon;
 import org.jboss.managed.api.ManagedDeployment;
@@ -54,5 +56,12 @@
    {
       return getDelegate();
    }
-   
+
+   private Object writeReplace() throws ObjectStreamException
+   {
+      // Only expose the ManagedComponentImpl
+      ManagedComponentImpl comp = new ManagedComponentImpl(getType(), getDeployment(), getDelegate(), getStateMapper()); 
+      comp.setRunState(getRunState());
+      return comp;
+   }
 }

Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentManagerImpl.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentManagerImpl.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentManagerImpl.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -35,7 +35,7 @@
 import org.jboss.deployers.spi.management.deploy.DeploymentStatus.CommandType;
 import org.jboss.logging.Logger;
 import org.jboss.profileservice.management.upload.remoting.StreamingDeploymentTarget;
-import org.jboss.profileservice.spi.MutableProfile;
+import org.jboss.profileservice.spi.DeploymentOption;
 import org.jboss.profileservice.spi.NoSuchProfileException;
 import org.jboss.profileservice.spi.ProfileKey;
 import org.jboss.profileservice.spi.ProfileRepository;
@@ -155,7 +155,32 @@
       deployment.setCopyContent(copyContent);
       return new DeploymentProgressImpl(targets, deployment, CommandType.DISTRIBUTE);
    }
+   
+   public DeploymentProgress distribute(String name, URL contentURL, DeploymentOption... options) throws Exception
+   {
+      if(name == null)
+         throw new IllegalArgumentException("Null name.");
+      if(contentURL == null)
+         throw new IllegalArgumentException("Null content url.");
+      if(options == null)
+         options = new DeploymentOption[0];
 
+      if(getTargetProfile() == null)
+      {
+         formatter.applyPattern(i18n.getString("DeploymentManager.NoProfileLoadedException")); //$NON-NLS-1$
+         Object[] args = {};
+         String msg = formatter.format(args);
+         throw new IllegalStateException(msg);
+      }
+      
+      List<DeploymentTarget> targets = getDeploymentTargets();
+      SerializableDeploymentID deployment = new SerializableDeploymentID(name, getTargetProfile(), contentURL.toString());
+      deployment.setContentURL(contentURL);
+      for(DeploymentOption option : options)
+         deployment.addDeploymentOption(option);
+      return new DeploymentProgressImpl(targets, deployment, CommandType.DISTRIBUTE);
+   }
+
    public String[] getRepositoryNames(String[] names) throws Exception
    {
       List<DeploymentTarget> targets = getDeploymentTargets();
@@ -165,7 +190,7 @@
    
    public boolean isRedeploySupported()
    {
-      return (getTargetProfile() instanceof MutableProfile);
+      return (getTargetProfile() != null);
    }
    
    public void loadProfile(ProfileKey key) throws NoSuchProfileException

Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/upload/SerializableDeploymentID.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/upload/SerializableDeploymentID.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/upload/SerializableDeploymentID.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -25,8 +25,11 @@
 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;
 
 /**
@@ -39,6 +42,7 @@
 
    /** 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;
@@ -62,6 +66,7 @@
       this.profileKey = profileKey;
       this.description = description;
       this.copyContent = true; // by default we copy content
+      this.options = new HashSet<DeploymentOption>();
    }
 
    public String[] getNames()
@@ -131,6 +136,30 @@
       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();

Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/upload/SerializableDeploymentStatus.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/upload/SerializableDeploymentStatus.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/upload/SerializableDeploymentStatus.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -32,7 +32,7 @@
  * Simple javabean impl of DeploymentStatus
  * 
  * @author Scott.Stark at jboss.org
- * @version $Revision:$
+ * @version $Revision$
  */
 public class SerializableDeploymentStatus implements DeploymentStatus,
       Serializable

Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/AbstractDeployHandler.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/AbstractDeployHandler.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/AbstractDeployHandler.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -224,7 +224,8 @@
       String[] names = deploymentTarget.getNames();
       
       // Add deployment content to the repository
-      String repositoryName = deploymentRepository.addDeploymentContent(names[0], contentIS);
+      String repositoryName = deploymentRepository.addDeploymentContent(names[0], contentIS,
+            deploymentTarget.getDeploymentOptions());
       
       // FIXME make deployment visible to management view
       VirtualFile vf = deploymentRepository.getDeploymentContent(repositoryName);

Modified: trunk/server/src/etc/conf/all/bootstrap/profile.xml
===================================================================
--- trunk/server/src/etc/conf/all/bootstrap/profile.xml	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/server/src/etc/conf/all/bootstrap/profile.xml	2009-05-26 10:14:36 UTC (rev 89429)
@@ -131,12 +131,23 @@
       <property name="tempDirURI">${jboss.server.home.url}temp${/}cluster-repo</property>
    </bean>
 
-	<!-- The attachment store -->
+	<!-- A persistence factory for creating the persisted format of ManagedComponents -->
+	<bean name="PersistenceFactory" class="org.jboss.system.server.profileservice.persistence.AbstractPersistenceFactory">
+		<constructor><parameter><inject bean="ManagedObjectFactory" /></parameter></constructor>
+		<!-- Accept any ComponentMapper -->
+		<incallback method="addComponentMapper" />
+		<uncallback method="removeComponentMapper" />
+		<!-- Accept any ManagedObjectPersistencePlugin -->
+		<incallback method="addPersistencePlugin" />
+		<uncallback method="removePersistencePlugin" />
+	</bean>
+
+	<!-- The attachment store -->	
 	<bean name="AttachmentStore" class="org.jboss.system.server.profileservice.repository.AbstractAttachmentStore">
 		<constructor><parameter><inject bean="BootstrapProfileFactory" property="attachmentStoreRoot" /></parameter></constructor>
 		<property name="mainDeployer"><inject bean="MainDeployer" /></property>
 		<property name="serializer"><inject bean="AttachmentsSerializer" /></property>
-		<property name="metaDataFilter"><bean class="org.jboss.system.server.profile.basic.XmlIncludeVirtualFileFilter" /></property>
+		<property name="persistenceFactory"><inject bean="PersistenceFactory" /></property>
 	</bean>
 
 	<bean name="AttachmentsSerializer" class="org.jboss.system.server.profileservice.repository.JAXBAttachmentSerializer">
@@ -148,7 +159,17 @@
 		<property name="attachmentStore"><inject bean="AttachmentStore" /></property>
 	</bean>
 
-   <bean name="ProfileServicePersistenceDeployer" class="org.jboss.system.server.profileservice.persistence.deployer.ProfileServicePersistenceDeployer" />
+   <bean name="ProfileServicePersistenceDeployer" class="org.jboss.system.server.profileservice.persistence.deployer.ProfileServicePersistenceDeployer">
+   		<property name="persistenceFactory"><inject bean="PersistenceFactory" /></property>
+   		<property name="attachmentStore"><inject bean="AttachmentStore" /></property>
+   </bean>
+   
+   <bean name="KernelDeploymentComponentMapper" class="org.jboss.deployers.plugins.managed.KernelDeploymentComponentMapper">
+   		<constructor><parameter><inject bean="PersistenceFactory" /></parameter></constructor>
+   </bean>
+   <bean name="ServiceDeploymentComponentMapper" class="org.jboss.system.deployers.managed.ServiceDeploymentComponentMapper">
+   		<constructor><parameter><inject bean="PersistenceFactory" /></parameter></constructor>
+   </bean>
 
 	<!-- A filter for excluding files from the scanner -->
 	<bean name="DeploymentFilter" class="org.jboss.virtual.plugins.vfs.helpers.ExtensibleFilter">

Modified: trunk/server/src/etc/conf/default/bootstrap/profile.xml
===================================================================
--- trunk/server/src/etc/conf/default/bootstrap/profile.xml	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/server/src/etc/conf/default/bootstrap/profile.xml	2009-05-26 10:14:36 UTC (rev 89429)
@@ -92,12 +92,23 @@
 		<property name="checker"><inject bean="StructureModificationChecker" /></property>
 	</bean>
 
+	<!-- A persistence factory for creating the persisted format of ManagedComponents -->
+	<bean name="PersistenceFactory" class="org.jboss.system.server.profileservice.persistence.AbstractPersistenceFactory">
+		<constructor><parameter><inject bean="ManagedObjectFactory" /></parameter></constructor>
+		<!-- Accept any ComponentMapper -->
+		<incallback method="addComponentMapper" />
+		<uncallback method="removeComponentMapper" />
+		<!-- Accept any ManagedObjectPersistencePlugin -->
+		<incallback method="addPersistencePlugin" />
+		<uncallback method="removePersistencePlugin" />
+	</bean>
+
 	<!-- The attachment store -->
 	<bean name="AttachmentStore" class="org.jboss.system.server.profileservice.repository.AbstractAttachmentStore">
 		<constructor><parameter><inject bean="BootstrapProfileFactory" property="attachmentStoreRoot" /></parameter></constructor>
 		<property name="mainDeployer"><inject bean="MainDeployer" /></property>
 		<property name="serializer"><inject bean="AttachmentsSerializer" /></property>
-		<property name="metaDataFilter"><bean class="org.jboss.system.server.profile.basic.XmlIncludeVirtualFileFilter" /></property>
+		<property name="persistenceFactory"><inject bean="PersistenceFactory" /></property>
 	</bean>
 
 	<bean name="AttachmentsSerializer" class="org.jboss.system.server.profileservice.repository.JAXBAttachmentSerializer">
@@ -109,8 +120,18 @@
 		<property name="attachmentStore"><inject bean="AttachmentStore" /></property>
 	</bean>
 
-   <bean name="ProfileServicePersistenceDeployer" class="org.jboss.system.server.profileservice.persistence.deployer.ProfileServicePersistenceDeployer" />
-
+	<bean name="ProfileServicePersistenceDeployer" class="org.jboss.system.server.profileservice.persistence.deployer.ProfileServicePersistenceDeployer">
+   		<property name="persistenceFactory"><inject bean="PersistenceFactory" /></property>
+   		<property name="attachmentStore"><inject bean="AttachmentStore" /></property>
+   </bean>
+   
+   <bean name="KernelDeploymentComponentMapper" class="org.jboss.deployers.plugins.managed.KernelDeploymentComponentMapper">
+   		<constructor><parameter><inject bean="PersistenceFactory" /></parameter></constructor>
+   </bean>
+   <bean name="ServiceDeploymentComponentMapper" class="org.jboss.system.deployers.managed.ServiceDeploymentComponentMapper">
+   		<constructor><parameter><inject bean="PersistenceFactory" /></parameter></constructor>
+   </bean>
+   
 	<!-- A filter for excluding files from the scanner -->
 	<bean name="DeploymentFilter" class="org.jboss.virtual.plugins.vfs.helpers.ExtensibleFilter">
 		<!-- Files starting with theses strings are ignored -->

Modified: trunk/system/.classpath
===================================================================
--- trunk/system/.classpath	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/system/.classpath	2009-05-26 10:14:36 UTC (rev 89429)
@@ -1,45 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
 <classpath>
-  <classpathentry kind="src" path="src/main"/>
-  <classpathentry kind="src" path="src/resources" including="dtd/**" excluding="**/*.java"/>
-  <classpathentry kind="output" path="target/classes"/>
-  <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
-  <classpathentry kind="var" path="M2_REPO/javax/activation/activation/1.1/activation-1.1.jar" sourcepath="M2_REPO/javax/activation/activation/1.1/activation-1.1-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/apache/ant/ant/1.7.1/ant-1.7.1.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/apache/ant/ant-launcher/1.7.1/ant-launcher-1.7.1.jar"/>
-  <classpathentry kind="var" path="M2_REPO/javassist/javassist/3.9.0.GA/javassist-3.9.0.GA.jar" sourcepath="M2_REPO/javassist/javassist/3.9.0.GA/javassist-3.9.0.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/sun-jaxb/jaxb-api/2.1.9/jaxb-api-2.1.9.jar" sourcepath="M2_REPO/sun-jaxb/jaxb-api/2.1.9/jaxb-api-2.1.9-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/aop/jboss-aop/2.1.0.CR2/jboss-aop-2.1.0.CR2.jar" sourcepath="M2_REPO/org/jboss/aop/jboss-aop/2.1.0.CR2/jboss-aop-2.1.0.CR2-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/microcontainer/jboss-aop-mc-int/2.0.4.GA/jboss-aop-mc-int-2.0.4.GA.jar" sourcepath="M2_REPO/org/jboss/microcontainer/jboss-aop-mc-int/2.0.4.GA/jboss-aop-mc-int-2.0.4.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/bootstrap/jboss-bootstrap/1.0.0-Beta-2/jboss-bootstrap-1.0.0-Beta-2.jar" sourcepath="M2_REPO/org/jboss/bootstrap/jboss-bootstrap/1.0.0-Beta-2/jboss-bootstrap-1.0.0-Beta-2-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/cl/jboss-classloader/2.0.3.GA/jboss-classloader-2.0.3.GA.jar" sourcepath="M2_REPO/org/jboss/cl/jboss-classloader/2.0.3.GA/jboss-classloader-2.0.3.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/cl/jboss-classloading/2.0.3.GA/jboss-classloading-2.0.3.GA.jar" sourcepath="M2_REPO/org/jboss/cl/jboss-classloading/2.0.3.GA/jboss-classloading-2.0.3.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/integration/jboss-classloading-spi/5.1.0.CR4/jboss-classloading-spi-5.1.0.CR4.jar" sourcepath="M2_REPO/org/jboss/integration/jboss-classloading-spi/5.1.0.CR4/jboss-classloading-spi-5.1.0.CR4-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/cl/jboss-classloading-vfs/2.0.3.GA/jboss-classloading-vfs-2.0.3.GA.jar" sourcepath="M2_REPO/org/jboss/cl/jboss-classloading-vfs/2.0.3.GA/jboss-classloading-vfs-2.0.3.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-common-core/2.2.12.GA/jboss-common-core-2.2.12.GA.jar" sourcepath="M2_REPO/org/jboss/jboss-common-core/2.2.12.GA/jboss-common-core-2.2.12.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/microcontainer/jboss-dependency/2.0.4.GA/jboss-dependency-2.0.4.GA.jar" sourcepath="M2_REPO/org/jboss/microcontainer/jboss-dependency/2.0.4.GA/jboss-dependency-2.0.4.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/deployers/jboss-deployers-client/2.0.5.GA/jboss-deployers-client-2.0.5.GA.jar" sourcepath="M2_REPO/org/jboss/deployers/jboss-deployers-client/2.0.5.GA/jboss-deployers-client-2.0.5.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/deployers/jboss-deployers-client-spi/2.0.5.GA/jboss-deployers-client-spi-2.0.5.GA.jar" sourcepath="M2_REPO/org/jboss/deployers/jboss-deployers-client-spi/2.0.5.GA/jboss-deployers-client-spi-2.0.5.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/deployers/jboss-deployers-core/2.0.5.GA/jboss-deployers-core-2.0.5.GA.jar" sourcepath="M2_REPO/org/jboss/deployers/jboss-deployers-core/2.0.5.GA/jboss-deployers-core-2.0.5.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/deployers/jboss-deployers-core-spi/2.0.5.GA/jboss-deployers-core-spi-2.0.5.GA.jar" sourcepath="M2_REPO/org/jboss/deployers/jboss-deployers-core-spi/2.0.5.GA/jboss-deployers-core-spi-2.0.5.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/deployers/jboss-deployers-impl/2.0.5.GA/jboss-deployers-impl-2.0.5.GA.jar" sourcepath="M2_REPO/org/jboss/deployers/jboss-deployers-impl/2.0.5.GA/jboss-deployers-impl-2.0.5.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/deployers/jboss-deployers-spi/2.0.5.GA/jboss-deployers-spi-2.0.5.GA.jar" sourcepath="M2_REPO/org/jboss/deployers/jboss-deployers-spi/2.0.5.GA/jboss-deployers-spi-2.0.5.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/deployers/jboss-deployers-structure-spi/2.0.5.GA/jboss-deployers-structure-spi-2.0.5.GA.jar" sourcepath="M2_REPO/org/jboss/deployers/jboss-deployers-structure-spi/2.0.5.GA/jboss-deployers-structure-spi-2.0.5.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/deployers/jboss-deployers-vfs/2.0.5.GA/jboss-deployers-vfs-2.0.5.GA.jar" sourcepath="M2_REPO/org/jboss/deployers/jboss-deployers-vfs/2.0.5.GA/jboss-deployers-vfs-2.0.5.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/deployers/jboss-deployers-vfs-spi/2.0.5.GA/jboss-deployers-vfs-spi-2.0.5.GA.jar" sourcepath="M2_REPO/org/jboss/deployers/jboss-deployers-vfs-spi/2.0.5.GA/jboss-deployers-vfs-spi-2.0.5.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/microcontainer/jboss-kernel/2.0.4.GA/jboss-kernel-2.0.4.GA.jar" sourcepath="M2_REPO/org/jboss/microcontainer/jboss-kernel/2.0.4.GA/jboss-kernel-2.0.4.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/logging/jboss-logging-log4j/2.0.6.GA/jboss-logging-log4j-2.0.6.GA.jar" sourcepath="M2_REPO/org/jboss/logging/jboss-logging-log4j/2.0.6.GA/jboss-logging-log4j-2.0.6.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/logging/jboss-logging-spi/2.0.5.GA/jboss-logging-spi-2.0.5.GA.jar" sourcepath="M2_REPO/org/jboss/logging/jboss-logging-spi/2.0.5.GA/jboss-logging-spi-2.0.5.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/man/jboss-managed/2.1.0.CR8/jboss-managed-2.1.0.CR8.jar" sourcepath="M2_REPO/org/jboss/man/jboss-managed/2.1.0.CR8/jboss-managed-2.1.0.CR8-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-mdr/2.0.1.GA/jboss-mdr-2.0.1.GA.jar" sourcepath="M2_REPO/org/jboss/jboss-mdr/2.0.1.GA/jboss-mdr-2.0.1.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/man/jboss-metatype/2.1.0.CR8/jboss-metatype-2.1.0.CR8.jar" sourcepath="M2_REPO/org/jboss/man/jboss-metatype/2.1.0.CR8/jboss-metatype-2.1.0.CR8-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/integration/jboss-profileservice-spi/5.1.0.CR4/jboss-profileservice-spi-5.1.0.CR4.jar" sourcepath="M2_REPO/org/jboss/integration/jboss-profileservice-spi/5.1.0.CR4/jboss-profileservice-spi-5.1.0.CR4-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-reflect/2.0.2.GA/jboss-reflect-2.0.2.GA.jar" sourcepath="M2_REPO/org/jboss/jboss-reflect/2.0.2.GA/jboss-reflect-2.0.2.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-vfs/2.1.0.GA/jboss-vfs-2.1.0.GA.jar" sourcepath="M2_REPO/org/jboss/jboss-vfs/2.1.0.GA/jboss-vfs-2.1.0.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/jbossxb/2.0.0.GA/jbossxb-2.0.0.GA.jar" sourcepath="M2_REPO/org/jboss/jbossxb/2.0.0.GA/jbossxb-2.0.0.GA-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/junit/junit/3.8.2/junit-3.8.2.jar" sourcepath="M2_REPO/junit/junit/3.8.2/junit-3.8.2-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/log4j/log4j/1.2.14/log4j-1.2.14.jar" sourcepath="M2_REPO/log4j/log4j/1.2.14/log4j-1.2.14-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/qdox/qdox/1.6.1/qdox-1.6.1.jar" sourcepath="M2_REPO/qdox/qdox/1.6.1/qdox-1.6.1-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/stax/stax-api/1.0/stax-api-1.0.jar"/>
-  <classpathentry kind="var" path="M2_REPO/trove/trove/1.0.2/trove-1.0.2.jar"/>
-  <classpathentry kind="var" path="M2_REPO/apache-xerces/xml-apis/2.9.1/xml-apis-2.9.1.jar"/>
-</classpath>
\ No newline at end of file
+	<classpathentry kind="src" path="src/main"/>
+	<classpathentry excluding="**/*.java" including="dtd/**" kind="src" path="src/resources"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="var" path="M2_REPO/javax/activation/activation/1.1/activation-1.1.jar" sourcepath="M2_REPO/javax/activation/activation/1.1/activation-1.1-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/apache/ant/ant/1.7.1/ant-1.7.1.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/apache/ant/ant-launcher/1.7.1/ant-launcher-1.7.1.jar"/>
+	<classpathentry kind="var" path="M2_REPO/javassist/javassist/3.9.0.GA/javassist-3.9.0.GA.jar" sourcepath="M2_REPO/javassist/javassist/3.9.0.GA/javassist-3.9.0.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/sun-jaxb/jaxb-api/2.1.9/jaxb-api-2.1.9.jar" sourcepath="M2_REPO/sun-jaxb/jaxb-api/2.1.9/jaxb-api-2.1.9-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/aop/jboss-aop/2.1.0.CR2/jboss-aop-2.1.0.CR2.jar" sourcepath="M2_REPO/org/jboss/aop/jboss-aop/2.1.0.CR2/jboss-aop-2.1.0.CR2-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/microcontainer/jboss-aop-mc-int/2.0.4.GA/jboss-aop-mc-int-2.0.4.GA.jar" sourcepath="M2_REPO/org/jboss/microcontainer/jboss-aop-mc-int/2.0.4.GA/jboss-aop-mc-int-2.0.4.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/bootstrap/jboss-bootstrap/1.0.0-Beta-2/jboss-bootstrap-1.0.0-Beta-2.jar" sourcepath="M2_REPO/org/jboss/bootstrap/jboss-bootstrap/1.0.0-Beta-2/jboss-bootstrap-1.0.0-Beta-2-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/cl/jboss-classloader/2.0.3.GA/jboss-classloader-2.0.3.GA.jar" sourcepath="M2_REPO/org/jboss/cl/jboss-classloader/2.0.3.GA/jboss-classloader-2.0.3.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/cl/jboss-classloading/2.0.3.GA/jboss-classloading-2.0.3.GA.jar" sourcepath="M2_REPO/org/jboss/cl/jboss-classloading/2.0.3.GA/jboss-classloading-2.0.3.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/integration/jboss-classloading-spi/5.1.0.GA/jboss-classloading-spi-5.1.0.GA.jar" sourcepath="/M2_REPO/org/jboss/integration/jboss-classloading-spi/5.1.0.GA/jboss-classloading-spi-5.1.0.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/cl/jboss-classloading-vfs/2.0.3.GA/jboss-classloading-vfs-2.0.3.GA.jar" sourcepath="M2_REPO/org/jboss/cl/jboss-classloading-vfs/2.0.3.GA/jboss-classloading-vfs-2.0.3.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/jboss-common-core/2.2.12.GA/jboss-common-core-2.2.12.GA.jar" sourcepath="M2_REPO/org/jboss/jboss-common-core/2.2.12.GA/jboss-common-core-2.2.12.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/microcontainer/jboss-dependency/2.0.4.GA/jboss-dependency-2.0.4.GA.jar" sourcepath="M2_REPO/org/jboss/microcontainer/jboss-dependency/2.0.4.GA/jboss-dependency-2.0.4.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/deployers/jboss-deployers-client/2.0.5.GA/jboss-deployers-client-2.0.5.GA.jar" sourcepath="M2_REPO/org/jboss/deployers/jboss-deployers-client/2.0.5.GA/jboss-deployers-client-2.0.5.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/deployers/jboss-deployers-client-spi/2.0.5.GA/jboss-deployers-client-spi-2.0.5.GA.jar" sourcepath="M2_REPO/org/jboss/deployers/jboss-deployers-client-spi/2.0.5.GA/jboss-deployers-client-spi-2.0.5.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/deployers/jboss-deployers-core/2.0.5.GA/jboss-deployers-core-2.0.5.GA.jar" sourcepath="M2_REPO/org/jboss/deployers/jboss-deployers-core/2.0.5.GA/jboss-deployers-core-2.0.5.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/deployers/jboss-deployers-core-spi/2.0.5.GA/jboss-deployers-core-spi-2.0.5.GA.jar" sourcepath="M2_REPO/org/jboss/deployers/jboss-deployers-core-spi/2.0.5.GA/jboss-deployers-core-spi-2.0.5.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/deployers/jboss-deployers-impl/2.0.5.GA/jboss-deployers-impl-2.0.5.GA.jar" sourcepath="M2_REPO/org/jboss/deployers/jboss-deployers-impl/2.0.5.GA/jboss-deployers-impl-2.0.5.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/deployers/jboss-deployers-spi/2.0.5.GA/jboss-deployers-spi-2.0.5.GA.jar" sourcepath="M2_REPO/org/jboss/deployers/jboss-deployers-spi/2.0.5.GA/jboss-deployers-spi-2.0.5.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/deployers/jboss-deployers-structure-spi/2.0.5.GA/jboss-deployers-structure-spi-2.0.5.GA.jar" sourcepath="M2_REPO/org/jboss/deployers/jboss-deployers-structure-spi/2.0.5.GA/jboss-deployers-structure-spi-2.0.5.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/deployers/jboss-deployers-vfs/2.0.5.GA/jboss-deployers-vfs-2.0.5.GA.jar" sourcepath="M2_REPO/org/jboss/deployers/jboss-deployers-vfs/2.0.5.GA/jboss-deployers-vfs-2.0.5.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/deployers/jboss-deployers-vfs-spi/2.0.5.GA/jboss-deployers-vfs-spi-2.0.5.GA.jar" sourcepath="M2_REPO/org/jboss/deployers/jboss-deployers-vfs-spi/2.0.5.GA/jboss-deployers-vfs-spi-2.0.5.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/microcontainer/jboss-kernel/2.0.4.GA/jboss-kernel-2.0.4.GA.jar" sourcepath="M2_REPO/org/jboss/microcontainer/jboss-kernel/2.0.4.GA/jboss-kernel-2.0.4.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/logging/jboss-logging-log4j/2.0.6.GA/jboss-logging-log4j-2.0.6.GA.jar" sourcepath="M2_REPO/org/jboss/logging/jboss-logging-log4j/2.0.6.GA/jboss-logging-log4j-2.0.6.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/logging/jboss-logging-spi/2.0.5.GA/jboss-logging-spi-2.0.5.GA.jar" sourcepath="M2_REPO/org/jboss/logging/jboss-logging-spi/2.0.5.GA/jboss-logging-spi-2.0.5.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/man/jboss-managed/2.1.0.GA/jboss-managed-2.1.0.GA.jar" sourcepath="/M2_REPO/org/jboss/man/jboss-managed/2.1.0.CR8/jboss-managed-2.1.0.CR8-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/jboss-mdr/2.0.1.GA/jboss-mdr-2.0.1.GA.jar" sourcepath="M2_REPO/org/jboss/jboss-mdr/2.0.1.GA/jboss-mdr-2.0.1.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/man/jboss-metatype/2.1.0.GA/jboss-metatype-2.1.0.GA.jar" sourcepath="/M2_REPO/org/jboss/man/jboss-metatype/2.1.0.GA/jboss-metatype-2.1.0.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/integration/jboss-profileservice-spi/5.1.0.GA/jboss-profileservice-spi-5.1.0.GA.jar" sourcepath="/M2_REPO/org/jboss/integration/jboss-profileservice-spi/5.1.0.GA/jboss-profileservice-spi-5.1.0.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/jboss-reflect/2.0.2.GA/jboss-reflect-2.0.2.GA.jar" sourcepath="M2_REPO/org/jboss/jboss-reflect/2.0.2.GA/jboss-reflect-2.0.2.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/jboss-vfs/2.1.0.GA/jboss-vfs-2.1.0.GA.jar" sourcepath="M2_REPO/org/jboss/jboss-vfs/2.1.0.GA/jboss-vfs-2.1.0.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/jbossxb/2.0.0.GA/jbossxb-2.0.0.GA.jar" sourcepath="M2_REPO/org/jboss/jbossxb/2.0.0.GA/jbossxb-2.0.0.GA-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/junit/junit/3.8.2/junit-3.8.2.jar" sourcepath="M2_REPO/junit/junit/3.8.2/junit-3.8.2-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/log4j/log4j/1.2.14/log4j-1.2.14.jar" sourcepath="M2_REPO/log4j/log4j/1.2.14/log4j-1.2.14-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/qdox/qdox/1.6.1/qdox-1.6.1.jar" sourcepath="M2_REPO/qdox/qdox/1.6.1/qdox-1.6.1-sources.jar"/>
+	<classpathentry kind="var" path="M2_REPO/stax/stax-api/1.0/stax-api-1.0.jar"/>
+	<classpathentry kind="var" path="M2_REPO/trove/trove/1.0.2/trove-1.0.2.jar"/>
+	<classpathentry kind="var" path="M2_REPO/apache-xerces/xml-apis/2.9.1/xml-apis-2.9.1.jar"/>
+	<classpathentry kind="output" path="target/classes"/>
+</classpath>

Modified: trunk/system/src/main/org/jboss/deployers/plugins/managed/BeanMetaDataICF.java
===================================================================
--- trunk/system/src/main/org/jboss/deployers/plugins/managed/BeanMetaDataICF.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/system/src/main/org/jboss/deployers/plugins/managed/BeanMetaDataICF.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -28,8 +28,10 @@
 import org.jboss.beans.info.spi.PropertyInfo;
 import org.jboss.beans.metadata.spi.AnnotationMetaData;
 import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.PropertyMetaData;
 import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
 import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.kernel.plugins.config.Configurator;
 import org.jboss.kernel.spi.dependency.KernelController;
 import org.jboss.logging.Logger;
 import org.jboss.managed.api.Fields;
@@ -181,7 +183,6 @@
          propertyInfo = beanInfo.getProperty(name);
       
       Object bean = locateBean(attachment.getName());
-      Object value = null;
       MetaValue mvalue = null;
       if(propertyInfo.isReadable() == false)
       {
@@ -194,10 +195,40 @@
       {
          String getterClassName = propertyInfo.getGetter().getDeclaringClass().getName();
          if(getterClassName.equals(attachment.getClass().getName()))
+         {
+            // use attachment
             mvalue = delegateICF.getValue(beanInfo, property, metaData, attachment);
+         }
+         else if(bean != null)
+         {
+            // use bean (if installed)
+            mvalue = delegateICF.getValue(beanInfo, property, metaData, bean);
+         }
          else
-            mvalue = delegateICF.getValue(beanInfo, property, metaData, bean);
-            
+         {
+            // Try to find the property in the meta data
+            PropertyMetaData md = null;
+            if(attachment.getProperties() != null && attachment.getProperties().isEmpty() == false)
+            {
+               for(PropertyMetaData bp : attachment.getProperties())
+               {
+                  if(name.equals(bp.getName()))
+                  {
+                     md = bp;
+                     break;
+                  }
+               }
+               if(md != null)
+               {
+                  // TODO add metaMapping
+                  if(md.getValue() != null)
+                  {
+                     mvalue = metaValueFactory.create(md.getValue().getUnderlyingValue(),
+                           propertyInfo.getType());
+                  }
+               }
+            }
+         }
       }
       catch(Throwable e)
       {
@@ -240,7 +271,7 @@
          Object plainValue = unwrapValue(property, propertyInfo.getType(), value);
          Object bean = locateBean(beanName);
          
-         // Only update if the bean is not null
+         // Only update the bean if installed
          if(bean != null)
             propertyInfo.set(bean, plainValue);
          
@@ -260,7 +291,15 @@
 
    protected ClassLoader getClassLoader(BeanMetaData bmd)
    {
-      ClassLoader loader = null; //Configurator.getClassLoader(bmd);
+      ClassLoader loader = null;
+      try
+      {
+         loader = Configurator.getClassLoader(bmd);
+      }
+      catch(Throwable t)
+      {
+         log.debug("Failed to load BeanMetaData class loader", t);
+      }
       // Fallback to TCL if there is no
       if(loader == null)
          loader = SecurityActions.getContextClassLoader();
@@ -277,4 +316,5 @@
       }
       return metaValueFactory.unwrap(value, typeInfo);
    }
+   
 }

Modified: trunk/system/src/main/org/jboss/deployers/plugins/managed/DefaultManagedObjectCreator.java
===================================================================
--- trunk/system/src/main/org/jboss/deployers/plugins/managed/DefaultManagedObjectCreator.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/system/src/main/org/jboss/deployers/plugins/managed/DefaultManagedObjectCreator.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -38,7 +38,7 @@
  * Default managed object creator.
  *
  * @author Scott.Stark at jboss.org
- * @version $Revision:$
+ * @version $Revision$
  */
 public class DefaultManagedObjectCreator implements ManagedObjectCreator
 {

Added: trunk/system/src/main/org/jboss/deployers/plugins/managed/KernelDeploymentComponentMapper.java
===================================================================
--- trunk/system/src/main/org/jboss/deployers/plugins/managed/KernelDeploymentComponentMapper.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/deployers/plugins/managed/KernelDeploymentComponentMapper.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -0,0 +1,143 @@
+/*
+ * 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.deployers.plugins.managed;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.BeanMetaDataFactory;
+import org.jboss.kernel.plugins.deployment.AbstractKernelDeployment;
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.metadata.spi.MetaData;
+import org.jboss.system.server.profileservice.persistence.PersistenceFactory;
+import org.jboss.system.server.profileservice.persistence.component.AbstractComponentMapper;
+import org.jboss.system.server.profileservice.persistence.xml.PersistedComponent;
+
+/**
+ * A AbstractKernelDeployment persistence ComponentMapper.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class KernelDeploymentComponentMapper extends AbstractComponentMapper
+{
+
+   public KernelDeploymentComponentMapper(PersistenceFactory persistenceFactory)
+   {
+      super(persistenceFactory);
+   }
+
+   @Override
+   protected void setComponentName(PersistedComponent component, ManagedObject mo)
+   {
+      BeanMetaData bmd = (BeanMetaData) mo.getAttachment();
+      // Set the current name
+      component.setName(bmd.getName());
+   }
+   
+   @Override
+   protected ManagedObject getComponent(Object attachment, PersistedComponent component, boolean create)
+   {
+      AbstractKernelDeployment deployment = (AbstractKernelDeployment) attachment;
+      Map<String, BeanMetaData> beans = new HashMap<String, BeanMetaData>();
+      for(BeanMetaData bmd : deployment.getBeans())
+      {
+         beans.put(bmd.getName(), bmd);
+      }
+      BeanMetaData bmd = beans.get(component.getOriginalName());
+      // Create a new Bean
+      if(bmd == null && create)
+      {
+         AbstractBeanMetaData bean = createEmptyBeanMetaData(component);
+         if(deployment.getBeanFactories() == null)
+            deployment.setBeanFactories(new ArrayList<BeanMetaDataFactory>());
+         
+         deployment.getBeanFactories().add(bean);
+         bmd = bean;
+      }
+      if(bmd == null)
+      {
+         throw new IllegalStateException("Could not find bean: " + component.getOriginalName());
+      }
+      // TODO we need the MetaData here!
+      MetaData metaData = null;
+      return getMOF().initManagedObject(bmd, metaData);
+   }
+
+   @Override
+   protected void removeComponent(Object attachment, PersistedComponent component)
+   {
+      AbstractKernelDeployment deployment = (AbstractKernelDeployment) attachment;
+      if(deployment.getBeanFactories() != null && deployment.getBeanFactories().isEmpty() == false)
+      {
+         boolean removed = false;
+         List<BeanMetaDataFactory> beanFactories = new ArrayList<BeanMetaDataFactory>();
+         for(BeanMetaDataFactory bmdf : deployment.getBeanFactories())
+         {
+            if(bmdf instanceof AbstractBeanMetaData)
+            {
+               AbstractBeanMetaData bean = (AbstractBeanMetaData) bmdf;
+               if(bean.getName().equals(component.getOriginalName()))
+               {
+                  removed = true;
+               }
+               else
+               {
+                  beanFactories.add(bmdf);                  
+               }
+            }
+            else
+            {
+               beanFactories.add(bmdf);
+            }
+         }
+         if(! removed)
+            throw new IllegalStateException("Could not remove component " + component.getOriginalName());
+         // Update deployment
+         deployment.setBeanFactories(beanFactories);
+      }
+   }
+   
+   protected AbstractBeanMetaData createEmptyBeanMetaData(PersistedComponent component)
+   {
+      AbstractBeanMetaData bean = new AbstractBeanMetaData();
+      bean.setName(component.getOriginalName());
+      // See if we stored the bean class name
+      String beanClassName = component.getTemplateName();
+      if(beanClassName == null)
+         beanClassName = component.getClassName();
+      if(beanClassName != null && beanClassName.equals(AbstractBeanMetaData.class.getName()) == false)
+         bean.setBean(beanClassName);
+      return bean;
+   }
+
+   public String getType()
+   {
+      return AbstractKernelDeployment.class.getName();
+   }
+   
+}
+

Modified: trunk/system/src/main/org/jboss/deployers/plugins/managed/KernelDeploymentManagedObjectCreator.java
===================================================================
--- trunk/system/src/main/org/jboss/deployers/plugins/managed/KernelDeploymentManagedObjectCreator.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/system/src/main/org/jboss/deployers/plugins/managed/KernelDeploymentManagedObjectCreator.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -105,6 +105,10 @@
          }
          managedObjects.put(KernelDeployment.class.getName(), deploymentMO);
       }
+      if(deploymentMO instanceof MutableManagedObject)
+         ((MutableManagedObject) deploymentMO).setName(KernelDeployment.class.getName());
+      if(deploymentMO instanceof ManagedObjectImpl)
+         ((ManagedObjectImpl) deploymentMO).setAttachmentName(KernelDeployment.class.getName());
 
       MetaData metaData = unit.getMetaData();
       // Update the beanFactories value to a list of BeanMetaDataFactory with BeanMetaDatas
@@ -134,6 +138,7 @@
             }
 
             MutableManagedObject bmdfMMO = (MutableManagedObject) bmdfMO;
+            bmdfMMO.setParent(deploymentMO);
             Map<String, ManagedProperty> oldProps = bmdfMMO.getProperties();
             ManagedProperty beansMPCheck = oldProps.get("beans");
             // If there already is a beans property assume it's correct
@@ -167,7 +172,15 @@
                   {
                      // The component managed objects need to be in the root map
                      ManagedObject compMO = (ManagedObject) gv.getValue();
-                     managedObjects.put(compUnit.getName(), compMO);
+                     // Use the ManagedObject name if it's not the same as the attachmentName
+                     String managedObjectName = compUnit.getName();
+                     if(compMO != null && compMO.getAttachmentName() != null)
+                     {
+                        managedObjectName = compMO.getAttachmentName().equals(compMO.getName()) ?
+                              compUnit.getName() : compMO.getName();
+                     }
+                     // Add the managed object 
+                     managedObjects.put(managedObjectName, compMO);
                      // Add the bean MO to the beans list
                      tmpBeans.add(gv);
                   }

Modified: trunk/system/src/main/org/jboss/deployers/plugins/managed/TypedManagedDeploymentCreator.java
===================================================================
--- trunk/system/src/main/org/jboss/deployers/plugins/managed/TypedManagedDeploymentCreator.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/system/src/main/org/jboss/deployers/plugins/managed/TypedManagedDeploymentCreator.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -41,8 +41,8 @@
 import org.jboss.managed.api.ManagedDeployment;
 import org.jboss.managed.api.ManagedObject;
 import org.jboss.managed.api.ManagedDeployment.DeploymentPhase;
+import org.jboss.managed.api.annotation.ManagementConstants;
 import org.jboss.managed.api.annotation.ManagementDeployment;
-import org.jboss.managed.api.annotation.ManagementConstants;
 import org.jboss.managed.plugins.ManagedDeploymentImpl;
 
 /**

Modified: trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/FilteredProfileMetaData.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/FilteredProfileMetaData.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/FilteredProfileMetaData.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -25,6 +25,7 @@
 
 import javax.xml.bind.annotation.XmlNsForm;
 import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
 
 import org.jboss.profileservice.spi.metadata.SubProfileMetaData;
 import org.jboss.xb.annotations.JBossXmlSchema;
@@ -38,6 +39,7 @@
  */
 @JBossXmlSchema(namespace="urn:jboss:profileservice:profile:filtered:1.0", elementFormDefault=XmlNsForm.QUALIFIED)
 @XmlRootElement(name = "profile")
+ at XmlType(name = "profileType", propOrder = {"source", "subprofiles", "deployments"})
 public class FilteredProfileMetaData extends BasicProfileMetaData
 {
 

Modified: trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/HotDeploymentProfileMetaData.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/HotDeploymentProfileMetaData.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/HotDeploymentProfileMetaData.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -28,6 +28,7 @@
 import javax.xml.bind.annotation.XmlNsForm;
 import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlTransient;
+import javax.xml.bind.annotation.XmlType;
 
 import org.jboss.profileservice.spi.metadata.ProfileDeploymentMetaData;
 import org.jboss.profileservice.spi.metadata.SubProfileMetaData;
@@ -41,6 +42,7 @@
  */
 @JBossXmlSchema(namespace="urn:jboss:profileservice:profile:hotdeployment:1.0", elementFormDefault=XmlNsForm.QUALIFIED)
 @XmlRootElement(name = "hotdeployment-profile")
+ at XmlType(name = "profileType", propOrder = {"source", "subprofiles"})
 public class HotDeploymentProfileMetaData extends AbstractProfileMetaData
 {
 

Modified: trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/ProfilesMetaData.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/ProfilesMetaData.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/ProfilesMetaData.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -29,6 +29,7 @@
 import javax.xml.bind.annotation.XmlElements;
 import javax.xml.bind.annotation.XmlNsForm;
 import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
 
 import org.jboss.profileservice.spi.metadata.ProfileKeyMetaData;
 import org.jboss.profileservice.spi.metadata.ProfileMetaData;
@@ -48,6 +49,7 @@
       namespace= "urn:jboss:profileservice:profiles:1.0",
       elementFormDefault=XmlNsForm.QUALIFIED,
       normalizeSpace=true)
+ at XmlType(name = "profilesType", propOrder = {"name", "server", "domain", "profiles"})
 public class ProfilesMetaData implements ProfileKeyMetaData
 {
    /** The name. */

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/attachments/AttachmentMetaData.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/attachments/AttachmentMetaData.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/attachments/AttachmentMetaData.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -39,6 +39,9 @@
    
    /** The attachment class name */
    private String className;
+
+   /** The last modified. */
+   private long lastModified;
    
    /** The attachment */
    private transient Object attachment;
@@ -65,6 +68,17 @@
       this.className = className;
    }
 
+   @XmlElement(name = "last-modified")
+   public long getLastModified()
+   {
+      return lastModified;
+   }
+   
+   public void setLastModified(long lastModified)
+   {
+      this.lastModified = lastModified;
+   }
+   
    @XmlTransient
    public Object getAttachment()
    {

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/attachments/AttachmentStore.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/attachments/AttachmentStore.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/attachments/AttachmentStore.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -26,6 +26,8 @@
 import org.jboss.deployers.client.spi.Deployment;
 import org.jboss.managed.api.ManagedComponent;
 import org.jboss.profileservice.spi.ProfileDeployment;
+import org.jboss.system.server.profileservice.persistence.xml.PersistenceRoot;
+import org.jboss.virtual.VirtualFile;
 
 /**
  * The AttachmentStore.
@@ -42,32 +44,51 @@
     * @return the attachment store root
     */
    URI getAttachmentStoreRoot();
-   
+
    /**
-    * Persist the changes of the managed component.
+    * Load the repository attachment meta data
     * 
-    * @param deployment the profile deployment
-    * @param comp the managed component
+    * @param deploymentCtx the deployment root
+    * @return the persisted meta data or null if it does not exist
     * @throws Exception
     */
-   void updateDeployment(ProfileDeployment deployment, ManagedComponent comp) throws Exception;
-   
+   RepositoryAttachmentMetaData loadMetaData(VirtualFile deploymentCtx) throws Exception;
+
    /**
-    * Remove a component from the persisted attachment.
+    * Load a attachment.
     * 
-    * @param deployment the profile deployment
+    * @param deploymentCtx
+    * @param attachment
+    * @return
+    * @throws Exception
+    */
+   PersistenceRoot loadAttachment(VirtualFile deploymentCtx, AttachmentMetaData attachment) throws Exception;
+
+   /**
+    * Persist the managed component.
+    * 
+    * @param ctx the deployment context name
     * @param comp the managed componenbt
     * @throws Exception
     */
-   void removeComponent(ProfileDeployment deployment, ManagedComponent comp) throws Exception;
+   void updateDeployment(String ctx, ManagedComponent comp) throws Exception;
+
+   /**
+    * Remove a component from the attachment.
+    * 
+    * @param ctx the deployment context name
+    * @param comp the managed componenbt
+    * @throws Exception
+    */
+   void removeComponent(String ctx, ManagedComponent comp) throws Exception;
    
    /**
-    * Create the deployment with the persisted attachments.
+    * Create a MC deployment.
     * 
-    * @param deployment the profile deployment
-    * @return the mc deployment
+    * @param deployment
+    * @return
     * @throws Exception
     */
-   Deployment loadDeploymentData(ProfileDeployment deployment) throws Exception;
+   Deployment createDeployment(ProfileDeployment deployment) throws Exception;
    
 }

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/attachments/LazyPredeterminedManagedObjects.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/attachments/LazyPredeterminedManagedObjects.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/attachments/LazyPredeterminedManagedObjects.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -28,7 +28,7 @@
 import org.jboss.deployers.spi.attachments.AttachmentsFactory;
 import org.jboss.deployers.spi.attachments.MutableAttachments;
 import org.jboss.system.server.profileservice.persistence.deployer.ProfileServicePersistenceDeployer;
-import org.jboss.system.server.profileservice.persistence.xml.PersistedManagedObject;
+import org.jboss.system.server.profileservice.persistence.xml.PersistenceRoot;
 import org.jboss.system.server.profileservice.repository.AbstractFileAttachmentsSerializer;
 
 /**
@@ -180,7 +180,7 @@
       return attachments.contains(name.substring(ProfileServicePersistenceDeployer.PERSISTED_ATTACHMENT_PREFIX.length()));
    }
 
-   private PersistedManagedObject loadAttachment(String name)
+   private PersistenceRoot loadAttachment(String name)
    {
       if(! ishandleAttachment(name))
          return null;
@@ -191,7 +191,7 @@
          // deploy/deployment/child/attachmentName
          String attachmentName = relativePath + attachmentClassName;
          // Load attachment
-         return serializer.loadAttachment(attachmentName, PersistedManagedObject.class);
+         return serializer.loadAttachment(attachmentName, PersistenceRoot.class);
       }
       catch(Exception e)
       {

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/attachments/RepositoryAttachmentMetaData.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/attachments/RepositoryAttachmentMetaData.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/attachments/RepositoryAttachmentMetaData.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -28,6 +28,7 @@
 import javax.xml.bind.annotation.XmlNsForm;
 import javax.xml.bind.annotation.XmlRootElement;
 
+import org.jboss.system.server.profileservice.persistence.PersistenceConstants;
 import org.jboss.xb.annotations.JBossXmlSchema;
 
 /**
@@ -36,7 +37,7 @@
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
  * @version $Revision$
  */
- at JBossXmlSchema(namespace = "urn:org:jboss:profileservice:attachments:1.0", elementFormDefault = XmlNsForm.QUALIFIED,
+ at JBossXmlSchema(namespace = PersistenceConstants.REPOSITORY_NAMESPACE_1_0, elementFormDefault = XmlNsForm.QUALIFIED,
       xmlns = { @XmlNs(namespaceURI = "http://www.w3.org/2001/XMLSchema", prefix = "xs") })
 @XmlRootElement(name = "attachments-metadata")
 public class RepositoryAttachmentMetaData

Added: trunk/system/src/main/org/jboss/system/server/profileservice/persistence/AbstractManagedObjectPersistence.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/persistence/AbstractManagedObjectPersistence.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/persistence/AbstractManagedObjectPersistence.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -0,0 +1,326 @@
+/*
+ * 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.system.server.profileservice.persistence;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.beans.info.spi.PropertyInfo;
+import org.jboss.logging.Logger;
+import org.jboss.managed.api.Fields;
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.managed.api.annotation.ViewUse;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.system.server.profileservice.persistence.xml.PersistedManagedObject;
+import org.jboss.system.server.profileservice.persistence.xml.PersistedProperty;
+import org.jboss.system.server.profileservice.persistence.xml.PersistedValue;
+
+/**
+ * A abstract ManagedObject persistence helper.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public abstract class AbstractManagedObjectPersistence 
+{
+
+   /** The logger. */
+   private static final Logger log = Logger.getLogger(AbstractManagedObjectPersistence.class);
+   
+   /** The value persistence. */
+   private final AbstractValuePersistence valuePersistence;
+   
+   protected AbstractManagedObjectPersistence(AbstractValuePersistence valuePersistence)
+   {
+      if(valuePersistence == null)
+         throw new IllegalArgumentException("null value persistence.");
+      
+      this.valuePersistence = valuePersistence;
+   }
+   
+   public AbstractValuePersistence getValuePersistence()
+   {
+      return valuePersistence;
+   }
+   
+   /**
+    * Create a persisted managed object.
+    * 
+    * @param mo the managed object
+    * @return the persistence xml meta data for managed object
+    */
+   public PersistedManagedObject createPersistedManagedObject(ManagedObject mo)
+   {
+      PersistedManagedObject persisted = new PersistedManagedObject();
+      return createPersistedManagedObject(persisted, mo);
+   }
+   
+   /**
+    * Process a managed object.
+    * 
+    * @param persisted the xml meta data
+    * @param mo the managed object
+    * @return isModified
+    */
+   public PersistedManagedObject createPersistedManagedObject(PersistedManagedObject persisted, ManagedObject mo)
+   {
+      if(persisted == null)
+         throw new IllegalArgumentException("Null persisted managed object.");
+      if(mo == null)
+         throw new IllegalArgumentException("Null managed object");
+      
+      // Set the template and class-name 
+      String className = mo.getAttachmentName();
+      if(mo.getAttachment() != null)
+      {
+         Class<?> attachment = mo.getAttachment().getClass();
+         className = attachment.getName();
+         // Set the template name
+         if(className.equals(mo.getAttachmentName()) == false)
+         {
+            // If the MO template is different from the actual attachment
+            persisted.setTemplateName(mo.getAttachmentName());
+         }
+      }
+      String name = mo.getName();
+      if(mo.getComponentName() != null && mo.getComponentName() instanceof String)
+         name = (String) mo.getComponentName();
+      
+      if(persisted.getOriginalName() == null)
+         persisted.setOriginalName(name);
+
+      // Set the managed-object meta information
+      persisted.setName(name);
+      persisted.setClassName(className);
+
+      return persisted;
+   }
+
+   /**
+    * Process the properties of the ManagedObject.
+    * 
+    * @param persisted the persisted managed object
+    * @param mo the managed object
+    */
+   protected void processProperties(PersistedManagedObject persisted, ManagedObject mo)
+   {
+      boolean trace = log.isTraceEnabled();
+      processProperties(persisted, mo, trace);
+   }
+   
+   /**
+    * Process the properties of the ManagedObject.
+    * 
+    * @param persisted the persisted managed object
+    * @param mo the managed object
+    * @param trace enable trace logs
+    */
+   protected void processProperties(PersistedManagedObject persisted, ManagedObject mo, boolean trace)
+   {
+      if(persisted == null)
+         throw new IllegalArgumentException("Null persisted object");
+      if(mo == null)
+         throw new IllegalArgumentException("Null managed object.");
+     
+      //
+      Map<String, PersistedProperty> properties = getPersistedProperties(persisted);
+      for(String propertyName : mo.getPropertyNames())
+      {
+         //
+         ManagedProperty property = mo.getProperty(propertyName);
+         PersistedProperty persistedProperty = properties.get(propertyName);
+         
+         if(persistedProperty == null)
+         {
+            // Create a new persisted property
+            persistedProperty = createPersistedProperty(property);
+         }
+         
+         // Process
+         if(processProperty(property, persistedProperty, trace))
+         {
+            persisted.getProperties().add(persistedProperty);
+         }
+      }
+   }
+   
+   /**
+    * Create a persisted property.
+    * 
+    * @param property the managed Property.
+    * @param persisted
+    * @return
+    */
+   protected PersistedProperty createPersistedProperty(ManagedProperty property)
+   {
+      if(property == null)
+         throw new IllegalArgumentException("Null managed property.");
+      
+      PersistedProperty persisted = new PersistedProperty();
+      persisted.setName(property.getName());
+      return persisted;
+   }
+
+   /**
+    * Process a managed property.
+    * 
+    * @param property the managed property
+    * @param persisted the persisted property
+    * @return true, if the property was processed
+    */
+   protected boolean processProperty(ManagedProperty property, PersistedProperty persisted)
+   {
+      boolean trace = log.isTraceEnabled();
+      return processProperty(property, persisted, trace);
+   }
+   
+   /**
+    * Process a managed property.
+    * 
+    * @param property the managed property
+    * @param persisted the persisted property
+    * @param trace enable trace logs
+    * @return true, if the property was processed
+    */   
+   protected boolean processProperty(ManagedProperty property, PersistedProperty persisted, boolean trace)
+   {
+      if(property == null)
+         throw new IllegalArgumentException("Null managed property.");
+      if(persisted == null)
+         throw new IllegalArgumentException("Null persisted property.");
+      
+      boolean processed = false;
+      // Check if we need to process this property
+      if(isProcessProperty(property, trace))
+      {
+         // 
+         MetaValue metaValue = property.getField(Fields.VALUE, MetaValue.class);
+         MetaType metaType = property.getField(Fields.META_TYPE, MetaType.class);
+         // Override metaType
+         if(metaValue != null)
+            metaType = metaValue.getMetaType();
+         
+         // Create the persisted value
+         PersistedValue value = createPersistedValue(metaValue, metaType, persisted.getValue());
+         if(value != null)
+         {
+            persisted.setValue(value);
+            if(trace)
+               log.trace("value for property ("+ property.getName() +"): " + value);
+            processed = true;
+         }
+      }
+      return processed;
+   }
+   
+   /**
+    * Create a persisted value. This delegates the value creation
+    * to the ValuePeristence.
+    * 
+    * @param metaValue the meta value
+    * @param metaType the meta type
+    * @param persisted the persisted value
+    * @return the created persisted value
+    */
+   private PersistedValue createPersistedValue(MetaValue metaValue, MetaType metaType, PersistedValue persisted)
+   {
+      return getValuePersistence().createPersistedValue(metaValue, metaType, persisted);
+   }
+   
+   /**
+    * Does this property needs to be processed.
+    * 
+    * @param property the managed property
+    * @param trace enable trace logs
+    * @return false if the property does not need to be processed otherwise true
+    */
+   protected boolean isProcessProperty(ManagedProperty property, boolean trace)
+   {
+      boolean process = false;
+      // 
+      if(property == null)
+         return process;
+      
+      // Skip non configuration properties
+      if(property.hasViewUse(ViewUse.CONFIGURATION) == false)
+      {
+         if(trace)
+            log.trace("Skip non configuration property: " + property.getName());
+         return process;
+      }
+      // Skip read only properties
+      if(property.isReadOnly())
+      {
+         if(trace)
+            log.trace("Skip readOnly property: " + property.getName());
+         return process;
+      }
+      // Skip removed properties
+      if(property.isRemoved())
+      {
+         if(trace)
+            log.trace("Skip removed property: " + property.getName());
+         return process;
+      }
+      // Skip read only properties
+      PropertyInfo propertyInfo = property.getField(Fields.PROPERTY_INFO, PropertyInfo.class);
+      if(propertyInfo != null && propertyInfo.isReadable() == false)
+      {
+         if(trace)
+            log.trace("Skip non readable property: " + property.getName());
+         return process;
+      }      
+      return true;
+   }
+   
+   /**
+    * Get a map of persisted managed objects, with the property name as key.
+    * 
+    * @param persisted the persisted managed object
+    * @return a map of persisted properties
+    */
+   protected static Map<String, PersistedProperty> getPersistedProperties(PersistedManagedObject persisted)
+   {
+      if(persisted == null)
+         throw new IllegalArgumentException("Null persisted managed object.");
+      
+      Map<String, PersistedProperty> properties = new HashMap<String, PersistedProperty>();
+      List<PersistedProperty> list = persisted.getProperties();
+      if(list == null)
+      {
+         list = new ArrayList<PersistedProperty>();
+         persisted.setProperties(list);
+      }
+      if(list.isEmpty() == false)
+      {
+         for(PersistedProperty p : list)
+            properties.put(p.getName(), p);
+      }
+      return properties;
+   }
+   
+}
+

Deleted: trunk/system/src/main/org/jboss/system/server/profileservice/persistence/AbstractManagedObjectPersistencePlugin.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/persistence/AbstractManagedObjectPersistencePlugin.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/persistence/AbstractManagedObjectPersistencePlugin.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -1,328 +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.system.server.profileservice.persistence;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.jboss.beans.info.spi.PropertyInfo;
-import org.jboss.logging.Logger;
-import org.jboss.managed.api.Fields;
-import org.jboss.managed.api.ManagedObject;
-import org.jboss.managed.api.ManagedProperty;
-import org.jboss.managed.api.annotation.ViewUse;
-import org.jboss.metatype.api.types.MetaType;
-import org.jboss.metatype.api.values.MetaValue;
-import org.jboss.system.server.profileservice.persistence.xml.PersistedManagedObject;
-import org.jboss.system.server.profileservice.persistence.xml.PersistedProperty;
-import org.jboss.system.server.profileservice.persistence.xml.PersistedValue;
-
-/**
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public abstract class AbstractManagedObjectPersistencePlugin implements ManagedObjectPersistencePlugin 
-{
-
-   /** The logger. */
-   private static final Logger log = Logger.getLogger(AbstractManagedObjectPersistencePlugin.class);
-   
-   /** The value persistence. */
-   private AbstractValuePersistence valuePersistence;
-   
-   public AbstractValuePersistence getValuePersistence()
-   {
-      return valuePersistence;
-   }
-   
-   public void setValuePersistence(AbstractValuePersistence valuePersistence)
-   {
-      if(valuePersistence == null)
-         throw new IllegalArgumentException("null value persistence.");
-      
-      this.valuePersistence = valuePersistence;
-   }
-   
-   /**
-    * Get the type for this plugin.
-    * 
-    * @return the type
-    */
-   public abstract String getType();
-   
-   /**
-    * Create a persisted managed object.
-    * 
-    * @param mo the managed object
-    * @return the persistence xml meta data for managed object
-    */
-   public PersistedManagedObject createPersistedManagedObject(ManagedObject mo)
-   {
-      PersistedManagedObject persisted = new PersistedManagedObject();
-      persisted.setOriginalName(mo.getName());
-      return createPersistedManagedObject(persisted, mo);
-   }
-   
-   /**
-    * Process a managed object.
-    * 
-    * @param persisted the xml meta data
-    * @param mo the managed object
-    * @return isModified
-    */
-   public PersistedManagedObject createPersistedManagedObject(PersistedManagedObject persisted, ManagedObject mo)
-   {
-      if(persisted == null)
-         throw new IllegalArgumentException("Null persisted managed object.");
-      if(mo == null)
-         throw new IllegalArgumentException("Null managed object");
-      
-      // Set the template and class-name 
-      String className = mo.getAttachmentName();
-      if(mo.getAttachment() != null)
-      {
-         Class<?> attachment = mo.getAttachment().getClass();
-         className = attachment.getName();
-         // Set the template name
-         if(className.equals(mo.getAttachmentName()) == false)
-         {
-            // If the MO template is different from the actual attachment
-            persisted.setTemplateName(mo.getAttachmentName());
-         }
-      }
-      if(persisted.getOriginalName() == null)
-         persisted.setOriginalName(mo.getName());
-
-      // Set the managed-object meta information
-      persisted.setName(mo.getName());
-      persisted.setClassName(className);
-
-      return persisted;
-   }
-
-   /**
-    * Process the properties of the ManagedObject.
-    * 
-    * @param persisted the persisted managed object
-    * @param mo the managed object
-    */
-   protected void processProperties(PersistedManagedObject persisted, ManagedObject mo)
-   {
-      boolean trace = log.isTraceEnabled();
-      processProperties(persisted, mo, trace);
-   }
-   
-   /**
-    * Process the properties of the ManagedObject.
-    * 
-    * @param persisted the persisted managed object
-    * @param mo the managed object
-    * @param trace enable trace logs
-    */
-   protected void processProperties(PersistedManagedObject persisted, ManagedObject mo, boolean trace)
-   {
-      if(persisted == null)
-         throw new IllegalArgumentException("Null persisted object");
-      if(mo == null)
-         throw new IllegalArgumentException("Null managed object.");
-     
-      //
-      Map<String, PersistedProperty> properties = getPersistedProperties(persisted);
-      for(String propertyName : mo.getPropertyNames())
-      {
-         //
-         ManagedProperty property = mo.getProperty(propertyName);
-         PersistedProperty persistedProperty = properties.get(propertyName);
-         
-         if(persistedProperty == null)
-         {
-            // Create a new peristed property
-            persistedProperty = createPersistedProperty(property);
-         }
-         
-         // Process
-         if(processProperty(property, persistedProperty, trace))
-         {
-            persisted.getProperties().add(persistedProperty);
-         }
-      }
-   }
-   
-   /**
-    * Create a persisted property.
-    * 
-    * @param property the managed Property.
-    * @param persisted
-    * @return
-    */
-   protected PersistedProperty createPersistedProperty(ManagedProperty property)
-   {
-      if(property == null)
-         throw new IllegalArgumentException("Null managed property.");
-      
-      PersistedProperty persisted = new PersistedProperty();
-      persisted.setName(property.getName());
-      return persisted;
-   }
-
-   /**
-    * Process a managed property.
-    * 
-    * @param property the managed property
-    * @param persisted the persisted property
-    * @return true, if the property was processed
-    */
-   protected boolean processProperty(ManagedProperty property, PersistedProperty persisted)
-   {
-      boolean trace = log.isTraceEnabled();
-      return processProperty(property, persisted, trace);
-   }
-   
-   /**
-    * Process a managed property.
-    * 
-    * @param property the managed property
-    * @param persisted the persisted property
-    * @param trace enable trace logs
-    * @return true, if the property was processed
-    */   
-   protected boolean processProperty(ManagedProperty property, PersistedProperty persisted, boolean trace)
-   {
-      if(property == null)
-         throw new IllegalArgumentException("Null managed property.");
-      if(persisted == null)
-         throw new IllegalArgumentException("Null persisted property.");
-      
-      boolean processed = false;
-      // Check if we need to process this property
-      if(isProcessProperty(property, trace))
-      {
-         // 
-         MetaValue metaValue = property.getField(Fields.VALUE, MetaValue.class);
-         MetaType metaType = property.getField(Fields.META_TYPE, MetaType.class);
-         // Override metaType
-         if(metaValue != null)
-            metaType = metaValue.getMetaType();
-         
-         // Create the persisted value
-         PersistedValue value = createPersistedValue(metaValue, metaType, persisted.getValue());
-         if(value != null)
-         {
-            persisted.setValue(value);
-            if(trace)
-               log.trace("value for property ("+ property.getName() +"): " + value);
-            processed = true;
-         }
-      }
-      return processed;
-   }
-   
-   /**
-    * Create a persisted value. This delegates the value creation
-    * to the ValuePeristence.
-    * 
-    * @param metaValue the meta value
-    * @param metaType the meta type
-    * @param persisted the persisted value
-    * @return the created persisted value
-    */
-   private PersistedValue createPersistedValue(MetaValue metaValue, MetaType metaType, PersistedValue persisted)
-   {
-      return getValuePersistence().createPersistedValue(metaValue, metaType, persisted);
-   }
-   
-   /**
-    * Does this property needs to be processed.
-    * 
-    * @param property the managed property
-    * @param trace enable trace logs
-    * @return false if the property does not need to be processed otherwise true
-    */
-   protected boolean isProcessProperty(ManagedProperty property, boolean trace)
-   {
-      boolean process = false;
-      // 
-      if(property == null)
-         return process;
-      
-      // Skip non configuration properties
-      if(property.hasViewUse(ViewUse.CONFIGURATION) == false)
-      {
-         if(trace)
-            log.trace("Skip non configuration property: " + property.getName());
-         return process;
-      }
-      // Skip read only properties
-      if(property.isReadOnly())
-      {
-         if(trace)
-            log.trace("Skip readOnly property: " + property.getName());
-         return process;
-      }
-      // Skip removed properties
-      if(property.isRemoved())
-      {
-         if(trace)
-            log.trace("Skip removed property: " + property.getName());
-         return process;
-      }
-      // Skip read only properties
-      PropertyInfo propertyInfo = property.getField(Fields.PROPERTY_INFO, PropertyInfo.class);
-      if(propertyInfo != null && propertyInfo.isReadable() == false)
-      {
-         if(trace)
-            log.trace("Skip non readable property: " + property.getName());
-         return process;
-      }      
-      return true;
-   }
-   
-   /**
-    * Get a map of persisted managed objects, with the property name as key.
-    * 
-    * @param persisted the persisted managed object
-    * @return a map of persisted properties
-    */
-   protected static Map<String, PersistedProperty> getPersistedProperties(PersistedManagedObject persisted)
-   {
-      if(persisted == null)
-         throw new IllegalArgumentException("Null persisted managed object.");
-      
-      Map<String, PersistedProperty> properties = new HashMap<String, PersistedProperty>();
-      List<PersistedProperty> list = persisted.getProperties();
-      if(list == null)
-      {
-         list = new ArrayList<PersistedProperty>();
-         persisted.setProperties(list);
-      }
-      if(list.isEmpty() == false)
-      {
-         for(PersistedProperty p : list)
-            properties.put(p.getName(), p);
-      }
-      return properties;
-   }
-   
-}
-

Added: trunk/system/src/main/org/jboss/system/server/profileservice/persistence/AbstractManagedObjectRecreation.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/persistence/AbstractManagedObjectRecreation.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/persistence/AbstractManagedObjectRecreation.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -0,0 +1,226 @@
+/*
+ * 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.system.server.profileservice.persistence;
+
+import org.jboss.beans.info.spi.PropertyInfo;
+import org.jboss.logging.Logger;
+import org.jboss.managed.api.Fields;
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.managed.api.annotation.ViewUse;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.system.server.profileservice.persistence.xml.PersistedManagedObject;
+import org.jboss.system.server.profileservice.persistence.xml.PersistedProperty;
+import org.jboss.system.server.profileservice.persistence.xml.PersistedValue;
+
+/**
+ * A abstract ManagedObject recreation helper.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public abstract class AbstractManagedObjectRecreation
+{
+
+   /** The logger. */
+   private static final Logger log = Logger.getLogger(AbstractManagedObjectRecreation.class);
+   
+   /** The value recreation. */
+   private final AbstractValueRecreation valueRecreation;
+
+   public AbstractManagedObjectRecreation(AbstractValueRecreation valueRecreation)
+   {
+      this.valueRecreation = valueRecreation;
+   }
+   
+   public AbstractValueRecreation getValueRecreation()
+   {
+      return this.valueRecreation;
+   }
+   
+   /**
+    * Process the properties of the persisted ManagedObject.
+    * 
+    * @param persisted the persisted managed object
+    * @param mo the ManagedObject
+    */
+   protected void processProperties(PersistedManagedObject persisted, ManagedObject mo)
+   {
+      if(persisted == null)
+         throw new IllegalArgumentException("null persisted managed object");
+      if(mo == null)
+         throw new IllegalArgumentException("null managed object");
+      
+      // Get the xml to see what we need to update
+      if(persisted.getProperties() != null && persisted.getProperties().isEmpty() == false)
+      {
+         for(PersistedProperty propertyElement : persisted.getProperties())
+         {
+            ManagedProperty property = mo.getProperty(propertyElement.getName());
+            if(property == null)
+               throw new IllegalStateException("unable to find propery: "+ propertyElement.getName());
+
+            // getProperty
+            processManagedProperty(propertyElement, property, mo.getAttachment());
+         }  
+      }
+   }
+
+   /**
+    * Process a managed property and set it's values to the attachment.
+    * 
+    * @param persisted the persisted property
+    * @param property the managed property
+    * @param attachment the attachment
+    * @return the meta value of this property
+    */
+   protected MetaValue processManagedProperty(PersistedProperty persisted, ManagedProperty property, Object attachment)
+   {
+      if(attachment == null)
+         throw new IllegalArgumentException("null attachment");
+      
+      // Get the property name
+      String name = property.getMappedName() != null ? property.getMappedName() : property.getName();
+      // Process the property
+      MetaValue metaValue = processManagedProperty(persisted, property);
+      // Set value
+      setValue(name, property, attachment);
+      // Return
+      return metaValue;
+   }
+   
+   /**
+    * Set the value to the managed property/
+    * 
+    * @param name the property name
+    * @param property the managed property itself
+    * @param attachment the attachment
+    */
+   protected abstract void setValue(String name, ManagedProperty property, Object attachment);
+   
+   /**
+    * Process the managed property.
+    * 
+    * @param persisted the persisted property
+    * @param property the managed property
+    * @return the value
+    */
+   protected MetaValue processManagedProperty(PersistedProperty persisted, ManagedProperty property)
+   {
+      return processManagedProperty(persisted, property, false);
+   }
+   
+   /**
+    * Process the managed property.
+    * 
+    * @param persisted the persisted property
+    * @param property the managed property
+    * @param trace enable trace logs
+    * @return the value
+    */
+   protected MetaValue processManagedProperty(PersistedProperty persisted, ManagedProperty property, boolean trace)
+   {
+      if(persisted == null)
+         throw new IllegalArgumentException("null persisted property");
+      if(property == null)
+         throw new IllegalArgumentException("null managed property");
+
+      MetaValue metaValue = property.getValue();
+      PersistedValue persistedValue = persisted.getValue();
+      if(persistedValue != null && isProcessProperty(property, trace))
+      {
+         MetaType metaType = property.getMetaType();
+         if(metaValue != null)
+            metaType = metaValue.getMetaType();
+
+         // Create the value based on the persisted information
+         metaValue = createValue(persistedValue, metaType);
+
+         // Update property
+         property.setField(Fields.VALUE, metaValue);
+         if(metaValue != null)
+            property.setField(Fields.META_TYPE, metaValue.getMetaType());
+      }
+      return metaValue;
+   }
+   
+   /**
+    * Call the value recreation to recreate a persisted value.
+    * 
+    * @param value the persisted value
+    * @param metaType the meta type
+    * @return the meta value
+    */
+   protected MetaValue createValue(PersistedValue value, MetaType metaType)
+   {
+      return getValueRecreation().createMetaValue(value, metaType);
+   }
+   
+   /**
+    * Does this property needs to be processed.
+    * 
+    * @param property the managed property
+    * @param trace enable trace logs
+    * @return false if the property does not need to be processed otherwise true
+    */
+   protected boolean isProcessProperty(ManagedProperty property, boolean trace)
+   {
+      // 
+      boolean process = false;
+      if(property == null)
+         return process;
+      
+      // Skip non configuration properties
+      if(property.hasViewUse(ViewUse.CONFIGURATION) == false)
+      {
+         if(trace)
+            log.trace("Skip non configuration property: " + property.getName());
+         return process;
+      }
+      // Skip read only properties
+      if(property.isReadOnly())
+      {
+         if(trace)
+            log.trace("Skip readOnly property: " + property.getName());
+         return process;
+      }
+      // Skip removed properties
+      if(property.isRemoved())
+      {
+         if(trace)
+            log.trace("Skip removed property: " + property.getName());
+         return process;
+      }
+      // Skip read only properties
+      PropertyInfo propertyInfo = property.getField(Fields.PROPERTY_INFO, PropertyInfo.class);
+      if(propertyInfo != null && propertyInfo.isReadable() == false)
+      {
+         if(trace)
+            log.trace("Skip non readable property: " + property.getName());
+         return process;
+      }
+      return true;
+   }
+   
+}
+

Added: trunk/system/src/main/org/jboss/system/server/profileservice/persistence/AbstractPersistenceFactory.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/persistence/AbstractPersistenceFactory.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/persistence/AbstractPersistenceFactory.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -0,0 +1,349 @@
+/*
+ * 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.system.server.profileservice.persistence;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.managed.api.ManagedComponent;
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.api.factory.ManagedObjectFactory;
+import org.jboss.system.server.profileservice.persistence.component.ComponentMapper;
+import org.jboss.system.server.profileservice.persistence.component.ComponentMapperRegistry;
+import org.jboss.system.server.profileservice.persistence.xml.ModificationInfo;
+import org.jboss.system.server.profileservice.persistence.xml.PersistedComponent;
+import org.jboss.system.server.profileservice.persistence.xml.PersistenceRoot;
+
+/**
+ * The abstract persistence factory.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class AbstractPersistenceFactory extends PersistenceFactory 
+{
+
+   /** The component mapper registry. */
+   private final ComponentMapperRegistry componentMapper = ComponentMapperRegistry.getInstance();
+
+   /** The delegating persistence plugin. */
+   private final DelegatingPersistencePlugin persistencePlugin;
+   
+   /** The recreation helper. */
+   private final ManagedObjectRecreationHelper recreationHelper;
+   
+   public AbstractPersistenceFactory()
+   {
+      this(ManagedObjectFactory.getInstance());
+   }
+   
+   public AbstractPersistenceFactory(ManagedObjectFactory managedObjectFactory)
+   {
+      super(managedObjectFactory);
+      this.recreationHelper = new ManagedObjectRecreationHelper(managedObjectFactory);
+      this.persistencePlugin = new DelegatingPersistencePlugin(recreationHelper);
+   }
+   
+   /**
+    * {@inheritDoc}
+    */
+   public ManagedObjectPersistencePlugin getPersistencePlugin()
+   {
+      return persistencePlugin;
+   }
+   
+   /**
+    * Apply the persisted information to a attachment.
+    * 
+    * @param root the persistence root
+    * @param attachment the root attachment
+    * @param classLoader the classloader
+    */
+   @Override
+   public void restorePersistenceRoot(PersistenceRoot root, Object parentAttachment, ClassLoader classLoader)
+   {
+      if(root == null)
+         throw new IllegalArgumentException("null root");
+      if(parentAttachment == null)
+         throw new IllegalArgumentException("null attachment");
+      
+      if(root.getComponents() != null && root.getComponents().isEmpty() == false)
+      {
+         // Set the classloader
+         recreationHelper.setLoader(classLoader);
+         try
+         {
+            // Restore the components
+            ComponentMapper mapper = getComponentMapper(root);
+            for(PersistedComponent component : root.getComponents())
+            {
+               mapper.restoreComponent(parentAttachment, component);
+            }
+         }
+         finally
+         {
+            recreationHelper.setLoader(null);
+         }
+      }
+   }
+   
+   /**
+    * Add a ManagedComponent.
+    * 
+    * @param root the persistence root
+    * @param parent the parent managed object
+    * @param component the managed component
+    * @return the updated persistence root
+    */
+   @Override
+   public PersistenceRoot addComponent(PersistenceRoot root, ManagedObject parent, ManagedComponent component)
+   {
+      if(root == null)
+         throw new IllegalArgumentException("null persistence root");
+      ComponentMapper mapper = getComponentMapper(parent);
+      PersistedComponent persistedComponent = mapper.addComponent(parent.getAttachment(), component);
+      return addPersistedComponent(root, persistedComponent);
+   }
+
+   /**
+    * Remove a ManagedComponent.
+    * 
+    * @param root the persistence root
+    * @param parent the parent managed object
+    * @param component the managed component
+    * @return the updated persistence root
+    */
+   @Override
+   public PersistenceRoot removeComponent(PersistenceRoot root, ManagedObject parent, ManagedComponent component)
+   {
+      if(root == null)
+         throw new IllegalArgumentException("null persistence root");
+      
+      ComponentMapper mapper = getComponentMapper(parent);
+      PersistedComponent persistedComponent = mapper.removeComponent(parent.getAttachment(), component);
+      return addPersistedComponent(root, persistedComponent);
+   }
+
+   /**
+    * Update a ManagedComponent.
+    * 
+    * @param root the persistence root
+    * @param parent the parent managed object
+    * @param component the managed component
+    * @return the updated persistence root
+    */
+   @Override
+   public PersistenceRoot updateComponent(PersistenceRoot root, ManagedObject parent, ManagedComponent component)
+   {
+      if(root == null)
+         throw new IllegalArgumentException("null persistence root");
+      
+      ComponentMapper mapper = getComponentMapper(parent);
+      PersistedComponent persistedComponent = mapper.updateComponent(parent.getAttachment(), component);
+      return addPersistedComponent(root, persistedComponent);
+   }
+
+   /**
+    * Reset a component. This will remove the persisted information.
+    * 
+    * @param root the persistence root
+    * @param parent the parent managed object
+    * @param component the managed component
+    * @return the updated persistence root
+    */
+   @Override
+   public PersistenceRoot resetComponent(PersistenceRoot root, ManagedObject parent, ManagedComponent component)
+   {
+      ComponentMapper mapper = getComponentMapper(parent);
+      PersistedComponent persistedComponent = mapper.updateComponent(parent.getAttachment(), component);
+      // Map the components
+      Map<String, PersistedComponent> components = mapComponents(root);
+      // Remove the component
+      PersistedComponent previous = components.remove(persistedComponent.getOriginalName());
+      if(previous == null)
+         previous = components.remove(persistedComponent.getName());
+      // Set the new values
+      root.setComponents(new ArrayList<PersistedComponent>(components.values()));
+      return root;
+   }
+   
+   /**
+    * Add a persisted component to the root. This will map and override
+    * existing components.
+    * 
+    * @param root the persistence root
+    * @param component the persisted component
+    * @return the update persistence root
+    */
+   protected PersistenceRoot addPersistedComponent(PersistenceRoot root, PersistedComponent component)
+   {
+      Map<String, PersistedComponent> components = mapComponents(root);
+      PersistedComponent previous = components.remove(component.getOriginalName());
+      if(previous == null)
+         previous = components.remove(component.getName());
+      // Add the persisted component
+      components.put(component.getName(), component);
+      
+      // Override with some previous information
+      if(previous != null)
+      {
+         // A added component should remain on added
+         if(previous.getModificationInfo() == ModificationInfo.ADDED
+               && component.getModificationInfo() == ModificationInfo.MODIFIED)
+            component.setModificationInfo(ModificationInfo.ADDED);
+         
+         // Just remove a previously added component
+         if(previous.getModificationInfo() == ModificationInfo.ADDED
+               && component.getModificationInfo() == ModificationInfo.REMOVED)
+            components.remove(component.getName());
+         
+         // Override the name
+         if(previous.getOriginalName() != null)
+            component.setOriginalName(previous.getOriginalName());         
+      }
+      
+      root.setComponents(new ArrayList<PersistedComponent>(components.values()));
+      return root;
+   }
+
+   /**
+    * Get the component mapper for a given ManagedObject.
+    * 
+    * @param parent the managed object
+    * @return the component mapper
+    * @throws IllegalStateException if no mapper is registered for this type
+    */
+   protected ComponentMapper getComponentMapper(ManagedObject parent)
+   {
+      ComponentMapper mapper = null;
+      if(parent.getAttachmentName() != null)
+         mapper = getComponentMapper(parent.getAttachmentName());
+      if(mapper == null && parent.getAttachment() != null)
+         mapper = getComponentMapper(parent.getAttachment().getClass().getName());
+
+      if(mapper == null)
+         throw new IllegalStateException("no mapper registered for type: " + parent.getAttachmentName());
+      
+      return mapper;
+   }
+   
+   /**
+    * Get the component mapper for a persistence root.
+    * 
+    * @param root the persistence root
+    * @return the component mapper
+    * @throws IllegalStateException if no mapper is registered for this type
+    */
+   protected ComponentMapper getComponentMapper(PersistenceRoot root)
+   {
+      ComponentMapper mapper = null;
+      if(root.getName() != null)
+         mapper = getComponentMapper(root.getName());
+      if(root.getClassName() != null)
+         mapper = getComponentMapper(root.getClassName());
+      
+      if(mapper == null)
+         throw new IllegalStateException("no mapper registered for type: " + root);
+      
+      return mapper;
+   }
+   
+   /**
+    * Get the component mapper for a given type.
+    * 
+    * @param type the type
+    * @return the component mapper, null if not registered
+    * @throw IllegalArgumentException for a null type
+    */
+   protected ComponentMapper getComponentMapper(String type)
+   {
+      if(type == null)
+         throw new IllegalArgumentException("null type");
+
+      return componentMapper.getMapper(type);
+   }
+   
+   /**
+    * Map the components based on their names.
+    * 
+    * @param root the persistence root
+    * @return a map of persisted components
+    */
+   protected static Map<String, PersistedComponent> mapComponents(PersistenceRoot root)
+   {
+      Map<String, PersistedComponent> map = new HashMap<String, PersistedComponent>();
+      if(root.getComponents() != null && root.getComponents().isEmpty() == false)
+      {
+         for(PersistedComponent component : root.getComponents())
+         {
+            // Map this based on the name, as this should 
+            // match the original name of the new component
+            map.put(component.getName(), component);
+         }
+      }
+      return map;
+   }
+
+   /**
+    * InstallCallback for adding a component mapper.
+    * 
+    * @param mapper the component mapper
+    */
+   public void addComponentMapper(ComponentMapper mapper)
+   {
+      componentMapper.addMapper(mapper);
+   }
+   
+   /**
+    * UnInstallCallback for removing a component mapper.
+    * 
+    * @param mapper the component mapper
+    * @return the removed component mapper
+    */
+   public ComponentMapper removeComponentMapper(ComponentMapper mapper)
+   {
+      return componentMapper.removeComponentMapper(mapper);
+   }
+   
+   /**
+    * InstallCallback for adding a persistence plugin.
+    * 
+    * @param plugin the persistence plugin
+    */
+   public void addPersistencePlugin(ManagedObjectPersistencePlugin plugin)
+   {
+      persistencePlugin.addPlugin(plugin);
+   }
+   
+   /**
+    * UnInstallCallback for removing a persistence plugin.
+    * 
+    * @param plugin the plugin
+    */
+   public void removePersistencePlugin(ManagedObjectPersistencePlugin plugin)
+   {
+      persistencePlugin.removePlugin(plugin);
+   }
+   
+}
+

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/persistence/AbstractValuePersistence.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/persistence/AbstractValuePersistence.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/persistence/AbstractValuePersistence.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -73,14 +73,14 @@
    /** The plugin. */
    private final ManagedObjectPersistencePlugin plugin;
    
-   public AbstractValuePersistence(ManagedObjectPersistencePlugin plugin, MetaValueFactory metaValueFactory)
+   public AbstractValuePersistence(ManagedObjectPersistencePlugin callback, MetaValueFactory metaValueFactory)
    {
-      if(plugin == null)
-         throw new IllegalArgumentException("Null managed object plugin.");
+      if(callback == null)
+         throw new IllegalArgumentException("Null managed object persistence callback.");
       if(metaValueFactory == null)
          throw new IllegalArgumentException("Null meta value factory.");
       
-      this.plugin = plugin;
+      this.plugin = callback;
       this.metaValueFactory = metaValueFactory;
    }
    

Added: trunk/system/src/main/org/jboss/system/server/profileservice/persistence/AbstractValueRecreation.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/persistence/AbstractValueRecreation.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/persistence/AbstractValueRecreation.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -0,0 +1,479 @@
+/*
+ * 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.system.server.profileservice.persistence;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.logging.Logger;
+import org.jboss.metatype.api.types.ArrayMetaType;
+import org.jboss.metatype.api.types.CollectionMetaType;
+import org.jboss.metatype.api.types.CompositeMetaType;
+import org.jboss.metatype.api.types.EnumMetaType;
+import org.jboss.metatype.api.types.GenericMetaType;
+import org.jboss.metatype.api.types.MapCompositeMetaType;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.Name;
+import org.jboss.metatype.api.types.PropertiesMetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.types.TableMetaType;
+import org.jboss.metatype.api.values.ArrayValue;
+import org.jboss.metatype.api.values.ArrayValueSupport;
+import org.jboss.metatype.api.values.CollectionValue;
+import org.jboss.metatype.api.values.CollectionValueSupport;
+import org.jboss.metatype.api.values.CompositeValue;
+import org.jboss.metatype.api.values.CompositeValueSupport;
+import org.jboss.metatype.api.values.EnumValue;
+import org.jboss.metatype.api.values.EnumValueSupport;
+import org.jboss.metatype.api.values.GenericValue;
+import org.jboss.metatype.api.values.GenericValueSupport;
+import org.jboss.metatype.api.values.MapCompositeValueSupport;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.PropertiesMetaValue;
+import org.jboss.metatype.api.values.SimpleValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.metatype.api.values.TableValue;
+import org.jboss.metatype.api.values.TableValueSupport;
+import org.jboss.metatype.plugins.types.StringName;
+import org.jboss.reflect.plugins.ValueConvertor;
+import org.jboss.system.server.profileservice.persistence.xml.NullValue;
+import org.jboss.system.server.profileservice.persistence.xml.PersistedArrayValue;
+import org.jboss.system.server.profileservice.persistence.xml.PersistedCollectionValue;
+import org.jboss.system.server.profileservice.persistence.xml.PersistedCompositeValue;
+import org.jboss.system.server.profileservice.persistence.xml.PersistedEnumValue;
+import org.jboss.system.server.profileservice.persistence.xml.PersistedGenericValue;
+import org.jboss.system.server.profileservice.persistence.xml.PersistedPair;
+import org.jboss.system.server.profileservice.persistence.xml.PersistedPropertiesValue;
+import org.jboss.system.server.profileservice.persistence.xml.PersistedSimpleValue;
+import org.jboss.system.server.profileservice.persistence.xml.PersistedTableValue;
+import org.jboss.system.server.profileservice.persistence.xml.PersistedValue;
+
+/**
+ * The abstract value recreation creates MetaValues based on the persisted
+ * managed object information and the MetaTypes of the ManagedObject used
+ * for persistence. The recreation of ManagedObjects itself is delegated
+ * to a ManagedObjectRecreationPlugin.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class AbstractValueRecreation
+{
+   
+   /** The simple types. */
+   private final static Map<String, Class<? extends Serializable>> simpleTypes = new HashMap<String, Class<? extends Serializable>>();
+   
+   /** The logger. */
+   private final static Logger log = Logger.getLogger(AbstractValueRecreation.class);
+   
+   /** The recreation plugin. */
+   private final ManagedObjectPersistencePlugin plugin;
+   
+   static
+   {
+      // Fill simple types map.
+      simpleTypes.put(BigDecimal.class.getName(), BigDecimal.class);
+      simpleTypes.put(BigInteger.class.getName(), BigInteger.class);
+      simpleTypes.put(Boolean.class.getName(), Boolean.class);
+      simpleTypes.put(Byte.class.getName(), Byte.class);
+      simpleTypes.put(Character.class.getName(), Character.class);
+      simpleTypes.put(Date.class.getName(), Date.class);
+      simpleTypes.put(Double.class.getName(), Double.class);
+      simpleTypes.put(Float.class.getName(), Float.class);
+      simpleTypes.put(Integer.class.getName(), Integer.class);
+      simpleTypes.put(Long.class.getName(), Long.class);
+      simpleTypes.put(Short.class.getName(), Short.class);
+      simpleTypes.put(String.class.getName(), String.class);
+      simpleTypes.put(Name.class.getName(), Name.class);
+      // primitive classes
+      simpleTypes.put(byte.class.getName(), byte.class);
+      simpleTypes.put(char.class.getName(), char.class);
+      simpleTypes.put(double.class.getName(), double.class);
+      simpleTypes.put(float.class.getName(), float.class);
+      simpleTypes.put(int.class.getName(), int.class);
+      simpleTypes.put(short.class.getName(), short.class);
+      simpleTypes.put(long.class.getName(), long.class);
+      simpleTypes.put(boolean.class.getName(), boolean.class);
+   }
+   
+   public AbstractValueRecreation(ManagedObjectPersistencePlugin callback)
+   {
+      if(callback == null)
+         throw new IllegalArgumentException("null managed object persistence callback");
+      
+      this.plugin = callback;
+   }
+   
+   public ManagedObjectPersistencePlugin getPlugin()
+   {
+      return plugin;
+   }
+   
+   /**
+    * Create the meta value, based on the xml persisted
+    * value and the generated MetaType.
+    * 
+    * @param valueElement the persisted xml element
+    * @param type the meta type
+    * @return the created meta value
+    */
+   public MetaValue createMetaValue(PersistedValue valueElement, MetaType metaType)
+   {
+      if(log.isTraceEnabled())
+      {
+         log.trace("processing value " + valueElement + " type: " + metaType);
+      }
+      
+      if(valueElement instanceof NullValue)
+         return null;
+      
+      if(valueElement == null)
+         return null;
+      
+      MetaValue metaValue = null;
+      try
+      {
+         if(metaType.isSimple())
+         {
+            metaValue = createSimpleValue(
+                  (PersistedSimpleValue) valueElement,
+                  (SimpleMetaType) metaType);
+         }
+         else if(metaType.isEnum())
+         {
+            metaValue = createEnumValue(
+                  (PersistedEnumValue) valueElement,
+                  (EnumMetaType) metaType);
+         }
+         else if(metaType.isCollection())
+         {
+            metaValue = createCollectionValue(
+                  (PersistedCollectionValue) valueElement,
+                  (CollectionMetaType) metaType);
+         }
+         else if(metaType.isGeneric())
+         {
+            metaValue = createGenericValue(
+                  (PersistedGenericValue) valueElement,
+                  (GenericMetaType) metaType);
+         }
+         else if(metaType.isComposite())
+         {
+            metaValue = createCompositeValue(
+                  (PersistedCompositeValue) valueElement,
+                  (CompositeMetaType) metaType);
+         }
+         else if(metaType.isTable())
+         {
+            metaValue = createTableValue(
+                  (PersistedTableValue) valueElement,
+                  (TableMetaType)metaType);
+         }
+         else if(metaType.isArray())
+         {
+            metaValue = createArrayValue(
+                  (PersistedArrayValue) valueElement,
+                  (ArrayMetaType) metaType);
+         }
+         else if(metaType.isProperties())
+         {
+            metaValue = createPropertiesValue(
+                  (PersistedPropertiesValue) valueElement,
+                  (PropertiesMetaType) metaType);
+         }
+         else
+         {
+            throw new IllegalStateException("unknown metaType");
+         }
+      }
+      finally
+      {
+         //
+      }
+      return metaValue;
+   }
+   
+   /**
+    * Create simple value.
+    * 
+    * @param valueElement the persisted xml meta data
+    * @param value the simple value
+    * @return a simple value
+    */
+   protected SimpleValue createSimpleValue(PersistedSimpleValue valueElement, SimpleMetaType metaType)
+   {
+      String elementValue = valueElement.getValue();
+      
+      Serializable converted = null;
+      if(elementValue != null)
+      {
+         if(metaType.equals(SimpleMetaType.STRING))
+         {
+            converted = (String) elementValue;
+         }
+         else if (metaType.equals(SimpleMetaType.NAMEDOBJECT))
+         {
+            converted = new StringName(elementValue);
+         }
+         else if (metaType.equals(SimpleMetaType.VOID))
+         {  
+            // 
+         }
+         else
+         {
+            converted = convert2Type(metaType.getTypeName(), elementValue);
+         }
+      }
+      return new SimpleValueSupport(metaType, converted);
+   }
+ 
+   /**
+    * Process an Enum value.
+    * 
+    * @param enumElement the persisted xml meta data
+    * @param value the enum value
+    * @return a enum value
+    */
+   protected EnumValue createEnumValue(PersistedEnumValue enumElement, EnumMetaType type)
+   {
+      return new EnumValueSupport(type, enumElement.getValue());
+   }
+   
+   /**
+    * Create composite value.
+    * 
+    * @param composite the persisted xml meta data
+    * @param value the composite value
+    * @return a composite value
+    */
+   protected CompositeValue createCompositeValue(PersistedCompositeValue composite, CompositeMetaType type)
+   {
+      // Handle the mapCompositeMetaType differently
+      if(type instanceof MapCompositeMetaType)
+         return handleMapCompositeMetaType(composite, (MapCompositeMetaType) type);
+      
+      // Create composite value
+      Map<String, MetaValue> values = new HashMap<String, MetaValue>();
+      if(composite.getValues() != null && composite.getValues().isEmpty() == false)
+      {
+         for(PersistedValue persistedValue : composite.getValues())
+         {
+            MetaType elementType = type.getType(persistedValue.getName());
+            if(elementType == null)
+               throw new IllegalStateException("Failed to process composite value: " + persistedValue.getName());
+            
+            // Create
+            MetaValue metaValue = createMetaValue(persistedValue, elementType);
+            // Put
+            values.put(persistedValue.getName(), metaValue);
+         }
+      }     
+      return new CompositeValueSupport(type, values);
+   }
+
+   /**
+    * Create the MapCompositeValueSupport value.
+    * 
+    * @param composite the persisted composite xml meta data
+    * @param type the MapComposite meta type
+    * @return the MapCompositeValueSupport
+    */
+   protected MapCompositeValueSupport handleMapCompositeMetaType(PersistedCompositeValue composite, MapCompositeMetaType type)
+   {
+      Map<String, MetaValue> values = new HashMap<String, MetaValue>();
+      if(composite.getValues() != null && composite.getValues().isEmpty() == false)
+      {
+         for(PersistedValue persistedValue : composite.getValues())
+         {
+            MetaValue value = createMetaValue(persistedValue, type.getValueType());
+            values.put(persistedValue.getName(), value);
+         }
+      }
+      return new MapCompositeValueSupport(values, type);
+   }
+   
+   /**
+    * Process a collection.
+    * 
+    * @param collection the persisted xml meta data
+    * @param value the collection value
+    * @return a collection value
+    */
+   protected CollectionValue createCollectionValue(PersistedCollectionValue collection, CollectionMetaType type)
+   {
+      List<MetaValue> elementList = new ArrayList<MetaValue>();
+      if(collection.getValues() != null && collection.getValues().isEmpty() == false)
+      {
+         for(PersistedValue element : collection.getValues())
+         {
+            elementList.add(
+                  createMetaValue(element, type.getElementType()));
+         }  
+      }
+      return new CollectionValueSupport(type, elementList.toArray(new MetaValue[elementList.size()]));
+   }
+   
+   /**
+    * Create generic value. 
+    * 
+    * @param genericElement the persisted generic xml meta data 
+    * @param metaType the generic meta type
+    * @return the generic value
+    */
+   protected GenericValue createGenericValue(PersistedGenericValue genericElement, GenericMetaType metaType)
+   {
+      Serializable value = null;
+      if(genericElement.getManagedObject() != null)
+      {
+         value = getPlugin().createManagedObject(genericElement.getManagedObject());
+      }
+      return new GenericValueSupport(metaType, value);
+   }
+   
+   /**
+    * Create the table value.
+    * 
+    * @param table the persisted table value
+    * @param type the table meta type
+    * @return the table value
+    */
+   protected TableValue createTableValue(PersistedTableValue table, TableMetaType type)
+   {
+      TableValueSupport support = new TableValueSupport(type);
+      if(table.getEntries() != null && table.getEntries().isEmpty() == false)
+      {
+         for(PersistedCompositeValue entry : table.getEntries())
+         {
+            support.put(createCompositeValue(entry, type.getRowType()));
+         }         
+      }
+      return support;
+   }
+   
+   /**
+    * Create the properties value.
+    * 
+    * @param value the persisted properties value
+    * @param metaType the properties meta type
+    * @return the properties value
+    */
+   protected MetaValue createPropertiesValue(
+         PersistedPropertiesValue value, PropertiesMetaType metaType)
+   {
+      PropertiesMetaValue properties = new PropertiesMetaValue();
+      for(PersistedPair pair : value.getEntries())
+      {
+         properties.setProperty(pair.getKey(), pair.getValue());
+      }
+
+      return properties;
+   }
+
+   /**
+    * Create array value.
+    * 
+    * @param valueElement the persisted array xml value
+    * @param type the array meta type 
+    * @return the array value
+    */
+   @SuppressWarnings("unchecked")
+   protected ArrayValue createArrayValue(PersistedArrayValue valueElement, ArrayMetaType type)
+   {
+      int size = valueElement.size();
+      List values = new ArrayList(size);
+      for(PersistedValue elementValue : valueElement.getValues())
+      {
+         if(elementValue instanceof PersistedArrayValue)
+         {
+            values.add(
+                  recreateArrayValue((PersistedArrayValue) elementValue, type.getElementType()));
+         }
+         else
+         {
+            MetaValue value = createMetaValue(elementValue, type.getElementType());
+            values.add(value);
+         }
+      }
+      return new ArrayValueSupport(type, values.toArray());
+   }
+
+   /**
+    * Recreate the array values.
+    * 
+    * @param valueElement the persisted xml value
+    * @param type the element type
+    * @return the recreated array
+    */
+   @SuppressWarnings("unchecked")
+   protected Object recreateArrayValue(PersistedArrayValue valueElement, MetaType type)
+   {
+      List values = new ArrayList(valueElement.size());
+      for(PersistedValue elementValue : valueElement.getValues())
+      {
+         if(elementValue instanceof PersistedArrayValue)
+         {
+            values.add(
+                  recreateArrayValue((PersistedArrayValue) elementValue, type));
+         }
+         else
+         {
+            MetaValue value = createMetaValue(elementValue, type);
+            values.add(value);
+         }
+      }
+      return values.toArray();
+   }
+   
+   /**
+    * Convert simple types.
+    * 
+    * @param clazz a primitive serializable class.
+    * @param value the String
+    * @return the converted object, null in case of any failure.
+    */
+   public Serializable convert2Type(String className, String value)
+   {
+      if(value == null)
+         return null;
+      
+      Class<?> clazz = simpleTypes.get(className);
+      if(clazz == null)
+         throw new IllegalStateException("Cannot find simple type entry for "+ value + " and class "+ className);
+      
+      try
+      {
+         return (Serializable) ValueConvertor.convertValue(clazz, value);
+      }
+      catch(Throwable t)
+      {
+         log.debug("could convert "+ value +" to " + clazz.getName());
+         return null;
+      }
+   }
+   
+}

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/persistence/AttachmentPropertyPopulator.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/persistence/AttachmentPropertyPopulator.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/persistence/AttachmentPropertyPopulator.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -22,24 +22,44 @@
 package org.jboss.system.server.profileservice.persistence;
 
 import java.lang.reflect.Proxy;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.WeakHashMap;
 
 import javax.management.ObjectName;
 
 import org.jboss.beans.info.spi.BeanInfo;
 import org.jboss.beans.info.spi.PropertyInfo;
+import org.jboss.config.plugins.property.PropertyConfiguration;
+import org.jboss.config.spi.Configuration;
 import org.jboss.logging.Logger;
 import org.jboss.managed.api.Fields;
+import org.jboss.managed.api.ManagedObject;
 import org.jboss.managed.api.ManagedProperty;
 import org.jboss.managed.api.factory.ManagedObjectFactory;
+import org.jboss.managed.plugins.factory.AbstractManagedObjectFactory;
 import org.jboss.managed.spi.factory.InstanceClassFactory;
+import org.jboss.metatype.api.types.CollectionMetaType;
 import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.values.CollectionValue;
+import org.jboss.metatype.api.values.GenericValue;
+import org.jboss.metatype.api.values.InstanceFactory;
 import org.jboss.metatype.api.values.MetaValue;
 import org.jboss.metatype.api.values.MetaValueFactory;
+import org.jboss.metatype.plugins.values.ListInstanceFactory;
+import org.jboss.metatype.plugins.values.SetInstanceFactory;
+import org.jboss.metatype.plugins.values.SortedSetInstanceFactory;
 import org.jboss.metatype.spi.values.MetaMapper;
+import org.jboss.reflect.spi.ClassInfo;
 
 /**
  * The AttachmentPropertyPopulator, this writes the values of a 
- * ManagedProperty to a attachment.
+ * ManagedProperty to the attachment using a registered ICF.
  * 
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
  * @version $Revision$
@@ -47,23 +67,60 @@
 public class AttachmentPropertyPopulator
 {
 
-   /** The managed object factory. */
-   private ManagedObjectFactory managedObjectFactory;
-
+   /** The logger. */
+   private static final Logger log = Logger.getLogger(AttachmentPropertyPopulator.class);
+   
    /** The meta value factory. */
-   private MetaValueFactory metaValueFactory = MetaValueFactory.getInstance();
+   private static final MetaValueFactory metaValueFactory = MetaValueFactory.getInstance();
    
-   /** The logger. */
-   private static final Logger log = Logger.getLogger(AttachmentPropertyPopulator.class);
+   /** The configuration */
+   private static final Configuration configuration;
+   
+   /** The managed object factory. */
+   private final ManagedObjectFactory managedObjectFactory;
+   
+   /** The helper. */
+   private final ManagedObjectRecreationHelper helper;
+   
+   /** The instance factory builders */
+   private Map<Class<?>, InstanceFactory<?>> instanceFactoryMap = new WeakHashMap<Class<?>, InstanceFactory<?>>();
 
-   public AttachmentPropertyPopulator()
+   static
    {
-      this.managedObjectFactory = ManagedObjectFactory.getInstance();
+      configuration = AccessController.doPrivileged(new PrivilegedAction<Configuration>()
+      {
+         public Configuration run()
+         {
+            return new PropertyConfiguration();
+         }
+      });
    }
    
-   public AttachmentPropertyPopulator(ManagedObjectFactory managedObjectFactory)
+   public <T> void setInstanceFactory(Class<T> clazz, InstanceFactory<T> factory)
    {
+      synchronized(instanceFactoryMap)
+      {
+         if (factory == null)
+            instanceFactoryMap.remove(clazz);
+         else
+            instanceFactoryMap.put(clazz, factory);
+      }
+   }
+   
+   public AttachmentPropertyPopulator(ManagedObjectFactory managedObjectFactory,
+         ManagedObjectRecreationHelper helper)
+   {
+      if(managedObjectFactory == null)
+         throw new IllegalArgumentException("null managed object factory.");
+      if(helper == null)
+         throw new IllegalArgumentException("null helper");
+      
       this.managedObjectFactory = managedObjectFactory;
+      this.helper = helper;
+      // set default collection instance factories
+      setInstanceFactory(List.class, ListInstanceFactory.INSTANCE);
+      setInstanceFactory(Set.class, SetInstanceFactory.INSTANCE);
+      setInstanceFactory(SortedSet.class, SortedSetInstanceFactory.INSTANCE);
    }
    
    /**
@@ -89,25 +146,75 @@
       // Get the meta data information
       MetaType metaType = property.getMetaType();
       MetaValue value = property.getValue();
+      if(value != null)
+         metaType = value.getMetaType();
 
-      // FIXME skip CompositeValueInvocationHandler
-      MetaMapper mapper = property.getTransientAttachment(MetaMapper.class);
-      if (mapper == null && metaType.isComposite())
+      MetaMapper<?> mapper = property.getTransientAttachment(MetaMapper.class);
+      if (mapper == null)
       {
-         if(metaType.getTypeName().equals(ObjectName.class.getName()) == false)
+         if(metaType.isComposite())
          {
-            // unwrap
-            Object unwrapped = metaValueFactory.unwrap(value, propertyInfo.getType());
-            if (Proxy.isProxyClass(unwrapped.getClass()))
-               return;            
+            // FIXME skip CompositeValueInvocationHandler
+            if(metaType.getTypeName().equals(ObjectName.class.getName()) == false)
+            {
+               // unwrap
+               Object unwrapped = metaValueFactory.unwrap(value, propertyInfo.getType());
+               if(unwrapped != null)
+               {
+                  if (Proxy.isProxyClass(unwrapped.getClass()))
+                     throw new IllegalStateException("cannot unwrap composite value for property " + property.getName()
+                           + " maybe missing @MetaMapping? " + metaType.getTypeName());                  
+               }
+            }
          }
+         else if(metaType.isCollection())
+         {
+            CollectionMetaType collectionMetaType = (CollectionMetaType) metaType;
+            if(collectionMetaType.getElementType() == AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE)
+            {
+               // FIXME
+               Collection<?> newCollection = unwrapGenericCollection((CollectionValue) value, propertyInfo);
+               propertyInfo.set(attachment, newCollection);
+               return;
+            }
+         }
       }
       
       // Set value
       InstanceClassFactory icf = managedObjectFactory.getInstanceClassFactory(attachment.getClass(), null);
       BeanInfo beanInfo = propertyInfo.getBeanInfo();
       icf.setValue(beanInfo, property, attachment, value);
+   }
+   
+   @SuppressWarnings("unchecked")
+   protected Collection<?> unwrapGenericCollection(CollectionValue collection, PropertyInfo propertyInfo) throws Throwable
+   {
+      // Create a new collection        
+      BeanInfo beanInfo = configuration.getBeanInfo(propertyInfo.getType());
+      Collection newCollection = (Collection) createNewInstance(beanInfo);
       
+      // unwrap generic collection
+      for(MetaValue value : collection.getElements())
+      {
+         ManagedObject o = (ManagedObject) ((GenericValue)value).getValue();
+         newCollection.add(o.getAttachment());
+      }
+      return newCollection;
    }
+   
+   @SuppressWarnings("deprecation")
+   protected Object createNewInstance(BeanInfo beanInfo) throws Throwable
+   {
+      ClassInfo classInfo = beanInfo.getClassInfo();
+      if (classInfo.isInterface())
+      {
+         InstanceFactory<?> instanceFactory = instanceFactoryMap.get(classInfo.getType());
+         if (instanceFactory == null)
+            throw new IllegalArgumentException("Cannot instantiate interface BeanInfo, missing InstanceFactory: " + classInfo);
 
+         return instanceFactory.instantiate(beanInfo);
+      }
+      return beanInfo.newInstance();
+   }
+
 }

Added: trunk/system/src/main/org/jboss/system/server/profileservice/persistence/DefaultManagedObjectPersistencePlugin.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/persistence/DefaultManagedObjectPersistencePlugin.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/persistence/DefaultManagedObjectPersistencePlugin.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -0,0 +1,86 @@
+/*
+ * 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.system.server.profileservice.persistence;
+
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.system.server.profileservice.persistence.xml.PersistedManagedObject;
+
+/**
+ * The default ManagedObject persistence plugin. 
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class DefaultManagedObjectPersistencePlugin implements ManagedObjectPersistencePlugin
+{
+
+   /** The default persistence delegate. */
+   private final DefaultPersistenceDelegate persistenceDelegate;
+   
+   /** The default recreation delegate. */
+   private final DefaultRecreationDelegate recreationDelegate;
+   
+   public DefaultManagedObjectPersistencePlugin(AbstractValuePersistence valuePersistence,
+         AbstractValueRecreation valueRecreation, ManagedObjectRecreationHelper helper)
+   {
+      // Create the delegates
+      this.persistenceDelegate = new DefaultPersistenceDelegate(valuePersistence);
+      this.recreationDelegate = new DefaultRecreationDelegate(valueRecreation, helper);
+   }
+   
+   public String getType()
+   {
+      return Object.class.getName();
+   }
+   
+   public AbstractValuePersistence getValuePersistence()
+   {
+      return persistenceDelegate.getValuePersistence();
+   }
+   
+   public AbstractValueRecreation getValueRecreation()
+   {
+      return recreationDelegate.getValueRecreation();
+   }
+   
+   public PersistedManagedObject createPersistedManagedObject(ManagedObject mo)
+   {
+      return persistenceDelegate.createPersistedManagedObject(mo);
+   }
+   
+   public PersistedManagedObject createPersistedManagedObject(PersistedManagedObject persisted, ManagedObject mo)
+   {
+      return persistenceDelegate.createPersistedManagedObject(persisted, mo);
+   }
+   
+   public ManagedObject createManagedObject(PersistedManagedObject persisted)
+   {
+      return recreationDelegate.createManagedObject(persisted);
+   }
+   
+   public ManagedObject updateManagedObject(PersistedManagedObject persisted, ManagedObject mo)
+   {
+      return recreationDelegate.updateManagedObject(persisted, mo);
+   }
+   
+}
+

Deleted: trunk/system/src/main/org/jboss/system/server/profileservice/persistence/DefaultManagedObjectPlugin.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/persistence/DefaultManagedObjectPlugin.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/persistence/DefaultManagedObjectPlugin.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -1,62 +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.system.server.profileservice.persistence;
-
-import org.jboss.managed.api.ManagedObject;
-import org.jboss.system.server.profileservice.persistence.xml.PersistedManagedObject;
-
-/**
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public class DefaultManagedObjectPlugin extends AbstractManagedObjectPersistencePlugin
-{
- 
-   public DefaultManagedObjectPlugin()
-   {
-      //
-   }
-   
-   public DefaultManagedObjectPlugin(AbstractValuePersistence valuePersistence)
-   {
-      setValuePersistence(valuePersistence);
-   }
-   
-   @Override
-   public String getType()
-   {
-      return Object.class.getName();
-   }
-   
-   @Override
-   public PersistedManagedObject createPersistedManagedObject(PersistedManagedObject persisted, ManagedObject mo)
-   {
-      // Create the persisted information
-      persisted = super.createPersistedManagedObject(persisted, mo);
-      // Process the properties
-      processProperties(persisted, mo);
-      // Return
-      return persisted;
-   }
-
-}
-

Added: trunk/system/src/main/org/jboss/system/server/profileservice/persistence/DefaultPersistenceDelegate.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/persistence/DefaultPersistenceDelegate.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/persistence/DefaultPersistenceDelegate.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -0,0 +1,54 @@
+/*
+ * 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.system.server.profileservice.persistence;
+
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.system.server.profileservice.persistence.xml.PersistedManagedObject;
+
+/**
+ * The default persistence plugin. This will create a PersistedManagedObject
+ * with it's properties.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class DefaultPersistenceDelegate extends AbstractManagedObjectPersistence
+{
+   
+   public DefaultPersistenceDelegate(AbstractValuePersistence valuePersistence)
+   {
+      super(valuePersistence);
+   }
+   
+   @Override
+   public PersistedManagedObject createPersistedManagedObject(PersistedManagedObject persisted, ManagedObject mo)
+   {
+      // Create the persisted information
+      persisted = super.createPersistedManagedObject(persisted, mo);
+      // Process the properties
+      processProperties(persisted, mo);
+      // Return
+      return persisted;
+   }
+
+}
+

Added: trunk/system/src/main/org/jboss/system/server/profileservice/persistence/DefaultRecreationDelegate.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/persistence/DefaultRecreationDelegate.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/persistence/DefaultRecreationDelegate.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -0,0 +1,103 @@
+/*
+ * 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.system.server.profileservice.persistence;
+
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.system.server.profileservice.persistence.xml.PersistedManagedObject;
+
+/**
+ * The default ManagedObject recreation plugin. This will process and update
+ * the ManagedObject and it's properties.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class DefaultRecreationDelegate extends AbstractManagedObjectRecreation
+{
+   
+   /** The recreation helper. */
+   private final ManagedObjectRecreationHelper helper;
+   
+   public DefaultRecreationDelegate(AbstractValueRecreation valueRecreation, ManagedObjectRecreationHelper helper)
+   {
+      super(valueRecreation);
+      if(helper == null)
+         throw new IllegalArgumentException("null helper");
+      
+      this.helper = helper;
+   }
+
+   public ManagedObject createManagedObject(PersistedManagedObject persisted)
+   {
+      if(persisted == null)
+         throw new IllegalArgumentException("null persisted managed object.");
+      
+      String className = persisted.getTemplateName();
+      if(className == null)
+         className = persisted.getClassName();
+
+      ManagedObject mo = createManagedObjectSkeleton(className);
+      if(mo == null)
+         throw new RuntimeException("could not recreate managed object for class " + className);
+      return updateManagedObject(persisted, mo);
+   }
+
+   public ManagedObject updateManagedObject(PersistedManagedObject persisted, ManagedObject mo)
+   {
+      if(persisted == null)
+         throw new IllegalArgumentException("null persisted managed object");
+      if(mo == null)
+         throw new IllegalArgumentException("null managed object");
+      
+      // Process properties
+      processProperties(persisted, mo);
+      
+      return mo;
+   }
+   
+   protected ManagedObject createManagedObjectSkeleton(String className)
+   {
+      try
+      {
+         return this.helper.createManagedObjectSkeleton(className);
+      }
+      catch(ClassNotFoundException cnfe)
+      {
+         throw new RuntimeException("could not recreate attachment", cnfe);
+      }
+   }
+   
+   @Override
+   protected void setValue(String name, ManagedProperty property, Object attachment)
+   {
+      try
+      {
+         this.helper.setValue(name, property, attachment);
+      }
+      catch (Throwable e)
+      {
+         throw new RuntimeException("Could not set value for property: " + property, e);
+      }
+   }
+}
+

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/persistence/DelegatingPersistencePlugin.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/persistence/DelegatingPersistencePlugin.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/persistence/DelegatingPersistencePlugin.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -30,6 +30,8 @@
 import org.jboss.system.server.profileservice.persistence.xml.PersistedManagedObject;
 
 /**
+ * A delegating persistence plugin.
+ * 
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
  * @version $Revision$
  */
@@ -48,19 +50,32 @@
    /** The value persistence. */
    private final AbstractValuePersistence valuePersistence;
    
-   public DelegatingPersistencePlugin()
+   /** The value recreation. */
+   private AbstractValueRecreation valueRecreation;
+   
+   public DelegatingPersistencePlugin(ManagedObjectRecreationHelper helper)
    {
-      this(new DefaultManagedObjectPlugin());
+      this.valuePersistence = new AbstractValuePersistence(this, metaValueFactory);
+      this.valueRecreation = new AbstractValueRecreation(this);
+      this.defaultPlugin = new DefaultManagedObjectPersistencePlugin(valuePersistence, valueRecreation, helper);
    }
    
-   public DelegatingPersistencePlugin(ManagedObjectPersistencePlugin defaultPlugin)
+   public String getType()
    {
-      this.valuePersistence = new AbstractValuePersistence(this, metaValueFactory);
-      this.defaultPlugin = defaultPlugin;
-      this.defaultPlugin.setValuePersistence(valuePersistence);
+      return Object.class.getName();
    }
    
    /**
+    * Get the value recreation.
+    * 
+    * @return the value recreation
+    */
+   public AbstractValuePersistence getValuePersistence()
+   {
+      return this.valuePersistence;
+   }
+   
+   /**
     * Create a persisted managed object.
     * 
     * @param mo the managed object
@@ -94,6 +109,49 @@
    }
    
    /**
+    * Get the value persistence.
+    * 
+    * @return the value persistence
+    */
+   public AbstractValueRecreation getValueRecreation()
+   {
+      return this.valueRecreation;
+   }
+   
+   /**
+    * Create a persisted managed object
+    * 
+    * @param mo the managed object
+    * @return the persistence xml meta data for managed object
+    */
+   public ManagedObject createManagedObject(PersistedManagedObject persisted)
+   {
+      if(persisted == null)
+         throw new IllegalArgumentException("null persisted managed object");
+      
+      ManagedObjectPersistencePlugin plugin = getPlugin(persisted);
+      return plugin.createManagedObject(persisted);
+   }
+
+   /**
+    * Create a persisted managed object
+    * 
+    * @param persisted the persisted managed object
+    * @param mo the managed object
+    * @return the persistence xml meta data for managed object
+    */
+   public ManagedObject updateManagedObject(PersistedManagedObject persisted, ManagedObject mo)
+   {
+      if(persisted == null)
+         throw new IllegalArgumentException("null persisted managed object");
+      if(mo == null)
+         throw new IllegalArgumentException("null managed object");
+      
+      ManagedObjectPersistencePlugin plugin = getPlugin(persisted);
+      return plugin.updateManagedObject(persisted, mo);
+   }
+   
+   /**
     * Extract the type name and get the plugin.
     * 
     * @param mo the managed object
@@ -104,14 +162,28 @@
       String type = mo.getAttachmentName();
       if(type == null && mo.getAttachment() != null)
          type = mo.getAttachment().getClass().getName();
-      // As the console is creating their own ManagedObjectImpl
-      // it could happen that the MO is not populated correctly.
-      if(type == null)
-         return defaultPlugin;
+
       return getPlugin(type);
    }
    
    /**
+    * Get the plugin registered for persisted managed object.
+    * 
+    * @param persisted the persisted managed object
+    * @return the ManagedObject recreation plugin
+    */
+   protected ManagedObjectPersistencePlugin getPlugin(PersistedManagedObject persisted)
+   {
+      if(persisted == null)
+         throw new IllegalArgumentException("null persisted managed object");
+      
+      String className = persisted.getTemplateName();
+      if(className == null)
+         className = persisted.getClassName();
+      return getPlugin(className);
+   }
+   
+   /**
     * Get the plugin.
     * 
     * @param type the managed object type
@@ -133,14 +205,13 @@
     * 
     * @param plugin the plugin to add
     */
-   public void addPlugin(AbstractManagedObjectPersistencePlugin plugin)
+   public void addPlugin(ManagedObjectPersistencePlugin plugin)
    {
       if(plugin == null)
          throw new IllegalArgumentException("Null plugin.");
       if(plugin.getType() == null)
          throw new IllegalArgumentException("Null plugin type.");
 
-      plugin.setValuePersistence(this.valuePersistence);
       this.plugins.put(plugin.getType(), plugin);
    }
 
@@ -149,7 +220,7 @@
     * 
     * @param plugin the plugin to remove
     */
-   public void removePlugin(AbstractManagedObjectPersistencePlugin plugin)
+   public void removePlugin(ManagedObjectPersistencePlugin plugin)
    {
       if(plugin == null)
          throw new IllegalArgumentException("Null plugin.");
@@ -159,14 +230,4 @@
       this.plugins.remove(plugin.getType());
    }
 
-   public AbstractValuePersistence getValuePersistence()
-   {
-      return this.valuePersistence;
-   }
-   
-   public void setValuePersistence(AbstractValuePersistence valuePersistence)
-   {
-      // 
-   }
-
 }

Deleted: trunk/system/src/main/org/jboss/system/server/profileservice/persistence/ManagedGenericOverrideHandler.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/persistence/ManagedGenericOverrideHandler.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/persistence/ManagedGenericOverrideHandler.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -1,325 +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.system.server.profileservice.persistence;
-
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.SortedSet;
-import java.util.Stack;
-import java.util.WeakHashMap;
-
-import org.jboss.beans.info.spi.BeanInfo;
-import org.jboss.beans.info.spi.PropertyInfo;
-import org.jboss.config.plugins.property.PropertyConfiguration;
-import org.jboss.config.spi.Configuration;
-import org.jboss.managed.api.Fields;
-import org.jboss.managed.api.ManagedObject;
-import org.jboss.managed.api.ManagedProperty;
-import org.jboss.managed.plugins.factory.AbstractManagedObjectFactory;
-import org.jboss.metatype.api.types.CollectionMetaType;
-import org.jboss.metatype.api.values.CollectionValue;
-import org.jboss.metatype.api.values.GenericValue;
-import org.jboss.metatype.api.values.GenericValueSupport;
-import org.jboss.metatype.api.values.InstanceFactory;
-import org.jboss.metatype.api.values.MetaValue;
-import org.jboss.metatype.plugins.values.ListInstanceFactory;
-import org.jboss.metatype.plugins.values.SetInstanceFactory;
-import org.jboss.metatype.plugins.values.SortedSetInstanceFactory;
-import org.jboss.reflect.spi.ClassInfo;
-import org.jboss.system.server.profileservice.persistence.xml.ModificationInfo;
-import org.jboss.system.server.profileservice.persistence.xml.PersistedGenericValue;
-import org.jboss.system.server.profileservice.persistence.xml.PersistedManagedObject;
-import org.jboss.system.server.profileservice.persistence.xml.PersistedProperty;
-
-/**
- * A handler for updating generic values.
- * 
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public class ManagedGenericOverrideHandler extends ManagedObjectOverride
-{
-
-   /** The instance factory builders */
-   private Map<Class<?>, InstanceFactory<?>> instanceFactoryMap = new WeakHashMap<Class<?>, InstanceFactory<?>>();
-   
-   /** The merging stack. */
-   private Stack<MergingProperties> properties = new Stack<MergingProperties>();
-   
-   /** The configuration */
-   private static Configuration configuration;
-
-   static
-   {
-      configuration = AccessController.doPrivileged(new PrivilegedAction<Configuration>()
-      {
-         public Configuration run()
-         {
-            return new PropertyConfiguration();
-         }
-      });
-   }
-   
-   public ManagedGenericOverrideHandler()
-   {
-      // set default collection instance factories
-      setInstanceFactory(List.class, ListInstanceFactory.INSTANCE);
-      setInstanceFactory(Set.class, SetInstanceFactory.INSTANCE);
-      setInstanceFactory(SortedSet.class, SortedSetInstanceFactory.INSTANCE);
-   }
-   
-   public <T> void setInstanceFactory(Class<T> clazz, InstanceFactory<T> factory)
-   {
-      synchronized(instanceFactoryMap)
-      {
-         if (factory == null)
-            instanceFactoryMap.remove(clazz);
-         else
-            instanceFactoryMap.put(clazz, factory);
-      }
-   }
-   
-   @Override
-   protected void processProperty(ManagedProperty property, PersistedProperty propertyElement, Object attachment,
-         boolean trace) throws Throwable
-   {
-      
-      if (property == null)
-         throw new IllegalStateException("Null property");
-      
-      // The propertyInfo
-      PropertyInfo info = property.getField(Fields.PROPERTY_INFO, PropertyInfo.class);
-      if(info.isReadable() == false)
-      {
-         log.trace("Skipping not readable property " + info);
-         return;
-      }
-      
-      // Push the merging item
-      MergingProperties item = new MergingProperties(attachment, info, propertyElement);
-      this.properties.push(item);
-      try
-      {
-         super.processProperty(property, propertyElement, attachment, trace);
-      }
-      finally
-      {
-         this.properties.pop();
-      }   
-   }
-   
-   @Override
-   protected void setValue(ManagedProperty property, MetaValue value, Object attachment) throws Throwable
-   {
-      if(value == null)
-         return;
-      
-      if (value.getMetaType().isGeneric())
-      {
-         // FIXME
-         if(value.getMetaType().equals(GENERIC_PERSISTED_VALUE_TYPE))
-         {
-            // See if we need to recreate a managed object
-            PersistedGenericValue moElement = (PersistedGenericValue) ((GenericValue) value).getValue();
-            if (moElement.getManagedObject() == null)
-               return;
-
-            if (moElement.getManagedObject().getClassName() == null
-                  && moElement.getManagedObject().getTemplateName() == null)
-               return;
-            
-            ManagedObject mo = createManagedObject(moElement.getManagedObject());
-            value = new GenericValueSupport(AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE, mo);  
-         }
-      }
-      // 
-      super.setValue(property, value, attachment);
-   }
-   
-   
-   /**
-    * Create a merged collection value.
-    * 
-    * @param original the original collection
-    * @param override the override collection
-    * @return the merged collection
-    * @throws Throwable 
-    */
-   @Override
-   protected CollectionValue mergeCollection(CollectionValue original, CollectionValue override, boolean trace)
-         throws Throwable
-   {
-      CollectionMetaType metaType = original.getMetaType();
-      if (metaType.getElementType().isGeneric())
-      {
-         // Check if the recreation was wrapping the correct value
-//         CollectionMetaType overrideMetaType = override.getMetaType();
-//         if(overrideMetaType.getElementType().equals(GENERIC_PERSISTED_VALUE_TYPE) == false)
-//            throw new IllegalStateException("Wrong generic value type: " + overrideMetaType.getElementType());
-         
-         
-         // Extract the information
-         MergingProperties item = this.properties.peek();
-         PropertyInfo propertyInfo = item.getPropertyInfo();
-         Object attachment = item.getAttachment();
-         
-         if(propertyInfo.isWritable() == false)
-         {
-            log.debug("Ignoring not writable property: " + propertyInfo);
-            return null;
-         }
-         
-         // Extract original collection
-         Collection<?> c = (Collection<?>) propertyInfo.get(attachment);
-         // Skip
-         if(c == null || c.isEmpty())
-            return null;
-         
-
-         // This should not happen
-         if(c.size() < override.getSize())
-            throw new IllegalStateException("c.size() < override.getSize()");
-         
-         // First identify the names of removed components
-         HashSet<String> removedNames = new HashSet<String>();
-         for (MetaValue mv : override)
-         {
-            // Extract the generic information
-            GenericValue overrideGeneric = (GenericValue) mv;
-            PersistedGenericValue overrideGenericValue = (PersistedGenericValue) overrideGeneric.getValue();
-            PersistedManagedObject pmo = overrideGenericValue.getManagedObject();
-            if (pmo.getModificationInfo() != ModificationInfo.REMOVED)
-               continue;
-            String name = overrideGenericValue.getManagedObject().getName();
-            if (name == null)
-               name = overrideGenericValue.getManagedObject().getOriginalName();
-            if (name != null)
-               removedNames.add(name);
-         }
-
-         Iterator<?> rawIterator = c.iterator();
-         Iterator<MetaValue> originalIterator = original.iterator();
-         Iterator<MetaValue> overrideIterator = override.iterator();
-
-         // Create a new collection        
-         BeanInfo beanInfo = configuration.getBeanInfo(propertyInfo.getType());
-         Collection newCollection = (Collection) createNewInstance(beanInfo);
-
-         while (rawIterator.hasNext())
-         {
-            // The raw object
-            Object o = rawIterator.next();
-            
-            // Skip generic values which are not annotated
-            GenericValue originalGeneric = (GenericValue) originalIterator.next();
-            
-            // Extract the generic information
-            GenericValue overrideGeneric = (GenericValue) overrideIterator.next();
-            PersistedGenericValue overrideGenericValue = (PersistedGenericValue) overrideGeneric.getValue(); 
-            
-            // Skip not annotated managed objects
-            if(originalGeneric.getValue() == null)
-            {
-               newCollection.add(o);
-               continue;
-            }
-            // Remove a ManagedObject
-            Object og = originalGeneric.getValue();
-            if ((og instanceof ManagedObject))
-            {
-               ManagedObject originalMO = (ManagedObject) og;
-               String name = originalMO.getName();
-               if(removedNames.contains(name))
-                  continue;
-            }
-
-            // process the generic value
-            processGenericValue(originalGeneric, overrideGenericValue, trace);
-            
-            newCollection.add(o);
-         }
-         propertyInfo.set(attachment, newCollection);
-         
-         // This does not need to get populated
-         return null;
-      }
-      else
-      {
-         // Normal merge
-         return super.mergeCollection(original, override, trace);
-      }
-   }
-   
-   @SuppressWarnings("deprecation")
-   protected Object createNewInstance(BeanInfo beanInfo) throws Throwable
-   {
-      ClassInfo classInfo = beanInfo.getClassInfo();
-      if (classInfo.isInterface())
-      {
-         InstanceFactory<?> instanceFactory = instanceFactoryMap.get(classInfo.getType());
-         if (instanceFactory == null)
-            throw new IllegalArgumentException("Cannot instantiate interface BeanInfo, missing InstanceFactory: " + classInfo);
-
-         return instanceFactory.instantiate(beanInfo);
-      }
-      return beanInfo.newInstance();
-   }
-   
-   public static class MergingProperties
-   {
-      /** The attachment. */
-      private Object attachment;
-
-      /** The managed object. */
-      private PropertyInfo propertyInfo;
-      
-      /** The persisted property. */
-      private PersistedProperty propertyElement;
-
-      public MergingProperties(Object attachment, PropertyInfo info, PersistedProperty propertyElement)
-      {
-         this.attachment = attachment;
-         this.propertyInfo = info;
-         this.propertyElement = propertyElement;
-      }
-
-      public Object getAttachment()
-      {
-         return attachment;
-      }
-      public PropertyInfo getPropertyInfo()
-      {
-         return propertyInfo;
-      }
-      public PersistedProperty getPropertyElement()
-      {
-         return propertyElement;
-      }
-   }
-
-}

Deleted: trunk/system/src/main/org/jboss/system/server/profileservice/persistence/ManagedObjectOverride.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/persistence/ManagedObjectOverride.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/persistence/ManagedObjectOverride.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -1,287 +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.system.server.profileservice.persistence;
-
-import org.jboss.logging.Logger;
-import org.jboss.managed.api.Fields;
-import org.jboss.managed.api.ManagedObject;
-import org.jboss.managed.api.ManagedProperty;
-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.CompositeValue;
-import org.jboss.metatype.api.values.GenericValue;
-import org.jboss.metatype.api.values.MetaValue;
-import org.jboss.metatype.api.values.TableValue;
-import org.jboss.system.server.profileservice.persistence.xml.PersistedGenericValue;
-import org.jboss.system.server.profileservice.persistence.xml.PersistedManagedObject;
-import org.jboss.system.server.profileservice.persistence.xml.PersistedProperty;
-import org.jboss.system.server.profileservice.persistence.xml.PersistedValue;
-
-/**
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public class ManagedObjectOverride extends ManagedObjectRecreation
-{
-
-   /** The logger. */
-   protected static final Logger log = Logger.getLogger(ManagedObjectOverride.class);
-
-   /** The attachment property populator. */
-   private AttachmentPropertyPopulator populator = new AttachmentPropertyPopulator();
-
-   public ManagedObject update(Object attachment, PersistedManagedObject element) throws Throwable
-   {
-      if (attachment == null)
-         throw new IllegalArgumentException("Null attachment");
-      if (element == null)
-         throw new IllegalArgumentException("Null persisted information.");
-
-      // The managed object
-      ManagedObject mo = buildManagedObject(attachment);
-      
-      //
-      if(mo == null)
-         return null;
-      
-      // Update
-      updateManagedObject(mo, element, attachment);
-
-      return mo;
-   }
-
-   public void updateManagedObject(ManagedObject mo, PersistedManagedObject element, Object attachment)
-         throws Throwable
-   {
-      if(mo == null)
-         throw new IllegalArgumentException("Null managed object.");
-      if(element == null)
-         throw new IllegalArgumentException("Null persisted information.");
-      // 
-      if(attachment == null)
-         attachment = mo.getAttachment();
-      if(attachment == null)
-         throw new IllegalArgumentException("Null attachment.");
-      
-      boolean trace = log.isTraceEnabled();
-      
-      // Process properties
-      for (PersistedProperty persisted : element.getProperties())
-      {
-         ManagedProperty property = mo.getProperty(persisted.getName());
-         // Process
-         processProperty(property, persisted, attachment, trace);
-      }
-   }
-
-   protected void processProperty(ManagedProperty property, PersistedProperty propertyElement, Object attachment,
-         boolean trace) throws Throwable
-   {
-      if (property == null)
-         throw new IllegalStateException("Null property");
-
-      // Get the original values
-      MetaValue metaValue = property.getValue();
-      MetaType metaType = property.getMetaType();
-      if (metaValue != null)
-         metaType = metaValue.getMetaType();
-
-      //
-      PersistedValue valueElement = propertyElement.getValue();
-      
-      // Recreate the metaValue
-      MetaValue override = createMetaValue(valueElement, metaType);
-
-      // Process
-      MetaValue value = processMetaValue(metaValue, override, trace);
-      
-      //
-      setValue(property, value, attachment);
-   }
-
-   protected void setValue(ManagedProperty property, MetaValue value, Object attachment)
-         throws Throwable
-   {
-      // Skip null metaValues
-      if(value == null)
-         return;
-
-      // Set the values 
-      property.setField(Fields.VALUE, value);
-      // Update meta type
-      property.setField(Fields.META_TYPE, value.getMetaType());
-      
-      // Populate the values
-      populator.processManagedProperty(property.getName(), property, attachment);
-   }
-
-   protected MetaValue processMetaValue(MetaValue original, MetaValue override, boolean trace) throws Throwable
-   {
-      if (override == null)
-         return original;
-      if (original == null)
-         return override;
-
-      if (original.getMetaType() == null)
-         throw new IllegalStateException("Original meta value is null " + original);
-         
-
-      // Now try to merge
-      MetaType metaType = original.getMetaType();
-      MetaValue metaValue = null;
-      if (metaType.isSimple())
-      {
-         metaValue = override;
-      }
-      else if (metaType.isEnum())
-      {
-         metaValue = override;
-      }
-      else if (metaType.isCollection())
-      {
-         metaValue = mergeCollection(
-               (CollectionValue) original,
-               (CollectionValue) override, trace);
-      }
-      else if (metaType.isGeneric())
-      {
-         metaValue = mergeGenericValue(
-               (GenericValue) original,
-               (GenericValue) override, trace);
-      }
-      else if (metaType.isComposite())
-      {
-         metaValue = mergeCompositeValue(
-               (CompositeValue) original,
-               (CompositeValue) override, trace);
-      }
-      else if (metaType.isTable())
-      {
-         metaValue = mergeTableValue(
-               (TableValue) original,
-               (TableValue) override, trace);
-      }
-      else if (metaType.isArray())
-      {
-         metaValue = mergeArray(
-               (ArrayValue) original,
-               (ArrayValue) override, trace);
-      }
-      else
-      {
-         throw new IllegalStateException("unknown metaType");
-      }
-      return metaValue;
-   }
-
-   /**
-    * Merge a composite value.
-    * 
-    * @param original
-    * @param override
-    * @return
-    */
-   protected CompositeValue mergeCompositeValue(CompositeValue original, CompositeValue override, boolean trace)
-   {
-      return override;
-   }
-
-   /**
-    * Merge a table
-    * 
-    * @param original
-    * @param override
-    * @return
-    */
-   protected TableValue mergeTableValue(TableValue original, TableValue override, boolean trace)
-   {
-      return override;
-   }
-
-   /**
-    * Create a merged array value.
-    * 
-    * @param original the original array
-    * @param override the override array
-    * @return the merged array
-    */
-   protected ArrayValue mergeArray(ArrayValue original, ArrayValue override, boolean trace)
-   {
-      return override;
-   }
-
-   /**
-    * Create a merged collection value.
-    * 
-    * @param original the original collection
-    * @param override the override collection
-    * @return the merged collection
-    * @throws Throwable 
-    */
-   protected CollectionValue mergeCollection(CollectionValue original, CollectionValue override, boolean trace)
-         throws Throwable
-   {
-      return override;
-   }
-
-   /**
-    * Merge a generic value.
-    * 
-    * @param original the original generic value
-    * @param override the override generic value
-    * @return the merged value
-    */
-   protected GenericValue mergeGenericValue(GenericValue original, GenericValue override, boolean trace)
-         throws Throwable
-   {
-      Object v = override.getValue();
-      if (v instanceof PersistedGenericValue)
-      {
-         PersistedGenericValue moElement = (PersistedGenericValue) override.getValue();
-
-         return processGenericValue(original, moElement, trace);
-      }
-      // Don't do anything
-      return null;
-   }
-
-   protected GenericValue processGenericValue(GenericValue original, PersistedGenericValue override, boolean trace)
-         throws Throwable
-   {
-      // Don't do anything
-      if(override.getManagedObject() == null)
-         return null;
-      
-      Object o = original.getValue();
-      if ((o instanceof ManagedObject))
-      {
-         ManagedObject originalMO = (ManagedObject) o;
-
-         // process
-         updateManagedObject(originalMO, override.getManagedObject(), originalMO.getAttachment());
-         return original;
-      }
-      throw new RuntimeException("Cannot merge original: " + original + ", override: " + override);
-   }
-
-}

Deleted: trunk/system/src/main/org/jboss/system/server/profileservice/persistence/ManagedObjectPeristenceHandler.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/persistence/ManagedObjectPeristenceHandler.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/persistence/ManagedObjectPeristenceHandler.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -1,80 +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.system.server.profileservice.persistence;
-
-import org.jboss.managed.api.ManagedObject;
-import org.jboss.system.server.profileservice.persistence.xml.PersistedManagedObject;
-
-/**
- * Create a xml representation of a Managed Object.
- * 
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public class ManagedObjectPeristenceHandler
-{
-   
-   /** . */
-   private final ManagedObjectPersistencePlugin plugin;
-
-   public ManagedObjectPeristenceHandler()
-   {
-      this.plugin = new DelegatingPersistencePlugin();
-   }
-   
-   /**
-    * Create the persistence meta data for a ManagedObject.
-    * 
-    * @param mo the managed object
-    * @return the persistence meta data
-    */
-   public PersistedManagedObject createPersistenceMetaData(ManagedObject mo)
-   {
-      if(mo == null)
-         throw new IllegalArgumentException("Null managedObject.");
-      
-      return getPlugin().createPersistedManagedObject(mo);
-   }
-   
-   /**
-    * Process a managed object.
-    * 
-    * @param moElement the xml meta data.
-    * @param mo the managed object
-    * @return isModified
-    */
-   public void processManagedObject(PersistedManagedObject persisted, ManagedObject mo)
-   {
-      if(persisted == null)
-         throw new IllegalArgumentException("Null rootElement.");
-      if(mo == null)
-         throw new IllegalArgumentException("null managedObject");
-      
-      getPlugin().createPersistedManagedObject(persisted, mo);
-   }
-
-   protected ManagedObjectPersistencePlugin getPlugin()
-   {
-      return this.plugin;
-   }
-   
-}

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/persistence/ManagedObjectPersistencePlugin.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/persistence/ManagedObjectPersistencePlugin.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/persistence/ManagedObjectPersistencePlugin.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -25,6 +25,9 @@
 import org.jboss.system.server.profileservice.persistence.xml.PersistedManagedObject;
 
 /**
+ * The managed object persistence plugin, handling the persistence
+ * of a ManagedObject.
+ * 
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
  * @version $Revision$
  */
@@ -32,18 +35,25 @@
 {
 
    /**
+    * Get the plugin type.
+    * 
+    * @return the type
+    */
+   String getType();
+   
+   /**
     * Get the value persistence.
     * 
     * @return the value persistence
     */
-   AbstractValuePersistence getValuePersistence(); 
+   AbstractValuePersistence getValuePersistence();
    
    /**
-    * Set the value persistence.
+    * Get the value recreation.
     * 
-    * @param valuePersistence the value persistence
+    * @return the value recreation
     */
-   void setValuePersistence(AbstractValuePersistence valuePersistence);
+   AbstractValueRecreation getValueRecreation();
    
    /**
     * Create a persisted managed object
@@ -62,4 +72,21 @@
     */
    PersistedManagedObject createPersistedManagedObject(PersistedManagedObject persisted, ManagedObject mo);
    
+   /**
+    * Create a managed object, based on the persisted information.
+    * 
+    * @param persisted the persisted managed object
+    * @return the managed object
+    */
+   ManagedObject createManagedObject(PersistedManagedObject persisted);
+   
+   /**
+    * Update a managed object, based on the persisted information.
+    * 
+    * @param persisted the persisted managed object
+    * @param mo the managed object
+    * @return the managed object
+    */
+   ManagedObject updateManagedObject(PersistedManagedObject persisted, ManagedObject mo);
+   
 }

Deleted: trunk/system/src/main/org/jboss/system/server/profileservice/persistence/ManagedObjectRecreation.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/persistence/ManagedObjectRecreation.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/persistence/ManagedObjectRecreation.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -1,595 +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.system.server.profileservice.persistence;
-
-import java.io.Serializable;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.jboss.logging.Logger;
-import org.jboss.managed.api.Fields;
-import org.jboss.managed.api.ManagedObject;
-import org.jboss.managed.api.ManagedProperty;
-import org.jboss.managed.api.MutableManagedObject;
-import org.jboss.managed.api.annotation.ViewUse;
-import org.jboss.metadata.spi.MetaData;
-import org.jboss.metatype.api.types.ArrayMetaType;
-import org.jboss.metatype.api.types.CollectionMetaType;
-import org.jboss.metatype.api.types.CompositeMetaType;
-import org.jboss.metatype.api.types.EnumMetaType;
-import org.jboss.metatype.api.types.GenericMetaType;
-import org.jboss.metatype.api.types.MapCompositeMetaType;
-import org.jboss.metatype.api.types.MetaType;
-import org.jboss.metatype.api.types.Name;
-import org.jboss.metatype.api.types.PropertiesMetaType;
-import org.jboss.metatype.api.types.SimpleMetaType;
-import org.jboss.metatype.api.types.TableMetaType;
-import org.jboss.metatype.api.values.ArrayValue;
-import org.jboss.metatype.api.values.ArrayValueSupport;
-import org.jboss.metatype.api.values.CollectionValue;
-import org.jboss.metatype.api.values.CollectionValueSupport;
-import org.jboss.metatype.api.values.CompositeValue;
-import org.jboss.metatype.api.values.CompositeValueSupport;
-import org.jboss.metatype.api.values.EnumValue;
-import org.jboss.metatype.api.values.EnumValueSupport;
-import org.jboss.metatype.api.values.GenericValue;
-import org.jboss.metatype.api.values.GenericValueSupport;
-import org.jboss.metatype.api.values.MapCompositeValueSupport;
-import org.jboss.metatype.api.values.MetaValue;
-import org.jboss.metatype.api.values.PropertiesMetaValue;
-import org.jboss.metatype.api.values.SimpleValue;
-import org.jboss.metatype.api.values.SimpleValueSupport;
-import org.jboss.metatype.api.values.TableValue;
-import org.jboss.metatype.api.values.TableValueSupport;
-import org.jboss.metatype.plugins.types.StringName;
-import org.jboss.reflect.plugins.ValueConvertor;
-import org.jboss.system.server.profileservice.persistence.xml.NullValue;
-import org.jboss.system.server.profileservice.persistence.xml.PersistedArrayValue;
-import org.jboss.system.server.profileservice.persistence.xml.PersistedCollectionValue;
-import org.jboss.system.server.profileservice.persistence.xml.PersistedCompositeValue;
-import org.jboss.system.server.profileservice.persistence.xml.PersistedEnumValue;
-import org.jboss.system.server.profileservice.persistence.xml.PersistedGenericValue;
-import org.jboss.system.server.profileservice.persistence.xml.PersistedManagedObject;
-import org.jboss.system.server.profileservice.persistence.xml.PersistedPair;
-import org.jboss.system.server.profileservice.persistence.xml.PersistedPropertiesValue;
-import org.jboss.system.server.profileservice.persistence.xml.PersistedProperty;
-import org.jboss.system.server.profileservice.persistence.xml.PersistedSimpleValue;
-import org.jboss.system.server.profileservice.persistence.xml.PersistedTableValue;
-import org.jboss.system.server.profileservice.persistence.xml.PersistedValue;
-
-/**
- * This handler recreates only the ManagedObject based on the persisted meta data.
- * 
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public class ManagedObjectRecreation 
-{
-   /** The generic type of a persisted generic value */
-   public final static GenericMetaType GENERIC_PERSISTED_VALUE_TYPE = new GenericMetaType(PersistedGenericValue.class.getName(), "persisted generic value");
-   
-   /** The meta data. */
-   private MetaData metaData;
-   
-   /** The plugin. */
-   private MOCreatorPlugin plugin;
-   
-   /** The simple types. */
-   private final static Map<String, Class<? extends Serializable>> simpleTypes = new HashMap<String, Class<? extends Serializable>>();
-   
-   /** The logger. */
-   private final static Logger log = Logger.getLogger(ManagedObjectRecreation.class);   
-   
-   static
-   {
-      // Fill simple types map.
-      simpleTypes.put(BigDecimal.class.getName(), BigDecimal.class);
-      simpleTypes.put(BigInteger.class.getName(), BigInteger.class);
-      simpleTypes.put(Boolean.class.getName(), Boolean.class);
-      simpleTypes.put(Byte.class.getName(), Byte.class);
-      simpleTypes.put(Character.class.getName(), Character.class);
-      simpleTypes.put(Date.class.getName(), Date.class);
-      simpleTypes.put(Double.class.getName(), Double.class);
-      simpleTypes.put(Float.class.getName(), Float.class);
-      simpleTypes.put(Integer.class.getName(), Integer.class);
-      simpleTypes.put(Long.class.getName(), Long.class);
-      simpleTypes.put(Short.class.getName(), Short.class);
-      simpleTypes.put(String.class.getName(), String.class);
-      simpleTypes.put(Name.class.getName(), Name.class);
-      // primitive classes
-      simpleTypes.put(byte.class.getName(), byte.class);
-      simpleTypes.put(char.class.getName(), char.class);
-      simpleTypes.put(double.class.getName(), double.class);
-      simpleTypes.put(float.class.getName(), float.class);
-      simpleTypes.put(int.class.getName(), int.class);
-      simpleTypes.put(short.class.getName(), short.class);
-      simpleTypes.put(long.class.getName(), long.class);
-      simpleTypes.put(boolean.class.getName(), boolean.class);
-   }
-   
-   public ManagedObjectRecreation()
-   {
-      this.plugin = new MOCreatorPlugin();
-   }
-   
-   protected ManagedObject createManagedObject(PersistedManagedObject moElement) throws Exception
-   {
-      if(moElement == null)
-         throw new IllegalArgumentException("Null persisted meta data.");
-      if(moElement.getClassName() == null)
-         throw new IllegalArgumentException("Null class-name for managed object.");
-      
-      // Check if we need to use a template for the managed object
-      String className = moElement.getTemplateName();
-      if(className == null)
-      {
-         className = moElement.getClassName();
-      }
-      ManagedObject mo = buildManagedObject(className); 
-      
-      
-      if(mo instanceof MutableManagedObject)
-      {
-         // Update the name
-         ((MutableManagedObject) mo).setName(moElement.getName());
-
-         if(moElement.getTemplateName() != null)
-         {
-            // Override the actual attachment
-            Class<?> attachment = plugin.getClassLoader().loadClass(moElement.getClassName());
-            ((MutableManagedObject) mo).setAttachment(attachment.newInstance());
-         }
-      }
-      
-      // Process
-      processManagedObject(moElement, mo);
-      
-      // Return
-      return mo;
-   }
-   
-   /**
-    * Process a ManagedObject.
-    * 
-    * @param moElement the persisted xml meta data.
-    * @param mo the managed object
-    * @return the attachment meta data.
-    */
-   private void processManagedObject(PersistedManagedObject moElement, ManagedObject mo)
-   {
-      if(moElement == null)
-         throw new IllegalArgumentException("Null rootElement.");
-      if(mo == null)
-         throw new IllegalArgumentException("null managedObject");
-      
-      // Get the xml to see what we need to merge
-      if(moElement.getProperties() != null && moElement.getProperties().isEmpty() == false)
-      {
-         for(PersistedProperty propertyElement : moElement.getProperties())
-         {
-            ManagedProperty property = mo.getProperty(propertyElement.getName());
-            if(property == null)
-               throw new IllegalStateException("unable to find propery: "+ property);
-            
-            // Skip all non configuration properties
-            if(! property.hasViewUse(ViewUse.CONFIGURATION))
-               continue;
-        
-            // getProperty
-            processManagedProperty(propertyElement, propertyElement.getName(), property, mo.getAttachment());
-         }  
-      }
-   }
-
-   /**
-    * Build a managed object based on the attachment.
-    * 
-    * @param attachment the attachment
-    * @return the ManagedObject
-    * @throws Exception
-    */
-   protected ManagedObject buildManagedObject(Object attachment) throws Exception
-   {
-      return plugin.initManagedObject(attachment, null);
-   }
-   
-   
-   /**
-    * Build a managedObject based on the className
-    * 
-    * @param className the name of the class
-    * @return the ManagedObject
-    * @throws Exception
-    */
-   protected ManagedObject buildManagedObject(String className) throws Exception
-   {
-      return plugin.createManagedObject(className, metaData);
-   }
-   
-   /**
-    * Process a ManagedProperty.
-    * 
-    * @param propertyElement the persisted xml meta data.
-    * @param name the property name.
-    * @param property the managed property.
-    */
-   protected void processManagedProperty(PersistedProperty propertyElement, String name, ManagedProperty property, Object attachment)
-   {
-      // Get MetaType
-      MetaType metaType = property.getMetaType();
-      // Process the value
-      PersistedValue persistedValue = propertyElement.getValue();
-      if(persistedValue != null)
-      {
-         // recurse = true
-         MetaValue value = createMetaValue(persistedValue, metaType);
-         // Set the value Field
-         property.setField(Fields.VALUE, value);
-         // Update meta type
-         if(value != null)
-            property.setField(Fields.META_TYPE, value.getMetaType());
-      }
-      // Done
-   }
-   
-   /**
-    * Create the meta value, based on the xml persited
-    * value and the generated MetaType.
-    * 
-    * @param valueElement the persisted xml element
-    * @param type the meta type.
-    * @return the created meta value.
-    */
-   protected MetaValue createMetaValue(PersistedValue valueElement, MetaType metaType)
-   {
-      if(log.isTraceEnabled())
-      {
-         log.trace("processing value " + valueElement + " type: " + metaType);
-      }
-      
-      if(valueElement instanceof NullValue)
-         return null;
-      
-      if(valueElement == null)
-         return null;
-      
-      MetaValue metaValue = null;
-      try
-      {
-         if(metaType.isSimple())
-         {
-            metaValue = createSimpleValue(
-                  (PersistedSimpleValue) valueElement,
-                  (SimpleMetaType) metaType);
-         }
-         else if(metaType.isEnum())
-         {
-            metaValue = createEnumValue(
-                  (PersistedEnumValue) valueElement,
-                  (EnumMetaType) metaType);
-         }
-         else if(metaType.isCollection())
-         {
-            metaValue = createCollectionValue(
-                  (PersistedCollectionValue) valueElement,
-                  (CollectionMetaType) metaType);
-         }
-         else if(metaType.isGeneric())
-         {
-            metaValue = createGenericValue(
-                  (PersistedGenericValue) valueElement,
-                  (GenericMetaType) metaType);
-         }
-         else if(metaType.isComposite())
-         {
-            metaValue = createCompositeValue(
-                  (PersistedCompositeValue) valueElement,
-                  (CompositeMetaType) metaType);
-         }
-         else if(metaType.isTable())
-         {
-            metaValue = createTableValue(
-                  (PersistedTableValue) valueElement,
-                  (TableMetaType)metaType);
-         }
-         else if(metaType.isArray())
-         {
-            metaValue = createArrayValue(
-                  (PersistedArrayValue) valueElement,
-                  (ArrayMetaType) metaType);
-         }
-         else if(metaType.isProperties())
-         {
-            metaValue = createPropertiesValue(
-                  (PersistedPropertiesValue) valueElement,
-                  (PropertiesMetaType) metaType);
-         }
-         else
-         {
-            throw new IllegalStateException("unknown metaType");
-         }
-      }
-      finally
-      {
-         //
-      }
-      return metaValue;
-   }
-   
-   /**
-    * Create simple value.
-    * 
-    * @param valueElement the persisted xml meta data.
-    * @param value the simple value.
-    * @return a simple value.
-    */
-   protected SimpleValue createSimpleValue(PersistedSimpleValue valueElement, SimpleMetaType metaType)
-   {
-      String elementValue = valueElement.getValue();
-      
-      Serializable converted = null;
-      if(elementValue != null)
-      {
-         if(metaType.equals(SimpleMetaType.STRING))
-         {
-            converted = (String) elementValue;
-         }
-         else if (metaType.equals(SimpleMetaType.NAMEDOBJECT))
-         {
-            converted = new StringName(elementValue);
-         }
-         else if (metaType.equals(SimpleMetaType.VOID))
-         {  
-            // 
-         }
-         else
-         {
-            converted = convert2Type(metaType.getTypeName(), elementValue);
-         }
-      }
-      return new SimpleValueSupport(metaType, converted);
-   }
- 
-   /**
-    * Process an Enum value.
-    * 
-    * @param enumElement the persisted xml meta data.
-    * @param value the enum value.
-    * @return a enum value.
-    */
-   protected EnumValue createEnumValue(PersistedEnumValue enumElement, EnumMetaType type)
-   {
-      return new EnumValueSupport(type, enumElement.getValue());
-   }
-   
-   /**
-    * Create composite value.
-    * 
-    * @param composite the persisted xml meta data.
-    * @param value the composite value.
-    * @return a composite value.
-    */
-   protected CompositeValue createCompositeValue(PersistedCompositeValue composite, CompositeMetaType type)
-   {
-      // Handle the mapCompositeMetaType differently
-      if(type instanceof MapCompositeMetaType)
-         return handleMapCompositeMetaType(composite, (MapCompositeMetaType) type);
-      
-      // Create composite value
-      Map<String, MetaValue> values = new HashMap<String, MetaValue>();
-      if(composite.getValues() != null && composite.getValues().isEmpty() == false)
-      {
-         for(PersistedValue persistedValue : composite.getValues())
-         {
-            MetaType elementType = type.getType(persistedValue.getName());
-            if(elementType == null)
-               throw new IllegalStateException("Failed to process composite value: " + persistedValue.getName());
-            
-            // Create
-            MetaValue metaValue = createMetaValue(persistedValue, elementType);
-            // Put
-            values.put(persistedValue.getName(), metaValue);
-         }
-      }
-      return new CompositeValueSupport(type, values);
-   }
-
-   /**
-    * Create the MapCompositeValueSupport value.
-    * 
-    * @param composite the persisted composite xml meta data
-    * @param type the MapComposite meta type
-    * @return the MapCompositeValueSupport
-    */
-   protected MapCompositeValueSupport handleMapCompositeMetaType(PersistedCompositeValue composite, MapCompositeMetaType type)
-   {
-      Map<String, MetaValue> values = new HashMap<String, MetaValue>();
-      if(composite.getValues() != null && composite.getValues().isEmpty() == false)
-      {
-         for(PersistedValue persistedValue : composite.getValues())
-         {
-            MetaValue value = createMetaValue(persistedValue, type.getValueType());
-            values.put(persistedValue.getName(), value);
-         }
-      }
-      return new MapCompositeValueSupport(values, type);
-   }
-   
-   /**
-    * Process a collection.
-    * 
-    * @param collection the persisted xml meta data.
-    * @param value the collection value.
-    * @return a collection value.
-    */
-   protected CollectionValue createCollectionValue(PersistedCollectionValue collection, CollectionMetaType type)
-   {
-      List<MetaValue> elementList = new ArrayList<MetaValue>();
-      if(collection.getValues() != null && collection.getValues().isEmpty() == false)
-      {
-         for(PersistedValue element : collection.getValues())
-         {
-            elementList.add(
-                  createMetaValue(element, type.getElementType()));
-         }  
-      }
-      // Generic values are getting wrapped differently
-      if(type.isGeneric())
-      {
-         type = new CollectionMetaType(type.getClassName(), "", GENERIC_PERSISTED_VALUE_TYPE);
-      }
-      return new CollectionValueSupport(type, elementList.toArray(new MetaValue[elementList.size()]));
-   }
-   
-   /**
-    * Create generic value. 
-    * 
-    * @param genericElement the persisted generic xml meta data 
-    * @param metaType the generic meta type
-    * @return the generic value
-    */
-   protected GenericValue createGenericValue(PersistedGenericValue genericElement, GenericMetaType metaType)
-   {
-      // If we don't recurse, someone else needs to extract the managed object
-      return new GenericValueSupport(GENERIC_PERSISTED_VALUE_TYPE, genericElement);
-   }
-   
-   /**
-    * Create the table value.
-    * 
-    * @param table the persisted table value.
-    * @param type the table meta type.
-    * @return the table value.
-    */
-   protected TableValue createTableValue(PersistedTableValue table, TableMetaType type)
-   {
-      TableValueSupport support = new TableValueSupport(type);
-      if(table.getEntries() != null && table.getEntries().isEmpty() == false)
-      {
-         for(PersistedCompositeValue entry : table.getEntries())
-         {
-            support.put(createCompositeValue(entry, type.getRowType()));
-         }         
-      }
-      return support;
-   }
-   
-   protected MetaValue createPropertiesValue(
-         PersistedPropertiesValue value, PropertiesMetaType metaType)
-   {
-      PropertiesMetaValue properties = new PropertiesMetaValue();
-      for(PersistedPair pair : value.getEntries())
-      {
-         properties.setProperty(pair.getKey(), pair.getValue());
-      }
-
-      return properties;
-   }
-
-   /**
-    * Create array value.
-    * 
-    * @param valueElement the persisted array xml value
-    * @param type the array meta type 
-    * @return the array value
-    */
-   @SuppressWarnings("unchecked")
-   protected ArrayValue createArrayValue(PersistedArrayValue valueElement, ArrayMetaType type)
-   {
-      int size = valueElement.size();
-      List values = new ArrayList(size);
-      for(PersistedValue elementValue : valueElement.getValues())
-      {
-         if(elementValue instanceof PersistedArrayValue)
-         {
-            values.add(
-                  recreateArrayValue((PersistedArrayValue) elementValue, type.getElementType()));
-         }
-         else
-         {
-            MetaValue value = createMetaValue(elementValue, type.getElementType());
-            values.add(value);
-         }
-      }
-      return new ArrayValueSupport(type, values.toArray());
-   }
-
-   /**
-    * Recreate the array values.
-    * 
-    * @param valueElement the persisted xml value
-    * @param type the element type
-    * @return the recreated array
-    */
-   @SuppressWarnings("unchecked")
-   protected Object recreateArrayValue(PersistedArrayValue valueElement, MetaType type)
-   {
-      List values = new ArrayList(valueElement.size());
-      for(PersistedValue elementValue : valueElement.getValues())
-      {
-         if(elementValue instanceof PersistedArrayValue)
-         {
-            values.add(
-                  recreateArrayValue((PersistedArrayValue) elementValue, type));
-         }
-         else
-         {
-            MetaValue value = createMetaValue(elementValue, type);
-            values.add(value);
-         }
-      }
-      return values.toArray();
-   }
-   
-   /**
-    * Convert simple types.
-    * 
-    * @param clazz a primitive serializable class.
-    * @param value the String
-    * @return the converted object, null in case of any failure.
-    */
-   public Serializable convert2Type(String className, String value)
-   {
-      if(value == null)
-         return null;
-      
-      Class<?> clazz = simpleTypes.get(className);
-      if(clazz == null)
-         throw new IllegalStateException("Cannot find simple type entry for "+ value + " and class "+ className);
-      
-      try
-      {
-         return (Serializable) ValueConvertor.convertValue(clazz, value);
-      }
-      catch(Throwable t)
-      {
-         log.debug("could convert "+ value +" to " + clazz.getName());
-         return null;
-      }
-   }
-   
-}

Added: trunk/system/src/main/org/jboss/system/server/profileservice/persistence/ManagedObjectRecreationHelper.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/persistence/ManagedObjectRecreationHelper.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/persistence/ManagedObjectRecreationHelper.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -0,0 +1,132 @@
+/*
+ * 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.system.server.profileservice.persistence;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.managed.api.factory.ManagedObjectFactory;
+
+/**
+ * A recreation helper.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class ManagedObjectRecreationHelper
+{
+
+   /** The loader. */
+   private final ThreadLocal<ClassLoader> loader = new ThreadLocal<ClassLoader>();
+   
+   /** The managed object factory. */
+   private final ManagedObjectFactory mangedObjectFactory;
+   
+   /** The attachment property populator. */
+   private final AttachmentPropertyPopulator attachmentPopulator;
+   
+   public ManagedObjectRecreationHelper(ManagedObjectFactory mangedObjectFactory)
+   {
+      if(mangedObjectFactory == null)
+         throw new IllegalArgumentException("null managed object factory");
+      
+      this.mangedObjectFactory = mangedObjectFactory;
+      this.attachmentPopulator =  new AttachmentPropertyPopulator(mangedObjectFactory, this);
+   }
+   
+   public ClassLoader getLoader()
+   {
+      return this.loader.get();
+   }
+   
+   public void setLoader(ClassLoader loader)
+   {
+      this.loader.set(loader);
+   }
+   
+   /**
+    * Set a value to a managed property. This delegates
+    * to the AttachmentPropertyPopulator.
+    * 
+    * @param name the property name
+    * @param property the managed property
+    * @param attachment the attachment
+    * @throws Throwable for any erro
+    */
+   public void setValue(String name, ManagedProperty property, Object attachment) throws Throwable
+   {
+      attachmentPopulator.processManagedProperty(name, property, attachment);
+   }
+   
+   /**
+    * Create a ManagedObject skeleton based on a class name.
+    * 
+    * @param className the class name
+    * @return the ManagedObject, null if the class has no ManagementObject annotations
+    * @throws ClassNotFoundException 
+    */
+   protected ManagedObject createManagedObjectSkeleton(String className) throws ClassNotFoundException
+   {
+      Class<?> clazz = loadClass(className);
+      return mangedObjectFactory.createManagedObject(clazz);
+   }
+   
+   /**
+    * Load class.
+    * 
+    * @param className the class name
+    * @return the class
+    * @throws ClassNotFoundException
+    */
+   protected Class<?> loadClass(String className) throws ClassNotFoundException
+   {
+      ClassLoader cl = getLoader();
+      if(cl == null)
+         cl = SecurityActions.getContextClassLoader();
+      return cl.loadClass(className); 
+   }
+   
+   private static final class SecurityActions
+   {
+      public static ClassLoader getContextClassLoader()
+      {
+         if (System.getSecurityManager() == null)
+         {
+            return Thread.currentThread().getContextClassLoader();
+         }
+         else
+         {
+            return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
+            {
+                public ClassLoader run()
+                {
+                   return Thread.currentThread().getContextClassLoader();
+                }
+            });
+         }  
+      }
+   }
+   
+}
+

Deleted: trunk/system/src/main/org/jboss/system/server/profileservice/persistence/ManagedObjectRemoveHandler.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/persistence/ManagedObjectRemoveHandler.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/persistence/ManagedObjectRemoveHandler.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -1,88 +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.system.server.profileservice.persistence;
-
-import org.jboss.managed.api.ManagedCommon;
-import org.jboss.managed.api.ManagedObject;
-import org.jboss.system.server.profileservice.persistence.xml.ModificationInfo;
-import org.jboss.system.server.profileservice.persistence.xml.PersistedManagedObject;
-
-/**
- * 
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public class ManagedObjectRemoveHandler extends ManagedObjectPeristenceHandler
-{
-
-   /** The item to remove. */
-   private ManagedCommon removeItem = null;
-   
-   private ManagedObjectPersistencePlugin plugin;
-   
-   public ManagedObjectRemoveHandler(ManagedCommon removeItem)
-   {
-      super();
-      if(removeItem == null)
-         throw new IllegalArgumentException("Null component to remove.");
-      this.removeItem = removeItem;
-      this.plugin = new DelegatingPersistencePlugin(new RemovePlugin());
-   }
-
-   @Override
-   protected ManagedObjectPersistencePlugin getPlugin()
-   {
-      return this.plugin;
-   }
-
-   public class RemovePlugin extends DefaultManagedObjectPlugin
-   {
-      
-      @Override
-      public PersistedManagedObject createPersistedManagedObject(PersistedManagedObject persisted, ManagedObject mo)
-      {
-         if(mo != null)
-         {
-            if(mo.getName() == removeItem.getName())
-            {
-               persisted.setModificationInfo(ModificationInfo.REMOVED);
-               return persisted;
-            }
-            else
-            {
-               return super.createPersistedManagedObject(persisted, mo);
-            }
-         }
-         else
-         {
-            return super.createPersistedManagedObject(persisted, mo);
-         }
-      }
-
-      @Override
-      public String getType()
-      {
-         return null;
-      }      
-   }
-   
-}

Added: trunk/system/src/main/org/jboss/system/server/profileservice/persistence/PersistenceConstants.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/persistence/PersistenceConstants.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/persistence/PersistenceConstants.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -0,0 +1,45 @@
+/*
+ * 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.system.server.profileservice.persistence;
+
+/**
+ * The PersistenceConstants.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision: 88716 $
+ */
+public class PersistenceConstants
+{
+   
+   /** The repository xml namespace. */
+   public static final String REPOSITORY_NAMESPACE_1_0 = "urn:org:jboss:profileservice:attachments:1.0";
+
+   /** The component xml namespace. */
+   public static final String COMPONENT_NAMESPACE_1_0 = "urn:org:jboss:profileservice:persistence:managed-component:1.0";
+   
+   /** The managed-object name. */
+   public static final String MANAGED_OBJECT_ELEMENT_NAME = "managed-object";
+   
+   /** The managed-component name. */
+   public static final String MANAGED_COMPONENT_ELEMENT_NAME = "managed-component";
+   
+}

Added: trunk/system/src/main/org/jboss/system/server/profileservice/persistence/PersistenceFactory.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/persistence/PersistenceFactory.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/persistence/PersistenceFactory.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -0,0 +1,170 @@
+/*
+ * 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.system.server.profileservice.persistence;
+
+import org.jboss.managed.api.ManagedComponent;
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.api.factory.ManagedObjectFactory;
+import org.jboss.system.server.profileservice.persistence.xml.PersistenceRoot;
+
+/**
+ * The persistence factory.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public abstract class PersistenceFactory
+{
+
+   /** The managed object factory. */
+   private final ManagedObjectFactory managedObjectFactory;
+   
+   protected PersistenceFactory(ManagedObjectFactory managedObjectFactory)
+   {
+      if(managedObjectFactory == null)
+         throw new IllegalArgumentException("null managed object factory");
+      //
+      this.managedObjectFactory = managedObjectFactory;
+   }
+   
+   /**
+    * Get the managed object factory.
+    * 
+    * @return the manged object factory
+    */
+   public ManagedObjectFactory getManagedObjectFactory()
+   {
+      return managedObjectFactory;
+   }
+   
+   /**
+    * Get the persistence plugin.
+    * 
+    * @return the persistence plugin
+    */
+   public abstract ManagedObjectPersistencePlugin getPersistencePlugin();
+
+   /**
+    * Apply the persisted information to a attachment.
+    * 
+    * @param root the persistence root
+    * @param attachment the root attachment
+    * @param classLoader the classloader
+    */
+   public abstract void restorePersistenceRoot(PersistenceRoot root, Object attachment, ClassLoader classLoader);
+   
+   /**
+    * Add a ManagedComponent.
+    * 
+    * @param parent the parent managed object
+    * @param component the managed component
+    * @return the updated persistence root
+    */
+   public PersistenceRoot addComponent(ManagedObject parent, ManagedComponent component)
+   {
+      if(parent == null)
+         throw new IllegalArgumentException("null parent managed object");
+      if(component == null)
+         throw new IllegalArgumentException("null managed component");
+      
+      PersistenceRoot root = new PersistenceRoot();
+      return addComponent(root, parent, component);
+   }
+   
+   /**
+    * Add a ManagedComponent.
+    * 
+    * @param root the persistence root
+    * @param parent the parent managed object
+    * @param component the managed component
+    * @return the updated persistence root
+    */
+   public abstract PersistenceRoot addComponent(PersistenceRoot root, ManagedObject parent, ManagedComponent component);
+   
+   /**
+    * Update a ManagedComponent.
+    * 
+    * @param parent the parent managed object
+    * @param component the managed component
+    * @return the updated persistence root
+    */
+   public PersistenceRoot updateComponent(ManagedObject parent, ManagedComponent component)
+   {
+      if(parent == null)
+         throw new IllegalArgumentException("null parent managed object");
+      if(component == null)
+         throw new IllegalArgumentException("null managed component");
+      
+      PersistenceRoot root = new PersistenceRoot();
+      return updateComponent(root, parent, component);
+   }
+   
+   /**
+    * Update a ManagedComponent.
+    * 
+    * @param root the persistence root
+    * @param parent the parent managed object
+    * @param component the managed component
+    * @return the updated persistence root
+    */
+   public abstract PersistenceRoot updateComponent(PersistenceRoot root, ManagedObject parent, ManagedComponent component);
+
+   /**
+    * Remove a ManagedComponent.
+    * 
+    * @param parent the parent managed object
+    * @param component the managed component
+    * @return the updated persistence root
+    */
+   public PersistenceRoot removeComponent(ManagedObject parent, ManagedComponent component)
+   {
+      if(parent == null)
+         throw new IllegalArgumentException("null parent managed object");
+      if(component == null)
+         throw new IllegalArgumentException("null managed component");
+      
+      PersistenceRoot root = new PersistenceRoot();
+      return removeComponent(root, parent, component); 
+   }
+   
+   /**
+    * Remove a ManagedComponent.
+    * 
+    * @param root the persistence root
+    * @param parent the parent managed object
+    * @param component the managed component
+    * @return the updated persistence root
+    */
+   public abstract PersistenceRoot removeComponent(PersistenceRoot root, ManagedObject parent, ManagedComponent component);
+
+   /**
+    * Reset a component. This will remove the persisted information.
+    * 
+    * @param root the persistence root
+    * @param parent the parent managed object
+    * @param component the managed component
+    * @return the updated persistence root
+    */
+   public abstract PersistenceRoot resetComponent(PersistenceRoot root, ManagedObject parent, ManagedComponent component);
+   
+}
+

Added: trunk/system/src/main/org/jboss/system/server/profileservice/persistence/component/AbstractComponentMapper.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/persistence/component/AbstractComponentMapper.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/persistence/component/AbstractComponentMapper.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -0,0 +1,189 @@
+/*
+ * 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.system.server.profileservice.persistence.component;
+
+import java.util.ArrayList;
+
+import org.jboss.managed.api.ManagedComponent;
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.api.factory.ManagedObjectFactory;
+import org.jboss.system.server.profileservice.persistence.ManagedObjectPersistencePlugin;
+import org.jboss.system.server.profileservice.persistence.PersistenceFactory;
+import org.jboss.system.server.profileservice.persistence.xml.ModificationInfo;
+import org.jboss.system.server.profileservice.persistence.xml.PersistedComponent;
+import org.jboss.system.server.profileservice.persistence.xml.PersistedManagedObject;
+import org.jboss.system.server.profileservice.persistence.xml.PersistedProperty;
+
+/**
+ * The abstract component mapper.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public abstract class AbstractComponentMapper implements ComponentMapper
+{
+
+   /** The persistence factory. */
+   private final PersistenceFactory persistenceFactory;
+   
+   public AbstractComponentMapper(PersistenceFactory persistenceFactory)
+   {
+      if(persistenceFactory == null)
+         throw new IllegalArgumentException("null persistence factory");
+      
+      this.persistenceFactory = persistenceFactory;
+   }
+   
+   public ManagedObjectPersistencePlugin getPersistencePlugin()
+   {
+      return persistenceFactory.getPersistencePlugin();
+   }
+   
+   public ManagedObjectFactory getMOF()
+   {
+      return persistenceFactory.getManagedObjectFactory();
+   }
+  
+   public void restoreComponent(Object attachment, PersistedComponent component)
+   {
+      if(attachment == null)
+         throw new IllegalArgumentException("null attachment");
+      if(component == null)
+         throw new IllegalArgumentException("null component");
+
+      // Check what we need to do
+      ModificationInfo modification = component.getModificationInfo();
+      if(modification == null)
+         modification = ModificationInfo.MODIFIED;
+      switch(modification)
+      {
+         case ADDED:
+            updateComponent(attachment, component, true);
+            break;
+         case MODIFIED:
+            updateComponent(attachment, component, false);
+            break;
+         case REMOVED:
+            removeComponent(attachment, component);
+            break;
+      }
+   }
+
+   public PersistedComponent addComponent(Object attachment, ManagedComponent component)
+   {
+      return createPersistedComponent(attachment, component, ModificationInfo.ADDED);
+   }
+   
+   public PersistedComponent updateComponent(Object attachment, ManagedComponent component)
+   {
+      return createPersistedComponent(attachment, component, ModificationInfo.MODIFIED);
+   }
+   
+   public PersistedComponent removeComponent(Object attachment, ManagedComponent component)
+   {
+      PersistedComponent persisted = createPersistedComponent(attachment, component, ModificationInfo.REMOVED);
+      // FIXME cleanup properties, as they are not need for removed components
+      persisted.setProperties(new ArrayList<PersistedProperty>());
+      return persisted;
+   }
+   
+   /**
+    * Remove a component from the attachment.
+    * 
+    * @param attachment the attachment
+    * @param component the component to remove
+    */
+   protected abstract void removeComponent(Object attachment, PersistedComponent component);
+
+   /**
+    * Get a ManagedObject for a given component, based on the information
+    * in the attachment descriptor.
+    * 
+    * @param attachment the attachment
+    * @param component the component
+    * @param create whether to create a non existing component or not
+    * @return the managed object for the component
+    */
+   protected abstract ManagedObject getComponent(Object attachment, PersistedComponent component, boolean create);
+   
+   /**
+    * Create the persisted information for a given ManagedComponent.
+    * 
+    * @param attachment the attachment
+    * @param component the managed component
+    * @return the persisted component
+    */
+   protected PersistedComponent createComponent(Object attachment, ManagedComponent component)
+   {
+      // ManagedObject mo = component.getDeployment().getManagedObject(component.getName());
+      ManagedObject mo = (ManagedObject) component.getParent();
+      PersistedManagedObject persisted = getPersistencePlugin().createPersistedManagedObject(mo);
+      PersistedComponent persistedComponent = new PersistedComponent(persisted);
+      setComponentName(persistedComponent, mo);
+      return persistedComponent;
+   }
+   
+   /**
+    * Set the current name for this component.
+    * 
+    * @param component the persisted component
+    * @param mo the managed object
+    */
+   protected abstract void setComponentName(PersistedComponent component, ManagedObject mo);
+   
+   /**
+    * Update a attachment descripto based on the persisted
+    * component information.
+    * 
+    * @param attachment the attachment
+    * @param component the persisted component
+    * @param added whether this component was added or not
+    */
+   protected void updateComponent(Object attachment, PersistedComponent component, boolean added)
+   {
+      ManagedObject mo = getComponent(attachment, component, added);
+      getPersistencePlugin().updateManagedObject(component, mo);
+   }
+
+   /**
+    * Create a persisted component for a given ManagedComponent.
+    * 
+    * @param attachment the attachment
+    * @param component the managed component
+    * @param modification the modification info
+    * @return the persisted component
+    */
+   protected PersistedComponent createPersistedComponent(Object attachment, ManagedComponent component, ModificationInfo modification)
+   {
+      if(attachment == null)
+         throw new IllegalArgumentException("null attachment");
+      if(component == null)
+         throw new IllegalArgumentException("null component");
+      if(modification == null)
+         throw new IllegalArgumentException("null modification info");
+      // Create the component and set the modification information
+      PersistedComponent persisted = createComponent(attachment, component);
+      persisted.setModificationInfo(modification);
+      return persisted;      
+   }
+
+}

Added: trunk/system/src/main/org/jboss/system/server/profileservice/persistence/component/ComponentMapper.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/persistence/component/ComponentMapper.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/persistence/component/ComponentMapper.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -0,0 +1,77 @@
+/*
+ * 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.system.server.profileservice.persistence.component;
+
+import org.jboss.managed.api.ManagedComponent;
+import org.jboss.system.server.profileservice.persistence.xml.PersistedComponent;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public interface ComponentMapper
+{
+
+   /**
+    * Get the component mapper type.
+    * 
+    * @return the type
+    */
+   String getType();
+   
+   /**
+    * Restore a component based on the persisted information.
+    * 
+    * @param attachment the attachment
+    * @param component the persisted component
+    */
+   void restoreComponent(Object attachment, PersistedComponent component);
+
+   /**
+    * Add a component.
+    * 
+    * @param attachment the parent attachment
+    * @param component the managed component
+    * @return the persisted managed component
+    */
+   PersistedComponent addComponent(Object attachment, ManagedComponent component);
+   
+   /**
+    * Update a component.
+    * 
+    * @param attachment the parent attachment
+    * @param component the managed component
+    * @return the persisted managed component
+    */
+   PersistedComponent updateComponent(Object attachment, ManagedComponent component);
+   
+   /**
+    * Remove a component.
+    * 
+    * @param attachment the parent attachment
+    * @param component the managed component
+    * @return the persisted managed component
+    */
+   PersistedComponent removeComponent(Object attachment, ManagedComponent component);
+   
+}
+

Added: trunk/system/src/main/org/jboss/system/server/profileservice/persistence/component/ComponentMapperRegistry.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/persistence/component/ComponentMapperRegistry.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/persistence/component/ComponentMapperRegistry.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -0,0 +1,108 @@
+/*
+ * 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.system.server.profileservice.persistence.component;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * A component mapper registry.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class ComponentMapperRegistry
+{
+   
+   /** The instance. */
+   private static final ComponentMapperRegistry INSTANCE = new ComponentMapperRegistry();
+   
+   /** The component mapper map. */
+   private final Map<String, ComponentMapper> map = new ConcurrentHashMap<String, ComponentMapper>();
+
+   protected ComponentMapperRegistry()
+   {
+      //
+   }
+   
+   public static ComponentMapperRegistry getInstance()
+   {
+      return INSTANCE;
+   }
+   
+   /**
+    * Get a component mapper.
+    * 
+    * @param name the mapper type
+    * @return the mapper or null if not registered
+    */
+   public ComponentMapper getMapper(String name)
+   {
+      if(name == null)
+         throw new IllegalArgumentException("null name");
+      
+      return this.map.get(name);
+   }
+   
+   /**
+    * Add a component mapper.
+    * 
+    * @param mapper the component mapper
+    */
+   public void addMapper(ComponentMapper mapper)
+   {
+      if(mapper == null)
+         throw new IllegalArgumentException("null mapper");
+      
+      this.map.put(mapper.getType(), mapper);
+   }
+   
+   public void addMapper(String type, ComponentMapper mapper)
+   {
+      if(type == null)
+         throw new IllegalArgumentException("null mapper type");
+
+      this.map.put(type, mapper);      
+   }
+
+   /**
+    * Remove a component mapper.
+    * 
+    * @param mapper the component mapper
+    * @return the previous mapper or null
+    */
+   public ComponentMapper removeComponentMapper(ComponentMapper mapper)
+   {
+      if(mapper == null)
+         throw new IllegalArgumentException("null mapper");
+      return removeComponentMapper(mapper.getType());
+   }
+   
+   public ComponentMapper removeComponentMapper(String type)
+   {
+      if(type == null)
+         throw new IllegalArgumentException("null mapper type");
+      
+      return this.map.remove(type);
+   }
+}
+

Added: trunk/system/src/main/org/jboss/system/server/profileservice/persistence/deployer/PersistenceModificationChecker.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/persistence/deployer/PersistenceModificationChecker.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/persistence/deployer/PersistenceModificationChecker.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -0,0 +1,100 @@
+/*
+ * 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.system.server.profileservice.persistence.deployer;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.jboss.deployers.spi.structure.ContextInfo;
+import org.jboss.deployers.spi.structure.StructureMetaData;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.logging.Logger;
+import org.jboss.system.server.profile.basic.XmlIncludeVirtualFileFilter;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.VirtualFileFilter;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class PersistenceModificationChecker
+{
+   
+   /** The logger. */
+   private static final Logger log = Logger.getLogger(PersistenceModificationChecker.class);
+   
+   /** The filter. */
+   private static VirtualFileFilter filter = new XmlIncludeVirtualFileFilter();
+   
+   public static boolean hasBeenModified(VFSDeploymentUnit unit, long lastModified) throws Exception
+   {
+      VirtualFile root = unit.getRoot();
+      if (root.isArchive() || root.isLeaf())
+      {
+         if(root.getLastModified() > lastModified)
+            return true;
+      }
+
+      StructureMetaData structureMetaData = unit.getAttachment(StructureMetaData.class);
+      if(structureMetaData == null)
+         return false;
+      
+      ContextInfo info = structureMetaData.getContext(unit.getSimpleName());
+      if(info == null && unit.isTopLevel())
+         info = structureMetaData.getContext("");
+      
+      if(info == null)
+         return false;
+      
+      return hasBeenModifed(root, info, lastModified);
+   }
+
+   protected static boolean hasBeenModifed(VirtualFile root, ContextInfo contextInfo, long lastModified) throws IOException
+   {
+      List<String> metadataPaths = contextInfo.getMetaDataPath();
+      if (metadataPaths != null && metadataPaths.isEmpty() == false)
+      {
+         for (String metaDataPath : metadataPaths)
+         {
+            VirtualFile mdpVF = root.getChild(metaDataPath);
+            if (mdpVF != null)
+            {
+               List<VirtualFile> children = mdpVF.getChildren(filter);
+               if (children != null && children.isEmpty() == false)
+               {
+                  for (VirtualFile child : children)
+                  {
+                     if (child.getLastModified() > lastModified)
+                     {
+                        if (log.isTraceEnabled())
+                           log.trace("Metadata location modified: " + child);
+                        return true;
+                     }
+                  }
+               }
+            }
+         }
+      }
+      return false;
+   }
+}
+

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/persistence/deployer/ProfileServicePersistenceDeployer.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/persistence/deployer/ProfileServicePersistenceDeployer.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/persistence/deployer/ProfileServicePersistenceDeployer.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -21,18 +21,18 @@
  */
 package org.jboss.system.server.profileservice.persistence.deployer;
 
-import java.util.Set;
-
 import org.jboss.deployers.spi.DeploymentException;
 import org.jboss.deployers.spi.deployer.DeploymentStages;
 import org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer;
 import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
 import org.jboss.logging.Logger;
-import org.jboss.managed.api.ManagedObject;
-import org.jboss.managed.api.factory.ManagedObjectFactory;
-import org.jboss.metadata.spi.MetaData;
-import org.jboss.system.server.profileservice.persistence.ManagedGenericOverrideHandler;
-import org.jboss.system.server.profileservice.persistence.xml.PersistedManagedObject;
+import org.jboss.system.server.profileservice.attachments.AttachmentMetaData;
+import org.jboss.system.server.profileservice.attachments.AttachmentStore;
+import org.jboss.system.server.profileservice.attachments.RepositoryAttachmentMetaData;
+import org.jboss.system.server.profileservice.persistence.PersistenceFactory;
+import org.jboss.system.server.profileservice.persistence.xml.PersistenceRoot;
+import org.jboss.virtual.VirtualFile;
 
 /**
  * The ProfileService Persistence Deployer. This deployer applies the
@@ -47,11 +47,11 @@
    /** The managed prefix. */
    public static final String PERSISTED_ATTACHMENT_PREFIX = "PERISTED";
    
-   /** The managed object override handler. */
-   private ManagedGenericOverrideHandler overrideHandler = new ManagedGenericOverrideHandler();
+   /** The attachment store. */
+   private AttachmentStore store;
    
-   /** The managed object factory. */
-   private ManagedObjectFactory factory = ManagedObjectFactory.getInstance();
+   /** The persistence factory. */
+   private PersistenceFactory persistenceFactory;
    
    /** The Logger. */
    private static final Logger log = Logger.getLogger(ProfileServicePersistenceDeployer.class);
@@ -63,47 +63,77 @@
       setStage(DeploymentStages.PRE_REAL);
    }
    
-   public ManagedObjectFactory getManagedObjectFactory()
+   public PersistenceFactory getPersistenceFactory()
    {
-      return factory;
+      return persistenceFactory;
    }
    
-   public void setManagedObjectFactory(ManagedObjectFactory factory)
+   public void setPersistenceFactory(PersistenceFactory persistenceFactory)
    {
-      this.factory = factory;
+      this.persistenceFactory = persistenceFactory;
    }
    
+   public AttachmentStore getAttachmentStore()
+   {
+      return store;
+   }
+   
+   public void setAttachmentStore(AttachmentStore store)
+   {
+      this.store = store;
+   }
+   
    @Override
    protected void internalDeploy(DeploymentUnit unit) throws DeploymentException
    {
-      // Check all attachments, if they have a managed attachment
-      // TODO there might be a better way to do that ? :)
-      Set<String> attachments = unit.getTransientManagedObjects().getAttachments().keySet();
-      for(String attachment : attachments)
+      if(unit == null || unit instanceof VFSDeploymentUnit == false)
+         return;
+      try
       {
-         PersistedManagedObject persistedManagedObject = (PersistedManagedObject) unit.getAttachment(PERSISTED_ATTACHMENT_PREFIX + attachment);
-         
-         if(persistedManagedObject != null)
+         applyPersistentChanges((VFSDeploymentUnit) unit);
+      }
+      catch(Throwable e)
+      {
+         log.warn("Failed to update the persisted attachment information", e);
+      }
+   }
+   
+   protected void applyPersistentChanges(VFSDeploymentUnit unit) throws Throwable
+   {
+      VirtualFile vf = unit.getRoot();
+      RepositoryAttachmentMetaData metaData = store.loadMetaData(vf);
+      if(metaData == null)
+         return;      
+      
+      // Check if the deployment was modified
+      if(PersistenceModificationChecker.hasBeenModified(unit, metaData.getLastModified()))
+      {
+         log.debug("Deployment was modified, not applying persisted information : " + unit);
+         return;
+      }
+      //
+      if(metaData.getAttachments() != null && metaData.getAttachments().isEmpty() == false)
+      {
+         for(AttachmentMetaData attachment: metaData.getAttachments())
          {
-            // Get the transient attachment
-            Object instance = unit.getTransientManagedObjects().getAttachment(attachment);
-            try
+            Object instance = unit.getAttachment(attachment.getName());
+            if(instance != null)
             {
-               MetaData metaData = unit.getMetaData();
-               ManagedObject original = factory.initManagedObject(instance, metaData);
-               
-               // Update the attachment
-               overrideHandler.updateManagedObject(original, persistedManagedObject, instance);
-               
-               // Override
-               unit.addAttachment(attachment, original.getAttachment());
+               PersistenceRoot root = this.store.loadAttachment(vf, attachment);
+               if(root == null)
+               {
+                  log.warn("Null persisted information for deployment: " + vf);
+               }
+               // update ...
+               getPersistenceFactory().restorePersistenceRoot(root, instance, unit.getClassLoader());
             }
-            catch(Throwable e)
+            else
             {
-               log.debug("Failed to update the persisted attachment information", e);
+               log.warn("Could not apply changes, failed to find attachment: " + attachment.getName());
             }
-         }
-      }
+         }         
+      }      
    }
+   
 
 }

Added: trunk/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistedComponent.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistedComponent.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistedComponent.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -0,0 +1,53 @@
+/*
+ * 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.system.server.profileservice.persistence.xml;
+
+/**
+ * A persisted managed component.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class PersistedComponent extends PersistedManagedObject
+{
+
+   public PersistedComponent()
+   {
+      //
+   }
+   
+   public PersistedComponent(PersistedManagedObject persisted)
+   {
+      if(persisted == null)
+         throw new IllegalArgumentException("null persisted managed object");
+      
+      setName(persisted.getName());
+      setClassName(persisted.getClassName());
+      setProperties(persisted.getProperties());
+      setOriginalName(persisted.getOriginalName());
+      setTemplateName(persisted.getTemplateName());
+      // TODO the modificationInfo should be handled here
+      setModificationInfo(persisted.getModificationInfo());
+   }
+
+}
+

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistedCompositeValue.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistedCompositeValue.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistedCompositeValue.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -36,7 +36,7 @@
 {
 
    /** The values */
-   List<PersistedValue> values;
+   private List<PersistedValue> values;
    
    @XmlElements( value = {
          @XmlElement(name = "null", type = NullValue.class),

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistedGenericValue.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistedGenericValue.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistedGenericValue.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -21,27 +21,28 @@
  */
 package org.jboss.system.server.profileservice.persistence.xml;
 
-import static org.jboss.system.server.profileservice.persistence.xml.PersistenceConstants.MANAGED_OBJECT_ELEMENT_NAME;
+import static org.jboss.system.server.profileservice.persistence.PersistenceConstants.MANAGED_OBJECT_ELEMENT_NAME;
 
-import java.io.Serializable;
-
+import javax.xml.bind.annotation.XmlAnyElement;
 import javax.xml.bind.annotation.XmlElement;
 
+import org.w3c.dom.Element;
+
 /**
  * The persisted generic value.
  * 
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
  * @version $Revision$
  */
-public class PersistedGenericValue extends AbstractPersisitedValue implements PersistedValue, Serializable
+public class PersistedGenericValue extends AbstractPersisitedValue implements PersistedValue
 {
    
-   /** The serialVersionUID */
-   private static final long serialVersionUID = -6858198681439447173L;
-   
    /** A managed-object. */
    private PersistedManagedObject managedObject;
    
+   /** A generic element. */
+   private Element generic;
+   
    @XmlElement(name = MANAGED_OBJECT_ELEMENT_NAME, type = PersistedManagedObject.class)
    public PersistedManagedObject getManagedObject()
    {
@@ -53,17 +54,23 @@
       this.managedObject = managedObject;
    }
    
-   public boolean hasModificationFlag(ModificationInfo info)
+   @XmlAnyElement
+   public Element getGeneric()
    {
-      if(managedObject == null)
-         return false;
-
-      return managedObject.getModificationInfo() == info;
+      return generic;
    }
    
+   public void setGeneric(Element generic)
+   {
+      this.generic = generic;
+   }
+   
    protected void toString(StringBuilder builder)
    {
-      builder.append(", managed-object = ").append(getManagedObject());
+      if(getManagedObject() != null)
+         builder.append(", managed-object = ").append(getManagedObject());
+      if(getGeneric() != null)
+         builder.append(", generic-value = ").append(getGeneric());
    }
    
    @Override

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistedManagedObject.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistedManagedObject.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistedManagedObject.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -21,7 +21,7 @@
  */
 package org.jboss.system.server.profileservice.persistence.xml;
 
-import static org.jboss.system.server.profileservice.persistence.xml.PersistenceConstants.MANAGED_OBJECT_ELEMENT_NAME;
+import static org.jboss.system.server.profileservice.persistence.PersistenceConstants.MANAGED_OBJECT_ELEMENT_NAME;
 
 import java.util.List;
 
@@ -32,6 +32,7 @@
 import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlType;
 
+import org.jboss.system.server.profileservice.persistence.PersistenceConstants;
 import org.jboss.xb.annotations.JBossXmlSchema;
 
 /**
@@ -40,9 +41,9 @@
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
  * @version $Revision$
  */
- at JBossXmlSchema(namespace = PersistenceConstants.NAMESPACE_1_0, elementFormDefault = XmlNsForm.QUALIFIED)
+ at JBossXmlSchema(namespace = PersistenceConstants.COMPONENT_NAMESPACE_1_0, elementFormDefault = XmlNsForm.QUALIFIED)
 @XmlRootElement(name = MANAGED_OBJECT_ELEMENT_NAME)
- at XmlType(propOrder = {"originalName", "templateName", "modificationInfo", "properties"})
+ at XmlType(propOrder = {"originalName", "templateName", "properties"})
 public class PersistedManagedObject extends AbstractElement
 {
    
@@ -56,6 +57,7 @@
    private List<PersistedProperty> properties;
    
    /** The modification info. */
+   // TODO this should be in PersistedComponent
    private ModificationInfo modificationInfo;
    
    public PersistedManagedObject()
@@ -84,26 +86,26 @@
       this.templateName = templateName;
    }
    
-   @XmlAttribute(name = "modification")
-   public ModificationInfo getModificationInfo()
+   @XmlAttribute(name = "original-name")
+   public String getOriginalName()
    {
-      return this.modificationInfo;
+      return originalName;
    }
    
-   public void setModificationInfo(ModificationInfo info)
+   public void setOriginalName(String originalName)
    {
-      this.modificationInfo = info;
+      this.originalName = originalName;
    }
    
-   @XmlElement(name = "orignal-name")
-   public String getOriginalName()
+   @XmlAttribute(name = "modification")
+   public ModificationInfo getModificationInfo()
    {
-      return originalName;
+      return this.modificationInfo;
    }
    
-   public void setOriginalName(String originalName)
+   public void setModificationInfo(ModificationInfo info)
    {
-      this.originalName = originalName;
+      this.modificationInfo = info;
    }
    
    @XmlElementWrapper(name="properties")

Added: trunk/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistenceRoot.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistenceRoot.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistenceRoot.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -0,0 +1,91 @@
+/*
+ * 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.system.server.profileservice.persistence.xml;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlNsForm;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+import org.jboss.system.server.profileservice.persistence.PersistenceConstants;
+import org.jboss.xb.annotations.JBossXmlSchema;
+
+/**
+ * The attachment persistence xml root.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+ at JBossXmlSchema(namespace = PersistenceConstants.COMPONENT_NAMESPACE_1_0,
+      elementFormDefault = XmlNsForm.QUALIFIED)
+ at XmlRootElement(name = "root", namespace = PersistenceConstants.COMPONENT_NAMESPACE_1_0)
+ at XmlType(propOrder = {"components"})
+public class PersistenceRoot
+{
+
+   /** The name */
+   private String name;
+   
+   /** The attachment class name. */
+   private String className;
+   
+   /** The components. */
+   private List<PersistedComponent> components;
+   
+   @XmlAttribute(name = "name")
+   public String getName()
+   {
+      return name;
+   }
+   
+   public void setName(String name)
+   {
+      this.name = name;
+   }
+   
+   @XmlAttribute(name = "class-name")
+   public String getClassName()
+   {
+      return className;
+   }
+   
+   public void setClassName(String className)
+   {
+      this.className = className;
+   }
+   
+   @XmlElement(name = "component")
+   public List<PersistedComponent> getComponents()
+   {
+      return components;
+   }
+   
+   public void setComponents(List<PersistedComponent> components)
+   {
+      this.components = components;
+   }
+   
+}
+

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/persistence/xml/package-info.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/persistence/xml/package-info.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/persistence/xml/package-info.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -19,7 +19,7 @@
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
- at XmlSchema(namespace = "urn:org:jboss:profileservice:persistence:managed-object:1.0", 
+ at XmlSchema(namespace = "urn:org:jboss:profileservice:persistence:managed-component:1.0", 
       elementFormDefault = XmlNsForm.QUALIFIED,
       xmlns = { @XmlNs(namespaceURI = "http://www.w3.org/2001/XMLSchema", prefix = "xs") }
 )

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractAttachmentStore.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractAttachmentStore.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractAttachmentStore.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -22,7 +22,6 @@
 package org.jboss.system.server.profileservice.repository;
 
 import java.io.File;
-import java.io.IOException;
 import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URISyntaxException;
@@ -30,16 +29,13 @@
 import java.security.NoSuchAlgorithmException;
 import java.util.ArrayList;
 import java.util.Formatter;
-import java.util.HashSet;
 import java.util.List;
-import java.util.Set;
+import java.util.Map;
 
 import org.jboss.deployers.client.plugins.deployment.AbstractDeployment;
 import org.jboss.deployers.client.spi.Deployment;
+import org.jboss.deployers.spi.attachments.AttachmentsFactory;
 import org.jboss.deployers.spi.attachments.MutableAttachments;
-import org.jboss.deployers.spi.structure.ClassPathEntry;
-import org.jboss.deployers.spi.structure.ContextInfo;
-import org.jboss.deployers.spi.structure.StructureMetaData;
 import org.jboss.deployers.structure.spi.DeploymentContext;
 import org.jboss.deployers.structure.spi.main.MainDeployerStructure;
 import org.jboss.deployers.vfs.spi.client.VFSDeploymentFactory;
@@ -47,78 +43,73 @@
 import org.jboss.logging.Logger;
 import org.jboss.managed.api.ManagedCommon;
 import org.jboss.managed.api.ManagedComponent;
-import org.jboss.managed.api.ManagedDeployment;
 import org.jboss.managed.api.ManagedObject;
 import org.jboss.profileservice.spi.ProfileDeployment;
 import org.jboss.system.server.profileservice.attachments.AttachmentMetaData;
 import org.jboss.system.server.profileservice.attachments.AttachmentStore;
-import org.jboss.system.server.profileservice.attachments.DeploymentClassPathMetaData;
-import org.jboss.system.server.profileservice.attachments.DeploymentStructureMetaData;
-import org.jboss.system.server.profileservice.attachments.LazyPredeterminedManagedObjects;
 import org.jboss.system.server.profileservice.attachments.RepositoryAttachmentMetaData;
 import org.jboss.system.server.profileservice.attachments.RepositoryAttachmentMetaDataFactory;
-import org.jboss.system.server.profileservice.persistence.ManagedObjectPeristenceHandler;
-import org.jboss.system.server.profileservice.persistence.ManagedObjectRemoveHandler;
-import org.jboss.system.server.profileservice.persistence.xml.PersistedManagedObject;
+import org.jboss.system.server.profileservice.persistence.PersistenceFactory;
+import org.jboss.system.server.profileservice.persistence.xml.PersistenceRoot;
 import org.jboss.virtual.VirtualFile;
-import org.jboss.virtual.VirtualFileFilter;
 
 /**
- * The AbstractAttachmentStore updates and restores the persisted attachments.
+ * The AbstractAttachmentStore.
  * 
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
  * @version $Revision$
  */
 public class AbstractAttachmentStore implements AttachmentStore
 {
-   /** The attachment store root. */
-   private final URI attatchmentStoreRoot;
 
-   /** The attachment serializer. */
-   protected AbstractFileAttachmentsSerializer serializer;
-   
-   /** The deployment factory. */
-   protected VFSDeploymentFactory deploymentFactory = VFSDeploymentFactory.getInstance();
-   
-   /** The MainDeployerStructure. */
-   protected MainDeployerStructure mainDeployer;
-   
-   /** The virutal file filter. */
-   private VirtualFileFilter metaDataFilter;
-   
    /** The metadata name */
    public static final String METADATA_NAME = "metadata";
    
-   /** The managed object persistence handler. */
-   private static final ManagedObjectPeristenceHandler handler = new ManagedObjectPeristenceHandler();
-
    /** The logger. */
    private static final Logger log = Logger.getLogger(AbstractAttachmentStore.class);
    
-   public AbstractAttachmentStore(File root)
+   /** The vfs deployment factory. */
+   private static final VFSDeploymentFactory deploymentFactory = VFSDeploymentFactory.getInstance();
+   
+   /** The attachment store root. */
+   private final URI attachmentStoreRoot;
+   
+   /** The attachment serializer. */
+   private AbstractFileAttachmentsSerializer serializer;
+
+   /** The main deployer. */
+   private MainDeployerStructure mainDeployer;
+   
+   /** The persistence factory. */
+   private PersistenceFactory persistenceFactory;
+  
+   protected static URI getURI(File root)
    {
       if(root == null)
-         throw new IllegalArgumentException("Null attachmentStoreDir");
+         throw new IllegalArgumentException("Null attachment root.");
       if(root.exists() && root.isDirectory() == false)
-         throw new IllegalArgumentException("AttachmentStoreRoot is not a directory.");
-      this.attatchmentStoreRoot = root.toURI();
+         throw new IllegalArgumentException("Attachment root is not a directory.");
+      return root.toURI();
    }
-   
-   public URI getAttachmentStoreRoot()
+
+   public AbstractAttachmentStore(File root)
    {
-      return this.attatchmentStoreRoot;
+      this(getURI(root));
    }
    
-   public VFSDeploymentFactory getDeploymentFactory()
+   public AbstractAttachmentStore(URI uri)
    {
-      return deploymentFactory;
+      if(uri == null)
+         throw new IllegalArgumentException("Null uri.");
+      
+      this.attachmentStoreRoot = uri;
    }
    
-   public void setDeploymentFactory(VFSDeploymentFactory deploymentFactory)
+   public URI getAttachmentStoreRoot()
    {
-      this.deploymentFactory = deploymentFactory;
+      return this.attachmentStoreRoot;
    }
-   
+  
    public MainDeployerStructure getMainDeployer()
    {
       return mainDeployer;
@@ -131,535 +122,227 @@
    
    public AbstractFileAttachmentsSerializer getSerializer()
    {
-      return serializer;
+      return this.serializer;
    }
    
    public void setSerializer(AbstractFileAttachmentsSerializer serializer)
    {
       this.serializer = serializer;
    }
-   
-   public VirtualFileFilter getMetaDataFilter()
+
+   public PersistenceFactory getPersistenceFactory()
    {
-      return metaDataFilter;
+      return persistenceFactory;
    }
    
-   public void setMetaDataFilter(VirtualFileFilter metaDataFilter)
+   public void setPersistenceFactory(PersistenceFactory persistenceFactory)
    {
-      this.metaDataFilter = metaDataFilter;
+      this.persistenceFactory = persistenceFactory;
    }
    
-   public Deployment createMCDeployment(ProfileDeployment profileDeployment) throws Exception
+   public Deployment createDeployment(ProfileDeployment deployment) throws Exception
    {
-      if(profileDeployment.getRoot() == null)
-      {
-         return new AbstractDeployment(profileDeployment.getName());
-      }
+      Deployment mcDeployment = null;
+      if(deployment.getRoot() == null)
+         mcDeployment = new AbstractDeployment(deployment.getName());
       else
+         mcDeployment = deploymentFactory.createVFSDeployment(deployment.getRoot());
+      
+      // Add the deployment attachments as PredeterminedManagedObjects
+      Map<String, Object> attachments = deployment.getAttachments();
+      if(attachments != null && attachments.isEmpty() == false)
       {
-         return deploymentFactory.createVFSDeployment(profileDeployment.getRoot());
+         MutableAttachments predetermined = AttachmentsFactory.createMutableAttachments();
+         for(String name : attachments.keySet())
+            predetermined.addAttachment(name, attachments.get(name));
+         mcDeployment.setPredeterminedManagedObjects(predetermined);
       }
+      return mcDeployment;
    }
    
    /**
-    * Create a VFSDeployment with predetermined managed object.
+    * Load the attachment metadata for a deployment.
     * 
-    * @param file the deployment root.
-    * @param phase the deployment phase
-    * @return the VFSDeployment
+    * @param relativeDeploymentPath the relative path
+    * @return the attachment metadata
     */
-   public Deployment loadDeploymentData(ProfileDeployment profileDeployment) throws Exception
+   protected RepositoryAttachmentMetaData loadAttachmentMetaData(String relativeDeploymentPath)
    {
-      if(profileDeployment == null)
-         throw new IllegalArgumentException("Null profile deployment.");
-      
-      boolean trace = log.isTraceEnabled();
-      
-      // Create VFS deployment
-      Deployment deployment = createMCDeployment(profileDeployment);
-      if(log.isTraceEnabled())
-         log.trace("Created deployment: " + deployment);
-      
-      // TODO also handle normal Deployments
-      if(profileDeployment.getRoot() == null)
-         return deployment;
-      
-      // simpleName + hash
-      String deploymentPath = createRelativeDeploymentPath(profileDeployment);
-      if(trace)
-         log.trace("trying to load attachment from relative path: " + deploymentPath);
-      
-      // Load the metadata
-      RepositoryAttachmentMetaData attachmentMetaData = loadAttachmentMetaData(deploymentPath);
-      
-      if(attachmentMetaData == null)
-      {
-         log.debug("No persisted attachment found for deployment " + deployment + " with relative path: "+ deploymentPath);
-         return deployment;
-      }
-      
-      log.debug("Persisted attachment found for deployment " + deployment + " with relative path: "+ deploymentPath);
-      
+      // attachments/simpleName - hash/metadata.xml
+      String fixedMetadataPath = getMetaDataPathName(relativeDeploymentPath);   
+               
       try
-      {
-         // If the deployment has changes we skip restoring the persisted metadata.
-         // TODO delete attachments ?
-         // TODO check metadata locations
-         if(attachPredeterminedObject(profileDeployment.getRoot(), attachmentMetaData) == false)
-         {
-            log.debug("Not using the persisted metadata, as the deployment was modified.");
-            return deployment;
-         }
+      {  // Try to load the repository attachment metadata
+         return getSerializer().loadAttachment(fixedMetadataPath, RepositoryAttachmentMetaData.class);
       }
-      catch(IOException e)
+      catch(Exception e)
       {
-         log.error("failed to get LastModified date for file, not using persisted metadata: "+ profileDeployment.getName());
-         return deployment;
+         log.error("Failed to load attachment metadata from relative path: "+ relativeDeploymentPath, e);
       }
-      
-      // Start with "" the root contextPath
-      rebuildStructureContext(deployment, "", deploymentPath, attachmentMetaData, trace);
-      
-      return deployment;
+      return null;
    }
    
-   /**
-    * Determine whether to attach the PredeterminedManagedObjects or not.
-    * 
-    * TODO this should also check the metadata paths for the deployment. 
-    * 
-    * @param root the path of the deployment
-    * @param metaData the repository meta data
-    * @return hasBeenModified.
-    * @throws IOException
-    */
-   protected boolean attachPredeterminedObject(VirtualFile root, RepositoryAttachmentMetaData metaData)
-      throws IOException
+   public RepositoryAttachmentMetaData loadMetaData(VirtualFile deploymentRoot) throws Exception
    {
-      boolean attach = true;
-      long lastModified = metaData.getLastModified();
-      // Check directory
-      if(root.isLeaf() == false && root.isArchive() == false)
-      {
-         // TODO recursive checks
-         DeploymentStructureMetaData structure = metaData.getDeploymentStructure();
-         if(checkMetaDataModifications(root, structure, lastModified) == false)
-            return false;
-      }
-      else
-      {
-         // Otherwise we only check the root
-         if(lastModified < root.getLastModified())
-            return false;         
-      }
-      return attach;
+      if(deploymentRoot == null)
+         throw new IllegalArgumentException("Null deployment root.");
+      
+      String deploymentPath = createRelativeDeploymentPath(deploymentRoot);
+      return loadAttachmentMetaData(deploymentPath);
    }
-   
-   
-   protected boolean checkMetaDataModifications(VirtualFile root, DeploymentStructureMetaData structure, long lastModified)
-   {
-      if(structure == null)
-         return true;
 
-      List<String> metaDataPaths = structure.getMetaDataPaths();
-      if(metaDataPaths != null && metaDataPaths.isEmpty() == false)
-      {
-         for(String path : metaDataPaths)
-         {
-            try
-            {
-               VirtualFile vf = root.getChild(path);
-               if(vf != null)
-               {
-                  List<VirtualFile> children = vf.getChildren(metaDataFilter);
-                  if(children != null && children.isEmpty() == false)
-                  {
-                     for(VirtualFile child : children)
-                     {
-                        if(lastModified < child.getLastModified())
-                           return false;
-                     }
-                  }
-               }
-            }
-            catch(Exception e)
-            {
-               log.debug("Failed to check deployment modifications, ignoring persisted information.");
-               return false;
-            }
-         }            
-      }
-      return true;
-   }
-   
-   /**
-    * Remove a component will flag this component as removed and will therefore not
-    * be restored after a restart.
-    * 
-    * @param deployment the profile deployment
-    * @param comp the managed component
-    * @throws Exception
-    */
-   public void removeComponent(ProfileDeployment deployment, ManagedComponent comp)
-      throws Exception
+   public void removeComponent(String ctx, ManagedComponent comp) throws Exception
    {
-      if(deployment == null)
-         throw new IllegalArgumentException("Null deployment.");
+      if(ctx == null)
+         throw new IllegalArgumentException("null deployment ctx name");
       if(comp == null)
-         throw new IllegalArgumentException("Null managed component.");
+         throw new IllegalArgumentException("null managed component");
       
-      // Create the remove handler
-      ManagedObjectRemoveHandler removeHandler = new ManagedObjectRemoveHandler(comp);
-      updateDeployment(deployment, comp, removeHandler);
+      saveAttachment(ctx, comp, true);
    }
-   
-   
-   /**
-    * Persist the updated metadata for a managedComponent and generate a metadata describing
-    * the repository, if it does not exist already.
-    * 
-    * @param deployment the deployment.
-    * @param phase the deployment phase.
-    * @param comp the managed component.
-    * @throws Exception
-    */
-   public void updateDeployment(ProfileDeployment deployment, ManagedComponent comp)
-      throws Exception
+
+   public void updateDeployment(String ctx, ManagedComponent comp) throws Exception
    {
+      if(ctx == null)
+         throw new IllegalArgumentException("null deployment ctx name");
       if(comp == null)
-         return;
-      
-      // Update deployment
-      updateDeployment(deployment, comp, handler);      
+         throw new IllegalArgumentException("null managed component");
+
+      saveAttachment(ctx, comp, false);
    }
    
-   
-   public void updateDeployment(ProfileDeployment deployment, ManagedComponent comp, ManagedObjectPeristenceHandler persistenceHandler)
-      throws Exception
+   public void saveAttachment(String deploymentName, ManagedComponent component, boolean remove) throws Exception
    {
-      if(deployment == null)
-         throw new IllegalArgumentException("Null deployment.");
-      if(comp == null)
-         throw new IllegalArgumentException("Null managed component.");
-      if(persistenceHandler == null)
-         throw new IllegalArgumentException("Null persistence handler.");
+      VFSDeploymentContext ctx = getDeploymentContext(deploymentName);
+      if(ctx == null)
+         throw new IllegalStateException("Cannot persist attachment, failed to find deployment: " + deploymentName);
+
+      // Get the root
+      VirtualFile root = ctx.getRoot();
+      String deploymentPath = createRelativeDeploymentPath(root);
       
-      if(deployment.getRoot() == null)
+      // Load previous saved information
+      RepositoryAttachmentMetaData repositoryMetaData = loadAttachmentMetaData(deploymentPath);
+      if(repositoryMetaData == null)
       {
-         // TODO
-         log.debug("Cannot persist attachments for non VFS based deployment: " + deployment);
-         return;
+         repositoryMetaData = RepositoryAttachmentMetaDataFactory.createInstance();
+         repositoryMetaData.setDeploymentName(root.getName());
       }
-      
-      if(comp == null)
-         throw new IllegalArgumentException("ManagedComponent may not be null.");
-      
-      boolean trace = log.isTraceEnabled();
-      
-      // Log 
-      log.debug("updating deployment: "+ deployment + ", component: "+ comp);
-      
-      // simpleName + hash
-      String deploymentPath = createRelativeDeploymentPath(deployment);
-      RepositoryAttachmentMetaData savedMetaData = loadAttachmentMetaData(deploymentPath); 
-      
-      // Get parent deployment
-      ManagedDeployment md = comp.getDeployment();
-      String currentContextName = "";
-      if(md.getParent() != null)
-      {
-         while( md.getParent() != null )
-         {
-            currentContextName = md.getSimpleName() + "/" + currentContextName;
-            md = md.getParent();
-         }
-         currentContextName = fixName(currentContextName);
-      }
-      
-      RepositoryAttachmentMetaData currentContextMetaData = null;
-      if(savedMetaData != null)
-      {
-         if(trace)
-            log.trace("Previous metadata found for deployment: " + deployment);
-         
-         // The root context
-         if("".equals(currentContextName))
-         {
-            currentContextMetaData = savedMetaData;
-         }
-         else
-         {
-            for(RepositoryAttachmentMetaData child : savedMetaData.getChildren())
-            {
-               // extract the current context
-               if(child.getDeploymentName().equals(currentContextName))
-                  currentContextMetaData = child;
-            }
-         }
-      }
-      else
-      {
-         // Create the metadata
-         savedMetaData = RepositoryAttachmentMetaDataFactory.createInstance(md);
-         currentContextMetaData = createRepositoryMetaData(savedMetaData, currentContextName, md);
-      }
-      
-      if(currentContextMetaData == null)
-         throw new IllegalStateException("Could not create metadata");
-      
-      // Get the currentTimeMillis
-      long lastModified = System.currentTimeMillis();
-      
-      // Get the parent ManagedCommon
-      ManagedCommon parent = comp;
+
+      // Get the parent MO
+      ManagedCommon parent = component;
       while(parent.getParent() != null)
          parent = parent.getParent();
 
       // Get the managed object, as a component can also be a child of a managedObject
-      ManagedObject managedObject = comp.getDeployment().getManagedObject(parent.getName());
-      // Create a AttachmentMetaData for the MO
-      if(managedObject != null)
+      ManagedObject managedObject = component.getDeployment().getManagedObject(parent.getName());
+      if(managedObject == null && parent instanceof ManagedObject)
+         managedObject = (ManagedObject) parent;
+      
+      // Get the current attachment
+      String attachmentName = managedObject.getAttachmentName(); 
+      List<AttachmentMetaData> attachments = repositoryMetaData.getAttachments();
+      if(attachments == null)
       {
-         String attachmentName = managedObject.getAttachmentName(); 
-         // Create attachmentMetaData if needed
-         AttachmentMetaData attachment = RepositoryAttachmentMetaDataFactory.findAttachment(attachmentName, currentContextMetaData.getAttachments());
-         if(attachment == null)
-         {
-            // Add a new attachment
-            attachment = new AttachmentMetaData();
-            RepositoryAttachmentMetaDataFactory.addAttachment(currentContextMetaData, attachment);
-         }
-         
-         // Is attachmentName the same as the className ?
-         attachment.setName(attachmentName);
-         attachment.setClassName(managedObject.getAttachment().getClass().getName());
-         
-         // Create the persistence information and add it as a transient attachment
-         PersistedManagedObject persistedMO = createPersistedMetaData(managedObject, persistenceHandler);
-         attachment.setAttachment(persistedMO);
-         
-         // Update lastModified
-         currentContextMetaData.setLastModified(lastModified);
+         attachments = new ArrayList<AttachmentMetaData>();
+         repositoryMetaData.setAttachments(attachments);
       }
+      // Extract the attachment 
+      AttachmentMetaData attachment = null;
+      for(AttachmentMetaData a : attachments)
+      {
+         if(attachmentName.equals(a.getName()))
+            attachment = a;
+      }      
       
-      // Save the attachment for the root
-      saveAttachmentMetaData(deploymentPath, savedMetaData);
-
-      // Set the last modified on the root metadata
-      savedMetaData.setLastModified(lastModified);
-      
-      // Save the repository meta data
-      this.serializer.saveAttachment(getMetaDataPathName(deploymentPath), savedMetaData);      
-      
-   }
-   
-   /**
-    * Create the repository meta data from the parent ManagedDeployment.
-    * 
-    * @param parentMd the parent managed deployment
-    * @return the RepositoryAttachmentMetaData with the structure information 
-    * @throws Exception
-    */
-   protected RepositoryAttachmentMetaData createRepositoryMetaData(RepositoryAttachmentMetaData parentMetaData, String childPath, ManagedDeployment parentMd)
-      throws Exception
-   {
-      // Child metadata 
-      RepositoryAttachmentMetaData childMetaData = null;
-      
-      StructureMetaData structure = getStructureMetaData(parentMd.getName());
-      if(structure == null)
-         throw new IllegalStateException("Could not get the StructureMetaData.");
-      
-      List<ContextInfo> contextInfos = structure.getContexts();
-      if(contextInfos == null)
-         throw new IllegalStateException("StructureMetaData has no contexts."); // can this happen anyway ?
-      
-      // root context
-      RepositoryAttachmentMetaDataFactory.applyStructureContext(parentMetaData, structure.getContext(""));
-      // Other contexts
-      for(ContextInfo info : contextInfos)
+      // Create a new one
+      if(attachment == null)
       {
-         // If it is not the root path
-         if(! "".equals(info.getPath()))
-         {
-            String childContextName = fixName(info.getPath());
-            // TODO we might need to check the context itself contains a subdeployment? 
-            
-            RepositoryAttachmentMetaData newChild = RepositoryAttachmentMetaDataFactory.createInstance();
-            newChild.setDeploymentName(childContextName);
-            
-            RepositoryAttachmentMetaDataFactory.applyStructureContext(newChild, info);
-            RepositoryAttachmentMetaDataFactory.addChild(parentMetaData, newChild);
-            
-            if(childPath.equals(childContextName))
-               childMetaData = newChild;
-         }
+         // Create attachment meta data
+         attachment = new AttachmentMetaData();
+         // Add attachment meta data
+         attachments.add(attachment);
       }
+
+      // Is attachmentName the same as the className ?
+      attachment.setName(attachmentName);
+      attachment.setClassName(managedObject.getAttachment().getClass().getName());
       
-      if("".equals(childPath))
-         childMetaData = parentMetaData;
+      // Save the attachment
+      String attachmentPath = deploymentPath + attachment.getName();
+      // Create the persistence information
+      PersistenceRoot persistenceRoot = getSerializer().loadAttachment(attachmentPath, PersistenceRoot.class);
+      //
+      persistenceRoot = createPersistedMetaData(persistenceRoot, managedObject, component, remove);
+      // Serialize the attachment
+      getSerializer().saveAttachment(attachmentPath, persistenceRoot);
+
+      // Update the last modified.
+      long lastModified = System.currentTimeMillis();
+      attachment.setLastModified(lastModified);
+      repositoryMetaData.setLastModified(lastModified);
       
-      return childMetaData;
+      //  Save the updated repository meta data
+      getSerializer().saveAttachment(getMetaDataPathName(deploymentPath), repositoryMetaData);
    }
-   
 
    /**
-    * Save the attachments based on the RepositoryAttachmentMetaData.
-    * 
-    * @param deploymentPath the deploymentPath
-    * @param metaData the repository meta data.
-    * @throws Exception
-    */
-   private void saveAttachmentMetaData(String deploymentPath, RepositoryAttachmentMetaData metaData)
-      throws Exception
+   * create the xml meta data for persisting the managed object.
+   * 
+   * @param parent the parent managed object.
+   * @param the managed object
+   * @param handler the persistence handler
+   * @return the xml metadata.
+   */
+  protected PersistenceRoot createPersistedMetaData(PersistenceRoot root, ManagedObject managedObject, ManagedComponent component, boolean remove)
+  {
+     if(root == null)
+        root = new PersistenceRoot();
+ 
+     if(remove)
+     {
+        root = this.persistenceFactory.removeComponent(root, managedObject, component);
+     }
+     else
+     {
+        root = this.persistenceFactory.updateComponent(root, managedObject, component);
+     }
+     if(root.getName() == null)
+        root.setName(managedObject.getAttachmentName());
+     if(root.getClassName() == null)
+        root.setClassName(managedObject.getAttachment().getClass().getName());
+     
+     return root;
+  }
+
+   
+   
+   public PersistenceRoot loadAttachment(VirtualFile deploymentCtx, AttachmentMetaData attachment) throws Exception
    {
-      boolean trace = log.isTraceEnabled();
-         
-      // Save attachments for the root context
-      if(metaData.getAttachments() != null && metaData.getAttachments().isEmpty() == false)
-      {
-         for(AttachmentMetaData attachment : metaData.getAttachments())
-         {
-            // Only save attachment if the attachment is present :)
-            if(attachment.getAttachment() == null)
-               continue;
-            
-            // Get the xml for the persisted attachment
-            PersistedManagedObject root = (PersistedManagedObject) attachment.getAttachment();
-            
-            String attachmentPath = deploymentPath + attachment.getName();
-            // Serialize the attachment
-            serializer.saveAttachment(attachmentPath, root);
-            
-            if(trace)
-               log.trace("Stored attachment to : " + attachmentPath);
-         }
-      }
+      if(deploymentCtx == null)
+         throw new IllegalArgumentException("Null deployment root.");
+      if(attachment == null)
+         throw new IllegalArgumentException("Null attachment");
       
-      // Save the attachments for the childs
-      if(metaData.getChildren() != null && metaData.getChildren().isEmpty() == false)
-      {
-         for(RepositoryAttachmentMetaData child : metaData.getChildren())
-         {
-            String childDeploymentPath = deploymentPath + File.separator + child.getDeploymentName() + File.separator;
-            saveAttachmentMetaData(childDeploymentPath, child);
-         }
-      }
+      String deploymentPath = createRelativeDeploymentPath(deploymentCtx);
+      
+      // Load
+      String attachmentPath = deploymentPath + attachment.getName();
+      return getSerializer().loadAttachment(attachmentPath, PersistenceRoot.class);
    }
    
    /**
-    * create the xml meta data for persisting the managed object.
+    * Get the metadata path, based on a relative path.
     * 
-    * @param mo the managed object.
-    * @param handler the persistence handler
-    * @return the xml metadata.
+    * @param deploymentPath the relative path to the deployment
+    * @return
     */
-   protected PersistedManagedObject createPersistedMetaData(ManagedObject mo, ManagedObjectPeristenceHandler handler)
+   protected String getMetaDataPathName(String deploymentPath)
    {
-      // Return
-      return handler.createPersistenceMetaData(mo);
+      return deploymentPath.endsWith(File.separator) ? deploymentPath + METADATA_NAME : deploymentPath + File.separator + METADATA_NAME;
    }
    
    /**
-    * Rebuild the StructureMetaData based on the RepositoryAttachmentMetaData
-    * and add predeterminedManagedObjects.
-    * 
-    * @param deployment the VFSDeployment
-    * @param contextName the structure context path
-    * @param deploymentPath the path to the attachment
-    * @param attachmentMetaData the meta data
-    */
-   protected void rebuildStructureContext(Deployment deployment,
-         String contextName,
-         String deploymentPath,
-         RepositoryAttachmentMetaData attachmentMetaData,
-         boolean trace)
-   {
-      // The toplevel context
-      boolean isRoot = "".equals(contextName);
-      
-      if(trace)
-         log.trace("Rebuilding StructureMetaData for context: " + contextName);
-
-      // Get the stored deployment structure
-      DeploymentStructureMetaData structure = attachmentMetaData.getDeploymentStructure();
-      
-      // MetaData and ClassPath
-      List<String> metaDataPaths = new ArrayList<String>();
-      List<ClassPathEntry> classPath = new ArrayList<ClassPathEntry>();
-      if(structure != null)
-      {
-         if(structure.getClassPaths() != null)
-         {
-            for(DeploymentClassPathMetaData md : structure.getClassPaths())
-               classPath.add(deploymentFactory.createClassPathEntry(md.getPath(), md.getSuffixes()));
-         }
-         
-         if(structure.getMetaDataPaths() != null)
-            metaDataPaths = structure.getMetaDataPaths(); 
-      }
-      
-      // Now create the ContextInfo
-      ContextInfo info = deploymentFactory.addContext(deployment, contextName, metaDataPaths, classPath);
-      if(structure != null)
-      {
-         // Set the comparator
-         info.setComparatorClassName(structure.getComparatorClass());
-         // Set the relative order
-         info.setRelativeOrder(structure.getRelatativeOrder());
-      }
-      if(trace)
-         log.trace("created ContextInfo: "+  info + " for deployment: "+ deployment);
-      
-      // Add attachments if needed 
-      if(attachmentMetaData.getAttachments() != null && ! attachmentMetaData.getAttachments().isEmpty())
-      {
-         Set<String> availableAttachments = new HashSet<String>();
-         for(AttachmentMetaData attachment : attachmentMetaData.getAttachments())
-            availableAttachments.add(attachment.getClassName());
-
-          MutableAttachments mutable =  createPredeterminedAttachment(deploymentPath, availableAttachments);
-          
-          // TODO is there a better way to do this ?
-          if(isRoot)
-          {
-             deployment.setPredeterminedManagedObjects(mutable);
-          }
-          else
-          {
-             info.setPredeterminedManagedObjects(mutable);
-          }
-          
-          if(trace)
-             log.trace("Added PredetminedManagedObjects: " + availableAttachments + " to context " + contextName);
-      }
-      else
-      {
-         if(trace)
-            log.trace("No PredetminedManagedObjects found for context " + contextName);         
-      }
-      
-      // Process children
-      List<RepositoryAttachmentMetaData> children = attachmentMetaData.getChildren(); 
-      if(children != null && children.isEmpty() == false)
-      {
-         for(RepositoryAttachmentMetaData childMetaData : children)
-         {
-            // The structure context path
-            String childContextName = contextName + "/" + childMetaData.getDeploymentName();
-            // The relative path of the child attachment (therefore File.separator) 
-            String relativePath = deploymentPath + childMetaData.getDeploymentName() + File.separator;
-            
-            if(trace)
-               log.trace("Processing child context: "+ childContextName);
-            
-            // Rebuild the structure of the child
-            rebuildStructureContext(deployment, fixName(childContextName), relativePath, childMetaData, trace);
-         }
-      }
-   }
-   
-   /**
     * Create the relative path to the persisted deployment attachment meta data.
     * The string is simpleName + "-" + hash (based on the URI of the deployment)
     * 
@@ -667,14 +350,14 @@
     * @return the relative name
     * @throws Exception
     */
-   protected String createRelativeDeploymentPath(ProfileDeployment deployment) throws Exception
+   protected String createRelativeDeploymentPath(VirtualFile vf) throws Exception
    {
-      if(deployment == null)
+      if(vf == null)
          throw new IllegalStateException("Null deployment.");
       
       // deployment URI 
-      String pathName = deployment.getRoot().toURI().toString();
-      String fileName = deployment.getRoot().getName();
+      String pathName = vf.toURI().toString();
+      String fileName = vf.getName();
       // Generate hash
       String hash = HashGenerator.createHash(pathName);
       // simple name + "-" + hash
@@ -683,69 +366,6 @@
    }
    
    /**
-    * Create a predetermined managedObject attachment.
-    * 
-    * @param deploymentPath the relative deployment path
-    * @param availableAttachments the available attachments
-    * @return
-    */
-   protected MutableAttachments createPredeterminedAttachment(String deploymentPath, Set<String> availableAttachments)
-   {
-      return new LazyPredeterminedManagedObjects(this.serializer, deploymentPath, availableAttachments);
-   }
-   
-   /**
-    * Get the metadata path, based on a relative path.
-    * 
-    * @param deploymentPath the relative path to the deployment
-    * @return
-    */
-   protected String getMetaDataPathName(String deploymentPath)
-   {
-      return deploymentPath.endsWith(File.separator) ? deploymentPath + METADATA_NAME : deploymentPath + File.separator + METADATA_NAME;
-   }
-   
-   /**
-    * Load the attachment metadata for a deployment.
-    * 
-    * @param relativeDeploymentPath the relative path
-    * @return the attachment metadata
-    */
-   protected RepositoryAttachmentMetaData loadAttachmentMetaData(String relativeDeploymentPath)
-   {
-      // attachments/simpleName - hash/metadata.xml
-      String fixedMetadataPath = getMetaDataPathName(relativeDeploymentPath);   
-               
-      try
-      {  // Try to load the repository attachment metadata
-         return this.serializer.loadAttachment(fixedMetadataPath, RepositoryAttachmentMetaData.class);
-      }
-      catch(Exception e)
-      {
-         log.error("Failed to load attachment metadata from relative path: "+ relativeDeploymentPath, e);
-      }
-      return null;
-   }
-   
-   
-   /**
-    * Get the structure meta data for a deployment.
-    * 
-    * @param vfsDeploymentName the vfs deployment name
-    * @return the StructureMetaData
-    * @throws Exception
-    */
-   protected StructureMetaData getStructureMetaData(String vfsDeploymentName)
-   {
-      // Get the StructureMetaData;
-      DeploymentContext deploymentContext = getDeploymentContext(vfsDeploymentName);
-      if(deploymentContext == null)
-         throw new IllegalStateException("Could not find deployment context for name: "+ vfsDeploymentName);
-      
-      return deploymentContext.getDeploymentUnit().getAttachment(StructureMetaData.class);
-    }
-   
-   /**
     * Get deployment context.
     *
     * @param name the deployment context name
@@ -763,30 +383,7 @@
 
       return (VFSDeploymentContext)deploymentContext;
    }
-   
-   /**
-    * Make sure that the name does not start or end with /
-    * 
-    * @param name
-    * @return
-    */
-   private String fixName(String name)
-   {
-      if(name == null)
-         return null;
-      
-      if(name.equals(""))
-         return name;
-      
-      if(name.startsWith("/"))
-         name = name.substring(1);
-      
-      if(name.endsWith("/"))
-         name = name.substring(0, name.length() -1);
-      
-      return name;
-   }
-   
+
    private static class HashGenerator
    {
       /** The digest. */
@@ -844,5 +441,5 @@
          return digest;
       }
    }
-   
+ 
 }

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileDeployment.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileDeployment.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileDeployment.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -25,6 +25,7 @@
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
+import org.jboss.deployers.vfs.spi.client.VFSDeployment;
 import org.jboss.profileservice.spi.ProfileDeployment;
 import org.jboss.virtual.VirtualFile;
 
@@ -36,7 +37,7 @@
  */
 public class AbstractProfileDeployment implements ProfileDeployment
 {
-   
+
    /** The name. */
    private String name;
    
@@ -46,8 +47,11 @@
    /** The attachments. */
    private Map<String, Object> attachments = new ConcurrentHashMap<String, Object>();
    
+   /** The transient attachments. */
+   private transient Map<String, Object> transientAttachments = new ConcurrentHashMap<String, Object>();
+   
    /** The serialVersionUID. */
-   private static final long serialVersionUID = -2600392045205267112L;
+   private static final long serialVersionUID = -2208890215429044674L;
    
    /**
     * Get the vfs file name safely.
@@ -105,6 +109,16 @@
    }
    
    /**
+    * Get all attachments.
+    * 
+    * @return the attachments
+    */
+   public Map<String, Object> getAttachments()
+   {
+      return Collections.unmodifiableMap(this.attachments);
+   }
+   
+   /**
     * Get attachment.
     * 
     * @param name the name of the attachment
@@ -119,6 +133,32 @@
       
       return this.attachments.get(name);
    }
+   
+   /**
+    * Get attachment.
+    * 
+    * @param <T> the expected type
+    * @param name the name of the attachment
+    * @param expected the expected type
+    * @return the attachment or null if not present
+    * 
+    * @throws IllegalArgumentException for a null name
+    */
+   public <T> T getAttachment(String name, Class<T> expectedType)
+   {
+      if(expectedType == null)
+         throw new IllegalArgumentException("null expected type");
+      
+      Object attachment = getAttachment(name);
+      if(attachment == null)
+         return null;
+     
+      if(expectedType.isInstance(attachment) == false)
+         throw new IllegalStateException("attachment " + name + 
+            " with value " + attachment + " is not of the expected type " + expectedType);
+      
+      return expectedType.cast(attachment);
+   }
 
    /**
     * Add attachment.
@@ -140,15 +180,98 @@
    }
    
    /**
-    * Get all attachments.
+    * Remove attachment.
     * 
-    * @return the attachments
+    * @param name the attachment name
+    * @return the attachment or null if not present
+    * 
+    * @throws IllegalArgumentException for a null name
     */
-   public Map<String, Object> getAttachments()
+   public Object removeAttachment(String name)
    {
-      return Collections.unmodifiableMap(this.attachments);
+      if(name == null)
+         throw new IllegalArgumentException("Null attachment name.");
+      
+      return this.attachments.remove(name);
    }
    
+   /**
+    * Get the transient attachment. 
+    * 
+    * @param name the name of the attachment
+    * @return the attachment or null if not present
+    * 
+    * @throws IllegalArgumentException for a null name
+    */
+   public Object getTransientAttachment(String name)
+   {
+      if(name == null)
+         throw new IllegalArgumentException("Null attachment name.");
+      
+      return this.transientAttachments.get(name);
+   }
+   
+   /**
+    * Get transient attachment.
+    * 
+    * @param <T> the expected type
+    * @param name the name of the attachment
+    * @param expected the expected type
+    * @return the attachment or null if not present
+    * 
+    * @throws IllegalArgumentException for a null name
+    */
+   public <T> T getTransientAttachment(String name, Class<T> expectedType)
+   {
+      if(expectedType == null)
+         throw new IllegalArgumentException("null expected type");
+      
+      Object attachment = getTransientAttachment(name);
+      if(attachment == null)
+         return null;
+     
+      if(expectedType.isInstance(attachment) == false)
+         throw new IllegalStateException("attachment " + name + 
+            " with value " + attachment + " is not of the expected type " + expectedType);
+      
+      return expectedType.cast(attachment);
+   }
+   
+   /**
+    * Add transient attachment
+    * 
+    * @param name the name of the attachment
+    * @param attachment the attachment
+    * @return any previous attachment
+    * 
+    * @throws IllegalArgumentException for a null name or attachment 
+    */
+   public Object addTransientAttachment(String name, Object attachment)
+   {
+      if(name == null)
+         throw new IllegalArgumentException("Null attachment name.");
+      if(attachment == null)
+         throw new IllegalArgumentException("Null attachment.");
+      
+      return this.transientAttachments.put(name, attachment);
+   }
+   
+   /**
+    * Remove transient attachment.
+    * 
+    * @param name the attachment name
+    * @return the attachment or null if not present
+    * 
+    * @throws IllegalArgumentException for a null name
+    */
+   public Object removeTransientAttachment(String name)
+   {
+      if(name == null)
+         throw new IllegalArgumentException("Null attachment name.");
+      
+      return this.transientAttachments.remove(name);
+   }
+   
    public String toString()
    {
       return "AbstractProfileDeployment(" + root != null ? root.getName() : name + ")";

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractVFSProfileSource.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractVFSProfileSource.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractVFSProfileSource.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -196,7 +196,7 @@
    protected void loadApplications(VirtualFile applicationDir) throws Exception
    {
       ArrayList<VirtualFile> added = new ArrayList<VirtualFile>();
-      addedDeployments(added, applicationDir);
+      addedDeployment(added, applicationDir);
       for (VirtualFile vf : added)
       {
          ProfileDeployment vfCtx = createDeployment(vf);
@@ -214,7 +214,7 @@
     */
    protected void addedDeployments(List<VirtualFile> list, VirtualFile root) throws IOException, URISyntaxException
    {
-      if(root.isLeaf())
+      if(root.isLeaf() == true || root.isArchive() == true)
       {
          addedDeployment(list, root);
       }

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/BasicDeploymentRepository.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/BasicDeploymentRepository.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/BasicDeploymentRepository.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -36,6 +36,7 @@
 import java.util.zip.ZipInputStream;
 
 import org.jboss.profileservice.spi.DeploymentContentFlags;
+import org.jboss.profileservice.spi.DeploymentOption;
 import org.jboss.profileservice.spi.ModificationInfo;
 import org.jboss.profileservice.spi.ProfileDeployment;
 import org.jboss.profileservice.spi.ProfileKey;
@@ -142,6 +143,12 @@
 
    public String addDeploymentContent(String vfsPath, InputStream contentIS) throws IOException
    {
+      return addDeploymentContent(vfsPath, contentIS, new DeploymentOption[0]);
+   }
+   
+   public String addDeploymentContent(String vfsPath, InputStream contentIS, DeploymentOption... options)
+      throws IOException
+   {
       boolean trace = log.isTraceEnabled();
       // Suspend hot deployment checking
       if( trace )

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/JAXBAttachmentSerializer.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/JAXBAttachmentSerializer.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/JAXBAttachmentSerializer.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -29,20 +29,13 @@
 
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
 
 import org.jboss.logging.Logger;
-import org.jboss.system.server.profileservice.attachments.RepositoryAttachmentMetaData;
-import org.jboss.system.server.profileservice.persistence.xml.PersistedManagedObject;
-import org.jboss.system.server.profileservice.persistence.xml.PersistenceConstants;
-import org.jboss.xb.binding.Unmarshaller;
-import org.jboss.xb.binding.UnmarshallerFactory;
-import org.jboss.xb.binding.sunday.unmarshalling.DefaultSchemaResolver;
 
 /**
  * A basic JAXB attachment Serializer.
  * 
- * It uses JAXB for marshalling the meta data and JBoss XB to unmarshal.
- * 
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
  * @version $Revision$
  */
@@ -55,32 +48,22 @@
    /** The attachment suffix. */
    private static final String ATTACHMENT_SUFFIX = ".attachment.xml";
    
-   /** The default schema resolver. */
-   private static final DefaultSchemaResolver resolver = new DefaultSchemaResolver();
-   
-   static
-   {
-      resolver.addClassBinding("urn:org:jboss:profileservice:attachments:1.0", RepositoryAttachmentMetaData.class);
-      resolver.addClassBinding(PersistenceConstants.NAMESPACE_1_0, PersistedManagedObject.class);
-   }
-   
    public JAXBAttachmentSerializer(File dir)
    {
       super(dir);
    }
-   
+
    @SuppressWarnings("unchecked")
    protected <T> T loadAttachment(File attachmentsStore, Class<T> expected) throws Exception
    {
-      // JBoss XB
-      log.trace("loadAttachment, attachmentsStore="+attachmentsStore);
-      Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
-      unmarshaller.setValidation(false);
-      unmarshaller.setSchemaValidation(false);
+      if(log.isTraceEnabled())
+         log.trace("loadAttachment, attachmentsStore=" + attachmentsStore);
+      JAXBContext ctx = JAXBContext.newInstance(expected);
+      Unmarshaller unmarshaller = ctx.createUnmarshaller();
       InputStream is = new FileInputStream(attachmentsStore);
       try
       {
-         return (T) unmarshaller.unmarshal(is, resolver);
+         return (T) unmarshaller.unmarshal(is);
       }
       finally
       {
@@ -90,8 +73,8 @@
 
    protected void saveAttachment(File attachmentsStore, Object attachment) throws Exception
    {
-      // JAXB
-      log.trace("saveAttachment, attachmentsStore="+attachmentsStore+ ", attachment="+attachment);
+      if(log.isTraceEnabled())
+         log.trace("saveAttachment, attachmentsStore="+attachmentsStore+ ", attachment="+attachment);
       JAXBContext ctx = JAXBContext.newInstance(attachment.getClass());
       Marshaller marshaller = ctx.createMarshaller();
       marshaller.setProperty("jaxb.formatted.output", Boolean.TRUE);

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/MainDeployerAdapter.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/MainDeployerAdapter.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/MainDeployerAdapter.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -147,7 +147,7 @@
     */
    protected Deployment loadDeploymentData(ProfileDeployment deployment) throws Exception
    {
-      return store.loadDeploymentData(deployment);
+      return store.createDeployment(deployment);
    }
    
 }

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/clustered/ClusteredDeploymentRepository.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/clustered/ClusteredDeploymentRepository.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/clustered/ClusteredDeploymentRepository.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -36,6 +36,7 @@
 
 import org.jboss.logging.Logger;
 import org.jboss.profileservice.spi.DeploymentContentFlags;
+import org.jboss.profileservice.spi.DeploymentOption;
 import org.jboss.profileservice.spi.ModificationInfo;
 import org.jboss.profileservice.spi.ProfileDeployment;
 import org.jboss.profileservice.spi.ProfileKey;
@@ -296,7 +297,7 @@
       }
    }
    
-   public String addDeploymentContent(String vfsPath, InputStream contentIS) throws IOException
+   public String addDeploymentContent(String vfsPath, InputStream contentIS, DeploymentOption... options) throws IOException
    {
       if (this.clusteringHandler == null)
       {

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/clustered/ImmutableClusteredDeploymentRepository.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/clustered/ImmutableClusteredDeploymentRepository.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/clustered/ImmutableClusteredDeploymentRepository.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -30,6 +30,7 @@
 import java.util.Map;
 import java.util.Set;
 
+import org.jboss.profileservice.spi.DeploymentOption;
 import org.jboss.profileservice.spi.DeploymentRepository;
 import org.jboss.profileservice.spi.ModificationInfo;
 import org.jboss.profileservice.spi.ProfileKey;
@@ -66,7 +67,7 @@
       return Collections.emptySet();
    }
 
-   public String addDeploymentContent(String vfsPath, InputStream contentIS) throws IOException
+   public String addDeploymentContent(String vfsPath, InputStream contentIS, DeploymentOption... options) throws IOException
    {
       throw new IllegalStateException("Cannot add content to an immutable repository.");
    }

Added: trunk/system/src/tests/org/jboss/test/server/profileservice/component/persistence/support/CompositeMetaData.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/server/profileservice/component/persistence/support/CompositeMetaData.java	                        (rev 0)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/component/persistence/support/CompositeMetaData.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -0,0 +1,78 @@
+/*
+ * 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.test.server.profileservice.component.persistence.support;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class CompositeMetaData
+{
+
+   String string;
+   char character;   
+   Integer integer;
+   
+   public CompositeMetaData()
+   {
+      //
+   }
+   
+   public CompositeMetaData(String string, char character, Integer integer)
+   {
+      this.string = string;
+      this.character = character;
+      this.integer = integer;
+   }
+   
+   public String getString()
+   {
+      return string;
+   }
+   
+   public void setString(String string)
+   {
+      this.string = string;
+   }
+   
+   public char getCharacter()
+   {
+      return character;
+   }
+   
+   public void setCharacter(char character)
+   {
+      this.character = character;
+   }
+   
+   public Integer getInteger()
+   {
+      return integer;
+   }
+   
+   public void setInteger(Integer integer)
+   {
+      this.integer = integer;
+   }
+
+}
+

Added: trunk/system/src/tests/org/jboss/test/server/profileservice/component/persistence/support/TestComponent.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/server/profileservice/component/persistence/support/TestComponent.java	                        (rev 0)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/component/persistence/support/TestComponent.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -0,0 +1,78 @@
+/*
+ * 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.test.server.profileservice.component.persistence.support;
+
+import javax.management.ObjectName;
+
+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.ManagementProperty;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+ at ManagementObject(componentType = @ManagementComponent(type="test", subtype="test"))
+public class TestComponent
+{
+
+   String name;
+   ObjectName objectName;
+   CompositeMetaData composite;
+   
+   @ManagementProperty
+   @ManagementObjectID
+   public String getName()
+   {
+      return name;
+   }
+   
+   public void setName(String name)
+   {
+      this.name = name;
+   }
+   
+   @ManagementProperty
+   public ObjectName getObjectName()
+   {
+      return objectName;
+   }
+   
+   public void setObjectName(ObjectName objectName)
+   {
+      this.objectName = objectName;
+   }
+   
+   @ManagementProperty
+   public CompositeMetaData getComposite()
+   {
+      return composite;
+   }
+   
+   public void setComposite(CompositeMetaData composite)
+   {
+      this.composite = composite;
+   }
+   
+}
+

Added: trunk/system/src/tests/org/jboss/test/server/profileservice/component/persistence/support/TestComponentMapper.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/server/profileservice/component/persistence/support/TestComponentMapper.java	                        (rev 0)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/component/persistence/support/TestComponentMapper.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -0,0 +1,122 @@
+/*
+ * 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.test.server.profileservice.component.persistence.support;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.managed.api.ManagedComponent;
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.metatype.api.values.SimpleValue;
+import org.jboss.system.server.profileservice.persistence.PersistenceFactory;
+import org.jboss.system.server.profileservice.persistence.component.AbstractComponentMapper;
+import org.jboss.system.server.profileservice.persistence.xml.PersistedComponent;
+import org.jboss.system.server.profileservice.persistence.xml.PersistedManagedObject;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class TestComponentMapper extends AbstractComponentMapper
+{
+
+   public TestComponentMapper(PersistenceFactory persistenceFactory)
+   {
+      super(persistenceFactory);
+   }
+
+   @Override
+   protected PersistedComponent createComponent(Object attachment, ManagedComponent component)
+   {
+      // Note: this is using the TestMgtComponentImpl to get the MO
+      ManagedObject mo = (ManagedObject) component.getParent();
+      PersistedManagedObject persistedMO = getPersistencePlugin().createPersistedManagedObject(mo);
+      PersistedComponent persisted = new PersistedComponent(persistedMO);
+      setComponentName(persisted, mo);
+      return persisted;
+   }
+   
+   @Override
+   protected void setComponentName(PersistedComponent component, ManagedObject mo)
+   {
+      // Set the current name for tracking.
+      component.setName((String) ((SimpleValue)mo.getProperty("name").getValue()).getValue()); 
+   }
+
+   @Override
+   protected ManagedObject getComponent(Object attachment, PersistedComponent component, boolean create)
+   {
+      TestDeployment deployment = (TestDeployment) attachment;
+      TestComponent instance = null;
+      if(deployment.getComponents() != null && deployment.getComponents().isEmpty() == false)
+      {
+         for(TestComponent md : deployment.getComponents())
+         {
+            if(md.getName().equals(component.getOriginalName()))
+            {
+               instance = md;
+               break;
+            }
+         }
+      }
+      if(instance == null && create)
+      {
+         instance = createTestComponent(component);
+         deployment.getComponents().add(instance);
+      }
+      if(instance == null)
+      {
+         throw new IllegalStateException("could not find instance with name " + component.getOriginalName());
+      }
+      return getMOF().initManagedObject(instance, null);
+   }
+
+   @Override
+   protected void removeComponent(Object attachment, PersistedComponent component)
+   {
+      TestDeployment deployment = (TestDeployment) attachment;
+      List<TestComponent> components = new ArrayList<TestComponent>(); 
+      if(deployment.getComponents() != null && deployment.getComponents().isEmpty() == false)
+      {
+         for(TestComponent md : deployment.getComponents())
+         {
+            if(md.getName().equals(component.getOriginalName()) == false)
+               components.add(md);
+         }
+         deployment.setComponents(components);
+      }
+   }
+   
+   protected TestComponent createTestComponent(PersistedComponent component)
+   {
+      TestComponent test = new TestComponent();
+      test.setName(component.getOriginalName());
+      return test;
+   }
+
+   public String getType()
+   {
+      return TestDeployment.class.getName();
+   }
+
+}
+

Added: trunk/system/src/tests/org/jboss/test/server/profileservice/component/persistence/support/TestDeployment.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/server/profileservice/component/persistence/support/TestDeployment.java	                        (rev 0)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/component/persistence/support/TestDeployment.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -0,0 +1,52 @@
+/*
+ * 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.test.server.profileservice.component.persistence.support;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.managed.api.annotation.ManagementObject;
+import org.jboss.managed.api.annotation.ManagementProperty;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+ at ManagementObject
+public class TestDeployment
+{
+
+   /** The test components. */
+   private List<TestComponent> components = new ArrayList<TestComponent>();
+   
+   @ManagementProperty(managed = true)
+   public List<TestComponent> getComponents()
+   {
+      return components;
+   }
+   
+   public void setComponents(List<TestComponent> components)
+   {
+      this.components = components;
+   }
+}
+

Added: trunk/system/src/tests/org/jboss/test/server/profileservice/component/persistence/support/TestMgtComponentImpl.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/server/profileservice/component/persistence/support/TestMgtComponentImpl.java	                        (rev 0)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/component/persistence/support/TestMgtComponentImpl.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -0,0 +1,93 @@
+/*
+ * 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.test.server.profileservice.component.persistence.support;
+
+import java.io.Serializable;
+import java.lang.annotation.Annotation;
+import java.util.Map;
+
+import org.jboss.managed.api.ComponentType;
+import org.jboss.managed.api.ManagedCommon;
+import org.jboss.managed.api.ManagedComponent;
+import org.jboss.managed.api.ManagedDeployment;
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.api.RunState;
+import org.jboss.managed.plugins.DelegateManagedCommonImpl;
+
+/**
+ * A test managed component, to have access to the ManagedObject over
+ * the getParent() method.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class TestMgtComponentImpl extends DelegateManagedCommonImpl
+   implements ManagedComponent, Serializable
+{
+
+   private ManagedObject mo;
+   
+   public TestMgtComponentImpl(ManagedObject delegate)
+   {
+      super(delegate);
+      this.mo = delegate;
+   }
+   
+   @Override
+   public ManagedCommon getParent()
+   {
+      return mo;
+   }
+
+   public Map<String, Annotation> getAnnotations()
+   {
+      // FIXME getAnnotations
+      return null;
+   }
+
+   public ManagedDeployment getDeployment()
+   {
+      // FIXME getDeployment
+      return null;
+   }
+
+   public RunState getRunState()
+   {
+      // FIXME getRunState
+      return null;
+   }
+
+   public ComponentType getType()
+   {
+      // FIXME getType
+      return null;
+   }
+
+   public boolean update()
+   {
+      // FIXME update
+      return false;
+   }
+
+
+}
+

Added: trunk/system/src/tests/org/jboss/test/server/profileservice/component/persistence/test/AbstractComponentMapperTest.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/server/profileservice/component/persistence/test/AbstractComponentMapperTest.java	                        (rev 0)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/component/persistence/test/AbstractComponentMapperTest.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -0,0 +1,94 @@
+/*
+ * 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.test.server.profileservice.component.persistence.test;
+
+import java.io.File;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+
+import org.jboss.managed.api.factory.ManagedObjectFactory;
+import org.jboss.system.server.profileservice.persistence.AbstractPersistenceFactory;
+import org.jboss.system.server.profileservice.persistence.PersistenceFactory;
+import org.jboss.system.server.profileservice.persistence.component.ComponentMapper;
+import org.jboss.system.server.profileservice.persistence.xml.PersistenceRoot;
+import org.jboss.test.BaseTestCase;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class AbstractComponentMapperTest extends BaseTestCase
+{
+
+   /** The managed object factory. */
+   private ManagedObjectFactory managedObjectFactory = ManagedObjectFactory.getInstance();
+   
+   /** The persistence factory. */
+   private AbstractPersistenceFactory persistenceFactory = new AbstractPersistenceFactory();
+   
+   public AbstractComponentMapperTest(String name)
+   {
+      super(name);
+   }
+
+   protected ManagedObjectFactory getMOF()
+   {
+      return managedObjectFactory;
+   }
+   
+   protected PersistenceFactory getPersistenceFactory()
+   {
+      return persistenceFactory;
+   }
+   
+   protected void addComponentMapper(ComponentMapper mapper)
+   {
+      persistenceFactory.addComponentMapper(mapper);
+   }
+   
+   protected PersistenceRoot restore(PersistenceRoot root) throws Exception
+   {
+      File file = File.createTempFile("test", null);
+      serialize(root, file);
+      return deserialize(file);
+   }
+   
+   protected void serialize(PersistenceRoot moElement, File file) throws Exception
+   {
+      JAXBContext ctx = JAXBContext.newInstance(PersistenceRoot.class);
+      Marshaller marshaller = ctx.createMarshaller();
+      marshaller.setProperty("jaxb.formatted.output", Boolean.TRUE);
+      marshaller.marshal(moElement, file);
+      marshaller.marshal(moElement, System.out);
+   }
+   
+   protected PersistenceRoot deserialize(File file) throws Exception
+   {
+      JAXBContext ctx = JAXBContext.newInstance(PersistenceRoot.class);
+      Unmarshaller unmarshaller = ctx.createUnmarshaller();
+      return (PersistenceRoot) unmarshaller.unmarshal(file);
+   }
+
+}
+

Added: trunk/system/src/tests/org/jboss/test/server/profileservice/component/persistence/test/ComponentMapperUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/server/profileservice/component/persistence/test/ComponentMapperUnitTestCase.java	                        (rev 0)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/component/persistence/test/ComponentMapperUnitTestCase.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -0,0 +1,220 @@
+/*
+ * 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.test.server.profileservice.component.persistence.test;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.management.ObjectName;
+
+import org.jboss.managed.api.ManagedComponent;
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.metatype.api.values.CollectionValue;
+import org.jboss.metatype.api.values.GenericValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.system.server.profileservice.persistence.xml.PersistenceRoot;
+import org.jboss.test.server.profileservice.component.persistence.support.CompositeMetaData;
+import org.jboss.test.server.profileservice.component.persistence.support.TestComponent;
+import org.jboss.test.server.profileservice.component.persistence.support.TestComponentMapper;
+import org.jboss.test.server.profileservice.component.persistence.support.TestDeployment;
+import org.jboss.test.server.profileservice.component.persistence.support.TestMgtComponentImpl;
+
+/**
+ * Basic component mapper unit test case.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class ComponentMapperUnitTestCase extends AbstractComponentMapperTest
+{
+   
+   public ComponentMapperUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void setUp() throws Exception
+   {
+      super.setUp();
+   }
+   
+   public void testAdd() throws Exception
+   {
+      // Add the component mapper
+      addComponentMapper(new TestComponentMapper(getPersistenceFactory()));
+
+      TestComponent addComponent = createComponentMetaData("component3",
+            new ObjectName("org.jboss:type=testComponent3"),
+            createCompositeMetaData("composite3", 'c', new Integer(3)));
+      
+      ManagedObject temp = getMOF().initManagedObject(addComponent, null);
+      ManagedComponent component = new TestMgtComponentImpl(temp);
+      
+      ManagedObject mo = createDeploymentMO();
+      PersistenceRoot root = getPersistenceFactory().addComponent(mo, component);
+      
+      root = restore(root);
+      
+      TestDeployment attachment = createDeploymentMetaData();
+      getPersistenceFactory().restorePersistenceRoot(root, attachment, null);
+      
+      //
+      assertEquals(3, attachment.getComponents().size());
+   }
+   
+   public void testUpdate() throws Exception
+   {
+      // Add the component mapper
+      addComponentMapper(new TestComponentMapper(getPersistenceFactory()));
+
+      // Get the components
+      ManagedObject mo = createDeploymentMO();
+      Iterator<?> iterator = ((CollectionValue) mo.getProperty("components").getValue()).iterator();
+      ManagedObject component1 = (ManagedObject) ((GenericValue) iterator.next()).getValue();
+      ManagedObject component2 = (ManagedObject) ((GenericValue) iterator.next()).getValue();
+      
+      // create the persistence information
+      TestMgtComponentImpl tComp1 = new TestMgtComponentImpl(component1);
+      PersistenceRoot root = getPersistenceFactory().updateComponent(mo, tComp1);
+      TestMgtComponentImpl tComp2 = new TestMgtComponentImpl(component2);
+      root = getPersistenceFactory().updateComponent(root, mo, tComp2);      
+      
+      assertNotNull(root.getComponents());
+      // serialize / deserialize
+      PersistenceRoot persisted = restore(root);
+      
+      // Create a new root attachment with empty components
+      TestDeployment test = new TestDeployment();
+      test.getComponents().add(createComponentMetaData("component1", null, null));
+      test.getComponents().add(createComponentMetaData("component2", null, null));
+      // Apply the persisted information, which should recreate the missing properties
+      getPersistenceFactory().restorePersistenceRoot(persisted, test, null);
+      assertFalse(test.getComponents().isEmpty());
+      
+      // Check if the properties are available again
+      for(TestComponent restoredComponent : test.getComponents())
+      {
+         assertNotNull("null object name "+ restoredComponent.getName(), restoredComponent.getObjectName());
+         assertNotNull("null composite "+ restoredComponent.getName(), restoredComponent.getComposite());
+      }
+   }
+   
+   public void testRemove() throws Exception
+   {
+      // Add the component mapper
+      addComponentMapper(new TestComponentMapper(getPersistenceFactory()));
+
+      // Get the components
+      ManagedObject mo = createDeploymentMO();      
+      Iterator<?> iterator = ((CollectionValue) mo.getProperty("components").getValue()).iterator();
+      ManagedObject component1 = (ManagedObject) ((GenericValue) iterator.next()).getValue();
+      
+      // create the persistence information
+      TestMgtComponentImpl tComp1 = new TestMgtComponentImpl(component1);
+      PersistenceRoot root = getPersistenceFactory().removeComponent(mo, tComp1);
+      PersistenceRoot persisted = restore(root);
+
+      // Check removed
+      TestDeployment deployment = createDeploymentMetaData();
+      getPersistenceFactory().restorePersistenceRoot(persisted, deployment, null);
+      assertEquals(1, deployment.getComponents().size());
+      
+      // Reset
+      root = getPersistenceFactory().resetComponent(persisted, mo, tComp1);
+      persisted = restore(root);
+      assertNull(persisted.getComponents());
+   }
+   
+   public void testNameChanges() throws Exception
+   {
+      // Add the component mapper
+      addComponentMapper(new TestComponentMapper(getPersistenceFactory()));
+
+      // Get the components
+      ManagedObject mo = createDeploymentMO();
+
+      PersistenceRoot root = new PersistenceRoot();
+      
+      TestDeployment deployment = updateName(root, mo, "change1");
+      mo = getMOF().initManagedObject(deployment, null); 
+      
+      deployment = updateName(root, mo, "change2");
+      mo = getMOF().initManagedObject(deployment, null);
+      
+      deployment = updateName(root, mo, "change3");
+      mo = getMOF().initManagedObject(deployment, null);      
+      
+   }
+   
+   protected TestDeployment updateName(PersistenceRoot root, ManagedObject mo, String name) throws Exception
+   {
+      Iterator<?> iterator = ((CollectionValue) mo.getProperty("components").getValue()).iterator();
+      ManagedObject component = (ManagedObject) ((GenericValue) iterator.next()).getValue();
+      
+      component.getProperty("name").setValue(SimpleValueSupport.wrap(name));
+      root = getPersistenceFactory().updateComponent(root, mo, new TestMgtComponentImpl(component));
+      root = restore(root);
+      
+      TestDeployment deployment = createDeploymentMetaData();
+      getPersistenceFactory().restorePersistenceRoot(root, deployment, null);
+      return deployment;
+   }
+   
+   protected ManagedObject createDeploymentMO() throws Exception
+   {
+      return getMOF().initManagedObject(createDeploymentMetaData(), null);
+   }
+   
+   protected TestDeployment createDeploymentMetaData() throws Exception
+   {
+      TestDeployment deployment = new TestDeployment();
+      List<TestComponent> components = new ArrayList<TestComponent>();
+      components.add(
+            createComponentMetaData("component1",
+                  new ObjectName("org.jboss:type=testComponent1"),
+                  createCompositeMetaData("composite1", 'a', new Integer(1))));
+      components.add(
+            createComponentMetaData("component2",
+                  new ObjectName("org.jboss:type=testComponent2"),
+                  createCompositeMetaData("composite2", 'b', new Integer(2))));
+      deployment.setComponents(components);
+      return deployment;
+   }
+   
+   protected TestComponent createComponentMetaData(String name, ObjectName objectName,
+         CompositeMetaData composite)
+   {
+      TestComponent component = new TestComponent();
+      component.setName(name);
+      component.setObjectName(objectName);
+      component.setComposite(composite);
+      return component;
+   }
+   
+   protected CompositeMetaData createCompositeMetaData(String name, char character, Integer integer)
+   {
+      return new CompositeMetaData(name, character, integer);
+   }
+   
+}
+

Modified: trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/support/GenericSupportMetaData.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/support/GenericSupportMetaData.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/support/GenericSupportMetaData.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -35,8 +35,12 @@
 public class GenericSupportMetaData
 {
 
+   /** The list. */
    List<SimpleGenericMetaData> list;
    
+   /** The array. */
+   SimpleGenericMetaData[][] array;
+   
    @ManagementProperty(managed = true)
    public List<SimpleGenericMetaData> getList()
    {
@@ -48,5 +52,16 @@
       this.list = list;
    }
    
+   @ManagementProperty(managed = true)
+   public SimpleGenericMetaData[][] getArray()
+   {
+      return array;
+   }
+   
+   public void setArray(SimpleGenericMetaData[][] array)
+   {
+      this.array = array;
+   }
+   
 }
 

Modified: trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/support/TestMetaData.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/support/TestMetaData.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/support/TestMetaData.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -21,7 +21,6 @@
  */
 package org.jboss.test.server.profileservice.persistence.support;
 
-import java.io.Serializable;
 import java.util.List;
 import java.util.Map;
 
@@ -34,9 +33,10 @@
  * @version $Revision$
  */
 @ManagementObject
-public class TestMetaData implements Serializable
+public class TestMetaData
 {
 
+   /** The name. */
    String name;
    
    /** The primitive */

Modified: trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/test/AbstractPersistenceFormatTest.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/test/AbstractPersistenceFormatTest.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/test/AbstractPersistenceFormatTest.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -25,19 +25,17 @@
 
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
 
 import org.jboss.managed.api.ManagedObject;
 import org.jboss.managed.api.factory.ManagedObjectFactory;
 import org.jboss.metatype.api.types.MetaTypeFactory;
 import org.jboss.metatype.api.values.MetaValueFactory;
-import org.jboss.system.server.profileservice.persistence.ManagedObjectPeristenceHandler;
+import org.jboss.system.server.profileservice.persistence.DelegatingPersistencePlugin;
+import org.jboss.system.server.profileservice.persistence.ManagedObjectPersistencePlugin;
+import org.jboss.system.server.profileservice.persistence.ManagedObjectRecreationHelper;
 import org.jboss.system.server.profileservice.persistence.xml.PersistedManagedObject;
-import org.jboss.system.server.profileservice.repository.AbstractFileAttachmentsSerializer;
-import org.jboss.system.server.profileservice.repository.JAXBAttachmentSerializer;
 import org.jboss.test.BaseTestCase;
-import org.jboss.xb.binding.Unmarshaller;
-import org.jboss.xb.binding.UnmarshallerFactory;
-import org.jboss.xb.binding.sunday.unmarshalling.DefaultSchemaResolver;
 
 /**
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
@@ -47,19 +45,23 @@
 {
 
    /** The managed object factory */
-   private ManagedObjectFactory managedObjectFactory = ManagedObjectFactory.getInstance();
+   private static final ManagedObjectFactory managedObjectFactory = ManagedObjectFactory.getInstance();
    
+   /** A helper. */
+   private static final ManagedObjectRecreationHelper helper;
+   
    /** The meta value factory */
    private MetaValueFactory metaValueFactory = MetaValueFactory.getInstance();
    
    /** The meta type factory */
    private MetaTypeFactory metaTypeFactory = MetaTypeFactory.getInstance();
    
-   protected static final DefaultSchemaResolver resolver = new DefaultSchemaResolver();
+   /** The persistence plugin. */
+   private DelegatingPersistencePlugin plugin = new DelegatingPersistencePlugin(helper);
    
    static
    {
-      resolver.addClassBinding("urn:org:jboss:profileservice:persistence:managed-object:1.0", PersistedManagedObject.class);
+      helper = new ManagedObjectRecreationHelper(managedObjectFactory);
    }
    
    public AbstractPersistenceFormatTest(String name)
@@ -67,9 +69,14 @@
       super(name);
    }
 
+   protected ManagedObjectPersistencePlugin getPersistencePlugin()
+   {
+      return this.plugin;
+   }
+   
    protected ManagedObjectFactory getMOF()
    {
-      return this.managedObjectFactory;
+      return managedObjectFactory;
    }
    
    protected MetaValueFactory getMVF()
@@ -87,82 +94,9 @@
       return getMOF().initManagedObject(o, null);
    }
    
-   protected AbstractFileAttachmentsSerializer getAttachmentSerializer() throws Exception
-   {
-      return getAttachmentSerializer(false);
-   }
-   
-   protected AbstractFileAttachmentsSerializer getAttachmentSerializer(boolean logToSystemOut) throws Exception
-   {
-      File tempFile = File.createTempFile(getName(), null);
-      return createSerializer(tempFile, logToSystemOut);
-   }
-
-   /**
-    * Create the attachment Serializer.
-    * Use a tempFile for storing the Xml.
-    * 
-    * @param tempFile the temp File
-    * @return a AttachmentSerializer.
-    * @throws Exception
-    */
-   protected AbstractFileAttachmentsSerializer createSerializer(File tempFile) throws Exception
-   {
-      return createSerializer(tempFile, false);
-   }
-   
-   protected AbstractFileAttachmentsSerializer createSerializer(final File tempFile, final boolean logToSystemOut) throws Exception
-   {
-      return new TempAttachmentSerializer(tempFile);
-   }
-   
-   private class TempAttachmentSerializer extends JAXBAttachmentSerializer
-   {
-      public TempAttachmentSerializer(File tempFile)
-      {
-         super(tempFile);
-      }
-      
-//      @Override
-//      protected <T> T loadAttachment(File attachmentsStore, Class<T> expected) throws Exception
-//      {
-//         Unmarshaller u = UnmarshallerFactory.newInstance().newUnmarshaller();
-//         JBossXBBuilder builder = new JBossXBBuilder();
-//         SchemaBinding binding = builder.build(expected);
-//         return (T) u.unmarshal(attachmentsStore.getAbsolutePath(), binding); 
-//      }
-      
-      @Override
-      protected void saveAttachment(File attachmentsStore, Object attachment) throws Exception
-      {
-         log.trace("saveAttachments, attachmentsStore="+attachmentsStore+ ", attachment="+attachment);
-         JAXBContext ctx = JAXBContext.newInstance(attachment.getClass());
-         Marshaller marshaller = ctx.createMarshaller();
-         marshaller.setProperty("jaxb.formatted.output", Boolean.TRUE);
-         marshaller.marshal(attachment, attachmentsStore);
-         marshaller.marshal(attachment, System.out);
-      }
-      
-      @Override
-      protected File getAttachmentPath(String baseName)
-      {
-         // Return the temp file
-         return getAttachmentsStoreDir();
-      }
-   }
-   
    protected PersistedManagedObject restore(ManagedObject mo) throws Exception
    {
-      ManagedObjectPeristenceHandler persistence = new ManagedObjectPeristenceHandler();
-      return restore(mo, persistence);
-   }
-   
-   protected PersistedManagedObject restore(ManagedObject mo, ManagedObjectPeristenceHandler persistence) throws Exception
-   {
-      PersistedManagedObject moElement = new PersistedManagedObject();
-
-      // Process
-      persistence.processManagedObject(moElement, mo);
+      PersistedManagedObject moElement = plugin.createPersistedManagedObject(mo);
       
       File file = File.createTempFile("test", null);
       serialize(moElement, file);
@@ -180,8 +114,21 @@
    
    protected PersistedManagedObject deserialize(File file) throws Exception
    {
-      Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
-      return (PersistedManagedObject) unmarshaller.unmarshal(file.toURL().openStream(), resolver);
+      JAXBContext ctx = JAXBContext.newInstance(PersistedManagedObject.class);
+      Unmarshaller un = ctx.createUnmarshaller();
+      return (PersistedManagedObject) un.unmarshal(file);
    }
+   
+   protected ManagedObject update(Object attachment, PersistedManagedObject moElement)
+   {
+      ManagedObject mo = getMOF().initManagedObject(attachment, null);
+      return update(mo, moElement);
+   }
+   
+   protected ManagedObject update(ManagedObject mo, PersistedManagedObject persisted)
+   {
+      return getPersistencePlugin().updateManagedObject(persisted, mo);
+   }
+   
 }
 

Modified: trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/test/ArrayValueUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/test/ArrayValueUnitTestCase.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/test/ArrayValueUnitTestCase.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -25,7 +25,6 @@
 
 import org.jboss.managed.api.ManagedObject;
 import org.jboss.metatype.api.values.ArrayValue;
-import org.jboss.system.server.profileservice.persistence.ManagedGenericOverrideHandler;
 import org.jboss.system.server.profileservice.persistence.xml.PersistedManagedObject;
 import org.jboss.test.server.profileservice.persistence.support.SimpleArrayMetaData;
 
@@ -49,10 +48,8 @@
       PersistedManagedObject moElement = restore(mo);
       
       assertNotNull(moElement);
+      ManagedObject restored = update(new SimpleArrayMetaData(), moElement);
       
-      ManagedGenericOverrideHandler handler = new ManagedGenericOverrideHandler();
-      ManagedObject restored = handler.update(new SimpleArrayMetaData(), moElement);
-      
       assertNotNull(restored.getProperties());
       assertEquals(3, restored.getProperties().size());
       

Modified: trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/test/BasicPersistenceFormatUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/test/BasicPersistenceFormatUnitTestCase.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/test/BasicPersistenceFormatUnitTestCase.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -36,7 +36,6 @@
 import org.jboss.metatype.api.values.MetaValue;
 import org.jboss.metatype.api.values.SimpleValue;
 import org.jboss.metatype.api.values.SimpleValueSupport;
-import org.jboss.system.server.profileservice.persistence.ManagedGenericOverrideHandler;
 import org.jboss.system.server.profileservice.persistence.xml.PersistedManagedObject;
 import org.jboss.test.server.profileservice.persistence.support.PrimitiveMetaData;
 import org.jboss.test.server.profileservice.persistence.support.TestMetaData;
@@ -50,7 +49,6 @@
 
    public BasicPersistenceFormatUnitTestCase(String name)
    {
-      // FIXME SimplePersistenceFormatUnitTestCase constructor
       super(name);
    }
    public void testPrimitive() throws Throwable
@@ -72,8 +70,7 @@
       PersistedManagedObject restored = restore(mo);
       assertNotNull(restored);
       
-      ManagedGenericOverrideHandler handler = new ManagedGenericOverrideHandler();
-      mo = handler.update(createPrimitive(), restored);
+      mo = update(new PrimitiveMetaData(), restored);
       
       assertEquals("newName", getMVF().unwrap(mo.getProperty("name").getValue()));
       SimpleValue integer = (SimpleValue) mo.getProperty("integer").getValue();
@@ -112,9 +109,8 @@
       PersistedManagedObject restored = restore(mo);
       assertNotNull(restored);
       
-      // Create again
-      ManagedGenericOverrideHandler handler = new ManagedGenericOverrideHandler();
-      mo = handler.update(createTestMetaData(), restored);
+      // Create empty
+      mo = update(new TestMetaData(), restored);
       
       p = mo.getProperty("primitive");
       nested = (CompositeValue) p.getValue();
@@ -148,8 +144,7 @@
       PersistedManagedObject restored = restore(mo);
       assertNotNull(restored);
       
-      ManagedGenericOverrideHandler handler = new ManagedGenericOverrideHandler();
-      mo = handler.update(createTestMetaData(), restored);
+      mo = update(new TestMetaData(), restored);
       
       p = mo.getProperty("testMap");
       assertNotNull(p);
@@ -180,8 +175,7 @@
       assertNotNull(restored);
       
       //
-      ManagedGenericOverrideHandler handler = new ManagedGenericOverrideHandler();
-      mo = handler.update(createTestMetaData(), restored);
+      mo = update(new TestMetaData(), restored);
       
       p = mo.getProperty("charArray");
       assertNotNull(p);

Modified: trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/test/CollectionValueUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/test/CollectionValueUnitTestCase.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/test/CollectionValueUnitTestCase.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -25,7 +25,6 @@
 import java.util.List;
 
 import org.jboss.managed.api.ManagedObject;
-import org.jboss.system.server.profileservice.persistence.ManagedGenericOverrideHandler;
 import org.jboss.system.server.profileservice.persistence.xml.PersistedManagedObject;
 import org.jboss.test.server.profileservice.persistence.support.CollectionMetaData;
 
@@ -47,8 +46,7 @@
       PersistedManagedObject moElement = restore(mo);
       assertNotNull(moElement);
       
-      ManagedGenericOverrideHandler handler = new ManagedGenericOverrideHandler();
-      ManagedObject restored = handler.update(createMetaData(), moElement);
+      ManagedObject restored = update(new CollectionMetaData(), moElement);
       
       assertNotNull(restored);
 

Modified: trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/test/GenericValueUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/test/GenericValueUnitTestCase.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/test/GenericValueUnitTestCase.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -28,7 +28,6 @@
 import org.jboss.metatype.api.values.CollectionValue;
 import org.jboss.metatype.api.values.GenericValue;
 import org.jboss.metatype.api.values.SimpleValueSupport;
-import org.jboss.system.server.profileservice.persistence.ManagedGenericOverrideHandler;
 import org.jboss.system.server.profileservice.persistence.xml.PersistedManagedObject;
 import org.jboss.test.server.profileservice.persistence.support.GenericSupportMetaData;
 import org.jboss.test.server.profileservice.persistence.support.SimpleGenericMetaData;
@@ -47,21 +46,20 @@
 
    public void test() throws Throwable
    {
-
       ManagedObject mo = createTestMO();
 
       CollectionValue collection = (CollectionValue) mo.getProperty("list").getValue();
       ManagedObject child2 = (ManagedObject) ((GenericValue) collection.getElements()[1]).getValue();
       child2.getProperty("string").setValue(SimpleValueSupport.wrap("changedName"));
-
+      // TODO test generic array
+      
       PersistedManagedObject moElement = restore(mo);
 
-      ManagedGenericOverrideHandler handler = new ManagedGenericOverrideHandler();
-      ManagedObject restored = handler.update(createTestMetaData(), moElement);
+      ManagedObject restored = update(new GenericSupportMetaData(), moElement);
 
       GenericSupportMetaData md = (GenericSupportMetaData) restored.getAttachment();
       assertNotNull(md);
-
+      
       SimpleGenericMetaData child = md.getList().get(1);
       assertEquals(child.getString(), "changedName");
    }
@@ -87,7 +85,17 @@
 
       return metaData;
    }
+   
+   protected SimpleGenericMetaData[][] createArray()
+   {
 
+      SimpleGenericMetaData child1 = createSImple("array11", 11, null);
+      SimpleGenericMetaData child2 = createSImple("array12", 12, null);
+      SimpleGenericMetaData child3 = createSImple("array21", 21, null);
+      SimpleGenericMetaData child4 = createSImple("array22", 22, null);      
+      return new SimpleGenericMetaData[][] {{child1, child2}, {child3, child4}};
+   }
+
    private SimpleGenericMetaData createSImple(String string, int integer, SimpleGenericMetaData child)
    {
       return new SimpleGenericMetaData(string, integer, child);

Modified: trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/test/MapCompositeUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/test/MapCompositeUnitTestCase.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/test/MapCompositeUnitTestCase.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -27,7 +27,6 @@
 import org.jboss.managed.api.ManagedObject;
 import org.jboss.managed.api.ManagedProperty;
 import org.jboss.metatype.api.values.MapCompositeValueSupport;
-import org.jboss.system.server.profileservice.persistence.ManagedGenericOverrideHandler;
 import org.jboss.system.server.profileservice.persistence.xml.PersistedManagedObject;
 import org.jboss.test.server.profileservice.persistence.support.SimpleStringMapMetaData;
 
@@ -58,9 +57,10 @@
       PersistedManagedObject moElement = restore(mo);
       assertNotNull(moElement);
       
-      ManagedGenericOverrideHandler handler = new ManagedGenericOverrideHandler();
-      ManagedObject restored = handler.update(createTestMetaData(), moElement);
+      ManagedObject restored = update(new SimpleStringMapMetaData(), moElement);
       assertNotNull(restored);
+      SimpleStringMapMetaData metadata = (SimpleStringMapMetaData) restored.getAttachment();
+      assertTrue(metadata.getMap().equals(initMap()));
    }
    
    protected SimpleStringMapMetaData createTestMetaData()

Modified: trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/test/ObjectNameUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/test/ObjectNameUnitTestCase.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/test/ObjectNameUnitTestCase.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -26,7 +26,7 @@
 import org.jboss.managed.api.ManagedObject;
 import org.jboss.managed.api.ManagedProperty;
 import org.jboss.metatype.api.values.CompositeValue;
-import org.jboss.system.server.profileservice.persistence.ManagedGenericOverrideHandler;
+import org.jboss.metatype.api.values.PropertiesMetaValue;
 import org.jboss.system.server.profileservice.persistence.xml.PersistedCompositeValue;
 import org.jboss.system.server.profileservice.persistence.xml.PersistedManagedObject;
 import org.jboss.system.server.profileservice.persistence.xml.PersistedPropertiesValue;
@@ -54,6 +54,8 @@
       ManagedProperty p = mo.getProperty("name");
       CompositeValue c = (CompositeValue) p.getValue();
       assertNotNull(c);
+      PropertiesMetaValue properties = (PropertiesMetaValue) c.get("keyPropertyList");
+      properties.put("v", "value5");
 
       // Assert xml information
       PersistedManagedObject restoredElement = restore(mo);
@@ -81,9 +83,10 @@
       assertTrue(po.getValue() instanceof PersistedSimpleValue);
       
       //
-      ManagedGenericOverrideHandler handler = new ManagedGenericOverrideHandler();
-      ManagedObject restored = handler.update(createMD(), restoredElement);
+      ManagedObject restored = update(new ObjectNameMetaData(), restoredElement);
       assertNotNull(restored);
+      ObjectNameMetaData metaData = (ObjectNameMetaData) restored.getAttachment();
+      assertEquals(createObjectName("value5"), metaData.getName());
 
    }
    

Modified: trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/test/TableValueUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/test/TableValueUnitTestCase.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/test/TableValueUnitTestCase.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -33,7 +33,6 @@
 import org.jboss.metatype.api.values.SimpleValue;
 import org.jboss.metatype.api.values.SimpleValueSupport;
 import org.jboss.metatype.api.values.TableValue;
-import org.jboss.system.server.profileservice.persistence.ManagedGenericOverrideHandler;
 import org.jboss.system.server.profileservice.persistence.xml.PersistedManagedObject;
 import org.jboss.test.server.profileservice.persistence.support.SimpleTableMetaData;
 
@@ -63,8 +62,7 @@
       assertNotNull(moElement.getProperties());
 
       // Recreate MO
-      ManagedGenericOverrideHandler handler = new ManagedGenericOverrideHandler();
-      ManagedObject restored = handler.update(createTestMetaData(), moElement);
+      ManagedObject restored = update(new SimpleTableMetaData(), moElement);
 
       // Assert
       ManagedProperty p = restored.getProperty("map");
@@ -75,6 +73,9 @@
       assertRow(table, 1, "one");
       assertRow(table, 2, "two");
       assertRow(table, 3, "three");
+      
+      SimpleTableMetaData metaData = (SimpleTableMetaData) restored.getAttachment();
+      assertTrue(metaData.getMap().equals(initMap()));
    }
    
    protected void assertRow(TableValue table, Serializable key, Serializable value)

Modified: trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/test/TestNestedPeristenceFormatUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/test/TestNestedPeristenceFormatUnitTestCase.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/test/TestNestedPeristenceFormatUnitTestCase.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -36,12 +36,9 @@
 import org.jboss.metatype.api.values.MetaValue;
 import org.jboss.metatype.api.values.SimpleValue;
 import org.jboss.metatype.api.values.SimpleValueSupport;
-import org.jboss.system.server.profileservice.persistence.ManagedGenericOverrideHandler;
-import org.jboss.system.server.profileservice.persistence.ManagedObjectPeristenceHandler;
 import org.jboss.system.server.profileservice.persistence.xml.PersistedCollectionValue;
 import org.jboss.system.server.profileservice.persistence.xml.PersistedGenericValue;
 import org.jboss.system.server.profileservice.persistence.xml.PersistedManagedObject;
-import org.jboss.system.server.profileservice.repository.AbstractFileAttachmentsSerializer;
 import org.jboss.test.server.profileservice.persistence.support.NestedTestMetaData;
 import org.jboss.test.server.profileservice.persistence.support.PrimitiveMetaData;
 import org.jboss.test.server.profileservice.persistence.support.TestMetaData;
@@ -103,8 +100,7 @@
       enableTrace("org.jboss.system.server.profileservice.persistence");
 
       // Recreate
-      ManagedGenericOverrideHandler handler = new ManagedGenericOverrideHandler();
-      mo = handler.update(createNestedTestMetaData(), restored);
+      mo = update(createNestedTestMetaData(), restored);
       
       deployment = getDeployment("ChangedName", mo); 
       assertNotNull("changed name deployment null", deployment);
@@ -162,21 +158,6 @@
       return null;
    }
    
-   protected PersistedManagedObject process(ManagedObject mo) throws Exception
-   {
-      // Create root;
-      PersistedManagedObject persisted = new PersistedManagedObject();
-      // Create xml elements
-      ManagedObjectPeristenceHandler handler = new ManagedObjectPeristenceHandler();
-      handler.processManagedObject(persisted, mo);
-
-      // Save
-      AbstractFileAttachmentsSerializer serializer = getAttachmentSerializer(true);
-      serializer.saveAttachment("test", persisted);
-      // Restore
-      return serializer.loadAttachment("test", PersistedManagedObject.class);
-   }
-   
    protected ManagedObject createNestedMO()
    {
       return createMO(createNestedTestMetaData());

Modified: trunk/system/src/tests/org/jboss/test/server/profileservice/support/MockAttachmentStore.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/server/profileservice/support/MockAttachmentStore.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/support/MockAttachmentStore.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -28,7 +28,11 @@
 import org.jboss.deployers.vfs.spi.client.VFSDeploymentFactory;
 import org.jboss.managed.api.ManagedComponent;
 import org.jboss.profileservice.spi.ProfileDeployment;
+import org.jboss.system.server.profileservice.attachments.AttachmentMetaData;
 import org.jboss.system.server.profileservice.attachments.AttachmentStore;
+import org.jboss.system.server.profileservice.attachments.RepositoryAttachmentMetaData;
+import org.jboss.system.server.profileservice.persistence.xml.PersistenceRoot;
+import org.jboss.virtual.VirtualFile;
 
 /**
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
@@ -44,6 +48,11 @@
       return null;
    }
 
+   public Deployment createDeployment(ProfileDeployment deployment) throws Exception
+   {
+      return loadDeploymentData(deployment);
+   }
+   
    public Deployment loadDeploymentData(ProfileDeployment deployment) throws Exception
    {
       if(deployment == null)
@@ -66,5 +75,29 @@
       // nothing
    }
 
+   public PersistenceRoot loadAttachment(VirtualFile deploymentCtx, AttachmentMetaData attachment) throws Exception
+   {
+      // FIXME loadAttachment
+      return null;
+   }
+
+   public RepositoryAttachmentMetaData loadMetaData(VirtualFile deploymentCtx) throws Exception
+   {
+      // FIXME loadMetaData
+      return null;
+   }
+
+   public void removeComponent(String ctx, ManagedComponent comp) throws Exception
+   {
+      // FIXME removeComponent
+      
+   }
+
+   public void updateDeployment(String ctx, ManagedComponent comp) throws Exception
+   {
+      // FIXME updateDeployment
+      
+   }
+
 }
 

Added: trunk/system-jmx/src/main/org/jboss/system/deployers/managed/ServiceDeploymentComponentMapper.java
===================================================================
--- trunk/system-jmx/src/main/org/jboss/system/deployers/managed/ServiceDeploymentComponentMapper.java	                        (rev 0)
+++ trunk/system-jmx/src/main/org/jboss/system/deployers/managed/ServiceDeploymentComponentMapper.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -0,0 +1,143 @@
+/*
+ * 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.system.deployers.managed;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+
+import org.jboss.logging.Logger;
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.system.metadata.ServiceDeployment;
+import org.jboss.system.metadata.ServiceMetaData;
+import org.jboss.system.server.profileservice.persistence.PersistenceFactory;
+import org.jboss.system.server.profileservice.persistence.component.AbstractComponentMapper;
+import org.jboss.system.server.profileservice.persistence.xml.PersistedComponent;
+
+/**
+ * The ServiceDeployment component mapper. This handles the ServiceMetaData
+ * components in a ServiceDeployment.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class ServiceDeploymentComponentMapper extends AbstractComponentMapper
+{
+   
+   /** The logger. */
+   private static final Logger log = Logger.getLogger(ServiceDeploymentComponentMapper.class);
+   
+   public ServiceDeploymentComponentMapper(PersistenceFactory persistenceFactory)
+   {
+      super(persistenceFactory);
+   }
+
+   @Override
+   protected void setComponentName(PersistedComponent component, ManagedObject mo)
+   {
+      ServiceMetaData md = (ServiceMetaData) mo.getAttachment();
+      String name = md.getObjectName().getCanonicalName();
+      component.setName(name);
+   }
+   
+   @Override
+   protected ManagedObject getComponent(Object attachment, PersistedComponent component, boolean create)
+   {
+      ServiceDeployment deployment = (ServiceDeployment) attachment;
+      ServiceMetaData service = null;
+      List<ServiceMetaData> services = deployment.getServices();
+      if(services == null)
+      {
+         services = new ArrayList<ServiceMetaData>();
+         deployment.setServices(services);
+      }
+      if(services != null && services.isEmpty() == false)
+      {
+         for(ServiceMetaData metaData : services)
+         {
+            if(metaData.getObjectName().getCanonicalName().equals(component.getOriginalName()))
+            {
+               service = metaData;
+               break;
+            }
+         }
+      }
+      if(service == null && create)
+      {
+         // Create a new empty service meta data
+         service = createEmptyServiceMetaData(component);
+         deployment.getServices().add(service);
+      }
+      if(service == null)
+      {
+         throw new IllegalStateException("could not find service with name " + component.getOriginalName());
+      }
+      return getMOF().initManagedObject(service, null);
+   }
+
+   @Override
+   protected void removeComponent(Object attachment, PersistedComponent component)
+   {
+      ServiceDeployment deployment = (ServiceDeployment) attachment;
+      List<ServiceMetaData> deploymentServices = deployment.getServices();
+      List<ServiceMetaData> services = new ArrayList<ServiceMetaData>();
+      if(deploymentServices != null && deploymentServices.isEmpty() == false)
+      {
+         for(ServiceMetaData metaData : deploymentServices)
+         {
+            // Ignore the removed bean
+            if(metaData.getObjectName().getCanonicalName().
+                  equals(component.getOriginalName()) == false)
+               services.add(metaData);
+         }
+      }
+      deployment.setServices(services);
+   }
+   
+   protected ServiceMetaData createEmptyServiceMetaData(PersistedComponent component)
+   {
+      ServiceMetaData service = new ServiceMetaData();
+      ObjectName objectName = null;
+      try
+      {
+         objectName = new ObjectName(component.getOriginalName());
+         service.setObjectName(objectName);
+      }
+      catch (MalformedObjectNameException e)
+      {
+         // TODO: this should not happen, but we might could just ignore this
+         // as the Persistence should restore the object name anyway
+         throw new RuntimeException("failed to create object name for component " + component, e);
+      }
+      log.debug("created service "+ component.getOriginalName());
+      return service;
+   }
+
+   public String getType()
+   {
+      return ServiceDeployment.class.getName();
+   }
+
+}
+

Modified: trunk/system-jmx/src/main/org/jboss/system/deployers/managed/ServiceMetaDataICF.java
===================================================================
--- trunk/system-jmx/src/main/org/jboss/system/deployers/managed/ServiceMetaDataICF.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/system-jmx/src/main/org/jboss/system/deployers/managed/ServiceMetaDataICF.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -21,6 +21,7 @@
  */
 package org.jboss.system.deployers.managed;
 
+import java.beans.PropertyEditor;
 import java.io.Serializable;
 import java.lang.reflect.Type;
 import java.util.HashMap;
@@ -52,6 +53,7 @@
 import org.jboss.system.metadata.ServiceTextValueMetaData;
 import org.jboss.system.metadata.ServiceValueContext;
 import org.jboss.system.metadata.ServiceValueMetaData;
+import org.jboss.util.propertyeditor.PropertyEditors;
 import org.w3c.dom.Element;
 
 /**
@@ -59,6 +61,7 @@
  * 
  * @author Scott.Stark at jboss.org
  * @author Dimitris.Andreadis at jboss.org
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
  * @version $Revision$
  */
 public class ServiceMetaDataICF implements InstanceClassFactory<ServiceMetaData>
@@ -149,6 +152,7 @@
 
       ClassLoader prevLoader = SecurityActions.getContextClassLoader();
       Object value = null;
+      MetaType metaType = property.getMetaType();
       MetaValue mvalue = null;
       ObjectName mbean = md.getObjectName();
       String attrName = null;
@@ -171,12 +175,11 @@
             }
          }
          // If the value is null, look to mbean for the value
-         if (value == null)
+         if (value == null && getMbeanServer() != null)
          {
             try
             {
-               if(getMbeanServer() != null)
-                  value = getMbeanServer().getAttribute(mbean, name);
+               value = getMbeanServer().getAttribute(mbean, name);
             }
             catch (AttributeNotFoundException e)
             {
@@ -207,16 +210,26 @@
             if (value instanceof ServiceTextValueMetaData)
             {
                ServiceTextValueMetaData text = (ServiceTextValueMetaData) value;
-               // TODO: cache this somehow
-               HashMap<String, MBeanAttributeInfo> attrs = ServiceConfigurator.getAttributeMap(mbeanServer, mbean);
-               MBeanAttributeInfo mbi = attrs.get(attrName);
-               ServiceValueContext svc = new ServiceValueContext(mbeanServer, controller, mbi, loader);
-               value = text.getValue(svc);
+               try
+               {
+                  // TODO: cache this somehow
+                  HashMap<String, MBeanAttributeInfo> attrs = ServiceConfigurator.getAttributeMap(mbeanServer, mbean);
+                  MBeanAttributeInfo mbi = attrs.get(attrName);
+                  ServiceValueContext svc = new ServiceValueContext(mbeanServer, controller, mbi, loader);
+                  value = text.getValue(svc);
+               }
+               catch(Exception e)
+               {
+                  // TODO: better way to determine if the bean was installed, as this does not make much sense
+                  PropertyEditor editor = PropertyEditors.getEditor(metaType.getTypeName());
+                  editor.setAsText(text.getText());
+                  value = editor.getValue();
+               }
             }
             else if (value instanceof ServiceDependencyValueMetaData)
             {
                ServiceDependencyValueMetaData depends = (ServiceDependencyValueMetaData) value;
-               value = depends.getDependency();
+               value = depends.getObjectName();
             }
             else if (value instanceof ServiceElementValueMetaData)
             {
@@ -304,7 +317,7 @@
             PropertyInfo propertyInfo = beanInfo.getProperty(name);
             plainValue = metaValueFactory.unwrap(value, propertyInfo.getType());
          }
-         
+
          if (attributeValue == null)
          {
             String aname = mapAttributeName(md, name);
@@ -312,16 +325,26 @@
             {
                ServiceAttributeMetaData attr = new ServiceAttributeMetaData();
                attr.setName(aname);
-               md.addAttribute(attr);
+               // Check if this is mapped to a Element
                if(mappedType != null && mappedType.equals(Element.class))
                {
                   attributeValue = new ServiceElementValueMetaData();
                }
-               else
-               {
-                  attributeValue = new ServiceTextValueMetaData("");
+               else if(plainValue != null)
+               {                 
+                  // Create a text value
+                  String textValue = String.valueOf(plainValue);
+                  // Don't create a empty value
+                  if(textValue.trim().length() > 0 )
+                     attributeValue = new ServiceTextValueMetaData(textValue);
                }
+               // Don't create a null serviceAttribute
+               if(attributeValue == null)
+                  return;
+               
+               // Add
                attr.setValue(attributeValue);
+               md.addAttribute(attr);
             }
          }
          if (attributeValue != null)
@@ -329,8 +352,9 @@
             // Unwrap the ServiceValueMetaData types
             if (attributeValue instanceof ServiceTextValueMetaData)
             {
+               String textValue = plainValue != null ? String.valueOf(plainValue) : null; 
                ServiceTextValueMetaData text = (ServiceTextValueMetaData) attributeValue;
-               text.setText(String.valueOf(plainValue));
+               text.setText(textValue);
             }
             else if (attributeValue instanceof ServiceElementValueMetaData)
             {

Modified: trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/support/SimpleAnnotatedBean.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/support/SimpleAnnotatedBean.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/support/SimpleAnnotatedBean.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -21,13 +21,14 @@
  */ 
 package org.jboss.test.profileservice.persistenceformat.support;
 
+import org.jboss.managed.api.annotation.ManagementObject;
 import org.jboss.managed.api.annotation.ManagementProperty;
 
 /**
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
  * @version $Revision$
  */
-//@ManagementObject(name = "SimpleBean")
+ at ManagementObject(name = "SimpleBean")
 public class SimpleAnnotatedBean
 {
    

Added: trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/support/TestMgtComponentImpl.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/support/TestMgtComponentImpl.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/support/TestMgtComponentImpl.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -0,0 +1,90 @@
+/*
+ * 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.test.profileservice.persistenceformat.support;
+
+import java.io.Serializable;
+import java.lang.annotation.Annotation;
+import java.util.Map;
+
+import org.jboss.managed.api.ComponentType;
+import org.jboss.managed.api.ManagedCommon;
+import org.jboss.managed.api.ManagedComponent;
+import org.jboss.managed.api.ManagedDeployment;
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.api.RunState;
+import org.jboss.managed.plugins.DelegateManagedCommonImpl;
+
+/**
+ * 
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class TestMgtComponentImpl extends DelegateManagedCommonImpl
+   implements ManagedComponent, Serializable
+{
+
+   private ManagedObject mo;
+
+   public TestMgtComponentImpl(ManagedObject delegate)
+   {
+      super(delegate);
+      this.mo = delegate;
+   }
+
+   @Override
+   public ManagedCommon getParent()
+   {
+      return mo;
+   }
+
+   public Map<String, Annotation> getAnnotations()
+   {
+      // FIXME getAnnotations
+      return null;
+   }
+
+   public ManagedDeployment getDeployment()
+   {
+      // FIXME getDeployment
+      return null;
+   }
+
+   public RunState getRunState()
+   {
+      // FIXME getRunState
+      return null;
+   }
+
+   public ComponentType getType()
+   {
+      // FIXME getType
+      return null;
+   }
+
+   public boolean update()
+   {
+      // FIXME update
+      return false;
+   }
+
+}

Modified: trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/test/AbstractPersistenceFormatTest.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/test/AbstractPersistenceFormatTest.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/test/AbstractPersistenceFormatTest.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -25,16 +25,19 @@
 
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
 
+import org.jboss.managed.api.ManagedComponent;
 import org.jboss.managed.api.ManagedObject;
 import org.jboss.managed.api.factory.ManagedObjectFactory;
+import org.jboss.managed.plugins.factory.AbstractManagedObjectFactory;
 import org.jboss.metatype.api.values.MetaValueFactory;
-import org.jboss.system.server.profileservice.persistence.ManagedObjectPeristenceHandler;
-import org.jboss.system.server.profileservice.persistence.xml.PersistedManagedObject;
+import org.jboss.system.server.profileservice.persistence.AbstractPersistenceFactory;
+import org.jboss.system.server.profileservice.persistence.PersistenceFactory;
+import org.jboss.system.server.profileservice.persistence.component.ComponentMapper;
+import org.jboss.system.server.profileservice.persistence.xml.PersistenceRoot;
 import org.jboss.test.JBossTestCase;
-import org.jboss.xb.binding.Unmarshaller;
-import org.jboss.xb.binding.UnmarshallerFactory;
-import org.jboss.xb.binding.sunday.unmarshalling.DefaultSchemaResolver;
+import org.jboss.test.profileservice.persistenceformat.support.TestMgtComponentImpl;
 
 /**
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
@@ -49,22 +52,17 @@
    /** The meta value factory */
    private MetaValueFactory metaValueFactory = MetaValueFactory.getInstance();
    
-   /** The schema resolver */
-   protected static final DefaultSchemaResolver resolver = new DefaultSchemaResolver();
+   /** The persistence factory. */
+   private AbstractPersistenceFactory persistenceFactory = new AbstractPersistenceFactory();
    
-   static
-   {
-      resolver.addClassBinding("urn:org:jboss:profileservice:persistence:managed-object:1.0", PersistedManagedObject.class);
-   }
-   
    public AbstractPersistenceFormatTest(String name)
    {
       super(name);
    }
 
-   protected ManagedObjectFactory getMOF()
+   protected AbstractManagedObjectFactory getMOF()
    {
-      return this.managedObjectFactory;
+      return (AbstractManagedObjectFactory) this.managedObjectFactory;
    }
    
    protected MetaValueFactory getMVF()
@@ -72,37 +70,53 @@
       return this.metaValueFactory;
    }
    
+   protected PersistenceFactory getPersistenceFactory()
+   {
+      return persistenceFactory;
+   }
+   
    protected ManagedObject initManagedObject(Object o)
    {
       return getMOF().initManagedObject(o, null);
    }
    
-   protected PersistedManagedObject createPersisted(ManagedObject mo)
+   protected ManagedComponent createComponent(ManagedObject mo)
    {
-      ManagedObjectPeristenceHandler persistence = new ManagedObjectPeristenceHandler();
-      return persistence.createPersistenceMetaData(mo);      
+      return new TestMgtComponentImpl(mo);
    }
    
-   protected PersistedManagedObject restore(ManagedObject mo) throws Exception
+   protected void addComponentMapper(ComponentMapper mapper)
    {
-      File file = File.createTempFile("test", null);
-      serialize(createPersisted(mo), file);
-      return deserialize(file);
+      persistenceFactory.addComponentMapper(mapper);
    }
    
-   protected void serialize(PersistedManagedObject moElement, File file) throws Exception
+   protected PersistenceRoot updateComponent(ManagedObject parent, ManagedComponent component) throws Exception
    {
-      JAXBContext ctx = JAXBContext.newInstance(PersistedManagedObject.class);
+      PersistenceRoot root = getPersistenceFactory().updateComponent(parent, component);
+      return restore(root);
+   }
+   
+   protected PersistenceRoot restore(PersistenceRoot root) throws Exception
+   {
+      File f = File.createTempFile("test", null);
+      serialize(root, f);
+      return deserialize(f);      
+   }
+   
+   protected void serialize(PersistenceRoot moElement, File file) throws Exception
+   {
+      JAXBContext ctx = JAXBContext.newInstance(PersistenceRoot.class);
       Marshaller marshaller = ctx.createMarshaller();
       marshaller.setProperty("jaxb.formatted.output", Boolean.TRUE);
       marshaller.marshal(moElement, file);
       marshaller.marshal(moElement, System.out);
    }
    
-   protected PersistedManagedObject deserialize(File file) throws Exception
+   protected PersistenceRoot deserialize(File file) throws Exception
    {
-      Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
-      return (PersistedManagedObject) unmarshaller.unmarshal(file.toURL().openStream(), resolver);
+      JAXBContext ctx = JAXBContext.newInstance(PersistenceRoot.class);
+      Unmarshaller unmarshaller = ctx.createUnmarshaller();
+      return (PersistenceRoot) unmarshaller.unmarshal(file);
    }
 }
 

Modified: trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/test/JBossBeansPersistenceFormatTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/test/JBossBeansPersistenceFormatTestCase.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/test/JBossBeansPersistenceFormatTestCase.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -21,21 +21,30 @@
  */ 
 package org.jboss.test.profileservice.persistenceformat.test;
 
-import java.util.Set;
+import java.util.ArrayList;
+import java.util.List;
 
 import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.BeanMetaDataFactory;
 import org.jboss.beans.metadata.spi.PropertyMetaData;
 import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
 import org.jboss.deployers.plugins.managed.BeanMetaDataICF;
+import org.jboss.deployers.plugins.managed.KernelDeploymentComponentMapper;
 import org.jboss.kernel.Kernel;
 import org.jboss.kernel.plugins.bootstrap.basic.BasicBootstrap;
+import org.jboss.kernel.plugins.deployment.AbstractKernelDeployment;
 import org.jboss.kernel.spi.dependency.KernelController;
 import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.kernel.spi.deployment.KernelDeployment;
+import org.jboss.managed.api.ManagedComponent;
 import org.jboss.managed.api.ManagedObject;
 import org.jboss.managed.plugins.factory.AbstractManagedObjectFactory;
 import org.jboss.metadata.spi.MetaData;
-import org.jboss.system.server.profileservice.persistence.ManagedGenericOverrideHandler;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.system.server.profileservice.persistence.PersistenceFactory;
+import org.jboss.system.server.profileservice.persistence.xml.PersistedComponent;
 import org.jboss.system.server.profileservice.persistence.xml.PersistedManagedObject;
+import org.jboss.system.server.profileservice.persistence.xml.PersistenceRoot;
 import org.jboss.test.profileservice.persistenceformat.support.SimpleAnnotatedBean;
 
 /**
@@ -53,14 +62,16 @@
    
    /** The controller. */
    private KernelController controller;
+   
+   /** Some random bean names. */
+   private final static String[] BEAN_NAMES = new String[] {"TestBean", "SimpleAnnotatedBean", "OtherBean"};
 
    public JBossBeansPersistenceFormatTestCase(String name)
    {
       super(name);
    }
-
    
-   protected void setUp() throws Exception
+   public void setUp() throws Exception
    {
       super.setUp();
       // Bootstrap
@@ -70,65 +81,151 @@
       kernel = bootstrap.getKernel();
       //
       controller = kernel.getController();
-   }
-   
-   protected BeanMetaData installBean() throws Throwable
-   {
-      BeanMetaDataBuilder builder = getSimpleBeanMetaDataBuilder();
-      // Add a value
-      builder.addPropertyMetaData("stringProperty", "testValue");
-      // Install
-      controller.install(builder.getBeanMetaData());
       
-      return builder.getBeanMetaData();
-   }
-   
-   public void test() throws Throwable
-   {
-      // InstallBean
-      BeanMetaData md = installBean();
-      
       // setUp beanICF
       BeanMetaDataICF beanICF = new BeanMetaDataICF();
       beanICF.setController(controller);
-      beanICF.setDelegateICF(((AbstractManagedObjectFactory)getMOF()).getDefaultInstanceFactory());
+      beanICF.setDelegateICF(((AbstractManagedObjectFactory) 
+            getMOF()).getDefaultInstanceFactory());
       
       getMOF().addInstanceClassFactory(beanICF);
+      addComponentMapper(new TestMapper(getPersistenceFactory()));  
+   }
+   
+   public void testUpdateComponent() throws Throwable
+   {
+      // Install
+      KernelDeployment deployment = createKernelDeployment(BEAN_NAMES);
+      // install
+      installDeployment(deployment);
       
-      KernelControllerContext ctx = (KernelControllerContext) controller.getInstalledContext("SimpleAnnotatedBean");
-      assertNotNull(ctx);
+      // Create the managed objects
+      ManagedObject deploymentMO = getMOF().initManagedObject(deployment, null);
+      ManagedObject mo = getBeanMO("SimpleAnnotatedBean");
+      assertNotNull("null mo", mo);
+      assertTrue(mo.getAttachment() instanceof BeanMetaData);
+      ManagedComponent component = createComponent(mo);
+      assertNotNull(component);
+      assertEquals(component.getAttachmentName(), SimpleAnnotatedBean.class.getName());
+
+      // Change value
+      component.getProperty("stringProperty").setValue(SimpleValueSupport.wrap("changedTestValue"));
       
-      MetaData metaData = kernel.getMetaDataRepository().getMetaData(ctx);
-      assertNotNull(metaData);
-      
-      ManagedObject mo = getMOF().initManagedObject(md, null, metaData, "SimpleAnnotatedBean", null);
-      assertNotNull(mo);
+      PersistenceRoot root = updateComponent(deploymentMO, component);
+      assertNotNull(root);
 
-      PersistedManagedObject moElement = restore(mo);
-      assertNotNull(moElement);
-
       // Uninstall for offline attachment persistence
-      controller.uninstall("SimpleAnnotatedBean");
+      uninstallDeployment(deployment);
       
-      ManagedGenericOverrideHandler override = new ManagedGenericOverrideHandler();
-      // Try to restore the information without the installed bean      
-      mo = getMOF().initManagedObject(getSimpleBeanMetaDataBuilder().getBeanMetaData(), null);
+      // Recreate the kernel deployment
+      deployment = createKernelDeployment(BEAN_NAMES);
+      getPersistenceFactory().restorePersistenceRoot(root, deployment, null);
+      
+      // check bean meta data
+      BeanMetaData bmd = getBeanMetaData(deployment, "SimpleAnnotatedBean");
+      boolean sawProperty = false;
+      for(PropertyMetaData prop : bmd.getProperties())
+      {
+         if(prop.getName().equals("stringProperty"))
+         {
+            assertEquals("changedTestValue", prop.getValue().getUnderlyingValue());
+            sawProperty = true;
+         }
+      }
+      assertTrue(sawProperty);
+      
+      // install
+      installDeployment(deployment);
+      mo = getBeanMO("SimpleAnnotatedBean");
       assertNotNull(mo);
       
-      override.updateManagedObject(mo, moElement, mo.getAttachment());
-      Set<PropertyMetaData> properties = ((BeanMetaData)mo.getAttachment()).getProperties();
-      assertNotNull(properties);
-      // TODO
-      assertEquals(1, properties.size());
+      assertEquals(SimpleValueSupport.wrap("changedTestValue"),
+            mo.getProperty("stringProperty").getValue());
+
    }
    
-   protected BeanMetaDataBuilder getSimpleBeanMetaDataBuilder()
+   protected ManagedObject getBeanMO(String name)
    {
-      BeanMetaDataBuilder b = BeanMetaDataBuilder.createBuilder("SimpleAnnotatedBean", SimpleAnnotatedBean.class.getName());
-      b.addAnnotation("@org.jboss.managed.api.annotation.ManagementObject(name=\"simpleBean\")");
-      return b;
+      KernelControllerContext ctx = (KernelControllerContext) controller.getInstalledContext(name);
+      assertNotNull(ctx);
+      BeanMetaData bmd = ctx.getBeanMetaData();
+      assertNotNull("null BeanMetaData", bmd);
+      MetaData metaData = kernel.getMetaDataRepository().getMetaData(ctx);
+      assertNotNull("null MetaData", metaData);
+      return getMOF().initManagedObject(bmd, null, metaData, name, null);
    }
    
+   protected void installDeployment(KernelDeployment deployment) throws Throwable
+   {
+      for(BeanMetaDataFactory factory : deployment.getBeanFactories())
+      {
+         for(BeanMetaData bmd : factory.getBeans())
+            controller.install(bmd);
+      }
+   }
    
+   protected void uninstallDeployment(KernelDeployment deployment)
+   {
+      for(BeanMetaDataFactory factory : deployment.getBeanFactories())
+      {
+         for(BeanMetaData bmd : factory.getBeans())
+            controller.uninstall(bmd.getName());
+      }      
+   }
+   
+   protected BeanMetaData getBeanMetaData(KernelDeployment deployment, String name)
+   {
+      BeanMetaData bmd = null;
+      for(BeanMetaDataFactory factory : deployment.getBeanFactories())
+      {
+         for(BeanMetaData beanMetaData : factory.getBeans())
+         {
+            if(beanMetaData.getName().equals(name))
+            {
+               bmd = beanMetaData;
+               break;
+            }
+         }
+      }
+      assertNotNull("null beanMetaData for " + name, bmd);
+      return bmd;
+   }
+   
+   protected KernelDeployment createKernelDeployment(String... beans)
+   {
+      AbstractKernelDeployment deployment = new AbstractKernelDeployment();
+      List<BeanMetaDataFactory> beanFactories = new ArrayList<BeanMetaDataFactory>();
+      for(String beanName : beans)
+         beanFactories.add(createBeanDataFactory(beanName));
+      deployment.setBeanFactories(beanFactories);
+      return deployment;
+   }
+   
+   protected BeanMetaDataFactory createBeanDataFactory(String name)
+   {
+      BeanMetaDataBuilder b = BeanMetaDataBuilder.createBuilder(name, SimpleAnnotatedBean.class.getName());
+      b.addAnnotation("@org.jboss.managed.api.annotation.ManagementObject(name=\""+ name +"\")");
+      b.addPropertyMetaData("stringProperty", "test" + name);
+      return b.asBeanMetaDataFactory();
+   }
+ 
+   private static final class TestMapper extends KernelDeploymentComponentMapper
+   {
+      public TestMapper(PersistenceFactory persistenceFactory)
+      {
+         super(persistenceFactory);
+      }
+      
+      protected PersistedComponent createComponent(Object attachment, ManagedComponent component)
+      {
+         // Note: this is using the TestMgtComponentImpl to get the MO
+         ManagedObject mo = (ManagedObject) component.getParent();
+         PersistedManagedObject persisted = getPersistencePlugin().createPersistedManagedObject(mo);
+         PersistedComponent persistedComponent = new PersistedComponent(persisted);
+         setComponentName(persistedComponent, mo);
+         return persistedComponent;
+      }
+   }
+   
 }
 

Modified: trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/test/JBossServicePersistenceFormatTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/test/JBossServicePersistenceFormatTestCase.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/test/JBossServicePersistenceFormatTestCase.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -22,15 +22,18 @@
 package org.jboss.test.profileservice.persistenceformat.test;
 
 import java.io.File;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.Marshaller;
 import javax.xml.parsers.DocumentBuilderFactory;
 
+import org.jboss.managed.api.ManagedComponent;
+import org.jboss.managed.api.ManagedObject;
 import org.jboss.mx.loading.LoaderRepositoryFactory.LoaderRepositoryConfig;
+import org.jboss.system.deployers.managed.ServiceDeploymentComponentMapper;
+import org.jboss.system.metadata.ServiceAttributeMetaData;
 import org.jboss.system.metadata.ServiceConstructorMetaData;
 import org.jboss.system.metadata.ServiceDependencyMetaData;
 import org.jboss.system.metadata.ServiceDeployment;
@@ -38,14 +41,20 @@
 import org.jboss.system.metadata.ServiceDeploymentParser;
 import org.jboss.system.metadata.ServiceMetaData;
 import org.jboss.system.metadata.ServiceMetaDataParser;
-import org.jboss.system.server.profileservice.repository.AbstractFileAttachmentsSerializer;
-import org.jboss.system.server.profileservice.repository.JAXBAttachmentSerializer;
+import org.jboss.system.metadata.ServiceValueMetaData;
+import org.jboss.system.server.profileservice.persistence.ManagedObjectPersistencePlugin;
+import org.jboss.system.server.profileservice.persistence.PersistenceFactory;
+import org.jboss.system.server.profileservice.persistence.xml.ModificationInfo;
+import org.jboss.system.server.profileservice.persistence.xml.PersistedComponent;
+import org.jboss.system.server.profileservice.persistence.xml.PersistedManagedObject;
+import org.jboss.system.server.profileservice.persistence.xml.PersistenceRoot;
 import org.w3c.dom.Document;
 
 /**
- * Testing the marshalling/unmarshalling with the JAXBAttachmentSerializer 
- * for ServiceDeployment (jboss-service.xml).
+ * Persistence test for ServiceMetaData components.
  * 
+ * TODO the ManagedObject view of ServiceMetaData needs to be completed. 
+ * 
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
  * @version $Revision$
  */
@@ -56,29 +65,75 @@
    {
       super(name);
    }
-
-   public void testJbossService() throws Exception
+   
+   
+   public void testServiceMetaData() throws Exception
    {
-      // Parse 
+      // Don't use the ServiceMetaDataICF - to be able to test plain
+      // ServiceMetaData without MOClass override... 
+      // getMOF().addInstanceClassFactory(new ServiceMetaDataICF());
+      
+      addComponentMapper(new TestMapper(getPersistenceFactory()));
+      
       ServiceDeployment deployment = parseJbossServiceXml("profileservice/persistence/jboss-service.xml");
-      assertNotNull(deployment);
-      // Create serializer
-      AbstractFileAttachmentsSerializer serializer = getAttachmentSerializer();
-      // Save
-      serializer.saveAttachment("test", deployment);
-      // Restore
-      ServiceDeployment restored = serializer.loadAttachment("test", ServiceDeployment.class);
-      assertNotNull(restored);
       
-      // Assert services
-      assertServices(deployment.getServices(), restored.getServices());
-      // loader repository
-      assertLoaderRepository(deployment.getLoaderRepositoryConfig(), restored.getLoaderRepositoryConfig());
-      // classpath
-      assertClassPaths(deployment.getClassPaths(), restored.getClassPaths());
+      // Manually create a persistence view
+      List<ServiceMetaData> services = deployment.getServices();
+      List<PersistedComponent> components = new ArrayList<PersistedComponent>();
+      ManagedObjectPersistencePlugin plugin = getPersistenceFactory().getPersistencePlugin();
+      for(ServiceMetaData md : deployment.getServices())
+      {
+         // Bypass the ServiceMetaDataICF...
+         ManagedObject mo = getMOF().initManagedObject(md, null); 
+         PersistedManagedObject persisted = plugin.createPersistedManagedObject(mo);
+         
+         // Fix the names, as we don't use the ServiceMetaDataICF
+         String name = md.getObjectName().getCanonicalName();
+         persisted.setName(name);
+         persisted.setOriginalName(name);
+         persisted.setModificationInfo(ModificationInfo.ADDED);
+         
+         components.add(new PersistedComponent(persisted));
+      }
+      
+      PersistenceRoot root = new PersistenceRoot();
+      root.setComponents(components);
+      root = restore(root);
+      
+      // Test if we can recreate a complete view, without
+      // requiring any previous service
+      deployment = new ServiceDeployment();
+      deployment.setServices(new ArrayList<ServiceMetaData>());      
+
+      getPersistenceFactory().restorePersistenceRoot(root, deployment, null);
+      
+      assertServices(services, deployment.getServices());
+      
    }
    
-   protected void assertServices(List<ServiceMetaData> original, List<ServiceMetaData> restored)
+//   
+//   public void testJbossService() throws Exception
+//   {
+//      // Parse 
+//      ServiceDeployment deployment = parseJbossServiceXml("profileservice/persistence/jboss-service.xml");
+//      assertNotNull(deployment);
+//      // Create serializer
+//      AbstractFileAttachmentsSerializer serializer = getAttachmentSerializer();
+//      // Save
+//      serializer.saveAttachment("test", deployment);
+//      // Restore
+//      ServiceDeployment restored = serializer.loadAttachment("test", ServiceDeployment.class);
+//      assertNotNull(restored);
+//      
+//      // Assert services
+//      assertServices(deployment.getServices(), restored.getServices());
+//      // loader repository
+//      assertLoaderRepository(deployment.getLoaderRepositoryConfig(), restored.getLoaderRepositoryConfig());
+//      // classpath
+//      assertClassPaths(deployment.getClassPaths(), restored.getClassPaths());
+//   }
+   
+   protected void assertServices(List<ServiceMetaData> original, List<ServiceMetaData> restored) throws Exception
    {
       assertNotNull(original);
       assertNotNull(restored);
@@ -98,7 +153,7 @@
       }
    }
    
-   protected void assertServiceMetaData(ServiceMetaData original, ServiceMetaData restored)
+   protected void assertServiceMetaData(ServiceMetaData original, ServiceMetaData restored) throws Exception
    {
       // Code
       assertEquals(original.getCode(), restored.getCode());
@@ -143,9 +198,58 @@
       {
          assertNull(restored.getDependencies());
       }
+      
+//      assertAttributes(original.getAttributes(), restored.getAttributes());
+      assertDependencies(original.getDependencies(), restored.getDependencies());
+      
    }
+   
+   protected void assertAttributes(List<ServiceAttributeMetaData> original, List<ServiceAttributeMetaData> restored)
+   {
+      if(original == null)
+      {
+         assertNull(restored);
+         return;
+      }
+      else
+      {
+         assertNotNull(restored);
+      }
+      
+      assertEquals(original.size(), restored.size());
+      if(original.isEmpty())
+         return;
+      
+      Map<String, ServiceAttributeMetaData> attributesMap = new HashMap<String, ServiceAttributeMetaData>();
+      for(ServiceAttributeMetaData attribute : restored)
+         attributesMap.put(attribute.getName(), attribute);
+      
+      for(ServiceAttributeMetaData attribute : original)
+         assertAttributeMetaData(attribute, attributesMap.get(attribute.getName()));
+   }
+   
+   protected void assertAttributeMetaData(ServiceAttributeMetaData original, ServiceAttributeMetaData restored)
+   {
+      assertNotNull(original);
+      assertNotNull(original.getName(), restored);
+      
+      if(original.getValue() == null)
+      {
+         assertNull(restored.getValue());
+         return;
+      }
+      else
+      {
+         assertNotNull(restored.getValue());
+      }
+      
+      ServiceValueMetaData value = original.getValue();
+      // TODO we need some MetaMapping for attributes
+      assertEquals(original.getName(), value.getClass().getName(), restored.getValue().getClass().getName());
+   }
+   
 
-   protected void assertServiceConstructor(ServiceConstructorMetaData original, ServiceConstructorMetaData restored)
+   protected void assertServiceConstructor(ServiceConstructorMetaData original, ServiceConstructorMetaData restored) throws Exception
    {
       if(original == null)
       {
@@ -161,9 +265,32 @@
       {
          assertNotNull(restored.getParams());
          assertEquals(original.getParams().length, restored.getParams().length);
+         assertEquals(original.getParams(), restored.getParams());
       }
+      if(original.getSignature() != null)
+      {
+         assertNotNull(restored.getSignature());
+         assertEquals(original.getParams().length, restored.getParams().length);
+         assertEquals(original.getSignature(), restored.getSignature());
+      }
    }
    
+   protected void assertDependencies(List<ServiceDependencyMetaData> original, List<ServiceDependencyMetaData> restored)
+   {
+      if(original == null)
+      {
+         assertNull(restored);
+         return;
+      }
+      else
+      {
+         assertNotNull(restored);
+      }
+         
+      assertEquals(original.size(), restored.size());
+      // TODO assertDependency
+   }
+   
    protected void assertDependency(ServiceDependencyMetaData original, ServiceDependencyMetaData restored)
    {
       if(original == null)
@@ -232,58 +359,25 @@
       return deployment;
    }
    
-   protected AbstractFileAttachmentsSerializer getAttachmentSerializer() throws Exception
+   private static final class TestMapper extends ServiceDeploymentComponentMapper
    {
-      return getAttachmentSerializer(false);
-   }
-   
-   protected AbstractFileAttachmentsSerializer getAttachmentSerializer(boolean logToSystemOut) throws Exception
-   {
-      File tempFile = File.createTempFile(getName(), null);
-      return createSerializer(tempFile, logToSystemOut);
-   }
 
-   /**
-    * Create the attachment Serializer.
-    * Use a tempFile for storing the Xml.
-    * 
-    * @param tempFile the temp File
-    * @return a AttachmentSerializer.
-    * @throws Exception
-    */
-   protected AbstractFileAttachmentsSerializer createSerializer(File tempFile) throws Exception
-   {
-      return createSerializer(tempFile, false);
-   }
-   
-   protected AbstractFileAttachmentsSerializer createSerializer(final File tempFile, final boolean logToSystemOut) throws Exception
-   {
-      return new TempAttachmentSerializer(tempFile);
-   }
-   
-   private class TempAttachmentSerializer extends JAXBAttachmentSerializer
-   {
-      public TempAttachmentSerializer(File tempFile)
+      public TestMapper(PersistenceFactory persistenceFactory)
       {
-         super(tempFile);
+         super(persistenceFactory);
       }
       
       @Override
-      protected void saveAttachment(File attachmentsStore, Object attachment) throws Exception
+      protected PersistedComponent createComponent(Object attachment, ManagedComponent component)
       {
-         log.trace("saveAttachments, attachmentsStore="+attachmentsStore+ ", attachment="+attachment);
-         JAXBContext ctx = JAXBContext.newInstance(attachment.getClass());
-         Marshaller marshaller = ctx.createMarshaller();
-         marshaller.setProperty("jaxb.formatted.output", Boolean.TRUE);
-         marshaller.marshal(attachment, attachmentsStore);
+         // Note: this is using the TestMgtComponentImpl to get the MO
+         ManagedObject mo = (ManagedObject) component.getParent();
+         PersistedManagedObject persisted = getPersistencePlugin().createPersistedManagedObject(mo);
+         PersistedComponent persistedComponent = new PersistedComponent(persisted);
+         setComponentName(persistedComponent, mo);
+         return persistedComponent;
       }
       
-      @Override
-      protected File getAttachmentPath(String baseName)
-      {
-         // Return the temp file
-         return getAttachmentsStoreDir();
-      }
    }
 }
 

Modified: trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/test/JMSDestinationPersistenceFormatTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/test/JMSDestinationPersistenceFormatTestCase.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/test/JMSDestinationPersistenceFormatTestCase.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -24,22 +24,28 @@
 import java.io.File;
 import java.util.List;
 
+import javax.management.ObjectName;
 import javax.xml.parsers.DocumentBuilderFactory;
 
+import org.jboss.managed.api.ManagedComponent;
 import org.jboss.managed.api.ManagedObject;
 import org.jboss.managed.api.ManagedProperty;
 import org.jboss.metatype.api.values.CollectionValue;
 import org.jboss.metatype.api.values.GenericValue;
 import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.system.deployers.managed.ServiceDeploymentComponentMapper;
 import org.jboss.system.deployers.managed.ServiceMetaDataICF;
 import org.jboss.system.metadata.ServiceAttributeMetaData;
+import org.jboss.system.metadata.ServiceDependencyValueMetaData;
 import org.jboss.system.metadata.ServiceDeployment;
 import org.jboss.system.metadata.ServiceDeploymentParser;
 import org.jboss.system.metadata.ServiceMetaData;
 import org.jboss.system.metadata.ServiceMetaDataParser;
 import org.jboss.system.metadata.ServiceTextValueMetaData;
-import org.jboss.system.server.profileservice.persistence.ManagedGenericOverrideHandler;
+import org.jboss.system.server.profileservice.persistence.PersistenceFactory;
+import org.jboss.system.server.profileservice.persistence.xml.PersistedComponent;
 import org.jboss.system.server.profileservice.persistence.xml.PersistedManagedObject;
+import org.jboss.system.server.profileservice.persistence.xml.PersistenceRoot;
 import org.w3c.dom.Document;
 
 /**
@@ -76,25 +82,34 @@
    {
       // Set the ICF
       getMOF().addInstanceClassFactory(new ServiceMetaDataICF());
+      // TODO create dependency on messaging project ?
+//      getMOF().addManagedObjectDefinition(new QueueMODefinition(getMOF()));
+//      getMOF().addManagedObjectDefinition(new TopicMODefinition(getMOF()));
       
+      // Add the testmapper
+      addComponentMapper(new TestMapper(getPersistenceFactory()));
+      
       // create
       ManagedObject deploymentMO = getDeploymentMO(xmlName);
 
+      ManagedComponent component = createJMSComponent(deploymentMO);
+      
       // update property
-      getProperty(deploymentMO, "downCacheSize").setValue(SimpleValueSupport.wrap(123456));
+      component.getProperty("downCacheSize").setValue(SimpleValueSupport.wrap(123456));
       
-      PersistedManagedObject moElement = restore(deploymentMO);
+      ServiceDeployment deployment = parseJbossServiceXml(xmlName);
+      PersistenceRoot root = updateComponent(deploymentMO, component);
+      getPersistenceFactory().restorePersistenceRoot(root, deployment, null);
       
-      ManagedGenericOverrideHandler handler = new ManagedGenericOverrideHandler();
-      ManagedObject restored = handler.update(parseJbossServiceXml(xmlName), moElement);
+      // 
+      ManagedObject restored = getMOF().initManagedObject(deployment, null);
+      component = createJMSComponent(restored);
       
       // assert
-      assertEquals(SimpleValueSupport.wrap(123456), getProperty(restored, "downCacheSize").getValue());
+      assertEquals(SimpleValueSupport.wrap(123456),  component.getProperty("downCacheSize").getValue());
       
       
       // Assert attachment meta data
-      ServiceDeployment deployment =  (ServiceDeployment) restored.getAttachment();
-      assertNotNull(deployment);
       ServiceMetaData service = deployment.getServices().get(0);
       assertNotNull(service);
       boolean foundAttribute = false;
@@ -106,10 +121,32 @@
             assertEquals("123456", text);
             foundAttribute = true;
          }
+         else if("ServerPeer".equals(attribute.getName()))
+         {
+            ServiceDependencyValueMetaData value = ((ServiceDependencyValueMetaData) attribute.getValue());
+            ObjectName name = value.getObjectName();
+            assertNotNull(name);
+         }
+         else if("ExpiryQueue".equals(attribute.getName()))
+         {
+            ServiceTextValueMetaData value = (ServiceTextValueMetaData) attribute.getValue();
+            assertNotNull(value.getText());
+         }
       }
       assertTrue(foundAttribute);
    }
    
+   protected ManagedComponent createJMSComponent(ManagedObject serviceDeploymentMO)
+   {
+      assertNotNull(serviceDeploymentMO);
+      CollectionValue collection = (CollectionValue) serviceDeploymentMO.getProperty("services").getValue();
+      assertNotNull(collection);
+      GenericValue topic = (GenericValue) collection.iterator().next();
+      assertNotNull(topic);
+      ManagedObject topicMO = (ManagedObject) topic.getValue();
+      return createComponent(topicMO);
+   }
+   
    protected ManagedProperty getProperty(ManagedObject serviceDeploymentMO, String propertyName)
    {
       assertNotNull(serviceDeploymentMO);
@@ -151,4 +188,23 @@
       return deployment;
    }
    
+   private static final class TestMapper extends ServiceDeploymentComponentMapper
+   {
+
+      public TestMapper(PersistenceFactory persistenceFactory)
+      {
+         super(persistenceFactory);
+      }
+      
+      protected PersistedComponent createComponent(Object attachment, ManagedComponent component)
+      {
+         // Note: this is using the TestMgtComponentImpl to get the MO
+         ManagedObject mo = (ManagedObject) component.getParent();
+         PersistedManagedObject persisted = getPersistencePlugin().createPersistedManagedObject(mo);
+         PersistedComponent persistedComponent = new PersistedComponent(persisted);
+         setComponentName(persistedComponent, mo);
+         return persistedComponent;
+      }
+      
+   }
 }

Modified: trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/test/LocalDataSourcePersistenceFormatTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/test/LocalDataSourcePersistenceFormatTestCase.java	2009-05-26 09:17:50 UTC (rev 89428)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/test/LocalDataSourcePersistenceFormatTestCase.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -29,18 +29,21 @@
 import javax.xml.bind.Unmarshaller;
 import javax.xml.transform.sax.SAXSource;
 
+import org.jboss.managed.api.ManagedComponent;
 import org.jboss.managed.api.ManagedObject;
-import org.jboss.managed.api.ManagedProperty;
 import org.jboss.metatype.api.values.CollectionValue;
 import org.jboss.metatype.api.values.GenericValue;
 import org.jboss.metatype.api.values.SimpleValueSupport;
 import org.jboss.resource.deployers.management.LocalDSInstanceClassFactory;
+import org.jboss.resource.deployers.management.MCFDGComponentMapper;
 import org.jboss.resource.metadata.mcf.ManagedConnectionFactoryDeploymentGroup;
 import org.jboss.resource.metadata.mcf.ManagedConnectionFactoryDeploymentMetaData;
 import org.jboss.system.deployers.managed.ServiceMetaDataICF;
 import org.jboss.system.metadata.ServiceMetaData;
-import org.jboss.system.server.profileservice.persistence.ManagedGenericOverrideHandler;
+import org.jboss.system.server.profileservice.persistence.PersistenceFactory;
+import org.jboss.system.server.profileservice.persistence.xml.PersistedComponent;
 import org.jboss.system.server.profileservice.persistence.xml.PersistedManagedObject;
+import org.jboss.system.server.profileservice.persistence.xml.PersistenceRoot;
 import org.jboss.util.xml.JBossEntityResolver;
 import org.xml.sax.InputSource;
 import org.xml.sax.XMLReader;
@@ -60,11 +63,17 @@
       super(name);
    }
    
+   public void setUp() throws Exception
+   {
+      super.setUp();
+   }
+   
    public void testProfileServiceTestDS() throws Throwable
    {
       getMOF().addInstanceClassFactory(new LocalDSInstanceClassFactory());
-      // FIXME
       getMOF().addInstanceClassFactory(new ServiceMetaDataICF());
+      // 
+      addComponentMapper(new TestMapper(getPersistenceFactory()));
 
       // Initial parsing of the dataSource deployment
       ManagedConnectionFactoryDeploymentGroup deployment = parseDataSource("profileservice/persistence/profileservice-test-ds.xml");
@@ -72,26 +81,28 @@
 
       ManagedObject mo = getMOF().initManagedObject(deployment, null);
 
+      ManagedComponent c = createDSComponent(mo);
       // Change values
-      getManagedProperty(mo, "min-pool-size").setValue(SimpleValueSupport.wrap(13));
-      getManagedProperty(mo, "max-pool-size").setValue(SimpleValueSupport.wrap(53));
+      c.getProperty("min-pool-size").setValue(SimpleValueSupport.wrap(13));
+      c.getProperty("max-pool-size").setValue(SimpleValueSupport.wrap(53));
       
-      PersistedManagedObject moelement = restore(mo);
-      assertNotNull(moelement);
+      PersistenceRoot root = updateComponent(mo, c);
+      assertNotNull(root);
 
-      enableTrace("org.jboss.system");
-
       // Recreate
       deployment = parseDataSource("profileservice/persistence/profileservice-test-ds.xml");
-      ManagedGenericOverrideHandler handler = new ManagedGenericOverrideHandler();
-      ManagedObject restored = handler.update(deployment, moelement);
-      assertNotNull(restored);
+      // update the information
+      getPersistenceFactory().restorePersistenceRoot(root, deployment, null);
 
-      assertEquals(SimpleValueSupport.wrap(13), getManagedProperty(mo, "min-pool-size").getValue());
-      assertEquals(SimpleValueSupport.wrap(53), getManagedProperty(mo, "max-pool-size").getValue());
+      // Create the MO again
+      mo = getMOF().initManagedObject(deployment, null);
+      c = createDSComponent(mo);
       
+      assertEquals(SimpleValueSupport.wrap(13), c.getProperty("min-pool-size").getValue());
+      assertEquals(SimpleValueSupport.wrap(53), c.getProperty("max-pool-size").getValue());
       
-      ManagedConnectionFactoryDeploymentGroup mcfdg = (ManagedConnectionFactoryDeploymentGroup) restored.getAttachment();
+      // Assert the attachment
+      ManagedConnectionFactoryDeploymentGroup mcfdg = deployment;
       assertNotNull(mcfdg);
       // Assert services
       assertServices(mcfdg.getServices()); 
@@ -125,12 +136,12 @@
       }
    }
    
-   protected ManagedProperty getManagedProperty(ManagedObject mo, String propertyName)
+   protected ManagedComponent createDSComponent(ManagedObject deployment)
    {
-      CollectionValue collection = (CollectionValue) mo.getProperty("deployments").getValue();
+      CollectionValue collection = (CollectionValue) deployment.getProperty("deployments").getValue();
       GenericValue generic = (GenericValue) collection.iterator().next();
-      ManagedObject deployment = (ManagedObject) generic.getValue();
-      return deployment.getProperty(propertyName);
+      ManagedObject mo = (ManagedObject) generic.getValue();
+      return createComponent(mo);
    }
    
    protected ManagedConnectionFactoryDeploymentGroup parseDataSource(String resource) throws Exception
@@ -151,4 +162,25 @@
             ManagedConnectionFactoryDeploymentGroup.class);
       return elem.getValue();
    }
+   
+   private static class TestMapper extends MCFDGComponentMapper
+   {
+
+      public TestMapper(PersistenceFactory persistenceFactory)
+      {
+         super(persistenceFactory);
+      }
+      
+      @Override
+      protected PersistedComponent createComponent(Object attachment, ManagedComponent component)
+      {
+         // Note: this is using the TestMgtComponentImpl to get the MO
+         ManagedObject mo = (ManagedObject) component.getParent();
+         PersistedManagedObject persisted = getPersistencePlugin().createPersistedManagedObject(mo);
+         PersistedComponent persistedComponent = new PersistedComponent(persisted);
+         setComponentName(persistedComponent, mo);
+         return persistedComponent;
+      }
+      
+   }
 }

Added: trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/test/ServiceBindingMgrPersistenceFormatTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/test/ServiceBindingMgrPersistenceFormatTestCase.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/test/ServiceBindingMgrPersistenceFormatTestCase.java	2009-05-26 10:14:36 UTC (rev 89429)
@@ -0,0 +1,181 @@
+/*
+ * 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.test.profileservice.persistenceformat.test;
+
+import java.util.List;
+
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.deployers.plugins.managed.BeanMetaDataICF;
+import org.jboss.deployers.plugins.managed.KernelDeploymentComponentMapper;
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.plugins.bootstrap.basic.BasicBootstrap;
+import org.jboss.kernel.plugins.deployment.AbstractKernelDeployment;
+import org.jboss.kernel.spi.dependency.KernelController;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.kernel.spi.deployment.KernelDeployment;
+import org.jboss.managed.api.ManagedComponent;
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.plugins.factory.AbstractManagedObjectFactory;
+import org.jboss.metatype.api.values.CollectionValue;
+import org.jboss.metatype.api.values.MapCompositeValueSupport;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.profileservice.management.TempManagedComponentImpl;
+import org.jboss.services.binding.ServiceBindingManager;
+import org.jboss.system.server.profileservice.persistence.xml.PersistenceRoot;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBindingResolver;
+import org.jboss.xb.binding.sunday.unmarshalling.SingletonSchemaResolverFactory;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class ServiceBindingMgrPersistenceFormatTestCase extends AbstractPersistenceFormatTest
+{
+   
+   /** The bootstrap. */
+   private BasicBootstrap bootstrap;
+   
+   /** The kernel. */
+   private Kernel kernel;
+   
+   /** The controller. */
+   private KernelController controller;
+   
+   /** Unmarshaller factory */
+   private static final UnmarshallerFactory factory = UnmarshallerFactory.newInstance();
+
+   /** The resolver */
+   private static final SchemaBindingResolver resolver = SingletonSchemaResolverFactory.getInstance().getSchemaBindingResolver();
+   
+   public ServiceBindingMgrPersistenceFormatTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void setUp() throws Exception
+   {
+      super.setUp();
+      // Bootstrap
+      bootstrap = new BasicBootstrap();
+      bootstrap.run();
+      //
+      kernel = bootstrap.getKernel();
+      //
+      controller = kernel.getController();
+      
+      // setUp beanICF
+      BeanMetaDataICF beanICF = new BeanMetaDataICF();
+      beanICF.setController(controller);
+      beanICF.setDelegateICF(((AbstractManagedObjectFactory) 
+            getMOF()).getDefaultInstanceFactory());
+      
+      getMOF().addInstanceClassFactory(beanICF);
+      addComponentMapper(new KernelDeploymentComponentMapper(getPersistenceFactory()));
+   }
+   
+   public void test() throws Throwable
+   {
+      // Set the jboss.bind.address
+      System.setProperty("jboss.bind.address", "127.0.0.1");
+      // Parse
+      KernelDeployment deployment = parse(Thread.currentThread().getContextClassLoader().getResource("profileservice/persistence/testbindings-jboss-beans.xml").toString());
+      // Deploy
+      deploy(deployment);
+      // Get the BeanMetaData
+      KernelControllerContext ctx = (KernelControllerContext) controller.getContext("ServiceBindingManagementObject", null);
+      assertNotNull(ctx);
+      BeanMetaData bmd = ctx.getBeanMetaData();
+      assertNotNull(bmd);
+
+      // Create the ManagedObjects
+      ManagedObject deploymentMO = getMOF().initManagedObject(deployment, null);
+      ManagedObject mo = getMOF().initManagedObject(bmd, null);
+      assertNotNull(mo);
+      // Change the value
+      CollectionValue bindingSets = (CollectionValue) mo.getProperty("standardBindings").getValue(); 
+      assertNotNull(bindingSets);
+      setPortValue("HttpsConnector", bindingSets, 13245);
+
+      // Persist
+      ManagedComponent component = new TempManagedComponentImpl(null, null, mo);
+      PersistenceRoot root = getPersistenceFactory().updateComponent(deploymentMO, component);
+      root.setClassName(AbstractKernelDeployment.class.getName());
+      root = restore(root);
+      
+      // Undeploy
+      undeploy(deployment);
+      // Restore
+      getPersistenceFactory().restorePersistenceRoot(root, deployment, null);
+      
+      deploy(deployment);
+
+      // Check if the values were changed.
+      ServiceBindingManager service = (ServiceBindingManager) kernel.getRegistry().getEntry("ServiceBindingManager").getTarget();
+      assertNotNull(service);
+      assertEquals(13245, service.getIntBinding("jboss.web:service=WebServer", "HttpsConnector"));
+   }
+   
+   protected void setPortValue(String name, CollectionValue values, int port)
+   {
+      boolean found = false;
+      for(MetaValue v : values.getElements())
+      {
+         MapCompositeValueSupport c = (MapCompositeValueSupport) v;
+         SimpleValue bindingName = (SimpleValue)c.get("bindingName");
+         if(bindingName != null && bindingName.getValue().equals(name))
+         {
+            found = true;
+            c.put("port", SimpleValueSupport.wrap(port));
+         }
+      }
+      assertTrue("found "+ name, found);
+   }
+   
+   protected void deploy(KernelDeployment deployment) throws Throwable
+   {
+      List<BeanMetaData> beans = deployment.getBeans();
+      for(BeanMetaData bmd : beans)
+         controller.install(bmd);
+   }
+   
+   protected void undeploy(KernelDeployment deployment)
+   {
+      List<BeanMetaData> beans = deployment.getBeans();
+      for(BeanMetaData bmd : beans)
+         controller.uninstall(bmd.getName());
+   }
+   
+   
+   protected KernelDeployment parse(String name) throws Throwable
+   {
+      Unmarshaller unmarshaller = factory.newUnmarshaller();
+      KernelDeployment deployment = (KernelDeployment) unmarshaller.unmarshal(name, resolver);
+      deployment.setName(name);
+      return deployment;
+   }
+   
+}
+




More information about the jboss-cvs-commits mailing list