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

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Apr 3 08:05:07 EDT 2009


Author: emuckenhuber
Date: 2009-04-03 08:05:06 -0400 (Fri, 03 Apr 2009)
New Revision: 86739

Added:
   trunk/system/src/main/org/jboss/system/server/profile/repository/NoopProfile.java
   trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/EmptyProfileMetaData.java
   trunk/system/src/main/org/jboss/system/server/profileservice/hotdeploy/Scanner.java
   trunk/system/src/main/org/jboss/system/server/profileservice/persistence/ManagedObjectRemoveHandler.java
   trunk/system/src/main/org/jboss/system/server/profileservice/persistence/xml/NullValue.java
   trunk/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistedPair.java
   trunk/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistedPropertiesValue.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/BasicDeploymentRepository.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/BasicProfileFactory.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/FilteredProfileFactory.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/HotDeploymentRepository.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/TypedProfileFactory.java
   trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/support/ObjectNameMetaData.java
   trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/test/ObjectNameUnitTestCase.java
   trunk/system/src/tests/org/jboss/test/server/profileservice/support/FilteredProfile.java
   trunk/system/src/tests/org/jboss/test/server/profileservice/support/FilteredProfileFactory.java
   trunk/system/src/tests/org/jboss/test/server/profileservice/support/XmlProfileFactory.java
   trunk/system/src/tests/org/jboss/test/server/profileservice/test/DeploymentRepositoryUnitTestCase.java
   trunk/testsuite/src/main/org/jboss/test/profileservice/override/restart/test/LocalDSRemoveOverrideUnitTestCase.java
   trunk/testsuite/src/main/org/jboss/test/profileservice/override/test/LocalDSRemoveTestCase.java
   trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/support/
   trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/support/SimpleAnnotatedBean.java
   trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/test/JBossBeansPersistenceFormatTestCase.java
   trunk/testsuite/src/main/org/jboss/test/profileservice/template/
   trunk/testsuite/src/main/org/jboss/test/profileservice/template/test/
   trunk/testsuite/src/main/org/jboss/test/profileservice/template/test/AbstractTemplateTest.java
   trunk/testsuite/src/main/org/jboss/test/profileservice/template/test/DSDeploymentTemplateUnitTestCase.java
   trunk/testsuite/src/main/org/jboss/test/profileservice/template/test/JMSDestinationTemplateUnitTestCase.java
Removed:
   trunk/connector/src/main/org/jboss/resource/deployers/management/ConnectionFactoryTemplateInfo.java
   trunk/profileservice/src/main/org/jboss/profileservice/management/templates/DsXmlDataSourceTemplate.java
   trunk/profileservice/src/main/org/jboss/profileservice/management/templates/DsXmlDataSourceTemplateInfo.java
   trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/FilteredProfileSourceMetaData.java
   trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/ImmutableProfileMetaData.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/FilteredDeploymentRepositoryFactory.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/ImmutableDeploymentRepository.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/MutableDeploymentRepository.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/XmlProfileFactory.java
   trunk/system/src/tests/org/jboss/test/server/profileservice/support/MockProfileRepository.java
   trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/support/SimpleAnnotatedBean.java
   trunk/testsuite/src/main/org/jboss/test/profileservice/template/test/
   trunk/testsuite/src/main/org/jboss/test/profileservice/template/test/AbstractTemplateTest.java
   trunk/testsuite/src/main/org/jboss/test/profileservice/template/test/DSDeploymentTemplateUnitTestCase.java
   trunk/testsuite/src/main/org/jboss/test/profileservice/template/test/JMSDestinationTemplateUnitTestCase.java
Modified:
   trunk/component-matrix/pom.xml
   trunk/connector/src/main/org/jboss/resource/deployers/management/AbstractConnectionFactoryICF.java
   trunk/connector/src/main/org/jboss/resource/metadata/mcf/DataSourceConnectionPropertyMetaData.java
   trunk/connector/src/main/org/jboss/resource/metadata/mcf/DataSourceDeploymentMetaData.java
   trunk/connector/src/main/org/jboss/resource/metadata/mcf/ManagedConnectionFactoryDeploymentMetaData.java
   trunk/connector/src/main/org/jboss/resource/metadata/mcf/NonXADataSourceDeploymentMetaData.java
   trunk/connector/src/main/org/jboss/resource/metadata/mcf/TxConnectionFactoryDeploymentMetaData.java
   trunk/connector/src/main/org/jboss/resource/metadata/mcf/XADataSourceDeploymentMetaData.java
   trunk/messaging/src/etc/deploy/common/messaging-jboss-beans.xml
   trunk/profileservice/src/main/org/jboss/profileservice/management/AbstractRuntimeComponentDispatcher.java
   trunk/profileservice/src/main/org/jboss/profileservice/management/KernelBusRuntimeComponentDispatcher.java
   trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java
   trunk/profileservice/src/main/org/jboss/profileservice/management/upload/AbstractTransientProfileManager.java
   trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentManagerImpl.java
   trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentProgressImpl.java
   trunk/profileservice/src/main/org/jboss/profileservice/management/upload/messages.properties
   trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/AbstractDeployHandler.java
   trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/DeployHandler.java
   trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/StreamingDeploymentTarget.java
   trunk/profileservice/src/resources/hdscanner-jboss-beans.xml
   trunk/profileservice/src/resources/profileservice-jboss-beans.xml
   trunk/server/src/etc/conf/default/bootstrap/profile.xml
   trunk/system/src/main/org/jboss/deployers/plugins/managed/BeanMetaDataICF.java
   trunk/system/src/main/org/jboss/deployers/plugins/managed/KernelDeploymentManagedObjectCreator.java
   trunk/system/src/main/org/jboss/system/server/profile/repository/AbstractImmutableProfile.java
   trunk/system/src/main/org/jboss/system/server/profile/repository/AbstractProfile.java
   trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/AbstractProfileMetaData.java
   trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/AbstractProfileSourceMetaData.java
   trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/BasicProfileDeploymentMetaData.java
   trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/BasicProfileMetaData.java
   trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/BasicSubProfileMetaData.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/HotDeploymentProfileSourceMetaData.java
   trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/ImmutableProfileSourceMetaData.java
   trunk/system/src/main/org/jboss/system/server/profileservice/ProfileServiceBootstrap.java
   trunk/system/src/main/org/jboss/system/server/profileservice/attachments/AttachmentStore.java
   trunk/system/src/main/org/jboss/system/server/profileservice/hotdeploy/HDScanner.java
   trunk/system/src/main/org/jboss/system/server/profileservice/persistence/AttachmentPropertyPopulator.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/xml/AbstractPersisitedValue.java
   trunk/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistedCollectionValue.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/PersistedManagedObject.java
   trunk/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistedProperty.java
   trunk/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistedSimpleValue.java
   trunk/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistedValue.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractAttachmentStore.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractBootstrapProfileFactory.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileAction.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileFactory.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileLifeCycleAction.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileService.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractVFSProfileSource.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/DefaultDeploymentRepositoryFactory.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/ProfileDeployAction.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/StaticProfileFactory.java
   trunk/system/src/main/org/jboss/system/server/profileservice/repository/TypedProfileRepository.java
   trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/remove/test/RemoveGenericValueUnitTestCase.java
   trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/support/GenericSupportMetaData.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/BasicPersistenceFormatUnitTestCase.java
   trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/test/PersistenceFormatTestSuite.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/system/src/tests/org/jboss/test/server/profileservice/test/AbstractProfileServiceTestBase.java
   trunk/system/src/tests/org/jboss/test/server/profileservice/test/BootstrapProfileFactoryUnitTestCase.java
   trunk/system/src/tests/org/jboss/test/server/profileservice/test/ProfileServiceUnitTestCase.java
   trunk/testsuite/src/main/org/jboss/test/profileservice/override/restart/test/ConnectionFactoryRestartUnitTestCase.java
   trunk/testsuite/src/main/org/jboss/test/profileservice/override/restart/test/PersistedDataSourceUnitTestCase.java
   trunk/testsuite/src/main/org/jboss/test/profileservice/override/test/AbstractProfileServiceTest.java
   trunk/testsuite/src/main/org/jboss/test/profileservice/override/test/ConnectionFactoryOverrideTestCase.java
   trunk/testsuite/src/main/org/jboss/test/profileservice/override/test/ProfileServiceOverrideTestCase.java
   trunk/testsuite/src/main/org/jboss/test/profileservice/test/JmsDestinationUnitTestCase.java
   trunk/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java
   trunk/testsuite/src/resources/test-configs/cluster-profilesvc-0/conf/bootstrap/profile.xml
   trunk/testsuite/src/resources/test-configs/cluster-profilesvc-1/conf/bootstrap/profile.xml
Log:
port some missing changes to trunk

Modified: trunk/component-matrix/pom.xml
===================================================================
--- trunk/component-matrix/pom.xml	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/component-matrix/pom.xml	2009-04-03 12:05:06 UTC (rev 86739)
@@ -68,7 +68,7 @@
     <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.3</version.org.jboss.ejb3>
-    <version.org.jboss.integration>6.0.0.Alpha7</version.org.jboss.integration>
+    <version.org.jboss.integration>5.1.0.CR2</version.org.jboss.integration>
     <version.org.jboss.jbossxb>2.0.0.GA</version.org.jboss.jbossxb>
     <version.org.jboss.jpa>1.0.0-CR1</version.org.jboss.jpa>
     <version.org.jboss.logbridge>1.0.0.CR3</version.org.jboss.logbridge>

Modified: trunk/connector/src/main/org/jboss/resource/deployers/management/AbstractConnectionFactoryICF.java
===================================================================
--- trunk/connector/src/main/org/jboss/resource/deployers/management/AbstractConnectionFactoryICF.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/connector/src/main/org/jboss/resource/deployers/management/AbstractConnectionFactoryICF.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -75,7 +75,7 @@
                String name = prop.getName();               
                MetaValue svalue = SimpleValueSupport.wrap(prop.getValue());
                mapValue.put(name, svalue);
-               MetaValue stype = SimpleValueSupport.wrap(prop.getValue());
+               MetaValue stype = SimpleValueSupport.wrap(prop.getType());
                mapValue.put(name+".type", stype);
             }
          }
@@ -114,6 +114,10 @@
          List<ManagedConnectionFactoryPropertyMetaData> list = new ArrayList<ManagedConnectionFactoryPropertyMetaData>();
          for(String name : mapValue.getMetaType().keySet())
          {
+            // Ignore the type we've added before
+            if(name.endsWith(".type"))
+               continue;
+            
             ManagedConnectionFactoryPropertyMetaData prop = new ManagedConnectionFactoryPropertyMetaData();
             prop.setName(name);
             String svalue = (String) getMetaValueFactory().unwrap(mapValue.get(name));

Deleted: trunk/connector/src/main/org/jboss/resource/deployers/management/ConnectionFactoryTemplateInfo.java
===================================================================
--- trunk/connector/src/main/org/jboss/resource/deployers/management/ConnectionFactoryTemplateInfo.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/connector/src/main/org/jboss/resource/deployers/management/ConnectionFactoryTemplateInfo.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -1,193 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2007, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.resource.deployers.management;
-
-import java.util.HashSet;
-import java.util.Map;
-
-import org.jboss.managed.api.DeploymentTemplateInfo;
-import org.jboss.managed.api.Fields;
-import org.jboss.managed.plugins.BasicDeploymentTemplateInfo;
-import org.jboss.managed.plugins.DefaultFieldsImpl;
-import org.jboss.managed.plugins.ManagedObjectImpl;
-import org.jboss.managed.plugins.ManagedPropertyImpl;
-import org.jboss.metatype.api.types.CompositeMetaType;
-import org.jboss.metatype.api.types.ImmutableCompositeMetaType;
-import org.jboss.metatype.api.types.MetaType;
-import org.jboss.metatype.api.types.SimpleMetaType;
-import org.jboss.metatype.api.values.MetaValue;
-import org.jboss.metatype.api.values.SimpleValueSupport;
-
-/**
- * The ConnectionFactory template information. This describes the detached properties
- * that are available for defining a new ConnectionFactory deployment.
- * 
- * The following properties are supported: 
- * datasource-type : one of local-tx-datasource, no-tx-datasource, xa-datasource, no-tx-connection-factory, tx-connection-factory
- * jndi-name
- * connection-url
- * user-name
- * password
- * security-domain
- * driver-class
- * connection-properties
- * 
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public class ConnectionFactoryTemplateInfo extends BasicDeploymentTemplateInfo
-{
-   private static final long serialVersionUID = 1;
-   private Map<String, String> propertyNameMappings;
-   private String attachmentName;
-   private String dsTypeAttachmentName;
-
-   public ConnectionFactoryTemplateInfo(String name, String description, String attachmentName)
-   {
-      this(name, description, attachmentName, attachmentName);
-   }
-   public ConnectionFactoryTemplateInfo(String name, String description,
-         String attachmentName, String dsTypeAttachmentName)
-   {
-      super(name, description);
-      this.attachmentName = attachmentName;
-      this.dsTypeAttachmentName = dsTypeAttachmentName;
-   }
-
-   public Map<String, String> getPropertyNameMappings()
-   {
-      return propertyNameMappings;
-   }
-   public void setPropertyNameMappings(Map<String, String> propertyNameMappings)
-   {
-      this.propertyNameMappings = propertyNameMappings;
-   }
-
-   public void start()
-   {
-      populate();
-   }
-
-   @Override
-   public ConnectionFactoryTemplateInfo copy()
-   {
-      ConnectionFactoryTemplateInfo copy = new ConnectionFactoryTemplateInfo(getName(), getDescription(),
-            attachmentName, dsTypeAttachmentName);
-      copy.setPropertyNameMappings(propertyNameMappings);
-      copy(copy);
-      copy.populate();
-      return copy;
-   }
-   protected void populate()
-   {
-      ManagedObjectImpl mo = new ManagedObjectImpl(attachmentName);
-      // The jndi name field info
-      DefaultFieldsImpl f0 = new DefaultFieldsImpl();
-      setFieldName("jndi-name", f0);
-      f0.setDescription("The jndi name to bind the DataSource under");
-      f0.setMandatory(true);
-      f0.setMetaType(SimpleMetaType.STRING);
-      ManagedPropertyImpl jndiName = new ManagedPropertyImpl(mo, f0);
-      super.addProperty(jndiName);
-      // The connection-url field info
-      DefaultFieldsImpl f1 = new DefaultFieldsImpl();
-      setFieldName("connection-url", f1);
-      f1.setDescription("The jdbc url of the DataSource");
-      f1.setMandatory(true);
-      f1.setMetaType(SimpleMetaType.STRING);
-      ManagedPropertyImpl conURL = new ManagedPropertyImpl(mo, f1);
-      super.addProperty(conURL);
-      // The user field info
-      DefaultFieldsImpl f2 = new DefaultFieldsImpl();
-      setFieldName("user-name", f2);
-      f2.setDescription("The username for the connection-url");
-      f2.setMandatory(false);
-      f2.setMetaType(SimpleMetaType.STRING);
-      ManagedPropertyImpl user = new ManagedPropertyImpl(mo, f2);
-      super.addProperty(user);
-      // The password field info
-      DefaultFieldsImpl f3 = new DefaultFieldsImpl();
-      setFieldName("password", f3);
-      f3.setDescription("The password for the connection-url");
-      f3.setMandatory(false);
-      f3.setMetaType(SimpleMetaType.STRING);
-      ManagedPropertyImpl password = new ManagedPropertyImpl(mo, f3);
-      super.addProperty(password);
-      // The security-domain field info   
-      DefaultFieldsImpl f4 = new DefaultFieldsImpl();
-      setFieldName("security-domain", f4);
-      f4.setDescription("The security-domain used to validate connections");
-      f4.setMandatory(false);
-      f4.setMetaType(SimpleMetaType.STRING);
-      ManagedPropertyImpl secDomain = new ManagedPropertyImpl(mo, f4);
-      super.addProperty(secDomain);
-      // The driver-class field info
-      DefaultFieldsImpl f5 = new DefaultFieldsImpl();
-      setFieldName("driver-class", f5);
-      f5.setDescription("The jdbc driver class name");
-      f5.setMandatory(true);
-      f5.setMetaType(SimpleMetaType.STRING);
-      ManagedPropertyImpl driverClass = new ManagedPropertyImpl(mo, f5);
-      super.addProperty(driverClass);
-      // The driver connection properties field info
-      DefaultFieldsImpl f6 = new DefaultFieldsImpl();
-      setFieldName("connection-properties", f6);
-      f6.setDescription("The jdbc driver connection properties");
-      f6.setMandatory(false);
-      String[] itemNames = {"conn-prop1", "conn-prop2"};
-      String[] itemDescriptions = {"conn-prop1 description", "conn-prop2 description"};
-      MetaType[] itemTypes = {SimpleMetaType.STRING, SimpleMetaType.STRING};
-      CompositeMetaType propsType = new ImmutableCompositeMetaType("java.lang.Properties", "DS connection properties",
-            itemNames, itemDescriptions, itemTypes);
-      f6.setMetaType(propsType);
-      ManagedPropertyImpl connProps = new ManagedPropertyImpl(mo, f6);
-      super.addProperty(connProps);
-
-      // The type of the connection factory
-      ManagedObjectImpl mo2 = new ManagedObjectImpl(dsTypeAttachmentName);
-      DefaultFieldsImpl f21 = new DefaultFieldsImpl();
-      setFieldName("datasource-type", f21);
-      f21.setDescription("The type of the ConnectionFactory");
-      f21.setMandatory(true);
-      f21.setValue(SimpleValueSupport.wrap("local-tx-datasource"));
-      HashSet<MetaValue> values = new HashSet<MetaValue>();
-      values.add(SimpleValueSupport.wrap("local-tx-datasource"));
-      values.add(SimpleValueSupport.wrap("no-tx-datasource"));
-      values.add(SimpleValueSupport.wrap("xa-datasource"));
-      f21.setLegalValues(values);
-      f21.setMetaType(SimpleMetaType.STRING);
-      ManagedPropertyImpl dsType = new ManagedPropertyImpl(mo2, f21);
-      super.addProperty(dsType);
-   }
-
-   protected void setFieldName(String name, Fields f)
-   {
-      f.setField(Fields.NAME, name);
-      if( propertyNameMappings != null )
-      {
-         String mappedName = propertyNameMappings.get(name);
-         if( mappedName != null )
-            f.setField(Fields.MAPPED_NAME, mappedName);
-      }
-   }
-
-}

Modified: trunk/connector/src/main/org/jboss/resource/metadata/mcf/DataSourceConnectionPropertyMetaData.java
===================================================================
--- trunk/connector/src/main/org/jboss/resource/metadata/mcf/DataSourceConnectionPropertyMetaData.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/connector/src/main/org/jboss/resource/metadata/mcf/DataSourceConnectionPropertyMetaData.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -27,7 +27,6 @@
 import javax.xml.bind.annotation.XmlValue;
 
 import org.jboss.managed.api.annotation.ManagementObject;
-import org.jboss.managed.api.annotation.ManagementProperty;
 
 
 /**

Modified: trunk/connector/src/main/org/jboss/resource/metadata/mcf/DataSourceDeploymentMetaData.java
===================================================================
--- trunk/connector/src/main/org/jboss/resource/metadata/mcf/DataSourceDeploymentMetaData.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/connector/src/main/org/jboss/resource/metadata/mcf/DataSourceDeploymentMetaData.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -316,8 +316,8 @@
 
    @Override
    @ManagementProperty(name="config-property",
-         description="The connection factory property info", managed=true,
-         includeInTemplate=true)
+         description="The connection factory property info",
+         managed=true, readOnly = true)
    @ManagementPropertyFactory(ConnectionFactoryProperty.class)
    public List<ManagedConnectionFactoryPropertyMetaData> getManagedConnectionFactoryProperties()
    {

Modified: trunk/connector/src/main/org/jboss/resource/metadata/mcf/ManagedConnectionFactoryDeploymentMetaData.java
===================================================================
--- trunk/connector/src/main/org/jboss/resource/metadata/mcf/ManagedConnectionFactoryDeploymentMetaData.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/connector/src/main/org/jboss/resource/metadata/mcf/ManagedConnectionFactoryDeploymentMetaData.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -182,7 +182,8 @@
     * @return the connectionDefinition.
     */
    @ManagementProperty(name="connection-definition",
-         includeInTemplate=true)
+         description="The connection factory class name",
+         mandatory=true, includeInTemplate=true)
    public String getConnectionDefinition()
    {
       return connectionDefinition;
@@ -205,7 +206,8 @@
     */
    @ManagementProperty(name="jndi-name",
          description="The global JNDI name to bind the factory under",
-         includeInTemplate=true)
+         includeInTemplate=true,
+         mandatory=true)
    @ManagementObjectID(type="DataSource")
    public String getJndiName()
    {
@@ -271,7 +273,9 @@
     * 
     * @return the managedConnectionFactoryProperties.
     */
-   @ManagementProperty(name="config-property", managed=true, includeInTemplate=true)
+   @ManagementProperty(name="config-property",
+         description="The connection factory config properties",
+         managed=true, includeInTemplate=true)
    @ManagementPropertyFactory(ConnectionFactoryProperty.class)
    public List<ManagedConnectionFactoryPropertyMetaData> getManagedConnectionFactoryProperties()
    {
@@ -294,7 +298,9 @@
     * 
     * @return the rarName.
     */
-   @ManagementProperty(name="rar-name")
+   @ManagementProperty(name="rar-name",
+         description="The resource adapter archive name",
+         mandatory=true, includeInTemplate=true)
    public String getRarName()
    {
       return rarName;
@@ -315,7 +321,9 @@
     * 
     * @return the securityMetaData.
     */
-   @ManagementProperty(name="security-domain", managed=true, includeInTemplate=true)
+   @ManagementProperty(name="security-domain",
+         description="The security-domain used to validate connections",
+         managed=true, includeInTemplate=true)
    public SecurityMetaData getSecurityMetaData()
    {
       return securityMetaData;
@@ -358,7 +366,9 @@
     * 
     * @return the jmxInvokerName.
     */
-   @ManagementProperty(name="jmx-invoker-name")
+   @ManagementProperty(name="jmx-invoker-name",
+         description="The name of the JMX invoker",
+         includeInTemplate=true)
    @ManagementObjectRef(type="JMXInvoker")
    public String getJmxInvokerName()
    {
@@ -417,7 +427,9 @@
       this.dependsServices = dependsServices;
    }
    
-   @ManagementProperty(name="min-pool-size", includeInTemplate=true)
+   @ManagementProperty(name="min-pool-size",
+         description="The min size of the pool",
+         includeInTemplate=true)
    public void setMinSize(int minSize)
    {
       this.minSize = minSize;
@@ -428,7 +440,9 @@
       return this.minSize;
    }
    
-   @ManagementProperty(name="max-pool-size", includeInTemplate=true)
+   @ManagementProperty(name="max-pool-size",
+         description="The max size of the pool",
+         includeInTemplate=true)
    public void setMaxSize(int maxSize)
    {
       this.maxPoolSize = maxSize;
@@ -444,7 +458,9 @@
       }
    }
    
-   @ManagementProperty(name="blocking-timeout-millis", includeInTemplate=true)
+   @ManagementProperty(name="blocking-timeout-millis",
+         description="The time to wait for a connection to become available before giving up",
+         includeInTemplate=true)
    public void setBlockingTimeoutMilliSeconds(long blockTimeout)
    {
      this.blockingTimeout = blockTimeout;
@@ -455,7 +471,9 @@
       return this.blockingTimeout;
    }
    
-   @ManagementProperty(name="idle-timeout-minutes", includeInTemplate=true)
+   @ManagementProperty(name="idle-timeout-minutes",
+         description="The idle timeout in minutes",
+         includeInTemplate=true)
    public void setIdleTimeoutMinutes(int idleTimeout)
    {
       this.idleTimeout = idleTimeout;
@@ -466,7 +484,9 @@
       return this.idleTimeout;
    }
 
-   @ManagementProperty(name="prefill", includeInTemplate=true)
+   @ManagementProperty(name="prefill",
+         description = "Whether to prefill the pool",
+         includeInTemplate=true)
    public void setPrefill(Boolean prefill)
    {
       this.prefill = prefill;
@@ -477,7 +497,9 @@
       return this.prefill;      
    }
 
-   @ManagementProperty(name="background-validation", includeInTemplate=true)
+   @ManagementProperty(name="background-validation",
+         description = "Whether to use backgroup validation",
+         includeInTemplate=true)
    public boolean isBackgroundValidation()
    {
       return backgroundValidation;
@@ -550,7 +572,9 @@
       this.interleaving = interleaving;
    }
 
-   @ManagementProperty(name="allocation-retry", includeInTemplate=true)
+   @ManagementProperty(name="allocation-retry",
+         description="The number of times allocation retries should be tried",
+         includeInTemplate=true)
    public int getAllocationRetry()
    {
       return this.allocationRetry;
@@ -561,7 +585,9 @@
       this.allocationRetry = ar;
    } 
    
-   @ManagementProperty(name="allocation-retry-wait-millis", includeInTemplate=true)
+   @ManagementProperty(name="allocation-retry-wait-millis",
+         description="The time to wait between allocation retries",
+         includeInTemplate=true)
    public long getAllocationRetryWaitMillis()
    {
       return this.allocationRetryWaitMillis;

Modified: trunk/connector/src/main/org/jboss/resource/metadata/mcf/NonXADataSourceDeploymentMetaData.java
===================================================================
--- trunk/connector/src/main/org/jboss/resource/metadata/mcf/NonXADataSourceDeploymentMetaData.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/connector/src/main/org/jboss/resource/metadata/mcf/NonXADataSourceDeploymentMetaData.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -58,8 +58,9 @@
    @XmlElement(name="connection-property")
    private List<DataSourceConnectionPropertyMetaData> connectionProperties = new ArrayList<DataSourceConnectionPropertyMetaData>();
 
-   @ManagementProperty(name="connection-url", description="The DataSource connection URL",
-         includeInTemplate=true)
+   @ManagementProperty(name="connection-url",
+         description="The DataSource connection URL",
+         mandatory=true, includeInTemplate=true)
    public String getConnectionUrl()
    {
       return connectionUrl;
@@ -72,7 +73,7 @@
 
    @ManagementProperty(name="driver-class",
          description="The DataSource connection driver class name",
-         includeInTemplate=true)
+         mandatory=true, includeInTemplate=true)
    public String getDriverClass()
    {
       return driverClass;
@@ -100,7 +101,7 @@
    @Override
    @ManagementProperty(name="config-property",
          description="The connection factory property info",
-         managed=true, includeInTemplate=true)
+         managed=true, readOnly = true)
    @ManagementPropertyFactory(ConnectionFactoryProperty.class)
    public List<ManagedConnectionFactoryPropertyMetaData> getManagedConnectionFactoryProperties()
    {

Modified: trunk/connector/src/main/org/jboss/resource/metadata/mcf/TxConnectionFactoryDeploymentMetaData.java
===================================================================
--- trunk/connector/src/main/org/jboss/resource/metadata/mcf/TxConnectionFactoryDeploymentMetaData.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/connector/src/main/org/jboss/resource/metadata/mcf/TxConnectionFactoryDeploymentMetaData.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -59,13 +59,16 @@
    @XmlElement(name="xa-transaction")
    private Boolean xaTransaction = Boolean.FALSE;
    
-   @ManagementProperty(name="xa-resource-timeout")
+   @ManagementProperty(name="xa-resource-timeout",
+         description="The XA resource timeout",
+         includeInTemplate=true)
    public int getXaResourceTimeout()
    {
       return xaResourceTimeout;
    }
    
-   @ManagementProperty(name="xa-transaction")
+   @ManagementProperty(name="xa-transaction",
+         includeInTemplate=true)
    public Boolean getXATransaction()
    {
       return xaTransaction;

Modified: trunk/connector/src/main/org/jboss/resource/metadata/mcf/XADataSourceDeploymentMetaData.java
===================================================================
--- trunk/connector/src/main/org/jboss/resource/metadata/mcf/XADataSourceDeploymentMetaData.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/connector/src/main/org/jboss/resource/metadata/mcf/XADataSourceDeploymentMetaData.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -76,8 +76,9 @@
       setTransactionSupportMetaData(ManagedConnectionFactoryTransactionSupportMetaData.XA);
    }
 
-   @ManagementProperty(name="xa-datasource-class", description="The XADataSource class",
-         includeInTemplate=true)
+   @ManagementProperty(name="xa-datasource-class",
+         description="The XADataSource class",
+         mandatory=true, includeInTemplate=true)
    public String getXaDataSourceClass()
    {
       return xaDataSourceClass;
@@ -88,7 +89,8 @@
       this.xaDataSourceClass = xaDataSourceClass;
    }
 
-   @ManagementProperty(name="url-property", description="The url-property",
+   @ManagementProperty(name="url-property",
+         description="The url-property",
          includeInTemplate=true)
    public String getURLProperty()
    {
@@ -100,7 +102,8 @@
       this.urlProperty = urlProperty;
    }
 
-   @ManagementProperty(name="xa-resource-timeout", description="The XAResource timeout",
+   @ManagementProperty(name="xa-resource-timeout",
+         description="The XAResource timeout",
          includeInTemplate=true)
    public int getXaResourceTimeout()
    {
@@ -113,7 +116,7 @@
    }
    
    @ManagementProperty(name="xa-datasource-properties",
-         description="The DataSource properties",
+         description="The xa datasource properties",
          managed=true, includeInTemplate=true)
    @ManagementPropertyFactory(XAConnectionFactoryProperty.class)
    public List<XAConnectionPropertyMetaData> getXADataSourceProperties()
@@ -129,7 +132,7 @@
    @Override
    @ManagementProperty(name="config-property",
          description="The connection factory property info",
-         managed=true, includeInTemplate=true)
+         managed=true, readOnly = true)
    @ManagementPropertyFactory(ConnectionFactoryProperty.class)
    public List<ManagedConnectionFactoryPropertyMetaData> getManagedConnectionFactoryProperties()
    {

Modified: trunk/messaging/src/etc/deploy/common/messaging-jboss-beans.xml
===================================================================
--- trunk/messaging/src/etc/deploy/common/messaging-jboss-beans.xml	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/messaging/src/etc/deploy/common/messaging-jboss-beans.xml	2009-04-03 12:05:06 UTC (rev 86739)
@@ -34,16 +34,22 @@
       <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.messaging:service=SecurityStore",exposedInterface=org.jboss.jms.server.jbosssx.JBossASSecurityMetadataStoreMBean.class)</annotation>
    </bean>
 
+   <bean name="MessagingDeploymentTemplateInfoFactory"
+      class="org.jboss.managed.plugins.factory.DeploymentTemplateInfoFactory"/>
+
    <bean name="QueueTemplate" class="org.jboss.profileservice.management.templates.JmsDestinationTemplate">
       <property name="info"><inject bean="QueueTemplateInfo"/></property>
    </bean>
    <bean name="QueueTemplateInfo"
       class="org.jboss.profileservice.management.templates.JmsDestinationTemplateInfo">
-      <constructor>
-         <parameter>QueueTemplate</parameter>
-         <parameter>A template for JMS queue *-service.xml deployments</parameter>
-         <parameter>queue</parameter>
+      <constructor factoryMethod="createTemplateInfo">
+         <factory bean="DSDeploymentTemplateInfoFactory"/>
+         <parameter class="java.lang.Class">org.jboss.profileservice.management.templates.JmsDestinationTemplateInfo</parameter>
+         <parameter class="java.lang.Class">org.jboss.jms.server.destination.QueueServiceMO</parameter>
+         <parameter class="java.lang.String">QueueTemplate</parameter>
+         <parameter class="java.lang.String">A template for JMS queue *-service.xml deployments</parameter>
       </constructor>
+      <property name="destinationType">QueueTemplate</property>
    </bean>
 
    <bean name="TopicTemplate" class="org.jboss.profileservice.management.templates.JmsDestinationTemplate">
@@ -51,11 +57,14 @@
    </bean>
    <bean name="TopicTemplateInfo"
       class="org.jboss.profileservice.management.templates.JmsDestinationTemplateInfo">
-      <constructor>
-         <parameter>TopicTemplate</parameter>
-         <parameter>A template for JMS topic *-service.xml deployments</parameter>
-         <parameter>topic</parameter>
+      <constructor factoryMethod="createTemplateInfo">
+         <factory bean="DSDeploymentTemplateInfoFactory"/>
+         <parameter class="java.lang.Class">org.jboss.profileservice.management.templates.JmsDestinationTemplateInfo</parameter>
+         <parameter class="java.lang.Class">org.jboss.jms.server.destination.TopicServiceMO</parameter>
+         <parameter class="java.lang.String">TopicTemplate</parameter>
+         <parameter class="java.lang.String">A template for JMS topic *-service.xml deployments</parameter>
       </constructor>
+      <property name="destinationType">TopicTemplate</property>
    </bean>
 
   <bean name="QueueMODefinition" class="org.jboss.jms.server.destination.QueueMODefinition">

Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/AbstractRuntimeComponentDispatcher.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/AbstractRuntimeComponentDispatcher.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/AbstractRuntimeComponentDispatcher.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -42,6 +42,14 @@
    }
 
    /**
+    * Get the state of the component
+    *
+    * @param name the component name
+    * @return state enum value
+    */
+   public abstract String getState(Object name);
+
+   /**
     * Create meta value.
     *
     * @param value the value

Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/KernelBusRuntimeComponentDispatcher.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/KernelBusRuntimeComponentDispatcher.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/KernelBusRuntimeComponentDispatcher.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -21,6 +21,7 @@
  */
 package org.jboss.profileservice.management;
 
+import java.util.Arrays;
 import java.lang.reflect.UndeclaredThrowableException;
 
 import org.jboss.dependency.spi.ControllerContext;
@@ -42,23 +43,6 @@
    private KernelBus bus;
    private Kernel kernel;
 
-   @Deprecated
-   public KernelBusRuntimeComponentDispatcher(KernelBus bus)
-   {
-      this(bus, null);
-   }
-
-   @Deprecated
-   public KernelBusRuntimeComponentDispatcher(KernelBus bus, MetaValueFactory valueFactory)
-   {
-      super(valueFactory);
-      if (bus == null)
-         throw new IllegalArgumentException("Null kernel bus.");
-
-      this.bus = bus;
-      this.kernel = bus.getKernel();
-   }
-
    public KernelBusRuntimeComponentDispatcher(Kernel kernel)
    {
       this(kernel, null);
@@ -93,7 +77,7 @@
       }
       catch (Throwable t)
       {
-         throw new UndeclaredThrowableException(t);
+         throw new UndeclaredThrowableException(t, "Failed to get property '" + propertyName + "' on component '" + componentName + "'.");
       }
    }
 
@@ -105,7 +89,7 @@
       }
       catch (Throwable t)
       {
-         throw new UndeclaredThrowableException(t);
+         throw new UndeclaredThrowableException(t, "Failed to set property '" + propertyName + "' on component '" + componentName + "' to value [" + value + "].");
       }
    }
 
@@ -117,16 +101,10 @@
       }
       catch (Throwable t)
       {
-         throw new UndeclaredThrowableException(t);
+         throw new UndeclaredThrowableException(t, "Failed to invoke method '" + methodName + "' on component '" + componentName + "' with parameters " + Arrays.asList(param) + ".");
       }
    }
 
-   /**
-    * Get the state of a bean
-    * 
-    * @param name the bean name
-    * @return state enum value
-    */
    public String getState(Object name)
    {
       KernelController controller = kernel.getController();

Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -52,6 +52,7 @@
 import org.jboss.logging.Logger;
 import org.jboss.managed.api.ComponentType;
 import org.jboss.managed.api.DeploymentTemplateInfo;
+import org.jboss.managed.api.Fields;
 import org.jboss.managed.api.ManagedComponent;
 import org.jboss.managed.api.ManagedDeployment;
 import org.jboss.managed.api.ManagedObject;
@@ -146,9 +147,6 @@
    private Map<String, ManagedDeployment> managedDeployments = new HashMap<String, ManagedDeployment>();   
    /** The root deployments to resolve the deployment name. */
    private List<String> rootDeployments = new ArrayList<String>();
-
-   @Deprecated
-   private Map<String, ProfileKey> deploymentsToProfile = new HashMap<String, ProfileKey>();
    
    /** The state mappings. */
    private Map<String, String> stateMappings = new HashMap<String, String>();
@@ -179,13 +177,13 @@
       stateMappings.put("Installed", RunState.RUNNING.name());
    }
    
-   public synchronized void load()
+   public boolean load()
    {
       // If the profile is not modified do nothing
       if(isReload() == false)
       {
          log.debug("Not reloading profiles.");
-         return;
+         return false;
       }
       this.forceReload = false;
       
@@ -284,6 +282,7 @@
          Thread.currentThread().interrupt();
          log.debug("Restored interrupted state of calling thread");
       }
+      return true;
    }
    
    public void reload()
@@ -302,7 +301,6 @@
       this.unresolvedRefs.clear();
       this.lastModified.clear();
       this.rootDeployments.clear();
-      this.deploymentsToProfile.clear();
    }
    
    protected void loadProfiles(boolean trace)
@@ -387,9 +385,11 @@
       }
       managedDeployments.put(name, md);
       
-      // TODO this mapping should not be needed
+      // Associate profile with the deployment
       if(profile != null)
-         deploymentsToProfile.put(name, profile);
+      {
+         md.setAttachment(ProfileKey.class.getName(), profile);
+      }
 
       // Add root deployments
       if(level == 0)
@@ -637,7 +637,7 @@
       if (state == RunState.UNKNOWN && dispatcher != null)
       {
          //TODO, update RuntimeComponentDispatcher
-         KernelBusRuntimeComponentDispatcher xdispatcher = (KernelBusRuntimeComponentDispatcher) dispatcher;
+         AbstractRuntimeComponentDispatcher xdispatcher = (AbstractRuntimeComponentDispatcher) dispatcher;
          Object name = comp.getComponentName();
          if (name == null && runtimeMO != null)
             name = runtimeMO.getComponentName();
@@ -905,8 +905,7 @@
       HashSet<ManagedDeployment> mds = new HashSet<ManagedDeployment>();
       for(String name : names)
       {
-         ProfileDeployment ctx = getProfileDeployment(name);
-         ManagedDeployment md = getManagedDeployment(ctx);
+         ManagedDeployment md = getDeployment(name);
          mds.add(md);
       }
       return mds;
@@ -999,6 +998,9 @@
    public void applyTemplate(String deploymentBaseName, DeploymentTemplateInfo info)
       throws Exception
    {
+      if(info == null)
+         throw new IllegalArgumentException("Null template info.");
+      
       DeploymentTemplate template = templates.get(info.getName());
       if( template == null )
       {
@@ -1010,110 +1012,14 @@
 
       // 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);
       
-      /* Scan through the template properties to see if there is a
-      property with an ManagementObjectID annotation that needs
-      to be used to update the associated ManagedObject name.
-      */
-      for(ManagedProperty prop : info.getProperties().values())
-      {
-         // Skip null values
-         if( prop.getValue() == null )
-            continue;
-         Map<String, Annotation> pannotations = prop.getAnnotations();
-         if (pannotations != null)
-         {
-            ManagementObjectID id = (ManagementObjectID) pannotations.get(ManagementObjectID.class.getName());
-            if (id != null)
-            {
-               Object refName = getRefName(prop.getValue());
-               if (refName == null)
-                  refName = id.name();
-               String name = "" + refName;
-               log.debug("Updating template ManagedObject name to:"+name+" from property: "+prop);
-               ManagedObject mo = prop.getManagedObject();
-               if(mo instanceof MutableManagedObject)
-               {
-                  MutableManagedObject mmo = (MutableManagedObject) mo;
-                  mmo.setName(name);
-               }
-               else
-               {
-                  formatter.applyPattern(i18n.getString("ManagementView.InvalidTemplatePropertyMO")); //$NON-NLS-1$
-                  Object[] args = {prop.getName()};
-                  String msg = formatter.format(args);
-                  throw new IllegalArgumentException(msg);
-               }
-            }
-         }
-      }
-   
-      // Now apply the managed properties to get the deployment ManagedObjects
-      Map<String, ManagedObject> mos = mainDeployer.getManagedObjects(deploymentName);
-      log.debug("applyTemplate, deploymentBaseName="+deploymentBaseName+":"+mos);
-      // Map the 
-      String propName = info.getRootManagedPropertyName();
-      if(propName != null)
-      {
-         // Flatten out the root objects
-         ManagedObject rootMO = mos.get(deploymentName);
-         if(rootMO != null)
-            flattenRootObject(rootMO, propName, mos);
-      }
-      for(ManagedProperty prop : info.getProperties().values())
-      {
-         // Skip null values
-         if( prop.getValue() == null )
-            continue;
-   
-         ManagedObject mo = prop.getManagedObject();
-         if (mo == null)
-            throw new IllegalArgumentException("Null managed object: " + prop);
-   
-         ManagedObject ctxMO = mos.get(mo.getName());
-         if( ctxMO == null )
-         {
-            formatter.applyPattern(i18n.getString("ManagementView.InvalidTemplateKey")); //$NON-NLS-1$
-            Object[] args = {mo.getName()};
-            String msg = formatter.format(args);
-            throw new IllegalArgumentException(msg);
-         }
-         ManagedProperty ctxProp = ctxMO.getProperty(prop.getName());
-         // Check for a mapped name
-         if( ctxProp == null )
-         {
-            String mappedName = prop.getMappedName();
-            if( mappedName != null )
-               ctxProp = ctxMO.getProperty(mappedName);
-         }
-         if( ctxProp == null )
-         {
-            formatter.applyPattern(i18n.getString("ManagementView.InvalidTemplateProperty")); //$NON-NLS-1$
-            Object[] args = {prop.getName()};
-            String msg = formatter.format(args);
-            throw new IllegalArgumentException(msg);
-         }
-         // The property value must be a MetaValue
-         Object value = prop.getValue();
-         if ((value instanceof MetaValue) == false)
-         {
-            formatter.applyPattern(i18n.getString("ManagementView.InvalidPropertyValue")); //$NON-NLS-1$
-            Object[] args = {prop.getName(), value.getClass()};
-            String msg = formatter.format(args);
-            throw new IllegalArgumentException(msg);
-         }
-         MetaValue metaValue = (MetaValue)value;
-         ctxProp.setValue(metaValue);
-   
-         // todo - should this also dispatch to runtime component?
-         Object componentName = getComponentName(ctxProp);
-         if (componentName != null)
-            dispatcher.set(componentName, ctxProp.getName(), metaValue);
-      }
+      // Process the deployment
+      ManagedDeployment md = getMainDeployer().getManagedDeployment(deploymentName);
+      processManagedDeployment(md, getDefaulProfiletKey(), 0, log.isTraceEnabled());
    }
    
    public void process() throws DeploymentException
@@ -1160,12 +1066,15 @@
       {
          // Look at the children
          // TODO - support more levels of nested deployments ?
-         for(ManagedDeployment child : compMD.getChildren())
+         if(compMD.getChildren() != null && compMD.getChildren().isEmpty() == false)
          {
-            if(serverComp != null)
-               break;
-            
-            serverComp = child.getComponent(comp.getName());
+            for(ManagedDeployment child : compMD.getChildren())
+            {
+               if(serverComp != null)
+                  break;
+               
+               serverComp = child.getComponent(comp.getName());
+            }            
          }
       }
       if(serverComp == null)
@@ -1217,8 +1126,11 @@
             String msg = formatter.format(args);
             throw new IllegalArgumentException(msg);
          }
+         // Update the serverComp
          MetaValue metaValue = (MetaValue)value;
+         ctxProp.setField(Fields.META_TYPE, metaValue.getMetaType());
          ctxProp.setValue(metaValue);
+         
          // Dispatch any runtime component property values
          Object componentName = getComponentName(ctxProp);
          ActivationPolicy policy = ctxProp.getActivationPolicy();
@@ -1234,7 +1146,62 @@
    
    public void removeComponent(ManagedComponent comp) throws Exception
    {
-      // FIXME
+      //
+      ManagedDeployment md = comp.getDeployment();
+
+      // Get the parent
+      while( md.getParent() != null )
+         md = md.getParent();
+         
+      String name = md.getName();
+      ProfileDeployment profileDeployment = getProfileDeployment(name);
+      if( profileDeployment == null )
+      {
+         formatter.applyPattern(i18n.getString("ManagementView.NoSuchDeploymentException")); //$NON-NLS-1$
+         Object[] args = {name};
+         String msg = formatter.format(args);
+         throw new NoSuchDeploymentException(msg);
+      }
+      
+      // Apply the managed properties to the server ManagedDeployment/ManagedComponent
+      ManagedDeployment compMD = managedDeployments.get(md.getName());
+      log.debug("updateComponent, deploymentName="+name+": "+compMD);
+      
+      ManagedComponent serverComp = null;
+      // Find the managed component again
+      if(comp.getDeployment().getParent() == null)
+      {
+         serverComp = compMD.getComponent(comp.getName());
+      }
+      else
+      {
+         // Look at the children
+         // TODO - support more levels of nested deployments ?
+         if(compMD.getChildren() != null && compMD.getChildren().isEmpty() == false)
+         {
+            for(ManagedDeployment child : compMD.getChildren())
+            {
+               if(serverComp != null)
+                  break;
+               
+               serverComp = child.getComponent(comp.getName());
+            }            
+         }
+      }
+      if(serverComp == null)
+      {
+         log.debug("Name: "+comp.getName()+" does not map to existing ManagedComponet in ManagedDeployment: "+md.getName()
+               + ", components: "+compMD.getComponents());
+         formatter.applyPattern(i18n.getString("ManagementView.InvalidComponentName")); //$NON-NLS-1$
+         Object[] args = {comp.getName(), md.getName()};
+         String msg = formatter.format(args);
+         throw new IllegalArgumentException(msg);
+      }
+      
+      //
+      log.debug("remove component: " + comp + ", deployment: "+ profileDeployment);
+      // Remove
+      this.store.removeComponent(profileDeployment, serverComp);
    }
 
    /**
@@ -1434,43 +1401,6 @@
       return opProxies;
    }
 
-   /**
-    * Take the root managed object and the associated deployment unit
-    * managed object map, and look to the root MO for a collection type
-    * managed property named rootProperty to which the template property
-    * map.
-    * 
-    * @param rootMO
-    * @param rootProperty
-    * @param managedObjects
-    */
-   private void flattenRootObject(ManagedObject rootMO, String rootProperty,
-         Map<String,ManagedObject> managedObjects)
-   {
-      ManagedProperty deployments = rootMO.getProperty(rootProperty);
-      MetaType propType = deployments.getMetaType();
-      if (propType.isCollection())
-      {
-         CollectionMetaType amt = (CollectionMetaType) propType;
-         MetaType etype = amt.getElementType();
-         if (etype == AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE)
-         {
-            CollectionValue avalue = (CollectionValue) deployments.getValue();
-            if(avalue != null)
-            {
-               MetaValue[] elements = avalue.getElements();
-               for(int n = 0; n < avalue.getSize(); n ++)
-               {
-                  GenericValue gv = (GenericValue) elements[n];
-                  ManagedObject propMO = (ManagedObject) gv.getValue();
-                  if(propMO != null)
-                     managedObjects.put(propMO.getName(), propMO);
-               }
-            }
-         }
-      }
-   }
-
    public class ManagedOperationDelegate implements ManagedOperation
    {
       private static final long serialVersionUID = -775240509110032859L;
@@ -1534,9 +1464,15 @@
       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 = this.deploymentsToProfile.get(name);
+      ProfileKey key = getProfileKeyForDeployemnt(name);
       if(key == null)
          throw new NoSuchDeploymentException("No associated profile found for deployment:" + name);
       

Deleted: trunk/profileservice/src/main/org/jboss/profileservice/management/templates/DsXmlDataSourceTemplate.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/templates/DsXmlDataSourceTemplate.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/templates/DsXmlDataSourceTemplate.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -1,219 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.profileservice.management.templates;
-
-import java.io.File;
-import java.io.FileWriter;
-import java.util.Map;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.jboss.deployers.spi.management.DeploymentTemplate;
-import org.jboss.deployers.vfs.spi.client.VFSDeployment;
-import org.jboss.logging.Logger;
-import org.jboss.managed.api.DeploymentTemplateInfo;
-import org.jboss.managed.api.ManagedProperty;
-import org.jboss.metatype.api.types.CompositeMetaType;
-import org.jboss.metatype.api.values.CompositeValue;
-import org.jboss.metatype.api.values.SimpleValue;
-import org.jboss.util.xml.DOMWriter;
-import org.jboss.virtual.VFS;
-import org.jboss.virtual.VirtualFile;
-import org.w3c.dom.DOMImplementation;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Text;
-
-/**
- * A template for creating a datasource(*-ds.xml) deployments.
- * 
- * @author Scott.Stark at jboss.org
- * @author adrian at jboss.org
- * @version $Revision$
- */
-public class DsXmlDataSourceTemplate
-   implements DeploymentTemplate
-{
-   /** The logger. */
-   private static final Logger log = Logger.getLogger(DsXmlDataSourceTemplate.class);
-   
-   /** The file suffix. */
-   private static final String FILE_SUFFIX = "-ds.xml";
-   
-   /** The deployment template info. */
-   private DeploymentTemplateInfo info;
-
-   public String getDeploymentName(String deploymentBaseName)
-   {
-      if(deploymentBaseName == null)
-         throw new IllegalArgumentException("Null base name.");
-      
-      if(deploymentBaseName.endsWith(FILE_SUFFIX) == false)
-         deploymentBaseName = deploymentBaseName + FILE_SUFFIX;
-      
-      return deploymentBaseName;
-   }
-   
-   /**
-    * Creates a root/{deploymentBaseName}-ds.xml base descriptor.
-    */
-   public VirtualFile applyTemplate(VirtualFile root, String deploymentBaseName,
-         DeploymentTemplateInfo values)
-      throws Exception
-   {
-      return applyTemplate(values);
-   }
-
-   public VirtualFile applyTemplate(DeploymentTemplateInfo values) throws Exception
-   {
-      // Create a temp file
-      File dsXml = File.createTempFile(getClass().getSimpleName(), FILE_SUFFIX);
-      // Write template
-      writeTemplate(dsXml, values);
-      // Return virtual file
-      return VFS.getRoot(dsXml.toURI());
-   }
-   
-   /**
-    * There is no update of the ctx by this template since the data model
-    * is driven from the descriptor created by applyTemplate.
-    * 
-    * @param ctx - the DeploymentContext to associate metadata to
-    * @param values - the managed property values passed to apply.
-    */
-   public void updateTemplateDeployment(VFSDeployment ctx,
-         DeploymentTemplateInfo values)
-      throws Exception
-   {
-   }
-
-   public DeploymentTemplateInfo getInfo()
-   {
-      return info;
-   }
-   public void setInfo(DeploymentTemplateInfo info)
-   {
-      this.info = info;
-   }
-
-   protected void writeTemplate(File dsXml, DeploymentTemplateInfo values)
-      throws Exception
-   {
-      FileWriter fw = new FileWriter(dsXml);
-      fw.write("<datasources>\n");
-      Map<String, ManagedProperty> properties = values.getProperties();
-      // Get the datasource-type
-      ManagedProperty dsType = properties.get("datasource-type");
-      if( dsType == null || dsType.getValue() == null )
-         throw new IllegalStateException("Required datasource-type value not found");
-      fw.write('<');
-      fw.write(dsType.getValue().toString());
-      fw.write(">\n");
-
-      // All other properties are simple text child elements
-      for(ManagedProperty p : properties.values())
-      {
-         String tagName = p.getName();
-         if( tagName.equals("datasource-type") )
-            continue;
-         if( p.isMandatory() && p.getValue() == null )
-            throw new IllegalStateException("Required "+tagName+" value not found");
-         fw.write("  <");
-         fw.write(tagName);
-         fw.write('>');
-         // Except for connection-properties
-         if( p.getMetaType() instanceof CompositeMetaType )
-         {
-            CompositeValue cvalue = (CompositeValue) p.getValue();
-            for(String key : cvalue.getMetaType().keySet())
-            {
-               if( cvalue.containsKey(key) )
-               {
-                  SimpleValue svalue = (SimpleValue) cvalue.get(key);
-                  String string = svalue.toString();
-                  fw.write("  <");
-                  fw.write(key);
-                  fw.write('>');
-                  fw.write(string);
-                  fw.write("</");
-                  fw.write(tagName);
-                  fw.write(">\n");                  
-               }
-            }
-         }
-         else
-         {
-            Object value = p.getValue();
-            if( value == null )
-               value = "";
-            fw.write(value.toString());
-            fw.write("</");
-            fw.write(tagName);
-            fw.write(">\n");
-         }
-      }
-      // close dsType tag
-      fw.write("</");
-      fw.write(dsType.getValue().toString());
-      fw.write(">\n");
-      fw.write("</datasources>\n");
-      fw.flush();
-      fw.close();
-   }
-
-   protected Document buildDocument(DeploymentTemplateInfo values)
-      throws Exception
-   {
-      Document document = null;
-      DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
-      DocumentBuilder builder = factory.newDocumentBuilder();
-      DOMImplementation impl = builder.getDOMImplementation();
-      document = impl.createDocument(null, null, null);
-      Element ds = document.createElement("datasources");
-      document.appendChild(ds);
-      Map<String, ManagedProperty> properties = values.getProperties();
-      // datasource-type
-      ManagedProperty dsType = properties.get("datasource-type");
-      if( dsType == null || dsType.getValue() == null )
-         throw new IllegalStateException("Required datasource-type value not found");
-      Element dsTypeElem = document.createElement(dsType.getValue().toString());
-      ds.appendChild(dsTypeElem);
-      // All other
-      for(ManagedProperty p : properties.values())
-      {
-         String tagName = p.getName();
-         if( tagName.equals("datasource-type") )
-            continue;
-         if( p.isMandatory() && p.getValue() == null )
-            throw new IllegalStateException("Required "+tagName+" value not found");
-         Element element = document.createElement(tagName);
-         Text t = document.createTextNode(p.getValue().toString());
-         element.appendChild(t);
-         dsTypeElem.appendChild(element);
-      }
-
-      log.debug("Updated metadata to: "+DOMWriter.printNode(document, true));
-      return document;
-   }
-
-}

Deleted: trunk/profileservice/src/main/org/jboss/profileservice/management/templates/DsXmlDataSourceTemplateInfo.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/templates/DsXmlDataSourceTemplateInfo.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/templates/DsXmlDataSourceTemplateInfo.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -1,170 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.profileservice.management.templates;
-
-import java.util.HashSet;
-import java.util.Map;
-
-import org.jboss.managed.api.Fields;
-import org.jboss.managed.plugins.BasicDeploymentTemplateInfo;
-import org.jboss.managed.plugins.DefaultFieldsImpl;
-import org.jboss.managed.plugins.ManagedObjectImpl;
-import org.jboss.managed.plugins.ManagedPropertyImpl;
-import org.jboss.metatype.api.types.CompositeMetaType;
-import org.jboss.metatype.api.types.ImmutableCompositeMetaType;
-import org.jboss.metatype.api.types.MetaType;
-import org.jboss.metatype.api.types.SimpleMetaType;
-import org.jboss.metatype.api.values.MetaValue;
-import org.jboss.metatype.api.values.SimpleValueSupport;
-
-/**
- * The properties used by the DsXmlDataSourceTemplate.
- * 
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public class DsXmlDataSourceTemplateInfo extends BasicDeploymentTemplateInfo
-{
-   private static final long serialVersionUID = 1;
-   private Map<String, String> propertyNameMappings;
-   private String attachmentName;
-   private String dsTypeAttachmentName;
-
-   public DsXmlDataSourceTemplateInfo(String name, String description, String attachmentName)
-   {
-      this(name, description, attachmentName, attachmentName);
-   }
-   public DsXmlDataSourceTemplateInfo(String name, String description,
-         String attachmentName, String dsTypeAttachmentName)
-   {
-      super(name, description);
-      this.attachmentName = attachmentName;
-      this.dsTypeAttachmentName = dsTypeAttachmentName;
-   }
-
-   public Map<String, String> getPropertyNameMappings()
-   {
-      return propertyNameMappings;
-   }
-   public void setPropertyNameMappings(Map<String, String> propertyNameMappings)
-   {
-      this.propertyNameMappings = propertyNameMappings;
-   }
-
-   public void start()
-   {
-      populate();
-   }
-
-   protected void populate()
-   {
-      ManagedObjectImpl mo = new ManagedObjectImpl(attachmentName);
-      // The jndi name field info
-      DefaultFieldsImpl f0 = new DefaultFieldsImpl();
-      setFieldName("jndi-name", f0);
-      f0.setDescription("The jndi name to bind the DataSource under");
-      f0.setMandatory(true);
-      f0.setMetaType(SimpleMetaType.STRING);
-      ManagedPropertyImpl jndiName = new ManagedPropertyImpl(mo, f0);
-      super.addProperty(jndiName);
-      // The connection-url field info
-      DefaultFieldsImpl f1 = new DefaultFieldsImpl();
-      setFieldName("connection-url", f1);
-      f1.setDescription("The jdbc url of the DataSource");
-      f1.setMandatory(true);
-      f1.setMetaType(SimpleMetaType.STRING);
-      ManagedPropertyImpl conURL = new ManagedPropertyImpl(mo, f1);
-      super.addProperty(conURL);
-      // The user field info
-      DefaultFieldsImpl f2 = new DefaultFieldsImpl();
-      setFieldName("user-name", f2);
-      f2.setDescription("The username for the connection-url");
-      f2.setMandatory(false);
-      f2.setMetaType(SimpleMetaType.STRING);
-      ManagedPropertyImpl user = new ManagedPropertyImpl(mo, f2);
-      super.addProperty(user);
-      // The password field info
-      DefaultFieldsImpl f3 = new DefaultFieldsImpl();
-      setFieldName("password", f3);
-      f3.setDescription("The password for the connection-url");
-      f3.setMandatory(false);
-      f3.setMetaType(SimpleMetaType.STRING);
-      ManagedPropertyImpl password = new ManagedPropertyImpl(mo, f3);
-      super.addProperty(password);
-      // The security-domain field info   
-      DefaultFieldsImpl f4 = new DefaultFieldsImpl();
-      setFieldName("security-domain", f4);
-      f4.setDescription("The security-domain used to validate connections");
-      f4.setMandatory(false);
-      f4.setMetaType(SimpleMetaType.STRING);
-      ManagedPropertyImpl secDomain = new ManagedPropertyImpl(mo, f4);
-      super.addProperty(secDomain);
-      // The driver-class field info
-      DefaultFieldsImpl f5 = new DefaultFieldsImpl();
-      setFieldName("driver-class", f5);
-      f5.setDescription("The jdbc driver class name");
-      f5.setMandatory(true);
-      f5.setMetaType(SimpleMetaType.STRING);
-      ManagedPropertyImpl driverClass = new ManagedPropertyImpl(mo, f5);
-      super.addProperty(driverClass);
-      // The driver connection properties field info
-      DefaultFieldsImpl f6 = new DefaultFieldsImpl();
-      setFieldName("connection-properties", f6);
-      f6.setDescription("The jdbc driver connection properties");
-      f6.setMandatory(false);
-      String[] itemNames = {"conn-prop1", "conn-prop2"};
-      String[] itemDescriptions = {"conn-prop1 description", "conn-prop2 description"};
-      MetaType[] itemTypes = {SimpleMetaType.STRING, SimpleMetaType.STRING};
-      CompositeMetaType propsType = new ImmutableCompositeMetaType("java.lang.Properties", "DS connection properties",
-            itemNames, itemDescriptions, itemTypes);
-      f6.setMetaType(propsType);
-      ManagedPropertyImpl connProps = new ManagedPropertyImpl(mo, f6);
-      super.addProperty(connProps);
-
-      // The type of the datasource
-      ManagedObjectImpl mo2 = new ManagedObjectImpl(dsTypeAttachmentName);
-      DefaultFieldsImpl f21 = new DefaultFieldsImpl();
-      setFieldName("datasource-type", f21);
-      f21.setDescription("The type of the DataSource");
-      f21.setMandatory(true);
-      f21.setValue(SimpleValueSupport.wrap("local-tx-datasource"));
-      HashSet<MetaValue> values = new HashSet<MetaValue>();
-      values.add(SimpleValueSupport.wrap("local-tx-datasource"));
-      values.add(SimpleValueSupport.wrap("no-tx-datasource"));
-      values.add(SimpleValueSupport.wrap("xa-datasource"));
-      f21.setLegalValues(values);
-      f21.setMetaType(SimpleMetaType.STRING);
-      ManagedPropertyImpl dsType = new ManagedPropertyImpl(mo2, f21);
-      super.addProperty(dsType);
-   }
-
-   protected void setFieldName(String name, Fields f)
-   {
-      f.setField(Fields.NAME, name);
-      if( propertyNameMappings != null )
-      {
-         String mappedName = propertyNameMappings.get(name);
-         if( mappedName != null )
-            f.setField(Fields.MAPPED_NAME, mappedName);
-      }
-   }
-}

Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/upload/AbstractTransientProfileManager.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/upload/AbstractTransientProfileManager.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/upload/AbstractTransientProfileManager.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -21,16 +21,18 @@
  */ 
 package org.jboss.profileservice.management.upload;
 
-import java.util.ArrayList;
+import java.net.URI;
+import java.util.Collection;
+import java.util.Collections;
 
 import org.jboss.logging.Logger;
+import org.jboss.profileservice.spi.ModificationInfo;
+import org.jboss.profileservice.spi.MutableProfile;
 import org.jboss.profileservice.spi.Profile;
-import org.jboss.profileservice.spi.ProfileFactory;
+import org.jboss.profileservice.spi.ProfileDeployment;
 import org.jboss.profileservice.spi.ProfileKey;
 import org.jboss.profileservice.spi.ProfileService;
-import org.jboss.profileservice.spi.metadata.ProfileMetaData;
-import org.jboss.system.server.profile.repository.metadata.BasicProfileMetaData;
-import org.jboss.system.server.profile.repository.metadata.ImmutableProfileSourceMetaData;
+import org.jboss.system.server.profile.repository.AbstractImmutableProfile;
 
 /**
  * The AbstractTransientProfileManager maintains a profile for transient deployments.
@@ -50,9 +52,6 @@
    /** The transient profile key. */
    public static final ProfileKey TRANSIENT_PROFILE_KEY = new ProfileKey(TRANSIENT_PROFILE_NAME);
    
-   /** The profile factory. */
-   private ProfileFactory profileFactory;
-   
    /** The profile service. */
    protected ProfileService ps;
    
@@ -68,16 +67,6 @@
    {
       this.ps = ps;
    }
-   
-   public ProfileFactory getProfileFactory()
-   {
-      return profileFactory;
-   }
-   
-   public void setProfileFactory(ProfileFactory profileFactory)
-   {
-      this.profileFactory = profileFactory;
-   }
 
    /**
     * Start registers and activates the transient deployments profile
@@ -88,8 +77,6 @@
    {
       if(this.ps == null)
          throw new IllegalStateException("Null profile service.");
-      if(this.profileFactory == null)
-         throw new IllegalStateException("Null profile factory.");
       
       // Create the transient deployment profile
       Profile profile = createTransientProfile();
@@ -99,6 +86,7 @@
       {
          log.debug("activating transient profile " + TRANSIENT_PROFILE_NAME);
          this.ps.activateProfile(TRANSIENT_PROFILE_KEY);
+         this.ps.validateProfile(TRANSIENT_PROFILE_KEY);
       }
    }
    
@@ -137,26 +125,35 @@
     */
    protected Profile createTransientProfile() throws Exception
    {
-      ProfileMetaData metaData = createTransientProfileMetaData();
-      return profileFactory.createProfile(TRANSIENT_PROFILE_KEY, metaData);
+      return new TransientDeploymentProfile(TRANSIENT_PROFILE_KEY);
    }
    
    /**
-    * Create the transient profile meta data.
-    * 
-    * @return the transient profile meta data
+    * The transient deployments profile. 
     */
-   protected ProfileMetaData createTransientProfileMetaData()
+   public static class TransientDeploymentProfile extends AbstractImmutableProfile implements MutableProfile
    {
-      // Source
-      ImmutableProfileSourceMetaData source = new ImmutableProfileSourceMetaData();
-      source.setSources(new ArrayList<String>());
-      // Profile
-      BasicProfileMetaData profile = new BasicProfileMetaData();
-      profile.setSource(source);
-      profile.setName(TRANSIENT_PROFILE_NAME);
-      //
-      return profile;
+      public TransientDeploymentProfile(ProfileKey key)
+      {
+         super(key, new URI[0]);
+      }
+
+      public void addDeployment(ProfileDeployment deployment) throws Exception
+      {
+         if(deployment == null)
+            throw new IllegalArgumentException("Null deployment.");
+         super.addDeployment(deployment.getName(), deployment);
+      }
+
+      public void enableModifiedDeploymentChecks(boolean flag)
+      {
+         //
+      }
+
+      public Collection<ModificationInfo> getModifiedDeployments() throws Exception
+      {
+         return Collections.emptySet();
+      }
    }
    
 }

Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentManagerImpl.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentManagerImpl.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentManagerImpl.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -25,7 +25,6 @@
 import java.text.MessageFormat;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.HashSet;
 import java.util.List;
 import java.util.Locale;
 import java.util.ResourceBundle;
@@ -38,9 +37,8 @@
 import org.jboss.profileservice.management.upload.remoting.StreamingDeploymentTarget;
 import org.jboss.profileservice.spi.MutableProfile;
 import org.jboss.profileservice.spi.NoSuchProfileException;
-import org.jboss.profileservice.spi.Profile;
 import org.jboss.profileservice.spi.ProfileKey;
-import org.jboss.profileservice.spi.ProfileService;
+import org.jboss.profileservice.spi.ProfileRepository;
 import org.jboss.remoting.InvokerLocator;
 
 /**
@@ -57,10 +55,10 @@
    
    /** The bundle name. */
    private static final String BUNDLE_NAME = "org.jboss.profileservice.management.upload.messages"; //$NON-NLS-1$
+
+   /** The profile repository. */
+   private ProfileRepository profileRepository;
    
-   /** The profile service. */
-   private ProfileService ps;
-   
    /** The default profile key to upload contents. */
    private ProfileKey defaultKey;
    /** The loaded profile key. */
@@ -94,13 +92,14 @@
       this.defaultKey = defaultKey;
    }
    
-   public ProfileService getProfileService()
+   public ProfileRepository getProfileRepository()
    {
-      return this.ps;
+      return profileRepository;
    }
-   public void setProfileService(ProfileService ps)
+   
+   public void setProfileRepository(ProfileRepository profileRepository)
    {
-      this.ps = ps;
+      this.profileRepository = profileRepository;
    }
 
    public InvokerLocator getLocator()
@@ -122,29 +121,11 @@
    }
 
    /**
-    * Get the mutable profile keys.
+    * Get the available profiles with a DeploymentRepository.
     */
    public Collection<ProfileKey> getProfiles()
    {
-      Collection<ProfileKey> mutableProfiles = new HashSet<ProfileKey>(); 
-      for( ProfileKey key : this.ps.getActiveProfileKeys())
-      {
-         // Exclude the transient profile
-         if(key.equals(AbstractTransientProfileManager.TRANSIENT_PROFILE_KEY))
-            continue;
-         
-         try
-         {
-            Profile profile = this.ps.getActiveProfile(key);
-            if(profile.isMutable())
-               mutableProfiles.add(key);
-         }
-         catch(NoSuchProfileException ignore)
-         {
-            //
-         }
-      }
-      return mutableProfiles; 
+      return new ArrayList<ProfileKey>(this.profileRepository.getProfileKeys()); 
    }
    
    public DeploymentProgress distribute(String name, URL contentURL)
@@ -184,15 +165,8 @@
    
    public boolean isRedeploySupported()
    {
-      // TODO
-      return false;
+      return (getTargetProfile() instanceof MutableProfile);
    }
-
-   public boolean isRedeploySupported(ProfileKey key) throws NoSuchProfileException
-   {
-      // FIXME
-      return false;
-   }
    
    public void loadProfile(ProfileKey key) throws NoSuchProfileException
    {
@@ -200,11 +174,11 @@
       if(key.isDefaultKey() && this.defaultKey != null)
          key = this.defaultKey;
       
-      // Get the mutable profile
-      MutableProfile profile = getProfile(key);
+      // Check if we have a associated DeploymentRepository
+      checkProfile(key);
       
       // Set the key
-      this.activeProfileKey = profile.getKey();      
+      this.activeProfileKey = key;      
    }
    
    public void releaseProfile()
@@ -278,23 +252,21 @@
    }
 
    /**
-    * Get a mutable profile
+    * Check if the Profile has a associated DeploymentRepository.
+    * This will be needed by the DeployHandler to add the deployment content.
     * 
     * @param key the profile key
-    * @return the mutable profile
     * @throws NoSuchProfileException if the profile does not exist or is not mutable
     */
-   public MutableProfile getProfile(ProfileKey key) throws NoSuchProfileException
+   public void checkProfile(ProfileKey key) throws NoSuchProfileException
    {
-      Profile profile = this.ps.getActiveProfile(key);
-      if(profile.isMutable() == false)
+      if(getProfiles().contains(key) == false)
       {
          formatter.applyPattern(i18n.getString("DeploymentManager.NoMutableProfileException")); //$NON-NLS-1$
-         Object[] args = {};
+         Object[] args = { key };
          String msg = formatter.format(args);
          throw new NoSuchProfileException(msg);
       }
-      return (MutableProfile) profile;
    }
    
    /**

Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentProgressImpl.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentProgressImpl.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentProgressImpl.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -81,6 +81,9 @@
          case DISTRIBUTE:
             distribute();
             break;
+         case PREPARE:
+            prepare();
+            break;
          case START:
             start();
             break;
@@ -90,6 +93,9 @@
          case REMOVE:
             remove();
             break;
+         case REDEPLOY:
+            redeploy();
+            break;
          default:
             throw new IllegalStateException(command+" is not currently handled");
       }
@@ -332,4 +338,94 @@
          }
       }
    }
+   
+   protected void redeploy()
+   {
+      SerializableDeploymentStatus status = new SerializableDeploymentStatus(command, StateType.RUNNING);
+      status.setMessage("Running redeploy to: "+targets);
+      currentStatus = status;
+      ProgressEvent event =  new ProgressEvent(deployment, currentStatus);
+      notify(event);
+      for(DeploymentTarget target : targets)
+      {
+         if(isCancelled)
+         {
+            status = new SerializableDeploymentStatus(command, StateType.CANCELLED);
+            status.setMessage("Redeploy has been cancelled");
+            currentStatus = status;
+            event =  new ProgressEvent(deployment, currentStatus);
+            notify(event);
+            break;
+         }
+
+         try
+         {
+            target.redeploy(deployment);
+            status = new SerializableDeploymentStatus(command, StateType.COMPLETED);
+            status.setTarget(target);
+            status.setMessage("Completed redeploy for target: "+target);
+            status.setCompleted(true);
+            status.setRunning(true);
+            currentStatus = status;
+            event =  new ProgressEvent(deployment, currentStatus);
+            notify(event);
+         }
+         catch(Exception e)
+         {
+            status = new SerializableDeploymentStatus(command, StateType.FAILED);
+            status.setTarget(target);
+            status.setFailure(e);
+            status.setFailed(true);
+            currentStatus = status;
+            ProgressEvent error = new ProgressEvent(deployment, currentStatus);
+            notify(error);
+            break;
+         }
+      }
+   }
+   
+   protected void prepare()
+   {
+      SerializableDeploymentStatus status = new SerializableDeploymentStatus(command, StateType.RUNNING);
+      status.setMessage("Running prepare to: "+targets);
+      currentStatus = status;
+      ProgressEvent event =  new ProgressEvent(deployment, currentStatus);
+      notify(event);
+      for(DeploymentTarget target : targets)
+      {
+         if(isCancelled)
+         {
+            status = new SerializableDeploymentStatus(command, StateType.CANCELLED);
+            status.setMessage("Prepare has been cancelled");
+            currentStatus = status;
+            event =  new ProgressEvent(deployment, currentStatus);
+            notify(event);
+            break;
+         }
+
+         try
+         {
+            target.prepare(deployment);
+            status = new SerializableDeploymentStatus(command, StateType.COMPLETED);
+            status.setTarget(target);
+            status.setMessage("Completed prepare for target: "+target);
+            status.setCompleted(true);
+            status.setRunning(true);
+            currentStatus = status;
+            event =  new ProgressEvent(deployment, currentStatus);
+            notify(event);
+         }
+         catch(Exception e)
+         {
+            status = new SerializableDeploymentStatus(command, StateType.FAILED);
+            status.setTarget(target);
+            status.setFailure(e);
+            status.setFailed(true);
+            currentStatus = status;
+            ProgressEvent error = new ProgressEvent(deployment, currentStatus);
+            notify(error);
+            break;
+         }
+      }
+   }
 }

Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/upload/messages.properties
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/upload/messages.properties	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/upload/messages.properties	2009-04-03 12:05:06 UTC (rev 86739)
@@ -1,3 +1,4 @@
 # resource bundle for the DeploymentManager
+DeploymentManager.NoProfileLoadedException=No profile loaded.
 DeploymentManager.NoSuchProfileException=Failed to find profile for key: {0}
 DeploymentManager.NoMutableProfileException=Profile does not support deployment actions: {0}
\ No newline at end of file

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-04-03 11:43:54 UTC (rev 86738)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/AbstractDeployHandler.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -22,7 +22,9 @@
 package org.jboss.profileservice.management.upload.remoting;
 
 import java.io.InputStream;
+import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.List;
 import java.util.Map;
 
 import javax.management.MBeanServer;
@@ -30,11 +32,9 @@
 import org.jboss.aop.joinpoint.Invocation;
 import org.jboss.aop.joinpoint.InvocationResponse;
 import org.jboss.aspects.remoting.AOPRemotingInvocationHandler;
-import org.jboss.deployers.spi.DeploymentException;
 import org.jboss.deployers.spi.management.deploy.DeploymentID;
 import org.jboss.deployers.spi.management.deploy.DeploymentManager;
 import org.jboss.logging.Logger;
-import org.jboss.managed.api.ManagedDeployment.DeploymentPhase;
 import org.jboss.profileservice.management.upload.SerializableDeploymentID;
 import org.jboss.profileservice.spi.DeploymentRepository;
 import org.jboss.profileservice.spi.NoSuchProfileException;
@@ -150,8 +150,11 @@
       }
       else
       {
-         Map payload = request.getRequestPayload();
+         Map<?, ?> payload = request.getRequestPayload();
          DeploymentID dtID = (DeploymentID) payload.get("DeploymentTargetID");
+         if(dtID == null)
+            throw new IllegalStateException("Null deployment target ID.");
+         
          log.debug("invoke, payload: "+payload+", parameter: "+parameter);
          try
          {
@@ -165,6 +168,10 @@
             {
                returnValue = distribute(dtID);
             }
+            else if( parameter.equals("prepare"))
+            {
+               // TODO
+            }
             else if( parameter.equals("start") )
             {
                start(dtID);
@@ -181,7 +188,11 @@
             else if( parameter.equals("undeploy") )
             {
                remove(dtID);
-            }            
+            }
+            else if (parameter.equals("redeploy"))
+            {
+               redeploy(dtID);
+            }
          }
          catch(Exception e)
          {
@@ -199,10 +210,10 @@
    /**
     * Handle a DeploymentManager distribute invocation for copyContent == true
     * 
-    * @see DeploymentManager#distribute(String, DeploymentPhase, java.net.URL)
+    * @see DeploymentManager#distribute(String, java.net.URL, boolean)
     * @param request - the remoting invocation
     */
-   public Object handleStream(InputStream contentIS, InvocationRequest request) throws Throwable
+   public InvocationResponse handleStream(InputStream contentIS, InvocationRequest request) throws Throwable
    {
       // Get the deployment repository for this deploymentID
       SerializableDeploymentID deploymentTarget = (SerializableDeploymentID) request.getParameter();
@@ -232,35 +243,30 @@
       DeploymentRepository deploymentRepository = getDeploymentRepository(dtID);
       log.info("Begin start, "+Arrays.asList(names));
       
+      List<String> deployments = new ArrayList<String>(); 
       for(String name : names)
       {
          // Schedule start for the deployment
-         scheduleStart(name, deploymentRepository);
+         deployments.add(start(name, deploymentRepository));
       }
+      // Process
+      deployer.process();
       // CheckComplete
-      processCheckComplete();
-      log.info("End start, "+Arrays.asList(names));
+      deployer.checkComplete(
+            deployments.toArray(new String[deployments.size()]));
+      
+      log.info("End start, "+ deployments);
    }
 
-   protected void scheduleStart(String name, DeploymentRepository deploymentRepository) throws Exception
+   protected String start(String name, DeploymentRepository repository) throws Exception
    {
-      VirtualFile vf = deploymentRepository.getDeploymentContent(name);
-      scheduleStart(vf, deploymentRepository);
+      ProfileDeployment deployment = scheduleStart(name, repository);
+      deployer.addDeployment(deployment);
+      log.debug("Scheduling start for deployment: " + deployment);
+      return deployment.getName();
    }
    
-   protected void scheduleStart(VirtualFile vf, DeploymentRepository repository) throws Exception
-   {
-      // Create profile deployment
-      ProfileDeployment profileDeployment = createDeployment(vf);
-      // Add deployment to profile
-      repository.addDeployment(profileDeployment.getName(), profileDeployment);
-      // Add deployment 
-      deployer.addDeployment(profileDeployment);
-      // Unlock the contents
-      repository.unlockDeploymentContent(profileDeployment.getName());
-      
-      log.debug("Scheduling start for: "+ profileDeployment);
-   }
+   protected abstract ProfileDeployment scheduleStart(String name, DeploymentRepository deploymentRepository) throws Exception;
    
    /**
     * Stop the deployments.
@@ -274,27 +280,29 @@
       DeploymentRepository deploymentRepository = getDeploymentRepository(dtID);
       log.info("Stop, "+Arrays.asList(names));
       
+      List<String> deployments = new ArrayList<String>();
       for(String name : names)
       {
          // Schedule stop
-         scheduleStop(name, deploymentRepository);
+         deployments.add(stop(name, deploymentRepository));
       }
       // CheckComplete
-      processCheckComplete();
+      deployer.process();
+      // TODO check if there is still a deploymentContext ?
+      log.info("End stop, "+ deployments);
    }
    
-   protected void scheduleStop(String name, DeploymentRepository repository) throws Exception
+   protected String stop(String name, DeploymentRepository repository) throws Exception
    {
-      // Obtain the deployment
-      ProfileDeployment vfsd = repository.getDeployment(name);
-      // Lock the content to make it unavailable to the deployment scanner
-      repository.lockDeploymentContent(vfsd.getName());
-      // Remove deployment
-      deployer.removeDeployment(vfsd);
+      ProfileDeployment deployment = scheduleStop(name, repository);
+      deployer.removeDeployment(deployment);
+      log.debug("Scheduling stop for deployment: " + deployment);
       
-      log.debug("Scheduling stop for: "+ vfsd);
+      return deployment.getName();
    }
    
+   protected abstract ProfileDeployment scheduleStop(String name, DeploymentRepository repository) throws Exception;
+   
    /**
     * Remove a deployment from the deployment repository.
     * This will delete the file for non-transient deployments.
@@ -315,24 +323,22 @@
       }
    }
    
-   protected void removeDeployment(String name, DeploymentRepository repository) throws Exception
+   protected abstract void removeDeployment(String name, DeploymentRepository repository) throws Exception;
+
+   /**
+    * Redeploy a deployment.
+    * 
+    * @param dtID the deployment id
+    * @throws Exception for any error
+    */
+   protected void redeploy(DeploymentID dtID) throws Exception
    {
-      // Remove the deployment
-      ProfileDeployment deployment = repository.removeDeployment(name);
-      // Reset to an unlocked deployment
-      if(deployment != null)
-         repository.unlockDeploymentContent(deployment.getName());
-      log.debug("Removed: "+name);
+      // Stop
+      stop(dtID);
+      // Start
+      start(dtID);
    }
    
-   protected void processCheckComplete() throws DeploymentException
-   {
-      // Process
-      deployer.process();
-      // And checkComplete
-      deployer.checkComplete();
-   }
-   
    /**
     * Create a profile deployment.
     * 

Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/DeployHandler.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/DeployHandler.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/DeployHandler.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -33,6 +33,9 @@
 import org.jboss.logging.Logger;
 import org.jboss.profileservice.management.upload.AbstractTransientProfileManager;
 import org.jboss.profileservice.spi.DeploymentRepository;
+import org.jboss.profileservice.spi.MutableProfile;
+import org.jboss.profileservice.spi.ProfileDeployment;
+import org.jboss.profileservice.spi.ProfileService;
 import org.jboss.virtual.VFS;
 import org.jboss.virtual.VirtualFile;
 
@@ -49,21 +52,29 @@
    /** The logger. */
    static final Logger log = Logger.getLogger(DeployHandler.class);
 
-   /** The transient deployment repository. */
-   private DeploymentRepository transientDeploymentRepository;
+   /** The transient profile. */
+   private MutableProfile transientProfile;
    
+   /** The profile service. */
+   private ProfileService ps;
+   
    /** The transient deployments map. */
-   Map<String, VirtualFile> transientDeployments = new ConcurrentHashMap<String, VirtualFile>();
+   private Map<String, VirtualFile> transientDeployments = new ConcurrentHashMap<String, VirtualFile>();
    
-   public DeploymentRepository getTransientDeploymentRepository()
+   public ProfileService getProfileService()
    {
-      return transientDeploymentRepository;
+      return ps;
    }
    
+   public void setProfileService(ProfileService ps)
+   {
+      this.ps = ps;
+   }
+   
    public void start() throws Exception
    {
-      // Set the transient profile repository
-      this.transientDeploymentRepository = profileRepository.getProfileDeploymentRepository(AbstractTransientProfileManager.TRANSIENT_PROFILE_KEY);
+      // Set the transient profile
+      this.transientProfile = (MutableProfile) ps.getActiveProfile(AbstractTransientProfileManager.TRANSIENT_PROFILE_KEY);
    }
 
    @Override
@@ -78,31 +89,6 @@
       
       return repositoryNames.toArray( new String[repositoryNames.size()] );
    }
-   
-   protected List<String> getTransientRepositoryNames(String[] names)
-   {
-      List<String> repositoryNames = new ArrayList<String>();
-      for(String name : names)
-      {
-         if(this.transientDeployments.containsKey(name))
-         {
-            repositoryNames.add(name);
-            continue;
-         }
-         for(VirtualFile vf : this.transientDeployments.values())
-         {
-            if(vf.getName().equals(name))
-            {
-               try
-               {
-                  repositoryNames.add(vf.toURI().toString());
-               }
-               catch(Exception ignored) { }
-            }
-         }
-      }
-      return repositoryNames;
-   }
 
    /**
     * Distribute a transient (copyContent == false) deployment. 
@@ -128,31 +114,45 @@
    }
 
    @Override
-   protected void scheduleStart(String name, DeploymentRepository deploymentRepository) throws Exception
+   protected ProfileDeployment scheduleStart(String name, DeploymentRepository deploymentRepository) throws Exception
    {
       String deploymentName = resolveDeploymentName(name);
       if(deploymentName != null)
       {
-         VirtualFile vf = this.transientDeployments.get(name);
-         super.scheduleStart(vf, this.transientDeploymentRepository);
+         // Create deployment
+         VirtualFile vf = this.transientDeployments.get(deploymentName);
+         ProfileDeployment deployment = createDeployment(vf);
+         // Add to transient profile
+         this.transientProfile.addDeployment(deployment);
+         return deployment;
       }
       else
       {
-         super.scheduleStart(name, deploymentRepository);
+         // Create deployment
+         VirtualFile vf = deploymentRepository.getDeploymentContent(name);
+         ProfileDeployment deployment = createDeployment(vf);
+         // Add deployment repository
+         deploymentRepository.addDeployment(deployment.getName(), deployment);
+         deploymentRepository.unlockDeploymentContent(deployment.getName());
+         return deployment;
       }
    }
    
    @Override
-   protected void scheduleStop(String name, DeploymentRepository deploymentRepository) throws Exception
+   protected ProfileDeployment scheduleStop(String name, DeploymentRepository deploymentRepository) throws Exception
    {
       String deploymentName = resolveDeploymentName(name);
       if(deploymentName != null)
       {
-         super.scheduleStop(name, this.transientDeploymentRepository);
+         // Remove from profile
+         return this.transientProfile.removeDeployment(deploymentName); 
       }
       else
       {
-         super.scheduleStop(name, deploymentRepository);
+         // Lock content
+         ProfileDeployment deployment = deploymentRepository.getDeployment(name);
+         deploymentRepository.lockDeploymentContent(deployment.getName());
+         return deployment;
       }
    }
    
@@ -162,15 +162,41 @@
       String deploymentName = resolveDeploymentName(name);
       if(deploymentName != null)
       {
+         // Remove from local cache
          this.transientDeployments.remove(deploymentName);
-         super.removeDeployment(deploymentName, this.transientDeploymentRepository);
       }
       else
       {
-         super.removeDeployment(name, deploymentRepository);
+         // Remove deployment from repository
+         deploymentRepository.removeDeployment(name);
       }
    }
    
+   protected List<String> getTransientRepositoryNames(String[] names)
+   {
+      List<String> repositoryNames = new ArrayList<String>();
+      for(String name : names)
+      {
+         if(this.transientDeployments.containsKey(name))
+         {
+            repositoryNames.add(name);
+            continue;
+         }
+         for(VirtualFile vf : this.transientDeployments.values())
+         {
+            if(vf.getName().equals(name))
+            {
+               try
+               {
+                  repositoryNames.add(vf.toURI().toString());
+               }
+               catch(Exception ignored) { }
+            }
+         }
+      }
+      return repositoryNames;
+   }
+   
    /**
     * Try to resolve the deployment name.
     * 

Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/StreamingDeploymentTarget.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/StreamingDeploymentTarget.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/StreamingDeploymentTarget.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -137,14 +137,34 @@
       }
    }
 
-   public void redeploy(DeploymentID deployment) throws Exception
+   public void redeploy(DeploymentID dtID) throws Exception
    {
-      throw new IllegalStateException("redeploy is not yet implemented");
+      Client client = getClient();
+      try
+      {
+         log.debug("Begin redeploy: " + dtID);
+         invoke(client, "redeploy", createArgs(dtID));
+         log.debug("End redeploy: "+dtID);
+      }
+      finally
+      {
+         client.disconnect();
+      }
    }
 
-   public void prepare(DeploymentID deployment) throws Exception
+   public void prepare(DeploymentID dtID) throws Exception
    {
-      throw new IllegalStateException("prepare is not yet implemented");
+      Client client = getClient();
+      try
+      {
+         log.debug("Begin prepare: " + dtID);
+         invoke(client, "prepare", createArgs(dtID));
+         log.debug("End prepare: "+dtID);
+      }
+      finally
+      {
+         client.disconnect();
+      }
    }
 
    /**
@@ -205,9 +225,9 @@
       Client client = getClient();
       try
       {
-         log.debug("Begin undeploy: " + dtID);
-         invoke(client, "undeploy", createArgs(dtID));
-         log.debug("End undeploy");
+         log.debug("Begin remove: " + dtID);
+         invoke(client, "remove", createArgs(dtID));
+         log.debug("End remove");
       }
       finally
       {

Modified: trunk/profileservice/src/resources/hdscanner-jboss-beans.xml
===================================================================
--- trunk/profileservice/src/resources/hdscanner-jboss-beans.xml	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/profileservice/src/resources/hdscanner-jboss-beans.xml	2009-04-03 12:05:06 UTC (rev 86739)
@@ -8,12 +8,11 @@
 <deployment xmlns="urn:jboss:bean-deployer:2.0">
 
     <!-- Hotdeployment of applications -->
-    <bean name="HDScanner"
-        class="org.jboss.system.server.profileservice.hotdeploy.HDScanner">
+    <bean name="HDScanner" class="org.jboss.system.server.profileservice.hotdeploy.HDScanner">
         <property name="deployer"><inject bean="ProfileServiceDeployer"/></property>
-        <property name="controller"><inject bean="jboss.kernel:service=KernelController"/></property>
         <property name="profileService"><inject bean="ProfileService"/></property>
         <property name="scanPeriod">5000</property>
         <property name="scanThreadName">HDScanner</property>
     </bean>
+
 </deployment>

Modified: trunk/profileservice/src/resources/profileservice-jboss-beans.xml
===================================================================
--- trunk/profileservice/src/resources/profileservice-jboss-beans.xml	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/profileservice/src/resources/profileservice-jboss-beans.xml	2009-04-03 12:05:06 UTC (rev 86739)
@@ -88,6 +88,7 @@
             <parameter>DeploymentManager</parameter>
         </uninstall>
         <property name="deployer"><inject bean="ProfileServiceDeployer"/></property>
+        <property name="profileService"><inject bean="ProfileService"/></property>
         <property name="profileRepository"><inject bean="ProfileRepositoryFactory" /></property>
         <depends>TransientDeploymentsProfileManager</depends>
     </bean>
@@ -95,7 +96,6 @@
     <bean name="TransientDeploymentsProfileManager"
         class="org.jboss.profileservice.management.upload.AbstractTransientProfileManager">
         <property name="profileService"><inject bean="ProfileService"/></property>
-        <property name="profileFactory"><inject bean="ProfileFactory" /></property>
     </bean>
 
     <bean name="RuntimeComponentDispatcher" class="org.jboss.profileservice.management.KernelBusRuntimeComponentDispatcher">
@@ -152,7 +152,7 @@
             </parameter>
         </uninstall>
         <property name="defaultProfileKey"><inject bean="ApplicationsProfileKey"/></property>
-        <property name="profileService"><inject bean="ProfileService"/></property>
+        <property name="profileRepository"><inject bean="ProfileRepositoryFactory"/></property>
         <property name="locator"><inject bean="ConnectorMBean" property="invokerLocator"/></property>
         <property name="remotingSubsystem">DeploymentManager</property>
     </bean>

Modified: trunk/server/src/etc/conf/default/bootstrap/profile.xml
===================================================================
--- trunk/server/src/etc/conf/default/bootstrap/profile.xml	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/server/src/etc/conf/default/bootstrap/profile.xml	2009-04-03 12:05:06 UTC (rev 86739)
@@ -1,7 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
 
-<!-- 
-	The ProfileService.
+<!--
+   The profile service
+   $Id$
 -->
 <deployment xmlns="urn:jboss:bean-deployer:2.0">
 
@@ -53,8 +54,10 @@
 	</bean>
 
 	<!-- The profile factory -->
-	<bean name="ProfileFactory" class="org.jboss.system.server.profileservice.repository.AbstractProfileFactory">
-		<property name="profileRepository"><inject bean="ProfileRepositoryFactory" /></property>
+	<bean name="ProfileFactory" class="org.jboss.system.server.profileservice.repository.TypedProfileFactory">
+		<!-- Accept any AbstractprofileFactory -->
+		<incallback method="addProfileFactory" />
+		<uncallback method="removeProfileFactory" />
 	</bean>
 
 	<!-- The profile repository factory -->
@@ -65,7 +68,6 @@
 	</bean>
 
   <!-- The structure modification cache and checker -->
-
   <bean name="StructureModCache" class="org.jboss.deployers.vfs.spi.structure.modified.DefaultStructureCache">
     <destroy method="flush"/>
   </bean>
@@ -78,6 +80,11 @@
     <property name="filter"><bean class="org.jboss.system.server.profile.basic.XmlIncludeVirtualFileFilter" /></property>
   </bean>
 
+	<bean name="BasicProfileFactory" class="org.jboss.system.server.profileservice.repository.BasicProfileFactory">
+		<property name="profileRepository"><inject bean="ProfileRepositoryFactory" /></property>
+	</bean>
+	<bean name="FilteredProfileFactory" class="org.jboss.system.server.profileservice.repository.FilteredProfileFactory"/>
+
 	<!-- The default deployment repository factory -->
 	<bean name="DefaultDeploymentRepositoryFactory" class="org.jboss.system.server.profileservice.repository.DefaultDeploymentRepositoryFactory">
 		<property name="deploymentFilter"><inject bean="DeploymentFilter" /></property>
@@ -89,6 +96,7 @@
 		<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>
 	</bean>
 
 	<bean name="AttachmentsSerializer" class="org.jboss.system.server.profileservice.repository.JAXBAttachmentSerializer">

Modified: trunk/system/src/main/org/jboss/deployers/plugins/managed/BeanMetaDataICF.java
===================================================================
--- trunk/system/src/main/org/jboss/deployers/plugins/managed/BeanMetaDataICF.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/system/src/main/org/jboss/deployers/plugins/managed/BeanMetaDataICF.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -28,6 +28,7 @@
 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.builder.BeanMetaDataBuilder;
 import org.jboss.dependency.spi.ControllerContext;
 import org.jboss.kernel.spi.dependency.KernelController;
 import org.jboss.logging.Logger;
@@ -125,6 +126,23 @@
             }
          }
       }
+      // Find <annotation/> in the beans.xml 
+//      if(annotations != null)
+//      {
+//         for(AnnotationMetaData amd : annotations)
+//         {
+//            Annotation ann = amd.getAnnotationInstance();
+//            if(ann instanceof ManagementObject)
+//            {
+//               String beanClassName = attachment.getBean();
+//               ClassLoader loader = getClassLoader(attachment);
+//               mocClass = loader.loadClass(beanClassName); 
+//               log.debug("Saw ManagementObject, "+mocClass+" for bean: "+attachment);
+//               break;               
+//            }
+//         }
+//      }
+      
       // Use the bean from the metadata
       if(mocClass == null)
       {
@@ -177,6 +195,7 @@
             mvalue = delegateICF.getValue(beanInfo, property, metaData, attachment);
          else
             mvalue = delegateICF.getValue(beanInfo, property, metaData, bean);
+            
       }
       catch(Throwable e)
       {
@@ -218,7 +237,14 @@
          }
          Object plainValue = metaValueFactory.unwrap(value, propertyInfo.getType());
          Object bean = locateBean(beanName);
-         propertyInfo.set(bean, plainValue);
+         
+         // Only update if the bean is not null
+         if(bean != null)
+            propertyInfo.set(bean, plainValue);
+         
+         BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder(attachment);
+         builder.addPropertyMetaData(name, plainValue);
+         
       }
       catch(Throwable e)
       {

Modified: trunk/system/src/main/org/jboss/deployers/plugins/managed/KernelDeploymentManagedObjectCreator.java
===================================================================
--- trunk/system/src/main/org/jboss/deployers/plugins/managed/KernelDeploymentManagedObjectCreator.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/system/src/main/org/jboss/deployers/plugins/managed/KernelDeploymentManagedObjectCreator.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -116,6 +116,7 @@
          CollectionMetaType beansType = new CollectionMetaType(BeanMetaDataFactory.class.getName(), AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE);
          for(BeanMetaDataFactory bmdf : beanFactories)
          {
+            
             ManagedObject bmdfMO = mof.initManagedObject(bmdf, metaData);
             if(bmdfMO == null)
                continue;

Modified: trunk/system/src/main/org/jboss/system/server/profile/repository/AbstractImmutableProfile.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profile/repository/AbstractImmutableProfile.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/system/src/main/org/jboss/system/server/profile/repository/AbstractImmutableProfile.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -134,5 +134,26 @@
    {
       return false;
    }
+   
+   public String toString()
+   {
+      StringBuilder builder = new StringBuilder();
+      builder.append(getClass().getSimpleName());
+      builder.append('@').append(Integer.toHexString(System.identityHashCode(this)));
+      builder.append("{key = ").append(getKey());
+      toString(builder);
+      builder.append("}");
+      return builder.toString();
+   }
+   
+   /**
+    * Additional information for toString().
+    * 
+    * @param builder the builder.
+    */
+   protected void toString(StringBuilder builder)
+   {
+      //
+   }
 
 }

Modified: trunk/system/src/main/org/jboss/system/server/profile/repository/AbstractProfile.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profile/repository/AbstractProfile.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/system/src/main/org/jboss/system/server/profile/repository/AbstractProfile.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -50,7 +50,7 @@
    final private DeploymentRepository repository;
    
    /** The profile dependencies */
-   List<ProfileKey> subProfiles;
+   private List<ProfileKey> subProfiles;
    
    /** Is hot deployment checking enabled */
    private volatile boolean hotdeployEnabled = false;
@@ -132,7 +132,7 @@
    {
       if(name == null)
          throw new IllegalArgumentException("Null name.");
-      // FIXME
+
       try
       {
          return this.repository.getDeployment(name) != null;

Copied: trunk/system/src/main/org/jboss/system/server/profile/repository/NoopProfile.java (from rev 86733, branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/NoopProfile.java)
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profile/repository/NoopProfile.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/system/server/profile/repository/NoopProfile.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -0,0 +1,126 @@
+/*
+ * 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.profile.repository;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
+import org.jboss.profileservice.spi.NoSuchDeploymentException;
+import org.jboss.profileservice.spi.Profile;
+import org.jboss.profileservice.spi.ProfileDeployment;
+import org.jboss.profileservice.spi.ProfileKey;
+
+/**
+ * A empty profile, which does not contain any deployments. This profile
+ * basically just has a key and dependencies on other profiles.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class NoopProfile implements Profile
+{
+   
+   private final ProfileKey key;
+   private final long lastModified;
+   private List<ProfileKey> subProfiles;
+   
+   public NoopProfile(ProfileKey key)
+   {
+      this(key, null);
+   }
+   
+   public NoopProfile(ProfileKey key, List<ProfileKey> subProfiles)
+   {
+      this.key = key;
+      this.subProfiles = subProfiles;
+      this.lastModified = System.currentTimeMillis();
+   }
+
+   public ProfileKey getKey()
+   {
+      return this.key;
+   }
+
+   public long getLastModified()
+   {
+      return this.lastModified;
+   }
+
+   public Collection<ProfileKey> getSubProfiles()
+   {
+      return this.subProfiles;
+   }
+   
+   public void setSubProfiles(List<ProfileKey> subProfiles)
+   {
+      this.subProfiles = subProfiles;
+   }
+   
+   public Set<String> getDeploymentNames()
+   {
+      return Collections.emptySet();
+   }
+
+   public Collection<ProfileDeployment> getDeployments()
+   {
+      return Collections.emptySet();
+   }
+   
+   public ProfileDeployment getDeployment(String name) throws NoSuchDeploymentException
+   {
+      throw new NoSuchDeploymentException("This profiles does not contain any deployments.");
+   }
+
+   public boolean hasDeployment(String name)
+   {
+      return false;
+   }
+
+   public boolean isMutable()
+   {
+      return false;
+   }
+   
+   public String toString()
+   {
+      StringBuilder builder = new StringBuilder();
+      builder.append(getClass().getSimpleName());
+      builder.append('@').append(Integer.toHexString(System.identityHashCode(this)));
+      builder.append("{key = ").append(getKey());
+      toString(builder);
+      builder.append("}");
+      return builder.toString();
+   }
+   
+   /**
+    * Additional information for toString().
+    * 
+    * @param builder the builder.
+    */
+   protected void toString(StringBuilder builder)
+   {
+      //
+   }
+
+}

Modified: trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/AbstractProfileMetaData.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/AbstractProfileMetaData.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/AbstractProfileMetaData.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -27,7 +27,6 @@
 import javax.xml.bind.annotation.XmlElement;
 
 import org.jboss.profileservice.spi.metadata.ProfileMetaData;
-import org.jboss.profileservice.spi.metadata.ProfileSourceMetaData;
 import org.jboss.profileservice.spi.metadata.SubProfileMetaData;
 
 /**
@@ -48,11 +47,26 @@
    /** The doamin. */
    private String domain;
    
-   /** The profile sources. */
-   private ProfileSourceMetaData source;
-   
    /** The sub profiles. */
    private List<SubProfileMetaData> subprofiles;
+   
+   public AbstractProfileMetaData()
+   {
+      //
+   }
+   
+   public AbstractProfileMetaData(String domain, String server, String name)
+   {
+      this(domain, server, name, null);
+   }
+   
+   public AbstractProfileMetaData(String domain, String server, String name, List<SubProfileMetaData> subProfiles)
+   {
+      this.domain = domain;
+      this.server = server;
+      this.name = name;
+      this.subprofiles = subProfiles;
+   }
 
    @XmlAttribute(name = "name")
    public String getName()
@@ -87,17 +101,6 @@
       this.domain = domain;
    }
 
-   @XmlElement(name = "profile-source", type = FilteredProfileSourceMetaData.class)
-   public ProfileSourceMetaData getSource()
-   {
-      return source;
-   }
-
-   public void setSource(ProfileSourceMetaData source)
-   {
-      this.source = source;
-   }
-
    @XmlElement(name = "sub-profile", type = BasicSubProfileMetaData.class)
    public List<SubProfileMetaData> getSubprofiles()
    {

Modified: trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/AbstractProfileSourceMetaData.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/AbstractProfileSourceMetaData.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/AbstractProfileSourceMetaData.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -41,6 +41,16 @@
    /** The source. */
    private List<String> sources;
    
+   public AbstractProfileSourceMetaData()
+   {
+      //
+   }
+   
+   public AbstractProfileSourceMetaData(List<String> sources)
+   {
+      this.sources = sources;
+   }
+   
    @XmlTransient
    public String getType()
    {

Modified: trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/BasicProfileDeploymentMetaData.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/BasicProfileDeploymentMetaData.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/BasicProfileDeploymentMetaData.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -26,6 +26,8 @@
 import org.jboss.profileservice.spi.metadata.ProfileDeploymentMetaData;
 
 /**
+ * A basic ProfileDeployment meta data implementation.
+ * 
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
  * @version $Revision$
  */
@@ -35,6 +37,16 @@
    /** The deployment name. */
    private String name;
    
+   public BasicProfileDeploymentMetaData()
+   {
+      //
+   }
+   
+   public BasicProfileDeploymentMetaData(String name)
+   {
+      this.name = name;
+   }
+   
    @XmlValue
    public String getName()
    {
@@ -45,5 +57,6 @@
    {
       this.name = name;
    }
+   
 }
 

Modified: trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/BasicProfileMetaData.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/BasicProfileMetaData.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/BasicProfileMetaData.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -26,6 +26,8 @@
 import javax.xml.bind.annotation.XmlElement;
 
 import org.jboss.profileservice.spi.metadata.ProfileDeploymentMetaData;
+import org.jboss.profileservice.spi.metadata.ProfileSourceMetaData;
+import org.jboss.profileservice.spi.metadata.SubProfileMetaData;
 
 /**
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
@@ -34,9 +36,38 @@
 public class BasicProfileMetaData extends AbstractProfileMetaData
 {
    
+   /** The profile source. */
+   private ProfileSourceMetaData source;
+   
    /** The deployments. */
    private List<ProfileDeploymentMetaData> deployments;
+   
+   public BasicProfileMetaData()
+   {
+      super();
+   }
+   
+   public BasicProfileMetaData(String domain, String server, String name)
+   {
+      super(domain, server, name, null);
+   }
+   
+   public BasicProfileMetaData(String domain, String server, String name, List<SubProfileMetaData> subProfiles)
+   {
+      super(domain, server, name, subProfiles);
+   }
+   
+   @XmlElement(name = "profile-source", type = ImmutableProfileSourceMetaData.class)
+   public ProfileSourceMetaData getSource()
+   {
+      return source;
+   }
 
+   public void setSource(ProfileSourceMetaData source)
+   {
+      this.source = source;
+   }   
+
    @XmlElement(name = "deployment", type = BasicProfileDeploymentMetaData.class)
    public List<ProfileDeploymentMetaData> getDeployments()
    {

Modified: trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/BasicSubProfileMetaData.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/BasicSubProfileMetaData.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/BasicSubProfileMetaData.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -41,6 +41,18 @@
    
    /** The doamin. */
    private String domain;
+   
+   public BasicSubProfileMetaData()
+   {
+      //
+   }
+   
+   public BasicSubProfileMetaData(String domain, String server, String name)
+   {
+      this.domain = domain;
+      this.server = server;
+      this.name = name;
+   }
 
    @XmlValue
    public String getName()

Copied: trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/EmptyProfileMetaData.java (from rev 86733, branches/Branch_5_x/system/src/main/org/jboss/system/server/profile/repository/metadata/EmptyProfileMetaData.java)
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/EmptyProfileMetaData.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/EmptyProfileMetaData.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -0,0 +1,72 @@
+/*
+ * 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.profile.repository.metadata;
+
+import java.util.Collections;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlTransient;
+
+import org.jboss.profileservice.spi.metadata.ProfileDeploymentMetaData;
+import org.jboss.profileservice.spi.metadata.ProfileMetaData;
+import org.jboss.profileservice.spi.metadata.ProfileSourceMetaData;
+import org.jboss.profileservice.spi.metadata.SubProfileMetaData;
+
+/**
+ * A empty profile meta meta, which only has a name and dependencies 
+ * to other profiles.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class EmptyProfileMetaData extends AbstractProfileMetaData implements ProfileMetaData
+{
+   
+   public EmptyProfileMetaData()
+   {
+      super();
+   }
+   
+   public EmptyProfileMetaData(String domain, String server, String name)
+   {
+      super(domain, server, name, null);
+   }
+   
+   public EmptyProfileMetaData(String domain, String server, String name, List<SubProfileMetaData> subProfiles)
+   {
+      super(domain, server, name, subProfiles);
+   }
+   
+   @XmlTransient
+   public List<ProfileDeploymentMetaData> getDeployments()
+   {
+      return Collections.emptyList();
+   }
+
+   @XmlTransient
+   public ProfileSourceMetaData getSource()
+   {
+      return null;
+   }
+   
+}
+

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-04-03 11:43:54 UTC (rev 86738)
+++ trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/FilteredProfileMetaData.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -21,9 +21,12 @@
  */ 
 package org.jboss.system.server.profile.repository.metadata;
 
+import java.util.List;
+
 import javax.xml.bind.annotation.XmlNsForm;
 import javax.xml.bind.annotation.XmlRootElement;
 
+import org.jboss.profileservice.spi.metadata.SubProfileMetaData;
 import org.jboss.xb.annotations.JBossXmlSchema;
 
 /**
@@ -38,5 +41,20 @@
 public class FilteredProfileMetaData extends BasicProfileMetaData
 {
 
+   public FilteredProfileMetaData()
+   {
+      super();
+   }
+   
+   public FilteredProfileMetaData(String domain, String server, String name)
+   {
+      super(domain, server, name, null);
+   }
+   
+   public FilteredProfileMetaData(String domain, String server, String name, List<SubProfileMetaData> subProfiles)
+   {
+      super(domain, server, name, subProfiles);
+   }
+   
 }
 

Deleted: trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/FilteredProfileSourceMetaData.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/FilteredProfileSourceMetaData.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/FilteredProfileSourceMetaData.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -1,61 +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.profile.repository.metadata;
-
-import java.util.List;
-
-import javax.xml.bind.annotation.XmlNsForm;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlTransient;
-
-import org.jboss.profileservice.spi.metadata.ProfileDeploymentMetaData;
-import org.jboss.xb.annotations.JBossXmlSchema;
-
-/**
- * A filtered profile source meta data. 
- * This is a workaround that we can a filtered deploymentRepository 
- * on this metadata only, based on the deployments list.
- * 
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
- at JBossXmlSchema(namespace="urn:jboss:profileservice:source:filtered:1.0", elementFormDefault=XmlNsForm.QUALIFIED)
- at XmlRootElement(name = "profile-source")
-public class FilteredProfileSourceMetaData extends AbstractProfileSourceMetaData
-{
-   
-   /** The deployments */
-   List<ProfileDeploymentMetaData> deployments;
-
-   @XmlTransient
-   public List<ProfileDeploymentMetaData> getDeployments()
-   {
-      return deployments;
-   }
-   
-   public void setDeployments(List<ProfileDeploymentMetaData> deployments)
-   {
-      this.deployments = deployments;
-   }
-   
-}
-

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-04-03 11:43:54 UTC (rev 86738)
+++ trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/HotDeploymentProfileMetaData.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -24,10 +24,14 @@
 import java.util.Collections;
 import java.util.List;
 
+import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlNsForm;
 import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
 
 import org.jboss.profileservice.spi.metadata.ProfileDeploymentMetaData;
+import org.jboss.profileservice.spi.metadata.ProfileSourceMetaData;
+import org.jboss.profileservice.spi.metadata.SubProfileMetaData;
 import org.jboss.xb.annotations.JBossXmlSchema;
 
 /**
@@ -41,10 +45,40 @@
 public class HotDeploymentProfileMetaData extends AbstractProfileMetaData
 {
 
+   /** The profile source. */
+   private ProfileSourceMetaData source;
+   
+   public HotDeploymentProfileMetaData()
+   {
+      super();
+   }
+   
+   public HotDeploymentProfileMetaData(String domain, String server, String name)
+   {
+      super(domain, server, name, null);
+   }
+   
+   public HotDeploymentProfileMetaData(String domain, String server, String name, List<SubProfileMetaData> subProfiles)
+   {
+      super(domain, server, name, subProfiles);
+   }
+   
+   @XmlElement(name = "profile-source", type = HotDeploymentProfileSourceMetaData.class)
+   public ProfileSourceMetaData getSource()
+   {
+      return source;
+   }
+
+   public void setSource(ProfileSourceMetaData source)
+   {
+      this.source = source;
+   }
+
    /**
     * There cannot be any specific deployments for a
     * hot deployment profile, as it will scan the folders.  
     */
+   @XmlTransient
    public List<ProfileDeploymentMetaData> getDeployments()
    {
       return Collections.emptyList();

Modified: trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/HotDeploymentProfileSourceMetaData.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/HotDeploymentProfileSourceMetaData.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/HotDeploymentProfileSourceMetaData.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -21,6 +21,8 @@
  */ 
 package org.jboss.system.server.profile.repository.metadata;
 
+import java.util.List;
+
 /**
  * A hot deployment profile source meta data.
  * 
@@ -30,5 +32,14 @@
 public class HotDeploymentProfileSourceMetaData extends AbstractProfileSourceMetaData
 {
 
+   public HotDeploymentProfileSourceMetaData()
+   {
+      super();
+   }
+   
+   public HotDeploymentProfileSourceMetaData(List<String> sources)
+   {
+      super(sources);
+   }
 }
 

Deleted: trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/ImmutableProfileMetaData.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/ImmutableProfileMetaData.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/ImmutableProfileMetaData.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -1,49 +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.profile.repository.metadata;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.jboss.profileservice.spi.metadata.ProfileDeploymentMetaData;
-
-
-/**
- * The meta data defining a immutable profile.
- * 
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public class ImmutableProfileMetaData extends AbstractProfileMetaData
-{
-
-   /**
-    * There cannot be any specific deployments for a
-    * immutable profile, as it will scan the folders.
-    */
-   public List<ProfileDeploymentMetaData> getDeployments()
-   {
-      return Collections.emptyList();
-   }
-
-}
-

Modified: trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/ImmutableProfileSourceMetaData.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/ImmutableProfileSourceMetaData.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/system/src/main/org/jboss/system/server/profile/repository/metadata/ImmutableProfileSourceMetaData.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -21,6 +21,8 @@
  */ 
 package org.jboss.system.server.profile.repository.metadata;
 
+import java.util.List;
+
 /**
  * A immutable profile source meta data.
  * 
@@ -29,6 +31,16 @@
  */
 public class ImmutableProfileSourceMetaData extends AbstractProfileSourceMetaData
 {
+   
+   public ImmutableProfileSourceMetaData()
+   {
+      super();
+   }
+   
+   public ImmutableProfileSourceMetaData(List<String> sources)
+   {
+      super(sources);
+   }
 
 }
 

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/ProfileServiceBootstrap.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/ProfileServiceBootstrap.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/ProfileServiceBootstrap.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -260,7 +260,8 @@
       
       // Activate the root profile
       log.info("Loading profile: " + this.profileKey);
-      profileService.activateProfile(this.profileKey);
+      this.profileService.activateProfile(this.profileKey);
+      this.profileService.validateProfile(this.profileKey);
       
       try
       {

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-04-03 11:43:54 UTC (rev 86738)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/attachments/AttachmentStore.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -39,24 +39,33 @@
    /**
     * Get the uri where the attachments are stored.
     * 
-    * @return the attachment store root.
+    * @return the attachment store root
     */
    URI getAttachmentStoreRoot();
    
    /**
     * Persist the changes of the managed component.
     * 
-    * @param deployment the profile deployment.
-    * @param comp the managed component.
+    * @param deployment the profile deployment
+    * @param comp the managed component
     * @throws Exception
     */
    void updateDeployment(ProfileDeployment deployment, ManagedComponent comp) throws Exception;
    
    /**
+    * Remove a component from the persisted attachment.
+    * 
+    * @param deployment the profile deployment
+    * @param comp the managed componenbt
+    * @throws Exception
+    */
+   void removeComponent(ProfileDeployment deployment, ManagedComponent comp) throws Exception;
+   
+   /**
     * Create the deployment with the persisted attachments.
     * 
-    * @param deployment the profile deployment.
-    * @return the mc deployment.
+    * @param deployment the profile deployment
+    * @return the mc deployment
     * @throws Exception
     */
    Deployment loadDeploymentData(ProfileDeployment deployment) throws Exception;

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/hotdeploy/HDScanner.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/hotdeploy/HDScanner.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/hotdeploy/HDScanner.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -21,6 +21,7 @@
  */
 package org.jboss.system.server.profileservice.hotdeploy;
 
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
@@ -29,7 +30,6 @@
 import java.util.concurrent.TimeUnit;
 
 import org.jboss.deployers.client.spi.main.MainDeployer;
-import org.jboss.kernel.spi.dependency.KernelController;
 import org.jboss.logging.Logger;
 import org.jboss.profileservice.spi.ModificationInfo;
 import org.jboss.profileservice.spi.MutableProfile;
@@ -45,68 +45,67 @@
  * is really just a simple ExecutorService Runnable that knows nothing
  * about how to detect changed deployers. The ProfileService determines
  * this.
- * 
- * @see MainDeployer
- * @see ProfileService
- * 
+ *
  * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
  * @author Scott.Stark at jboss.org
  * @author adrian at jboss.org
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ * 
  * @version $Revision$
+ * @see MainDeployer
+ * @see ProfileService
  */
-public class HDScanner
-   implements Runnable
+public class HDScanner implements Runnable, Scanner
 {
    private static final Logger log = Logger.getLogger(HDScanner.class);
-   // Private Data --------------------------------------------------
-   /** The MainDeployer used to deploy modifications */
+
+   /**
+    * The MainDeployer used to deploy modifications
+    */
    private MainDeployerAdapter deployer;
-   /** The controller */
-   private KernelController controller;
 
-   /** The ProfileService used to determine modified deployments */
+   /**
+    * The ProfileService used to determine modified deployments
+    */
    private ProfileService profileService;
 
-   /** The ExecutorService/ThreadPool for performing scans */
+   /**
+    * The ExecutorService/ThreadPool for performing scans
+    */
    private ScheduledExecutorService scanExecutor;
    private ScheduledFuture activeScan;
-   /** Thread name used when the ScheduledExecutorService is created internally */
+
+   /**
+    * Thread name used when the ScheduledExecutorService is created internally
+    */
    private String scanThreadName = "HDScanner";
 
-   /** Period in ms between deployment scans */
+   /**
+    * Period in ms between deployment scans
+    */
    private long scanPeriod = 5000;
-   /** The number of scans that have been done */
+
+   /**
+    * The number of scans that have been done
+    */
    private int scanCount;
 
-   // Constructor ---------------------------------------------------
-   
-   public HDScanner()
-   {
-      // empty
-   }
-   
-   // Attributes ----------------------------------------------------
+   /**
+    * The suspended flag
+    */
+   private boolean suspended;
 
    public void setDeployer(MainDeployerAdapter deployer)
    {
       this.deployer = deployer;
    }
 
-   public KernelController getController()
-   {
-      return controller;
-   }
-
-   public void setController(KernelController controller)
-   {
-      this.controller = controller;
-   }
-
    public ProfileService getProfileService()
    {
       return profileService;
    }
+
    public void setProfileService(ProfileService profileService)
    {
       this.profileService = profileService;
@@ -145,17 +144,18 @@
    {
       return scanPeriod;
    }
+
    /* (non-Javadoc)
-    * @see org.jboss.deployment.scanner.VFSDeploymentScanner#setScanPeriod(long)
-    */
+   * @see org.jboss.deployment.scanner.VFSDeploymentScanner#setScanPeriod(long)
+   */
    public void setScanPeriod(long period)
    {
       this.scanPeriod = period;
    }
 
-   /** 
+   /**
     * Are deployment scans enabled.
-    * 
+    *
     * @return whether scan is enabled
     */
    public boolean isScanEnabled()
@@ -167,6 +167,7 @@
    {
       return scanCount;
    }
+
    public synchronized void resetScanCount()
    {
       this.scanCount = 0;
@@ -174,52 +175,54 @@
 
    /**
     * Enable/disable deployment scans.
+    *
     * @param scanEnabled true to enable scans, false to disable.
     */
    public synchronized void setScanEnabled(boolean scanEnabled)
    {
-      if( scanEnabled == true && activeScan == null )
+      if (scanEnabled == true && activeScan == null)
       {
-         activeScan = this.scanExecutor.scheduleWithFixedDelay(this, 0,
-               scanPeriod, TimeUnit.MILLISECONDS);
+         start();
       }
-      else if( scanEnabled == false && activeScan != null )
+      else if (scanEnabled == false && activeScan != null)
       {
-         activeScan.cancel(true);
-         activeScan = null;
+         stop();
       }
    }
 
-
-   // Operations ----------------------------------------------------
-   
    public void create() throws Exception
    {
       // Default to a single thread executor
-      if( scanExecutor == null )
+      if (scanExecutor == null)
       {
          scanExecutor = Executors.newSingleThreadScheduledExecutor(
-            new ThreadFactory()
-            {
-               public Thread newThread(Runnable r)
+               new ThreadFactory()
                {
-                  return new Thread(r, HDScanner.this.getScanThreadName());
+                  public Thread newThread(Runnable r)
+                  {
+                     return new Thread(r, HDScanner.this.getScanThreadName());
+                  }
                }
-            }
-        );
+         );
       }
    }
-   
-   
-   public void start() throws Exception
+
+   public void start()
    {
-      activeScan = scanExecutor.scheduleWithFixedDelay(this, 0,
-            scanPeriod, TimeUnit.MILLISECONDS);
+      activeScan = scanExecutor.scheduleWithFixedDelay(this, 0, scanPeriod, TimeUnit.MILLISECONDS);
    }
 
+   public synchronized void stop()
+   {
+      if (activeScan != null)
+      {
+         activeScan.cancel(true);
+         activeScan = null;
+      }
+   }
+
    /**
-    * Executes scan 
-    *
+    * Executes scan
     */
    public void run()
    {
@@ -227,7 +230,7 @@
       {
          scan();
       }
-      catch(Throwable e)
+      catch (Throwable e)
       {
          log.warn("Scan failed", e);
       }
@@ -237,158 +240,129 @@
       }
    }
 
-   public void stop()
+   public synchronized void suspend()
    {
-      if( activeScan != null )
+      suspended = (activeScan != null);
+      if (suspended)
       {
-         activeScan.cancel(true);
+         activeScan.cancel(false);
+         try
+         {
+            activeScan.get();
+         }
+         catch (Exception ignored)
+         {
+         }
          activeScan = null;
       }
    }
 
+   public synchronized void resume()
+   {
+      if (suspended)
+      {
+         start();
+      }
+      suspended = false;
+   }
+
    public synchronized void scan() throws Exception
    {
       boolean trace = log.isTraceEnabled();
 
       // Query the ProfileService for deployments
-      if( trace )
+      if (trace)
          log.trace("Begin deployment scan");
 
       // Get the active profiles
       Collection<ProfileKey> activeProfiles = profileService.getActiveProfileKeys();
-      if(activeProfiles == null || activeProfiles.isEmpty())
+      if (activeProfiles == null || activeProfiles.isEmpty())
       {
-         if( trace )
+         if (trace)
             log.trace("End deployment scan, no active profiles");
          return;
       }
-      // Current workaround for JBAS-4206
-      Profile firstProfile = null;
 
       // Get the modified deployments
       boolean modified = false;
-      for(ProfileKey key : activeProfiles)
+      Collection<String> modifiedDeploymentNames = new ArrayList<String>();
+      for (ProfileKey key : activeProfiles)
       {
          // The profile
-         Profile profile = null;
+         Profile profile;
          try
          {
             profile = profileService.getActiveProfile(key);
          }
-         catch(NoSuchProfileException ignore)
+         catch (NoSuchProfileException ignore)
          {
-            if(trace)
-               log.debug("failed to get profile for key: "+ key);
+            if (trace)
+               log.debug("failed to get profile for key: " + key);
             continue;
          }
          // Check if it's a mutable profile
-         if( profile.isMutable() == false)
+         if (profile.isMutable() == false)
          {
-            if( trace )
-               log.trace("Ignoring not mutable profile: "+ key);
+            if (trace)
+               log.trace("Ignoring not mutable profile: " + key);
             continue;
          }
-         MutableProfile activeProfile = (MutableProfile) profile;
-         // Current workaround for JBAS-4206
-         if(firstProfile == null)
-            firstProfile = activeProfile;
-         
+
+         MutableProfile activeProfile = (MutableProfile)profile;
          Collection<ModificationInfo> modifiedDeployments = activeProfile.getModifiedDeployments();
-         for(ModificationInfo info : modifiedDeployments)
+         for (ModificationInfo info : modifiedDeployments)
          {
             ProfileDeployment ctx = info.getDeployment();
-            switch( info.getStatus() )
+            switch (info.getStatus())
             {
                case ADDED:
                case MODIFIED:
                   deployer.addDeployment(ctx);
+                  modifiedDeploymentNames.add(ctx.getName());
                   break;
                case REMOVED:
                   deployer.removeDeployment(ctx.getName());
                   break;
             }
          }
-         
-         if(modifiedDeployments.size() > 0)
+
+         if (modifiedDeployments.size() > 0)
             modified = true;
       }
 
-      // Process the changes
       try
       {
-         if( modified )
+         // Process the changes
+         if (modified)
          {
-            // Current workaround for JBAS-4206
-//            ClassLoader oldTCL = Thread.currentThread().getContextClassLoader();
-//            ClassLoader tcl = getTCL(firstProfile);
-            try
+            deployer.process();
+            
+            // Only check the modified deployments to avoid duplicate errors
+            for(String name : modifiedDeploymentNames)
             {
-//               if (tcl != null)
-//                  Thread.currentThread().setContextClassLoader(tcl);
-               deployer.process();
                // Can be nulled by a shutdown
-               if(deployer != null)
-                  deployer.checkComplete();
+               if (deployer != null)
+                  deployer.checkComplete(name);
             }
-            finally
-            {
-//               Thread.currentThread().setContextClassLoader(oldTCL);
-            }
          }
       }
       catch (Exception e)
       {
          log.warn("Failed to process changes", e);
-         // TODO: somehow need to ignore bad deployments to avoid repeated errors
          return;
       }
-      
 
-      if( trace )
+
+      if (trace)
          log.trace("End deployment scan");
    }
 
    /**
     * Inc the scanCount and to a notifyAll.
-    *
     */
    protected synchronized void incScanCount()
    {
-      scanCount ++;
+      scanCount++;
       notifyAll();
    }
-
-   // Private -------------------------------------------------------
-
-   /**
-    * Current workaround for JBAS-4206
-    */
-//   private ClassLoader getTCL(Profile activeProfile)
-//      throws Exception
-//   {
-//      MainDeployerStructure structure = (MainDeployerStructure) mainDeployer;
-//      Collection<VFSDeployment> ctxs = activeProfile.getDeployments();
-//      if (ctxs != null && ctxs.isEmpty() == false)
-//      {
-//         for (VFSDeployment deployment : ctxs)
-//         {
-//            DeploymentUnit unit = structure.getDeploymentUnit(deployment.getName());
-//            if (unit != null)
-//            {
-//               try
-//               {
-//                  ClassLoader cl = unit.getClassLoader();
-//                  if (cl != null)
-//                     return cl;
-//               }
-//               catch (Exception ignored)
-//               {
-//               }
-//            }
-//            
-//         }
-//      }
-//      log.warn("No bootstrap deployments? profile=" + activeProfile);
-//      return null;
-//   }
 }

Copied: trunk/system/src/main/org/jboss/system/server/profileservice/hotdeploy/Scanner.java (from rev 86733, branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/hotdeploy/Scanner.java)
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/hotdeploy/Scanner.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/hotdeploy/Scanner.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.system.server.profileservice.hotdeploy;
+
+/**
+ * Simple scanner interface.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public interface Scanner
+{
+   /**
+    * Suspend scanning.
+    */
+   void suspend();
+
+   /**
+    * Resume scanning.
+    */
+   void resume();
+
+   /**
+    * Do scan.
+    *
+    * @throws Exception for any error
+    */
+   void scan() throws Exception;
+}
\ No newline at end of file

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-04-03 11:43:54 UTC (rev 86738)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/persistence/AttachmentPropertyPopulator.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -23,6 +23,8 @@
 
 import java.lang.reflect.Proxy;
 
+import javax.management.ObjectName;
+
 import org.jboss.beans.info.spi.BeanInfo;
 import org.jboss.beans.info.spi.PropertyInfo;
 import org.jboss.logging.Logger;
@@ -90,11 +92,13 @@
       // FIXME skip CompositeValueInvocationHandler
       if (metaType.isComposite())
       {
-         // unwrap
-         Object unwrapped = metaValueFactory.unwrap(value, propertyInfo.getType());
-         if (Proxy.isProxyClass(unwrapped.getClass()))
-            return;
-
+         if(metaType.getTypeName().equals(ObjectName.class.getName()) == false)
+         {
+            // unwrap
+            Object unwrapped = metaValueFactory.unwrap(value, propertyInfo.getType());
+            if (Proxy.isProxyClass(unwrapped.getClass()))
+               return;            
+         }
       }
       
       // Set value

Modified: 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-04-03 11:43:54 UTC (rev 86738)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/persistence/ManagedGenericOverrideHandler.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -21,11 +21,21 @@
  */ 
 package org.jboss.system.server.profileservice.persistence;
 
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.util.Collection;
 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;
@@ -34,7 +44,12 @@
 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.PersistedProperty;
@@ -48,9 +63,45 @@
 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
@@ -96,6 +147,10 @@
             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);  
          }
@@ -125,13 +180,24 @@
 //         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())
@@ -140,11 +206,15 @@
          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
-            rawIterator.next();
+            Object o = rawIterator.next();
             
             // Skip generic values which are not annotated
             GenericValue originalGeneric = (GenericValue) originalIterator.next();
@@ -155,19 +225,24 @@
             
             // Skip not annotated managed objects
             if(originalGeneric.getValue() == null)
+            {
+               newCollection.add(o);
                continue;
+            }
 
-            // TODO Remove a ManagedObject
+            // Remove a ManagedObject
             ModificationInfo modificationInfo = overrideGenericValue.getModificationInfo(); 
             if(modificationInfo != null && modificationInfo == ModificationInfo.REMOVED)
             {
-               rawIterator.remove();
                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;
@@ -179,6 +254,21 @@
       }
    }
    
+   @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. */
@@ -210,5 +300,5 @@
          return propertyElement;
       }
    }
-   
+
 }

Modified: 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-04-03 11:43:54 UTC (rev 86738)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/persistence/ManagedObjectOverride.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -112,6 +112,7 @@
       {
          // TODO 
       }
+      
       // Recreate the metaValue
       MetaValue override = createMetaValue(valueElement, metaType);
 
@@ -147,14 +148,6 @@
 
       if (original.getMetaType() == null)
          throw new IllegalStateException("Original meta value is null " + original);
-
-//      if (original.getMetaType().getTypeName().equals(override.getMetaType().getTypeName()) == false)
-//      {
-//         // On generic values the restored is different from the original
-//         if(original.getMetaType().isGeneric() == false)
-//            throw new RuntimeException("Cannot merge two different types original: " + original.getMetaType()
-//                  + " override: " + override.getMetaType());
-//      }
          
 
       // Now try to merge

Modified: 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-04-03 11:43:54 UTC (rev 86738)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/persistence/ManagedObjectPeristenceHandler.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -42,15 +42,18 @@
 import org.jboss.metatype.api.values.GenericValue;
 import org.jboss.metatype.api.values.MetaValue;
 import org.jboss.metatype.api.values.MetaValueFactory;
+import org.jboss.metatype.api.values.PropertiesMetaValue;
 import org.jboss.metatype.api.values.SimpleValue;
 import org.jboss.metatype.api.values.TableValue;
-import org.jboss.system.server.profileservice.persistence.xml.ModificationInfo;
+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;
@@ -155,7 +158,7 @@
          properties.add(propertyElement);
       }
    }
-   
+
    /**
     * Create the persisted property.
     * 
@@ -178,7 +181,7 @@
       PersistedProperty property = new PersistedProperty(name);
       // Create persisted value
       PersistedValue persistedValue = createPersistedValue(value, metaType);
-      persistedValue.setModificationInfo(ModificationInfo.MODIFIED);
+//      persistedValue.setModificationInfo(ModificationInfo.MODIFIED);
       //
       property.setValue(persistedValue);
       // Return
@@ -198,7 +201,7 @@
          log.trace("creating persisted value for : " + value + " with metaType " + metaType);
       
       if(value == null)
-         return emtpyPersistedValue(metaType);
+         return new NullValue();
       
       // Override the metaType e.g. the MapCompositeValueSupport
       metaType = value.getMetaType();
@@ -241,6 +244,11 @@
          persistedValue = createTableValue(
                (TableValue) value);
       }
+      else if(metaType.isProperties())
+      {
+         persistedValue = createPropertiesValue(
+               (PropertiesMetaValue) value);
+      }
       else
       {
          throw new IllegalStateException("unknown metaType");
@@ -248,13 +256,14 @@
       return persistedValue;
    }
    
+
    /**
     * Create the persistence enum value.
     * 
     * @param value the enum value
     * @return the enum xml meta data
     */
-   private PersistedEnumValue createEnumValue(EnumValue value)
+   protected PersistedEnumValue createEnumValue(EnumValue value)
    {
       PersistedEnumValue persistedValue = new PersistedEnumValue();
       persistedValue.setValue(value.getValue());
@@ -267,7 +276,7 @@
     * @param value the simple value
     * @return the simple xml meta data
     */
-   private PersistedSimpleValue createSimpleValue(SimpleValue value)
+   protected PersistedSimpleValue createSimpleValue(SimpleValue value)
    {
       PersistedSimpleValue persistedValue = new PersistedSimpleValue();
       persistedValue.setValue(convertSimple2String(value));
@@ -280,7 +289,7 @@
     * @param value the collection value
     * @return the collection xml meta data
     */
-   private PersistedCollectionValue createCollectionValue(CollectionValue value)
+   protected PersistedCollectionValue createCollectionValue(CollectionValue value)
    {
       PersistedCollectionValue collection = new PersistedCollectionValue();
       for(MetaValue child : value.getElements())
@@ -297,7 +306,7 @@
     * @param value the generic value
     * @return the generic xml meta data
     */
-   private PersistedGenericValue createGenericValue(GenericValue value)
+   protected PersistedGenericValue createGenericValue(GenericValue value)
    {
       //
       PersistedGenericValue generic = new PersistedGenericValue();
@@ -323,7 +332,7 @@
     * @param value the array value
     * @return
     */
-   private PersistedArrayValue createArrayValue(ArrayValue value, ArrayMetaType metaType)
+   protected PersistedArrayValue createArrayValue(ArrayValue value, ArrayMetaType metaType)
    {
       //
       PersistedArrayValue array = new PersistedArrayValue();
@@ -384,7 +393,7 @@
     * @param metaType the composite meta type
     * @return the persistence composite xml meta data
     */
-   private PersistedCompositeValue createCompositeValue(CompositeValue value, CompositeMetaType metaType)
+   protected PersistedCompositeValue createCompositeValue(CompositeValue value, CompositeMetaType metaType)
    {
       //
       PersistedCompositeValue composite = new PersistedCompositeValue();
@@ -415,7 +424,7 @@
     * @param value the table value
     * @return the persistence table xml meta data
     */
-   private PersistedTableValue createTableValue(TableValue value)
+   protected PersistedTableValue createTableValue(TableValue value)
    {
       PersistedTableValue table = new PersistedTableValue();
       // Fix the entries
@@ -434,6 +443,24 @@
       return table;
    }
 
+   protected PersistedValue createPropertiesValue(PropertiesMetaValue value)
+   {
+      PersistedPropertiesValue properties = new PersistedPropertiesValue();
+      List<PersistedPair> pairs = properties.getEntries();
+      if(pairs == null)
+      {
+         pairs = new ArrayList<PersistedPair>();
+         properties.setEntries(pairs);
+      }
+      for(Object key : value.keySet())
+      {
+         Object kvalue = value.get(key);
+         PersistedPair pair = new PersistedPair(key.toString(), kvalue.toString());
+         pairs.add(pair);
+      }
+      return properties;
+   }
+
    /**
     * Create a emtpy xml meta data, based on the meta type
     * 

Modified: 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-04-03 11:43:54 UTC (rev 86738)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/persistence/ManagedObjectRecreation.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -45,6 +45,7 @@
 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;
@@ -59,18 +60,22 @@
 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;
@@ -266,6 +271,9 @@
          log.trace("processing value " + valueElement + " type: " + metaType);
       }
       
+      if(valueElement instanceof NullValue)
+         return null;
+      
       if(valueElement == null)
          return null;
       
@@ -314,6 +322,12 @@
                   (PersistedArrayValue) valueElement,
                   (ArrayMetaType) metaType);
          }
+         else if(metaType.isProperties())
+         {
+            metaValue = createPropertiesValue(
+                  (PersistedPropertiesValue) valueElement,
+                  (PropertiesMetaType) metaType);
+         }
          else
          {
             throw new IllegalStateException("unknown metaType");
@@ -357,7 +371,7 @@
             converted = convert2Type(metaType.getTypeName(), elementValue);
          }
       }
-      return SimpleValueSupport.wrap(converted);
+      return new SimpleValueSupport(metaType, converted);
    }
  
    /**
@@ -484,6 +498,18 @@
       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.
     * 

Copied: trunk/system/src/main/org/jboss/system/server/profileservice/persistence/ManagedObjectRemoveHandler.java (from rev 86733, branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/ManagedObjectRemoveHandler.java)
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/persistence/ManagedObjectRemoveHandler.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/persistence/ManagedObjectRemoveHandler.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -0,0 +1,65 @@
+/*
+ * 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.metatype.api.values.GenericValue;
+import org.jboss.system.server.profileservice.persistence.xml.ModificationInfo;
+import org.jboss.system.server.profileservice.persistence.xml.PersistedGenericValue;
+
+/**
+ * 
+ * @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;
+   
+   public ManagedObjectRemoveHandler(ManagedCommon removeItem)
+   {
+      if(removeItem == null)
+         throw new IllegalArgumentException("Null component to remove.");
+      this.removeItem = removeItem;
+   }
+   
+   @Override
+   protected PersistedGenericValue createGenericValue(GenericValue value)
+   {
+      Object o = value.getValue();
+      if(o instanceof ManagedObject)
+      {
+         ManagedObject mo = (ManagedObject) o;
+         if(mo.getName() == removeItem.getName())
+         {
+            PersistedGenericValue v = new PersistedGenericValue();
+            v.setModificationInfo(ModificationInfo.REMOVED);
+            return v;            
+         }
+      }
+      return super.createGenericValue(value);
+   }
+  
+}

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/persistence/xml/AbstractPersisitedValue.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/persistence/xml/AbstractPersisitedValue.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/persistence/xml/AbstractPersisitedValue.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -45,4 +45,12 @@
       this.info = info;
    }
    
+   public boolean hasModificationFlag(ModificationInfo info)
+   {
+      if(info == null)
+         return false;
+      
+      return this.info.equals(info);
+   }
+   
 }

Copied: trunk/system/src/main/org/jboss/system/server/profileservice/persistence/xml/NullValue.java (from rev 86733, branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/xml/NullValue.java)
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/persistence/xml/NullValue.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/persistence/xml/NullValue.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -0,0 +1,34 @@
+/*
+ * 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.xml;
+
+/**
+ * A <null/> value.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class NullValue extends AbstractPersisitedValue implements PersistedValue
+{
+
+}
+

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistedCollectionValue.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistedCollectionValue.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistedCollectionValue.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -38,12 +38,14 @@
    /** The values. */
    private List<PersistedValue> values = new ArrayList<PersistedValue>();
    
-   @XmlElements( value = {
+   @XmlElements( value = {         
+         @XmlElement(name = "null", type = NullValue.class),
          @XmlElement(name = "simple", type = PersistedSimpleValue.class),
          @XmlElement(name = "enum", type = PersistedEnumValue.class),
          @XmlElement(name = "generic", type = PersistedGenericValue.class),
          @XmlElement(name = "collection", type = PersistedCollectionValue.class),
          @XmlElement(name = "composite", type = PersistedCompositeValue.class),
+         @XmlElement(name = "properties", type = PersistedPropertiesValue.class),
          @XmlElement(name = "table", type = PersistedTableValue.class),
          @XmlElement(name = "array", type = PersistedArrayValue.class)
    })

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-04-03 11:43:54 UTC (rev 86738)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistedCompositeValue.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -39,11 +39,13 @@
    List<PersistedValue> values;
    
    @XmlElements( value = {
+         @XmlElement(name = "null", type = NullValue.class),
          @XmlElement(name = "simple", type = PersistedSimpleValue.class),
          @XmlElement(name = "enum", type = PersistedEnumValue.class),
          @XmlElement(name = "generic", type = PersistedGenericValue.class),
          @XmlElement(name = "collection", type = PersistedCollectionValue.class),
          @XmlElement(name = "composite", type = PersistedCompositeValue.class),
+         @XmlElement(name = "properties", type = PersistedPropertiesValue.class),
          @XmlElement(name = "table", type = PersistedTableValue.class),
          @XmlElement(name = "array", type = PersistedArrayValue.class)
    })

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-04-03 11:43:54 UTC (rev 86738)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistedManagedObject.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -43,6 +43,10 @@
 @XmlRootElement(name = MANAGED_OBJECT_ELEMENT_NAME)
 public class PersistedManagedObject extends AbstractElement
 {
+   
+   /** The original name. */
+   private String originalName;
+   
    /** The template name. */
    private String templateName;
    
@@ -75,6 +79,17 @@
       this.templateName = templateName;
    }
    
+   @XmlElement(name = "orignal-name")
+   public String getOriginalName()
+   {
+      return originalName;
+   }
+   
+   public void setOriginalName(String originalName)
+   {
+      this.originalName = originalName;
+   }
+   
    @XmlElementWrapper(name="properties")
    @XmlElement(name = "property")
    public List<PersistedProperty> getProperties()

Copied: trunk/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistedPair.java (from rev 86733, branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistedPair.java)
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistedPair.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistedPair.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -0,0 +1,65 @@
+/*
+ * 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.xml;
+
+import javax.xml.bind.annotation.XmlAttribute;
+
+/**
+ * The SimpleValue/SimpleMetaType.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class PersistedPair extends PersistedSimpleValue
+{
+   /** The name. */
+   private String key;
+   
+   public PersistedPair()
+   {
+      super("pair");
+   }
+   
+   public PersistedPair(String key, String value)
+   {
+      super("pair");
+      this.key = key;
+      super.setValue(value);
+   }
+
+   @XmlAttribute(name = "key")
+   public String getKey()
+   {
+      return this.key;
+   }
+   
+   public void setKey(String key)
+   {
+      this.key = key;
+   }
+
+   protected void toString(StringBuilder builder)
+   {
+      builder.append(", key = ").append(getKey());
+   }
+   
+}

Copied: trunk/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistedPropertiesValue.java (from rev 86733, branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistedPropertiesValue.java)
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistedPropertiesValue.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistedPropertiesValue.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -0,0 +1,51 @@
+/*
+ * 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.xml;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlElement;
+
+/**
+ * The persisted TableValue.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class PersistedPropertiesValue extends AbstractPersisitedValue implements PersistedValue
+{
+
+   /** The entries. */
+   List<PersistedPair> entries;
+
+   @XmlElement(name = "entry")
+   public List<PersistedPair> getEntries()
+   {
+      return entries;
+   }
+   
+   public void setEntries(List<PersistedPair> entries)
+   {
+      this.entries = entries;
+   }
+   
+}

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistedProperty.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistedProperty.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistedProperty.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -54,11 +54,13 @@
    }
    
    @XmlElements( value = {
+         @XmlElement(name = "null", type = NullValue.class),
          @XmlElement(name = "simple", type = PersistedSimpleValue.class),
          @XmlElement(name = "enum", type = PersistedEnumValue.class),
          @XmlElement(name = "composite", type = PersistedCompositeValue.class),
          @XmlElement(name = "generic", type = PersistedGenericValue.class),
          @XmlElement(name = "collection", type = PersistedCollectionValue.class),
+         @XmlElement(name = "properties", type = PersistedPropertiesValue.class),
          @XmlElement(name = "table", type = PersistedTableValue.class),
          @XmlElement(name = "array", type = PersistedArrayValue.class)
    })

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistedSimpleValue.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistedSimpleValue.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistedSimpleValue.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -93,6 +93,14 @@
       this.info = info;
    }
    
+   public boolean hasModificationFlag(ModificationInfo info)
+   {
+      if(info == null)
+         return false;
+      
+      return this.info.equals(info);
+   }
+   
    @XmlValue 
    public String getValue()
    {

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistedValue.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistedValue.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/persistence/xml/PersistedValue.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -45,5 +45,14 @@
     */
    void setModificationInfo(ModificationInfo info);
    
+   
+   /**
+    * Check the modificationInfo.
+    * 
+    * @param info the modification info.
+    * @return this.info.equals(info);
+    */
+   boolean hasModificationFlag(ModificationInfo info);
+   
 }
 

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-04-03 11:43:54 UTC (rev 86738)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractAttachmentStore.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -58,8 +58,10 @@
 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.virtual.VirtualFile;
+import org.jboss.virtual.VirtualFileFilter;
 
 /**
  * The AbstractAttachmentStore updates and restores the persisted attachments.
@@ -81,12 +83,15 @@
    /** 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);
    
@@ -134,6 +139,16 @@
       this.serializer = serializer;
    }
    
+   public VirtualFileFilter getMetaDataFilter()
+   {
+      return metaDataFilter;
+   }
+   
+   public void setMetaDataFilter(VirtualFileFilter metaDataFilter)
+   {
+      this.metaDataFilter = metaDataFilter;
+   }
+   
    public Deployment createMCDeployment(ProfileDeployment profileDeployment) throws Exception
    {
       if(profileDeployment.getRoot() == null)
@@ -222,15 +237,84 @@
       throws IOException
    {
       boolean attach = true;
-      if(metaData.getLastModified() < root.getLastModified())
+      long lastModified = metaData.getLastModified();
+      // Check directory
+      if(root.isLeaf() == false && root.isArchive() == false)
       {
-         attach = false;
+         // TODO recursive checks
+         DeploymentStructureMetaData structure = metaData.getDeploymentStructure();
+         if(checkMetaDataModifications(root, structure, lastModified) == false)
+            return false;
       }
-      // TODO check metaData locations
+      else
+      {
+         // Otherwise we only check the root
+         if(lastModified < root.getLastModified())
+            return false;         
+      }
       return attach;
    }
    
+   
+   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
+   {
+      if(deployment == null)
+         throw new IllegalArgumentException("Null deployment.");
+      if(comp == null)
+         throw new IllegalArgumentException("Null managed component.");
+      
+      // Create the remove handler
+      ManagedObjectRemoveHandler removeHandler = new ManagedObjectRemoveHandler(comp);
+      updateDeployment(deployment, comp, removeHandler);
+   }
+   
+   
+   /**
     * Persist the updated metadata for a managedComponent and generate a metadata describing
     * the repository, if it does not exist already.
     * 
@@ -242,9 +326,24 @@
    public void updateDeployment(ProfileDeployment deployment, ManagedComponent comp)
       throws Exception
    {
-      if(deployment ==  null)
-         throw new IllegalArgumentException("ProfileDeployment may not be null.");
+      if(comp == null)
+         return;
       
+      // Update deployment
+      updateDeployment(deployment, comp, handler);      
+   }
+   
+   
+   public void updateDeployment(ProfileDeployment deployment, ManagedComponent comp, ManagedObjectPeristenceHandler persistenceHandler)
+      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.");
+      
       if(deployment.getRoot() == null)
       {
          // TODO
@@ -334,8 +433,11 @@
          // Is attachmentName the same as the className ?
          attachment.setName(attachmentName);
          attachment.setClassName(managedObject.getAttachment().getClass().getName());
-         // Set attachment, this is transient - as it will get persisted in it's own file.
-         attachment.setAttachment(managedObject);
+         
+         // Create the persistence information and add it as a transient attachment
+         PersistedManagedObject persistedMO = createPersistedMetaData(managedObject, persistenceHandler);
+         attachment.setAttachment(persistedMO);
+         
          // Update lastModified
          currentContextMetaData.setLastModified(lastModified);
       }
@@ -347,7 +449,8 @@
       savedMetaData.setLastModified(lastModified);
       
       // Save the repository meta data
-      this.serializer.saveAttachment(getMetaDataPathName(deploymentPath), savedMetaData);
+      this.serializer.saveAttachment(getMetaDataPathName(deploymentPath), savedMetaData);      
+      
    }
    
    /**
@@ -421,9 +524,8 @@
             if(attachment.getAttachment() == null)
                continue;
             
-            // Create xml meta data for persistence.
-            ManagedObject mo = (ManagedObject) attachment.getAttachment();
-            PersistedManagedObject root = createPersistedMetaData(mo);
+            // Get the xml for the persisted attachment
+            PersistedManagedObject root = (PersistedManagedObject) attachment.getAttachment();
             
             String attachmentPath = deploymentPath + attachment.getName();
             // Serialize the attachment
@@ -449,9 +551,10 @@
     * create the xml meta data for persisting the managed object.
     * 
     * @param mo the managed object.
+    * @param handler the persistence handler
     * @return the xml metadata.
     */
-   protected PersistedManagedObject createPersistedMetaData(ManagedObject mo)
+   protected PersistedManagedObject createPersistedMetaData(ManagedObject mo, ManagedObjectPeristenceHandler handler)
    {
       // Return
       return handler.createPersistenceMetaData(mo);
@@ -569,7 +672,7 @@
       if(deployment == null)
          throw new IllegalStateException("Null deployment.");
       
-      // deployment URI toString
+      // deployment URI 
       String pathName = deployment.getRoot().toURI().toString();
       String fileName = deployment.getRoot().getName();
       // Generate hash

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractBootstrapProfileFactory.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractBootstrapProfileFactory.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractBootstrapProfileFactory.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -138,7 +138,8 @@
       processSubProfiles(profiles, subProfiles, profileMetaData.getSubprofiles());
       
       // Create the profile
-      Profile profile = profileFactory.createProfile(key, profileMetaData, subProfiles);
+      // Provide a new copy of the keys
+      Profile profile = profileFactory.createProfile(key, profileMetaData, new ArrayList<ProfileKey>(subProfiles));
       
       // Add to the profileMap
       profiles.put(key, profile);

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileAction.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileAction.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileAction.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -35,7 +35,7 @@
    
    public abstract void install(Profile profile) throws Exception;
    
-   public abstract void uninstall(Profile profile) throws Exception;
+   public abstract void uninstall(Profile profile);
    
    /**
     * Install.

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileFactory.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileFactory.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileFactory.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -22,70 +22,61 @@
 package org.jboss.system.server.profileservice.repository;
 
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.List;
 
-import org.jboss.profileservice.spi.DeploymentRepository;
 import org.jboss.profileservice.spi.Profile;
 import org.jboss.profileservice.spi.ProfileFactory;
 import org.jboss.profileservice.spi.ProfileKey;
-import org.jboss.profileservice.spi.ProfileRepository;
+import org.jboss.profileservice.spi.metadata.ProfileKeyMetaData;
 import org.jboss.profileservice.spi.metadata.ProfileMetaData;
-import org.jboss.system.server.profile.repository.AbstractProfile;
+import org.jboss.profileservice.spi.metadata.SubProfileMetaData;
 
 /**
- * The abstract profile factory.
+ * A abstract profile factory.
  * 
- * TODO this should create the profile based on the meta data,
- * as it only creates a AbstractProfile with it's DeploymentRepository
- * at the moment. 
- * 
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
  * @version $Revision$
  */
-public class AbstractProfileFactory implements ProfileFactory
+public abstract class AbstractProfileFactory implements ProfileFactory
 {   
-   /** The deployment repository factory. */
-   private ProfileRepository profileRepository;
-
-   public String[] getTypes()
-   {
-      // For further use
-      return null;
-   }
+   /**
+    * This is used by the BoostrapProfileFactory, as it already created the
+    * subProfiles list. 
+    * 
+    * @param key the profile key
+    * @param metaData the profile meta data
+    * @param subProfiles the sub profiles list
+    * @return the profile
+    * @throws Exception
+    */
+   public abstract Profile createProfile(ProfileKey key, ProfileMetaData metaData, List<ProfileKey> subProfiles) throws Exception;
    
-   public ProfileRepository getProfileRepository()
-   {
-      return profileRepository;
-   }
-   
-   public void setProfileRepository(ProfileRepository profileRepository)
-   {
-      this.profileRepository = profileRepository;
-   }
-   
    public Profile createProfile(ProfileKey key, ProfileMetaData metaData) throws Exception
    {
-      return createProfile(key, metaData, Collections.EMPTY_LIST);
-   }
-   
-   public Profile createProfile(ProfileKey key, ProfileMetaData metaData, List<ProfileKey> subProfiles) throws Exception
-   {
       if(key == null)
          throw new IllegalArgumentException("Null profile key.");
       if(metaData == null)
          throw new IllegalArgumentException("Null profile meta data.");
       
-      // Start to create the profile
-      DeploymentRepository repository = profileRepository.createProfileDeploymentRepository(key, metaData);
-      
-      // Create the profile
-      AbstractProfile profile = new AbstractProfile(repository, key);
-      
-      // Copy the sub-profile keys
-      profile.setSubProfiles(new ArrayList<ProfileKey>(subProfiles));
-      
-      return profile;
+      // 
+      return createProfile(key, metaData, createSubProfiles(metaData));
    }
-
-}
\ No newline at end of file
+   
+   protected List<ProfileKey> createSubProfiles(ProfileMetaData metaData)
+   {
+      List<ProfileKey> subProfiles = new ArrayList<ProfileKey>();
+      if(metaData.getSubprofiles() != null && metaData.getSubprofiles().isEmpty() == false)
+      {
+         for(SubProfileMetaData subProfile : metaData.getSubprofiles())
+         {
+            subProfiles.add(createKey(subProfile));
+         }
+      }
+      return subProfiles;
+   }
+   
+   protected ProfileKey createKey(ProfileKeyMetaData metaData)
+   {
+      return new ProfileKey(metaData.getDomain(), metaData.getServer(), metaData.getName());
+   }   
+}

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileLifeCycleAction.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileLifeCycleAction.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileLifeCycleAction.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -31,7 +31,7 @@
  * TODO use jboss-reflect for this.
  * 
  * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
+ * @version $Revision: 84894 $
  */
 public abstract class AbstractProfileLifeCycleAction extends AbstractProfileAction
 {
@@ -48,9 +48,17 @@
    }
 
    @Override
-   public void uninstall(Profile profile) throws Exception
+   public void uninstall(Profile profile)
    {
-      invoke(profile, getUninstallMethod());
+      try
+      {
+         invoke(profile, getUninstallMethod());
+      }
+      catch(Exception e)
+      {
+         log.warn("Error invoking uninstall method '" + getUninstallMethod()
+               + "' on profile: " + profile.getKey());
+      }
    }
 
    protected static void invoke(Profile profile, String method) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileService.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileService.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractProfileService.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -29,7 +29,6 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.CopyOnWriteArrayList;
 
 import org.jboss.dependency.plugins.AbstractController;
@@ -47,7 +46,6 @@
 import org.jboss.profileservice.spi.Profile;
 import org.jboss.profileservice.spi.ProfileKey;
 import org.jboss.profileservice.spi.ProfileService;
-import org.jboss.profileservice.spi.metadata.ProfileMetaData;
 import org.jboss.util.JBossStringBuilder;
 
 /**
@@ -63,7 +61,7 @@
    private ProfileKey defaultProfile;
    
    /** The registered profiles. */
-   private Map<ProfileKey, ProfileContext> registeredProfiles = new ConcurrentHashMap<ProfileKey, ProfileContext>();
+   private List<ProfileKey> profiles = new CopyOnWriteArrayList<ProfileKey>();
    
    /** The active profiles. */
    private List<ProfileKey> activeProfiles = new CopyOnWriteArrayList<ProfileKey>();
@@ -155,7 +153,7 @@
 
    public Collection<ProfileKey> getProfileKeys()
    {
-      return new ArrayList<ProfileKey>(this.registeredProfiles.keySet());
+      return Collections.unmodifiableCollection(this.profiles);
    }
    
    /**
@@ -169,8 +167,16 @@
    {
       if(key ==  null)
          throw new IllegalArgumentException("Null profile key.");
+
+      // Get the profile
+      ProfileContext profile = null;
+      if(this.profiles.contains(key))
+         profile = (ProfileContext) this.controller.getContext(key, null);
       
-      ProfileContext profile = this.registeredProfiles.get(key); 
+      // If the key is the default, fallback to the injected default key
+      if(profile == null && key.isDefaultKey() && this.defaultProfile != null)
+         profile = (ProfileContext) controller.getContext(this.defaultProfile, null);   
+         
       if(profile == null)
          throw new NoSuchProfileException("No such profile: " + key);
       
@@ -191,19 +197,21 @@
     */
    public Profile getActiveProfile(ProfileKey key) throws NoSuchProfileException
    {
-      if(key == null)
+      if(key ==  null)
          throw new IllegalArgumentException("Null profile key.");
-      
+
+      // Get the profile
       ProfileContext profile = null;
       if(this.activeProfiles.contains(key))
-         profile = (ProfileContext) controller.getInstalledContext(key);
+         profile = (ProfileContext) this.controller.getInstalledContext(key);
       
-      // If the key is a default key, fallback to the injected default key
-      if(key.isDefaultKey() && this.defaultProfile != null)
-         profile = (ProfileContext) controller.getInstalledContext(this.defaultProfile);
+      // If the key is the default, fallback to the injected default key
+      if(profile == null && key.isDefaultKey() && this.defaultProfile != null)
+         profile = (ProfileContext) controller.getInstalledContext(this.defaultProfile);   
+         
+      if(profile == null)
+         throw new NoSuchProfileException("No such profile: " + key);
       
-      if(profile == null)
-         throw new NoSuchProfileException("Profile not installed: " + key);
       return profile.getProfile();
    }
    
@@ -217,9 +225,9 @@
       if(this.controller == null)
          throw new IllegalStateException("Null controller.");
       if(this.deployer == null)
-         throw new IllegalStateException("Null main deployer.");
+         throw new IllegalStateException("Null deployer.");
       
-      // FIXME this should be moved to static actions
+      // TODO this should be moved to static actions
       this.profileActions.put(ControllerState.CREATE, new ProfileCreateAction());
       this.profileActions.put(ControllerState.START, new ProfileStartAction());
       this.profileActions.put(DEPLOY_STATE, new ProfileDeployAction(deployer));
@@ -237,21 +245,6 @@
    }
    
    /**
-    * Create and register a profile.
-    * 
-    * @param metaData the profile meta data.
-    * @throws Exception
-    */
-   public ProfileKey createProfile(ProfileMetaData metaData) throws Exception
-   {
-      if(metaData == null)
-         throw new IllegalArgumentException("Null meta data");
-      
-      // FIXME
-      throw new IllegalStateException("NYI");
-   }
-   
-   /**
     * Register a Profile.
     * 
     * @param profile the profile.
@@ -265,8 +258,11 @@
       ProfileKey key = profile.getKey();
       if(key == null)
          throw new IllegalArgumentException("Null profile key.");
-      if(registeredProfiles.get(profile.getKey()) != null)
+      if(this.profiles.contains(key))
+      {
+         log.debug("Profile already registered: " + profile);
          return;
+      }
       
       if(controller.isShutdown())
          throw new IllegalStateException("Controller is shutdown.");
@@ -276,7 +272,7 @@
       try
       {
          controller.install(context);
-         this.registeredProfiles.put(key, context);
+         this.profiles.add(key);
       }
       catch(Throwable t)
       {
@@ -300,7 +296,7 @@
       if(this.activeProfiles.contains(key))
          return;
 
-      ProfileContext context = this.registeredProfiles.get(key);
+      ProfileContext context = (ProfileContext) this.controller.getContext(key, null);
       if(context == null)
          throw new NoSuchProfileException("No such profile: "+ key);
 
@@ -313,17 +309,24 @@
       {
          throw new RuntimeException(t);
       }
-      
-      // TODO let the caller validate  
-      // Check if the profile was activated successfully 
-      validate(context);
    }
    
    public void validateProfile(ProfileKey key) throws Exception
    {
-      ProfileContext profile = this.registeredProfiles.get(key);
+      if(key ==  null)
+         throw new IllegalArgumentException("Null profile key.");
+
+      // Get the profile
+      ProfileContext profile = null;
+      if(this.profiles.contains(key))
+         profile = (ProfileContext) this.controller.getContext(key, null);
+      
+      // If the key is the default, fallback to the injected default key
+      if(profile == null && key.isDefaultKey() && this.defaultProfile != null)
+         profile = (ProfileContext) controller.getContext(this.defaultProfile, null);   
+         
       if(profile == null)
-         throw new NoSuchProfileException("No such profile registered: "+ key);
+         throw new NoSuchProfileException("No such profile: " + key);
       
       validate(profile);
    }
@@ -348,21 +351,29 @@
    public void install(ControllerContext context, ControllerState fromState, ControllerState toState) throws Throwable
    {
       if(context instanceof ProfileContext == false)
+      {
          return;
-      // TODO
+      }
+
       AbstractProfileAction action = this.profileActions.get(toState);
       if(action != null)
+      {
          action.install((ProfileContext) context);
+      }
    }
    
    public void uninstall(ControllerContext context, ControllerState fromState, ControllerState toState)
    {
       if(context instanceof ProfileContext == false)
+      {
          return;
-      // TODO
+      }
+
       AbstractProfileAction action = this.profileActions.get(fromState);
       if(action != null)
+      {
          action.uninstall((ProfileContext) context);
+      }
    }
 
    /**
@@ -382,15 +393,13 @@
       if(controller.isShutdown())
          return;
       
-      ControllerContext context = controller.getContext(key, ControllerState.INSTALLED);
+      ControllerContext context = controller.getInstalledContext(key);
       if(context == null)
          throw new IllegalStateException("Profile not installed: "+ key);
       try
       {
          log.debug("deactivating profile: " + key);
          controller.change(context, ControllerState.NOT_INSTALLED);
-         
-         // TODO release other not needed contexts ? 
       }
       catch(Throwable t)
       {
@@ -412,16 +421,15 @@
       if(this.activeProfiles.contains(key))
          throw new IllegalStateException("Cannot unregister active profile: "+ key);
       
-      if(this.registeredProfiles.containsKey(key) == false)
+      if(this.profiles.contains(key) == false)
          throw new NoSuchProfileException("Profile not registered: " + key);
       
       log.debug("unregistering profile: " + key);
-      this.registeredProfiles.remove(key);
-
       if(controller.isShutdown())
          return;
       
       controller.uninstall(key);
+      this.profiles.remove(key);
    }
    
    /**

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-04-03 11:43:54 UTC (rev 86738)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/AbstractVFSProfileSource.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -22,6 +22,7 @@
 package org.jboss.system.server.profileservice.repository;
 
 import java.io.IOException;
+import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.ArrayList;
@@ -57,8 +58,11 @@
    /** Allowed deployments filter. */
    private VirtualFileFilter deploymentFilter;
    
-   /** The application phase deployment files keyed by VirtualFile URI string. */
+   /** The application files keyed by VirtualFile URI string. */
    private final Map<String, VirtualFile> applicationVFCache = new ConcurrentHashMap<String, VirtualFile>();
+   
+   /** Do a recursive search - default == true. */
+   private boolean recursiveScan = true;
 
    /** The last time the profile was modified. */
    private volatile long lastModified;
@@ -88,6 +92,16 @@
       this.deploymentFilter = deploymentFilter;
    }
    
+   public boolean isRecursiveScan()
+   {
+      return recursiveScan;
+   }
+   
+   public void setRecursiveScan(boolean recursiveScan)
+   {
+      this.recursiveScan = recursiveScan;
+   }
+   
    public URI[] getRepositoryURIs()
    {
       return uris.toArray(new URI[uris.size()]);
@@ -118,8 +132,6 @@
    
    public void addDeployment(String vfsPath, ProfileDeployment d) throws Exception
    {
-      if(vfsPath == null)
-         throw new IllegalArgumentException("Null vfsPath");
       if(d == null)
          throw new IllegalArgumentException("Null deployment");
       
@@ -201,19 +213,24 @@
       if(acceptsDeployment(key) == false)
          return;
 
-      if (component.isLeaf())
+      // If it's a directory or exploded deployment
+      if(component.isLeaf() == false && component.isArchive() == false)
       {
-         list.add(component);
+         // Check the name
+         if(isRecursiveScan() && component.getName().indexOf('.') == -1)
+         {
+            // recurse if not '.' in name and recursive search is enabled
+            addedDeployments(list, component);            
+         }
+         else
+         {
+            list.add(component);
+         }
       }
-      else if (component.getName().indexOf('.') == -1)
-      {
-         // recurse if not '.' in name and recursive search is enabled
-         addedDeployments(list, component);
-      }
       else
       {
          list.add(component);
-      }      
+      }
    }
    
    protected boolean acceptsDeployment(String name)
@@ -250,6 +267,13 @@
    {
       return new AbstractProfileDeployment(vf);
    }
+   
+   protected String addVirtualFileCache(VirtualFile vf) throws MalformedURLException, URISyntaxException
+   {
+      String uri = vf.toURI().toString();
+      this.applicationVFCache.put(uri, vf);
+      return uri;
+   }
 
    protected VirtualFile getCachedVirtualFile(String name)
    {

Copied: trunk/system/src/main/org/jboss/system/server/profileservice/repository/BasicDeploymentRepository.java (from rev 86733, branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/BasicDeploymentRepository.java)
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/BasicDeploymentRepository.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/BasicDeploymentRepository.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -0,0 +1,280 @@
+/*
+ * 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.repository;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.SyncFailedException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+import java.util.zip.ZipInputStream;
+
+import org.jboss.profileservice.spi.ModificationInfo;
+import org.jboss.profileservice.spi.ProfileDeployment;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.virtual.VFS;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * A basic deployment repository.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class BasicDeploymentRepository extends AbstractDeploymentRepository
+{
+
+   /** Should an attempt to overwrite existing content fail in {@link #addDeploymentContent(String, ZipInputStream)}*/
+   private boolean failIfAlreadyExists = false;
+   
+   /** A optional upload uri. */
+   private URI uploadUri;
+   
+   /** A lock for the hot deployment/{@link #getModifiedDeployments()} */
+   private ReentrantReadWriteLock lock = new ReentrantReadWriteLock(true);
+   
+   public BasicDeploymentRepository(ProfileKey key, URI[] uris)
+   {
+      super(key, uris);
+   }
+   
+   public boolean isFailIfAlreadyExists()
+   {
+      return failIfAlreadyExists;
+   }
+   
+   public void setFailIfAlreadyExists(boolean failIfAlreadyExists)
+   {
+      this.failIfAlreadyExists = failIfAlreadyExists;
+   }
+   
+   public URI getUploadUri()
+   {
+      if(uploadUri != null)
+         return uploadUri;
+
+      if(getRepositoryURIs() != null && getRepositoryURIs().length > 0)
+         return getRepositoryURIs()[0];
+      
+      throw new IllegalArgumentException("No upload uri available.");
+   }
+   
+   public void setUploadUri(URI uploadUri)
+   {
+      if(uploadUri == null)
+      {
+         this.uploadUri = null;
+         return;
+      }
+      // Validate
+      if(getRepositoryURIs() != null && getRepositoryURIs().length > 0)
+      {
+         if(Arrays.asList(getRepositoryURIs()).contains(uploadUri))
+         {
+            this.uploadUri = uploadUri;
+            return;
+         }
+      }
+      throw new IllegalArgumentException("Upload uri is not managed by this repository: "+ uploadUri);
+   }
+
+   public void load() throws Exception
+   {
+      for(URI uri : getRepositoryURIs())
+      {
+         VirtualFile root = getCachedVirtualFile(uri);
+         loadApplications(root);
+      }
+      updateLastModfied();
+   }
+   
+   public Collection<ModificationInfo> getModifiedDeployments() throws Exception
+   {
+      return Collections.emptySet();
+   }
+
+   public String addDeploymentContent(String vfsPath, InputStream contentIS) throws IOException
+   {
+      boolean trace = log.isTraceEnabled();
+      // Suspend hot deployment checking
+      if( trace )
+         log.trace("Aquiring content write lock");
+      lockWrite();
+      String repositoryName = null;
+      try
+      {
+         // Write the content out
+         File contentRoot = new File(getUploadUri()); 
+         if(contentRoot == null)
+            throw new FileNotFoundException("Failed to obtain content dir for phase: "+vfsPath);
+         if(contentRoot.isDirectory() == false)
+            throw new FileNotFoundException("The content root is not a directory." + contentRoot.getAbsolutePath());
+         // The content file
+         File contentFile = new File(contentRoot, vfsPath);
+         
+         // Check if it already exists
+         boolean exists = contentFile.exists();
+         if(exists && isFailIfAlreadyExists())
+            throw new SyncFailedException("Deployment content already exists: "+ contentFile.getAbsolutePath());
+         
+         // Copy streams
+         FileOutputStream fos = new FileOutputStream(contentFile);
+         try
+         {
+            byte[] tmp = new byte[4096];
+            int read;
+            while((read = contentIS.read(tmp)) > 0)
+            {
+               if (trace)
+                  log.trace("write, " + read);
+               fos.write(tmp, 0, read);
+            }
+            fos.flush();
+            // Get the vfs uri and add the VFS uri to the cached VFS uris
+            VirtualFile contentVF = VFS.getRoot(contentFile.toURI());
+            try
+            {
+               // Add the new virtual file to the cache
+               repositoryName = addVirtualFileCache(contentVF);
+               
+               // Cleanup 
+               if(exists)
+                  cleanUpRoot(contentVF);
+            }
+            catch(URISyntaxException e)
+            {
+               throw new RuntimeException(e); // This should not happen anyway
+            }
+         }
+         finally
+         {
+            try
+            {
+               fos.close();
+            }
+            catch (IOException ignored)
+            {
+            }
+         }
+
+         // Lock the content
+         lockDeploymentContent(repositoryName);
+      }
+      finally
+      {
+         // Allow hot deployment checking
+         unlockWrite();
+         if(trace)
+            log.trace("Released content write lock");
+      }
+      return repositoryName;
+   }
+   
+   public ProfileDeployment removeDeployment(String vfsPath) throws Exception
+   {
+      // Suspend hot deployment checking
+      if( log.isTraceEnabled() )
+         log.trace("Aquiring content write lock");
+      lockWrite();
+      try
+      {
+         // Remove the deployment from the filesystem
+         ProfileDeployment deployment = getDeployment(vfsPath);
+         VirtualFile root = deployment.getRoot();
+         
+         if(root != null)
+         {
+            // Delete the file
+            if(root.delete() == false)
+               throw new IOException("Failed to delete: " + root);
+            
+            cleanUpRoot(root);  
+         }
+         
+         // Cleanup
+         return super.removeDeployment(deployment.getName());
+      }
+      finally
+      {
+         unlockWrite();
+         if (log.isTraceEnabled())
+            log.trace("Released content write lock");
+      }
+   }
+   
+   /**
+    * A way for the hot-deployment repository to cleanup
+    * the root (modification checker).
+    * 
+    * @param vf the deployment root
+    */
+   protected void cleanUpRoot(VirtualFile vf)
+   {
+      //
+   }
+   
+   public void remove() throws Exception
+   {
+      // FIXME remove
+   }
+   
+   /**
+    * Lock for read
+    */
+   protected void lockRead()
+   {
+      lock.readLock().lock();
+   }
+
+   /**
+    * Unlock for read
+    */
+   protected void unlockRead()
+   {
+      lock.readLock().unlock();
+   }
+
+   /**
+    * Lock for write
+    */
+   protected void lockWrite()
+   {
+      lock.writeLock().lock();
+   }
+
+   /**
+    * Unlock for write
+    */
+   protected void unlockWrite()
+   {
+      lock.writeLock().unlock();
+   }
+
+}
+

Copied: trunk/system/src/main/org/jboss/system/server/profileservice/repository/BasicProfileFactory.java (from rev 86733, branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/BasicProfileFactory.java)
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/BasicProfileFactory.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/BasicProfileFactory.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -0,0 +1,88 @@
+/*
+ * 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.repository;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+
+import org.jboss.profileservice.spi.DeploymentRepository;
+import org.jboss.profileservice.spi.Profile;
+import org.jboss.profileservice.spi.ProfileFactory;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.ProfileRepository;
+import org.jboss.profileservice.spi.metadata.ProfileMetaData;
+import org.jboss.system.server.profile.repository.AbstractProfile;
+import org.jboss.system.server.profile.repository.metadata.BasicProfileMetaData;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class BasicProfileFactory extends AbstractProfileFactory implements ProfileFactory
+{
+   /** The deployment repository factory. */
+   private ProfileRepository profileRepository;
+   
+   /** The handled meta data types. */
+   public static final Collection<String> types;
+   
+   static
+   {
+      types = Arrays.asList(BasicProfileMetaData.class.getName());
+   }
+
+   public String[] getTypes()
+   {
+      return types.toArray(new String[types.size()]);
+   }
+   
+   public ProfileRepository getProfileRepository()
+   {
+      return profileRepository;
+   }
+   
+   public void setProfileRepository(ProfileRepository profileRepository)
+   {
+      this.profileRepository = profileRepository;
+   }
+   
+   public Profile createProfile(ProfileKey key, ProfileMetaData metaData, List<ProfileKey> subProfiles) throws Exception
+   {
+      if(key == null)
+         throw new IllegalArgumentException("Null profile key.");
+      if(metaData == null)
+         throw new IllegalArgumentException("Null profile meta data.");
+      
+      // Start to create the profile
+      DeploymentRepository repository = profileRepository.createProfileDeploymentRepository(key, metaData);
+      
+      // Create the profile
+      AbstractProfile profile = new AbstractProfile(repository, key);
+      
+      // Copy the sub-profile keys
+      profile.setSubProfiles(subProfiles);
+      
+      return profile;
+   }
+}
+

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/DefaultDeploymentRepositoryFactory.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/DefaultDeploymentRepositoryFactory.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/DefaultDeploymentRepositoryFactory.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -53,6 +53,12 @@
   
    /** The repository types. */
    public final static Collection<String> types; 
+   
+   /** A list of uploadURIs. */
+   private List<URI> uploadURIs;
+   
+   /** The isFailIfAlreadyExists property. */
+   private boolean failIfAlreadyExists = false;
 
    /** The deployment filter. */
    private VirtualFileFilter deploymentFilter;
@@ -79,6 +85,26 @@
    {
       this.deploymentFilter = deploymentFilter;
    }
+   
+   public boolean isFailIfAlreadyExists()
+   {
+      return failIfAlreadyExists;
+   }
+   
+   public void setFailIfAlreadyExists(boolean failIfAlreadyExists)
+   {
+      this.failIfAlreadyExists = failIfAlreadyExists;
+   }
+   
+   public List<URI> getUploadURIs()
+   {
+      return uploadURIs;
+   }
+   
+   public void setUploadURIs(List<URI> uploadURIs)
+   {
+      this.uploadURIs = uploadURIs;
+   }
 
    public StructureModificationChecker getChecker()
    {
@@ -118,25 +144,51 @@
          throw new IllegalArgumentException("Null profile key.");
       if(uris == null)
          throw new IllegalArgumentException("Null uris");
-      
+
+      BasicDeploymentRepository repository;
       if(mutable)
       {
-         MutableDeploymentRepository repository = new MutableDeploymentRepository(key, uris);
-         // Manually inject beans :)
-         repository.setDeploymentFilter(deploymentFilter);
-         repository.setChecker(checker);
-
-         return repository;
+         repository = new HotDeploymentRepository(key, uris);
+         // Set modification checker
+         ((HotDeploymentRepository)repository).setChecker(checker);
       }
       else
       {
-         ImmutableDeploymentRepository repository = new ImmutableDeploymentRepository(key, uris);
-         repository.setDeploymentFilter(deploymentFilter);
-         
-         return repository;
+         repository = new BasicDeploymentRepository(key, uris);
       }
+      // Set a optional upload dir
+      setUploadURI(repository);
+      // Set the deployment filter
+      repository.setDeploymentFilter(deploymentFilter);
+      // Set if the repository should override existing content
+      repository.setFailIfAlreadyExists(isFailIfAlreadyExists());
+      
+      return repository;
    }
    
+   /**
+    * Define a upload uri for a deployment repository.
+    * 
+    * @param repository the deployment repository
+    */
+   protected void setUploadURI(BasicDeploymentRepository repository)
+   {
+      if(this.uploadURIs != null && this.uploadURIs.isEmpty() == false)
+      {
+         URI[] repositoryURIs = repository.getRepositoryURIs();
+         if(repositoryURIs != null && repositoryURIs.length > 0)
+         {
+            for(URI repositoryURI : repositoryURIs)
+            {
+               if(this.uploadURIs.contains(repositoryURI))
+               {
+                  repository.setUploadUri(repositoryURI);
+               }
+            }
+         }
+      }
+   }
+   
    protected URI[] createUris(ProfileSourceMetaData metaData) throws URISyntaxException
    {
       List<URI> uris = new ArrayList<URI>();

Deleted: trunk/system/src/main/org/jboss/system/server/profileservice/repository/FilteredDeploymentRepositoryFactory.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/FilteredDeploymentRepositoryFactory.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/FilteredDeploymentRepositoryFactory.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -1,167 +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.repository;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
-import org.jboss.profileservice.spi.DeploymentRepository;
-import org.jboss.profileservice.spi.DeploymentRepositoryFactory;
-import org.jboss.profileservice.spi.ModificationInfo;
-import org.jboss.profileservice.spi.ProfileDeployment;
-import org.jboss.profileservice.spi.ProfileKey;
-import org.jboss.profileservice.spi.metadata.ProfileDeploymentMetaData;
-import org.jboss.profileservice.spi.metadata.ProfileSourceMetaData;
-import org.jboss.system.server.profile.repository.metadata.FilteredProfileSourceMetaData;
-import org.jboss.virtual.VirtualFile;
-
-/**
- * TODO
- * 
- * Create a filtered deployment repository, based on the deployments
- * of the filtered profile source meta data.
- * 
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public class FilteredDeploymentRepositoryFactory implements DeploymentRepositoryFactory
-{
-
-   /** The filtered immutable type. */
-   public final static String[] FACTORY_TYPE = new String[] { FilteredProfileSourceMetaData.class.getName() };
-   
-   public String[] getTypes()
-   {
-      return FACTORY_TYPE;
-   }
-
-   public DeploymentRepository createDeploymentRepository(ProfileKey key, ProfileSourceMetaData metaData)
-   throws Exception
-   {
-      if(metaData instanceof FilteredProfileSourceMetaData == false)
-         throw new IllegalArgumentException("Wrong profileSource meta data");
-      
-      return internalCreateRepository(key, (FilteredProfileSourceMetaData) metaData); 
-   }
-   
-   protected DeploymentRepository internalCreateRepository(ProfileKey key, FilteredProfileSourceMetaData metaData) throws Exception
-   {
-      if(metaData == null)
-         throw new IllegalArgumentException("Null metadata");
-      
-      List<String> deploymentList = new ArrayList<String>();
-      if(metaData.getDeployments() != null && metaData.getDeployments().isEmpty() == false)
-      {
-         for(ProfileDeploymentMetaData deployment : metaData.getDeployments())
-         {
-            String deploymentName = deployment.getName();
-            if(deploymentName != null)
-               deploymentList.add(deploymentName);
-         }
-      }
-      return new FilteredRepository(deploymentList, key, createUris(metaData)); 
-   }
-   
-   protected URI[] createUris(ProfileSourceMetaData metaData) throws URISyntaxException
-   {
-      List<URI> uris = new ArrayList<URI>();
-      for(String source : metaData.getSources())
-      {
-         URI uri = new URI(source);
-         uris.add(uri);
-      }
-      return uris.toArray(new URI[uris.size()]);
-   }
-   
-   /**
-    * A filtered deployment repository.
-    */
-   private class FilteredRepository extends AbstractDeploymentRepository
-   {
-      private List<String> deploymentNames;
-
-      public FilteredRepository(List<String> deploymentNames, ProfileKey key, URI[] uris)
-      {
-         super(key, uris);
-         this.deploymentNames = deploymentNames;
-      }
-      
-      public void load() throws Exception
-      {
-         // Load deployment names
-         for(String deploymentName : deploymentNames)
-         {
-            // Get the deployment content
-            VirtualFile vf = resolveDeploymentName(deploymentName);
-            // Load the deployment
-            ProfileDeployment deployment = createDeployment(vf);
-            // Add the deployment
-            addDeployment(deployment.getName(), deployment);
-         }
-         updateLastModfied();
-      }
-
-      public String addDeploymentContent(String vfsPath, InputStream contentIS) throws IOException
-      {
-         throw new RuntimeException("Cannot add deployment content to an immutable repository.");
-      }
-
-      @SuppressWarnings("unchecked")
-      public Collection<ModificationInfo> getModifiedDeployments() throws Exception
-      {
-         return Collections.EMPTY_LIST;
-      }
-
-      public void remove() throws Exception
-      {
-         // nothing
-      }
-      
-      protected VirtualFile resolveDeploymentName(String deploymentName) throws IOException
-      {
-         List<VirtualFile> list = new ArrayList<VirtualFile>();
-         for(URI uri : getRepositoryURIs())
-         {
-            VirtualFile repo = getCachedVirtualFile(uri);
-            VirtualFile vf = repo.getChild(deploymentName);
-            if(vf != null)
-               list.add(vf);
-         }
-         if(list.size() == 0)
-         {
-            throw new FileNotFoundException("Unable to find name: " + deploymentName);
-         }
-         else if (list.size() > 1)
-         {
-            throw new FileNotFoundException("Multiple matching names: " + deploymentName + " available " + list);
-         }
-         return list.get(0);
-      }
-   }   
-}

Copied: trunk/system/src/main/org/jboss/system/server/profileservice/repository/FilteredProfileFactory.java (from rev 86733, branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/FilteredProfileFactory.java)
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/FilteredProfileFactory.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/FilteredProfileFactory.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -0,0 +1,87 @@
+/*
+ * 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.repository;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+
+import org.jboss.profileservice.spi.Profile;
+import org.jboss.profileservice.spi.ProfileFactory;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.metadata.ProfileMetaData;
+import org.jboss.profileservice.spi.metadata.ProfileSourceMetaData;
+import org.jboss.system.server.profile.repository.AbstractImmutableProfile;
+import org.jboss.system.server.profile.repository.metadata.FilteredProfileMetaData;
+
+/**
+ * A filtered profile factory. This should create a profile based on the 
+ * deployments defined in the meta data.
+ * Currently this only creates a immutable profile, based on it's source.
+ * 
+ * @see {org.jboss.test.server.profileservice.support.FilteredProfileFactory}
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class FilteredProfileFactory extends AbstractProfileFactory implements ProfileFactory
+{
+
+   /** The profile meta data types. */
+   public static final Collection<String> types;
+   
+   static
+   {
+      types = Arrays.asList(FilteredProfileMetaData.class.getName());
+   }
+   
+   public String[] getTypes()
+   {
+      return types.toArray(new String[types.size()]);
+   }
+   
+   @Override
+   public Profile createProfile(ProfileKey key, ProfileMetaData metaData, List<ProfileKey> subProfiles)
+         throws URISyntaxException
+   {
+      return new AbstractImmutableProfile(key, createURIs(metaData), subProfiles);
+   }
+   
+   protected URI[] createURIs(ProfileMetaData metaData) throws URISyntaxException
+   {
+      ProfileSourceMetaData profileSource = metaData.getSource();
+      if(profileSource == null)
+         throw new IllegalArgumentException("Null profile source.");
+      
+      List<URI> uris = new ArrayList<URI>();
+      for(String source : profileSource.getSources())
+      {
+         URI uri = new URI(source);
+         uris.add(uri);
+      }
+      return uris.toArray(new URI[uris.size()]);
+   }
+   
+}

Copied: trunk/system/src/main/org/jboss/system/server/profileservice/repository/HotDeploymentRepository.java (from rev 86733, branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/HotDeploymentRepository.java)
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/HotDeploymentRepository.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/HotDeploymentRepository.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -0,0 +1,167 @@
+/*
+ * 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.repository;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.jboss.deployers.vfs.spi.structure.modified.StructureModificationChecker;
+import org.jboss.profileservice.spi.DeploymentContentFlags;
+import org.jboss.profileservice.spi.ModificationInfo;
+import org.jboss.profileservice.spi.ProfileDeployment;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.ModificationInfo.ModifyStatus;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * A deployment repository, with hot deployment capabilities.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ * @version $Revision$
+ */
+public class HotDeploymentRepository extends BasicDeploymentRepository
+{
+
+   /** The structure modification checker */
+   private StructureModificationChecker checker;
+   
+   public HotDeploymentRepository(ProfileKey key, URI[] uris)
+   {
+      super(key, uris);
+   }
+
+   /**
+    * Get the structure modified checker.
+    *
+    * @return the checker
+    */
+   protected StructureModificationChecker getChecker()
+   {
+      if (checker == null)
+         throw new IllegalArgumentException("Checker must be set");
+
+      return checker;
+   }
+
+   /**
+    * Set the checker.
+    *
+    * @param checker the checker
+    */
+   public void setChecker(StructureModificationChecker checker)
+   {
+      this.checker = checker;
+   }
+
+   @Override
+   public synchronized Collection<ModificationInfo> getModifiedDeployments() throws Exception
+   {
+      boolean trace = log.isTraceEnabled();
+      Collection<ProfileDeployment> apps = getDeployments();
+      ArrayList<ModificationInfo> modified = new ArrayList<ModificationInfo>();
+      if (trace)
+         log.trace("Checking applications for modifications");
+      if (trace)
+         log.trace("Aquiring content read lock");
+      lockRead();
+      try
+      {
+         if (apps != null)
+         {
+            Iterator<ProfileDeployment> iter = apps.iterator();
+            while (iter.hasNext())
+            {
+               ProfileDeployment ctx = iter.next();
+               VirtualFile root = ctx.getRoot();
+               String pathName = ctx.getName();
+               // Ignore locked or disabled applications
+               if (this.hasDeploymentContentFlags(pathName, ignoreFlags))
+               {
+                  if (trace)
+                     log.trace("Ignoring locked application: " + root);
+                  continue;
+               }
+               // Check for removal
+               if (root.exists() == false)
+               {
+                  long rootLastModified = root.getLastModified();
+                  ModificationInfo info = new ModificationInfo(ctx, rootLastModified, ModifyStatus.REMOVED);
+                  modified.add(info);
+                  iter.remove();
+                  // Remove last modified cache
+                  cleanUpRoot(root);
+                  if (trace)
+                     log.trace(pathName + " was removed");
+               }
+               // Check for modification
+               else if (hasDeploymentContentFlags(pathName, DeploymentContentFlags.MODIFIED)
+                     || getChecker().hasStructureBeenModified(root))
+               {
+                  long rootLastModified = root.getLastModified();
+                  if (trace)
+                     log.trace(pathName + " was modified: " + rootLastModified);
+                  // Create the modification info
+                  ModificationInfo info = new ModificationInfo(ctx, rootLastModified, ModifyStatus.MODIFIED);
+                  modified.add(info);
+               }
+            }
+            // Now check for additions
+            for (URI applicationDir : getRepositoryURIs())
+            {
+               VirtualFile deployDir = getCachedVirtualFile(applicationDir);
+               ArrayList<VirtualFile> added = new ArrayList<VirtualFile>();
+               addedDeployments(added, deployDir);
+               for (VirtualFile vf : added)
+               {
+                  // Create deployment
+                  ProfileDeployment ctx = createDeployment(vf);
+                  // Create modification info
+                  ModificationInfo info = new ModificationInfo(ctx, vf.getLastModified(), ModifyStatus.ADDED);
+                  // Add
+                  modified.add(info);
+                  addDeployment(ctx.getName(), ctx);
+                  getChecker().addStructureRoot(vf);
+               }
+            }
+         }
+      }
+      finally
+      {
+         unlockRead();
+         if (trace)
+            log.trace("Released content read lock");
+      }
+
+      if (modified.size() > 0)
+         updateLastModfied();
+      return modified;
+   }
+   
+   @Override
+   protected void cleanUpRoot(VirtualFile vf)
+   {
+      getChecker().removeStructureRoot(vf);
+   }
+}

Deleted: trunk/system/src/main/org/jboss/system/server/profileservice/repository/ImmutableDeploymentRepository.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/ImmutableDeploymentRepository.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/ImmutableDeploymentRepository.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -1,74 +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.repository;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URI;
-import java.util.Collection;
-import java.util.Collections;
-
-import org.jboss.profileservice.spi.ModificationInfo;
-import org.jboss.profileservice.spi.ProfileKey;
-import org.jboss.virtual.VirtualFile;
-
-/**
- * A immutable deployment repository.
- * 
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public class ImmutableDeploymentRepository extends AbstractDeploymentRepository
-{
-
-   public ImmutableDeploymentRepository(ProfileKey key, URI[] uris)
-   {
-      super(key, uris);
-   }
-
-   public void load() throws Exception
-   {
-      for(URI uri : getRepositoryURIs())
-      {
-         VirtualFile root = getCachedVirtualFile(uri);
-         loadApplications(root);
-      }
-      updateLastModfied();
-   }
-   
-   public Collection<ModificationInfo> getModifiedDeployments() throws Exception
-   {
-      return Collections.emptySet();
-   }
-
-   public String addDeploymentContent(String vfsPath, InputStream contentIS) throws IOException
-   {
-      throw new IllegalStateException("Cannot add content to an immutable repository.");
-   }
-
-   public void remove() throws Exception
-   {
-      throw new IllegalStateException("Cannot remove immutable repository.");
-   }
-
-}
-

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-04-03 11:43:54 UTC (rev 86738)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/JAXBAttachmentSerializer.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -22,6 +22,10 @@
 package org.jboss.system.server.profileservice.repository;
 
 import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
 
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.Marshaller;
@@ -69,18 +73,37 @@
    protected <T> T loadAttachment(File attachmentsStore, Class<T> expected) throws Exception
    {
       // JBoss XB
+      log.trace("loadAttachment, attachmentsStore="+attachmentsStore);
       Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
-      return (T) unmarshaller.unmarshal(attachmentsStore.toURL().openStream(), resolver);
+      unmarshaller.setValidation(false);
+      unmarshaller.setSchemaValidation(false);
+      InputStream is = new FileInputStream(attachmentsStore);
+      try
+      {
+         return (T) unmarshaller.unmarshal(is, resolver);
+      }
+      finally
+      {
+         is.close();
+      }
    }
 
    protected void saveAttachment(File attachmentsStore, Object attachment) throws Exception
    {
       // JAXB
-      log.trace("saveAttachments, attachmentsStore="+attachmentsStore+ ", attachment="+attachment);
+      log.trace("saveAttachment, 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);
+      OutputStream os = new FileOutputStream(attachmentsStore);
+      try
+      {
+         marshaller.marshal(attachment, os);
+      }
+      finally
+      {
+         os.close();
+      }
    }
    
    @Override

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-04-03 11:43:54 UTC (rev 86738)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/MainDeployerAdapter.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -118,6 +118,17 @@
    }
    
    /**
+    * Check complete
+    * 
+    * @param names the deployment names
+    * @throws DeploymentExcetion
+    */
+   public void checkComplete(String... names) throws DeploymentException
+   {
+      this.mainDeployer.checkComplete(names);
+   }
+   
+   /**
     * CheckComplete
     * 
     * @throws DeploymentException

Deleted: trunk/system/src/main/org/jboss/system/server/profileservice/repository/MutableDeploymentRepository.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/MutableDeploymentRepository.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/MutableDeploymentRepository.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -1,283 +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.repository;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.SyncFailedException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-import java.util.zip.ZipInputStream;
-
-import org.jboss.deployers.vfs.spi.structure.modified.StructureModificationChecker;
-import org.jboss.profileservice.spi.DeploymentContentFlags;
-import org.jboss.profileservice.spi.ModificationInfo;
-import org.jboss.profileservice.spi.ProfileDeployment;
-import org.jboss.profileservice.spi.ProfileKey;
-import org.jboss.profileservice.spi.ModificationInfo.ModifyStatus;
-import org.jboss.virtual.VFS;
-import org.jboss.virtual.VirtualFile;
-
-/**
- * A mutable deployment repository, with hot deployment capabilities.
- * 
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
- * @version $Revision$
- */
-public class MutableDeploymentRepository extends AbstractDeploymentRepository
-{
-   /** Should an attempt to overwrite existing content fail in {@link #addDeploymentContent(String, ZipInputStream)}*/
-   private boolean failIfAlreadyExists = false;
-
-   /** The structure modification checker */
-   private StructureModificationChecker checker;
-
-   /** A lock for the hot deployment/{@link #getModifiedDeployments()} */
-   private ReentrantReadWriteLock contentLock = new ReentrantReadWriteLock(true);
-   
-   public MutableDeploymentRepository(ProfileKey key, URI[] uris)
-   {
-      super(key, uris);
-   }
-
-   /**
-    * Get the structure modified checker.
-    *
-    * @return the checker
-    */
-   protected StructureModificationChecker getChecker()
-   {
-      if (checker == null)
-         throw new IllegalArgumentException("Checker must be set");
-
-      return checker;
-   }
-
-   /**
-    * Set the checker.
-    *
-    * @param checker the checker
-    */
-   public void setChecker(StructureModificationChecker checker)
-   {
-      this.checker = checker;
-   }
-
-   public void load() throws Exception
-   {
-      for(URI uri : getRepositoryURIs())
-      {
-         VirtualFile root = getCachedVirtualFile(uri);
-         loadApplications(root);
-      }
-      updateLastModfied();
-   }
-   
-   public String addDeploymentContent(String vfsPath, InputStream contentIS) throws IOException
-   {
-      boolean trace = log.isTraceEnabled();
-      // Suspend hot deployment checking
-      if( trace )
-         log.trace("Aquiring content write lock");
-      contentLock.writeLock().lock();
-      String repositoryName = null;
-      try
-      {
-         if(getRepositoryURIs().length == 0)
-            throw new IllegalStateException("No uris associated with this repository.");
-         
-         // FIXME, this is writing the content to the first URI
-         // Write the content out
-         File contentRoot = new File(getRepositoryURIs()[0]); 
-         if(contentRoot == null)
-            throw new FileNotFoundException("Failed to obtain content dir for phase: "+vfsPath);
-         File contentFile = new File(contentRoot, vfsPath);
-         
-         if(failIfAlreadyExists && contentFile.exists())
-            throw new SyncFailedException("Deployment content already exists: "+contentFile.getAbsolutePath());
-         FileOutputStream fos = new FileOutputStream(contentFile);
-         try
-         {
-            byte[] tmp = new byte[4096];
-            int read;
-            while((read = contentIS.read(tmp)) > 0)
-            {
-               if (trace)
-                  log.trace("write, " + read);
-               fos.write(tmp, 0, read);
-            }
-            fos.flush();
-            // Get the vfs uri and add the VFS uri to the cached VFS uris
-            VirtualFile contentVF = VFS.getRoot(contentFile.toURI());
-            try
-            {
-               contentVF = getCachedVirtualFile(contentVF.toURI());
-               repositoryName = contentVF.toURI().toString();
-            }
-            catch(URISyntaxException e)
-            {
-               throw new RuntimeException(e); // This should not happen anyway
-            }
-         }
-         finally
-         {
-            try
-            {
-               fos.close();
-            }
-            catch (IOException ignored)
-            {
-            }
-         }
-
-         // Lock the content
-         lockDeploymentContent(repositoryName);
-      }
-      finally
-      {
-         // Allow hot deployment checking
-         contentLock.writeLock().unlock();
-         if(trace)
-            log.trace("Released content write lock");
-      }
-      return repositoryName;
-   }
-
-   public synchronized Collection<ModificationInfo> getModifiedDeployments() throws Exception
-   {
-      ArrayList<ModificationInfo> modified = new ArrayList<ModificationInfo>();
-      Collection<ProfileDeployment> apps = getDeployments();
-      boolean trace = log.isTraceEnabled();
-      if (trace)
-         log.trace("Checking applications for modifications");
-      if (trace)
-         log.trace("Aquiring content read lock");
-      contentLock.readLock().lock();
-      try
-      {
-         if (apps != null)
-         {
-            Iterator<ProfileDeployment> iter = apps.iterator();
-            while (iter.hasNext())
-            {
-               ProfileDeployment ctx = iter.next();
-               VirtualFile root = ctx.getRoot();
-               String pathName = ctx.getName();
-               // Ignore locked or disabled applications
-               if (this.hasDeploymentContentFlags(pathName, ignoreFlags))
-               {
-                  if (trace)
-                     log.trace("Ignoring locked application: " + root);
-                  continue;
-               }
-               // Check for removal
-               if (root.exists() == false)
-               {
-                  long rootLastModified = root.getLastModified();
-                  ModificationInfo info = new ModificationInfo(ctx, rootLastModified, ModifyStatus.REMOVED);
-                  modified.add(info);
-                  iter.remove();
-                  // Remove last modified cache
-                  getChecker().removeStructureRoot(root);
-                  if (trace)
-                     log.trace(pathName + " was removed");
-               }
-               // Check for modification
-               else if (getChecker().hasStructureBeenModified(root) || hasDeploymentContentFlags(pathName, DeploymentContentFlags.MODIFIED))
-               {
-                  long rootLastModified = root.getLastModified();
-                  if (trace)
-                     log.trace(pathName + " was modified: " + rootLastModified);
-                  // Create the modification info
-                  ModificationInfo info = new ModificationInfo(ctx, rootLastModified, ModifyStatus.MODIFIED);
-                  modified.add(info);
-               }
-            }
-            // Now check for additions
-            for (URI applicationDir : getRepositoryURIs())
-            {
-               VirtualFile deployDir = getCachedVirtualFile(applicationDir);
-               ArrayList<VirtualFile> added = new ArrayList<VirtualFile>();
-               addedDeployments(added, deployDir);
-               for (VirtualFile vf : added)
-               {
-                  // Create deployment
-                  ProfileDeployment ctx = createDeployment(vf);
-                  // Create modification info
-                  ModificationInfo info = new ModificationInfo(ctx, vf.getLastModified(), ModifyStatus.ADDED);
-                  // Add
-                  modified.add(info);
-                  addDeployment(ctx.getName(), ctx);
-                  getChecker().addStructureRoot(vf);
-               }
-            }
-         }
-      }
-      finally
-      {
-         contentLock.readLock().unlock();
-         if (trace)
-            log.trace("Released content read lock");
-      }
-
-      if (modified.size() > 0)
-         updateLastModfied();
-      return modified;
-   }
-
-   public ProfileDeployment removeDeployment(String vfsPath) throws Exception
-   {
-      // Suspend hot deployment checking
-      if( log.isTraceEnabled() )
-         log.trace("Aquiring content write lock");
-      contentLock.writeLock().lock();
-      try
-      {
-         // Remove the deployment from the filesystem
-         ProfileDeployment deployment = getDeployment(vfsPath);
-         VirtualFile root = deployment.getRoot();
-         if(root.delete() == false)
-            throw new IOException("Failed to delete: " + root);
-         // Cleanup
-         return super.removeDeployment(deployment.getName());
-      }
-      finally
-      {
-         contentLock.writeLock().unlock();
-         if (log.isTraceEnabled())
-            log.trace("Released content write lock");
-      }
-   }
-   
-   public void remove() throws Exception
-   {
-      // FIXME remove
-   }
-}

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/ProfileDeployAction.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/ProfileDeployAction.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/ProfileDeployAction.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -38,7 +38,7 @@
 
    /** The profile deployment deployer. */
    private MainDeployerAdapter deployer;
-   
+  
    public ProfileDeployAction(MainDeployerAdapter deployer)
    {
       if(deployer == null)
@@ -47,25 +47,33 @@
    }
    
    @Override
-   public void install(Profile profile) throws Exception
+   public void install(Profile profile)
    {
       Collection<ProfileDeployment> deployments = profile.getDeployments();
       if (deployments != null && !deployments.isEmpty())
       {
          // Add deployments
          for (ProfileDeployment deployment : profile.getDeployments())
-            deployer.addDeployment(deployment);
+         {
+            try
+            {
+               // Add deployment
+               deployer.addDeployment(deployment);
+            }
+            catch(Exception e)
+            {
+               log.error("Failed to add deployment: " + deployment, e);
+            }
+         }
+            
          // deploy
          deployer.process();
-         // TODO do we need some additional meta data to do e.g.: ?
-         // deployer.checkComplete();
       }
    }
 
    @Override
-   public void uninstall(Profile profile) throws Exception
+   public void uninstall(Profile profile)
    {
-      // Handle deployments
       Collection<ProfileDeployment> deployments = profile.getDeployments();
       if (deployments != null && !deployments.isEmpty())
       {
@@ -74,23 +82,17 @@
          {
             try
             {
-               // remove deployments
+               // remove deployment
                deployer.removeDeployment(deployment);
             }
             catch(Throwable t)
             {
-               log.warn("failed to  undeploy: " + t);
+               log.warn("failed to remove deployment: " + deployment, t);
             }
          }
+         
          // undeploy
-         try
-         {
-            deployer.process();
-         }
-         catch (Throwable t)
-         {
-            log.warn("Error on releasing profile: ", t);
-         }
+         deployer.process();
       }
    }
 }

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/StaticProfileFactory.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/StaticProfileFactory.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/StaticProfileFactory.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -35,6 +35,8 @@
 import org.jboss.system.server.profile.repository.metadata.AbstractProfileSourceMetaData;
 import org.jboss.system.server.profile.repository.metadata.BasicProfileMetaData;
 import org.jboss.system.server.profile.repository.metadata.BasicSubProfileMetaData;
+import org.jboss.system.server.profile.repository.metadata.EmptyProfileMetaData;
+import org.jboss.system.server.profile.repository.metadata.FilteredProfileMetaData;
 import org.jboss.system.server.profile.repository.metadata.HotDeploymentProfileSourceMetaData;
 import org.jboss.system.server.profile.repository.metadata.ImmutableProfileSourceMetaData;
 
@@ -167,8 +169,9 @@
       
       // Create bootstrap profile meta data
       ProfileKey bootstrapKey = new ProfileKey(bootstrapName);
-      ProfileMetaData bootstrap = createProfileMetaData(
-            bootstrapName, false, new URI[] { bootstrapURI }, new String[0]);
+      BasicProfileMetaData bootstrap = new FilteredProfileMetaData(
+            null, null, bootstrapName);
+      bootstrap.setSource(createSource(new URI[]{ bootstrapURI }, false));
       addProfile(bootstrapKey, bootstrap);
       
       // Create deployers profile meta data
@@ -188,55 +191,65 @@
       
       // Create empty root profile;
       String[] rootSubProfiles = new String[] { applicationsName };
-      ProfileMetaData root = createProfileMetaData(
-            rootKey.getName(), false, new URI[0], rootSubProfiles);
+      ProfileMetaData root = new EmptyProfileMetaData(
+            null, null, rootKey.getName(), createSubProfileMetaData(rootSubProfiles)); 
+
       // Add to profile map
       addProfile(rootKey, root);
    }
    
    /**
-    * Create a profile meta data.
+    * Create a basic profile meta data. This profile will have it's own
+    * DeploymentRepository and therefore exposed in the DeploymentManager
+    * for deploy actions.
     * 
     * @param name the profile name.
-    * @param hotDeployment if it's a hotDeployment profile
+    * @param isHotDeployment if hotDeployment is enabled.
     * @param uris the repository uris.
     * @param subProfiles a list of profile dependencies.
     * 
     * @return the profile meta data.
     */
-   protected ProfileMetaData createProfileMetaData(String name, boolean hotDeployment, URI[] uris, String[] subProfiles)
+   protected ProfileMetaData createProfileMetaData(String name, boolean isHotDeployment, URI[] uris, String[] subProfiles)
    {
       // Create profile
-      BasicProfileMetaData metaData = new BasicProfileMetaData();
-      metaData.setName(name);
+      BasicProfileMetaData metaData = new BasicProfileMetaData(null, null, name);
+      
       // Create profile sources
-      ProfileSourceMetaData source = createSource(uris, hotDeployment);
-      metaData.setSource(source);
+      metaData.setSource(createSource(uris, isHotDeployment));
       
-      List<SubProfileMetaData> profileList = new ArrayList<SubProfileMetaData>();
-      for(String subProfile : subProfiles)
-      {
-         BasicSubProfileMetaData md = new BasicSubProfileMetaData();
-         md.setName(subProfile);
-         profileList.add(md);
-      }
-      metaData.setSubprofiles(profileList);
+      // Set subProfiles
+      metaData.setSubprofiles(createSubProfileMetaData(subProfiles));
       
       return metaData;
    }
    
+   protected List<SubProfileMetaData> createSubProfileMetaData(String[] subProfiles)
+   {
+      List<SubProfileMetaData> subProfileList = new ArrayList<SubProfileMetaData>();
+      if(subProfiles != null && subProfiles.length > 0)
+      {
+         for(String profileName : subProfiles)
+         {
+            subProfileList.add(new BasicSubProfileMetaData(null, null, profileName));
+         }
+      }
+      return subProfileList;
+   }
+   
+   
    /**
     * Create a profile repository source meta data.
     * 
     * @param uris the uris for the repository
-    * @param hotDeployment to create a hotDeployment profile
+    * @param isHotDeployment to create a hotDeployment profile
     * 
     * @return the profile source meta data.
     */
-   protected ProfileSourceMetaData createSource(URI[] uris, boolean hotDeployment)
+   protected ProfileSourceMetaData createSource(URI[] uris, boolean isHotDeployment)
    {
       AbstractProfileSourceMetaData source = null;
-      if(hotDeployment)
+      if(isHotDeployment)
       {
          source = new HotDeploymentProfileSourceMetaData();
       }

Copied: trunk/system/src/main/org/jboss/system/server/profileservice/repository/TypedProfileFactory.java (from rev 86733, branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/TypedProfileFactory.java)
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/TypedProfileFactory.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/TypedProfileFactory.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -0,0 +1,146 @@
+/*
+ * 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.repository;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.jboss.profileservice.spi.Profile;
+import org.jboss.profileservice.spi.ProfileFactory;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.metadata.ProfileMetaData;
+import org.jboss.system.server.profile.repository.NoopProfile;
+import org.jboss.system.server.profile.repository.metadata.EmptyProfileMetaData;
+
+/**
+ * A typed profile factory. This delegates the creation of profiles to 
+ * the registered factories, based on the class name of the profile meta data. 
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class TypedProfileFactory extends AbstractProfileFactory implements ProfileFactory
+{
+
+   /** The profile factories. */
+   private Map<String, AbstractProfileFactory> factories = new ConcurrentHashMap<String, AbstractProfileFactory>();
+   
+   /** The locally handled types. */
+   public static final Collection<String> types;
+   
+   static
+   {
+      types = Arrays.asList(EmptyProfileMetaData.class.getName());
+   }
+   
+   public String[] getTypes()
+   {
+      return types.toArray(new String[types.size()]);
+   }
+   
+   public Profile createProfile(ProfileKey key, ProfileMetaData metaData, List<ProfileKey> subProfiles) throws Exception
+   {
+      if(key == null)
+         throw new IllegalArgumentException("Null profile key.");
+      if(metaData == null)
+         throw new IllegalArgumentException("Null profile meta data");
+      
+      String profileType = metaData.getClass().getName();
+      if(types.contains(profileType))
+      {
+         return createNoopProfile(key, metaData, subProfiles);
+      }
+      // Delegate to registered factories
+      return delegateCreateProfile(profileType, key, metaData, subProfiles);
+   }
+   
+   /**
+    * Delegate the creation of the profile to one of the registered
+    * profile factories.
+    * 
+    * @param type the meta data type
+    * @param key the profile key
+    * @param metaData the profile meta data
+    * @param subProfiles the sub profiles
+    * @return the profile
+    * @throws IllegalArgumentException if there is no factory registered for the meta data type
+    * @throws Exception for any error
+    */
+   protected Profile delegateCreateProfile(String type, ProfileKey key, ProfileMetaData metaData, List<ProfileKey> subProfiles) throws IllegalArgumentException, Exception
+   {
+      AbstractProfileFactory factory = this.factories.get(type);
+      if(factory == null)
+         throw new IllegalArgumentException("Unrecognized meta data type: " + type);
+      
+      return factory.createProfile(key, metaData, subProfiles);
+   }
+   
+   /**
+    * Create a empty profile. 
+    * 
+    * @param key the profile key
+    * @param metaData the profile meta data
+    * @param subProfiles the sub profiles
+    * @return the profile
+    */
+   protected Profile createNoopProfile(ProfileKey key, ProfileMetaData metaData, List<ProfileKey> subProfiles)
+   {
+      return new NoopProfile(key, subProfiles);
+   }
+   
+   /**
+    * Add a profile factory.
+    * 
+    * @param factory the abstract profile factory to add
+    */
+   public void addProfileFactory(AbstractProfileFactory factory)
+   {
+      if(factory == null)
+         throw new IllegalArgumentException("Null profile factory.");
+      if(factory.getTypes() == null)
+         throw new IllegalArgumentException("Null factory types.");
+      
+      for(String type : factory.getTypes())
+         this.factories.put(type, factory);
+   }
+   
+   /**
+    * Remove a profile factory.
+    * 
+    * @param factory the abstract profile factory to remove
+    */
+   public void removeProfileFactory(AbstractProfileFactory factory)
+   {
+      if(factory == null)
+         throw new IllegalArgumentException("Null profile factory.");
+      if(factory.getTypes() == null)
+         throw new IllegalArgumentException("Null factory types.");
+      
+      for(String type : factory.getTypes())
+         this.factories.remove(type);
+   }
+
+}
+

Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/TypedProfileRepository.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/TypedProfileRepository.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/TypedProfileRepository.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -32,7 +32,6 @@
 import org.jboss.profileservice.spi.ProfileRepository;
 import org.jboss.profileservice.spi.metadata.ProfileMetaData;
 import org.jboss.profileservice.spi.metadata.ProfileSourceMetaData;
-import org.jboss.system.server.profile.repository.metadata.FilteredProfileSourceMetaData;
 
 /**
  * The profile repository.
@@ -90,12 +89,6 @@
    
          ProfileSourceMetaData source = metaData.getSource();
          
-         // FIXME the filtering should be done by the profile itself!
-         if(source instanceof FilteredProfileSourceMetaData)
-         {
-            ((FilteredProfileSourceMetaData) source).setDeployments(metaData.getDeployments());
-         }
-         
          // TODO check if there is a conflict with hotdeployment repositories
          repository = createProfileDeploymentRepository(key, type , source);
          if(repository != null)

Deleted: trunk/system/src/main/org/jboss/system/server/profileservice/repository/XmlProfileFactory.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/XmlProfileFactory.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/XmlProfileFactory.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -1,317 +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.repository;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.net.URI;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import org.jboss.profileservice.spi.ProfileKey;
-import org.jboss.profileservice.spi.metadata.ProfileMetaData;
-import org.jboss.profileservice.spi.metadata.SubProfileMetaData;
-import org.jboss.system.server.profile.repository.metadata.FilteredProfileMetaData;
-import org.jboss.system.server.profile.repository.metadata.HotDeploymentProfileMetaData;
-import org.jboss.system.server.profile.repository.metadata.ProfilesMetaData;
-import org.jboss.virtual.VFS;
-import org.jboss.virtual.VirtualFile;
-import org.jboss.xb.binding.JBossXBException;
-import org.jboss.xb.binding.Unmarshaller;
-import org.jboss.xb.binding.UnmarshallerFactory;
-import org.jboss.xb.binding.sunday.unmarshalling.DefaultSchemaResolver;
-import org.jboss.xb.binding.sunday.unmarshalling.SingletonSchemaResolverFactory;
-
-/**
- * A profile factory based which generates the ProfileMetaData based on .xml files.
- * 
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public class XmlProfileFactory extends AbstractBootstrapProfileFactory
-{
-   /** The profiles directory name. */
-   public final static String PROFILES_SUFFIX = ".profile";
-   
-   /** The attachment store uri. */
-   private File attachmentStoreRoot;
-   
-   /** Profile directories */
-   private Collection<VirtualFile> profileDirectories;
-   
-   /** The unmarshaller. */
-   private Unmarshaller unmarshaller;
-   
-   /** The parsed file list */
-   private Collection<ProfileKey> processedProfileKeys = new ArrayList<ProfileKey>();
-
-   /** The default schema resolver. */
-   private static final DefaultSchemaResolver resolver = (DefaultSchemaResolver) SingletonSchemaResolverFactory.getInstance().getSchemaBindingResolver();
-   
-   static
-   {
-      // Add schema bindings
-      resolver.addClassBinding("urn:jboss:profileservice:profiles:1.0", ProfilesMetaData.class);
-      resolver.addClassBinding("urn:jboss:profileservice:profile:filtered:1.0", FilteredProfileMetaData.class);
-      resolver.addClassBinding("urn:jboss:profileservice:profile:hotdeployment:1.0", HotDeploymentProfileMetaData.class);
-   }
-   
-   public XmlProfileFactory(URI[] profileDirectories) throws Exception
-   {
-      if(profileDirectories == null)
-         throw new IllegalArgumentException("Null directories");
-      this.profileDirectories = new ArrayList<VirtualFile>();
-      for(URI uri : profileDirectories)
-      {
-         VirtualFile vf = VFS.getRoot(uri);
-         if(vf == null)
-            throw new IllegalArgumentException("Could not find uri: " + vf);
-         if(vf.isLeaf())
-            throw new IllegalArgumentException("Not a directory: " + vf);
-         this.profileDirectories.add(vf);
-      }
-   }
-   
-   public Collection<VirtualFile> getProfileDirectories()
-   {
-      return profileDirectories;
-   }
-   
-   public void setProfileDirectories(Collection<VirtualFile> profileDirectories)
-   {
-      this.profileDirectories = profileDirectories;
-   }   
-   
-   public File getAttachmentStoreRoot()
-   {
-      return attachmentStoreRoot;
-   }
-
-   public void setAttachmentStoreRoot(File attachmentStoreRoot)
-   {
-      this.attachmentStoreRoot = attachmentStoreRoot;
-   }
-   
-   /**
-    * Create the profile meta data.
-    * 
-    * @param rootKey the key of the profile/
-    * @param the url pointing to the profile file.
-    * @throws Exception
-    */
-   @Override
-   protected void createProfileMetaData(ProfileKey rootKey, URL url) throws Exception
-   {
-      // Create the unmarshaller
-      this.unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
-
-      // Get the root profile virtual file
-      VirtualFile vf = getProfileFile(rootKey, url);
-      // Parse
-      ProfilesMetaData rootProfiles = parse(vf);
-      // Process
-      processProfilesMetaData(rootProfiles);
-   }
-   
-   /**
-    * process the profile meta data.
-    * 
-    * @param metaData the profile meta data.
-    * @throws Exception
-    */
-   protected void processProfileMetaData(ProfileMetaData metaData) throws Exception
-   {
-      // Create profileKey
-      ProfileKey key = createProfileKey(metaData);      
-      processProfileMetaData(key, metaData);
-   }
-   
-   /**
-    * process the profile meta data
-    * 
-    * @param key the profile key.
-    * @param metaData the meta data.
-    * 
-    * @throws Exception
-    */
-   protected void processProfileMetaData(ProfileKey key, ProfileMetaData metaData) throws Exception
-   {      
-      // Don't process the same key twice
-      if(this.processedProfileKeys.contains(key))
-         return;
-
-      // Add profile meta data
-      addProfile(key, metaData);
-      
-      // Process sub profiles
-      processSubProfiles(key, metaData);
-   }
-   
-   /**
-    * process the sub profiles.
-    * 
-    * @param key the profile key.
-    * @param metaData the profile meta data
-    * @throws Exception
-    */
-   protected void processSubProfiles(ProfileKey key, ProfileMetaData metaData) throws Exception
-   {
-      if(metaData.getSubprofiles() != null && metaData.getSubprofiles().isEmpty() == false)
-      {
-         for(SubProfileMetaData subProfile : metaData.getSubprofiles())
-         {
-            ProfileKey subProfileKey = createProfileKey(subProfile);
-            processSubProfileMetaData(subProfileKey, subProfile);
-         }
-      }
-   }
-   
-   /**
-    * process the sub profile.
-    * 
-    * @param key the sub profile key.
-    * @param metaData the sub profile meta data.
-    * @throws Exception
-    */
-   protected void processSubProfileMetaData(ProfileKey key, SubProfileMetaData metaData) throws Exception
-   {
-      // get file
-      VirtualFile vf = getProfileFile(key, null);
-      // parse
-      ProfilesMetaData profiles = parse(vf);
-      // TODO maybe override the profiles key (as it should be the same - filename and profiles name
-      // processProfilesMetaData(key, profiles);
-      processProfilesMetaData(profiles);
-   }
-   
-   /**
-    * process the profiles meta data.
-    * 
-    * @param key the profiles key.
-    * @param metaData the profiles meta data.
-    * @throws Exception
-    */
-   protected void processProfilesMetaData(ProfileKey key, ProfilesMetaData metaData) throws Exception
-   {
-      if(metaData.getProfiles() != null && metaData.getProfiles().isEmpty() == false)
-      {
-         for(ProfileMetaData profile : metaData.getProfiles())
-         {
-            processProfileMetaData(profile);
-         }
-      }
-      // Add the profiles for later resolution
-      addProfiles(key, metaData.getProfiles());      
-   }
-   
-   /**
-    * Process the <profiles> meta data.
-    * This will add dependencies based on the ordering of the xml.
-    * 
-    * @param profilesMetaData the profiles meta data
-    */
-   protected void processProfilesMetaData(ProfilesMetaData profilesMetaData) throws Exception
-   {
-      // The <profiles> key
-      ProfileKey profilesKey = createProfileKey(profilesMetaData);
-      processProfilesMetaData(profilesKey, profilesMetaData);
-   }
-
-   /**
-    * get the virtual file of the profile.
-    * 
-    * @param key the profile key.
-    * @param url the url pointing to the file
-    * @return a resolved name if the url is null.
-    * 
-    * @throws Exception
-    */
-   protected VirtualFile getProfileFile(ProfileKey key, URL url) throws Exception
-   {
-      if(url != null)
-         return VFS.getRoot(url);
-      else
-         return resolveFile(key.getName());
-   }
-   
-   /**
-    * Try to resolve the profile name.
-    * 
-    * @param name the profile name.
-    * @return the virtual file
-    * @throws Exception
-    */
-   protected VirtualFile resolveFile(String name) throws Exception
-   {
-      // ProfileKey.getName() + .profile
-      if(name.endsWith(PROFILES_SUFFIX) == false)
-         name = name + PROFILES_SUFFIX;
-         
-      VirtualFile vf = null;
-      for(VirtualFile dir : profileDirectories)
-      {
-         vf = dir.getChild(name);
-         if(vf != null)
-            break;
-      }
-      if(vf == null)
-         throw new FileNotFoundException("Could not find profile configuration file for: " + name);
-      return vf;
-   }
-   
-   /**
-    * Parse a profile file.
-    * 
-    * @param vf the virtual file.
-    * @return the <profiles> meta data
-    * @throws JBossXBException
-    * @throws IOException
-    */
-   protected ProfilesMetaData parse(VirtualFile vf) throws JBossXBException, IOException
-   {
-      if(log.isTraceEnabled())
-         log.trace("parsing file: " + vf.getPathName());
-      return (ProfilesMetaData) unmarshaller.unmarshal(vf.openStream(), resolver);
-   }
-   
-   @Override
-   protected void addProfile(ProfileKey key, ProfileMetaData metaData)
-   {
-      // Add to processed keys
-      processedProfileKeys.add(key);
-      // Add to parent
-      super.addProfile(key, metaData);
-   }
-   
-   @Override
-   protected void addProfiles(ProfileKey key, List<ProfileMetaData> metaData)
-   {
-      // Add to processed keys
-      processedProfileKeys.add(key);
-      // Add to pared
-      super.addProfiles(key, metaData);
-   }
-}
-

Modified: trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/remove/test/RemoveGenericValueUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/remove/test/RemoveGenericValueUnitTestCase.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/remove/test/RemoveGenericValueUnitTestCase.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -24,13 +24,13 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import org.jboss.managed.api.ManagedCommon;
 import org.jboss.managed.api.ManagedObject;
+import org.jboss.metatype.api.values.CollectionValue;
+import org.jboss.metatype.api.values.GenericValue;
 import org.jboss.system.server.profileservice.persistence.ManagedGenericOverrideHandler;
-import org.jboss.system.server.profileservice.persistence.ManagedObjectPeristenceHandler;
-import org.jboss.system.server.profileservice.persistence.xml.ModificationInfo;
-import org.jboss.system.server.profileservice.persistence.xml.PersistedCollectionValue;
+import org.jboss.system.server.profileservice.persistence.ManagedObjectRemoveHandler;
 import org.jboss.system.server.profileservice.persistence.xml.PersistedManagedObject;
-import org.jboss.system.server.profileservice.persistence.xml.PersistedProperty;
 import org.jboss.test.server.profileservice.persistence.support.GenericSupportMetaData;
 import org.jboss.test.server.profileservice.persistence.support.SimpleGenericMetaData;
 import org.jboss.test.server.profileservice.persistence.test.AbstractPersistenceFormatTest;
@@ -49,24 +49,23 @@
 
    public void test() throws Throwable
    {
+      ManagedObject mo = createTestMO();
 
-      ManagedObject mo = createTestMO();
+      CollectionValue c = (CollectionValue) mo.getProperty("list").getValue();
+      assertNotNull(c);
+      GenericValue g = (GenericValue) c.iterator().next();
+      assertNotNull(g);
+      ManagedCommon removeItem = (ManagedCommon) g.getValue();
       
-      ManagedObjectPeristenceHandler persistence = new ManagedObjectPeristenceHandler();
-      PersistedManagedObject moElement = persistence.createPersistenceMetaData(mo);
+      ManagedObjectRemoveHandler removeHandler = new ManagedObjectRemoveHandler(removeItem);
+      
+      PersistedManagedObject moElement = restore(mo, removeHandler);
       assertNotNull(moElement);
-      
-      // Remove
-      PersistedProperty p = moElement.getProperties().get(0);
-      PersistedCollectionValue collection = (PersistedCollectionValue) p.getValue(); 
-      assertNotNull(collection);
-      collection.getValue(0).setModificationInfo(ModificationInfo.REMOVED);
-      
+
       // Restore
       ManagedGenericOverrideHandler handler = new ManagedGenericOverrideHandler();
       ManagedObject restored = handler.update(createTestMetaData(), moElement);
 
-      
       // Check meta data
       GenericSupportMetaData md = (GenericSupportMetaData) restored.getAttachment();
       assertNotNull(md);
@@ -74,9 +73,10 @@
       SimpleGenericMetaData parent2 = md.getList().get(0);
       assertEquals("parent2", parent2.getString());
       assertNotNull(parent2.getChild());
-      assertEquals("child2", parent2.getChild().getString());      
+      assertEquals("child2", parent2.getChild().getString());
+      
    }
-
+   
    private ManagedObject createTestMO()
    {
       return getMOF().initManagedObject(createTestMetaData(), null);

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-04-03 11:43:54 UTC (rev 86738)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/support/GenericSupportMetaData.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -21,6 +21,7 @@
  */ 
 package org.jboss.test.server.profileservice.persistence.support;
 
+import java.util.Collections;
 import java.util.List;
 
 import org.jboss.managed.api.annotation.ManagementObject;
@@ -39,7 +40,7 @@
    @ManagementProperty(managed = true)
    public List<SimpleGenericMetaData> getList()
    {
-      return list;
+      return Collections.unmodifiableList(list);
    }
    
    public void setList(List<SimpleGenericMetaData> list)

Copied: trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/support/ObjectNameMetaData.java (from rev 86733, branches/Branch_5_x/system/src/tests/org/jboss/test/server/profileservice/persistence/support/ObjectNameMetaData.java)
===================================================================
--- trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/support/ObjectNameMetaData.java	                        (rev 0)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/support/ObjectNameMetaData.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -0,0 +1,67 @@
+/*
+ * 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.persistence.support;
+
+import javax.management.ObjectName;
+
+import org.jboss.managed.api.annotation.ManagementObject;
+import org.jboss.managed.api.annotation.ManagementProperty;
+import org.jboss.metatype.api.annotations.MetaMapping;
+import org.jboss.metatype.plugins.values.mappers.StringObjectNameMetaMapper;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+ at ManagementObject
+public class ObjectNameMetaData
+{
+   /** The object name. */
+   ObjectName name;
+   
+   /** The other object name. */
+   ObjectName otherName;
+
+   @ManagementProperty
+   public ObjectName getName()
+   {
+      return name;
+   }
+   
+   public void setName(ObjectName name)
+   {
+      this.name = name;
+   }
+   
+   @ManagementProperty
+   @MetaMapping(StringObjectNameMetaMapper.class)
+   public ObjectName getOtherName()
+   {
+      return otherName;
+   }
+   
+   public void setOtherName(ObjectName otherName)
+   {
+      this.otherName = otherName;
+   }
+}
+

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-04-03 11:43:54 UTC (rev 86738)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/test/AbstractPersistenceFormatTest.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -153,9 +153,15 @@
    
    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();
-      
-      ManagedObjectPeristenceHandler persistence = new ManagedObjectPeristenceHandler();
+
+      // Process
       persistence.processManagedObject(moElement, mo);
       
       File file = File.createTempFile("test", null);

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-04-03 11:43:54 UTC (rev 86738)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/test/BasicPersistenceFormatUnitTestCase.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -76,7 +76,9 @@
       mo = handler.update(createPrimitive(), restored);
       
       assertEquals("newName", getMVF().unwrap(mo.getProperty("name").getValue()));
-      assertEquals(111, getMVF().unwrap(mo.getProperty("integer").getValue()));
+      SimpleValue integer = (SimpleValue) mo.getProperty("integer").getValue();
+      assertEquals(111, getMVF().unwrap(integer));
+      assertTrue("actual " + integer , SimpleMetaType.INTEGER_PRIMITIVE.isValue(integer));
       assertEquals("optional", ((SimpleValue) mo.getProperty("optionalName").getValue()).getValue());
       
    }

Copied: trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/test/ObjectNameUnitTestCase.java (from rev 86733, branches/Branch_5_x/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	                        (rev 0)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/test/ObjectNameUnitTestCase.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -0,0 +1,106 @@
+/*
+ * 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.persistence.test;
+
+import javax.management.ObjectName;
+
+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.system.server.profileservice.persistence.xml.PersistedCompositeValue;
+import org.jboss.system.server.profileservice.persistence.xml.PersistedManagedObject;
+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.test.server.profileservice.persistence.support.ObjectNameMetaData;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class ObjectNameUnitTestCase extends AbstractPersistenceFormatTest
+{
+
+   public ObjectNameUnitTestCase(String name)
+   {
+      super(name);
+   }
+   
+   public void test() throws Throwable
+   {
+      ManagedObject mo = getMOF().initManagedObject(createMD(), null);
+      assertNotNull(mo);
+      
+      ManagedProperty p = mo.getProperty("name");
+      CompositeValue c = (CompositeValue) p.getValue();
+      assertNotNull(c);
+
+      // Assert xml information
+      PersistedManagedObject restoredElement = restore(mo);
+      assertNotNull(restoredElement);
+      
+      
+      // The objectName
+      PersistedProperty pp = restoredElement.getProperties().get(1);
+      assertNotNull(pp);
+      
+      PersistedCompositeValue pcv = (PersistedCompositeValue) pp.getValue();
+      assertNotNull(pcv);
+      
+      PersistedSimpleValue psv = (PersistedSimpleValue) pcv.getValues().get(0);
+      assertEquals("domain", psv.getName());
+      assertEquals("org.jboss", psv.getValue());
+      
+      PersistedPropertiesValue ppv = (PersistedPropertiesValue) pcv.getValues().get(1); 
+      assertEquals("keyPropertyList", ppv.getName());
+      assertEquals(2, ppv.getEntries().size());
+      
+      // The other object name
+      PersistedProperty po = restoredElement.getProperties().get(0);
+      assertNotNull(po);
+      assertTrue(po.getValue() instanceof PersistedSimpleValue);
+      
+      //
+      ManagedGenericOverrideHandler handler = new ManagedGenericOverrideHandler();
+      ManagedObject restored = handler.update(createMD(), restoredElement);
+      assertNotNull(restored);
+
+   }
+   
+   
+   protected ObjectNameMetaData createMD() throws Exception
+   {
+      ObjectNameMetaData md = new ObjectNameMetaData();
+      // Set objectName
+      md.setName(createObjectName("value1"));
+      md.setOtherName(createObjectName("value2"));
+      
+      return md;
+   }
+   
+   protected ObjectName createObjectName(String v) throws Exception
+   {
+      return new ObjectName("org.jboss:test=test,v="+v);
+   }
+}
+

Modified: trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/test/PersistenceFormatTestSuite.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/test/PersistenceFormatTestSuite.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/test/PersistenceFormatTestSuite.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -42,6 +42,7 @@
       suite.addTestSuite(MapCompositeUnitTestCase.class);
       suite.addTestSuite(TableValueUnitTestCase.class);
       suite.addTestSuite(TestNestedPeristenceFormatUnitTestCase.class);
+      suite.addTestSuite(ObjectNameUnitTestCase.class);
       
       return suite;
    }

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-04-03 11:43:54 UTC (rev 86738)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/test/TestNestedPeristenceFormatUnitTestCase.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -76,7 +76,7 @@
       valueMap.put("optionalName",
             new SimpleValueSupport(SimpleMetaType.STRING, "changed"));
       valueMap.put("integer", new SimpleValueSupport(
-            SimpleMetaType.INTEGER, 111));
+            SimpleMetaType.INTEGER_PRIMITIVE, 111));
 
       //
       p.setValue(new CompositeValueSupport(composite.getMetaType(), valueMap));

Copied: trunk/system/src/tests/org/jboss/test/server/profileservice/support/FilteredProfile.java (from rev 86733, branches/Branch_5_x/system/src/tests/org/jboss/test/server/profileservice/support/FilteredProfile.java)
===================================================================
--- trunk/system/src/tests/org/jboss/test/server/profileservice/support/FilteredProfile.java	                        (rev 0)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/support/FilteredProfile.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -0,0 +1,97 @@
+/*
+ * 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.support;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.profileservice.spi.ProfileDeployment;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.system.server.profile.repository.AbstractImmutableProfile;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class FilteredProfile extends AbstractImmutableProfile
+{
+
+   /** The profile deployments. */
+   private List<String> deploymentNames;
+   
+   public FilteredProfile(ProfileKey key, URI[] uris, List<String> deploymentNames)
+   {
+      this(key, uris, null, deploymentNames);
+   }
+   
+   public FilteredProfile(ProfileKey key, URI[] uris, List<ProfileKey> subprofiles, List<String> deploymentNames)
+   {
+      super(key, uris, subprofiles);
+      if(deploymentNames == null)
+         throw new IllegalArgumentException("Null profile deployments.");
+      
+      this.deploymentNames = deploymentNames;
+   }
+   
+   @Override
+   public void create() throws Exception
+   {
+      // Load deployment names
+      for(String deploymentName : deploymentNames)
+      {
+         // Get the deployment content
+         VirtualFile vf = resolveDeploymentName(deploymentName);
+         // Load the deployment
+         ProfileDeployment deployment = createDeployment(vf);
+         // Add the deployment
+         addDeployment(deployment.getName(), deployment);
+      }
+      updateLastModfied();
+   }
+
+   protected VirtualFile resolveDeploymentName(String deploymentName) throws IOException
+   {
+      List<VirtualFile> list = new ArrayList<VirtualFile>();
+      for(URI uri : getRepositoryURIs())
+      {
+         VirtualFile repo = getCachedVirtualFile(uri);
+         VirtualFile vf = repo.getChild(deploymentName);
+         if(vf != null)
+            list.add(vf);
+      }
+      if(list.size() == 0)
+      {
+         throw new FileNotFoundException("Unable to find name: " + deploymentName);
+      }
+      else if (list.size() > 1)
+      {
+         throw new FileNotFoundException("Multiple matching names: " + deploymentName + " available " + list);
+      }
+      return list.get(0);
+   }
+   
+}
+

Copied: trunk/system/src/tests/org/jboss/test/server/profileservice/support/FilteredProfileFactory.java (from rev 86733, branches/Branch_5_x/system/src/tests/org/jboss/test/server/profileservice/support/FilteredProfileFactory.java)
===================================================================
--- trunk/system/src/tests/org/jboss/test/server/profileservice/support/FilteredProfileFactory.java	                        (rev 0)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/support/FilteredProfileFactory.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -0,0 +1,96 @@
+/*
+ * 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.support;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+
+import org.jboss.profileservice.spi.Profile;
+import org.jboss.profileservice.spi.ProfileFactory;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.metadata.ProfileDeploymentMetaData;
+import org.jboss.profileservice.spi.metadata.ProfileMetaData;
+import org.jboss.profileservice.spi.metadata.ProfileSourceMetaData;
+import org.jboss.system.server.profile.repository.metadata.FilteredProfileMetaData;
+import org.jboss.system.server.profileservice.repository.AbstractProfileFactory;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class FilteredProfileFactory extends AbstractProfileFactory implements ProfileFactory
+{
+
+   /** The profile meta data types. */
+   public static final Collection<String> types;
+   
+   static
+   {
+      types = Arrays.asList(FilteredProfileMetaData.class.getName());
+   }
+   
+   public String[] getTypes()
+   {
+      return types.toArray(new String[types.size()]);
+   }
+   
+   @Override
+   public Profile createProfile(ProfileKey key, ProfileMetaData metaData, List<ProfileKey> subProfiles)
+         throws URISyntaxException
+   {
+      return new FilteredProfile(key, createURIs(metaData), subProfiles, getDeploymentNames(metaData));
+   }
+   
+   protected URI[] createURIs(ProfileMetaData metaData) throws URISyntaxException
+   {
+      ProfileSourceMetaData profileSource = metaData.getSource();
+      if(profileSource == null)
+         throw new IllegalArgumentException("Null profile source.");
+      
+      List<URI> uris = new ArrayList<URI>();
+      for(String source : profileSource.getSources())
+      {
+         URI uri = new URI(source);
+         uris.add(uri);
+      }
+      return uris.toArray(new URI[uris.size()]);
+   }
+ 
+   protected List<String> getDeploymentNames(ProfileMetaData metaData)
+   {
+      List<String> deploymentNames = new ArrayList<String>();
+      if(metaData.getDeployments() != null && metaData.getDeployments().isEmpty() == false)
+      {
+         for(ProfileDeploymentMetaData deployment : metaData.getDeployments())
+         {
+            deploymentNames.add(deployment.getName());
+         }
+      }
+      return deploymentNames;
+   }
+   
+}
+

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-04-03 11:43:54 UTC (rev 86738)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/support/MockAttachmentStore.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -54,6 +54,12 @@
       else
          return factory.createVFSDeployment(deployment.getRoot());
    }
+   
+   public void removeComponent(ProfileDeployment deployment, ManagedComponent comp) throws Exception
+   {
+      // FIXME removeComponent
+      
+   }
 
    public void updateDeployment(ProfileDeployment deployment, ManagedComponent comp) throws Exception
    {

Deleted: trunk/system/src/tests/org/jboss/test/server/profileservice/support/MockProfileRepository.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/server/profileservice/support/MockProfileRepository.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/support/MockProfileRepository.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -1,78 +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.test.server.profileservice.support;
-
-import java.util.Collection;
-import java.util.Collections;
-
-import org.jboss.profileservice.spi.DeploymentRepository;
-import org.jboss.profileservice.spi.DeploymentRepositoryFactory;
-import org.jboss.profileservice.spi.NoSuchProfileException;
-import org.jboss.profileservice.spi.ProfileKey;
-import org.jboss.profileservice.spi.ProfileRepository;
-import org.jboss.profileservice.spi.metadata.ProfileMetaData;
-import org.jboss.system.server.profile.repository.metadata.FilteredProfileSourceMetaData;
-
-/**
- * Create a filtered deployment repository
- * 
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public class MockProfileRepository implements ProfileRepository
-{
-
-   /** The deployment repository factory. */
-   DeploymentRepositoryFactory repository;
-   
-   public MockProfileRepository(DeploymentRepositoryFactory factory)
-   {
-      this.repository = factory;
-   }
-   
-   public DeploymentRepository createProfileDeploymentRepository(ProfileKey key, ProfileMetaData metaData) throws Exception
-   {
-      // Fill the filtered source with deployments
-      FilteredProfileSourceMetaData source = (FilteredProfileSourceMetaData) metaData.getSource();
-      source.setDeployments(metaData.getDeployments());
-      
-      return repository.createDeploymentRepository(key, source);
-   }
-
-   public DeploymentRepository getProfileDeploymentRepository(ProfileKey key) throws NoSuchProfileException
-   {
-      // FIXME
-      return null;
-   }
-
-   public Collection<ProfileKey> getProfileKeys()
-   {
-      return Collections.EMPTY_LIST;
-   }
-
-   public void removeProfileDeploymentRepository(ProfileKey key) throws Exception, NoSuchProfileException
-   {
-      // nothing      
-   }
-
-}
-

Copied: trunk/system/src/tests/org/jboss/test/server/profileservice/support/XmlProfileFactory.java (from rev 86733, branches/Branch_5_x/system/src/tests/org/jboss/test/server/profileservice/support/XmlProfileFactory.java)
===================================================================
--- trunk/system/src/tests/org/jboss/test/server/profileservice/support/XmlProfileFactory.java	                        (rev 0)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/support/XmlProfileFactory.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -0,0 +1,318 @@
+/*
+ * 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.support;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.metadata.ProfileMetaData;
+import org.jboss.profileservice.spi.metadata.SubProfileMetaData;
+import org.jboss.system.server.profile.repository.metadata.FilteredProfileMetaData;
+import org.jboss.system.server.profile.repository.metadata.HotDeploymentProfileMetaData;
+import org.jboss.system.server.profile.repository.metadata.ProfilesMetaData;
+import org.jboss.system.server.profileservice.repository.AbstractBootstrapProfileFactory;
+import org.jboss.virtual.VFS;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.xb.binding.JBossXBException;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultSchemaResolver;
+import org.jboss.xb.binding.sunday.unmarshalling.SingletonSchemaResolverFactory;
+
+/**
+ * A profile factory based which generates the ProfileMetaData based on .xml files.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class XmlProfileFactory extends AbstractBootstrapProfileFactory
+{
+   /** The profiles directory name. */
+   public final static String PROFILES_SUFFIX = ".profile";
+   
+   /** The attachment store uri. */
+   private File attachmentStoreRoot;
+   
+   /** Profile directories */
+   private Collection<VirtualFile> profileDirectories;
+   
+   /** The unmarshaller. */
+   private Unmarshaller unmarshaller;
+   
+   /** The parsed file list */
+   private Collection<ProfileKey> processedProfileKeys = new ArrayList<ProfileKey>();
+
+   /** The default schema resolver. */
+   private static final DefaultSchemaResolver resolver = (DefaultSchemaResolver) SingletonSchemaResolverFactory.getInstance().getSchemaBindingResolver();
+   
+   static
+   {
+      // Add schema bindings
+      resolver.addClassBinding("urn:jboss:profileservice:profiles:1.0", ProfilesMetaData.class);
+      resolver.addClassBinding("urn:jboss:profileservice:profile:filtered:1.0", FilteredProfileMetaData.class);
+      resolver.addClassBinding("urn:jboss:profileservice:profile:hotdeployment:1.0", HotDeploymentProfileMetaData.class);
+   }
+   
+   public XmlProfileFactory(URI[] profileDirectories) throws Exception
+   {
+      if(profileDirectories == null)
+         throw new IllegalArgumentException("Null directories");
+      this.profileDirectories = new ArrayList<VirtualFile>();
+      for(URI uri : profileDirectories)
+      {
+         VirtualFile vf = VFS.getRoot(uri);
+         if(vf == null)
+            throw new IllegalArgumentException("Could not find uri: " + vf);
+         if(vf.isLeaf())
+            throw new IllegalArgumentException("Not a directory: " + vf);
+         this.profileDirectories.add(vf);
+      }
+   }
+   
+   public Collection<VirtualFile> getProfileDirectories()
+   {
+      return profileDirectories;
+   }
+   
+   public void setProfileDirectories(Collection<VirtualFile> profileDirectories)
+   {
+      this.profileDirectories = profileDirectories;
+   }   
+   
+   public File getAttachmentStoreRoot()
+   {
+      return attachmentStoreRoot;
+   }
+
+   public void setAttachmentStoreRoot(File attachmentStoreRoot)
+   {
+      this.attachmentStoreRoot = attachmentStoreRoot;
+   }
+   
+   /**
+    * Create the profile meta data.
+    * 
+    * @param rootKey the key of the profile/
+    * @param the url pointing to the profile file.
+    * @throws Exception
+    */
+   @Override
+   protected void createProfileMetaData(ProfileKey rootKey, URL url) throws Exception
+   {
+      // Create the unmarshaller
+      this.unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+
+      // Get the root profile virtual file
+      VirtualFile vf = getProfileFile(rootKey, url);
+      // Parse
+      ProfilesMetaData rootProfiles = parse(vf);
+      // Process
+      processProfilesMetaData(rootProfiles);
+   }
+   
+   /**
+    * process the profile meta data.
+    * 
+    * @param metaData the profile meta data.
+    * @throws Exception
+    */
+   protected void processProfileMetaData(ProfileMetaData metaData) throws Exception
+   {
+      // Create profileKey
+      ProfileKey key = createProfileKey(metaData);      
+      processProfileMetaData(key, metaData);
+   }
+   
+   /**
+    * process the profile meta data
+    * 
+    * @param key the profile key.
+    * @param metaData the meta data.
+    * 
+    * @throws Exception
+    */
+   protected void processProfileMetaData(ProfileKey key, ProfileMetaData metaData) throws Exception
+   {      
+      // Don't process the same key twice
+      if(this.processedProfileKeys.contains(key))
+         return;
+
+      // Add profile meta data
+      addProfile(key, metaData);
+      
+      // Process sub profiles
+      processSubProfiles(key, metaData);
+   }
+   
+   /**
+    * process the sub profiles.
+    * 
+    * @param key the profile key.
+    * @param metaData the profile meta data
+    * @throws Exception
+    */
+   protected void processSubProfiles(ProfileKey key, ProfileMetaData metaData) throws Exception
+   {
+      if(metaData.getSubprofiles() != null && metaData.getSubprofiles().isEmpty() == false)
+      {
+         for(SubProfileMetaData subProfile : metaData.getSubprofiles())
+         {
+            ProfileKey subProfileKey = createProfileKey(subProfile);
+            processSubProfileMetaData(subProfileKey, subProfile);
+         }
+      }
+   }
+   
+   /**
+    * process the sub profile.
+    * 
+    * @param key the sub profile key.
+    * @param metaData the sub profile meta data.
+    * @throws Exception
+    */
+   protected void processSubProfileMetaData(ProfileKey key, SubProfileMetaData metaData) throws Exception
+   {
+      // get file
+      VirtualFile vf = getProfileFile(key, null);
+      // parse
+      ProfilesMetaData profiles = parse(vf);
+      // TODO maybe override the profiles key (as it should be the same - filename and profiles name
+      // processProfilesMetaData(key, profiles);
+      processProfilesMetaData(profiles);
+   }
+   
+   /**
+    * process the profiles meta data.
+    * 
+    * @param key the profiles key.
+    * @param metaData the profiles meta data.
+    * @throws Exception
+    */
+   protected void processProfilesMetaData(ProfileKey key, ProfilesMetaData metaData) throws Exception
+   {
+      if(metaData.getProfiles() != null && metaData.getProfiles().isEmpty() == false)
+      {
+         for(ProfileMetaData profile : metaData.getProfiles())
+         {
+            processProfileMetaData(profile);
+         }
+      }
+      // Add the profiles for later resolution
+      addProfiles(key, metaData.getProfiles());      
+   }
+   
+   /**
+    * Process the <profiles> meta data.
+    * This will add dependencies based on the ordering of the xml.
+    * 
+    * @param profilesMetaData the profiles meta data
+    */
+   protected void processProfilesMetaData(ProfilesMetaData profilesMetaData) throws Exception
+   {
+      // The <profiles> key
+      ProfileKey profilesKey = createProfileKey(profilesMetaData);
+      processProfilesMetaData(profilesKey, profilesMetaData);
+   }
+
+   /**
+    * get the virtual file of the profile.
+    * 
+    * @param key the profile key.
+    * @param url the url pointing to the file
+    * @return a resolved name if the url is null.
+    * 
+    * @throws Exception
+    */
+   protected VirtualFile getProfileFile(ProfileKey key, URL url) throws Exception
+   {
+      if(url != null)
+         return VFS.getRoot(url);
+      else
+         return resolveFile(key.getName());
+   }
+   
+   /**
+    * Try to resolve the profile name.
+    * 
+    * @param name the profile name.
+    * @return the virtual file
+    * @throws Exception
+    */
+   protected VirtualFile resolveFile(String name) throws Exception
+   {
+      // ProfileKey.getName() + .profile
+      if(name.endsWith(PROFILES_SUFFIX) == false)
+         name = name + PROFILES_SUFFIX;
+         
+      VirtualFile vf = null;
+      for(VirtualFile dir : profileDirectories)
+      {
+         vf = dir.getChild(name);
+         if(vf != null)
+            break;
+      }
+      if(vf == null)
+         throw new FileNotFoundException("Could not find profile configuration file for: " + name);
+      return vf;
+   }
+   
+   /**
+    * Parse a profile file.
+    * 
+    * @param vf the virtual file.
+    * @return the <profiles> meta data
+    * @throws JBossXBException
+    * @throws IOException
+    */
+   protected ProfilesMetaData parse(VirtualFile vf) throws JBossXBException, IOException
+   {
+      if(log.isTraceEnabled())
+         log.trace("parsing file: " + vf.getPathName());
+      return (ProfilesMetaData) unmarshaller.unmarshal(vf.openStream(), resolver);
+   }
+   
+   @Override
+   protected void addProfile(ProfileKey key, ProfileMetaData metaData)
+   {
+      // Add to processed keys
+      processedProfileKeys.add(key);
+      // Add to parent
+      super.addProfile(key, metaData);
+   }
+   
+   @Override
+   protected void addProfiles(ProfileKey key, List<ProfileMetaData> metaData)
+   {
+      // Add to processed keys
+      processedProfileKeys.add(key);
+      // Add to pared
+      super.addProfiles(key, metaData);
+   }
+}
+

Modified: trunk/system/src/tests/org/jboss/test/server/profileservice/test/AbstractProfileServiceTestBase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/server/profileservice/test/AbstractProfileServiceTestBase.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/test/AbstractProfileServiceTestBase.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -28,14 +28,10 @@
 import org.jboss.bootstrap.spi.Server;
 import org.jboss.bootstrap.spi.ServerConfig;
 import org.jboss.deployers.client.spi.main.MainDeployer;
-import org.jboss.profileservice.spi.DeploymentRepositoryFactory;
-import org.jboss.profileservice.spi.ProfileRepository;
-import org.jboss.system.server.profileservice.attachments.AttachmentStore;
 import org.jboss.system.server.profileservice.repository.AbstractProfileFactory;
 import org.jboss.test.BaseTestCase;
-import org.jboss.test.server.profileservice.support.MockAttachmentStore;
+import org.jboss.test.server.profileservice.support.FilteredProfileFactory;
 import org.jboss.test.server.profileservice.support.MockMainDeployer;
-import org.jboss.test.server.profileservice.support.MockProfileRepository;
 import org.jboss.test.server.profileservice.support.MockServer;
 import org.jboss.test.server.profileservice.support.MockServerConfig;
 
@@ -72,23 +68,11 @@
    protected MainDeployer createMainDeployer()
    {
       return new MockMainDeployer();
-   }
-   
-   protected AttachmentStore createAttachmentStore()
-   {
-      return new MockAttachmentStore();
-   }
-   
-   protected ProfileRepository createProfileRepository(DeploymentRepositoryFactory factory)
-   {
-      return new MockProfileRepository(factory);
-   }   
+   }  
 
-   protected AbstractProfileFactory createProfileFactory(DeploymentRepositoryFactory factory)
+   protected AbstractProfileFactory createProfileFactory()
    {
-      AbstractProfileFactory pf = new AbstractProfileFactory();
-      pf.setProfileRepository(createProfileRepository(factory));
-      return pf;
+      return new FilteredProfileFactory();
    }
    
 }

Modified: trunk/system/src/tests/org/jboss/test/server/profileservice/test/BootstrapProfileFactoryUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/server/profileservice/test/BootstrapProfileFactoryUnitTestCase.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/test/BootstrapProfileFactoryUnitTestCase.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -33,8 +33,7 @@
 import org.jboss.profileservice.spi.Profile;
 import org.jboss.profileservice.spi.ProfileKey;
 import org.jboss.system.server.profileservice.repository.AbstractBootstrapProfileFactory;
-import org.jboss.system.server.profileservice.repository.FilteredDeploymentRepositoryFactory;
-import org.jboss.system.server.profileservice.repository.XmlProfileFactory;
+import org.jboss.test.server.profileservice.support.XmlProfileFactory;
 import org.jboss.virtual.plugins.context.jar.JarUtils;
 
 /**
@@ -65,12 +64,10 @@
       File one = new File(f, "config/profiles");
       File two = new File(f, "common/profiles");
       
-      // A filtered deployment factory
-      FilteredDeploymentRepositoryFactory repositoryFactory = new FilteredDeploymentRepositoryFactory();
       // The xml profile factory
       AbstractBootstrapProfileFactory profileFactory = new XmlProfileFactory(
             new URI[] { one.toURI(), two.toURI() });
-      profileFactory.setProfileFactory(createProfileFactory(repositoryFactory));
+      profileFactory.setProfileFactory(createProfileFactory());
       
       // Clear jar suffixes.
       JarUtils.clearSuffixes();

Copied: trunk/system/src/tests/org/jboss/test/server/profileservice/test/DeploymentRepositoryUnitTestCase.java (from rev 86733, branches/Branch_5_x/system/src/tests/org/jboss/test/server/profileservice/test/DeploymentRepositoryUnitTestCase.java)
===================================================================
--- trunk/system/src/tests/org/jboss/test/server/profileservice/test/DeploymentRepositoryUnitTestCase.java	                        (rev 0)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/test/DeploymentRepositoryUnitTestCase.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -0,0 +1,101 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */ 
+package org.jboss.test.server.profileservice.test;
+
+import java.io.File;
+import java.net.URI;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.system.server.profile.repository.metadata.ImmutableProfileSourceMetaData;
+import org.jboss.system.server.profileservice.repository.BasicDeploymentRepository;
+import org.jboss.system.server.profileservice.repository.DefaultDeploymentRepositoryFactory;
+import org.jboss.test.BaseTestCase;
+
+/**
+ * Test the basic deployment repository.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class DeploymentRepositoryUnitTestCase extends BaseTestCase
+{
+
+   /** The default key. */
+   private static final ProfileKey defaultKey = new ProfileKey(ProfileKey.DEFAULT);
+   
+   public DeploymentRepositoryUnitTestCase(String name)
+   {
+      super(name);
+   }
+   
+   public void testSetUploadDir() throws Exception
+   {
+      File uri = new File("test1");
+      
+      BasicDeploymentRepository repository = new BasicDeploymentRepository(defaultKey, new URI[] {uri.toURI()});
+      assertEquals(uri.toURI(), repository.getUploadUri());
+      
+      // Set a available uri
+      repository.setUploadUri(uri.toURI());
+      assertEquals(uri.toURI(), repository.getUploadUri());
+      
+      File uri2 = new File("test2");
+      try
+      {
+         repository.setUploadUri(uri2.toURI());
+         fail("should not be able to set a not managed uri as upload dir.");
+      }
+      catch(Exception ok)
+      {
+         log.debug("saw exception", ok);
+      }
+      assertEquals(uri.toURI(), repository.getUploadUri());
+   }
+   
+   public void testDefaultRepositoryFactory() throws Exception
+   {
+      File uri1 = new File("test1");
+      File uri2 = new File("test2");
+      File upload = new File("upload");
+      
+      List<URI> uris = Collections.singletonList(upload.toURI());
+      
+      DefaultDeploymentRepositoryFactory f = new DefaultDeploymentRepositoryFactory();
+      f.setUploadURIs(uris);
+      
+      List<String> sourceNames = Arrays.asList(uri1.toURI().toString(), upload.toURI().toString());
+      ImmutableProfileSourceMetaData source = new ImmutableProfileSourceMetaData(sourceNames);
+      
+      // See if the upload directory is set correctly
+      BasicDeploymentRepository repository = (BasicDeploymentRepository) f.createDeploymentRepository(defaultKey, source);
+      assertEquals(upload.toURI(), repository.getUploadUri());
+      
+      // Change the factory upload uris
+      f.setUploadURIs(Collections.singletonList(uri2.toURI()));
+      repository = (BasicDeploymentRepository) f.createDeploymentRepository(defaultKey, source);
+      assertEquals(uri1.toURI(), repository.getUploadUri());
+   }
+
+}

Modified: trunk/system/src/tests/org/jboss/test/server/profileservice/test/ProfileServiceUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/server/profileservice/test/ProfileServiceUnitTestCase.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/test/ProfileServiceUnitTestCase.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -23,19 +23,21 @@
 
 import java.io.File;
 import java.net.URI;
+import java.util.ArrayList;
 import java.util.Collection;
+import java.util.List;
 
 import org.jboss.dependency.plugins.AbstractController;
+import org.jboss.profileservice.spi.NoSuchProfileException;
 import org.jboss.profileservice.spi.Profile;
 import org.jboss.profileservice.spi.ProfileKey;
 import org.jboss.profileservice.spi.ProfileService;
 import org.jboss.system.server.profileservice.repository.AbstractBootstrapProfileFactory;
 import org.jboss.system.server.profileservice.repository.AbstractProfileService;
-import org.jboss.system.server.profileservice.repository.FilteredDeploymentRepositoryFactory;
 import org.jboss.system.server.profileservice.repository.MainDeployerAdapter;
-import org.jboss.system.server.profileservice.repository.XmlProfileFactory;
 import org.jboss.test.server.profileservice.support.MockAttachmentStore;
 import org.jboss.test.server.profileservice.support.MockMainDeployer;
+import org.jboss.test.server.profileservice.support.XmlProfileFactory;
 import org.jboss.virtual.plugins.context.jar.JarUtils;
 
 /**
@@ -80,32 +82,61 @@
       File two = new File(f, "common/profiles");
       
       // 
-      FilteredDeploymentRepositoryFactory repositoryFactory = new FilteredDeploymentRepositoryFactory();
       AbstractBootstrapProfileFactory profileFactory = new XmlProfileFactory(
             new URI[] { one.toURI(), two.toURI() });
-      profileFactory.setProfileFactory(createProfileFactory(repositoryFactory));
+      profileFactory.setProfileFactory(createProfileFactory());
       
       // Clear jar suffixes.
       JarUtils.clearSuffixes();
       
+      // A list of profile keys
+      List<ProfileKey> keys = new ArrayList<ProfileKey>();
+      
       // Parse
       Collection<Profile> profiles = profileFactory.createProfiles(new ProfileKey("default"), null);
       for(Profile profile : profiles)
       {
          // Register
          profileService.registerProfile(profile);
+         ProfileKey key = profile.getKey();
+         keys.add(key);
+         try
+         {
+            // This is the default behavior. For custom profiles this could be different
+            profileService.getActiveProfile(key);
+            fail("profile already registered  "+ key);
+         }
+         catch(NoSuchProfileException e)
+         {
+            // ok
+         }
       }
       
+      // All profiles should be registered now
+      for(ProfileKey key : keys)
+         profileService.getProfile(key);
+      
       try
       {
          // Activate profile
-         profileService.activateProfile(new ProfileKey("default"));
+         ProfileKey key = new ProfileKey("default");
+         profileService.activateProfile(key);
+         profileService.validateProfile(key);
       }
       catch(Exception e)
       {
          getLog().error("failed to activate: ", e);
+         throw e;
       }
+
+      // Test the default profile
+      Profile active = profileService.getActiveProfile(new ProfileKey("default"));
+      assertNotNull(active);
       
+      // All profiles should be active now
+      for(ProfileKey key : keys)
+         profileService.getActiveProfile(key);
+      
       // Assert default profile
       assertActive("default");
       // Assert bootstrap profile
@@ -129,16 +160,35 @@
       
       for(ProfileKey key : profileService.getActiveProfileKeys())
       {
+         profileService.deactivateProfile(key);
          try
          {
-            profileService.deactivateProfile(key);
+            profileService.getActiveProfile(key);
+            fail("profile still active. " + key);
          }
-         catch(Exception e)
+         catch(NoSuchProfileException e)
          {
-            getLog().debug("error deactivating profile: " + key, e);
+            // OK
          }
       }
+      // No active profiles
+      assertTrue(profileService.getActiveProfileKeys().isEmpty());
       
+      for(ProfileKey key : profileService.getProfileKeys())
+      {
+         profileService.unregisterProfile(key);
+         try
+         {
+            profileService.getProfile(key);
+            fail("profile not unregistered " + key);
+         }
+         catch(NoSuchProfileException e)
+         {
+            // OK
+         }
+      }
+      // No registred profiles
+      assertTrue(profileService.getProfileKeys().isEmpty());
    }
    
    protected void assertActive(String profile) throws Exception

Modified: trunk/testsuite/src/main/org/jboss/test/profileservice/override/restart/test/ConnectionFactoryRestartUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/override/restart/test/ConnectionFactoryRestartUnitTestCase.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/override/restart/test/ConnectionFactoryRestartUnitTestCase.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -45,7 +45,7 @@
    public void test() throws Exception
    {
       ManagementView managementView = getManagementView();
-      ComponentType type = new ComponentType("ConnectionFactory", "XA");
+      ComponentType type = new ComponentType("ConnectionFactory", "Tx");
       ManagedComponent component = managementView.getComponent("JmsXA", type);
       assertNotNull(component);
    

Copied: trunk/testsuite/src/main/org/jboss/test/profileservice/override/restart/test/LocalDSRemoveOverrideUnitTestCase.java (from rev 86735, branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/override/restart/test/LocalDSRemoveOverrideUnitTestCase.java)
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/override/restart/test/LocalDSRemoveOverrideUnitTestCase.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/override/restart/test/LocalDSRemoveOverrideUnitTestCase.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -0,0 +1,66 @@
+/*
+ * 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.override.restart.test;
+
+import org.jboss.deployers.spi.management.ManagementView;
+import org.jboss.managed.api.ComponentType;
+import org.jboss.managed.api.ManagedComponent;
+import org.jboss.test.profileservice.override.test.AbstractProfileServiceTest;
+
+/**
+ * 
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class LocalDSRemoveOverrideUnitTestCase extends AbstractProfileServiceTest
+{
+
+   public LocalDSRemoveOverrideUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void test() throws Exception
+   {
+      try
+      {
+         ManagementView mgtView = getManagementView();
+         
+         //
+         ComponentType locaDSType = new ComponentType("DataSource", "LocalTx");
+         ManagedComponent test1 = mgtView.getComponent("ProfileServiceTestDataSource1", locaDSType);
+         assertNotNull(test1);
+         ManagedComponent remove = mgtView.getComponent("ProfileServiceTestRemoveDataSource", locaDSType);
+         assertNull(remove);
+         ManagedComponent test2 = mgtView.getComponent("ProfileServiceTestDataSource2", locaDSType);
+         assertNotNull(test2);  
+      }
+      finally
+      {
+         // Undeploy
+         undeployPackage(new String[] { "profileservice-remove-ds.xml" });         
+      }
+   }
+   
+}
+

Modified: trunk/testsuite/src/main/org/jboss/test/profileservice/override/restart/test/PersistedDataSourceUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/override/restart/test/PersistedDataSourceUnitTestCase.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/override/restart/test/PersistedDataSourceUnitTestCase.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -21,6 +21,7 @@
  */
 package org.jboss.test.profileservice.override.restart.test;
 
+import org.jboss.deployers.spi.management.KnownComponentTypes;
 import org.jboss.deployers.spi.management.ManagementView;
 import org.jboss.managed.api.ManagedComponent;
 import org.jboss.managed.api.ManagedDeployment;
@@ -62,6 +63,9 @@
          ManagedProperty property = mc.getProperty("prepared-statement-cache-size");
          assertEquals("prepared-statement-cache-size: "+ property.getValue(), SimpleValueSupport.wrap(34), property.getValue());
          
+         property = mc.getProperty("max-pool-size");
+         assertEquals("max-pool-size: "+ property.getValue(), SimpleValueSupport.wrap(34), property.getValue());
+         
          // This should work too
          ManagedComponent comp = getManagedComponent(mgtView, "ChangedDsJNDIName");
          assertNotNull(comp);
@@ -81,6 +85,29 @@
       }
    }
    
+   public void testUpdatedDSTemplate() throws Exception
+   {
+      String deploymentName = "LocalTestDS-ds.xml";
+      try
+      {
+         ManagementView mgtView = getManagementView();
+         ManagedComponent mc = mgtView.getComponent("TestLocalDS", KnownComponentTypes.DataSourceTypes.LocalTx.getType());
+         assertNotNull(mc);
+         
+         ManagedProperty property = mc.getProperty("prepared-statement-cache-size");
+         assertEquals("prepared-statement-cache-size: "+ property.getValue(), SimpleValueSupport.wrap(34), property.getValue());
+         
+         property = mc.getProperty("max-pool-size");
+         assertEquals("max-pool-size: "+ property.getValue(), SimpleValueSupport.wrap(34), property.getValue());
+
+      }
+      finally
+      {
+         undeployPackage(new String[] { deploymentName });
+      }
+      
+   }
+   
    public void testNestedDS() throws Exception
    {
       String deploymentName = "profileservice-datasource.ear";

Modified: trunk/testsuite/src/main/org/jboss/test/profileservice/override/test/AbstractProfileServiceTest.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/override/test/AbstractProfileServiceTest.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/override/test/AbstractProfileServiceTest.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -21,7 +21,6 @@
  */
 package org.jboss.test.profileservice.override.test;
 
-import java.net.MalformedURLException;
 import java.net.URL;
 
 import javax.naming.InitialContext;
@@ -77,7 +76,7 @@
    protected String[] deployPackage(String name) throws Exception
    {
       DeploymentManager deployMgr = getDeploymentManager();
-      URL contentURL = getVFSdeployURL(name);
+      URL contentURL = getDeployURL(name);
 
       assertNotNull(contentURL);
       
@@ -209,15 +208,5 @@
       assertTrue("DeploymentStatus.isCompleted: " + status, status.isCompleted());
       assertFalse("DeploymentStatus.isFailed: " + status, status.isFailed());
    }
-   
-   protected URL getVFSdeployURL(String name) throws MalformedURLException
-   {
-      // TODO - hack to get off JDK's url handling
-      URL contentURL = getDeployURL(name);
-      assertNotNull(contentURL);
-      String urlString = contentURL.toExternalForm();
-      int p = urlString.indexOf(":/");
-      return new URL("vfszip" + urlString.substring(p));      
-   }
   
 }
\ No newline at end of file

Modified: trunk/testsuite/src/main/org/jboss/test/profileservice/override/test/ConnectionFactoryOverrideTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/override/test/ConnectionFactoryOverrideTestCase.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/override/test/ConnectionFactoryOverrideTestCase.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -45,7 +45,7 @@
    {
       
       ManagementView managementView = getManagementView();
-      ComponentType type = new ComponentType("ConnectionFactory", "XA");
+      ComponentType type = new ComponentType("ConnectionFactory", "Tx");
       ManagedComponent component = managementView.getComponent("JmsXA", type);
       assertNotNull(component);
    

Copied: trunk/testsuite/src/main/org/jboss/test/profileservice/override/test/LocalDSRemoveTestCase.java (from rev 86735, branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/override/test/LocalDSRemoveTestCase.java)
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/override/test/LocalDSRemoveTestCase.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/override/test/LocalDSRemoveTestCase.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -0,0 +1,64 @@
+/*
+ * 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.override.test;
+
+import org.jboss.deployers.spi.management.ManagementView;
+import org.jboss.managed.api.ComponentType;
+import org.jboss.managed.api.ManagedComponent;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class LocalDSRemoveTestCase extends AbstractProfileServiceTest
+{
+
+   public LocalDSRemoveTestCase(String name)
+   {
+      super(name);
+   }
+   
+   public void test() throws Exception
+   {
+      
+      String repositoryNames[] = deployPackage("profileservice-remove-ds.xml");
+      assertNotNull(repositoryNames);
+
+      ManagementView mgtView = getManagementView();
+      
+      //
+      ComponentType locaDSType = new ComponentType("DataSource", "LocalTx");
+      ManagedComponent test1 = mgtView.getComponent("ProfileServiceTestDataSource1", locaDSType);
+      assertNotNull(test1);
+      ManagedComponent remove = mgtView.getComponent("ProfileServiceTestRemoveDataSource", locaDSType);
+      assertNotNull(remove);
+      ManagedComponent test2 = mgtView.getComponent("ProfileServiceTestDataSource2", locaDSType);
+      assertNotNull(test2);  
+      // Remove
+      mgtView.removeComponent(remove);
+      mgtView.process();
+      
+   }
+   
+   
+}
+

Modified: trunk/testsuite/src/main/org/jboss/test/profileservice/override/test/ProfileServiceOverrideTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/override/test/ProfileServiceOverrideTestCase.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/override/test/ProfileServiceOverrideTestCase.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -21,11 +21,18 @@
  */
 package org.jboss.test.profileservice.override.test;
 
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.deployers.spi.management.KnownComponentTypes;
 import org.jboss.deployers.spi.management.ManagementView;
+import org.jboss.managed.api.DeploymentTemplateInfo;
+import org.jboss.managed.api.Fields;
 import org.jboss.managed.api.ManagedComponent;
 import org.jboss.managed.api.ManagedDeployment;
 import org.jboss.managed.api.ManagedProperty;
 import org.jboss.metatype.api.values.CompositeValue;
+import org.jboss.metatype.api.values.MetaValue;
 import org.jboss.metatype.api.values.SimpleValueSupport;
 
 /**
@@ -54,10 +61,10 @@
          
          ManagementView mgtView = getManagementView();
          ManagedDeployment md = mgtView.getDeployment(deploymentName);
-         assertNotNull(md);
+         assertNotNull("Null managed deployment.", md);
          
          ManagedComponent mc = md.getComponent("ProfileServiceTestDS");
-         assertNotNull(mc);
+         assertNotNull("Null managed component", mc);
          
          // This should work too
          ManagedComponent comp = getManagedComponent(mgtView, "ProfileServiceTestDS");
@@ -76,7 +83,10 @@
          // change value
          property.setValue(SimpleValueSupport.wrap(34));
          
+         property = mc.getProperty("max-pool-size");
+         property.setValue(SimpleValueSupport.wrap(34));
          
+         
          ManagedProperty configProps = mc.getProperty("connection-properties");
          assertNotNull(configProps);
          CompositeValue collection = (CompositeValue) configProps.getValue();
@@ -118,6 +128,52 @@
       }
    }
    
+   public void testTemplateDS() throws Exception
+   {
+      String jndiName = "TestLocalDS";
+      
+      Map<String, MetaValue> propValues = new HashMap<String, MetaValue>();
+      propValues.put("driver-class", SimpleValueSupport.wrap("org.hsqldb.jdbcDriver"));
+      propValues.put("connection-url", SimpleValueSupport.wrap("jdbc:hsqldb:."));
+      propValues.put("connection-definition", SimpleValueSupport.wrap("javax.sql.DataSource"));
+      propValues.put("jndi-name", SimpleValueSupport.wrap(jndiName));
+      propValues.put("rar-name", SimpleValueSupport.wrap("jboss-local-jdbc.rar"));
+      
+      // The management view
+      ManagementView mgtView = getManagementView();
+      DeploymentTemplateInfo dsInfo = mgtView.getTemplate("LocalTxDataSourceTemplate");
+      assertNotNull(dsInfo);
+      // 
+      for(ManagedProperty property : dsInfo.getProperties().values())
+      {
+         MetaValue v = propValues.get(property.getName());
+         if(v != null)
+         {
+            property.setValue(v);
+            property.setField(Fields.META_TYPE, v.getMetaType());
+         }
+      }
+      //
+      mgtView.applyTemplate("LocalTestDS", dsInfo);
+      
+      // Check 
+      ManagedDeployment md = mgtView.getDeployment("LocalTestDS-ds.xml");
+      assertNotNull(md);
+      ManagedComponent mc = mgtView.getComponent(jndiName, KnownComponentTypes.DataSourceTypes.LocalTx.getType());
+      assertNotNull(mc);
+      
+      ManagedProperty property = mc.getProperty("prepared-statement-cache-size");
+      // change value
+      property.setValue(SimpleValueSupport.wrap(34));
+      
+      property = mc.getProperty("max-pool-size");
+      property.setValue(SimpleValueSupport.wrap(34));
+      
+      mgtView.updateComponent(mc);
+     
+   }
+   
+   
    public void testNestedDS() throws Exception
    {
       String deploymentName = "profileservice-datasource.ear";
@@ -126,7 +182,7 @@
          deployPackage(deploymentName);
          ManagementView mgtView = getManagementView();
          ManagedDeployment deployment = mgtView.getDeployment(deploymentName);
-         assertNotNull(deployment);
+         assertNotNull("Null managed deployment", deployment);
          
          assertNotNull(deployment.getChildren());
          assertFalse(deployment.getChildren().isEmpty());
@@ -145,7 +201,7 @@
          assertNotNull(md);
          
          ManagedComponent mc = md.getComponent("ProfileServiceNestedTestDS");
-         assertNotNull(mc);
+         assertNotNull("Null managed component", mc);
          
          // This should work too
          ManagedComponent comp = getManagedComponent(mgtView, "ProfileServiceNestedTestDS");

Copied: trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/support (from rev 86735, branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/support)

Deleted: trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/support/SimpleAnnotatedBean.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/support/SimpleAnnotatedBean.java	2009-04-03 09:48:37 UTC (rev 86735)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/support/SimpleAnnotatedBean.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -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.test.profileservice.persistenceformat.support;
-
-import org.jboss.managed.api.annotation.ManagementProperty;
-
-/**
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-//@ManagementObject(name = "SimpleBean")
-public class SimpleAnnotatedBean
-{
-   
-   /** The string property. */
-   private String stringProperty;
-   
-   /** The injection propeprty. */
-   private Object injectProperty;
- 
-   @ManagementProperty
-   public String getStringProperty()
-   {
-      return stringProperty;
-   }
-   
-   public void setStringProperty(String stringProperty)
-   {
-      this.stringProperty = stringProperty;
-   }
-   
-   @ManagementProperty
-   public Object getInjectProperty()
-   {
-      return injectProperty;
-   }
-   
-   public void setInjectProperty(Object injectProperty)
-   {
-      this.injectProperty = injectProperty;
-   }
-   
-}

Copied: trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/support/SimpleAnnotatedBean.java (from rev 86735, branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/support/SimpleAnnotatedBean.java)
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/support/SimpleAnnotatedBean.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/support/SimpleAnnotatedBean.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -0,0 +1,62 @@
+/*
+ * 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 org.jboss.managed.api.annotation.ManagementProperty;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+//@ManagementObject(name = "SimpleBean")
+public class SimpleAnnotatedBean
+{
+   
+   /** The string property. */
+   private String stringProperty;
+   
+   /** The injection propeprty. */
+   private Object injectProperty;
+ 
+   @ManagementProperty
+   public String getStringProperty()
+   {
+      return stringProperty;
+   }
+   
+   public void setStringProperty(String stringProperty)
+   {
+      this.stringProperty = stringProperty;
+   }
+   
+   @ManagementProperty
+   public Object getInjectProperty()
+   {
+      return injectProperty;
+   }
+   
+   public void setInjectProperty(Object injectProperty)
+   {
+      this.injectProperty = injectProperty;
+   }
+   
+}

Copied: trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/test/JBossBeansPersistenceFormatTestCase.java (from rev 86735, branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/test/JBossBeansPersistenceFormatTestCase.java)
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/test/JBossBeansPersistenceFormatTestCase.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/persistenceformat/test/JBossBeansPersistenceFormatTestCase.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -0,0 +1,134 @@
+/*
+ * 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.test;
+
+import java.util.Set;
+
+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.deployers.plugins.managed.BeanMetaDataICF;
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.plugins.bootstrap.basic.BasicBootstrap;
+import org.jboss.kernel.spi.dependency.KernelController;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+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.system.server.profileservice.persistence.xml.PersistedManagedObject;
+import org.jboss.test.profileservice.persistenceformat.support.SimpleAnnotatedBean;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class JBossBeansPersistenceFormatTestCase extends AbstractPersistenceFormatTest
+{
+   
+   /** The bootstrap. */
+   private BasicBootstrap bootstrap;
+   
+   /** The kernel. */
+   private Kernel kernel;
+   
+   /** The controller. */
+   private KernelController controller;
+
+   public JBossBeansPersistenceFormatTestCase(String name)
+   {
+      super(name);
+   }
+
+   
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+      // Bootstrap
+      bootstrap = new BasicBootstrap();
+      bootstrap.run();
+      //
+      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());
+      
+      getMOF().addInstanceClassFactory(beanICF);
+      
+      KernelControllerContext ctx = (KernelControllerContext) controller.getInstalledContext("SimpleAnnotatedBean");
+      assertNotNull(ctx);
+      
+      MetaData metaData = kernel.getMetaDataRepository().getMetaData(ctx);
+      assertNotNull(metaData);
+      
+      ManagedObject mo = getMOF().initManagedObject(md, null, metaData, "SimpleAnnotatedBean", null);
+      assertNotNull(mo);
+
+      PersistedManagedObject moElement = restore(mo);
+      assertNotNull(moElement);
+
+      // Uninstall for offline attachment persistence
+      controller.uninstall("SimpleAnnotatedBean");
+      
+      ManagedGenericOverrideHandler override = new ManagedGenericOverrideHandler();
+      // Try to restore the information without the installed bean      
+      mo = getMOF().initManagedObject(getSimpleBeanMetaDataBuilder().getBeanMetaData(), null);
+      assertNotNull(mo);
+      
+      override.updateManagedObject(mo, moElement, mo.getAttachment());
+      Set<PropertyMetaData> properties = ((BeanMetaData)mo.getAttachment()).getProperties();
+      assertNotNull(properties);
+      // TODO
+      assertEquals(1, properties.size());
+   }
+   
+   protected BeanMetaDataBuilder getSimpleBeanMetaDataBuilder()
+   {
+      BeanMetaDataBuilder b = BeanMetaDataBuilder.createBuilder("SimpleAnnotatedBean", SimpleAnnotatedBean.class.getName());
+      b.addAnnotation("@org.jboss.managed.api.annotation.ManagementObject(name=\"simpleBean\")");
+      return b;
+   }
+   
+   
+}
+

Copied: trunk/testsuite/src/main/org/jboss/test/profileservice/template (from rev 86735, branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/template)

Copied: trunk/testsuite/src/main/org/jboss/test/profileservice/template/test (from rev 86735, branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/template/test)

Deleted: trunk/testsuite/src/main/org/jboss/test/profileservice/template/test/AbstractTemplateTest.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/template/test/AbstractTemplateTest.java	2009-04-03 09:48:37 UTC (rev 86735)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/template/test/AbstractTemplateTest.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -1,190 +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.test.profileservice.template.test;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.jboss.beans.info.spi.PropertyInfo;
-import org.jboss.managed.api.DeploymentTemplateInfo;
-import org.jboss.managed.api.Fields;
-import org.jboss.managed.api.ManagedObject;
-import org.jboss.managed.api.ManagedProperty;
-import org.jboss.managed.api.annotation.ManagementProperty;
-import org.jboss.managed.api.factory.ManagedObjectFactory;
-import org.jboss.managed.plugins.factory.DeploymentTemplateInfoFactory;
-import org.jboss.managed.plugins.factory.ManagedObjectFactoryBuilder;
-import org.jboss.metatype.api.types.MetaType;
-import org.jboss.metatype.api.values.MetaValue;
-import org.jboss.metatype.api.values.MetaValueFactory;
-import org.jboss.metatype.plugins.values.MetaValueFactoryBuilder;
-import org.jboss.test.BaseTestCase;
-
-/**
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public abstract class AbstractTemplateTest extends BaseTestCase
-{
-   
-   /** The deployment factory. */
-   DeploymentTemplateInfoFactory factory = new DeploymentTemplateInfoFactory();
-
-   /** The managed object factory. */
-   ManagedObjectFactory mof = ManagedObjectFactoryBuilder.create();
-   
-   /** The meta value factory. */
-   MetaValueFactory mvf = MetaValueFactoryBuilder.create();
-   
-   protected boolean debug = false;
-
-   public AbstractTemplateTest(String name)
-   {
-      super(name);
-   }
-
-   public ManagedObjectFactory getMof()
-   {
-      return mof;
-   }
-   
-   public MetaValueFactory getMvf()
-   {
-      return mvf;
-   }
-   
-   public DeploymentTemplateInfoFactory getFactory()
-   {
-      return factory;
-   }
-   
-   public boolean isDebug()
-   {
-      return debug;
-   }
-   
-   public void setDebug(boolean debug)
-   {
-      this.debug = debug;
-   }
-
-   abstract DeploymentTemplateInfo createDeploymentInfo(String name, Class<?> clazz) throws Exception;
-   
-   protected DeploymentTemplateInfo assertTemplate(String name, Class<?> clazz) throws Exception
-   {
-      DeploymentTemplateInfo info = createDeploymentInfo(name, clazz);
-      assertNotNull(info);
-      
-      ManagedObject mo = mof.createManagedObject(clazz);
-      assertNotNull(mo);
-
-      log.debug(">> " + info.getName());
-      assertTemplateInfo(info, mo);      
-      
-      return info;
-   }
-
-   protected void assertTemplateInfo(DeploymentTemplateInfo info, ManagedObject mo)
-   {
-      List<String> processed = new ArrayList<String>();
-      for(ManagedProperty property : info.getProperties().values())
-      {
-         //
-         String propertyName = property.getName();
-         //
-         ManagedProperty other = mo.getProperty(propertyName);
-         assertProperty(propertyName , property, other);
-         //
-         processed.add(propertyName);
-         
-         log.debug("property: " + propertyName);
-         
-      }
-
-      for(ManagedProperty other : info.getProperties().values())
-      {
-         String otherName = other.getName();
-         if(processed.contains(otherName))
-            continue;
-         
-         ManagedProperty reference = mo.getProperty(otherName);
-         if(isDebug() && reference == null)
-         {
-            log.debug("Does not exist in runtime MO: " + otherName);
-            continue;
-         }
-         
-         assertNotNull(otherName + " is included in the MO", reference);
-         
-         ManagementProperty annotation = null;
-         if(reference.getAnnotations() != null)
-         {
-            annotation = (ManagementProperty) reference.getAnnotations().get(ManagementProperty.class.getName());
-         }
-         else
-         {
-            PropertyInfo propertyInfo = reference.getField(Fields.PROPERTY_INFO, PropertyInfo.class);
-            annotation = (ManagementProperty) propertyInfo.getAnnotation(ManagementProperty.class.getName());
-         }
-         if(isDebug() && annotation == null)
-         {
-            log.debug("@ManagedProperty not present: " + otherName);
-            continue;
-         }
-         assertNotNull(otherName + " annotation present", annotation);
-         
-         if(isDebug() && annotation.includeInTemplate() == false)
-         {
-            log.error("includeInTemplate == true " + otherName);
-            continue;
-         }
-            
-         
-         assertTrue(otherName + " includeInTemplate", annotation.includeInTemplate());
-         assertProperty(otherName, other, reference);
-      }      
-   }
-   
-   protected void assertProperty(String name, ManagedProperty property, ManagedProperty other)
-   {
-      assertNotNull(name, property);
-      assertNotNull(name, other);
-      
-      assertEquals(name, property.getMetaType(), other.getMetaType());
-      assertEquals(name, property.isMandatory(), other.isMandatory());
-   }
-   
-   protected void assertProperty(ManagedProperty property, MetaType metaType, Serializable value)
-   {
-      assertProperty(property, metaType, mvf.create(value));
-   }
-   
-   protected void assertProperty(ManagedProperty property, MetaType metaType, MetaValue metaValue)
-   {
-      assertNotNull(property);
-      assertEquals(property.getMetaType(), metaType);
-      assertEquals(property.getValue(), metaValue);
-   }
-
-}
-

Copied: trunk/testsuite/src/main/org/jboss/test/profileservice/template/test/AbstractTemplateTest.java (from rev 86735, branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/template/test/AbstractTemplateTest.java)
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/template/test/AbstractTemplateTest.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/template/test/AbstractTemplateTest.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -0,0 +1,190 @@
+/*
+ * 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.template.test;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.beans.info.spi.PropertyInfo;
+import org.jboss.managed.api.DeploymentTemplateInfo;
+import org.jboss.managed.api.Fields;
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.managed.api.annotation.ManagementProperty;
+import org.jboss.managed.api.factory.ManagedObjectFactory;
+import org.jboss.managed.plugins.factory.DeploymentTemplateInfoFactory;
+import org.jboss.managed.plugins.factory.ManagedObjectFactoryBuilder;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.MetaValueFactory;
+import org.jboss.metatype.plugins.values.MetaValueFactoryBuilder;
+import org.jboss.test.BaseTestCase;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public abstract class AbstractTemplateTest extends BaseTestCase
+{
+   
+   /** The deployment factory. */
+   DeploymentTemplateInfoFactory factory = new DeploymentTemplateInfoFactory();
+
+   /** The managed object factory. */
+   ManagedObjectFactory mof = ManagedObjectFactoryBuilder.create();
+   
+   /** The meta value factory. */
+   MetaValueFactory mvf = MetaValueFactoryBuilder.create();
+   
+   protected boolean debug = false;
+
+   public AbstractTemplateTest(String name)
+   {
+      super(name);
+   }
+
+   public ManagedObjectFactory getMof()
+   {
+      return mof;
+   }
+   
+   public MetaValueFactory getMvf()
+   {
+      return mvf;
+   }
+   
+   public DeploymentTemplateInfoFactory getFactory()
+   {
+      return factory;
+   }
+   
+   public boolean isDebug()
+   {
+      return debug;
+   }
+   
+   public void setDebug(boolean debug)
+   {
+      this.debug = debug;
+   }
+
+   abstract DeploymentTemplateInfo createDeploymentInfo(String name, Class<?> clazz) throws Exception;
+   
+   protected DeploymentTemplateInfo assertTemplate(String name, Class<?> clazz) throws Exception
+   {
+      DeploymentTemplateInfo info = createDeploymentInfo(name, clazz);
+      assertNotNull(info);
+      
+      ManagedObject mo = mof.createManagedObject(clazz);
+      assertNotNull(mo);
+
+      log.debug(">> " + info.getName());
+      assertTemplateInfo(info, mo);      
+      
+      return info;
+   }
+
+   protected void assertTemplateInfo(DeploymentTemplateInfo info, ManagedObject mo)
+   {
+      List<String> processed = new ArrayList<String>();
+      for(ManagedProperty property : info.getProperties().values())
+      {
+         //
+         String propertyName = property.getName();
+         //
+         ManagedProperty other = mo.getProperty(propertyName);
+         assertProperty(propertyName , property, other);
+         //
+         processed.add(propertyName);
+         
+         log.debug("property: " + propertyName);
+         
+      }
+
+      for(ManagedProperty other : info.getProperties().values())
+      {
+         String otherName = other.getName();
+         if(processed.contains(otherName))
+            continue;
+         
+         ManagedProperty reference = mo.getProperty(otherName);
+         if(isDebug() && reference == null)
+         {
+            log.debug("Does not exist in runtime MO: " + otherName);
+            continue;
+         }
+         
+         assertNotNull(otherName + " is included in the MO", reference);
+         
+         ManagementProperty annotation = null;
+         if(reference.getAnnotations() != null)
+         {
+            annotation = (ManagementProperty) reference.getAnnotations().get(ManagementProperty.class.getName());
+         }
+         else
+         {
+            PropertyInfo propertyInfo = reference.getField(Fields.PROPERTY_INFO, PropertyInfo.class);
+            annotation = (ManagementProperty) propertyInfo.getAnnotation(ManagementProperty.class.getName());
+         }
+         if(isDebug() && annotation == null)
+         {
+            log.debug("@ManagedProperty not present: " + otherName);
+            continue;
+         }
+         assertNotNull(otherName + " annotation present", annotation);
+         
+         if(isDebug() && annotation.includeInTemplate() == false)
+         {
+            log.error("includeInTemplate == true " + otherName);
+            continue;
+         }
+            
+         
+         assertTrue(otherName + " includeInTemplate", annotation.includeInTemplate());
+         assertProperty(otherName, other, reference);
+      }      
+   }
+   
+   protected void assertProperty(String name, ManagedProperty property, ManagedProperty other)
+   {
+      assertNotNull(name, property);
+      assertNotNull(name, other);
+      
+      assertEquals(name, property.getMetaType(), other.getMetaType());
+      assertEquals(name, property.isMandatory(), other.isMandatory());
+   }
+   
+   protected void assertProperty(ManagedProperty property, MetaType metaType, Serializable value)
+   {
+      assertProperty(property, metaType, mvf.create(value));
+   }
+   
+   protected void assertProperty(ManagedProperty property, MetaType metaType, MetaValue metaValue)
+   {
+      assertNotNull(property);
+      assertEquals(property.getMetaType(), metaType);
+      assertEquals(property.getValue(), metaValue);
+   }
+
+}
+

Deleted: trunk/testsuite/src/main/org/jboss/test/profileservice/template/test/DSDeploymentTemplateUnitTestCase.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/template/test/DSDeploymentTemplateUnitTestCase.java	2009-04-03 09:48:37 UTC (rev 86735)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/template/test/DSDeploymentTemplateUnitTestCase.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -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.test.profileservice.template.test;
-
-import org.jboss.managed.api.DeploymentTemplateInfo;
-import org.jboss.resource.deployers.management.DsDataSourceTemplateInfo;
-import org.jboss.resource.metadata.mcf.LocalDataSourceDeploymentMetaData;
-import org.jboss.resource.metadata.mcf.NoTxConnectionFactoryDeploymentMetaData;
-import org.jboss.resource.metadata.mcf.NoTxDataSourceDeploymentMetaData;
-import org.jboss.resource.metadata.mcf.TxConnectionFactoryDeploymentMetaData;
-
-/**
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public class DSDeploymentTemplateUnitTestCase extends AbstractTemplateTest
-{
-
-   public DSDeploymentTemplateUnitTestCase(String name)
-   {
-      super(name);
-   }
-
-   public boolean isDebug()
-   {
-      return debug;
-   }
-   
-   public void testLocalTxDataSourceTemplateInfo() throws Exception
-   {
-      assertTemplate("LocalTxDataSourceTemplateInfo",
-            LocalDataSourceDeploymentMetaData.class);
-   }
-
-   public void testNoTxDataSourceTemplateInfo() throws Exception
-   {
-      assertTemplate("NoTxDataSourceTemplateInfo",
-            NoTxDataSourceDeploymentMetaData.class);
-   }
-   
-   public void testTxConnectionFactoryTemplateInfo() throws Exception
-   {
-      assertTemplate("TxConnectionFactoryTemplateInfo",
-            TxConnectionFactoryDeploymentMetaData.class);
-   }
-
-   public void testNoTxConnectionFactoryTemplateInfo() throws Exception
-   {
-      assertTemplate("NoTxConnectionFactoryTemplateInfo",
-            NoTxConnectionFactoryDeploymentMetaData.class);
-   }
-   
-   protected DeploymentTemplateInfo createDeploymentInfo(String name, Class<?> attachment) throws Exception
-   {
-      DeploymentTemplateInfo info = getFactory().createTemplateInfo(DsDataSourceTemplateInfo.class, attachment, name, null);
-      // populate the values
-      ((DsDataSourceTemplateInfo) info).start();
-      return info;
-   }
-   
-}

Copied: trunk/testsuite/src/main/org/jboss/test/profileservice/template/test/DSDeploymentTemplateUnitTestCase.java (from rev 86735, branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/template/test/DSDeploymentTemplateUnitTestCase.java)
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/template/test/DSDeploymentTemplateUnitTestCase.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/template/test/DSDeploymentTemplateUnitTestCase.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -0,0 +1,80 @@
+/*
+ * 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.template.test;
+
+import org.jboss.managed.api.DeploymentTemplateInfo;
+import org.jboss.resource.deployers.management.DsDataSourceTemplateInfo;
+import org.jboss.resource.metadata.mcf.LocalDataSourceDeploymentMetaData;
+import org.jboss.resource.metadata.mcf.NoTxConnectionFactoryDeploymentMetaData;
+import org.jboss.resource.metadata.mcf.NoTxDataSourceDeploymentMetaData;
+import org.jboss.resource.metadata.mcf.TxConnectionFactoryDeploymentMetaData;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class DSDeploymentTemplateUnitTestCase extends AbstractTemplateTest
+{
+
+   public DSDeploymentTemplateUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public boolean isDebug()
+   {
+      return debug;
+   }
+   
+   public void testLocalTxDataSourceTemplateInfo() throws Exception
+   {
+      assertTemplate("LocalTxDataSourceTemplateInfo",
+            LocalDataSourceDeploymentMetaData.class);
+   }
+
+   public void testNoTxDataSourceTemplateInfo() throws Exception
+   {
+      assertTemplate("NoTxDataSourceTemplateInfo",
+            NoTxDataSourceDeploymentMetaData.class);
+   }
+   
+   public void testTxConnectionFactoryTemplateInfo() throws Exception
+   {
+      assertTemplate("TxConnectionFactoryTemplateInfo",
+            TxConnectionFactoryDeploymentMetaData.class);
+   }
+
+   public void testNoTxConnectionFactoryTemplateInfo() throws Exception
+   {
+      assertTemplate("NoTxConnectionFactoryTemplateInfo",
+            NoTxConnectionFactoryDeploymentMetaData.class);
+   }
+   
+   protected DeploymentTemplateInfo createDeploymentInfo(String name, Class<?> attachment) throws Exception
+   {
+      DeploymentTemplateInfo info = getFactory().createTemplateInfo(DsDataSourceTemplateInfo.class, attachment, name, null);
+      // populate the values
+      ((DsDataSourceTemplateInfo) info).start();
+      return info;
+   }
+   
+}

Deleted: trunk/testsuite/src/main/org/jboss/test/profileservice/template/test/JMSDestinationTemplateUnitTestCase.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/template/test/JMSDestinationTemplateUnitTestCase.java	2009-04-03 09:48:37 UTC (rev 86735)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/template/test/JMSDestinationTemplateUnitTestCase.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -1,132 +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.test.profileservice.template.test;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.jboss.managed.api.DeploymentTemplateInfo;
-import org.jboss.metatype.api.types.CompositeMetaType;
-import org.jboss.metatype.api.types.MapCompositeMetaType;
-import org.jboss.metatype.api.types.SimpleMetaType;
-import org.jboss.metatype.api.values.CompositeValue;
-import org.jboss.metatype.api.values.CompositeValueSupport;
-import org.jboss.metatype.api.values.MapCompositeValueSupport;
-import org.jboss.metatype.api.values.MetaValue;
-import org.jboss.metatype.api.values.SimpleValueSupport;
-import org.jboss.profileservice.management.templates.JmsDestinationTemplateInfo;
-
-/**
- * JMSDestination Queue and Topic template testcase.
- * 
- * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
- * @version $Revision$
- */
-public class JMSDestinationTemplateUnitTestCase extends AbstractTemplateTest
-{
-
-   /** The security mapper meta types. */
-   private static MapCompositeMetaType mapMetaType;
-   private static CompositeMetaType compositeMetaType;
-   
-   static
-   {
-//      SecurityConfigMapper mapper = new SecurityConfigMapper();
-//      mapMetaType = (MapCompositeMetaType) mapper.getMetaType();
-//      compositeMetaType = SecurityConfigMapper.composite;
-   }
-   
-   public JMSDestinationTemplateUnitTestCase(String name)
-   {
-      super(name);
-   }
-
-   public void testQueueTemplateInfo() throws Exception
-   {
-//      DeploymentTemplateInfo info = assertTemplate("QueueTemplate",
-//            QueueServiceMO.class);
-//      
-//      info.getProperties().get("name").setValue(new SimpleValueSupport(SimpleMetaType.STRING, "Test"));
-//      info.getProperties().get("JNDIName").setValue(new SimpleValueSupport(SimpleMetaType.STRING, "TestJNDIName"));
-//      
-//      info.getProperties().get("serverPeer").setValue(getMvf().create(new ObjectName("jboss.messaging.destination:service=Queue")));
-//      info.getProperties().get("DLQ").setValue(getMvf().create(new ObjectName("jboss.messaging.destination:service=Queue,name=PrivateDLQ")));
-//      info.getProperties().get("expiryQueue").setValue(getMvf().create(new ObjectName("jboss.messaging.destination:service=Queue,name=PrivateExpiryQueue")));
-//      info.getProperties().get("securityConfig").setValue(createComposityType());
-//      
-//      
-//      DeploymentTemplate t = new JmsDestinationTemplate();
-//      // Try to apply the template and delete the file afterwards
-//      t.applyTemplate(info);
-   }
-   
-   public void testTopicTemplateInfo() throws Exception
-   {
-//      DeploymentTemplateInfo info = assertTemplate("TopicTemplate",
-//            TopicServiceMO.class);
-//      
-//      info.getProperties().get("name").setValue(new SimpleValueSupport(SimpleMetaType.STRING, "Test"));
-//      info.getProperties().get("JNDIName").setValue(new SimpleValueSupport(SimpleMetaType.STRING, "TestJNDIName"));
-//      
-//      info.getProperties().get("serverPeer").setValue(getMvf().create(new ObjectName("jboss.messaging.destination:service=Queue")));
-//      info.getProperties().get("DLQ").setValue(getMvf().create(new ObjectName("jboss.messaging.destination:service=Queue,name=PrivateDLQ")));
-//      info.getProperties().get("expiryQueue").setValue(getMvf().create(new ObjectName("jboss.messaging.destination:service=Queue,name=PrivateExpiryQueue")));
-//      info.getProperties().get("securityConfig").setValue(createComposityType());
-//     
-//      DeploymentTemplate t = new JmsDestinationTemplate();
-//      // Try to apply the template and delete the file afterwards
-//      t.applyTemplate(info);  
-   }
-   
-   @Override
-   DeploymentTemplateInfo createDeploymentInfo(String name, Class<?> attachment) throws Exception
-   {
-      DeploymentTemplateInfo info = getFactory().createTemplateInfo(JmsDestinationTemplateInfo.class, attachment, name, null);
-      ((JmsDestinationTemplateInfo)info).start();
-      ((JmsDestinationTemplateInfo)info).setDestinationType(name);
-      return info;
-   }
-   
-   protected MapCompositeValueSupport createComposityType()
-   {
-      Map<String, MetaValue> values = new HashMap<String, MetaValue>();
-
-      values.put("admin", createCompositeValue(true, true, true));
-      values.put("publisher", createCompositeValue(true, true, false));
-      values.put("user", createCompositeValue(true, null, null));
-
-      return new MapCompositeValueSupport(values, mapMetaType);
-   }
-   
-   protected CompositeValue createCompositeValue(Boolean read, Boolean write, Boolean create)
-   {
-      Map<String, MetaValue> map = new HashMap<String, MetaValue>();
-
-      map.put("read", new SimpleValueSupport(SimpleMetaType.BOOLEAN, read));
-      map.put("write", new SimpleValueSupport(SimpleMetaType.BOOLEAN, write));
-      map.put("create", new SimpleValueSupport(SimpleMetaType.BOOLEAN, create));
-
-      return new CompositeValueSupport(compositeMetaType, map);
-   }
-
-}
-

Copied: trunk/testsuite/src/main/org/jboss/test/profileservice/template/test/JMSDestinationTemplateUnitTestCase.java (from rev 86735, branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/template/test/JMSDestinationTemplateUnitTestCase.java)
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/template/test/JMSDestinationTemplateUnitTestCase.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/template/test/JMSDestinationTemplateUnitTestCase.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -0,0 +1,132 @@
+/*
+ * 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.template.test;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.managed.api.DeploymentTemplateInfo;
+import org.jboss.metatype.api.types.CompositeMetaType;
+import org.jboss.metatype.api.types.MapCompositeMetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.CompositeValue;
+import org.jboss.metatype.api.values.CompositeValueSupport;
+import org.jboss.metatype.api.values.MapCompositeValueSupport;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.profileservice.management.templates.JmsDestinationTemplateInfo;
+
+/**
+ * JMSDestination Queue and Topic template testcase.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class JMSDestinationTemplateUnitTestCase extends AbstractTemplateTest
+{
+
+   /** The security mapper meta types. */
+   private static MapCompositeMetaType mapMetaType;
+   private static CompositeMetaType compositeMetaType;
+   
+   static
+   {
+//      SecurityConfigMapper mapper = new SecurityConfigMapper();
+//      mapMetaType = (MapCompositeMetaType) mapper.getMetaType();
+//      compositeMetaType = SecurityConfigMapper.composite;
+   }
+   
+   public JMSDestinationTemplateUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testQueueTemplateInfo() throws Exception
+   {
+//      DeploymentTemplateInfo info = assertTemplate("QueueTemplate",
+//            QueueServiceMO.class);
+//      
+//      info.getProperties().get("name").setValue(new SimpleValueSupport(SimpleMetaType.STRING, "Test"));
+//      info.getProperties().get("JNDIName").setValue(new SimpleValueSupport(SimpleMetaType.STRING, "TestJNDIName"));
+//      
+//      info.getProperties().get("serverPeer").setValue(getMvf().create(new ObjectName("jboss.messaging.destination:service=Queue")));
+//      info.getProperties().get("DLQ").setValue(getMvf().create(new ObjectName("jboss.messaging.destination:service=Queue,name=PrivateDLQ")));
+//      info.getProperties().get("expiryQueue").setValue(getMvf().create(new ObjectName("jboss.messaging.destination:service=Queue,name=PrivateExpiryQueue")));
+//      info.getProperties().get("securityConfig").setValue(createComposityType());
+//      
+//      
+//      DeploymentTemplate t = new JmsDestinationTemplate();
+//      // Try to apply the template and delete the file afterwards
+//      t.applyTemplate(info);
+   }
+   
+   public void testTopicTemplateInfo() throws Exception
+   {
+//      DeploymentTemplateInfo info = assertTemplate("TopicTemplate",
+//            TopicServiceMO.class);
+//      
+//      info.getProperties().get("name").setValue(new SimpleValueSupport(SimpleMetaType.STRING, "Test"));
+//      info.getProperties().get("JNDIName").setValue(new SimpleValueSupport(SimpleMetaType.STRING, "TestJNDIName"));
+//      
+//      info.getProperties().get("serverPeer").setValue(getMvf().create(new ObjectName("jboss.messaging.destination:service=Queue")));
+//      info.getProperties().get("DLQ").setValue(getMvf().create(new ObjectName("jboss.messaging.destination:service=Queue,name=PrivateDLQ")));
+//      info.getProperties().get("expiryQueue").setValue(getMvf().create(new ObjectName("jboss.messaging.destination:service=Queue,name=PrivateExpiryQueue")));
+//      info.getProperties().get("securityConfig").setValue(createComposityType());
+//     
+//      DeploymentTemplate t = new JmsDestinationTemplate();
+//      // Try to apply the template and delete the file afterwards
+//      t.applyTemplate(info);  
+   }
+   
+   @Override
+   DeploymentTemplateInfo createDeploymentInfo(String name, Class<?> attachment) throws Exception
+   {
+      DeploymentTemplateInfo info = getFactory().createTemplateInfo(JmsDestinationTemplateInfo.class, attachment, name, null);
+      ((JmsDestinationTemplateInfo)info).start();
+      ((JmsDestinationTemplateInfo)info).setDestinationType(name);
+      return info;
+   }
+   
+   protected MapCompositeValueSupport createComposityType()
+   {
+      Map<String, MetaValue> values = new HashMap<String, MetaValue>();
+
+      values.put("admin", createCompositeValue(true, true, true));
+      values.put("publisher", createCompositeValue(true, true, false));
+      values.put("user", createCompositeValue(true, null, null));
+
+      return new MapCompositeValueSupport(values, mapMetaType);
+   }
+   
+   protected CompositeValue createCompositeValue(Boolean read, Boolean write, Boolean create)
+   {
+      Map<String, MetaValue> map = new HashMap<String, MetaValue>();
+
+      map.put("read", new SimpleValueSupport(SimpleMetaType.BOOLEAN, read));
+      map.put("write", new SimpleValueSupport(SimpleMetaType.BOOLEAN, write));
+      map.put("create", new SimpleValueSupport(SimpleMetaType.BOOLEAN, create));
+
+      return new CompositeValueSupport(compositeMetaType, map);
+   }
+
+}
+

Modified: trunk/testsuite/src/main/org/jboss/test/profileservice/test/JmsDestinationUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/test/JmsDestinationUnitTestCase.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/test/JmsDestinationUnitTestCase.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -21,7 +21,9 @@
  */
 package org.jboss.test.profileservice.test;
 
+import java.util.Arrays;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 import junit.framework.Test;
@@ -33,6 +35,8 @@
 import org.jboss.managed.api.DeploymentTemplateInfo;
 import org.jboss.managed.api.ManagedComponent;
 import org.jboss.managed.api.ManagedProperty;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
 import org.jboss.metatype.api.values.MetaValue;
 import org.jboss.metatype.api.values.SimpleValueSupport;
 
@@ -52,19 +56,52 @@
    {
       TestSuite suite = new TestSuite();
 
+      suite.addTest(new JmsDestinationUnitTestCase("testQueueTemplate"));
+      suite.addTest(new JmsDestinationUnitTestCase("testTopicTemplate"));
       suite.addTest(new JmsDestinationUnitTestCase("testDLQ"));
       suite.addTest(new JmsDestinationUnitTestCase("testCreateQueue"));
       suite.addTest(new JmsDestinationUnitTestCase("testRemoveQueue"));
       suite.addTest(new JmsDestinationUnitTestCase("testCreateTopic"));
       suite.addTest(new JmsDestinationUnitTestCase("testRemoveTopic"));
 
+
       return suite;
+   }  
+
+   public void testQueueTemplate() throws Exception
+   {
+      DeploymentTemplateInfo info = getManagementView().getTemplate("QueueTemplate");
+      assertNotNull(info);
+      
+      Map<String, ManagedProperty> properties = info.getProperties();
+      assertNotNull(properties);
+      
+      List<String> items = Arrays.asList("JNDIName", "downCacheSize", "fullSize",
+            "clustered", "maxDeliveryAttempts", "maxSize", "messageCounterHistoryDayLimit",
+            "pageSize", "redeliveryDelay");
+
+      properties.keySet().containsAll(items);
       // Validate the ObjectName property types
       ManagedProperty serverPeer = info.getProperties().get("serverPeer");
       assertNotNull(serverPeer);
       assertEquals(SimpleMetaType.STRING, serverPeer.getMetaType());
    }
+   
+   public void testTopicTemplate() throws Exception
+   {
+      DeploymentTemplateInfo info = getManagementView().getTemplate("TopicTemplate");
+      assertNotNull(info);
+      
+      Map<String, ManagedProperty> properties = info.getProperties();
+      assertNotNull(properties);
+      
+      List<String> items = Arrays.asList("JNDIName", "downCacheSize", "fullSize",
+            "clustered", "maxDeliveryAttempts", "maxSize", "messageCounterHistoryDayLimit",
+            "pageSize", "redeliveryDelay");
 
+      properties.keySet().containsAll(items);
+   }
+   
    /**
     * Validate the default dead letter queue exists
     * @throws Exception
@@ -76,6 +113,11 @@
       ManagedComponent queue = mgtView.getComponent("/queue/DLQ", type);
       assertNotNull(queue);
       assertEquals("/queue/DLQ", queue.getName());
+      // Validate some of the expected properties
+      ManagedProperty serverPeer = queue.getProperty("serverPeer");
+      assertNotNull(serverPeer);
+      MetaType serverPeerType = serverPeer.getMetaType();
+      assertEquals(SimpleMetaType.STRING, serverPeerType);
    }
 
    public void testCreateQueue() throws Exception
@@ -158,7 +200,7 @@
       managementView.process();
 
       // Validate the components
-      managementView.reload();
+//      managementView.reload();
       ManagedComponent queue1 = managementView.getComponent("testCreateQueue1", type);
       assertNotNull(queue1);
       assertEquals("testCreateQueue1", queue1.getName());

Modified: trunk/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java	2009-04-03 12:05:06 UTC (rev 86739)
@@ -596,7 +596,7 @@
       assertTrue("security-domain value is a GenericValue", securityDomainValue instanceof GenericValue);
       log.debug("security-domain value: "+securityDomainValue);
    }
-
+   
    /**
     * Validate the DefaultDS stats that are non-null
     * 
@@ -871,6 +871,9 @@
       propValues.put("config-property", metaValue);
 
       propValues.put("track-connection-by-tx", SimpleValueSupport.wrap(Boolean.TRUE));
+      propValues.put("config-property", 
+            new MapCompositeValueSupport(new HashMap<String, MetaValue>(),
+                  new MapCompositeMetaType(SimpleMetaType.STRING)));
       // todo: how to set the specific domain?
       //ApplicationManagedSecurityMetaData secDomain = new ApplicationManagedSecurityMetaData();
       //props.get("security-domain").setValue(secDomain);
@@ -885,6 +888,18 @@
       assertNotNull(configProperty);
       MetaValue value = configProperty.getValue();
       assertTrue("MapCompositeMetaType", value.getMetaType() instanceof MapCompositeMetaType);
+      
+      MapCompositeValueSupport cValue = (MapCompositeValueSupport) value;
+      cValue.put("testKey", new SimpleValueSupport(SimpleMetaType.STRING, "testValue"));
+      
+      mgtView.updateComponent(dsMC);
+
+      mgtView = getManagementView();
+      dsMC = getManagedComponent(mgtView, compType, jndiName);
+      configProperty = dsMC.getProperty("config-property");
+      assertNotNull(configProperty);
+      cValue = (MapCompositeValueSupport) configProperty.getValue();
+      assertNotNull(cValue.get("testKey"));
    }
 
    /**
@@ -991,12 +1006,20 @@
       for(String propName : propValues.keySet())
       {
          ManagedProperty prop = props.get(propName);
+         // If the property does not exist on the template we don't set it
+         if(prop == null)
+            continue;
+         
          log.debug("template property before: "+prop.getName()+","+prop.getValue());
          assertNotNull("property " + propName + " found in template " + templateName, prop);
          prop.setValue(propValues.get(propName));
          log.debug("template property after: "+prop.getName()+","+prop.getValue());
       }
       
+      // Assert map composite
+      if(dsInfo.getProperties().get("config-property") != null)
+         assertTrue(dsInfo.getProperties().get("config-property").getMetaType() instanceof MapCompositeMetaType);
+      
       mgtView.applyTemplate(deploymentName, dsInfo);
 
       // reload the view

Modified: trunk/testsuite/src/resources/test-configs/cluster-profilesvc-0/conf/bootstrap/profile.xml
===================================================================
--- trunk/testsuite/src/resources/test-configs/cluster-profilesvc-0/conf/bootstrap/profile.xml	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/testsuite/src/resources/test-configs/cluster-profilesvc-0/conf/bootstrap/profile.xml	2009-04-03 12:05:06 UTC (rev 86739)
@@ -54,12 +54,15 @@
 		<property name="mof"><inject bean="ManagedObjectFactory" /></property>
 		<property name="mgtDeploymentCreator"><inject bean="ManagedDeploymentCreator" /></property>
 		<property name="bootstrapProfileFactory"><inject bean="BootstrapProfileFactory" /></property>
+      <property name="configurator"><inject bean="jboss.kernel:service=Kernel" property="configurator"/></property>
 	</bean>
 
-	<!-- The profile factory -->
-	<bean name="ProfileFactory" class="org.jboss.system.server.profileservice.repository.AbstractProfileFactory">
-		<property name="profileRepository"><inject bean="ProfileRepositoryFactory" /></property>
-	</bean>
+   <!-- The profile factory -->
+   <bean name="ProfileFactory" class="org.jboss.system.server.profileservice.repository.TypedProfileFactory">
+      <!-- Accept any AbstractprofileFactory -->
+      <incallback method="addProfileFactory" />
+      <uncallback method="removeProfileFactory" />
+   </bean>
 
 	<!-- The profile repository factory -->
 	<bean name="ProfileRepositoryFactory" class="org.jboss.system.server.profileservice.repository.TypedProfileRepository">
@@ -82,6 +85,11 @@
     <property name="filter"><bean class="org.jboss.system.server.profile.basic.XmlIncludeVirtualFileFilter" /></property>
   </bean>
 
+   <bean name="BasicProfileFactory" class="org.jboss.system.server.profileservice.repository.BasicProfileFactory">
+      <property name="profileRepository"><inject bean="ProfileRepositoryFactory" /></property>
+   </bean>
+   <bean name="FilteredProfileFactory" class="org.jboss.system.server.profileservice.repository.FilteredProfileFactory"/>
+
 	<!-- The default deployment repository factory -->
 	<bean name="DefaultDeploymentRepositoryFactory" class="org.jboss.system.server.profileservice.repository.DefaultDeploymentRepositoryFactory">
 		<property name="deploymentFilter"><inject bean="DeploymentFilter" /></property>
@@ -118,32 +126,33 @@
       <property name="tempDirURI">${jboss.server.home.url}temp${/}cluster-repo</property>
    </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>
-	</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>
+   </bean>
 
-	<bean name="AttachmentsSerializer" class="org.jboss.system.server.profileservice.repository.JAXBAttachmentSerializer">
-		<constructor><parameter><inject bean="BootstrapProfileFactory" property="attachmentStoreRoot" /></parameter></constructor>
-	</bean>
+   <bean name="AttachmentsSerializer" class="org.jboss.system.server.profileservice.repository.JAXBAttachmentSerializer">
+      <constructor><parameter><inject bean="BootstrapProfileFactory" property="attachmentStoreRoot" /></parameter></constructor>
+   </bean>
 
-	<bean name="ProfileServiceDeployer" class="org.jboss.system.server.profileservice.repository.MainDeployerAdapter">
-		<property name="mainDeployer"><inject bean="MainDeployer" /></property>
-		<property name="attachmentStore"><inject bean="AttachmentStore" /></property>
-	</bean>
+   <bean name="ProfileServiceDeployer" class="org.jboss.system.server.profileservice.repository.MainDeployerAdapter">
+      <property name="mainDeployer"><inject bean="MainDeployer" /></property>
+      <property name="attachmentStore"><inject bean="AttachmentStore" /></property>
+   </bean>
 
    <bean name="ProfileServicePersistenceDeployer" class="org.jboss.system.server.profileservice.persistence.deployer.ProfileServicePersistenceDeployer" />
 
-	<!-- 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 -->
-		<property name="prefixes">#,%,\,,.,_$</property>
-		<!-- Files ending with theses strings are ignored -->
-		<property name="suffixes">#,$,%,~,\,v,.BAK,.bak,.old,.orig,.tmp,.rej,.sh</property>
-		<!-- Files matching with theses strings are ignored -->
-		<property name="matches">.make.state,.nse_depinfo,CVS,CVS.admin,RCS,RCSLOG,SCCS,TAGS,core,tags</property>
-	</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 -->
+      <property name="prefixes">#,%,\,,.,_$</property>
+      <!-- Files ending with theses strings are ignored -->
+      <property name="suffixes">#,$,%,~,\,v,.BAK,.bak,.old,.orig,.tmp,.rej,.sh</property>
+      <!-- Files matching with theses strings are ignored -->
+      <property name="matches">.make.state,.nse_depinfo,CVS,CVS.admin,RCS,RCSLOG,SCCS,TAGS,core,tags</property>
+   </bean>
 
 </deployment>
\ No newline at end of file

Modified: trunk/testsuite/src/resources/test-configs/cluster-profilesvc-1/conf/bootstrap/profile.xml
===================================================================
--- trunk/testsuite/src/resources/test-configs/cluster-profilesvc-1/conf/bootstrap/profile.xml	2009-04-03 11:43:54 UTC (rev 86738)
+++ trunk/testsuite/src/resources/test-configs/cluster-profilesvc-1/conf/bootstrap/profile.xml	2009-04-03 12:05:06 UTC (rev 86739)
@@ -5,68 +5,71 @@
 -->
 <deployment xmlns="urn:jboss:bean-deployer:2.0">
 
-	<classloader><inject bean="profile-classloader:0.0.0" /></classloader>
+   <classloader><inject bean="profile-classloader:0.0.0" /></classloader>
 
-	<classloader name="profile-classloader" xmlns="urn:jboss:classloader:1.0" export-all="NON_EMPTY" import-all="true">
-		<root>${jboss.lib.url}jboss-profileservice-spi.jar</root>
-	</classloader>
+   <classloader name="profile-classloader" xmlns="urn:jboss:classloader:1.0" export-all="NON_EMPTY" import-all="true">
+      <root>${jboss.lib.url}jboss-profileservice-spi.jar</root>
+   </classloader>
 
-	<!-- 
-		The profile configuration
-		This contains required properties:
-			The uri to jboss-service.xml.
-			The uri to the deployers folder.
-			A list of uris to deploy folders. -->
-	<bean name="BootstrapProfileFactory" class="org.jboss.system.server.profileservice.StaticClusteredProfileFactory">
-		<property name="bootstrapURI">${jboss.server.home.url}conf/jboss-service.xml</property>
-		<property name="deployersURI">${jboss.server.home.url}deployers</property>
-		<property name="applicationURIs">
-			<list elementClass="java.net.URI">
-				<value>${jboss.server.home.url}deploy</value>
-			</list>
-		</property>
+   <!-- 
+      The profile configuration
+      This contains required properties:
+         The uri to jboss-service.xml.
+         The uri to the deployers folder.
+         A list of uris to deploy folders. -->
+   <bean name="BootstrapProfileFactory" class="org.jboss.system.server.profileservice.StaticClusteredProfileFactory">
+      <property name="bootstrapURI">${jboss.server.home.url}conf/jboss-service.xml</property>
+      <property name="deployersURI">${jboss.server.home.url}deployers</property>
+      <property name="applicationURIs">
+         <list elementClass="java.net.URI">
+            <value>${jboss.server.home.url}deploy</value>
+         </list>
+      </property>
       <property name="farmURIs">
          <list elementClass="java.net.URI">
             <value>${jboss.server.home.url}farm</value>
          </list>
       </property>
-		<property name="attachmentStoreRoot">${jboss.server.data.dir}/attachments</property>
-		<property name="profileFactory"><inject bean="ProfileFactory" /></property>
-	</bean>
-	
-	<!--  The default profile key -->
-	<bean name="DefaultProfileKey" class="org.jboss.profileservice.spi.ProfileKey">
-		<constructor><parameter>${jboss.server.name}</parameter></constructor>
-	</bean>
+      <property name="attachmentStoreRoot">${jboss.server.data.dir}/attachments</property>
+      <property name="profileFactory"><inject bean="ProfileFactory" /></property>
+   </bean>
+   
+   <!--  The default profile key -->
+   <bean name="DefaultProfileKey" class="org.jboss.profileservice.spi.ProfileKey">
+      <constructor><parameter>${jboss.server.name}</parameter></constructor>
+   </bean>
 
-	<!-- The ProfileService -->
-	<bean name="ProfileService" class="org.jboss.system.server.profileservice.repository.AbstractProfileService">
-		<constructor><parameter><inject bean="jboss.kernel:service=KernelController" /></parameter></constructor>
-		<property name="deployer"><inject bean="ProfileServiceDeployer" /></property>
-		<property name="defaultProfile"><inject bean="DefaultProfileKey" /></property>
-	</bean>
+   <!-- The ProfileService -->
+   <bean name="ProfileService" class="org.jboss.system.server.profileservice.repository.AbstractProfileService">
+      <constructor><parameter><inject bean="jboss.kernel:service=KernelController" /></parameter></constructor>
+      <property name="deployer"><inject bean="ProfileServiceDeployer" /></property>
+      <property name="defaultProfile"><inject bean="DefaultProfileKey" /></property>
+   </bean>
 
-	<!-- The Bootstrap implementation that loads the Profile from the ProfileService -->
-	<bean name="ProfileServiceBootstrap" class="org.jboss.system.server.profileservice.ProfileServiceBootstrap">
-		<property name="profileKey"><inject bean="DefaultProfileKey" /></property>
-		<property name="mainDeployer"><inject bean="MainDeployer" /></property>
-		<property name="profileService"><inject bean="ProfileService" /></property>
-		<property name="mof"><inject bean="ManagedObjectFactory" /></property>
-		<property name="mgtDeploymentCreator"><inject bean="ManagedDeploymentCreator" /></property>
-		<property name="bootstrapProfileFactory"><inject bean="BootstrapProfileFactory" /></property>
-	</bean>
+   <!-- The Bootstrap implementation that loads the Profile from the ProfileService -->
+   <bean name="ProfileServiceBootstrap" class="org.jboss.system.server.profileservice.ProfileServiceBootstrap">
+      <property name="profileKey"><inject bean="DefaultProfileKey" /></property>
+      <property name="mainDeployer"><inject bean="MainDeployer" /></property>
+      <property name="profileService"><inject bean="ProfileService" /></property>
+      <property name="mof"><inject bean="ManagedObjectFactory" /></property>
+      <property name="mgtDeploymentCreator"><inject bean="ManagedDeploymentCreator" /></property>
+      <property name="bootstrapProfileFactory"><inject bean="BootstrapProfileFactory" /></property>
+      <property name="configurator"><inject bean="jboss.kernel:service=Kernel" property="configurator"/></property>
+   </bean>
 
-	<!-- The profile factory -->
-	<bean name="ProfileFactory" class="org.jboss.system.server.profileservice.repository.AbstractProfileFactory">
-		<property name="profileRepository"><inject bean="ProfileRepositoryFactory" /></property>
-	</bean>
+   <!-- The profile factory -->
+   <bean name="ProfileFactory" class="org.jboss.system.server.profileservice.repository.TypedProfileFactory">
+      <!-- Accept any AbstractprofileFactory -->
+      <incallback method="addProfileFactory" />
+      <uncallback method="removeProfileFactory" />
+   </bean>
 
-	<!-- The profile repository factory -->
-	<bean name="ProfileRepositoryFactory" class="org.jboss.system.server.profileservice.repository.TypedProfileRepository">
-		<!-- Accept any DeploymentRepositoryFactory -->
-		<incallback method="addRepositoryFactory" />
-		<uncallback method="removeRepositoryFactory" />
-	</bean>
+   <!-- The profile repository factory -->
+   <bean name="ProfileRepositoryFactory" class="org.jboss.system.server.profileservice.repository.TypedProfileRepository">
+      <!-- Accept any DeploymentRepositoryFactory -->
+      <incallback method="addRepositoryFactory" />
+      <uncallback method="removeRepositoryFactory" />
+   </bean>
 
   <!-- The structure modification cache and checker -->
 
@@ -82,12 +85,17 @@
     <property name="filter"><bean class="org.jboss.system.server.profile.basic.XmlIncludeVirtualFileFilter" /></property>
   </bean>
 
-	<!-- The default deployment repository factory -->
-	<bean name="DefaultDeploymentRepositoryFactory" class="org.jboss.system.server.profileservice.repository.DefaultDeploymentRepositoryFactory">
-		<property name="deploymentFilter"><inject bean="DeploymentFilter" /></property>
-		<property name="checker"><inject bean="StructureModificationChecker" /></property>
-	</bean>
+   <bean name="BasicProfileFactory" class="org.jboss.system.server.profileservice.repository.BasicProfileFactory">
+      <property name="profileRepository"><inject bean="ProfileRepositoryFactory" /></property>
+   </bean>
+   <bean name="FilteredProfileFactory" class="org.jboss.system.server.profileservice.repository.FilteredProfileFactory"/>
 
+   <!-- The default deployment repository factory -->
+   <bean name="DefaultDeploymentRepositoryFactory" class="org.jboss.system.server.profileservice.repository.DefaultDeploymentRepositoryFactory">
+      <property name="deploymentFilter"><inject bean="DeploymentFilter" /></property>
+      <property name="checker"><inject bean="StructureModificationChecker" /></property>
+   </bean>
+
    <!-- The clustered deployment repository factory -->
    <bean name="ClusteredDeploymentRepositoryFactory" class="org.jboss.system.server.profileservice.repository.clustered.ClusteredDeploymentRepositoryFactory">
       <property name="deploymentFilter"><inject bean="DeploymentFilter" /></property>
@@ -118,32 +126,33 @@
       <property name="tempDirURI">${jboss.server.home.url}temp${/}cluster-repo</property>
    </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>
-	</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>
+   </bean>
 
-	<bean name="AttachmentsSerializer" class="org.jboss.system.server.profileservice.repository.JAXBAttachmentSerializer">
-		<constructor><parameter><inject bean="BootstrapProfileFactory" property="attachmentStoreRoot" /></parameter></constructor>
-	</bean>
+   <bean name="AttachmentsSerializer" class="org.jboss.system.server.profileservice.repository.JAXBAttachmentSerializer">
+      <constructor><parameter><inject bean="BootstrapProfileFactory" property="attachmentStoreRoot" /></parameter></constructor>
+   </bean>
 
-	<bean name="ProfileServiceDeployer" class="org.jboss.system.server.profileservice.repository.MainDeployerAdapter">
-		<property name="mainDeployer"><inject bean="MainDeployer" /></property>
-		<property name="attachmentStore"><inject bean="AttachmentStore" /></property>
-	</bean>
+   <bean name="ProfileServiceDeployer" class="org.jboss.system.server.profileservice.repository.MainDeployerAdapter">
+      <property name="mainDeployer"><inject bean="MainDeployer" /></property>
+      <property name="attachmentStore"><inject bean="AttachmentStore" /></property>
+   </bean>
 
    <bean name="ProfileServicePersistenceDeployer" class="org.jboss.system.server.profileservice.persistence.deployer.ProfileServicePersistenceDeployer" />
 
-	<!-- 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 -->
-		<property name="prefixes">#,%,\,,.,_$</property>
-		<!-- Files ending with theses strings are ignored -->
-		<property name="suffixes">#,$,%,~,\,v,.BAK,.bak,.old,.orig,.tmp,.rej,.sh</property>
-		<!-- Files matching with theses strings are ignored -->
-		<property name="matches">.make.state,.nse_depinfo,CVS,CVS.admin,RCS,RCSLOG,SCCS,TAGS,core,tags</property>
-	</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 -->
+      <property name="prefixes">#,%,\,,.,_$</property>
+      <!-- Files ending with theses strings are ignored -->
+      <property name="suffixes">#,$,%,~,\,v,.BAK,.bak,.old,.orig,.tmp,.rej,.sh</property>
+      <!-- Files matching with theses strings are ignored -->
+      <property name="matches">.make.state,.nse_depinfo,CVS,CVS.admin,RCS,RCSLOG,SCCS,TAGS,core,tags</property>
+   </bean>
 
 </deployment>
\ No newline at end of file




More information about the jboss-cvs-commits mailing list