[Jboss-cvs] JBossAS SVN: r55118 - in trunk: build system system/src/main/org/jboss/deployment system/src/main/org/jboss/system system/src/main/org/jboss/system/metadata system/src/main/org/jboss/system/microcontainer system/src/main/org/jboss/system/server system/src/resources/tests system/src/resources/tests/org system/src/resources/tests/org/jboss system/src/resources/tests/org/jboss/test system/src/resources/tests/org/jboss/test/system system/src/resources/tests/org/jboss/test/system/controller system/src/resources/tests/org/jboss/test/system/controller/basic system/src/resources/tests/org/jboss/test/system/controller/basic/test system/src/resources/tests/org/jboss/test/system/controller/configure system/src/resources/tests/org/jboss/test/system/controller/configure/test system/src/resources/tests/org/jboss/test/system/controller/instantiate system/src/resources/tests/org/jboss/test/system/controller/instantiate/plain system/src/resources/tests/org/jboss/test/system/control! ler/instantiate/plain/test system/src/resources/tests/org/jboss/test/system/controller/instantiate/standard system/src/resources/tests/org/jboss/test/system/controller/instantiate/standard/test system/src/resources/tests/org/jboss/test/system/controller/instantiate/test system/src/resources/tests/org/jboss/test/system/controller/lifecycle system/src/resources/tests/org/jboss/test/system/controller/lifecycle/basic system/src/resources/tests/org/jboss/test/system/controller/lifecycle/basic/test system/src/resources/tests/org/jboss/test/system/controller/lifecycle/seperated system/src/resources/tests/org/jboss/test/system/controller/lifecycle/seperated/test system/src/resources/tests/org/jboss/test/system/controller/parse system/src/resources/tests/org/jboss/test/system/controller/parse/test system/src/resources/tests/org/jboss/test/system/metadata system/src/resources/tests/org/jboss/test/system/metadata/basic system/src/resources/tests/org/jboss/test/system/metadata/basic/te! st system/src/resources/tests/org/jboss/test/system/metadata/constructor system/src/resources/tests/org/jboss/test/system/metadata/constructor/test system/src/resources/tests/org/jboss/test/system/metadata/depends system/src/resources/tests/org/jboss/test/system/metadata/depends/test system/src/tests/org/jboss/test system/sr

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Aug 3 12:34:36 EDT 2006


Author: adrian at jboss.org
Date: 2006-08-03 12:33:33 -0400 (Thu, 03 Aug 2006)
New Revision: 55118

Added:
   trunk/system/src/main/org/jboss/system/ServiceInstance.java
   trunk/system/src/main/org/jboss/system/metadata/
   trunk/system/src/main/org/jboss/system/metadata/ServiceAttributeMetaData.java
   trunk/system/src/main/org/jboss/system/metadata/ServiceConstructorMetaData.java
   trunk/system/src/main/org/jboss/system/metadata/ServiceDependencyListValueMetaData.java
   trunk/system/src/main/org/jboss/system/metadata/ServiceDependencyMetaData.java
   trunk/system/src/main/org/jboss/system/metadata/ServiceDependencyValueMetaData.java
   trunk/system/src/main/org/jboss/system/metadata/ServiceElementValueMetaData.java
   trunk/system/src/main/org/jboss/system/metadata/ServiceJBXBValueMetaData.java
   trunk/system/src/main/org/jboss/system/metadata/ServiceJavaBeanValueMetaData.java
   trunk/system/src/main/org/jboss/system/metadata/ServiceMetaData.java
   trunk/system/src/main/org/jboss/system/metadata/ServiceMetaDataParser.java
   trunk/system/src/main/org/jboss/system/metadata/ServiceTextValueMetaData.java
   trunk/system/src/main/org/jboss/system/metadata/ServiceValueMetaData.java
   trunk/system/src/main/org/jboss/system/microcontainer/
   trunk/system/src/main/org/jboss/system/microcontainer/ConfigureAction.java
   trunk/system/src/main/org/jboss/system/microcontainer/CreateDestroyLifecycleAction.java
   trunk/system/src/main/org/jboss/system/microcontainer/DescribeAction.java
   trunk/system/src/main/org/jboss/system/microcontainer/InstallAction.java
   trunk/system/src/main/org/jboss/system/microcontainer/InstantiateAction.java
   trunk/system/src/main/org/jboss/system/microcontainer/LifecycleDependencyItem.java
   trunk/system/src/main/org/jboss/system/microcontainer/ServiceControllerContext.java
   trunk/system/src/main/org/jboss/system/microcontainer/ServiceControllerContextAction.java
   trunk/system/src/main/org/jboss/system/microcontainer/ServiceControllerContextActions.java
   trunk/system/src/main/org/jboss/system/microcontainer/ServiceProxy.java
   trunk/system/src/main/org/jboss/system/microcontainer/StartStopLifecycleAction.java
   trunk/system/src/resources/tests/org/
   trunk/system/src/resources/tests/org/jboss/
   trunk/system/src/resources/tests/org/jboss/test/
   trunk/system/src/resources/tests/org/jboss/test/system/
   trunk/system/src/resources/tests/org/jboss/test/system/controller/
   trunk/system/src/resources/tests/org/jboss/test/system/controller/basic/
   trunk/system/src/resources/tests/org/jboss/test/system/controller/basic/test/
   trunk/system/src/resources/tests/org/jboss/test/system/controller/basic/test/Basic.xml
   trunk/system/src/resources/tests/org/jboss/test/system/controller/basic/test/DoubleInstall.xml
   trunk/system/src/resources/tests/org/jboss/test/system/controller/configure/
   trunk/system/src/resources/tests/org/jboss/test/system/controller/configure/test/
   trunk/system/src/resources/tests/org/jboss/test/system/controller/configure/test/Configure.xml
   trunk/system/src/resources/tests/org/jboss/test/system/controller/configure/test/ErrorInConfigure_NotAutomatic.xml
   trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/
   trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/plain/
   trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/plain/test/
   trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/plain/test/PlainMBeanAbstractClass_bad.xml
   trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/plain/test/PlainMBeanCodeClassNotFound_bad.xml
   trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/plain/test/PlainMBeanConstructorError_bad.xml
   trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/plain/test/PlainMBeanConstructorException_bad.xml
   trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/plain/test/PlainMBeanConstructorInvalidType_bad.xml
   trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/plain/test/PlainMBeanConstructorInvalidValue_bad.xml
   trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/plain/test/PlainMBeanConstructorTypeNotFound_bad.xml
   trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/plain/test/PlainMBeanNotMBean_bad.xml
   trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/plain/test/PlainMBean_install.xml
   trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/standard/
   trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/standard/test/
   trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/standard/test/StandardMBeanAbstractClass_bad.xml
   trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/standard/test/StandardMBeanCodeClassNotFound_bad.xml
   trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/standard/test/StandardMBeanConstructorError_bad.xml
   trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/standard/test/StandardMBeanConstructorException_bad.xml
   trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/standard/test/StandardMBeanConstructorInvalidType_bad.xml
   trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/standard/test/StandardMBeanConstructorInvalidValue_bad.xml
   trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/standard/test/StandardMBeanConstructorTypeNotFound_bad.xml
   trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/standard/test/StandardMBeanInterfaceNotFound_bad.xml
   trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/standard/test/StandardMBeanInterfaceNotImplemented_bad.xml
   trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/standard/test/StandardMBeanInterface_install.xml
   trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/standard/test/StandardMBean_install.xml
   trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/test/
   trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/test/PlainMBeanNoArg_install.xml
   trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/test/PlainMBeanOneArg_install.xml
   trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/test/PlainMBeanTwoArg_install.xml
   trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/test/StandardMBeanNoArg_install.xml
   trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/test/StandardMBeanOneArg_install.xml
   trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/test/StandardMBeanTwoArg_install.xml
   trunk/system/src/resources/tests/org/jboss/test/system/controller/lifecycle/
   trunk/system/src/resources/tests/org/jboss/test/system/controller/lifecycle/basic/
   trunk/system/src/resources/tests/org/jboss/test/system/controller/lifecycle/basic/test/
   trunk/system/src/resources/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsListNested_NotAutomatic.xml
   trunk/system/src/resources/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsList_NotAutomatic.xml
   trunk/system/src/resources/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsNested_NotAutomatic.xml
   trunk/system/src/resources/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsOptionalAttributeListNested_NotAutomatic.xml
   trunk/system/src/resources/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsOptionalAttributeList_NotAutomatic.xml
   trunk/system/src/resources/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsOptionalAttributeNested_NotAutomatic.xml
   trunk/system/src/resources/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsOptionalAttribute_NotAutomatic.xml
   trunk/system/src/resources/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDepends_NotAutomatic.xml
   trunk/system/src/resources/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicLifecycle_NotAutomatic.xml
   trunk/system/src/resources/tests/org/jboss/test/system/controller/lifecycle/seperated/
   trunk/system/src/resources/tests/org/jboss/test/system/controller/lifecycle/seperated/test/
   trunk/system/src/resources/tests/org/jboss/test/system/controller/lifecycle/seperated/test/SeperatedDependencyDepends_1.xml
   trunk/system/src/resources/tests/org/jboss/test/system/controller/lifecycle/seperated/test/SeperatedDependencyDepends_2.xml
   trunk/system/src/resources/tests/org/jboss/test/system/controller/parse/
   trunk/system/src/resources/tests/org/jboss/test/system/controller/parse/test/
   trunk/system/src/resources/tests/org/jboss/test/system/controller/parse/test/CodeEmpty.xml
   trunk/system/src/resources/tests/org/jboss/test/system/controller/parse/test/CodeMissing.xml
   trunk/system/src/resources/tests/org/jboss/test/system/controller/parse/test/ConstructorTypeEmpty.xml
   trunk/system/src/resources/tests/org/jboss/test/system/controller/parse/test/ConstructorTypeMissing.xml
   trunk/system/src/resources/tests/org/jboss/test/system/controller/parse/test/ConstructorValueMissing.xml
   trunk/system/src/resources/tests/org/jboss/test/system/controller/parse/test/NameEmpty.xml
   trunk/system/src/resources/tests/org/jboss/test/system/controller/parse/test/NameInvalid.xml
   trunk/system/src/resources/tests/org/jboss/test/system/controller/parse/test/NameMissing.xml
   trunk/system/src/resources/tests/org/jboss/test/system/metadata/
   trunk/system/src/resources/tests/org/jboss/test/system/metadata/basic/
   trunk/system/src/resources/tests/org/jboss/test/system/metadata/basic/test/
   trunk/system/src/resources/tests/org/jboss/test/system/metadata/basic/test/BasicMBean.xml
   trunk/system/src/resources/tests/org/jboss/test/system/metadata/basic/test/BasicMBeanEmptyCode.xml
   trunk/system/src/resources/tests/org/jboss/test/system/metadata/basic/test/BasicMBeanEmptyName.xml
   trunk/system/src/resources/tests/org/jboss/test/system/metadata/basic/test/BasicMBeanInterface.xml
   trunk/system/src/resources/tests/org/jboss/test/system/metadata/basic/test/BasicMBeanInvalidName.xml
   trunk/system/src/resources/tests/org/jboss/test/system/metadata/basic/test/BasicMBeanNoCode.xml
   trunk/system/src/resources/tests/org/jboss/test/system/metadata/basic/test/BasicMBeanNoName.xml
   trunk/system/src/resources/tests/org/jboss/test/system/metadata/constructor/
   trunk/system/src/resources/tests/org/jboss/test/system/metadata/constructor/test/
   trunk/system/src/resources/tests/org/jboss/test/system/metadata/constructor/test/ConstructorDefault.xml
   trunk/system/src/resources/tests/org/jboss/test/system/metadata/constructor/test/ConstructorEmptyType.xml
   trunk/system/src/resources/tests/org/jboss/test/system/metadata/constructor/test/ConstructorEmptyValue.xml
   trunk/system/src/resources/tests/org/jboss/test/system/metadata/constructor/test/ConstructorNoType.xml
   trunk/system/src/resources/tests/org/jboss/test/system/metadata/constructor/test/ConstructorNoValue.xml
   trunk/system/src/resources/tests/org/jboss/test/system/metadata/constructor/test/ConstructorOneArg.xml
   trunk/system/src/resources/tests/org/jboss/test/system/metadata/constructor/test/ConstructorTwoArgs.xml
   trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/
   trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/
   trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsEmpty.xml
   trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsInvalidObjectName.xml
   trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsListElementEmpty.xml
   trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsListElementNoNestedMBean.xml
   trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsListInvalidObjectName.xml
   trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsListNestedMBean.xml
   trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsListNone.xml
   trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsListOne.xml
   trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsListOptionalAttribute.xml
   trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsListOptionalAttributeElementEmpty.xml
   trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsListOptionalAttributeElementNoNestedMBean.xml
   trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsListOptionalAttributeInvalidObjectName.xml
   trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsListOptionalAttributeNestedMBean.xml
   trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsListTwo.xml
   trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsNestedMBean.xml
   trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsNoNestedMBean.xml
   trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsNone.xml
   trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsOne.xml
   trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsOptionalAttribute.xml
   trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsOptionalAttributeEmpty.xml
   trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsOptionalAttributeInvalidObjectName.xml
   trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsOptionalAttributeNestedMBean.xml
   trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsOptionalAttributeNoNestedMBean.xml
   trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsTwo.xml
   trunk/system/src/tests/org/jboss/test/AbstractSystemTest.java
   trunk/system/src/tests/org/jboss/test/SystemAllTestSuite.java
   trunk/system/src/tests/org/jboss/test/system/
   trunk/system/src/tests/org/jboss/test/system/SystemTestSuite.java
   trunk/system/src/tests/org/jboss/test/system/controller/
   trunk/system/src/tests/org/jboss/test/system/controller/AbstractControllerTest.java
   trunk/system/src/tests/org/jboss/test/system/controller/ControllerTestDelegate.java
   trunk/system/src/tests/org/jboss/test/system/controller/NewControllerTestDelegate.java
   trunk/system/src/tests/org/jboss/test/system/controller/OldControllerTestDelegate.java
   trunk/system/src/tests/org/jboss/test/system/controller/SimpleSARDeployer.java
   trunk/system/src/tests/org/jboss/test/system/controller/TestClassLoader.java
   trunk/system/src/tests/org/jboss/test/system/controller/TestClassLoaderMBean.java
   trunk/system/src/tests/org/jboss/test/system/controller/basic/
   trunk/system/src/tests/org/jboss/test/system/controller/basic/test/
   trunk/system/src/tests/org/jboss/test/system/controller/basic/test/BasicNewUnitTestCase.java
   trunk/system/src/tests/org/jboss/test/system/controller/basic/test/BasicOldUnitTestCase.java
   trunk/system/src/tests/org/jboss/test/system/controller/basic/test/BasicTest.java
   trunk/system/src/tests/org/jboss/test/system/controller/basic/test/ControllerBasicTestSuite.java
   trunk/system/src/tests/org/jboss/test/system/controller/basic/test/DoubleInstallNewUnitTestCase.java
   trunk/system/src/tests/org/jboss/test/system/controller/basic/test/DoubleInstallOldUnitTestCase.java
   trunk/system/src/tests/org/jboss/test/system/controller/basic/test/DoubleInstallTest.java
   trunk/system/src/tests/org/jboss/test/system/controller/configure/
   trunk/system/src/tests/org/jboss/test/system/controller/configure/test/
   trunk/system/src/tests/org/jboss/test/system/controller/configure/test/ConfigureNewUnitTestCase.java
   trunk/system/src/tests/org/jboss/test/system/controller/configure/test/ConfigureOldUnitTestCase.java
   trunk/system/src/tests/org/jboss/test/system/controller/configure/test/ConfigureTest.java
   trunk/system/src/tests/org/jboss/test/system/controller/configure/test/ControllerConfigureTestSuite.java
   trunk/system/src/tests/org/jboss/test/system/controller/configure/test/ErrorNewUnitTestCase.java
   trunk/system/src/tests/org/jboss/test/system/controller/configure/test/ErrorOldUnitTestCase.java
   trunk/system/src/tests/org/jboss/test/system/controller/configure/test/ErrorTest.java
   trunk/system/src/tests/org/jboss/test/system/controller/instantiate/
   trunk/system/src/tests/org/jboss/test/system/controller/instantiate/plain/
   trunk/system/src/tests/org/jboss/test/system/controller/instantiate/plain/test/
   trunk/system/src/tests/org/jboss/test/system/controller/instantiate/plain/test/PlainMBeanNewUnitTestCase.java
   trunk/system/src/tests/org/jboss/test/system/controller/instantiate/plain/test/PlainMBeanOldUnitTestCase.java
   trunk/system/src/tests/org/jboss/test/system/controller/instantiate/plain/test/PlainMBeanTest.java
   trunk/system/src/tests/org/jboss/test/system/controller/instantiate/standard/
   trunk/system/src/tests/org/jboss/test/system/controller/instantiate/standard/test/
   trunk/system/src/tests/org/jboss/test/system/controller/instantiate/standard/test/StandardMBeanNewUnitTestCase.java
   trunk/system/src/tests/org/jboss/test/system/controller/instantiate/standard/test/StandardMBeanOldUnitTestCase.java
   trunk/system/src/tests/org/jboss/test/system/controller/instantiate/standard/test/StandardMBeanTest.java
   trunk/system/src/tests/org/jboss/test/system/controller/instantiate/test/
   trunk/system/src/tests/org/jboss/test/system/controller/instantiate/test/ConstructorArgsNewUnitTestCase.java
   trunk/system/src/tests/org/jboss/test/system/controller/instantiate/test/ConstructorArgsOldUnitTestCase.java
   trunk/system/src/tests/org/jboss/test/system/controller/instantiate/test/ConstructorArgsTest.java
   trunk/system/src/tests/org/jboss/test/system/controller/instantiate/test/ControllerInstantiateTestSuite.java
   trunk/system/src/tests/org/jboss/test/system/controller/instantiate/test/NewNoMetaDataInstantiateUnitTestCase.java
   trunk/system/src/tests/org/jboss/test/system/controller/legacy/
   trunk/system/src/tests/org/jboss/test/system/controller/legacy/OldServiceConfigurator.java
   trunk/system/src/tests/org/jboss/test/system/controller/legacy/OldServiceController.java
   trunk/system/src/tests/org/jboss/test/system/controller/legacy/OldServiceControllerMBean.java
   trunk/system/src/tests/org/jboss/test/system/controller/legacy/OldServiceCreator.java
   trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/
   trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/
   trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/
   trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsListNestedNewUnitTestCase.java
   trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsListNestedOldUnitTestCase.java
   trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsListNewUnitTestCase.java
   trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsListOldUnitTestCase.java
   trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsNestedNewUnitTestCase.java
   trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsNestedOldUnitTestCase.java
   trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsNewUnitTestCase.java
   trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsOldUnitTestCase.java
   trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsOptionalAttributeListNestedNewUnitTestCase.java
   trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsOptionalAttributeListNestedOldUnitTestCase.java
   trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsOptionalAttributeListNewUnitTestCase.java
   trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsOptionalAttributeListOldUnitTestCase.java
   trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsOptionalAttributeNestedNewUnitTestCase.java
   trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsOptionalAttributeNestedOldUnitTestCase.java
   trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsOptionalAttributeNewUnitTestCase.java
   trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsOptionalAttributeOldUnitTestCase.java
   trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyTest.java
   trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicLifecycleNewUnitTestCase.java
   trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicLifecycleOldUnitTestCase.java
   trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicLifecycleTest.java
   trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/ControllerLifecycleBasicTestSuite.java
   trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/seperated/
   trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/seperated/test/
   trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/seperated/test/ControllerLifecycleSeperatedTestSuite.java
   trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/seperated/test/SeperatedDependencyDependsNewUnitTestCase.java
   trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/seperated/test/SeperatedDependencyDependsOldUnitTestCase.java
   trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/seperated/test/SeperatedDependencyTest.java
   trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/test/
   trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/test/ControllerLifecycleTestSuite.java
   trunk/system/src/tests/org/jboss/test/system/controller/parse/
   trunk/system/src/tests/org/jboss/test/system/controller/parse/test/
   trunk/system/src/tests/org/jboss/test/system/controller/parse/test/ControllerParseTestSuite.java
   trunk/system/src/tests/org/jboss/test/system/controller/parse/test/ErrorInParseNewUnitTestCase.java
   trunk/system/src/tests/org/jboss/test/system/controller/parse/test/ErrorInParseOldUnitTestCase.java
   trunk/system/src/tests/org/jboss/test/system/controller/parse/test/ErrorInParseTest.java
   trunk/system/src/tests/org/jboss/test/system/controller/support/
   trunk/system/src/tests/org/jboss/test/system/controller/support/AbstractSimple.java
   trunk/system/src/tests/org/jboss/test/system/controller/support/NotSimpleStandardMBeanInterface.java
   trunk/system/src/tests/org/jboss/test/system/controller/support/Order.java
   trunk/system/src/tests/org/jboss/test/system/controller/support/Simple.java
   trunk/system/src/tests/org/jboss/test/system/controller/support/SimpleMBean.java
   trunk/system/src/tests/org/jboss/test/system/controller/support/SimpleStandardMBeanInterface.java
   trunk/system/src/tests/org/jboss/test/system/controller/test/
   trunk/system/src/tests/org/jboss/test/system/controller/test/ControllerTestSuite.java
   trunk/system/src/tests/org/jboss/test/system/metadata/
   trunk/system/src/tests/org/jboss/test/system/metadata/basic/
   trunk/system/src/tests/org/jboss/test/system/metadata/basic/test/
   trunk/system/src/tests/org/jboss/test/system/metadata/basic/test/BasicMBeanUnitTestCase.java
   trunk/system/src/tests/org/jboss/test/system/metadata/constructor/
   trunk/system/src/tests/org/jboss/test/system/metadata/constructor/test/
   trunk/system/src/tests/org/jboss/test/system/metadata/constructor/test/ConstructorUnitTestCase.java
   trunk/system/src/tests/org/jboss/test/system/metadata/depends/
   trunk/system/src/tests/org/jboss/test/system/metadata/depends/test/
   trunk/system/src/tests/org/jboss/test/system/metadata/depends/test/DependsOptionalAttributeUnitTestCase.java
   trunk/system/src/tests/org/jboss/test/system/metadata/depends/test/DependsUnitTestCase.java
   trunk/system/src/tests/org/jboss/test/system/metadata/test/
   trunk/system/src/tests/org/jboss/test/system/metadata/test/AbstractMetaDataTest.java
   trunk/system/src/tests/org/jboss/test/system/metadata/test/MetaDataTestDelegate.java
   trunk/system/src/tests/org/jboss/test/system/metadata/test/MetaDataTestSuite.java
Modified:
   trunk/build/build-distr.xml
   trunk/system/.classpath
   trunk/system/build-test.xml
   trunk/system/build.xml
   trunk/system/src/main/org/jboss/deployment/DeploymentInfo.java
   trunk/system/src/main/org/jboss/system/ServiceConfigurator.java
   trunk/system/src/main/org/jboss/system/ServiceContext.java
   trunk/system/src/main/org/jboss/system/ServiceController.java
   trunk/system/src/main/org/jboss/system/ServiceControllerMBean.java
   trunk/system/src/main/org/jboss/system/ServiceCreator.java
   trunk/system/src/main/org/jboss/system/ServiceMBeanSupport.java
   trunk/system/src/main/org/jboss/system/server/ServerLoader.java
Log:
[JBAS-1841] - ServiceController is now a facade over the Microcontainer
Dependency Controller

Modified: trunk/build/build-distr.xml
===================================================================
--- trunk/build/build-distr.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/build/build-distr.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -1807,6 +1807,11 @@
       <fileset dir="${jboss.jbossxb.lib}">
         <include name="jboss-xml-binding.jar"/>
       </fileset>
+      <fileset dir="${jboss.microcontainer.lib}">
+        <include name="jboss-container.jar"/>
+        <include name="jboss-dependency.jar"/>
+        <include name="jboss-microcontainer.jar"/>
+      </fileset>
     </copy>
 
     <!-- Copy the generated client libraries -->

Modified: trunk/system/.classpath
===================================================================
--- trunk/system/.classpath	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/.classpath	2006-08-03 16:33:33 UTC (rev 55118)
@@ -3,6 +3,7 @@
 	<classpathentry kind="src" path="src/main"/>
 	<classpathentry output="output/eclipse-test-classes" kind="src" path="src/tests"/>
 	<classpathentry output="output/eclipse-test-classes" kind="src" path="src/tests-support"/>
+	<classpathentry kind="lib" path="src/resources/tests"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
 	<classpathentry kind="lib" path="/thirdparty/jboss/common/lib/jboss-common.jar"/>
 	<classpathentry kind="lib" path="/thirdparty/gnu-getopt/lib/getopt.jar"/>

Modified: trunk/system/build-test.xml
===================================================================
--- trunk/system/build-test.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/build-test.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -8,7 +8,7 @@
 
 <!-- $Id$ -->
 
-<project default="main" name="JBoss/Container Tests">
+<project default="main" name="JBoss/System Tests">
 
    <!-- ================================================================== -->
    <!-- Setup                                                              -->
@@ -100,7 +100,7 @@
       <path id="jboss.this.classpath">
          <fileset dir="${jboss.this.lib}">
             <include name="*.jar" />
-            <exclude name="${jar.prefix}.jar" />
+            <exclude name="run.jar" />
          </fileset>
       </path>
 
@@ -203,7 +203,7 @@
 
          <classpath>
             <pathelement location="${build.classes}" />
-            <pathelement location="${build.resources}" />
+            <pathelement location="${build.resources}/tests" />
             <path refid="javac.classpath" />
             <path refid="apache.xerces.classpath" />
          </classpath>
@@ -235,7 +235,7 @@
 
          <classpath>
             <pathelement location="${build.classes}" />
-            <pathelement location="${build.resources}" />
+            <pathelement location="${build.resources}/tests" />
             <path refid="thirdparty.classpath" />
             <path refid="apache.xerces.classpath"/>
          </classpath>

Modified: trunk/system/build.xml
===================================================================
--- trunk/system/build.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/build.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -95,9 +95,9 @@
     <!-- Tasks -->
     <!-- ===== -->
 
-    <property name="javac.target" value="5"/>
-    <property name="javac.source" value="5"/>
     <property name="jar.prefix" value="jboss-system"/>
+    <property name="javac.target" value="1.5"/>
+    <property name="javac.source" value="1.5"/>
     <property name="jar.client.includes" 
               value="org/jboss/deployment/DeploymentException*,
                      org/jboss/deployment/IncompleteDeploymentException*,
@@ -127,37 +127,11 @@
 
   <target name="compile"
 	  description="Compile all source files."
-	  depends="compile-classes,
+	  depends="_default:compile-classes,
               _default:compile-resources,
               _default:compile-etc,
               _default:compile-bin"/>
 
-  <!-- Compile all class files -->
-  <target name="compile-classes" depends="init">
-    <mkdir dir="${build.classes}"/>
-    <javac destdir="${build.classes}"
-      optimize="${javac.optimize}"
-      target="${javac.target}"
-      source="1.5"
-      debug="${javac.debug}"
-      depend="${javac.depend}"
-      verbose="${javac.verbose}"
-      deprecation="${javac.deprecation}"
-      includeAntRuntime="${javac.include.ant.runtime}"
-      includeJavaRuntime="${javac.include.java.runtime}"
-      includes="${javac.includes}"
-      excludes="${javac.excludes}"
-      failonerror="${javac.fail.onerror}">
-      <src path="${source.java}"/>
-      <classpath refid="javac.classpath"/>
-    </javac>
-  </target>
-
-
-
-
-
-
   <!-- ================================================================== -->
   <!-- Archives                                                           -->
   <!-- ================================================================== -->

Modified: trunk/system/src/main/org/jboss/deployment/DeploymentInfo.java
===================================================================
--- trunk/system/src/main/org/jboss/deployment/DeploymentInfo.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/main/org/jboss/deployment/DeploymentInfo.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -121,7 +121,7 @@
    public final Collection classpath = new ArrayList();
 
    /** The mbeans deployed */
-   public final List mbeans = new ArrayList();
+   public final List<ObjectName> mbeans = new ArrayList<ObjectName>();
 
    /** Anyone can have subdeployments */
    public final Set subDeployments = new ListSet();

Modified: trunk/system/src/main/org/jboss/system/ServiceConfigurator.java
===================================================================
--- trunk/system/src/main/org/jboss/system/ServiceConfigurator.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/main/org/jboss/system/ServiceConfigurator.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -21,25 +21,20 @@
  */
 package org.jboss.system;
 
-import java.beans.PropertyEditor;
-import java.beans.PropertyEditorManager;
 import java.io.IOException;
-import java.io.StringReader;
 import java.io.StringWriter;
 import java.io.Writer;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
-import java.util.ListIterator;
-import java.util.Properties;
 
 import javax.management.Attribute;
 import javax.management.InstanceNotFoundException;
 import javax.management.MBeanAttributeInfo;
 import javax.management.MBeanInfo;
 import javax.management.MBeanServer;
-import javax.management.ObjectInstance;
 import javax.management.ObjectName;
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
@@ -52,44 +47,28 @@
 import org.jboss.deployment.DeploymentException;
 import org.jboss.logging.Logger;
 import org.jboss.mx.util.JMXExceptionDecoder;
-import org.jboss.mx.util.MBeanProxyExt;
-import org.jboss.mx.util.ObjectNameFactory;
-import org.jboss.util.Classes;
-import org.jboss.util.StringPropertyReplacer;
-import org.jboss.util.propertyeditor.PropertyEditors;
+import org.jboss.system.metadata.ServiceAttributeMetaData;
+import org.jboss.system.metadata.ServiceMetaData;
+import org.jboss.system.metadata.ServiceMetaDataParser;
 import org.jboss.util.xml.DOMWriter;
-import org.jboss.xb.binding.Unmarshaller;
-import org.jboss.xb.binding.UnmarshallerFactory;
-import org.jboss.xb.binding.sunday.unmarshalling.DefaultSchemaResolver;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
 
 /**
  * Service configuration helper.
+ * 
  * @author <a href="mailto:marc at jboss.org">Marc Fleury</a>
  * @author <a href="mailto:hiram at jboss.org">Hiram Chirino</a>
  * @author <a href="mailto:d_jencks at users.sourceforge.net">David Jencks</a>
  * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
  * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
  * @version <tt>$Revision$</tt>
  */
 public class ServiceConfigurator
 {
-   /** 
-    * Augment the PropertyEditorManager search path to incorporate the JBoss
-    * specific editors. This simply references the PropertyEditors.class to
-    * invoke its static initialization block.
-    */
-   static
-   {
-      PropertyEditors.init();
-   }
-
-   // Private Data --------------------------------------------------
-   
    /** The MBean server which this service is registered in. */
    private final MBeanServer server;
    
@@ -102,30 +81,137 @@
    /** The ServiceBinding plugin policy */
    private ServiceBinding serviceBinding;
 
+   /** Instance logger. */
+   private static final Logger log = Logger.getLogger(ServiceConfigurator.class);
+
    /**
-    * The instance logger.
+    * Configure an MBean
+    * 
+    * @param server the server
+    * @param objectName the object name
+    * @param classLoaderName the classloader object name
+    * @param attrs the attributes
+    * @throws Exception for any error
     */
-   private final Logger log = Logger.getLogger(getClass());
+   public static void configure(MBeanServer server, ObjectName objectName, ObjectName classLoaderName, Collection<ServiceAttributeMetaData> attrs) throws Exception
+   {
+      ClassLoader cl = server.getClassLoader(classLoaderName);
+      configure(server, objectName, cl, attrs);
+   }
 
-   // Constructor ---------------------------------------------------
+   /**
+    * Configure an MBean
+    * 
+    * @param server the server
+    * @param objectName the object name
+    * @param cl the classloader
+    * @param attrs the attributes
+    * @throws Exception for any error
+    */
+   public static void configure(MBeanServer server, ObjectName objectName, ClassLoader cl, Collection<ServiceAttributeMetaData> attrs) throws Exception
+   {
+      HashMap<String, MBeanAttributeInfo> attributeMap = getAttributeMap(server, objectName);
+
+      for (ServiceAttributeMetaData attribute : attrs)
+      {
+         String attributeName = attribute.getName();
+         MBeanAttributeInfo attributeInfo = attributeMap.get(attributeName);
+         if (attributeInfo == null)
+            throw new DeploymentException("No Attribute found with name: " + attributeName + " for " + objectName);
+         Object value = attribute.getValue(server, attributeInfo, cl);
+         log.debug(attributeName + " set to " + value + " in " + objectName);
+         try
+         {
+            server.setAttribute(objectName, new Attribute(attributeName, value));
+         }
+         catch (Throwable t)
+         {
+            throw new DeploymentException("Exception setting attribute " + attributeName + " on mbean " + objectName, JMXExceptionDecoder.decode(t));
+         }
+      }
+   }
    
    /**
+    * Apply any service binding overrides
+    *
+    * @review why isn't the MBeanServer part of this api?
+    * @param server the server
+    * @param objectName the object name
+    * @param serviceBinding the service binding
+    * @throws Exception for any error
+    */
+   public static void applyServiceConfig(MBeanServer server, ObjectName objectName, ServiceBinding serviceBinding) throws Exception
+   {
+      try
+      {
+         serviceBinding.applyServiceConfig(objectName);
+      }
+      catch (Throwable e)
+      {
+         // serviceBinding is most probably a dynamic mbean proxy
+         Throwable t = JMXExceptionDecoder.decode(e);            
+         log.warn("Failed to apply service binding override for " + objectName, t);         
+      }
+   }
+
+   /**
+    * Get an attribute map for the MBean
+    * 
+    * @param server the server
+    * @param objectName the object name
+    * @return a map of attribute name to attribute info
+    * @throws Exception for any error
+    */
+   private static HashMap<String, MBeanAttributeInfo> getAttributeMap(MBeanServer server, ObjectName objectName) throws Exception
+   {
+      MBeanInfo info;
+      try
+      {
+         info = server.getMBeanInfo(objectName);
+      }
+      catch (InstanceNotFoundException e)
+      {
+         // The MBean is no longer available
+         throw new DeploymentException("Trying to configure nonexistent mbean: " + objectName);
+      }
+      catch (Exception e)
+      {
+         throw new DeploymentException("Could not get mbeanInfo", JMXExceptionDecoder.decode(e));
+      }
+      if (info == null)
+         throw new DeploymentException("MBeanInfo is null for mbean: " + objectName);
+      MBeanAttributeInfo[] attributes = info.getAttributes();
+      HashMap<String, MBeanAttributeInfo> attributeMap = new HashMap<String, MBeanAttributeInfo>();
+      for (int i = 0; i < attributes.length; i++)
+      {
+         MBeanAttributeInfo attr = attributes[i];
+         attributeMap.put(attr.getName(), attr);
+      }
+      
+      return attributeMap;
+   }
+   
+   /**
     * Constructor
     * 
-    * @param server
-    * @param serviceController
-    * @param serviceCreator
+    * @deprecated the service controller no longer uses the service configurator and vice-versa
+    * @param server the mbean server
+    * @param serviceController the servie controller
+    * @param serviceCreator the service creator
     */
-   public ServiceConfigurator(MBeanServer server,
-         ServiceController serviceController, ServiceCreator serviceCreator)
+   public ServiceConfigurator(MBeanServer server, ServiceController serviceController, ServiceCreator serviceCreator)
    {
+      if (server == null)
+         throw new IllegalArgumentException("Null server");
+      if (serviceCreator == null)
+         throw new IllegalArgumentException("Null serverCreator");
+      
       this.server = server;
       this.serviceController = serviceController;
       this.serviceCreator = serviceCreator;
-      this.serviceBinding = null;
+      if (serviceController != null)
+         this.serviceBinding = serviceController.getServiceBinding();
    }
-
-   // Public --------------------------------------------------------
    
    /**
     * Dynamically plug-in a ServiceBinding policy
@@ -142,69 +228,69 @@
     * The <code>install</code> method iterates through the mbean tags in the
     * supplied xml configuration and creates and configures the mbeans shown.
     * The mbean configuration can be nested.
+    * 
+    * @deprecated the service controller no longer uses the service configurator and vice-versa
     * @param config the xml <code>Element</code> containing the configuration of
     * the mbeans to create and configure.
+    * @param loaderName the classloader's ObjectName
     * @return a <code>List</code> of ObjectNames of created mbeans.
     * @throws DeploymentException if an error occurs
     */
-   public List install(Element config, ObjectName loaderName) throws DeploymentException
+   public List<ObjectName> install(Element config, ObjectName loaderName) throws DeploymentException
    {
-      List mbeans = new ArrayList();
-      try
+      // Parse the xml
+      ServiceMetaDataParser parser = new ServiceMetaDataParser(config);
+      List<ServiceMetaData> metaDatas = parser.parse();
+
+      // Track the registered object names
+      List<ObjectName> result = new ArrayList<ObjectName>(metaDatas.size());
+
+      // Go through each mbean in the passed xml
+      for (ServiceMetaData metaData : metaDatas)
       {
-         if (config.getTagName().equals("mbean"))
+         ObjectName objectName = metaData.getObjectName();
+         Collection<ServiceAttributeMetaData> attrs = metaData.getAttributes();
+         // Install and configure the mbean
+         try
          {
-            internalInstall(config, mbeans, loaderName, true);
+            ServiceCreator.install(server, objectName, metaData, null);
+            result.add(objectName);
+            configure(server, objectName, loaderName, attrs);
+            if (serviceBinding != null)
+               applyServiceConfig(server, objectName, serviceBinding);
          }
-         else
+         catch (Throwable t)
          {
-            NodeList nl = config.getChildNodes();
-
-            for (int i = 0; i < nl.getLength(); i++)
+            // Something went wrong
+            for (ObjectName name : result)
             {
-               if (nl.item(i).getNodeType() == Node.ELEMENT_NODE)
+               try
                {
-                  Element element = (Element) nl.item(i);
-                  if (element.getTagName().equals("mbean"))
-                  {
-                     Element mbean = (Element) nl.item(i);
-                     internalInstall(mbean, mbeans, loaderName, true);
-                  } // end of if ()
-               } // end of if ()
-            }//end of for
-         } //end of else
-         return mbeans;
-      }
-      catch (Exception e)
-      {
-         for (ListIterator li = mbeans.listIterator(mbeans.size()); li.hasPrevious();)
-         {
-            ObjectName mbean = (ObjectName) li.previous();
-            try
-            {
-               serviceCreator.remove(mbean);
+                  serviceCreator.remove(name);
+               }
+               catch (Exception e)
+               {
+                  log.error("Error removing mbean after failed deployment: " + name, e);
+               }
             }
-            catch (Exception n)
-            {
-               log.error("exception removing mbean after failed deployment: " + mbean, n);
-            }
+            DeploymentException.rethrowAsDeploymentException("Error during install", t);
          }
-
-         if (e instanceof DeploymentException)
-            throw (DeploymentException) e;
-
-         throw new DeploymentException(e);
       }
+      return result;
    }
 
    /**
     * Builds a string that consists of the configuration elements of the
     * currently running MBeans registered in the server.
-    * @throws Exception Failed to construct configuration.
+    * 
     * @todo replace with more sophisticated mbean persistence mechanism.
+    * @param server the MBeanServer
+    * @param serviceController the service controller
+    * @param objectNames the object names to retrieve
+    * @return the xml string
+    * @throws Exception Failed to construct configuration.
     */
-   public String getConfiguration(ObjectName[] objectNames)
-      throws Exception
+   public static String getConfiguration(MBeanServer server, ServiceController serviceController, ObjectName[] objectNames) throws Exception
    {
       Writer out = new StringWriter();
 
@@ -217,7 +303,7 @@
       // Store attributes as XML
       for (int j = 0; j < objectNames.length; j++)
       {
-         Element mbeanElement = internalGetConfiguration(doc, objectNames[j]);
+         Element mbeanElement = internalGetConfiguration(doc, server, serviceController, objectNames[j]);
          serverElement.appendChild(mbeanElement);
       }
 
@@ -231,478 +317,9 @@
       // Return configuration
       return out.toString();
    }
-   
-   // Protected -----------------------------------------------------
-   
-   /**
-    * The <code>configure</code> method configures an mbean based on the xml
-    * element configuration passed in.  Three formats are supported:
-    * &lt;attribute name="(name)"&gt;(value)&lt;/attribute&gt; &lt;depends
-    * optional-attribute-name="(name)"&gt;(object name of mbean
-    * referenced)&lt;/depends&gt; &lt;depends-list optional-attribute-name="(name)"&gt;
-    * [list of]  &lt;/depends-list-element&gt;(object name)&lt;/depends-list-element&gt;
-    * &lt;/depends-list&gt;
-    *
-    * The last two can include nested mbean configurations or ObjectNames.
-    * SIDE-EFFECT: adds all mbeans this one depends on to the ServiceContext
-    * structures.
-    * @param mbeanElement an <code>Element</code> value
-    * @throws Exception if an error occurs
-    */
-   protected void configure(ObjectName objectName, ObjectName loaderName,
-      Element mbeanElement, List mbeans)
-      throws Exception
-   {
-      // Set configuration to MBeans from XML
 
-      MBeanInfo info;
-      try
-      {
-         info = server.getMBeanInfo(objectName);
-      }
-      catch (InstanceNotFoundException e)
-      {
-         // The MBean is no longer available
-         throw new DeploymentException("trying to configure nonexistent mbean: " + objectName);
-      }
-      catch (Exception e)
-      {
-         throw new DeploymentException("Could not get mbeanInfo", JMXExceptionDecoder.decode(e));
-      } // end of catch
-
-      if (info == null)
-      {
-         throw new DeploymentException("MBeanInfo is null for mbean: " + objectName);
-      } // end of if ()
-
-      // Get the classloader for loading attribute classes.
-      ClassLoader cl = server.getClassLoader(loaderName);
-      // Initialize the mbean using the configuration supplied defaults
-      MBeanAttributeInfo[] attributes = info.getAttributes();
-      HashMap attributeMap = new HashMap();
-      for (int i = 0; i < attributes.length; i++)
-      {
-         MBeanAttributeInfo attr = attributes[i];
-         attributeMap.put(attr.getName(), attr);
-      }
-
-      NodeList attrs = mbeanElement.getChildNodes();
-      for (int j = 0; j < attrs.getLength(); j++)
-      {
-         // skip over non-element nodes
-         if (attrs.item(j).getNodeType() != Node.ELEMENT_NODE)
-         {
-            continue;
-         }
-
-         Element element = (Element) attrs.item(j);
-
-         boolean replace = true;
-
-         // Set attributes
-         if (element.getTagName().equals("attribute"))
-         {
-            String attributeName = element.getAttribute("name");
-            boolean trim = true;
-            String replaceAttr = element.getAttribute("replace");
-            if (replaceAttr.length() > 0)
-               replace = Boolean.valueOf(replaceAttr).booleanValue();
-            String trimAttr = element.getAttribute("trim");
-            if (trimAttr.length() > 0)
-               trim = Boolean.valueOf(trimAttr).booleanValue();
-            String serialDataType = element.getAttribute("serialDataType");
-
-            // Get the MBeanAttributeInfo
-            MBeanAttributeInfo attr = (MBeanAttributeInfo) attributeMap.get(attributeName);
-            if (attr == null)
-               throw new DeploymentException("No Attribute found with name: " + attributeName);
-
-            if (element.hasChildNodes())
-            {
-               Object value = null;
-               // Unmarshall the attribute value based on the serialDataType
-               if (serialDataType.equals("javaBean"))
-                  value = parseJavaBeanSerialData(attr, cl, element, replace, trim);
-               else if (serialDataType.equals("jbxb"))
-                  value = parseJbxbSerialData(attr, cl, element, replace, trim);
-               else
-                  value = parseTextSerialData(attr, cl, element, replace, trim);
-               
-               log.debug(attributeName + " set to " + value + " in " + objectName);
-               setAttribute(objectName, new Attribute(attributeName, value));
-            }//if has children
-
-         }
-         //end of "attribute
-         else if (element.getTagName().equals("depends"))
-         {
-            if (!element.hasChildNodes())
-            {
-               throw new DeploymentException("No ObjectName supplied for depends in  " + objectName);
-            }
-
-            String mbeanRefName = element.getAttribute("optional-attribute-name");
-            if ("".equals(mbeanRefName))
-               mbeanRefName = null;
-            else
-               mbeanRefName = StringPropertyReplacer.replaceProperties(mbeanRefName);
-
-            String proxyType = element.getAttribute("proxy-type");
-            if ("".equals(proxyType))
-               proxyType = null;
-            else
-               proxyType = StringPropertyReplacer.replaceProperties(proxyType);
-
-            // Get the mbeanRef value
-            ObjectName dependsObjectName = processDependency(objectName, loaderName, element, mbeans, replace);
-            log.debug("considering " + ((mbeanRefName == null) ? "<anonymous>" : mbeanRefName.toString()) + " with object name " + dependsObjectName);
-
-            if (mbeanRefName != null)
-            {
-               Object attribute = dependsObjectName;
-               if (proxyType != null)
-               {
-                  if (mbeanRefName == null)
-                     throw new DeploymentException("You cannot use a proxy-type without an optional-attribute-name");
-                  if (proxyType.equals("attribute"))
-                  {
-                     MBeanAttributeInfo attr = (MBeanAttributeInfo) attributeMap.get(mbeanRefName);
-                     if (attr == null)
-                        throw new DeploymentException("No Attribute found with name: " + mbeanRefName);
-                     proxyType = attr.getType();
-                  }
-                  Class proxyClass = cl.loadClass(proxyType);
-                  attribute = MBeanProxyExt.create(proxyClass, dependsObjectName,
-                     server, true);
-               }
-
-               //if if doesn't exist or has wrong type, we'll get an exception
-               setAttribute(objectName, new Attribute(mbeanRefName, attribute));
-            } // end of if ()
-         }
-         //end of depends
-         else if (element.getTagName().equals("depends-list"))
-         {
-            String dependsListName = element.getAttribute("optional-attribute-name");
-            if ("".equals(dependsListName))
-            {
-               dependsListName = null;
-            } // end of if ()
-
-            NodeList dependsList = element.getChildNodes();
-            ArrayList dependsListNames = new ArrayList();
-            for (int l = 0; l < dependsList.getLength(); l++)
-            {
-               if (dependsList.item(l).getNodeType() != Node.ELEMENT_NODE)
-               {
-                  continue;
-               }
-
-               Element dependsElement = (Element) dependsList.item(l);
-               if (dependsElement.getTagName().equals("depends-list-element"))
-               {
-                  if (!dependsElement.hasChildNodes())
-                  {
-                     throw new DeploymentException("Empty depends-list-element!");
-                  } // end of if ()
-
-                  // Get the depends value
-                  ObjectName dependsObjectName = processDependency(objectName, loaderName, dependsElement, mbeans, replace);
-                  if (!dependsListNames.contains(dependsObjectName))
-                  {
-                     dependsListNames.add(dependsObjectName);
-                  } // end of if ()
-               }
-
-            } // end of for ()
-            if (dependsListName != null)
-            {
-               setAttribute(objectName, new Attribute(dependsListName, dependsListNames));
-            } // end of if ()
-         }//end of depends-list
-      }
-
-      // If a ServiceBinding policy is plugged-in, check for overriden attributes
-      if (serviceBinding != null)
-      {
-         try
-         {
-            serviceBinding.applyServiceConfig(objectName);
-         }
-         catch (Exception e)
-         {
-            // serviceBinding is most probably a dynamic mbean proxy
-            Throwable t = JMXExceptionDecoder.decode(e);            
-            log.warn("Failed to apply service binding override", t);         
-         }
-      }
-   }
-
-   // Private -------------------------------------------------------
-   
-   private ObjectName internalInstall(Element mbeanElement, List mbeans,
-         ObjectName loaderName, boolean replace) throws Exception
-      {
-         ObjectInstance instance = null;
-         ObjectName mbeanName = parseObjectName(mbeanElement, replace);
-
-         instance = serviceCreator.install(mbeanName, loaderName, mbeanElement);
-
-         // just in case it changed...
-         mbeanName = instance.getObjectName();
-
-         mbeans.add(mbeanName);
-         if (mbeanName != null)
-         {
-            ServiceContext ctx = serviceController.createServiceContext(mbeanName);
-            try
-            {
-               configure(mbeanName, loaderName, mbeanElement, mbeans);
-               ctx.state = ServiceContext.CONFIGURED;
-               ctx.problem = null;
-            }
-            catch (Exception e)
-            {
-               ctx.state = ServiceContext.FAILED;
-               ctx.problem = e;
-               log.info("Problem configuring service " + mbeanName, e);
-               //throw e;
-            }
-         }
-
-         return mbeanName;
-      }
-   
-   /**
-    * Configure the mbean attribute using the element text and PropertyEditor for the
-    * attribute type. 
-    * @param attr - the mbean attribute
-    * @param cl - the class loader to use
-    * @param element - the mbean attribute element from the jboss-service descriptor
-    * @param replace - flag indicating if ${x} system property refs should be replaced
-    * @param trim - flag indicating if the element text shold be trimmed 
-    * @return the configured attribute value
-    * @throws Exception
-    */ 
-   private Object parseTextSerialData(MBeanAttributeInfo attr, ClassLoader cl,
-      Element element, boolean replace, boolean trim)
-      throws Exception
+   private static Element internalGetConfiguration(Document doc, MBeanServer server, ServiceController serviceController, ObjectName name) throws Exception
    {
-      // Get the attribute value
-      String attributeName = attr.getName();
-      String attributeText = getElementContent(element, trim, replace);
-      String typeName = attr.getType();
-
-      // see if it is a primitive type first
-      Class typeClass = Classes.getPrimitiveTypeForName(typeName);
-      if (typeClass == null)
-      {
-         // nope try look up
-         try
-         {
-            typeClass = cl.loadClass(typeName);
-         }
-         catch (ClassNotFoundException e)
-         {
-            throw new DeploymentException
-               ("Class not found for attribute: " + attributeName, e);
-         }
-      }
-
-      Object value = null;
-
-      /* Attributes of type Element are passed as is after optionally
-      performing system property replacement
-      */
-      if (typeClass.equals(Element.class))
-      {
-         // Use the first child Element of this element as the value
-         NodeList nl = element.getChildNodes();
-         for (int i = 0; i < nl.getLength(); i++)
-         {
-            Node n = nl.item(i);
-            if (n.getNodeType() == Node.ELEMENT_NODE)
-            {
-               value = n;
-               break;
-            }
-         }
-         // Replace any ${x} references in the element text
-         if (replace)
-         {
-            PropertyEditor editor = PropertyEditorManager.findEditor(typeClass);
-            if (editor == null)
-            {
-               log.warn("Cannot perform property replace on Element");
-            }
-            else
-            {
-               editor.setValue(value);
-               String text = editor.getAsText();
-               text = StringPropertyReplacer.replaceProperties(text);
-               editor.setAsText(text);
-               value = editor.getValue();
-            }
-         }
-      }
-
-      if (value == null)
-      {
-         PropertyEditor editor = PropertyEditorManager.findEditor(typeClass);
-         if (editor == null)
-         {
-            throw new DeploymentException
-               ("No property editor for attribute: " + attributeName +
-               "; type=" + typeClass);
-         }
-
-         // JBAS-1709, temporarily switch the TCL so that property
-         // editors have access to the actual deployment ClassLoader.
-         ClassLoader tcl = Thread.currentThread().getContextClassLoader();
-         Thread.currentThread().setContextClassLoader(cl);
-         try 
-         {
-            editor.setAsText(attributeText);
-            value = editor.getValue();
-         }
-         finally 
-         {
-            Thread.currentThread().setContextClassLoader(tcl);
-         }
-      }
-      return value;
-   }
-
-   /**
-    * Configure the mbean attribute as a javabean with the bean properties given by
-    * nested property elements.
-    * @param attr - the mbean attribute
-    * @param cl - the class loader to use
-    * @param element - the mbean attribute element from the jboss-service descriptor
-    * @param replace - flag indicating if ${x} system property refs should be replaced
-    * @param trim - flag indicating if the element text shold be trimmed 
-    * @return the configured attribute java bean
-    * @throws Exception
-    */ 
-   private Object parseJavaBeanSerialData(MBeanAttributeInfo attr, ClassLoader cl,
-      Element element, boolean replace, boolean trim)
-      throws Exception
-   {
-      // Extract the property elements
-      String attributeClassName = element.getAttribute("attributeClass");
-      if( attributeClassName == null || attributeClassName.length() == 0 )
-         attributeClassName = attr.getType();
-      Class attributeClass = cl.loadClass(attributeClassName);
-      // Create the bean instance
-      Object bean = attributeClass.newInstance();
-      // Get the JavaBean properties
-      NodeList properties = element.getElementsByTagName("property");
-      Properties beanProps = new Properties();
-      for(int n = 0; n < properties.getLength(); n ++)
-      {
-         // Skip over non-element nodes
-         Node node = properties.item(n);
-         if (node.getNodeType() != Node.ELEMENT_NODE)
-         {
-            continue;
-         }
-         Element property = (Element) node;
-         String name = property.getAttribute("name");
-         String value = getElementContent(property, trim, replace);
-         beanProps.setProperty(name, value);
-      }
-
-      // Apply the properties to the bean
-      PropertyEditors.mapJavaBeanProperties(bean, beanProps);
-      return bean;
-   }
-
-   /**
-    * Configure the mbean attribute as a bean with the bean unmarshalled from
-    * the attribute xml contents using the JBossXB unmarshaller.
-    * 
-    * @param attr - the mbean attribute
-    * @param cl - the class loader to use
-    * @param element - the mbean attribute element from the jboss-service descriptor
-    * @param replace - ignored
-    * @param trim - ignored 
-    * @return the configured attribute bean
-    * @throws Exception
-    */ 
-   private Object parseJbxbSerialData(MBeanAttributeInfo attr, ClassLoader cl,
-      Element element, boolean replace, boolean trim)
-      throws Exception
-   {
-      // Get the attribute element content in a parsable form
-      StringBuffer buffer = getElementContent(element);
-
-      // Parse the attribute element content
-      DefaultSchemaResolver resolver = new DefaultSchemaResolver();
-      Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
-      StringReader reader = new StringReader(buffer.toString());
-      Object bean = unmarshaller.unmarshal(reader, resolver);
-      return bean;
-   }
-
-   private ObjectName processDependency(ObjectName container, ObjectName loaderName,
-      Element element, List mbeans, boolean replace)
-      throws Exception
-   {
-      ObjectName dependsObjectName = null;
-      NodeList nl = element.getChildNodes();
-      for (int i = 0; i < nl.getLength(); i++)
-      {
-         Node childNode = nl.item(i);
-         if (childNode.getNodeType() == Node.ELEMENT_NODE)
-         {
-            Element child = (Element) childNode;
-            if (child.getTagName().equals("mbean"))
-            {
-               dependsObjectName = internalInstall(child, mbeans, loaderName, replace);
-               break;
-            }
-            else
-            {
-               throw new DeploymentException("Non mbean child element in depends tag: " + child);
-            } // end of else
-         } // end of if ()
-      } // end of for ()
-
-      if (dependsObjectName == null)
-      {
-         String name = getElementContent(element, true, replace);
-         dependsObjectName = ObjectNameFactory.create(name);
-      }
-      if (dependsObjectName == null)
-      {
-         throw new DeploymentException("No object name found for attribute!");
-      } // end of if ()
-
-      serviceController.registerDependency(container, dependsObjectName);
-
-      return dependsObjectName;
-   }
-
-   /**
-    * A helper to deal with those pesky JMX exceptions.
-    */
-   private void setAttribute(ObjectName name, Attribute attr)
-      throws Exception
-   {
-      try
-      {
-         server.setAttribute(name, attr);
-      }
-      catch (Exception e)
-      {
-         throw new DeploymentException("Exception setting attribute " +
-            attr + " on mbean " + name, JMXExceptionDecoder.decode(e));
-      }
-   }
-
-   private Element internalGetConfiguration(Document doc, ObjectName name)
-      throws Exception
-   {
       Element mbeanElement = doc.createElement("mbean");
       mbeanElement.setAttribute("name", name.toString());
 
@@ -757,49 +374,19 @@
    }
 
    /**
-    * Parse an object name from the given element attribute 'name'.
-    * @param element Element to parse name from.
-    * @return Object name.
-    * @throws ConfigurationException Missing attribute 'name' (thrown if 'name'
-    * is null or "").
-    * @throws Exception
+    * Builds a string that consists of the configuration elements of the
+    * currently running MBeans registered in the server.
+    * 
+    * TODO replace with more sophisticated mbean persistence mechanism.
+    * @param objectNames the object names
+    * @return the xml string
+    * @throws Exception Failed to construct configuration.
     */
-   private ObjectName parseObjectName(final Element element, boolean replace)
-      throws Exception
+   public String getConfiguration(ObjectName[] objectNames) throws Exception
    {
-      String name = element.getAttribute("name");
-
-      if (name == null || name.trim().equals(""))
-      {
-         throw new DeploymentException("MBean attribute 'name' must be given.");
-      }
-
-      if (replace)
-         name = StringPropertyReplacer.replaceProperties(name);
-
-      return new ObjectName(name);
+      return getConfiguration(server, serviceController, objectNames);
    }
 
-   private String getElementContent(Element element, boolean trim, boolean replace)
-      throws Exception
-   {
-      NodeList nl = element.getChildNodes();
-      String attributeText = "";
-      for (int i = 0; i < nl.getLength(); i++)
-      {
-         Node n = nl.item(i);
-         if (n instanceof Text)
-         {
-            attributeText += ((Text) n).getData();
-         }
-      } // end of for ()
-      if (trim)
-         attributeText = attributeText.trim();
-      if (replace)
-         attributeText = StringPropertyReplacer.replaceProperties(attributeText);
-      return attributeText;
-   }
-
    /**
     * A utility method that transforms the contents of the argument element into
     * a StringBuffer representation that can be reparsed.
@@ -809,6 +396,8 @@
     * 
     * @param element - the parent dom element whose contents are to be extracted as an xml document string. 
     * @return the xml document string.
+    * @throws IOException for an error during IO
+    * @throws TransformerException for an erro during transformation
     */
    public static StringBuffer getElementContent(Element element) throws IOException, TransformerException
    {

Modified: trunk/system/src/main/org/jboss/system/ServiceContext.java
===================================================================
--- trunk/system/src/main/org/jboss/system/ServiceContext.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/main/org/jboss/system/ServiceContext.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -35,6 +35,7 @@
  * 
  * @author <a href="mailto:marc.fleury at jboss.org">marc fleury</a>
  * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
  * @version $Revision$
  */
 public class ServiceContext implements Serializable
@@ -71,19 +72,27 @@
    public int state = NOTYETINSTALLED;
    
    /** Dependent beans **/
-   public List iDependOn = new LinkedList();
+   public List<ServiceContext> iDependOn = new LinkedList<ServiceContext>();
    
    /** Beans that depend on me **/
-   public List dependsOnMe = new LinkedList();
+   public List<ServiceContext> dependsOnMe = new LinkedList<ServiceContext>();
    
    /** The fancy proxy to my service calls **/
    public Service proxy;
 
    /** Cause for failure */
    public Throwable problem;
-
-   // Object overrides ----------------------------------------------
    
+   public String getStateString()
+   {
+      return getStateString(state);
+   }
+   
+   public static String getStateString(int stateInt)
+   {
+      return stateNames[stateInt];
+   }
+   
    public String toString()
    {
       StringBuffer sbuf = new StringBuffer(512);
@@ -104,8 +113,6 @@
       return sbuf.toString();
    }
    
-   // Private -------------------------------------------------------
-   
    private void printList(StringBuffer sbuf, String msg, List ctxs)
    {
       if (ctxs.size() > 0)

Modified: trunk/system/src/main/org/jboss/system/ServiceController.java
===================================================================
--- trunk/system/src/main/org/jboss/system/ServiceController.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/main/org/jboss/system/ServiceController.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -21,56 +21,61 @@
  */
 package org.jboss.system;
 
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedList;
 import java.util.List;
-import java.util.ListIterator;
 import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
 
-import javax.management.JMException;
-import javax.management.MBeanInfo;
-import javax.management.MBeanOperationInfo;
 import javax.management.MBeanRegistration;
 import javax.management.MBeanServer;
 import javax.management.Notification;
 import javax.management.ObjectName;
 
+import org.jboss.dependency.spi.Controller;
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.dependency.spi.ControllerMode;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.dependency.spi.DependencyInfo;
+import org.jboss.dependency.spi.DependencyItem;
 import org.jboss.deployment.DeploymentException;
 import org.jboss.deployment.DeploymentInfo;
 import org.jboss.deployment.DeploymentState;
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.plugins.bootstrap.basic.BasicBootstrap;
+import org.jboss.kernel.spi.dependency.KernelController;
 import org.jboss.logging.Logger;
 import org.jboss.mx.server.ServerConstants;
 import org.jboss.mx.util.JBossNotificationBroadcasterSupport;
-import org.jboss.mx.util.JMXExceptionDecoder;
 import org.jboss.mx.util.ObjectNameFactory;
+import org.jboss.system.metadata.ServiceMetaData;
+import org.jboss.system.metadata.ServiceMetaDataParser;
+import org.jboss.system.microcontainer.LifecycleDependencyItem;
+import org.jboss.system.microcontainer.ServiceControllerContext;
 import org.w3c.dom.Element;
 
 /**
  * This is the main Service Controller. A controller can deploy a service to a
- * jboss.system It installs by delegating, it configures by delegating
+ * jboss.system It installs by delegating, it configures by delegating<p>
  *
+ * This class has been rewritten to delegate to the microcontainer's
+ * generic controller. Like the original ServiceController, all state
+ * transitions must be handled manually, e.g. driven by the deployer
+ * invoking create, start, stop, etc.
+ * That is with one exception; we register ourselves an automatic context.
+ *
  * @see org.jboss.system.Service
  *
  * @author <a href="mailto:marc.fleury at jboss.org">Marc Fleury</a>
  * @author <a href="mailto:d_jencks at users.sourceforge.net">David Jencks</a>
  * @author <a href="mailto:scott.stark at jboss.org">Scott Stark</a>
  * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
  * @version $Revision$
- *
- * @jmx:mbean name="jboss.system:service=ServiceController"
  */
 public class ServiceController extends JBossNotificationBroadcasterSupport
    implements ServiceControllerMBean, MBeanRegistration
 {
-   // Constants -----------------------------------------------------
-
    /** The ObjectName of the default loader repository */
    public static final ObjectName DEFAULT_LOADER_REPOSITORY = ObjectNameFactory.create(ServerConstants.DEFAULT_LOADER_NAME);
 
@@ -82,28 +87,39 @@
 
    /** Class logger. */
    private static final Logger log = Logger.getLogger(ServiceController.class);
-   
-   // Attributes ----------------------------------------------------
 
+   /** The kernel */
+   protected Kernel kernel;
+
    /** A callback to the JMX MBeanServer */
    protected MBeanServer server;
+   
+   /** The service binding */
+   protected ServiceBinding serviceBinding;
 
-   /** Creator, helper class to instantiate MBeans **/
-   protected ServiceCreator creator;
+   /** The contexts */
+   protected Map<ObjectName, ServiceControllerContext> installed = new ConcurrentHashMap<ObjectName, ServiceControllerContext>(); 
+   
+   /**
+    * Get the MBeanServer
+    * 
+    * @return the server
+    */
+   public MBeanServer getMBeanServer()
+   {
+      return server;
+   }
+   
+   /**
+    * Get the serviceBinding.
+    * 
+    * @return the serviceBinding.
+    */
+   public ServiceBinding getServiceBinding()
+   {
+      return serviceBinding;
+   }
 
-   /** Configurator, helper class to configure MBeans **/
-   protected ServiceConfigurator configurator;
-
-   /** ObjectName to ServiceContext map **/
-   protected Map nameToServiceMap = Collections.synchronizedMap(new HashMap());
-
-   /** A linked list of services in the order they were created **/
-   protected List installedServices = new LinkedList();
-
-   // Constructors --------------------------------------------------
-
-   // Public --------------------------------------------------------
-
    /**
     * Plugin a ServiceBinding policy
     * 
@@ -111,95 +127,60 @@
     */   
    public void setServiceBinding(ServiceBinding serviceBinding)
    {
-      if (configurator != null)
-      {
-         configurator.setServiceBinding(serviceBinding);
-      }
+      this.serviceBinding = serviceBinding;
    }
    
-   /**
-    * Lists the ServiceContexts of deployed mbeans
-    *
-    * @return the list of ServiceContexts for mbeans deployed through ServiceController.
-    * @jmx:managed-operation
-    */
-   public List listDeployed()
+   public List<ServiceContext> listDeployed()
    {
-      return new ArrayList(installedServices);
+      // Retrieve the service context from all our installed contexts
+      ArrayList<ServiceContext> result = new ArrayList<ServiceContext>(installed.size());
+      for (ServiceControllerContext context : installed.values())
+         result.add(context.getServiceContext());
+      return result;
    }
 
-   /**
-    * The <code>listIncompletelyDeployed</code> method returns the service contexts
-    * for the mbeans whose status is not CREATED, RUNNING, STOPPED or DESTROYED.
-    *
-    * An MBean that has reached one of the above states has its dependencies resolved.
-    * 
-    * @return a List<ServiceContext>
-    * @jmx:managed-operation
-    */
-   public List listIncompletelyDeployed()
+   public List<ServiceContext> listIncompletelyDeployed()
    {
-      List id = new ArrayList();
-      for (Iterator i = installedServices.iterator(); i.hasNext();)
+      // Retrieve the service contexts that are not deployed properly
+      ArrayList<ServiceContext> result = new ArrayList<ServiceContext>();
+      for (ServiceControllerContext context : installed.values())
       {
-         ServiceContext sc = (ServiceContext) i.next();
-         if ( sc.state != ServiceContext.CREATED &&
-              sc.state != ServiceContext.RUNNING &&
-              sc.state != ServiceContext.STOPPED &&
-              sc.state != ServiceContext.DESTROYED )
+         ServiceContext sc = context.getServiceContext();
+         if (sc.state != ServiceContext.CREATED &&
+             sc.state != ServiceContext.RUNNING &&
+             sc.state != ServiceContext.STOPPED &&
+             sc.state != ServiceContext.DESTROYED)
          {
-            id.add(sc);
+            result.add(sc);
          }
       }
-      return id;
+      return result;
    }
 
-   /**
-    * lists ObjectNames of deployed mbeans deployed through serviceController.
-    *
-    * @return a list of ObjectNames of deployed mbeans.
-    * @jmx:managed-operation
-    */
-   public List listDeployedNames()
+   public List<ObjectName> listDeployedNames()
    {
-      List names = new ArrayList(installedServices.size());
-      for (Iterator i = installedServices.iterator(); i.hasNext();)
-      {
-         ServiceContext ctx = (ServiceContext) i.next();
-         names.add(ctx.objectName);
-      }
-
-      return names;
+      // Get all the object names from our installed contexts
+      ArrayList<ObjectName> result = new ArrayList<ObjectName>(installed.size());
+      for (ObjectName name : installed.keySet())
+         result.add(name);
+      return result;
    }
 
-   /**
-    * Gets the Configuration attribute of the ServiceController object
-    *
-    * @param objectNames Description of Parameter
-    * @return The Configuration value
-    * @exception Exception Description of Exception
-    * @jmx:managed-operation
-    */
    public String listConfiguration(ObjectName[] objectNames) throws Exception
    {
-      return configurator.getConfiguration(objectNames);
+      return ServiceConfigurator.getConfiguration(server, this, objectNames);
    }
 
-   /** Go through the mbeans of the DeploymentInfo and validate that they
-    * are in a state at least equal to that of the argument state
-    *
-    * @jmx:managed-operation
-    */
    public void validateDeploymentState(DeploymentInfo di, DeploymentState state)
    {
-      ArrayList mbeans = new ArrayList(di.mbeans);
+      ArrayList<ObjectName> mbeans = new ArrayList<ObjectName>(di.mbeans);
       if (di.deployedObject != null)
          mbeans.add(di.deployedObject);
       boolean mbeansStateIsValid = true;
-      for (int m = 0; m < mbeans.size(); m++)
+      for (int m = 0; m < mbeans.size(); ++m)
       {
-         ObjectName serviceName = (ObjectName) mbeans.get(m);
-         ServiceContext ctx = this.getServiceContext(serviceName);
+         ObjectName serviceName = mbeans.get(m);
+         ServiceContext ctx = getServiceContext(serviceName);
          if (ctx != null && state == DeploymentState.STARTED)
             mbeansStateIsValid &= ctx.state == ServiceContext.RUNNING;
       }
@@ -207,47 +188,84 @@
          di.state = state;
    }
 
-   /**
-    * Deploy the beans
-    *
-    * Deploy means "instantiate and configure" so the MBean is created in the MBeanServer
-    * You must call "create" and "start" separately on the MBean to affect the service lifecycle
-    * deploy doesn't bother with service lifecycle only MBean instanciation/registration/configuration
-    *
-    * @param config
-    * @param loaderName
-    * @return Description of the Returned Value
-    * @throws DeploymentException
-    * @jmx:managed-operation
-    */
-   public synchronized List install(Element config, ObjectName loaderName)
-         throws DeploymentException
+   public List<ObjectName> install(Element config, ObjectName loaderName) throws DeploymentException
    {
-      List mbeans = configurator.install(config, loaderName);
-      for (Iterator i = mbeans.iterator(); i.hasNext();)
+      KernelController controller = kernel.getController();
+
+      // Parse the xml
+      ServiceMetaDataParser parser = new ServiceMetaDataParser(config);
+      List<ServiceMetaData> metaDatas = parser.parse();
+
+      // Track the registered mbeans both for returning the result
+      // and uninstalling in the event of an error
+      List<ObjectName> result = new ArrayList<ObjectName>(metaDatas.size());
+      List<ServiceControllerContext> contexts = new ArrayList<ServiceControllerContext>(metaDatas.size());
+
+      // Go through each mbean in the passed xml
+      for (ServiceMetaData metaData : metaDatas)
       {
-         ObjectName mbean = (ObjectName) i.next();
-         installedServices.add(createServiceContext(mbean));
+         metaData.setClassLoaderName(loaderName);
+
+         // Install the context to the configured level
+         ServiceControllerContext context = new ServiceControllerContext(this, metaData);
+         try
+         {
+            controller.install(context);
+            contexts.add(context);
+            controller.change(context, ControllerState.CONFIGURED);
+            installed.put(context.getObjectName(), context);
+            result.add(context.getObjectName());
+         }
+         catch (Throwable t)
+         {
+            // Something went wrong
+            for (ServiceControllerContext ctx : contexts)
+               safelyRemoveAnyRegisteredContext(ctx);
+
+            DeploymentException.rethrowAsDeploymentException("Error during install", t);
+         }
       }
-      return mbeans;
+      return result;
    }
-
+   
    /**
-    * Register the mbean against the microkernel with no dependencies.
-    * @see #register(ObjectName, java.util.Collection)
-    * @jmx:managed-operation
+    * Install an MBean without any meta data
+    * 
+    * @param name the object name
+    * @param object the mbean object
+    * @throws DeploymentException for any error
     */
-   public synchronized void register(ObjectName serviceName) throws Exception
+   public void install(ObjectName name, Object object) throws DeploymentException
    {
+      if (name == null)
+         throw new IllegalArgumentException("Null name");
+      if (object == null)
+         throw new IllegalArgumentException("Null object");
+
+      KernelController controller = kernel.getController();
+
+      ServiceControllerContext context = new ServiceControllerContext(this, name, object); 
+      try
+      {
+         controller.install(context);
+         controller.change(context, ControllerState.CONFIGURED);
+         installed.put(context.getObjectName(), context);
+      }
+      catch (Throwable t)
+      {
+         // Something went wrong
+         safelyRemoveAnyRegisteredContext(context);
+
+         DeploymentException.rethrowAsDeploymentException("Error during install", t);
+      }
+   }
+   
+   public void register(ObjectName serviceName) throws Exception
+   {
       register(serviceName, null);
    }
 
-   /**
-    * @see #register(ServiceContext, java.util.Collection)
-    * @jmx:managed-operation
-    */
-   public synchronized void register(ObjectName serviceName, Collection depends)
-         throws Exception
+   public void register(ObjectName serviceName, Collection<ObjectName> depends)  throws Exception
    {
       if (serviceName == null)
       {
@@ -256,32 +274,34 @@
       }
       
       log.debug("Registering service " + serviceName);
-      ServiceContext ctx = createServiceContext(serviceName);
 
-      register(ctx, depends);
-   }
+      // This is an already registered mbean
+      KernelController controller = kernel.getController();
+      ServiceControllerContext context = new ServiceControllerContext(this, serviceName);
+      if (depends != null)
+         addDependencies(context, depends);
 
-   /**
-    * #Description of the Method
-    *
-    * @param serviceName Description of Parameter
-    * @exception Exception Description of Exception
-    * @jmx:managed-operation
-    */
-   public synchronized void create(ObjectName serviceName) throws Exception
+      // Install the context to the configured level
+      try
+      {
+         controller.install(context);
+         installed.put(serviceName, context);
+         controller.change(context, ControllerState.CONFIGURED);
+      }
+      catch (Throwable t)
+      {
+         // Something went wrong
+         safelyRemoveAnyRegisteredContext(context);
+         DeploymentException.rethrowAsDeploymentException("Error during register: " + serviceName, t);
+      }
+   }
+   
+   public void create(ObjectName serviceName) throws Exception
    {
       create(serviceName, null);
    }
 
-   /**
-    * #Description of the Method
-    *
-    * @param serviceName Description of Parameter
-    * @exception Exception Description of Exception
-    * @jmx:managed-operation
-    */
-   public synchronized void create(ObjectName serviceName, Collection depends)
-         throws Exception
+   public void create(ObjectName serviceName, Collection<ObjectName> depends) throws Exception
    {
       if (serviceName == null)
       {
@@ -290,75 +310,40 @@
       }
       
       log.debug("Creating service " + serviceName);
-      ServiceContext ctx = createServiceContext(serviceName);
+      
+      // Register if not already done so
+      ServiceControllerContext context = installed.get(serviceName);
+      if (context == null)
+      {
+         register(serviceName, depends);
+         context = installed.get(serviceName);
+      }
+      ServiceContext ctx = context.getServiceContext();
 
-      // Register the context and its dependencies if necessary
-      register(ctx, depends);
-
       // If we are already created (can happen in dependencies) or failed just return
       if (ctx.state == ServiceContext.CREATED
             || ctx.state == ServiceContext.RUNNING
             || ctx.state == ServiceContext.FAILED)
       {
-         log.debug("Ignoring create request for service: " + ctx.objectName);
+         log.debug("Ignoring create request for service: " + ctx.objectName + " at state " + ctx.getStateString());
          return;
       }
 
-      // JSR 77, and to avoid circular dependencies
-      int oldState = ctx.state;
-      ctx.state = ServiceContext.CREATED;
-
-      // Are all the mbeans I depend on created?   if not just return
-      for (Iterator iterator = ctx.iDependOn.iterator(); iterator.hasNext();)
-      {
-         ServiceContext sc = (ServiceContext) iterator.next();
-         int state = sc.state;
-
-         // A dependent is not created or running
-         if (!(state == ServiceContext.CREATED || state == ServiceContext.RUNNING))
-         {
-            log.debug("waiting in create of " + serviceName +
-                  " waiting on " + sc.objectName);
-            ctx.state = oldState;
-            return;
-         }
-      }
-
-      // Call create on the service Proxy
+      // Request the mbean go to the created state
+      KernelController controller = kernel.getController();
       try
       {
-         ctx.proxy.create();
-         sendControllerNotification(ServiceMBean.CREATE_EVENT, serviceName);            
+         controller.change(context, ControllerState.CREATE);
+         if (ctx.state != ServiceContext.CREATED)
+            log.debug("Waiting in create of " + serviceName + " on " + getUnresolvedDependencies(context, ControllerState.CREATE));
       }
-      catch (Throwable e)
+      catch (Throwable t)
       {
-         ctx.state = ServiceContext.FAILED;
-         ctx.problem = e;
-         log.warn("Problem creating service " + serviceName, e);
-         return;
+         log.warn("Problem creating service " + serviceName, t);
       }
-
-      // Those that depend on me are waiting for my creation, recursively create them
-      log.debug("Creating dependent components for: " + serviceName
-            + " dependents are: " + ctx.dependsOnMe);
-      ArrayList tmp = new ArrayList(ctx.dependsOnMe);
-      for (int n = 0; n < tmp.size(); n++)
-      {
-         // marcf fixme circular dependencies?
-         ServiceContext ctx2 = (ServiceContext) tmp.get(n);
-         create(ctx2.objectName);
-      }
-      tmp.clear();
    }
-
-   /**
-    * Starts the indicated service
-    *
-    * @param serviceName Description of Parameter
-    * @exception Exception Description of Exception
-    * @jmx:managed-operation
-    */
-   public synchronized void start(ObjectName serviceName) throws Exception
+   
+   public void start(ObjectName serviceName) throws Exception
    {
       if (serviceName == null)
       {
@@ -367,83 +352,37 @@
       }
 
       log.debug("starting service " + serviceName);
+      
+      // Register if not already done so
+      ServiceControllerContext context = installed.get(serviceName);
+      if (context == null)
+      {
+         register(serviceName, null);
+         context = installed.get(serviceName);
+      }
+      ServiceContext ctx = context.getServiceContext();
 
-      ServiceContext ctx = createServiceContext(serviceName);
-
-      if (!installedServices.contains(ctx))
-         installedServices.add(ctx);
-
       // If we are already started (can happen in dependencies) just return
       if (ctx.state == ServiceContext.RUNNING || ctx.state == ServiceContext.FAILED)
       {
-         log.debug("Ignoring start request for service: " + ctx.objectName);
+         log.debug("Ignoring start request for service: " + ctx.objectName + " at state " + ctx.getStateString());
          return;
       }
 
-      // Start() is called before create(), so call create() to compensate
-      if (ctx.state != ServiceContext.CREATED && ctx.state != ServiceContext.STOPPED)
-      {
-         log.debug("Start requested before create, calling create now for service: " + serviceName);
-         create(serviceName);
-      }
-      
-      // Get the fancy service proxy (for the lifecycle API)
-      if (ctx.proxy == null)
-         ctx.proxy = getServiceProxy(ctx.objectName, null);
-
-      // JSR 77, and to avoid circular dependencies
-      int oldState = ctx.state;
-      ctx.state = ServiceContext.RUNNING;
-
-      // Are all the mbeans I depend on started?   if not just return
-      for (Iterator iterator = ctx.iDependOn.iterator(); iterator.hasNext();)
-      {
-         ServiceContext sctx = (ServiceContext) iterator.next();
-
-         int state = sctx.state;
-
-         // A dependent is not running
-         if (!(state == ServiceContext.RUNNING))
-         {
-            log.debug("waiting in start " + serviceName + " on " + sctx.objectName);
-            ctx.state = oldState;
-            return;
-         }
-      }
-
-      // Call start on the service Proxy
+      // Request the mbean go to the fully installed state
+      KernelController controller = kernel.getController();
       try
       {
-         ctx.proxy.start();
-         sendControllerNotification(ServiceMBean.START_EVENT, serviceName);            
+         controller.change(context, ControllerState.INSTALLED);
+         if (ctx.state != ServiceContext.RUNNING)
+            log.debug("Waiting in start of " + serviceName + " on " + getUnresolvedDependencies(context, ControllerState.START));
       }
-      catch (Throwable e)
+      catch (Throwable t)
       {
-         ctx.state = ServiceContext.FAILED;
-         ctx.problem = e;
-         log.warn("Problem starting service " + serviceName, e);
-         return;
+         log.warn("Problem starting service " + serviceName, t);
       }
-      // Those that depend on me are waiting for my start, recursively start them
-      log.debug("Starting dependent components for: " + serviceName
-            + " dependent components: " + ctx.dependsOnMe);
-      ArrayList tmp = new ArrayList(ctx.dependsOnMe);
-      for (int n = 0; n < tmp.size(); n++)
-      {
-         // marcf fixme circular dependencies?
-         ServiceContext ctx2 = (ServiceContext) tmp.get(n);
-         start(ctx2.objectName);
-      }
-      tmp.clear();
    }
 
-   /**
-    * Stops and restarts the given service
-    *
-    * @param serviceName Description of Parameter
-    * @exception Exception Description of Exception
-    * @jmx:managed-operation
-    */
    public void restart(ObjectName serviceName) throws Exception
    {
       if (serviceName == null)
@@ -457,13 +396,6 @@
       start(serviceName);
    }
 
-   /**
-    * Stop the given service
-    *
-    * @param serviceName Description of Parameter
-    * @exception Exception Description of Exception
-    * @jmx:managed-operation
-    */
    public void stop(ObjectName serviceName) throws Exception
    {
       if (serviceName == null)
@@ -472,58 +404,35 @@
          return;
       }
 
-      ServiceContext ctx = (ServiceContext) nameToServiceMap.get(serviceName);
       log.debug("stopping service: " + serviceName);
 
-      if (ctx == null)
+      ServiceControllerContext context = installed.get(serviceName);
+      if (context == null)
       {
          log.warn("Ignoring request to stop nonexistent service: " + serviceName);
          return;
       }
 
       // If we are already stopped (can happen in dependencies) just return
-      if (ctx.state != ServiceContext.RUNNING) return;
-
-      // JSR 77 and to avoid circular dependencies
-      ctx.state = ServiceContext.STOPPED;
-
-      log.debug("stopping dependent services for: " + serviceName
-            + " dependent services are: " + ctx.dependsOnMe);
-      
-      ArrayList tmp = new ArrayList(ctx.dependsOnMe);
-      for (int n = 0; n < tmp.size(); n++)
+      ServiceContext ctx = context.getServiceContext();
+      if (ctx.state != ServiceContext.RUNNING)
       {
-         // stop all the mbeans that depend on me
-         ServiceContext ctx2 = (ServiceContext) tmp.get(n);
-         ObjectName other = ctx2.objectName;
-         stop(other);
+         log.debug("Ignoring stop request for service: " + ctx.objectName + " at state " + ctx.getStateString());
+         return;
       }
-      tmp.clear();
 
-      // Call stop on the service Proxy
-      if (ctx.proxy != null)
+      // Request the mbean go back to the created state
+      KernelController controller = kernel.getController();
+      try
       {
-         try
-         {
-            ctx.proxy.stop();
-            sendControllerNotification(ServiceMBean.STOP_EVENT, serviceName);
-         }
-         catch (Throwable e)
-         {
-            ctx.state = ServiceContext.FAILED;
-            ctx.problem = e;
-            log.warn("Problem stopping service " + serviceName, e);
-         }
+         controller.change(context, ControllerState.CREATE);
       }
+      catch (Throwable t)
+      {
+         log.warn("Problem stopping service " + serviceName, t);
+      }
    }
 
-   /**
-    * #Description of the Method
-    *
-    * @param serviceName Description of Parameter
-    * @exception Exception Description of Exception
-    * @jmx:managed-operation
-    */
    public void destroy(ObjectName serviceName) throws Exception
    {
       if (serviceName == null)
@@ -532,67 +441,35 @@
          return;
       }
 
-      ServiceContext ctx = (ServiceContext) nameToServiceMap.get(serviceName);
       log.debug("destroying service: " + serviceName);
 
-      if (ctx == null)
+      ServiceControllerContext context = installed.get(serviceName);
+      if (context == null)
       {
          log.warn("Ignoring request to destroy nonexistent service: " + serviceName);
          return;
       }
 
       // If we are already destroyed (can happen in dependencies) just return
-      if (ctx.state == ServiceContext.DESTROYED ||
-          ctx.state == ServiceContext.NOTYETINSTALLED)
-         return;
-      
-      // If we are still running, stop service first
-      if (ctx.state == ServiceContext.RUNNING)
+      ServiceContext ctx = context.getServiceContext();
+      if (ctx.state == ServiceContext.DESTROYED || ctx.state == ServiceContext.NOTYETINSTALLED || ctx.state == ServiceContext.FAILED)
       {
-         log.debug("Destroy requested before stop, calling stop now for service: " + serviceName);
-         stop(serviceName);
+         log.debug("Ignoring destroy request for service: " + ctx.objectName + " at state " + ctx.getStateString());
+         return;
       }
 
-      // JSR 77, and to avoid circular dependencies
-      ctx.state = ServiceContext.DESTROYED;
-
-      log.debug("destroying dependent services for: " + serviceName
-            + " dependent services are: " + ctx.dependsOnMe);
-      
-      ArrayList tmp = new ArrayList(ctx.dependsOnMe);
-      for (int n = 0; n < tmp.size(); n++)
+      // Request the mbean go the configured state
+      KernelController controller = kernel.getController();
+      try
       {
-         // destroy all the mbeans that depend on me
-         ServiceContext ctx2 = (ServiceContext) tmp.get(n);
-         ObjectName other = ctx2.objectName;
-         destroy(other);
+         controller.change(context, ControllerState.CONFIGURED);
       }
-      tmp.clear();
-
-      // Call destroy on the service Proxy
-      if (ctx.proxy != null)
+      catch (Throwable t)
       {
-         try
-         {
-            ctx.proxy.destroy();
-            sendControllerNotification(ServiceMBean.DESTROY_EVENT, serviceName);
-         }
-         catch (Throwable e)
-         {
-            ctx.state = ServiceContext.FAILED;
-            ctx.problem = e;
-            log.warn("Problem destroying service " + serviceName, e);
-         }
+         log.warn("Problem stopping service " + serviceName, t);
       }
    }
 
-   /**
-    * This MBean is going bye bye
-    *
-    * @param objectName Description of Parameter
-    * @exception Exception Description of Exception
-    * @jmx:managed-operation
-    */
    public void remove(ObjectName objectName) throws Exception
    {
       if (objectName == null)
@@ -601,166 +478,81 @@
          return;
       }
 
-      ServiceContext ctx = (ServiceContext) nameToServiceMap.get(objectName);
-      if (ctx == null)
+      // Removal can be attempted twice, this is because ServiceMBeanSupport does a "double check" 
+      // to make sure the ServiceController is tidied up
+      // However, if the tidyup is done correctly, it invokes this method recursively:
+      // ServiceController::remove -> MBeanServer::unregisterMBean
+      // ServiceMBeanSupport::postDeregister -> ServiceController::remove
+      ServiceControllerContext context = installed.remove(objectName);
+      if (context == null)
       {
-         log.debug("Ignoring request to remove nonexistent service: " + objectName);
+         log.trace("Ignoring request to remove nonexistent service: " + objectName);
          return;
       }
       log.debug("removing service: " + objectName);
 
-      // Notify those that think I depend on them
-      Iterator iterator = ctx.iDependOn.iterator();
-      while (iterator.hasNext())
-      {
-         ServiceContext iDependOnContext = (ServiceContext) iterator.next();
-         iDependOnContext.dependsOnMe.remove(ctx);
-
-         // Remove any context whose only reason for existence is that
-         // we depend on it, i.e. it otherwise unknown to the system
-         if (iDependOnContext.state == ServiceContext.NOTYETINSTALLED
-               && iDependOnContext.dependsOnMe.size() == 0)
-         {
-            nameToServiceMap.remove(iDependOnContext.objectName);
-            log.debug("Removing context for nonexistent service it is " +
-                  "no longer recording dependencies: " + iDependOnContext);
-         }
-      }
-      //We remove all traces of our dependency configuration, since we
-      //don't know what will show up the next time we are deployed.
-      ctx.iDependOn.clear();
-
-      // Do we have a deployed MBean?
-      if (server.isRegistered(objectName))
-      {
-         log.debug("removing " + objectName + " from server");
-
-         // Remove the context, unless it is still recording dependencies
-         if (ctx.dependsOnMe.size() == 0)
-            nameToServiceMap.remove(objectName);
-         else
-         {
-            log.debug("Context not removed, it is recording " +
-                  "dependencies: " + ctx);
-            ctx.proxy = null;
-         }
-
-         // remove the mbean from the instaled ones
-         installedServices.remove(ctx);
-         creator.remove(objectName);
-      }
-      else
-      {
-         // Remove the context, unless it is still recording dependencies
-         installedServices.remove(ctx);
-         if (ctx.dependsOnMe.size() == 0)
-         {
-            log.debug("removing already unregistered " + objectName + " from server");
-            nameToServiceMap.remove(objectName);
-         }
-         else
-         {
-            log.debug("no need to remove " + objectName + " from server");
-            ctx.proxy = null;
-         }
-      }
-      // This context is no longer installed, but it may still exist
-      // to record dependent services
-      ctx.state = ServiceContext.NOTYETINSTALLED;
+      // Uninstall the context
+      safelyRemoveAnyRegisteredContext(context);
    }
 
-   /**
-    * Lookup the ServiceContext for the given serviceName
-    *
-    * @jmx.managed-operation
-    */
    public ServiceContext getServiceContext(ObjectName serviceName)
    {
-      ServiceContext ctx = (ServiceContext) nameToServiceMap.get(serviceName);
-      return ctx;
+      ServiceControllerContext context = installed.get(serviceName);
+      if (context != null)
+         return context.getServiceContext();
+      return null;
    }
    
-   /**
-    * Describe <code>shutdown</code> method here.
-    *
-    * @jmx:managed-operation
-    */
    public void shutdown()
    {
-      log.debug("Stopping " + nameToServiceMap.size() + " services");
+      log.debug("Stopping " + installed.size() + " services");
 
-      List servicesCopy = new ArrayList(installedServices);
-
+      KernelController controller = kernel.getController();
+      
       int serviceCounter = 0;
-      ObjectName name = null;
 
-      ListIterator i = servicesCopy.listIterator(servicesCopy.size());
-      while (i.hasPrevious())
+      // Uninstall all the contexts we know about
+      for (ServiceControllerContext context : installed.values())
       {
-         ServiceContext ctx = (ServiceContext) i.previous();
-         name = ctx.objectName;
-
-         // Go through the full stop/destroy cycle
-         try
-         {
-            stop(name);
-         }
-         catch (Throwable e)
-         {
-            log.error("Could not stop mbean: " + name, e);
-         }
-         try
-         {
-            destroy(name);
-         }
-         catch (Throwable e)
-         {
-            log.error("Could not destroy mbean: " + name, e);
-         }
-         try
-         {
-            remove(name);
-            serviceCounter++;
-         }
-         catch (Throwable e)
-         {
-            log.error("Could not remove mbean: " + name, e);
-         }
+         controller.uninstall(context.getName());
+         ++serviceCounter;
       }
       log.debug("Stopped " + serviceCounter + " services");
    }
-   
-   // MBeanRegistration implementation ----------------------------------------
 
-   /**
-    * #Description of the Method
-    *
-    * @param server Description of Parameter
-    * @param name Description of Parameter
-    * @return Description of the Returned Value
-    * @exception Exception Description of Exception
-    */
    public ObjectName preRegister(MBeanServer server, ObjectName name)
          throws Exception
    {
       this.server = server;
 
-      creator = new ServiceCreator(server);
-      configurator = new ServiceConfigurator(server, this, creator);
+      // Bootstrap the microcontainer. 
+      // REVIEW: Should be an option to pass this to a specialised constructor
+      BasicBootstrap bootstrap = new BasicBootstrap();
+      bootstrap.run();
+      kernel = bootstrap.getKernel();
 
-      // Register the ServiceController as a running service
-      ServiceContext sc = this.createServiceContext(name);
-      sc.state = ServiceContext.RUNNING;
-
       log.debug("Controller MBean online");
       return name == null ? OBJECT_NAME : name;
    }
 
    public void postRegister(Boolean registrationDone)
    {
-      if (!registrationDone.booleanValue())
+      if (registrationDone.booleanValue() == false)
+         log.fatal("Registration of ServiceController failed");
+      else
       {
-         log.info("Registration of ServiceController failed");
+         // Register the ServiceController as a running service
+         KernelController controller = kernel.getController();
+         ServiceControllerContext context = new ServiceControllerContext(this, ServiceControllerMBean.OBJECT_NAME);
+         context.setMode(ControllerMode.AUTOMATIC);
+         try
+         {
+            controller.install(context);
+         }
+         catch (Throwable t)
+         {
+            log.fatal("Error registering service controller", t);
+         }
       }
    }
 
@@ -771,247 +563,81 @@
 
    public void postDeregister()
    {
-      nameToServiceMap.clear();
-      installedServices.clear();
-      creator.shutdown();
-      creator = null;
-      configurator = null;
+      installed.clear();
       server = null;
    }
 
-   // Package Protected ---------------------------------------------
-   
-   // Create a Service Context for the service, or get one if it exists
-   synchronized ServiceContext createServiceContext(ObjectName objectName)
+   /**
+    * Sends outs controller notifications about service lifecycle events
+    * 
+    * @param type the notification type
+    * @param serviceName the service name
+    */
+   public void sendControllerNotification(String type, ObjectName serviceName)
    {
-      // If it is already there just return it
-      if (nameToServiceMap.containsKey(objectName))
-         return (ServiceContext) nameToServiceMap.get(objectName);
-
-      // If not create it, add it and return it
-      ServiceContext ctx = new ServiceContext();
-      ctx.objectName = objectName;
-
-      // we keep track of these here
-      nameToServiceMap.put(objectName, ctx);
-
-      return ctx;
+      Notification notification = new Notification(type, this, super.nextNotificationSequenceNumber());
+      notification.setUserData(serviceName);
+      sendNotification(notification);
    }
 
-   void registerDependency(ObjectName needs, ObjectName used)
+   /**
+    * Add the passed lifecycle dependencies to the context
+    * 
+    * @param context the context
+    * @param depends the dependencies
+    */
+   private void addDependencies(ServiceControllerContext context, Collection<ObjectName> depends)
    {
-      log.debug("recording that " + needs + " depends on " + used);
-      ServiceContext needsCtx = createServiceContext(needs);
-      ServiceContext usedCtx = createServiceContext(used);
-
-
-      if (!needsCtx.iDependOn.contains(usedCtx))
+      DependencyInfo info = context.getDependencyInfo();
+      for (ObjectName other : depends)
       {
-         // needsCtx depends on usedCtx
-         needsCtx.iDependOn.add(usedCtx);
-         // UsedCtx needs to know I depend on him
-         usedCtx.dependsOnMe.add(needsCtx);
+         info.addIDependOn(new LifecycleDependencyItem(context.getName(), other.getCanonicalName(), ControllerState.CREATE));
+         info.addIDependOn(new LifecycleDependencyItem(context.getName(), other.getCanonicalName(), ControllerState.START));
       }
    }
 
-   // Private -------------------------------------------------------
-   
    /**
-    * Register the service context and its dependencies against the microkernel.
-    * If the context is already registered it does nothing.
+    * Get the unresolved dependencies
     * 
-    * @param ctx the ServiceContext to register
-    * @param depends a collection of ObjectNames of services the registered service depends on
+    * @param context the context
+    * @param state the state we want to move to
+    * @return the unresolved dependencies
     */
-   private void register(ServiceContext ctx, Collection depends) throws Exception
+   private String getUnresolvedDependencies(ServiceControllerContext context, ControllerState state)
    {
-      if (!installedServices.contains(ctx))
-         installedServices.add(ctx);
+      boolean first = true;
       
-      if (depends != null)
+      StringBuilder builder = new StringBuilder();
+      for (DependencyItem item : context.getDependencyInfo().getUnresolvedDependencies())
       {
-         log.debug("adding depends in ServiceController.register: " + depends);
-         for (Iterator i = depends.iterator(); i.hasNext();)
+         if (item.isResolved() == false && item.getWhenRequired() == state)
          {
-            registerDependency(ctx.objectName, (ObjectName) i.next());
+            if (first)
+               first = false;
+            else
+               builder.append(' ');
+            builder.append(item.getIDependOn());
          }
       }
-
-      // Get the fancy service proxy (for the lifecycle API), if needed
-      if (ctx.proxy == null)
-         ctx.proxy = getServiceProxy(ctx.objectName, null);
+      return builder.toString();
    }
-   
-   /**
-    * Get the Service interface through which the mbean given by objectName
-    * will be managed.
-    *
-    * @param objectName
-    * @param serviceFactory
-    * @return The Service value
-    *
-    * @throws ClassNotFoundException
-    * @throws InstantiationException
-    * @throws IllegalAccessException
-    */
-   private Service getServiceProxy(ObjectName objectName, String serviceFactory)
-         throws ClassNotFoundException, InstantiationException,
-         IllegalAccessException, JMException
-   {
-      Service service = null;
-      ClassLoader loader = Thread.currentThread().getContextClassLoader();
-      if (serviceFactory != null && serviceFactory.length() > 0)
-      {
-         Class clazz = loader.loadClass(serviceFactory);
-         ServiceFactory factory = (ServiceFactory) clazz.newInstance();
-         service = factory.createService(server, objectName);
-      }
-      else
-      {
-         MBeanInfo info = server.getMBeanInfo(objectName);
-         MBeanOperationInfo[] opInfo = info.getOperations();
-         Class[] interfaces = {Service.class};
-         InvocationHandler handler = new ServiceProxy(objectName, opInfo);
-         service = (Service) Proxy.newProxyInstance(Service.class.getClassLoader(), interfaces, handler);
-      }
 
-      return service;
-   }
-
    /**
-    * Sends outs controller notifications about service lifecycle events 
+    * Safely remove any potentially registered context (usually after an error)
+    * 
+    * @param ctx the context
     */
-   private void sendControllerNotification(String type, ObjectName serviceName)
+   private void safelyRemoveAnyRegisteredContext(ServiceControllerContext ctx)
    {
-      Notification notification = new Notification(type, this, super.nextNotificationSequenceNumber());
-      notification.setUserData(serviceName);
-      sendNotification(notification);
-   }
-   
-   // Inner classes -------------------------------------------------
-
-   /**
-    * A mapping from the Service interface method names to the corresponding
-    * index into the ServiceProxy.hasOp array.
-    */
-   private static HashMap serviceOpMap = new HashMap();
-
-   /**
-    * An implementation of InvocationHandler used to proxy of the Service
-    * interface for mbeans. It determines which of the start/stop
-    * methods of the Service interface an mbean implements by inspecting its
-    * MBeanOperationInfo values. Each Service interface method that has a
-    * matching operation is forwarded to the mbean by invoking the method
-    * through the MBeanServer object.
-    */
-   public class ServiceProxy implements InvocationHandler
-   {
-      private boolean[] hasOp = {false, false, false, false};
-      private ObjectName objectName;
-
-      /** Whether we have the lifecycle method */
-      private boolean hasJBossInternalLifecycle;
-
-      /**
-       * Go through the opInfo array and for each operation that matches on of
-       * the Service interface methods set the corresponding hasOp array value
-       * to true.
-       *
-       * @param objectName
-       * @param opInfo
-       */
-      public ServiceProxy(ObjectName objectName, MBeanOperationInfo[] opInfo)
+      // First the context must have a controller
+      Controller controller = ctx.getController();
+      if (controller != null)
       {
-         this.objectName = objectName;
-
-         for (int op = 0; op < opInfo.length; op++)
-         {
-            MBeanOperationInfo info = opInfo[op];
-            String name = info.getName();
-
-            if (name.equals(JBOSS_INTERNAL_LIFECYCLE))
-            {
-               hasJBossInternalLifecycle = true;
-               continue;
-            }
-
-            Integer opID = (Integer) serviceOpMap.get(name);
-            if (opID == null)
-            {
-               continue;
-            }
-
-            // Validate that is a no-arg void return type method
-            if (info.getReturnType().equals("void") == false)
-            {
-               continue;
-            }
-            if (info.getSignature().length != 0)
-            {
-               continue;
-            }
-
-            hasOp[opID.intValue()] = true;
-         }
+         // The name must be registered and it must be our context
+         Object name = ctx.getName();
+         ControllerContext registered = controller.getContext(name, null);
+         if (registered == ctx)
+            controller.uninstall(name);
       }
-
-      /**
-       * Map the method name to a Service interface method index and if the
-       * corresponding hasOp array element is true, dispatch the method to the
-       * mbean we are proxying.
-       *
-       * @param proxy
-       * @param method
-       * @param args
-       * @return             Always null.
-       * @throws Throwable
-       */
-      public Object invoke(Object proxy, Method method, Object[] args)
-            throws Throwable
-      {
-         String name = method.getName();
-
-         if (hasJBossInternalLifecycle)
-         {
-            try
-            {
-               server.invoke(objectName, JBOSS_INTERNAL_LIFECYCLE, new Object[] { name }, JBOSS_INTERNAL_LIFECYCLE_SIG);
-               return null;
-            }
-            catch (Exception e)
-            {
-               throw JMXExceptionDecoder.decode(e);
-            }
-         }
-
-         Integer opID = (Integer) serviceOpMap.get(name);
-
-         if (opID != null && hasOp[opID.intValue()] == true)
-         {
-            // deal with those pesky JMX exceptions
-            try
-            {
-               String[] sig = {};
-               server.invoke(objectName, name, args, sig);
-            }
-            catch (Exception e)
-            {
-               throw JMXExceptionDecoder.decode(e);
-            }
-         }
-
-         return null;
-      }
    }
-
-   /**
-    * Initialize the service operation map.
-    */
-   static
-   {
-      serviceOpMap.put("create", new Integer(0));
-      serviceOpMap.put("start", new Integer(1));
-      serviceOpMap.put("destroy", new Integer(2));
-      serviceOpMap.put("stop", new Integer(3));
-   }
 }

Modified: trunk/system/src/main/org/jboss/system/ServiceControllerMBean.java
===================================================================
--- trunk/system/src/main/org/jboss/system/ServiceControllerMBean.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/main/org/jboss/system/ServiceControllerMBean.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -41,8 +41,6 @@
 {
    /** The default ObjectName */
    ObjectName OBJECT_NAME = ObjectNameFactory.create("jboss.system:service=ServiceController");
-
-   // Attributes ----------------------------------------------------
    
    /**
     * Plugin a ServiceBinding policy
@@ -51,14 +49,12 @@
     */
    void setServiceBinding(ServiceBinding serviceBinding);
    
-   // Operations ----------------------------------------------------
-   
    /**
     * Lists the ServiceContexts of deployed mbeans
     * 
     * @return the list of ServiceContexts for mbeans deployed through ServiceController.
     */
-   List listDeployed();
+   List<ServiceContext> listDeployed();
 
    /**
     * The <code>listIncompletelyDeployed</code> method returns the
@@ -68,7 +64,7 @@
     * 
     * @return a List<ServiceContext>
     */
-   List listIncompletelyDeployed();
+   List<ServiceContext> listIncompletelyDeployed();
 
    /**
     * lists ObjectNames of deployed mbeans deployed through
@@ -76,7 +72,7 @@
     * 
     * @return a list of ObjectNames of deployed mbeans.
     */
-   List listDeployedNames();
+   List<ObjectName> listDeployedNames();
 
    /**
     * Gets the Configuration attribute of the ServiceController object
@@ -90,6 +86,9 @@
    /**
     * Go through the mbeans of the DeploymentInfo and validate that
     * they are in a state at least equal to that of the argument state
+    * 
+    * @param di the deployment info
+    * @param state the deployment state
     */
    void validateDeploymentState(DeploymentInfo di, DeploymentState state);
 
@@ -104,18 +103,25 @@
     * @return Description of the Returned Value
     * @throws DeploymentException
     */
-   List install(Element config, ObjectName loaderName) throws DeploymentException;
+   List<ObjectName> install(Element config, ObjectName loaderName) throws DeploymentException;
 
    /**
     * Register the mbean against the microkernel with no dependencies.
+    * 
     * @see #register(ObjectName, java.util.Collection)
+    * @param serviceName the object name
+    * @throws Exception for any error
     */
    void register(ObjectName serviceName) throws Exception;
 
    /**
     * Register the mbean against the microkernel with dependencies.
+    * 
+    * @param serviceName the object name
+    * @param depends the dependencies
+    * @throws Exception for any error
     */   
-   void register(ObjectName serviceName, Collection depends) throws Exception;
+   void register(ObjectName serviceName, Collection<ObjectName> depends) throws Exception;
 
    /**
     * Create a service
@@ -129,9 +135,10 @@
     * Create a service with given dependencies
     * 
     * @param serviceName Description of Parameter
+    * @param depends the dependencies
     * @throws Exception Description of Exception
     */
-   void create(ObjectName serviceName, Collection depends) throws Exception;
+   void create(ObjectName serviceName, Collection<ObjectName> depends) throws Exception;
 
    /**
     * Starts the indicated service
@@ -180,7 +187,9 @@
 
    /**
     * Lookup the ServiceContext for the given serviceName
+    * 
+    * @param serviceName the service name
+    * @return the service context
     */
    ServiceContext getServiceContext(ObjectName serviceName);
-
 }

Modified: trunk/system/src/main/org/jboss/system/ServiceCreator.java
===================================================================
--- trunk/system/src/main/org/jboss/system/ServiceCreator.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/main/org/jboss/system/ServiceCreator.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -21,25 +21,23 @@
  */
 package org.jboss.system;
 
-import java.beans.PropertyEditor;
-import java.beans.PropertyEditorManager;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.UndeclaredThrowableException;
 import java.net.URL;
+import java.util.List;
 
 import javax.management.MBeanServer;
 import javax.management.ObjectInstance;
 import javax.management.ObjectName;
+import javax.management.StandardMBean;
 
 import org.jboss.deployment.DeploymentException;
 import org.jboss.logging.Logger;
 import org.jboss.mx.service.ServiceConstants;
 import org.jboss.mx.util.JMXExceptionDecoder;
-import org.jboss.util.Classes;
-import org.jboss.util.StringPropertyReplacer;
-import org.w3c.dom.Attr;
+import org.jboss.system.metadata.ServiceConstructorMetaData;
+import org.jboss.system.metadata.ServiceMetaData;
+import org.jboss.system.metadata.ServiceMetaDataParser;
+import org.jboss.util.UnreachableStatementException;
 import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
 
 /**
  * A helper class for the controller.
@@ -48,173 +46,74 @@
  *
  * @author <a href="mailto:marc.fleury at jboss.org">Marc Fleury</a>
  * @author <a href="mailto:d_jencks at users.sourceforge.net">David Jencks</a>
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
  * @version $Revision$
  */
 public class ServiceCreator
 {
-   // Static --------------------------------------------------------
-   
-   /** The default XMBean class, when one is not specified */
-   private static final String XMBEAN_CODE = "org.jboss.mx.modelmbean.XMBean";
-   
    /** Instance logger. */
    private static final Logger log = Logger.getLogger(ServiceCreator.class);
-
-   // Attributes ----------------------------------------------------
    
    /** The server */
    private MBeanServer server;
 
-   // Constructors --------------------------------------------------
-   
    /**
-    * CTOR
+    * Install an MBean
+    * 
+    * @todo expand the meta data to include a pre-instantiated object
+    * @param server the mbean server
+    * @param objectName the object name
+    * @param metaData the service metadata
+    * @param mbean any mbean instance
+    * @return the installed instance
+    * @throws Exception for any error
     */
-   public ServiceCreator(final MBeanServer server)
+   public static ServiceInstance install(MBeanServer server, ObjectName objectName, ServiceMetaData metaData, Object mbean) throws Exception
    {
-      this.server = server;
-   }
+      if (server == null)
+         throw new IllegalArgumentException("Null MBeanServer");
+      if (objectName == null)
+         throw new IllegalArgumentException("Null ObjectName");
+      if (metaData == null && mbean == null)
+         throw new IllegalArgumentException("Either metadata or an mbean object must be supplied");
+      
+      // Check for duplicate
+      if (server.isRegistered(objectName))
+         throw new DeploymentException("Trying to install an already registered mbean: " + objectName);
 
-   // Public --------------------------------------------------------
-   
-   /**
-    * Clean shutdown
-    */
-   public void shutdown()
-   {
-      this.server = null;
-   } 
-   
-   /**
-    * Parses the given configuration document and creates MBean
-    * instances in the current MBean server.
-    *
-    * @param configuration     The configuration document.
-    *
-    * @throws ConfigurationException   The configuration document contains
-    *                                  invalid or missing syntax.
-    * @throws Exception                Failed for some other reason.
-    */
-   public ObjectInstance install(ObjectName mbeanName, ObjectName loaderName,
-      Element mbeanElement) throws Exception
-   {
-      if (server.isRegistered(mbeanName))
-      {
-         throw new DeploymentException("Trying to install an already registered mbean: " + mbeanName);
-      }
-      // If class is given, instantiate it
-      String code = mbeanElement.getAttribute("code");
-      if ( code == null || "".equals(code))
-      {
-         throw new ConfigurationException("missing 'code' attribute");
-      }
-
-      // get the constructor params/sig to use
-      ConstructorInfo constructor = ConstructorInfo.create(mbeanElement);
-
-      // Check for xmbean specific attributes
-      String xmbeandd = null;
-      Attr xmbeanddAttr = mbeanElement.getAttributeNode("xmbean-dd");
-      if( xmbeanddAttr != null )
-         xmbeandd = xmbeanddAttr.getValue();
-      String xmbeanCode = mbeanElement.getAttribute("xmbean-code");
-      if( xmbeanCode.length() == 0 )
-         xmbeanCode = XMBEAN_CODE;
-
-      // Create the mbean instance
-      ObjectInstance instance = null;
       try
       {
-         if ( xmbeandd == null )
+         ServiceInstance result = null; 
+         
+         // No meta data just register directly
+         if (metaData == null)
          {
-            // Check for the explicit management interface in case of a standard MBean
-            Attr itfAttr = mbeanElement.getAttributeNode("interface");
-            if (itfAttr != null)
-            {
-               // Get the good class loader
-               ClassLoader classLoader = server.getClassLoader(loaderName);
-
-               // Load interface class
-               String itf = itfAttr.getValue();
-               Class itfClass = classLoader.loadClass(itf);
-               log.debug("About to create bean resource: " + mbeanName + " with code: " + code);
-               Object resource = server.instantiate(code,
-                                                    loaderName,
-                                                    constructor.params,
-                                                    constructor.signature);
-               //
-               log.debug("About to register StandardMBean : " + mbeanName);
-               instance = server.createMBean("javax.management.StandardMBean",
-                                             mbeanName,
-                                             loaderName,
-                                             new Object[]{resource,itfClass},
-                                             new String[]{Object.class.getName(),Class.class.getName()});
-            }
-            else
-            {
-               // This is a standard or dynamic mbean
-               log.debug("About to create bean: " + mbeanName + " with code: " + code);
-               instance = server.createMBean(code,
-                                             mbeanName,
-                                             loaderName,
-                                             constructor.params,
-                                             constructor.signature);
-            }
-         } // end of if ()
-         else if( xmbeandd.length() == 0 )
-         {
-            // This is an xmbean with an embedded mbean descriptor
-            log.debug("About to create xmbean object: " + mbeanName
-               + " with code: " + code + " with embedded descriptor");
-            //xmbean: construct object first.
-            Object resource = server.instantiate(code, loaderName,
-                  constructor.params, constructor.signature);
-
-            NodeList mbeans = mbeanElement.getElementsByTagName("xmbean");
-            if( mbeans.getLength() == 0 )
-               throw new ConfigurationException("No nested mbean element given for xmbean");
-            Element mbeanDescriptor = (Element) mbeans.item(0);
-            Object[] args = {resource, mbeanDescriptor,
-                             ServiceConstants.PUBLIC_JBOSSMX_XMBEAN_DTD_1_0};
-            String[] sig = {Object.class.getName(), Element.class.getName(),
-                            String.class.getName()};
-            instance = server.createMBean(xmbeanCode,
-                                          mbeanName,
-                                          loaderName,
-                                          args,
-                                          sig);
+            ObjectInstance instance = server.registerMBean(mbean, objectName);
+            result = new ServiceInstance(instance, mbean);
          }
          else
          {
-            // This is an xmbean with an external descriptor
-            log.debug("About to create xmbean object: " + mbeanName
-               + " with code: " + code + " with descriptor: "+xmbeandd);
-            //xmbean: construct object first.
-            Object resource = server.instantiate(code, loaderName,
-                  constructor.params, constructor.signature);
-            // Try to find the dd first as a resource then as a URL
-            URL xmbeanddUrl = null;
-            try
+            String xmbeanDD = metaData.getXMBeanDD();
+            
+            // Not an XMBean
+            if (xmbeanDD == null)
             {
-               xmbeanddUrl = resource.getClass().getClassLoader().getResource(xmbeandd);
+               String interfaceName = metaData.getInterfaceName();
+               if (interfaceName != null)
+                  result = installStandardMBean(server, objectName, metaData);
+               else
+                  result = installPlainMBean(server, objectName, metaData);
             }
-            catch (Exception e)
-            {
-            } // end of try-catch
-            if (xmbeanddUrl == null)
-            {
-               xmbeanddUrl = new URL(xmbeandd);
-            } // end of if ()
+            // Embedded XMBean Descriptor
+            else if (xmbeanDD.length() == 0)
+               result = installEmbeddedXMBean(server, objectName, metaData);
+            // Reference to external XMBean descriptor
+            else
+               result = installExternalXMBean(server, objectName, metaData);
+         }
 
-            //now create the mbean
-            Object[] args = {resource, xmbeanddUrl};
-            String[] sig = {Object.class.getName(), URL.class.getName()};
-            instance = server.createMBean(xmbeanCode,
-                                          mbeanName,
-                                          loaderName,
-                                          args,
-                                          sig);
-         } // end of else
+         log.debug("Created mbean: " + objectName);
+         return result;
       }
       catch (Throwable e)
       {
@@ -223,155 +122,246 @@
          // didn't work, unregister in case the jmx agent is screwed.
          try
          {
-            server.unregisterMBean(mbeanName);
+            server.unregisterMBean(objectName);
          }
          catch (Throwable ignore)
          {
          }
 
-         if (newE instanceof Exception)
-         {
-            throw (Exception)newE;
-         } // end of if ()
-         throw new UndeclaredThrowableException(newE);
+         DeploymentException.rethrowAsDeploymentException("Unable to createMBean for " + objectName, newE);
+         throw new UnreachableStatementException();
       }
-
-      log.debug("Created bean: "+mbeanName);
-      return instance;
    }
 
-   public void remove(ObjectName name) throws Exception
+   /**
+    * Install a StandardMBean
+    * 
+    * @param server the mbean server
+    * @param objectName the object name
+    * @param metadata the service metadata
+    * @return the installed instance
+    * @throws Exception for any error
+    */
+   private static ServiceInstance installStandardMBean(MBeanServer server, ObjectName objectName, ServiceMetaData metaData) throws Exception
    {
-      // add defaut domain if there isn't one in this name
-      String domain = name.getDomain();
-      if (domain == null || "".equals(domain))
-      {
-         name = new ObjectName(server.getDefaultDomain() + name);
-      }
+      ObjectName loaderName = metaData.getClassLoaderName();
+      ClassLoader loader = server.getClassLoader(loaderName);
+      String code = metaData.getCode();
+      ServiceConstructorMetaData constructor = metaData.getConstructor();
+      String interfaceName = metaData.getInterfaceName();
 
-      // Remove the MBean from the MBeanServer
-      server.unregisterMBean(name);
+      Class intf = loader.loadClass(interfaceName);
+      log.debug("About to create bean resource: " + objectName + " with code: " + code + " and interface " + interfaceName);
+      Object resource = server.instantiate(code,
+                                           loaderName,
+                                           constructor.getParameters(loader),
+                                           constructor.getSignature());
+
+      log.debug("About to register StandardMBean : " + objectName);
+      ObjectInstance instance = server.createMBean(StandardMBean.class.getName(),
+                                                   objectName,
+                                                   loaderName,
+                                                   new Object[] { resource, intf },
+                                                   new String[] { Object.class.getName() , Class.class.getName() });
+      return new ServiceInstance(instance, resource);
    }
 
-   // Inner Class  --------------------------------------------------
-   
    /**
-    * Provides a wrapper around the information about which constructor
-    * that MBeanServer should use to construct a MBean.
-    * Please note that only basic datatypes (type is then the same as
-    * you use to declare it "short", "int", "float" etc.) and any class
-    * having a constructor taking a single "String" as only parameter.
-    *
-    * <p>XML syntax for contructor:
-    *   <pre>
-    *      <constructor>
-    *         <arg type="xxx" value="yyy"/>
-    *         ...
-    *         <arg type="xxx" value="yyy"/>
-    *      </constructor>
-    *   </pre>
+    * Install a plain MBean
+    * 
+    * @param server the mbean server
+    * @param objectName the object name
+    * @param metadata the service metadata
+    * @return the installed instance
+    * @throws Exception for any error
     */
-   private static class ConstructorInfo
+   private static ServiceInstance installPlainMBean(MBeanServer server, ObjectName objectName, ServiceMetaData metaData) throws Exception
    {
-      /** An empty parameters list. */
-      public static final Object EMPTY_PARAMS[] = {};
+      ObjectName loaderName = metaData.getClassLoaderName();
+      ClassLoader loader = server.getClassLoader(loaderName);
+      String code = metaData.getCode();
+      ServiceConstructorMetaData constructor = metaData.getConstructor();
+      
+      // This is a standard or dynamic mbean
+      log.debug("About to create bean: " + objectName + " with code: " + code);
+      ObjectInstance instance = server.createMBean(code,
+                                                   objectName,
+                                                   loaderName,
+                                                   constructor.getParameters(loader),
+                                                   constructor.getSignature());
+      
+      log.debug("About to register MBean : " + objectName);
+      return new ServiceInstance(instance, null); // FIXME need to get the resource
+   }
 
-      /** An signature list. */
-      public static final String EMPTY_SIGNATURE[] = {};
+   /**
+    * Install an embedded XMBean
+    * 
+    * @param server the mbean server
+    * @param objectName the object name
+    * @param metadata the service metadata
+    * @return the installed instance
+    * @throws Exception for any error
+    */
+   private static ServiceInstance installEmbeddedXMBean(MBeanServer server, ObjectName objectName, ServiceMetaData metaData) throws Exception
+   {
+      ObjectName loaderName = metaData.getClassLoaderName();
+      ClassLoader loader = server.getClassLoader(loaderName);
+      String code = metaData.getCode();
+      ServiceConstructorMetaData constructor = metaData.getConstructor();
 
-      /** The constructor signature. */
-      public String[] signature = EMPTY_SIGNATURE;
+      // This is an xmbean with an embedded mbean descriptor
+      log.debug("About to create xmbean object: " + objectName + " with code: " + code + " with embedded descriptor");
+      //xmbean: construct object first.
+      Object resource = server.instantiate(code, 
+                                           loaderName,
+                                           constructor.getParameters(loader), 
+                                           constructor.getSignature());
 
-      /** The constructor parameters. */
-      public Object[] params = EMPTY_PARAMS;
+      String xmbeanCode = metaData.getXMBeanCode();
+      Element mbeanDescriptor = metaData.getXMBeanDescriptor();
+      Object[] args = { resource, mbeanDescriptor, ServiceConstants.PUBLIC_JBOSSMX_XMBEAN_DTD_1_0 };
+      String[] sig = { Object.class.getName(), Element.class.getName(), String.class.getName() };
+      ObjectInstance instance = server.createMBean(xmbeanCode,
+                                                   objectName,
+                                                   loaderName,
+                                                   args,
+                                                   sig);
+      return new ServiceInstance(instance, resource);
+   }
 
-      /**
-       * Create a ConstructorInfo object for the given configuration.
-       *
-       * @param element   The element to build info for.
-       * @return          A constructor information object.
-       *
-       * @throws ConfigurationException   Failed to create info object.
-       */
-      public static ConstructorInfo create(Element element)
-         throws ConfigurationException
+   /**
+    * Install an external XMBean
+    * 
+    * @param server the mbean server
+    * @param objectName the object name
+    * @param metadata the service metadata
+    * @return the installed instance
+    * @throws Exception for any error
+    */
+   private static ServiceInstance installExternalXMBean(MBeanServer server, ObjectName objectName, ServiceMetaData metaData) throws Exception
+   {
+      ObjectName loaderName = metaData.getClassLoaderName();
+      ClassLoader loader = server.getClassLoader(loaderName);
+      String code = metaData.getCode();
+      ServiceConstructorMetaData constructor = metaData.getConstructor();
+      String xmbeanDD = metaData.getXMBeanDD();
+      
+      // This is an xmbean with an external descriptor
+      log.debug("About to create xmbean object: " + objectName  + " with code: " + code + " with descriptor: " + xmbeanDD);
+      //xmbean: construct object first.
+      Object resource = server.instantiate(code, 
+                                           loaderName, 
+                                           constructor.getParameters(loader), 
+                                           constructor.getSignature());
+      // Try to find the dd first as a resource then as a URL
+      URL xmbeanddUrl = null;
+      try
       {
-         ConstructorInfo info = new ConstructorInfo();
-         NodeList list = element.getElementsByTagName("constructor");
-         if (list.getLength() > 1 && list.item(0).getParentNode() == element)
-         {
-            throw new ConfigurationException
-            ("only one <constructor> element may be defined");
-         }
-         else if (list.getLength() == 1)
-         {
-            element = (Element)list.item(0);
+         xmbeanddUrl = resource.getClass().getClassLoader().getResource(xmbeanDD);
+      }
+      catch (Exception e)
+      {
+      }
 
-            // get all of the "arg" elements
-            list = element.getElementsByTagName("arg");
-            int length = list.getLength();
-            info.params = new Object[length];
-            info.signature = new String[length];
-            ClassLoader loader = Thread.currentThread().getContextClassLoader();
+      if (xmbeanddUrl == null)
+         xmbeanddUrl = new URL(xmbeanDD);
 
-            // decode the values into params & signature
-            for (int j=0; j<length; j++)
-            {
-               Element arg = (Element)list.item(j);
-               String signature = arg.getAttribute("type");
-               String value = arg.getAttribute("value");
-               // Allow for system property reference replacement
-               value = StringPropertyReplacer.replaceProperties(arg.getAttribute("value")); 
-               Object realValue = value;
+      String xmbeanCode = metaData.getXMBeanCode();
 
-               if( signature != null )
-               {
-                  // See if it is a primitive type first
-                  Class typeClass = Classes.getPrimitiveTypeForName(signature);
-                  if (typeClass == null)
-                  {
-                     // Try to load the class
-                     try
-                     {
-                        typeClass = loader.loadClass(signature);
-                     }
-                     catch (ClassNotFoundException e)
-                     {
-                        throw new ConfigurationException
-                           ("Class not found for type: " + signature, e);
-                     }
-                  }
+      //now create the mbean
+      Object[] args = { resource, xmbeanddUrl };
+      String[] sig = { Object.class.getName(), URL.class.getName() };
+      ObjectInstance instance = server.createMBean(xmbeanCode,
+                                                   objectName,
+                                                   loaderName,
+                                                   args,
+                                                   sig);
+      return new ServiceInstance(instance, resource);
+   }
 
-                  // Convert the string to the real value
-                  PropertyEditor editor = PropertyEditorManager.findEditor(typeClass);
-                  if (editor == null)
-                  {
-                     try
-                     {
-                        // See if there is a ctor(String) for the type
-                        Class[] sig = {String.class};
-                        Constructor ctor = typeClass.getConstructor(sig);
-                        Object[] args = {value};
-                        realValue = ctor.newInstance(args);
-                     }
-                     catch (Exception e)
-                     {
-                        throw new ConfigurationException("No property editor for type: " + typeClass);
-                     }
-                  }
-                  else
-                  {
-                     editor.setAsText(value);
-                     realValue = editor.getValue();
-                  }
-               }
-               info.signature[j] = signature;
-               info.params[j] = realValue;
-            }
-         }
-
-         return info;
+   /**
+    * Uninstall an MBean
+    * 
+    * @param server the mbean server
+    * @param objectName the object name
+    */
+   public static void uninstall(MBeanServer server, ObjectName objectName)
+   {
+      if (server == null)
+         throw new IllegalArgumentException("Null MBeanServer");
+      if (objectName == null)
+         throw new IllegalArgumentException("Null ObjectName");
+      try
+      {
+         log.debug("Removing mbean from server: " + objectName);
+         server.unregisterMBean(objectName);
       }
+      catch (Throwable t)
+      {
+         log.debug("Error unregistering mbean " + objectName, t);
+      }
    }
-
+   
+   /**
+    * Create a new ServiceCreator
+    * 
+    * @deprecated This is no longer used and will be going away
+    * @param server the mbean server
+    */
+   public ServiceCreator(final MBeanServer server)
+   {
+      if (server == null)
+         throw new IllegalArgumentException("Null MBeanServer");
+      this.server = server;
+   }
+   
+   /**
+    * Clean shutdown
+    */
+   public void shutdown()
+   {
+      this.server = null;
+   } 
+   
+   /**
+    * Parses the given configuration document and creates MBean
+    * instances in the current MBean server.
+    *
+    * @deprecated This is no longer used and will be going away
+    * @param mbeanName the object name
+    * @param loaderName the classloader
+    * @param mbeanElement the config
+    * @return the created object instance
+    * @throws Exception for any error
+    */
+   public ObjectInstance install(ObjectName mbeanName, ObjectName loaderName, Element mbeanElement) throws Exception
+   {
+      if (mbeanName == null)
+         throw new IllegalArgumentException("Null mbeanName");
+      if (mbeanElement == null)
+         throw new IllegalArgumentException("Null mbean element");
+      
+      ServiceMetaDataParser parser = new ServiceMetaDataParser(mbeanElement);
+      List<ServiceMetaData> metaDatas = parser.parse();
+      if (metaDatas.isEmpty())
+         throw new DeploymentException("No mbeans found in passed configuration for " + mbeanName);
+      ServiceMetaData metaData = metaDatas.get(0);
+      metaData.setClassLoaderName(loaderName);
+      ServiceInstance instance = install(server, mbeanName, metaData, null);
+      return instance.getObjectInstance();
+   }
+   
+   /**
+    * Remove the installed object
+    * 
+    * @param name the object name
+    * @throws Exception for any error
+    */
+   public void remove(ObjectName name) throws Exception
+   {
+      if (name == null)
+         throw new IllegalArgumentException("Null name");
+      uninstall(server, name);
+   }
 }

Added: trunk/system/src/main/org/jboss/system/ServiceInstance.java
===================================================================
--- trunk/system/src/main/org/jboss/system/ServiceInstance.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/main/org/jboss/system/ServiceInstance.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,78 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.system;
+
+import javax.management.ObjectInstance;
+
+/**
+ * ServiceInstance.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ServiceInstance
+{
+   /** The object instance */
+   private ObjectInstance objectInstance;
+   
+   /** The object */
+   private Object resource;
+
+   /**
+    * Create a new ServiceInstance.
+    */
+   public ServiceInstance()
+   {
+   }
+
+   /**
+    * Create a new ServiceInstance.
+    * 
+    * @param objectInstance the object instance
+    * @param resource the object
+    */
+   public ServiceInstance(ObjectInstance objectInstance, Object resource)
+   {
+      this.objectInstance = objectInstance;
+      this.resource = resource;
+   }
+
+   /**
+    * Get the resource.
+    * 
+    * @return the resource.
+    */
+   public Object getResource()
+   {
+      return resource;
+   }
+
+   /**
+    * Get the objectInstance.
+    * 
+    * @return the objectInstance.
+    */
+   public ObjectInstance getObjectInstance()
+   {
+      return objectInstance;
+   }
+}

Modified: trunk/system/src/main/org/jboss/system/ServiceMBeanSupport.java
===================================================================
--- trunk/system/src/main/org/jboss/system/ServiceMBeanSupport.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/main/org/jboss/system/ServiceMBeanSupport.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -417,17 +417,6 @@
    
    public void postDeregister()
    {
-      //clean up
-      try
-      {
-         if (serviceName != null && isJBossInternalLifecycleExposed)
-            server.invoke(ServiceController.OBJECT_NAME, "remove", new Object[] { serviceName }, SERVICE_CONTROLLER_SIG);
-      }
-      catch (Throwable t)
-      {
-         log.warn("Unexpected error during removal. " + serviceName, t);
-      }
-
       server = null;
       serviceName = null;
       state = UNREGISTERED;

Added: trunk/system/src/main/org/jboss/system/metadata/ServiceAttributeMetaData.java
===================================================================
--- trunk/system/src/main/org/jboss/system/metadata/ServiceAttributeMetaData.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/main/org/jboss/system/metadata/ServiceAttributeMetaData.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,155 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.system.metadata;
+
+import javax.management.MBeanAttributeInfo;
+import javax.management.MBeanServer;
+
+import org.jboss.deployment.DeploymentException;
+import org.jboss.util.UnreachableStatementException;
+
+/**
+ * ServiceAttributeMetaData.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ServiceAttributeMetaData
+{
+   /** The attribute name */
+   private String name;
+   
+   /** Whether to trim the value */
+   private boolean trim;
+   
+   /** Whether to do property replacement */
+   private boolean replace;
+   
+   /** The value */
+   private ServiceValueMetaData value;
+
+   /**
+    * Get the name.
+    * 
+    * @return the name.
+    */
+   public String getName()
+   {
+      return name;
+   }
+
+   /**
+    * Set the name.
+    * 
+    * @param name the name.
+    */
+   public void setName(String name)
+   {
+      if (name == null)
+         throw new IllegalArgumentException("Null name");
+      this.name = name;
+   }
+
+   /**
+    * Get the replace.
+    * 
+    * @return the replace.
+    */
+   public boolean isReplace()
+   {
+      return replace;
+   }
+
+   /**
+    * Set the replace.
+    * 
+    * @param replace the replace.
+    */
+   public void setReplace(boolean replace)
+   {
+      this.replace = replace;
+   }
+
+   /**
+    * Get the trim.
+    * 
+    * @return the trim.
+    */
+   public boolean isTrim()
+   {
+      return trim;
+   }
+
+   /**
+    * Set the trim.
+    * 
+    * @param trim the trim.
+    */
+   public void setTrim(boolean trim)
+   {
+      this.trim = trim;
+   }
+
+   /**
+    * Get the value.
+    * 
+    * @return the value.
+    */
+   public ServiceValueMetaData getValue()
+   {
+      return value;
+   }
+
+   /**
+    * Set the value.
+    * 
+    * @param value the value.
+    */
+   public void setValue(ServiceValueMetaData value)
+   {
+      if (value == null)
+         throw new IllegalArgumentException("Null value");
+      this.value = value;
+   }
+   
+   /**
+    * Get the value
+    * 
+    * @param server the mbean server
+    * @param attributeInfo the attribute info
+    * @param cl the classloader
+    * @return the value
+    * @throws Exception for any error
+    */
+   public Object getValue(MBeanServer server, MBeanAttributeInfo attributeInfo, ClassLoader cl) throws Exception
+   {
+      try
+      {
+         return value.getValue(server, attributeInfo, cl, isTrim(), isReplace());
+      }
+      catch (Throwable t)
+      {
+         DeploymentException.rethrowAsDeploymentException("Error configuring attribute " + name, t);
+         throw new UnreachableStatementException();
+      }
+   }
+}

Added: trunk/system/src/main/org/jboss/system/metadata/ServiceConstructorMetaData.java
===================================================================
--- trunk/system/src/main/org/jboss/system/metadata/ServiceConstructorMetaData.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/main/org/jboss/system/metadata/ServiceConstructorMetaData.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,155 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.system.metadata;
+
+import java.beans.PropertyEditor;
+import java.beans.PropertyEditorManager;
+import java.lang.reflect.Constructor;
+
+import org.jboss.system.ConfigurationException;
+import org.jboss.util.Classes;
+import org.jboss.util.StringPropertyReplacer;
+
+/**
+ * ServiceConstructorMetaData.
+ * 
+ * This class is based on the old ConstructorInfo from ServiceCreator
+ * 
+ * @author <a href="mailto:marc.fleury at jboss.org">Marc Fleury</a>
+ * @author <a href="mailto:d_jencks at users.sourceforge.net">David Jencks</a>
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ServiceConstructorMetaData
+{
+   /** An empty parameters */
+   public static final Object[] EMPTY_PARAMETERS = {};
+
+   /** An empty parameters list. */
+   public static final String[] EMPTY_PARAMS = {};
+
+   /** An signature list. */
+   public static final String[] EMPTY_SIGNATURE = {};
+
+   /** The constructor signature. */
+   private String[] signature = EMPTY_SIGNATURE;
+
+   /** The constructor parameters. */
+   private String[] params = EMPTY_PARAMS;
+
+   /**
+    * Get the params.
+    * 
+    * @return the params.
+    */
+   public String[] getParams()
+   {
+      return params;
+   }
+
+   /**
+    * Set the params.
+    * 
+    * @param params the params.
+    */
+   public void setParams(String[] params)
+   {
+      if (params == null)
+         throw new IllegalArgumentException("Null params");
+      this.params = params;
+   }
+
+   /**
+    * Get the signature.
+    * 
+    * @return the signature.
+    */
+   public String[] getSignature()
+   {
+      return signature;
+   }
+
+   /**
+    * Set the signature.
+    * 
+    * @param signature the signature.
+    */
+   public void setSignature(String[] signature)
+   {
+      if (signature == null)
+         throw new IllegalArgumentException("Null signature");
+      this.signature = signature;
+   }
+   
+   /**
+    * Get the parameters
+    * 
+    * @param cl the class loader
+    * @return the parameters
+    * @throws Exception for any error
+    */
+   public Object[] getParameters(ClassLoader cl) throws Exception
+   {
+      if (params.length == 0)
+         return EMPTY_PARAMETERS;
+      
+      Object[] result = new Object[params.length];
+      for (int i = 0; i < result.length; ++i)
+      {
+         String value = StringPropertyReplacer.replaceProperties(params[i]); 
+         Object realValue = value;
+
+         if (signature[i] != null)
+         {
+            // See if it is a primitive type first
+            Class typeClass = Classes.getPrimitiveTypeForName(signature[i]);
+            if (typeClass == null)
+               typeClass = cl.loadClass(signature[i]);
+
+            // Convert the string to the real value
+            PropertyEditor editor = PropertyEditorManager.findEditor(typeClass);
+            if (editor == null)
+            {
+               try
+               {
+                  // See if there is a ctor(String) for the type
+                  Class[] sig = {String.class};
+                  Constructor ctor = typeClass.getConstructor(sig);
+                  Object[] args = {value};
+                  realValue = ctor.newInstance(args);
+               }
+               catch (Exception e)
+               {
+                  throw new ConfigurationException("No property editor for type: " + typeClass);
+               }
+            }
+            else
+            {
+               editor.setAsText(value);
+               realValue = editor.getValue();
+            }
+         }
+         result[i] = realValue;
+      }
+      return result;
+   }
+}

Added: trunk/system/src/main/org/jboss/system/metadata/ServiceDependencyListValueMetaData.java
===================================================================
--- trunk/system/src/main/org/jboss/system/metadata/ServiceDependencyListValueMetaData.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/main/org/jboss/system/metadata/ServiceDependencyListValueMetaData.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,84 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.system.metadata;
+
+import java.util.List;
+
+import javax.management.MBeanAttributeInfo;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+/**
+ * ServiceDependencyListValueMetaData.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ServiceDependencyListValueMetaData implements ServiceValueMetaData
+{
+   /** The object names */
+   private List<ObjectName> objectNames;
+   
+   /**
+    * Create a new ServiceDependencyListValueMetaData.
+    */
+   public ServiceDependencyListValueMetaData()
+   {
+   }
+   
+   /**
+    * Create a new ServiceDependencyListValueMetaData.
+    * 
+    * @param objectNames the object names
+    */
+   public ServiceDependencyListValueMetaData(List<ObjectName> objectNames)
+   {
+      setObjectNames(objectNames);
+   }
+
+   /**
+    * Get the objectNames.
+    * 
+    * @return the objectNames.
+    */
+   public List<ObjectName> getObjectNames()
+   {
+      return objectNames;
+   }
+
+   /**
+    * Set the objectNames.
+    * 
+    * @param objectNames the objectNames.
+    */
+   public void setObjectNames(List<ObjectName> objectNames)
+   {
+      if (objectNames == null)
+         throw new IllegalArgumentException("Null objectNames");
+      this.objectNames = objectNames;
+   }
+
+   public Object getValue(MBeanServer server, MBeanAttributeInfo attributeInfo, ClassLoader cl, boolean trim, boolean replace) throws Exception
+   {
+      return objectNames;
+   }
+}

Added: trunk/system/src/main/org/jboss/system/metadata/ServiceDependencyMetaData.java
===================================================================
--- trunk/system/src/main/org/jboss/system/metadata/ServiceDependencyMetaData.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/main/org/jboss/system/metadata/ServiceDependencyMetaData.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,58 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.system.metadata;
+
+import javax.management.ObjectName;
+
+/**
+ * ServiceDependencyMetaData.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ServiceDependencyMetaData
+{
+   /** The dependency */
+   private ObjectName iDependOn;
+
+   /**
+    * Get the iDependOn.
+    * 
+    * @return the iDependOn.
+    */
+   public ObjectName getIDependOn()
+   {
+      return iDependOn;
+   }
+
+   /**
+    * Set the iDependOn.
+    * 
+    * @param dependOn the iDependOn.
+    */
+   public void setIDependOn(ObjectName iDependOn)
+   {
+      if (iDependOn == null)
+         throw new IllegalArgumentException("Null iDependOn");
+      this.iDependOn = iDependOn;
+   } 
+}

Added: trunk/system/src/main/org/jboss/system/metadata/ServiceDependencyValueMetaData.java
===================================================================
--- trunk/system/src/main/org/jboss/system/metadata/ServiceDependencyValueMetaData.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/main/org/jboss/system/metadata/ServiceDependencyValueMetaData.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,135 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.system.metadata;
+
+import javax.management.MBeanAttributeInfo;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.jboss.mx.util.MBeanProxyExt;
+
+/**
+ * ServiceDependencyValueMetaData.
+ * 
+ * This class is based on the old ServiceConfigurator
+ *
+ * @author <a href="mailto:marc at jboss.org">Marc Fleury</a>
+ * @author <a href="mailto:hiram at jboss.org">Hiram Chirino</a>
+ * @author <a href="mailto:d_jencks at users.sourceforge.net">David Jencks</a>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ServiceDependencyValueMetaData implements ServiceValueMetaData
+{
+   /** The object name */
+   private ObjectName objectName;
+
+   /** The proxy type */
+   private String proxyType;
+   
+   /**
+    * Create a new ServiceDependencyValueMetaData.
+    */
+   public ServiceDependencyValueMetaData()
+   {
+   }
+   
+   /**
+    * Create a new ServiceDependencyValueMetaData.
+    * 
+    * @param objectName the object name
+    */
+   public ServiceDependencyValueMetaData(ObjectName objectName)
+   {
+      setObjectName(objectName);
+   }
+   
+   /**
+    * Create a new ServiceDependencyValueMetaData.
+    * 
+    * @param objectName the object name
+    * @param proxyType the proxy type
+    */
+   public ServiceDependencyValueMetaData(ObjectName objectName, String proxyType)
+   {
+      setObjectName(objectName);
+      setProxyType(proxyType);
+   }
+
+   /**
+    * Get the objectName.
+    * 
+    * @return the objectName.
+    */
+   public ObjectName getObjectName()
+   {
+      return objectName;
+   }
+
+   /**
+    * Set the objectName.
+    * 
+    * @param objectName the objectName.
+    */
+   public void setObjectName(ObjectName objectName)
+   {
+      if (objectName == null)
+         throw new IllegalArgumentException("Null objectName");
+      this.objectName = objectName;
+   }
+
+   /**
+    * Get the proxyType.
+    * 
+    * @return the proxyType.
+    */
+   public String getProxyType()
+   {
+      return proxyType;
+   }
+
+   /**
+    * Set the proxyType.
+    * 
+    * @param proxyType the proxyType.
+    */
+   public void setProxyType(String proxyType)
+   {
+      this.proxyType = proxyType;
+   }
+
+   public Object getValue(MBeanServer server, MBeanAttributeInfo attributeInfo, ClassLoader cl, boolean trim, boolean replace) throws Exception
+   {
+      if (proxyType != null)
+      {
+         if (proxyType.equals("attribute"))
+            proxyType = attributeInfo.getType();
+
+         Class proxyClass = cl.loadClass(proxyType);
+         return MBeanProxyExt.create(proxyClass, objectName, server, true);
+      }
+      
+      return objectName;
+   }
+}

Added: trunk/system/src/main/org/jboss/system/metadata/ServiceElementValueMetaData.java
===================================================================
--- trunk/system/src/main/org/jboss/system/metadata/ServiceElementValueMetaData.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/main/org/jboss/system/metadata/ServiceElementValueMetaData.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,114 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.system.metadata;
+
+import java.beans.PropertyEditor;
+import java.beans.PropertyEditorManager;
+
+import javax.management.MBeanAttributeInfo;
+import javax.management.MBeanServer;
+
+import org.jboss.logging.Logger;
+import org.jboss.util.StringPropertyReplacer;
+import org.w3c.dom.Element;
+
+/**
+ * ServiceElementValueMetaData.
+ * 
+ * This class is based on the old ServiceConfigurator
+ *
+ * @author <a href="mailto:marc at jboss.org">Marc Fleury</a>
+ * @author <a href="mailto:hiram at jboss.org">Hiram Chirino</a>
+ * @author <a href="mailto:d_jencks at users.sourceforge.net">David Jencks</a>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ServiceElementValueMetaData implements ServiceValueMetaData
+{
+   /** The log */
+   private static final Logger log = Logger.getLogger(ServiceElementValueMetaData.class); 
+   
+   /** The element */
+   private Element element;
+
+   /**
+    * Create a new ServiceElementValueMetaData.
+    */
+   public ServiceElementValueMetaData()
+   {
+   }
+   
+   /**
+    * Create a new ServiceElementValueMetaData.
+    * 
+    * @param element the element
+    */
+   public ServiceElementValueMetaData(Element element)
+   {
+      setElement(element);
+   }
+
+   /**
+    * Get the element.
+    * 
+    * @return the element.
+    */
+   public Element getElement()
+   {
+      return element;
+   }
+
+   /**
+    * Set the element.
+    * 
+    * @param element the element.
+    */
+   public void setElement(Element element)
+   {
+      if (element == null)
+         throw new IllegalArgumentException("Null element");
+      this.element = element;
+   }
+
+   public Object getValue(MBeanServer server, MBeanAttributeInfo attributeInfo, ClassLoader cl, boolean trim, boolean replace) throws Exception
+   {         
+      // Replace any ${x} references in the element text
+      if (replace)
+      {
+         PropertyEditor editor = PropertyEditorManager.findEditor(Element.class);
+         if (editor == null)
+            log.warn("Cannot perform property replace on Element");
+         else
+         {
+            editor.setValue(element);
+            String text = editor.getAsText();
+            text = StringPropertyReplacer.replaceProperties(text);
+            editor.setAsText(text);
+            return editor.getValue();
+         }
+      }
+
+      return element;
+   }
+}

Added: trunk/system/src/main/org/jboss/system/metadata/ServiceJBXBValueMetaData.java
===================================================================
--- trunk/system/src/main/org/jboss/system/metadata/ServiceJBXBValueMetaData.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/main/org/jboss/system/metadata/ServiceJBXBValueMetaData.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,125 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.system.metadata;
+
+import java.io.IOException;
+import java.io.StringReader;
+import java.io.StringWriter;
+
+import javax.management.MBeanAttributeInfo;
+import javax.management.MBeanServer;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultSchemaResolver;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * ServiceJBXBValueMetaData.
+ * 
+ * This class is based on the old ServiceConfigurator
+ *
+ * @author <a href="mailto:marc at jboss.org">Marc Fleury</a>
+ * @author <a href="mailto:hiram at jboss.org">Hiram Chirino</a>
+ * @author <a href="mailto:d_jencks at users.sourceforge.net">David Jencks</a>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ServiceJBXBValueMetaData extends ServiceElementValueMetaData
+{
+   /**
+    * Create a new ServiceJBXBValueMetaData.
+    */
+   public ServiceJBXBValueMetaData()
+   {
+      super();
+   }
+
+   /**
+    * Create a new ServiceJBXBValueMetaData.
+    * 
+    * @param element the element
+    */
+   public ServiceJBXBValueMetaData(Element element)
+   {
+      super(element);
+   }
+
+   public Object getValue(MBeanServer server, MBeanAttributeInfo attributeInfo, ClassLoader cl, boolean trim, boolean replace) throws Exception
+   {
+      // Get the attribute element content in a parsable form
+      StringBuffer buffer = getElementContent(getElement());
+
+      // Parse the attribute element content
+      DefaultSchemaResolver resolver = new DefaultSchemaResolver();
+      Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+      StringReader reader = new StringReader(buffer.toString());
+      Object bean = unmarshaller.unmarshal(reader, resolver);
+      return bean;
+   }
+
+   /**
+    * A utility method that transforms the contents of the argument element into
+    * a StringBuffer representation that can be reparsed.
+    * 
+    * [FIXME] This is not a general DOMUtils method because of its funny contract. It does not 
+    * support multiple child elements neither can it deal with text content.
+    * 
+    * @param element - the parent dom element whose contents are to be extracted as an xml document string. 
+    * @return the xml document string.
+    */
+   private static StringBuffer getElementContent(Element element) throws IOException, TransformerException
+   {
+      NodeList children = element.getChildNodes();
+      Element content = null;
+      for (int n = 0; n < children.getLength(); n++)
+      {
+         Node node = children.item(n);
+         if (node.getNodeType() == Node.ELEMENT_NODE)
+         {
+            content = (Element)node;
+            break;
+         }
+      }
+      if (content == null)
+         return null;
+
+      // Get a parsable representation of this elements content
+      DOMSource source = new DOMSource(content);
+      TransformerFactory tFactory = TransformerFactory.newInstance();
+      Transformer transformer = tFactory.newTransformer();
+      StringWriter sw = new StringWriter();
+      StreamResult result = new StreamResult(sw);
+      transformer.transform(source, result);
+      sw.close();
+      return sw.getBuffer();
+   }
+}

Added: trunk/system/src/main/org/jboss/system/metadata/ServiceJavaBeanValueMetaData.java
===================================================================
--- trunk/system/src/main/org/jboss/system/metadata/ServiceJavaBeanValueMetaData.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/main/org/jboss/system/metadata/ServiceJavaBeanValueMetaData.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,98 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.system.metadata;
+
+import java.util.Properties;
+
+import javax.management.MBeanAttributeInfo;
+import javax.management.MBeanServer;
+
+import org.jboss.util.propertyeditor.PropertyEditors;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * ServiceJavaBeanValueMetaData.
+ * 
+ * This class is based on the old ServiceConfigurator
+ *
+ * @author <a href="mailto:marc at jboss.org">Marc Fleury</a>
+ * @author <a href="mailto:hiram at jboss.org">Hiram Chirino</a>
+ * @author <a href="mailto:d_jencks at users.sourceforge.net">David Jencks</a>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ServiceJavaBeanValueMetaData extends ServiceElementValueMetaData
+{
+   /**
+    * Create a new ServiceJavaBeanValueMetaData.
+    */
+   public ServiceJavaBeanValueMetaData()
+   {
+      super();
+   }
+
+   /**
+    * Create a new ServiceJavaBeanValueMetaData.
+    * 
+    * @param element the element
+    */
+   public ServiceJavaBeanValueMetaData(Element element)
+   {
+      super(element);
+   }
+
+   public Object getValue(MBeanServer server, MBeanAttributeInfo attributeInfo, ClassLoader cl, boolean trim, boolean replace) throws Exception
+   {
+      // Extract the property elements
+      Element element = getElement();
+      String attributeClassName = element.getAttribute("attributeClass");
+      if( attributeClassName == null || attributeClassName.length() == 0 )
+         attributeClassName = attributeInfo.getType();
+      Class attributeClass = cl.loadClass(attributeClassName);
+      // Create the bean instance
+      Object bean = attributeClass.newInstance();
+      // Get the JavaBean properties
+      NodeList properties = element.getElementsByTagName("property");
+      Properties beanProps = new Properties();
+      for(int n = 0; n < properties.getLength(); n ++)
+      {
+         // Skip over non-element nodes
+         Node node = properties.item(n);
+         if (node.getNodeType() != Node.ELEMENT_NODE)
+         {
+            continue;
+         }
+         Element property = (Element) node;
+         String name = property.getAttribute("name");
+         String value = ServiceMetaDataParser.getElementTextContent(property, trim, replace);
+         beanProps.setProperty(name, value);
+      }
+
+      // Apply the properties to the bean
+      PropertyEditors.mapJavaBeanProperties(bean, beanProps);
+      return bean;
+   }
+}

Added: trunk/system/src/main/org/jboss/system/metadata/ServiceMetaData.java
===================================================================
--- trunk/system/src/main/org/jboss/system/metadata/ServiceMetaData.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/main/org/jboss/system/metadata/ServiceMetaData.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,281 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.system.metadata;
+
+import java.util.Collections;
+import java.util.List;
+
+import javax.management.ObjectName;
+
+import org.w3c.dom.Element;
+
+/**
+ * ServiceMetaData.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ServiceMetaData
+{
+   /** The default XMBean class, when one is not specified */
+   public static final String XMBEAN_CODE = "org.jboss.mx.modelmbean.XMBean";
+   
+   /** The ObjectName */
+   private ObjectName objectName;
+   
+   /** The code */
+   private String code;
+   
+   /** The interface name */
+   private String interfaceName;
+   
+   /** The constructor */
+   private ServiceConstructorMetaData constructor;
+   
+   /** The XMBean dds */
+   private String xmbeanDD;
+   
+   /** The XMBean code */
+   private String xmbeanCode = XMBEAN_CODE;
+   
+   /** The XMBean descriptor */
+   private Element xmbeanDescriptor;
+   
+   /** The attributes */
+   private List<ServiceAttributeMetaData> attributes = Collections.emptyList();
+   
+   /** The dependencies */
+   private List<ServiceDependencyMetaData> dependencies = Collections.emptyList();
+
+   /** The class loader */
+   private ObjectName classLoaderName;
+   
+   /**
+    * Get the objectName.
+    * 
+    * @return the objectName.
+    */
+   public ObjectName getObjectName()
+   {
+      return objectName;
+   }
+
+   /**
+    * Set the objectName.
+    * 
+    * @param objectName the objectName.
+    */
+   public void setObjectName(ObjectName objectName)
+   {
+      if (objectName == null)
+         throw new IllegalArgumentException("Null objectName");
+      this.objectName = objectName;
+   }
+
+   /**
+    * Get the code.
+    * 
+    * @return the code.
+    */
+   public String getCode()
+   {
+      return code;
+   }
+
+   /**
+    * Set the code.
+    * 
+    * @param code the code.
+    */
+   public void setCode(String code)
+   {
+      if (code == null)
+         throw new IllegalArgumentException("Null code");
+      this.code = code;
+   }
+
+   /**
+    * Get the constructor.
+    * 
+    * @return the constructor.
+    */
+   public ServiceConstructorMetaData getConstructor()
+   {
+      return constructor;
+   }
+
+   /**
+    * Set the constructor.
+    * 
+    * @param constructor the constructor.
+    */
+   public void setConstructor(ServiceConstructorMetaData constructor)
+   {
+      this.constructor = constructor;
+   }
+
+   /**
+    * Get the interfaceName.
+    * 
+    * @return the interfaceName.
+    */
+   public String getInterfaceName()
+   {
+      return interfaceName;
+   }
+
+   /**
+    * Set the interfaceName.
+    * 
+    * @param interfaceName the interfaceName.
+    */
+   public void setInterfaceName(String interfaceName)
+   {
+      this.interfaceName = interfaceName;
+   }
+
+   /**
+    * Get the xmbeanCode.
+    * 
+    * @return the xmbeanCode.
+    */
+   public String getXMBeanCode()
+   {
+      return xmbeanCode;
+   }
+
+   /**
+    * Set the xmbeanCode.
+    * 
+    * @param xmbeanCode the xmbeanCode.
+    */
+   public void setXMBeanCode(String xmbeanCode)
+   {
+      if (xmbeanCode == null)
+         throw new IllegalArgumentException("Null xmbeanCode");
+      this.xmbeanCode = xmbeanCode;
+   }
+
+   /**
+    * Get the xmbeanDD.
+    * 
+    * @return the xmbeanDD.
+    */
+   public String getXMBeanDD()
+   {
+      return xmbeanDD;
+   }
+
+   /**
+    * Set the xmbeanDD.
+    * 
+    * @param xmbeanDD the xmbeanDD.
+    */
+   public void setXMBeanDD(String xmbeanDD)
+   {
+      this.xmbeanDD = xmbeanDD;
+   }
+
+   /**
+    * Get the xmbeanDescriptor.
+    * 
+    * @return the xmbeanDescriptor.
+    */
+   public Element getXMBeanDescriptor()
+   {
+      return xmbeanDescriptor;
+   }
+
+   /**
+    * Set the xmbeanDescriptor.
+    * 
+    * @param xmbeanDescriptor the xmbeanDescriptor.
+    */
+   public void setXMBeanDescriptor(Element xmbeanDescriptor)
+   {
+      this.xmbeanDescriptor = xmbeanDescriptor;
+   }
+
+   /**
+    * Get the attributes.
+    * 
+    * @return the attributes.
+    */
+   public List<ServiceAttributeMetaData> getAttributes()
+   {
+      return attributes;
+   }
+
+   /**
+    * Set the attributes.
+    * 
+    * @param attributes the attributes.
+    */
+   public void setAttributes(List<ServiceAttributeMetaData> attributes)
+   {
+      if (attributes == null)
+         throw new IllegalArgumentException("Null attributes");
+      this.attributes = attributes;
+   }
+
+   /**
+    * Get the dependencies.
+    * 
+    * @return the dependencies.
+    */
+   public List<ServiceDependencyMetaData> getDependencies()
+   {
+      return dependencies;
+   }
+
+   /**
+    * Set the dependencies.
+    * 
+    * @param dependencies the dependencies.
+    */
+   public void setDependencies(List<ServiceDependencyMetaData> dependencies)
+   {
+      if (dependencies == null)
+         throw new IllegalArgumentException("Null dependencies");
+      this.dependencies = dependencies;
+   }
+
+   /**
+    * Get the classLoaderName.
+    * 
+    * @return the classLoaderName.
+    */
+   public ObjectName getClassLoaderName()
+   {
+      return classLoaderName;
+   }
+
+   /**
+    * Set the classLoaderName.
+    * 
+    * @param classLoaderName the classLoaderName.
+    */
+   public void setClassLoaderName(ObjectName classLoaderName)
+   {
+      this.classLoaderName = classLoaderName;
+   }
+}

Added: trunk/system/src/main/org/jboss/system/metadata/ServiceMetaDataParser.java
===================================================================
--- trunk/system/src/main/org/jboss/system/metadata/ServiceMetaDataParser.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/main/org/jboss/system/metadata/ServiceMetaDataParser.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,531 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.system.metadata;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.management.ObjectName;
+
+import org.jboss.deployment.DeploymentException;
+import org.jboss.system.ConfigurationException;
+import org.jboss.util.StringPropertyReplacer;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+
+/**
+ * ServiceMetaDataParser
+ *
+ * This class is based on the old ServiceConfigurator/Creator.
+ *
+ * @author <a href="mailto:marc at jboss.org">Marc Fleury</a>
+ * @author <a href="mailto:hiram at jboss.org">Hiram Chirino</a>
+ * @author <a href="mailto:d_jencks at users.sourceforge.net">David Jencks</a>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ServiceMetaDataParser
+{
+   /** The element config */
+   private Element config;
+   
+   /**
+    * Create a new service meta data parser
+    * 
+    * @param config the xml config
+    */
+   public ServiceMetaDataParser(Element config)
+   {
+      if (config == null)
+         throw new IllegalArgumentException("Null config");
+      
+      this.config = config;
+   }
+
+   /**
+    * Parse the xml 
+    * 
+    * @return the list of service meta data
+    * @throws DeploymentException for any error
+    */
+   public List<ServiceMetaData> parse() throws DeploymentException
+   {
+      List<ServiceMetaData> services = new ArrayList<ServiceMetaData>();
+
+      try
+      {
+         if ("mbean".equals(config.getTagName()))
+            internalParse(services, config, true);
+         else
+         {
+            NodeList nl = config.getChildNodes();
+
+            for (int i = 0; i < nl.getLength(); ++i)
+            {
+               if (nl.item(i).getNodeType() == Node.ELEMENT_NODE)
+               {
+                  Element element = (Element) nl.item(i);
+                  if ("mbean".equals(element.getTagName()))
+                  {
+                     Element mbean = (Element) nl.item(i);
+                     internalParse(services, mbean, true);
+                  }
+               }
+            }
+         }
+      }
+      catch (Throwable t)
+      {
+         DeploymentException.rethrowAsDeploymentException("Unable to parse service configuration", t);
+      }
+      
+      return services;
+   }
+
+   /**
+    * Internal parse
+    * 
+    * @param services the list of service meta data
+    * @param mbeanElement the mbean configuration
+    * @param replace whether to replace system properties
+    * @return the ObjectName of the parsed mbean
+    * @throws Exception for any error
+    */
+   private ObjectName internalParse(List<ServiceMetaData> services, Element mbeanElement, boolean replace) throws Exception
+   {
+      ServiceMetaData service = new ServiceMetaData();
+
+      ObjectName mbeanName = parseObjectName(mbeanElement, replace);
+      service.setObjectName(mbeanName);
+      
+      String code = parseCode(mbeanName, mbeanElement);
+      service.setCode(code);
+
+      ServiceConstructorMetaData constructor = parseConstructor(mbeanName, mbeanElement, replace);
+      service.setConstructor(constructor);
+      
+      String interfaceName = parseInterface(mbeanName, mbeanElement);
+      service.setInterfaceName(interfaceName);
+      
+      String xmbeandd = parseXMBeanDD(mbeanName, mbeanElement);
+      service.setXMBeanDD(xmbeandd);
+
+      String xmbeanCode = parseXMBeanCode(mbeanName, mbeanElement);
+      service.setXMBeanCode(xmbeanCode);
+      
+      if (xmbeandd != null && xmbeandd.length() == 0)
+      {
+         Element xmbeanDescriptor = parseXMBeanDescriptor(mbeanName, mbeanElement);
+         service.setXMBeanDescriptor(xmbeanDescriptor);
+      }
+      
+      List<ServiceAttributeMetaData> attributes = new ArrayList<ServiceAttributeMetaData>();
+      List<ServiceDependencyMetaData> dependencies = new ArrayList<ServiceDependencyMetaData>();
+
+      NodeList attrs = mbeanElement.getChildNodes();
+      for (int j = 0; j < attrs.getLength(); j++)
+      {
+         // skip over non-element nodes
+         if (attrs.item(j).getNodeType() != Node.ELEMENT_NODE)
+            continue;
+
+         Element element = (Element) attrs.item(j);
+
+         boolean replaceAttribute = true;
+
+         // Set attributes
+         if (element.getTagName().equals("attribute"))
+         {
+            String attributeName = element.getAttribute("name");
+            if (attributeName == null)
+               throw new DeploymentException("Null attribute name for " + mbeanName);
+            boolean trim = true;
+            String replaceAttr = element.getAttribute("replace");
+            if (replaceAttr.length() > 0)
+               replaceAttribute = Boolean.valueOf(replaceAttr).booleanValue();
+            String trimAttr = element.getAttribute("trim");
+            if (trimAttr.length() > 0)
+               trim = Boolean.valueOf(trimAttr).booleanValue();
+            String serialDataType = element.getAttribute("serialDataType");
+
+            if (element.hasChildNodes())
+            {
+               // Unmarshall the attribute value based on the serialDataType
+               ServiceValueMetaData value = null;
+               if (serialDataType.equals("javaBean"))
+               {
+                  value = new ServiceJavaBeanValueMetaData(element);
+               }
+               else if (serialDataType.equals("jbxb"))
+               {
+                  value = new ServiceJBXBValueMetaData(element);
+               }
+               else
+               {
+                  NodeList nl = element.getChildNodes();
+                  for (int i = 0; i < nl.getLength(); i++)
+                  {
+                     Node n = nl.item(i);
+                     if (n.getNodeType() == Node.ELEMENT_NODE)
+                     {
+                        value = new ServiceElementValueMetaData((Element) n);
+                        break;
+                     }
+                  }
+                  if (value == null)
+                     value = new ServiceTextValueMetaData(getElementTextContent(element, trim, replace));
+               }
+               
+               ServiceAttributeMetaData attribute = new ServiceAttributeMetaData();
+               attribute.setName(attributeName);
+               attribute.setReplace(replaceAttribute);
+               attribute.setTrim(trim);
+               attribute.setValue(value);
+               attributes.add(attribute);
+            }
+         }
+         else if (element.getTagName().equals("depends"))
+         {
+            if (element.hasChildNodes() == false)
+               throw new DeploymentException("No ObjectName supplied for depends in " + mbeanName);
+
+            String mbeanRefName = element.getAttribute("optional-attribute-name");
+            if ("".equals(mbeanRefName))
+               mbeanRefName = null;
+            else
+               mbeanRefName = StringPropertyReplacer.replaceProperties(mbeanRefName);
+
+            String proxyType = element.getAttribute("proxy-type");
+            if ("".equals(proxyType))
+               proxyType = null;
+            else
+               proxyType = StringPropertyReplacer.replaceProperties(proxyType);
+
+            // Get the mbeanRef value
+            ObjectName dependsObjectName = processDependency(mbeanName, element, services, replace);
+
+            if (mbeanRefName != null)
+            {
+               if (proxyType != null)
+               {
+                  if (mbeanRefName == null)
+                     throw new DeploymentException("You cannot use a proxy-type without an optional-attribute-name for " + mbeanName);
+               }
+               ServiceValueMetaData value = new ServiceDependencyValueMetaData(dependsObjectName, proxyType);
+               ServiceAttributeMetaData attribute = new ServiceAttributeMetaData();
+               attribute.setName(mbeanRefName);
+               attribute.setValue(value);
+               attributes.add(attribute);
+            }
+            
+            ServiceDependencyMetaData dependency = new ServiceDependencyMetaData();
+            dependency.setIDependOn(dependsObjectName);
+            dependencies.add(dependency);
+         }
+         else if (element.getTagName().equals("depends-list"))
+         {
+            String dependsListName = element.getAttribute("optional-attribute-name");
+            if ("".equals(dependsListName))
+               dependsListName = null;
+
+            NodeList dependsList = element.getChildNodes();
+            ArrayList<ObjectName> dependsListNames = new ArrayList<ObjectName>();
+            for (int l = 0; l < dependsList.getLength(); ++l)
+            {
+               if (dependsList.item(l).getNodeType() != Node.ELEMENT_NODE)
+                  continue;
+
+               Element dependsElement = (Element) dependsList.item(l);
+               if (dependsElement.getTagName().equals("depends-list-element"))
+               {
+                  if (dependsElement.hasChildNodes() == false)
+                     throw new DeploymentException("Empty depends-list-element for " + mbeanName);
+
+                  // Get the depends value
+                  ObjectName dependsObjectName = processDependency(mbeanName, dependsElement, services, replace);
+                  if (dependsListNames.contains(dependsObjectName) == false)
+                     dependsListNames.add(dependsObjectName);
+
+                  ServiceDependencyMetaData dependency = new ServiceDependencyMetaData();
+                  dependency.setIDependOn(dependsObjectName);
+                  dependencies.add(dependency);
+               }
+            }
+            if (dependsListName != null)
+            {
+               ServiceValueMetaData value = new ServiceDependencyListValueMetaData(dependsListNames);
+               ServiceAttributeMetaData attribute = new ServiceAttributeMetaData();
+               attribute.setName(dependsListName);
+               attribute.setValue(value);
+               attributes.add(attribute);
+            }
+         }
+      }
+      
+      service.setAttributes(attributes);
+      service.setDependencies(dependencies);
+      
+      services.add(service);
+      
+      return mbeanName;
+   }
+
+   /**
+    * Parse an object name from the given element attribute 'name'.
+    * 
+    * @param mbeanElement the element to parse name from.
+    * @return the ObjectName
+    * @throws Exception for any error
+    */
+   private ObjectName parseObjectName(final Element mbeanElement, boolean replace) throws Exception
+   {
+      String name = mbeanElement.getAttribute("name");
+
+      if (name == null || name.trim().length() == 0)
+         throw new DeploymentException("Missing or empty 'name' attribute for mbean.");
+
+      if (replace)
+         name = StringPropertyReplacer.replaceProperties(name);
+
+      return new ObjectName(name);
+   }
+
+   /**
+    * Parse a class name from the given element attribute 'code'.
+    * 
+    * @param name the mbean name
+    * @param mbeanElement the element to parse name from.
+    * @return the class name
+    * @throws Exception for any error
+    */
+   private String parseCode(final ObjectName name, final Element mbeanElement) throws Exception
+   {
+      String code = mbeanElement.getAttribute("code");
+
+      if (code == null || code.trim().length() == 0)
+         throw new ConfigurationException("Missing or empty 'code' attribute for mbean " + name);
+
+      return code;
+   }
+
+   /**
+    * Parse the constructor element of the given element
+    * 
+    * @param name the mbean name
+    * @param mbeanElement the element to parse name from.
+    * @param replace whether to replace system properties
+    * @return the constructor meta data
+    * @throws Exception for any error
+    */
+   private ServiceConstructorMetaData parseConstructor(final ObjectName name, final Element mbeanElement, boolean replace) throws Exception
+   {
+      ServiceConstructorMetaData result = new ServiceConstructorMetaData();
+
+      NodeList list = mbeanElement.getElementsByTagName("constructor");
+      if (list.getLength() > 1 && list.item(0).getParentNode() == mbeanElement)
+         throw new DeploymentException("only one <constructor> element may be defined for " + name);
+      
+      if (list.getLength() == 1)
+      {
+         Element element = (Element) list.item(0);
+
+         // get all of the "arg" elements
+         list = element.getElementsByTagName("arg");
+         int length = list.getLength();
+         String[] params = new String[length];
+         String[] signature = new String[length];
+
+         // decode the values into params & signature
+         for (int j=0; j<length; ++j)
+         {
+            Element arg = (Element)list.item(j);
+            String typeName = null;
+            Attr attr = arg.getAttributeNode("type");
+            if (attr != null)
+               typeName = attr.getValue();
+            if (typeName == null || typeName.trim().length() == 0)
+               throw new ConfigurationException("Missing or empty 'type' attribute in constructor arg for " + name);
+            String value = null;
+            attr = arg.getAttributeNode("value");
+            if (attr != null)
+               value = attr.getValue();
+            if (value == null)
+               throw new ConfigurationException("Missing 'value' attribute in constructor arg for " + name);
+            signature[j] = typeName;
+            params[j] = value;
+         }
+         
+         result.setParams(params);
+         result.setSignature(signature);
+      }
+
+      return result;
+   }
+
+   /**
+    * Parse the interface name from the given element attribute 'interface'.
+    * 
+    * @param name the mbean name
+    * @param mbeanElement the element to parse name from.
+    * @return the class name
+    * @throws Exception for any error
+    */
+   private String parseInterface(final ObjectName name, final Element mbeanElement) throws Exception
+   {
+      Attr attr = mbeanElement.getAttributeNode("interface");
+      if (attr != null)
+         return attr.getValue();
+      else
+         return null;
+   }
+
+   /**
+    * Parse the xmbean dds from the given element attribute 'xmbean-dd'.
+    * 
+    * @param name the mbean name
+    * @param mbeanElement the element to parse name from.
+    * @return the xmbean dds location
+    * @throws Exception for any error
+    */
+   private String parseXMBeanDD(final ObjectName name, final Element mbeanElement) throws Exception
+   {
+      Attr attr = mbeanElement.getAttributeNode("xmbean-dd");
+      if (attr != null)
+         return attr.getValue();
+      else
+         return null;
+   }
+
+   /**
+    * Parse the xmbean code from the given element attribute 'xmbean-code'.
+    * 
+    * @param name the mbean name
+    * @param mbeanElement the element to parse name from.
+    * @return the xmbean code
+    * @throws Exception for any error
+    */
+   private String parseXMBeanCode(final ObjectName name, final Element mbeanElement) throws Exception
+   {
+      Attr attr = mbeanElement.getAttributeNode("xmbean-code");
+      if (attr != null)
+         return attr.getValue();
+      else
+         return ServiceMetaData.XMBEAN_CODE;
+   }
+
+   /**
+    * Parse the xmbean descriptor.
+    * 
+    * @param name the mbean name
+    * @param mbeanElement the element to parse name from.
+    * @return the xmbean descriptor
+    * @throws Exception for any error
+    */
+   private Element parseXMBeanDescriptor(final ObjectName name, final Element mbeanElement) throws Exception
+   {
+      NodeList mbeans = mbeanElement.getElementsByTagName("xmbean");
+      if (mbeans.getLength() == 0)
+         throw new DeploymentException("No nested mbean element given for xmbean for " + name);
+      return (Element) mbeans.item(0);
+   }
+
+   /**
+    * Process a dependency
+    * 
+    * @param mbeanName the surronding mbean
+    * @param element the element
+    * @param services the list of services
+    * @param replace whether to replace properties
+    * @return the dependent object name
+    * @throws Exception for any error
+    */
+   private ObjectName processDependency(ObjectName mbeanName, Element element, List<ServiceMetaData> services, boolean replace) throws Exception
+   {
+      ObjectName dependsObjectName = null;
+      
+      NodeList nl = element.getChildNodes();
+      for (int i = 0; i < nl.getLength(); i++)
+      {
+         Node childNode = nl.item(i);
+         if (childNode.getNodeType() == Node.ELEMENT_NODE)
+         {
+            Element child = (Element) childNode;
+            if (child.getTagName().equals("mbean"))
+            {
+               dependsObjectName = internalParse(services, child, replace);
+               break;
+            }
+            else
+               throw new DeploymentException("Non mbean child element in depends tag for " + mbeanName);
+         }
+      }
+
+      if (dependsObjectName == null)
+      {
+         String name = getElementTextContent(element, true, replace);
+         try
+         {
+            dependsObjectName = new ObjectName(name);
+         }
+         catch (Throwable t)
+         {
+            throw new DeploymentException("Invalid object name '" + name + "' in depends tag for " + mbeanName, t);
+         }
+      }
+      
+      if (dependsObjectName == null)
+         throw new DeploymentException("No object name found in depends tag for " + mbeanName);
+
+      return dependsObjectName;
+   }
+
+   /**
+    * Get an elements text content
+    * 
+    * @param element the element
+    * @return the concatentation of the text nodes
+    * @throws Exception for any error
+    */
+   public static String getElementTextContent(Element element, boolean trim, boolean replace) throws Exception
+   {
+      NodeList nl = element.getChildNodes();
+      String attributeText = "";
+      for (int i = 0; i < nl.getLength(); i++)
+      {
+         Node n = nl.item(i);
+         if (n instanceof Text)
+         {
+            attributeText += ((Text) n).getData();
+         }
+      }
+      if (trim)
+         attributeText = attributeText.trim();
+      if (replace)
+         attributeText = StringPropertyReplacer.replaceProperties(attributeText);
+      return attributeText;
+   }
+}

Added: trunk/system/src/main/org/jboss/system/metadata/ServiceTextValueMetaData.java
===================================================================
--- trunk/system/src/main/org/jboss/system/metadata/ServiceTextValueMetaData.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/main/org/jboss/system/metadata/ServiceTextValueMetaData.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,132 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.system.metadata;
+
+import java.beans.PropertyEditor;
+import java.beans.PropertyEditorManager;
+
+import javax.management.MBeanAttributeInfo;
+import javax.management.MBeanServer;
+
+import org.jboss.deployment.DeploymentException;
+import org.jboss.util.Classes;
+import org.jboss.util.propertyeditor.PropertyEditors;
+
+/**
+ * ServiceTextValueMetaData.
+ * 
+ * This class is based on the old ServiceConfigurator
+ *
+ * @author <a href="mailto:marc at jboss.org">Marc Fleury</a>
+ * @author <a href="mailto:hiram at jboss.org">Hiram Chirino</a>
+ * @author <a href="mailto:d_jencks at users.sourceforge.net">David Jencks</a>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ServiceTextValueMetaData implements ServiceValueMetaData
+{
+   static
+   {
+      try
+      {
+         PropertyEditors.init();
+      }
+      catch (Exception ignored)
+      {
+      }
+   }
+   
+   /** The text */
+   private String text;
+
+   /**
+    * Create a new ServiceTextValueMetaData.
+    * 
+    * @param text the text
+    */
+   public ServiceTextValueMetaData(String text)
+   {
+      setText(text);
+   }
+
+   /**
+    * Get the text.
+    * 
+    * @return the text.
+    */
+   public String getText()
+   {
+      return text;
+   }
+
+   /**
+    * Set the text.
+    * 
+    * @param text the text.
+    */
+   public void setText(String text)
+   {
+      if (text == null)
+         throw new IllegalArgumentException("Null text");
+      this.text = text;
+   }
+
+   public Object getValue(MBeanServer server, MBeanAttributeInfo attributeInfo, ClassLoader cl, boolean trim, boolean replace) throws Exception
+   {
+      String typeName = attributeInfo.getType();
+
+      // see if it is a primitive type first
+      Class typeClass = Classes.getPrimitiveTypeForName(typeName);
+      if (typeClass == null)
+      {
+         // nope try look up
+         try
+         {
+            typeClass = cl.loadClass(typeName);
+         }
+         catch (ClassNotFoundException e)
+         {
+            throw new DeploymentException("Class not found for attribute: " + attributeInfo.getName(), e);
+         }
+      }
+
+      PropertyEditor editor = PropertyEditorManager.findEditor(typeClass);
+      if (editor == null)
+         throw new DeploymentException("No property editor for attribute: " + attributeInfo.getName() + "; type=" + typeClass.getName());
+
+      // JBAS-1709, temporarily switch the TCL so that property
+      // editors have access to the actual deployment ClassLoader.
+      ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+      Thread.currentThread().setContextClassLoader(cl);
+      try 
+      {
+         editor.setAsText(text);
+         return editor.getValue();
+      }
+      finally 
+      {
+         Thread.currentThread().setContextClassLoader(tcl);
+      }
+   }
+}

Added: trunk/system/src/main/org/jboss/system/metadata/ServiceValueMetaData.java
===================================================================
--- trunk/system/src/main/org/jboss/system/metadata/ServiceValueMetaData.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/main/org/jboss/system/metadata/ServiceValueMetaData.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,47 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.system.metadata;
+
+import javax.management.MBeanAttributeInfo;
+import javax.management.MBeanServer;
+
+/**
+ * ServiceValueMetaData.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public interface ServiceValueMetaData
+{
+   /**
+    * Get the value
+    * 
+    * @param server the mbean server
+    * @param attributeInfo the mbean attribute info
+    * @param cl the class loader
+    * @param trim whether to trim
+    * @param replace whether to replace
+    * @return the value
+    * @throws Exception for any error
+    */
+   Object getValue(MBeanServer server, MBeanAttributeInfo attributeInfo, ClassLoader cl, boolean trim, boolean replace) throws Exception;
+}

Added: trunk/system/src/main/org/jboss/system/microcontainer/ConfigureAction.java
===================================================================
--- trunk/system/src/main/org/jboss/system/microcontainer/ConfigureAction.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/main/org/jboss/system/microcontainer/ConfigureAction.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,71 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.system.microcontainer;
+
+import java.util.List;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.jboss.system.ServiceBinding;
+import org.jboss.system.ServiceConfigurator;
+import org.jboss.system.ServiceContext;
+import org.jboss.system.metadata.ServiceAttributeMetaData;
+import org.jboss.system.metadata.ServiceMetaData;
+
+/**
+ * ConfigureAction.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ConfigureAction extends ServiceControllerContextAction
+{
+   public void installAction(ServiceControllerContext context) throws Throwable
+   {
+      MBeanServer server = context.getServiceController().getMBeanServer();
+      ObjectName objectName = context.getObjectName();
+
+      // Configure any attributes
+      ServiceMetaData metaData = context.getServiceMetaData();
+      if (metaData != null)
+      {
+         List<ServiceAttributeMetaData> attrs = metaData.getAttributes();
+         if (attrs.size() > 0)
+         {
+            ObjectName classLoaderName = metaData.getClassLoaderName(); 
+            ServiceConfigurator.configure(server, objectName, classLoaderName, attrs);
+         }
+      }
+
+      // If a ServiceBinding policy is plugged-in, check for overriden attributes
+      ServiceBinding serviceBinding = context.getServiceController().getServiceBinding();
+      if (serviceBinding != null)
+         ServiceConfigurator.applyServiceConfig(server, objectName, serviceBinding);
+      
+      context.getServiceContext().state = ServiceContext.CONFIGURED;
+   }
+
+   public void uninstallAction(ServiceControllerContext context)
+   {
+   }
+}

Added: trunk/system/src/main/org/jboss/system/microcontainer/CreateDestroyLifecycleAction.java
===================================================================
--- trunk/system/src/main/org/jboss/system/microcontainer/CreateDestroyLifecycleAction.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/main/org/jboss/system/microcontainer/CreateDestroyLifecycleAction.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,69 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.system.microcontainer;
+
+import javax.management.ObjectName;
+
+import org.jboss.system.Service;
+import org.jboss.system.ServiceContext;
+import org.jboss.system.ServiceController;
+import org.jboss.system.ServiceMBean;
+
+/**
+ * CreateDestroyLifecycleAction.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class CreateDestroyLifecycleAction extends ServiceControllerContextAction
+{
+   public void installAction(ServiceControllerContext context) throws Throwable
+   {
+      Service service = context.getServiceProxy();
+      service.create();
+
+      context.getServiceContext().state = ServiceContext.CREATED;
+      
+      ObjectName objectName = context.getObjectName();
+      ServiceController serviceController = context.getServiceController();
+      serviceController.sendControllerNotification(ServiceMBean.CREATE_EVENT, objectName);            
+   }
+
+   public void uninstallAction(ServiceControllerContext context)
+   {
+      try
+      {
+         Service service = context.getServiceProxy();
+         service.destroy();
+
+         context.getServiceContext().state = ServiceContext.DESTROYED;
+
+         ObjectName objectName = context.getObjectName();
+         ServiceController serviceController = context.getServiceController();
+         serviceController.sendControllerNotification(ServiceMBean.DESTROY_EVENT, objectName);            
+      }
+      catch (Throwable t)
+      {
+         log.debug("Error during destroy for " + context.getObjectName(), t);
+      }
+   }
+}

Added: trunk/system/src/main/org/jboss/system/microcontainer/DescribeAction.java
===================================================================
--- trunk/system/src/main/org/jboss/system/microcontainer/DescribeAction.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/main/org/jboss/system/microcontainer/DescribeAction.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,63 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.system.microcontainer;
+
+import java.util.List;
+
+import javax.management.ObjectName;
+
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.dependency.spi.DependencyInfo;
+import org.jboss.system.metadata.ServiceDependencyMetaData;
+import org.jboss.system.metadata.ServiceMetaData;
+
+/**
+ * DescribeAction.
+ * 
+ * @todo use a visitor on the metadata like the pojo version
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class DescribeAction extends ServiceControllerContextAction
+{
+   public void installAction(ServiceControllerContext context) throws Throwable
+   {
+      // Add the lifecycle dependencies
+      ServiceMetaData metaData = context.getServiceMetaData();
+      if (metaData != null)
+      {
+         Object name = context.getName();
+         DependencyInfo info = context.getDependencyInfo();
+         List<ServiceDependencyMetaData> dependencies = metaData.getDependencies();
+         for (ServiceDependencyMetaData dependency : dependencies)
+         {
+            ObjectName iDependOn = dependency.getIDependOn();
+            info.addIDependOn(new LifecycleDependencyItem(name, iDependOn.getCanonicalName(), ControllerState.CREATE));
+            info.addIDependOn(new LifecycleDependencyItem(name, iDependOn.getCanonicalName(), ControllerState.START));
+         }
+      }
+   }
+
+   public void uninstallAction(ServiceControllerContext context)
+   {
+   }
+}

Added: trunk/system/src/main/org/jboss/system/microcontainer/InstallAction.java
===================================================================
--- trunk/system/src/main/org/jboss/system/microcontainer/InstallAction.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/main/org/jboss/system/microcontainer/InstallAction.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,39 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.system.microcontainer;
+
+/**
+ * InstallAction.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class InstallAction extends ServiceControllerContextAction
+{
+   public void installAction(ServiceControllerContext context) throws Throwable
+   {
+   }
+
+   public void uninstallAction(ServiceControllerContext context)
+   {
+   }
+}

Added: trunk/system/src/main/org/jboss/system/microcontainer/InstantiateAction.java
===================================================================
--- trunk/system/src/main/org/jboss/system/microcontainer/InstantiateAction.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/main/org/jboss/system/microcontainer/InstantiateAction.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,58 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.system.microcontainer;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.jboss.system.ServiceCreator;
+import org.jboss.system.ServiceInstance;
+import org.jboss.system.metadata.ServiceMetaData;
+
+/**
+ * InstantiateAction.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class InstantiateAction extends ServiceControllerContextAction
+{
+   public void installAction(ServiceControllerContext context) throws Throwable
+   {
+      MBeanServer server = context.getServiceController().getMBeanServer();
+      ObjectName objectName = context.getObjectName();
+      ServiceMetaData metaData = context.getServiceMetaData();
+      Object mbean = context.getTarget();
+      ServiceInstance instance = ServiceCreator.install(server, objectName, metaData, mbean);
+      context.setTarget(instance.getResource());
+   }
+
+   public void uninstallAction(ServiceControllerContext context)
+   {
+      MBeanServer server = context.getServiceController().getMBeanServer();
+      ObjectName objectName = context.getObjectName();
+      ServiceCreator.uninstall(server, objectName);
+      ServiceMetaData metaData = context.getServiceMetaData();
+      if (metaData != null)
+         context.setTarget(null);
+   }
+}

Added: trunk/system/src/main/org/jboss/system/microcontainer/LifecycleDependencyItem.java
===================================================================
--- trunk/system/src/main/org/jboss/system/microcontainer/LifecycleDependencyItem.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/main/org/jboss/system/microcontainer/LifecycleDependencyItem.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,25 @@
+package org.jboss.system.microcontainer;
+
+import org.jboss.dependency.plugins.AbstractDependencyItem;
+import org.jboss.dependency.spi.ControllerState;
+
+/**
+ * A LifecycleDependencyItem.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class LifecycleDependencyItem extends AbstractDependencyItem
+{
+   /**
+    * Create a new LifecycleDependencyItem.
+    * 
+    * @param name the name
+    * @param dependency the dependency
+    * @param state the state
+    */
+   public LifecycleDependencyItem(Object name, Object dependency, ControllerState state)
+   {
+      super(name, dependency, state, state);
+   }
+}
\ No newline at end of file

Added: trunk/system/src/main/org/jboss/system/microcontainer/ServiceControllerContext.java
===================================================================
--- trunk/system/src/main/org/jboss/system/microcontainer/ServiceControllerContext.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/main/org/jboss/system/microcontainer/ServiceControllerContext.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,207 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.system.microcontainer;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.jboss.dependency.plugins.AbstractControllerContext;
+import org.jboss.dependency.spi.Controller;
+import org.jboss.dependency.spi.ControllerMode;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.system.Service;
+import org.jboss.system.ServiceContext;
+import org.jboss.system.ServiceController;
+import org.jboss.system.metadata.ServiceMetaData;
+
+/**
+ * ServiceControllerContext.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ServiceControllerContext extends AbstractControllerContext
+{
+   /** The ObjectName */
+   private ObjectName objectName;
+   
+   /** The service controller */
+   private ServiceController serviceController;
+   
+   /** The meta data */
+   private ServiceMetaData serviceMetaData;
+   
+   /** The service context */
+   private ServiceContext serviceContext = new ServiceContext();
+   
+   /**
+    * Create a new ServiceControllerContext.
+    * 
+    * @param serviceController the service controller
+    * @param name the name of the context
+    */
+   public ServiceControllerContext(ServiceController serviceController, ObjectName name)
+   {
+      super(name.getCanonicalName(), ServiceControllerContextActions.getLifecycleOnly());
+      this.objectName = name;
+      serviceContext.objectName = objectName;
+      this.serviceController = serviceController;
+      setMode(ControllerMode.MANUAL);
+   }
+   
+   /**
+    * Create a new ServiceControllerContext.
+    * 
+    * @param serviceController the service controller
+    * @param metaData the meta data
+    */
+   public ServiceControllerContext(ServiceController serviceController, ServiceMetaData metaData)
+   {
+      super(metaData.getObjectName().getCanonicalName(), ServiceControllerContextActions.getInstance());
+      this.objectName = metaData.getObjectName();
+      serviceContext.objectName = objectName;
+      this.serviceController = serviceController;
+      setMode(ControllerMode.MANUAL);
+      this.serviceMetaData = metaData;
+   }
+   
+   /**
+    * Create a new ServiceControllerContext.
+    * 
+    * @param serviceController the service controller
+    * @param name the name
+    * @param target the target
+    */
+   public ServiceControllerContext(ServiceController serviceController, ObjectName name, Object target)
+   {
+      super(name.getCanonicalName(), ServiceControllerContextActions.getInstance());
+      this.objectName = name;
+      serviceContext.objectName = objectName;
+      this.serviceController = serviceController;
+      setTarget(target);
+      setMode(ControllerMode.MANUAL);
+   }
+
+   /**
+    * Get the ObjectName.
+    * 
+    * @return the ObjectName.
+    */
+   public ObjectName getObjectName()
+   {
+      return objectName;
+   }
+
+   /**
+    * Get the serviceMetaData.
+    * 
+    * @return the serviceMetaData.
+    */
+   public ServiceMetaData getServiceMetaData()
+   {
+      return serviceMetaData;
+   }
+
+   /**
+    * Set the serviceMetaData.
+    * 
+    * @param serviceMetaData the serviceMetaData.
+    */
+   public void setServiceMetaData(ServiceMetaData serviceMetaData)
+   {
+      this.serviceMetaData = serviceMetaData;
+   }
+
+   /**
+    * Get the serviceController.
+    * 
+    * @return the serviceController.
+    */
+   public ServiceController getServiceController()
+   {
+      return serviceController;
+   }
+   
+   /**
+    * Get the service proxy
+    * 
+    * @return the service proxy
+    */
+   public Service getServiceProxy() throws Exception
+   {
+      if (serviceContext.proxy != null)
+         return serviceContext.proxy;
+      
+      MBeanServer server = serviceController.getMBeanServer();
+      if (server != null)
+         serviceContext.proxy = ServiceProxy.getServiceProxy(objectName, server);
+      
+      return serviceContext.proxy;
+   }
+   
+   /**
+    * Get the service context
+    * 
+    * @return the service context
+    */
+   public ServiceContext getServiceContext()
+   {
+      try
+      {
+         serviceContext.proxy = getServiceProxy();
+      }
+      catch (Exception ignored)
+      {
+      }
+      serviceContext.problem = getError();
+      if (getState() == ControllerState.ERROR)
+         serviceContext.state = ServiceContext.FAILED;
+      return serviceContext;
+   }
+
+   // Overridden to update the service context with any failure
+   public void install(ControllerState fromState, ControllerState toState) throws Throwable
+   {
+      try
+      {
+         super.install(fromState, toState);
+      }
+      catch (Throwable t)
+      {
+         serviceContext.problem = t;
+         serviceContext.state = ServiceContext.FAILED;
+         throw t;
+      }
+   }
+
+   // Overridden to update the service context with the installed/not installed state
+   // i.e. of the ServiceController registration
+   // Not to be confused with the microcontainer's (fully) installed state
+   public void setController(Controller controller)
+   {
+      super.setController(controller);
+      if (controller != null)
+         serviceContext.state = ServiceContext.INSTALLED;
+      else
+         serviceContext.state = ServiceContext.NOTYETINSTALLED;
+   }
+}

Added: trunk/system/src/main/org/jboss/system/microcontainer/ServiceControllerContextAction.java
===================================================================
--- trunk/system/src/main/org/jboss/system/microcontainer/ServiceControllerContextAction.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/main/org/jboss/system/microcontainer/ServiceControllerContextAction.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,112 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.system.microcontainer;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+import org.jboss.dependency.plugins.spi.action.ControllerContextAction;
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.logging.Logger;
+
+/**
+ * ServiceControllerContextAction.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ServiceControllerContextAction implements ControllerContextAction
+{
+   protected Logger log = Logger.getLogger(getClass());
+
+   public void install(final ControllerContext context) throws Throwable
+   {
+      if (System.getSecurityManager() == null || context instanceof ServiceControllerContext == false)
+         installAction((ServiceControllerContext) context);
+      else
+      {
+         PrivilegedExceptionAction<Object> action = new PrivilegedExceptionAction<Object>()
+         {
+            public Object run() throws Exception
+            {
+               try
+               {
+                  installAction((ServiceControllerContext) context);
+                  return null;
+               }
+               catch (RuntimeException e)
+               {
+                  throw e;
+               }
+               catch (Exception e)
+               {
+                  throw e;
+               }
+               catch (Error e)
+               {
+                  throw e;
+               }
+               catch (Throwable t)
+               {
+                  throw new RuntimeException(t);
+               }
+            }
+         };
+         try
+         {
+            AccessController.doPrivileged(action);
+         }
+         catch (PrivilegedActionException e)
+         {
+            throw e.getCause();
+         }
+      }
+   }
+
+   public void uninstall(final ControllerContext context)
+   {
+      if (System.getSecurityManager() == null || context instanceof ServiceControllerContext == false)
+         uninstallAction((ServiceControllerContext) context);
+      else
+      {
+         PrivilegedAction<Object> action = new PrivilegedAction<Object>()
+         {
+            public Object run()
+            {
+               uninstallAction((ServiceControllerContext) context);
+               return null;
+            }
+         };
+         AccessController.doPrivileged(action);
+      }
+   }
+   
+   public void installAction(ServiceControllerContext context) throws Throwable
+   {
+   }
+
+   public void uninstallAction(ServiceControllerContext context)
+   {
+   }
+}

Added: trunk/system/src/main/org/jboss/system/microcontainer/ServiceControllerContextActions.java
===================================================================
--- trunk/system/src/main/org/jboss/system/microcontainer/ServiceControllerContextActions.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/main/org/jboss/system/microcontainer/ServiceControllerContextActions.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,92 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.system.microcontainer;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.dependency.plugins.AbstractControllerContextActions;
+import org.jboss.dependency.plugins.spi.action.ControllerContextAction;
+import org.jboss.dependency.spi.ControllerState;
+
+/**
+ * ServiceControllerContextActions.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ServiceControllerContextActions extends AbstractControllerContextActions
+{
+   /** The single instance */
+   private static ServiceControllerContextActions instance;
+   /** The lifecycle instance */
+   private static ServiceControllerContextActions lifecycleOnly;
+
+   /**
+    * Get the instance
+    * 
+    * @return the actions
+    */
+   public static ServiceControllerContextActions getInstance()
+   {
+      if (instance == null)
+      {
+         Map<ControllerState, ControllerContextAction> actions = new HashMap<ControllerState, ControllerContextAction>();
+         actions.put(ControllerState.DESCRIBED, new DescribeAction());
+         actions.put(ControllerState.INSTANTIATED, new InstantiateAction());
+         actions.put(ControllerState.CONFIGURED, new ConfigureAction());
+         actions.put(ControllerState.CREATE, new CreateDestroyLifecycleAction());
+         actions.put(ControllerState.START, new StartStopLifecycleAction());
+         actions.put(ControllerState.INSTALLED, new InstallAction());
+         instance = new ServiceControllerContextActions(actions);
+      }
+      return instance;
+   }
+
+   /**
+    * Get the instance
+    * 
+    * @return the actions
+    */
+   public static ServiceControllerContextActions getLifecycleOnly()
+   {
+      if (lifecycleOnly == null)
+      {
+         Map<ControllerState, ControllerContextAction> actions = new HashMap<ControllerState, ControllerContextAction>();
+         actions.put(ControllerState.CREATE, new CreateDestroyLifecycleAction());
+         actions.put(ControllerState.START, new StartStopLifecycleAction());
+         lifecycleOnly = new ServiceControllerContextActions(actions);
+      }
+      return lifecycleOnly;
+   }
+
+   
+   /**
+    * Create a new ServiceControllerContextActions.
+    * 
+    * @param actions the actions
+    */
+   protected ServiceControllerContextActions(Map<ControllerState, ControllerContextAction> actions)
+   {
+      super(actions);
+   }
+}

Added: trunk/system/src/main/org/jboss/system/microcontainer/ServiceProxy.java
===================================================================
--- trunk/system/src/main/org/jboss/system/microcontainer/ServiceProxy.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/main/org/jboss/system/microcontainer/ServiceProxy.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,192 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.system.microcontainer;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.HashMap;
+
+import javax.management.MBeanInfo;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.jboss.mx.util.JMXExceptionDecoder;
+import org.jboss.system.Service;
+import org.jboss.system.ServiceController;
+
+/**
+ * An implementation of InvocationHandler used to proxy of the Service
+ * interface for mbeans. It determines which of the start/stop
+ * methods of the Service interface an mbean implements by inspecting its
+ * MBeanOperationInfo values. Each Service interface method that has a
+ * matching operation is forwarded to the mbean by invoking the method
+ * through the MBeanServer object.<p>
+ * 
+ * This class is based on the old ServiceConfigurator
+ * 
+ * @author <a href="mailto:marc at jboss.org">Marc Fleury</a>
+ * @author <a href="mailto:hiram at jboss.org">Hiram Chirino</a>
+ * @author <a href="mailto:d_jencks at users.sourceforge.net">David Jencks</a>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ServiceProxy implements InvocationHandler
+{
+   /**
+    * A mapping from the Service interface method names to the corresponding
+    * index into the ServiceProxy.hasOp array.
+    */
+   private static HashMap<String, Integer> serviceOpMap = new HashMap<String, Integer>();
+
+   /**
+    * Initialize the service operation map.
+    */
+   static
+   {
+      serviceOpMap.put("create", new Integer(0));
+      serviceOpMap.put("start", new Integer(1));
+      serviceOpMap.put("destroy", new Integer(2));
+      serviceOpMap.put("stop", new Integer(3));
+   }
+
+   private boolean[] hasOp = {false, false, false, false};
+   private ObjectName objectName;
+   private MBeanServer server;
+
+   /** Whether we have the lifecycle method */
+   private boolean hasJBossInternalLifecycle;
+
+   /**
+    * Get the Service interface through which the mbean given by objectName will be managed.
+    *
+    * @param objectName the object name
+    * @param server the mbean server
+    * @return The Service value
+    */
+   public static Service getServiceProxy(ObjectName objectName, MBeanServer server) throws Exception
+   {
+      Service service = null;
+      MBeanInfo info = server.getMBeanInfo(objectName);
+      MBeanOperationInfo[] opInfo = info.getOperations();
+      Class[] interfaces = { Service.class };
+      InvocationHandler handler = new ServiceProxy(objectName, server, opInfo);
+      service = (Service) Proxy.newProxyInstance(Service.class.getClassLoader(), interfaces, handler);
+
+      return service;
+   }
+
+   /**
+    * Go through the opInfo array and for each operation that matches on of
+    * the Service interface methods set the corresponding hasOp array value
+    * to true.
+    *
+    * @param objectName
+    * @param opInfo
+    */
+   public ServiceProxy(ObjectName objectName, MBeanServer server, MBeanOperationInfo[] opInfo)
+   {
+      this.server = server;
+      this.objectName = objectName;
+
+      for (int op = 0; op < opInfo.length; op++)
+      {
+         MBeanOperationInfo info = opInfo[op];
+         String name = info.getName();
+
+         if (name.equals(ServiceController.JBOSS_INTERNAL_LIFECYCLE))
+         {
+            hasJBossInternalLifecycle = true;
+            continue;
+         }
+
+         Integer opID = serviceOpMap.get(name);
+         if (opID == null)
+         {
+            continue;
+         }
+
+         // Validate that is a no-arg void return type method
+         if (info.getReturnType().equals("void") == false)
+         {
+            continue;
+         }
+         if (info.getSignature().length != 0)
+         {
+            continue;
+         }
+
+         hasOp[opID.intValue()] = true;
+      }
+   }
+
+   /**
+    * Map the method name to a Service interface method index and if the
+    * corresponding hasOp array element is true, dispatch the method to the
+    * mbean we are proxying.
+    *
+    * @param proxy
+    * @param method
+    * @param args
+    * @return             Always null.
+    * @throws Throwable
+    */
+   public Object invoke(Object proxy, Method method, Object[] args)
+         throws Throwable
+   {
+      String name = method.getName();
+
+      if (hasJBossInternalLifecycle)
+      {
+         try
+         {
+            server.invoke(objectName, ServiceController.JBOSS_INTERNAL_LIFECYCLE, new Object[] { name }, ServiceController.JBOSS_INTERNAL_LIFECYCLE_SIG);
+            return null;
+         }
+         catch (Exception e)
+         {
+            throw JMXExceptionDecoder.decode(e);
+         }
+      }
+
+      Integer opID = serviceOpMap.get(name);
+
+      if (opID != null && hasOp[opID.intValue()] == true)
+      {
+         // deal with those pesky JMX exceptions
+         try
+         {
+            String[] sig = {};
+            server.invoke(objectName, name, args, sig);
+         }
+         catch (Exception e)
+         {
+            throw JMXExceptionDecoder.decode(e);
+         }
+      }
+
+      return null;
+   }
+}

Added: trunk/system/src/main/org/jboss/system/microcontainer/StartStopLifecycleAction.java
===================================================================
--- trunk/system/src/main/org/jboss/system/microcontainer/StartStopLifecycleAction.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/main/org/jboss/system/microcontainer/StartStopLifecycleAction.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,69 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.system.microcontainer;
+
+import javax.management.ObjectName;
+
+import org.jboss.system.Service;
+import org.jboss.system.ServiceContext;
+import org.jboss.system.ServiceController;
+import org.jboss.system.ServiceMBean;
+
+/**
+ * StartStopLifecycleAction.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class StartStopLifecycleAction extends ServiceControllerContextAction
+{
+   public void installAction(ServiceControllerContext context) throws Throwable
+   {
+      Service service = context.getServiceProxy();
+      service.start();
+
+      context.getServiceContext().state = ServiceContext.RUNNING;
+
+      ObjectName objectName = context.getObjectName();
+      ServiceController serviceController = context.getServiceController();
+      serviceController.sendControllerNotification(ServiceMBean.START_EVENT, objectName);            
+   }
+
+   public void uninstallAction(ServiceControllerContext context)
+   {
+      try
+      {
+         Service service = context.getServiceProxy();
+         service.stop();
+
+         context.getServiceContext().state = ServiceContext.STOPPED;
+
+         ObjectName objectName = context.getObjectName();
+         ServiceController serviceController = context.getServiceController();
+         serviceController.sendControllerNotification(ServiceMBean.STOP_EVENT, objectName);            
+      }
+      catch (Throwable t)
+      {
+         log.debug("Error during stop for " + context.getObjectName(), t);
+      }
+   }
+}

Modified: trunk/system/src/main/org/jboss/system/server/ServerLoader.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/ServerLoader.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/main/org/jboss/system/server/ServerLoader.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -77,7 +77,7 @@
     * proper libraries.
     */
    public static final String DEFAULT_BOOT_LIBRARY_LIST =
-      "log4j-boot.jar,jboss-common.jar,jboss-system.jar,jboss-xml-binding.jar,namespace.jar";
+      "log4j-boot.jar,jboss-common.jar,jboss-system.jar,jboss-xml-binding.jar,namespace.jar,jboss-container.jar,jboss-dependency.jar,jboss-microcontainer.jar";
 
    /** The default server type. */
    public static final String DEFAULT_SERVER_TYPE = "org.jboss.system.server.ServerImpl";

Added: trunk/system/src/resources/tests/org/jboss/test/system/controller/basic/test/Basic.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/controller/basic/test/Basic.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/controller/basic/test/Basic.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+   <mbean name="jboss.test:type=test" code="org.jboss.test.system.controller.support.Simple"/>
+</server>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/controller/basic/test/DoubleInstall.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/controller/basic/test/DoubleInstall.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/controller/basic/test/DoubleInstall.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+   <mbean name="jboss.test:type=test" code="org.jboss.test.system.controller.support.Simple"/>
+</server>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/controller/configure/test/Configure.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/controller/configure/test/Configure.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/controller/configure/test/Configure.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+   <mbean name="jboss.test:type=test" code="org.jboss.test.system.controller.support.Simple">
+      <attribute name="AString">StringValue</attribute>
+      <attribute name="AByte">12</attribute>
+      <attribute name="ABoolean">true</attribute>
+      <attribute name="AShort">123</attribute>
+      <attribute name="AnInt">1234</attribute>
+      <attribute name="ALong">12345</attribute>
+      <attribute name="AFloat">3.14</attribute>
+      <attribute name="ADouble">3.14e12</attribute>
+      <attribute name="ADate">Mon Jan 01 00:00:00 CET 2001</attribute>
+      <attribute name="ABigDecimal">12e4</attribute>
+      <!--attribute name="ABigInteger">123456</attribute-->
+      <attribute name="Abyte">12</attribute>
+      <attribute name="Aboolean">true</attribute>
+      <attribute name="Ashort">123</attribute>
+      <attribute name="Anint">1234</attribute>
+      <attribute name="Along">12345</attribute>
+      <attribute name="Afloat">3.14</attribute>
+      <attribute name="Adouble">3.14e12</attribute>
+   </mbean>
+</server>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/controller/configure/test/ErrorInConfigure_NotAutomatic.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/controller/configure/test/ErrorInConfigure_NotAutomatic.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/controller/configure/test/ErrorInConfigure_NotAutomatic.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+   <mbean name="jboss.test:type=test" code="org.jboss.test.system.controller.support.Simple">
+      <attribute name="AnInt">Error</attribute>
+   </mbean>
+</server>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/plain/test/PlainMBeanAbstractClass_bad.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/plain/test/PlainMBeanAbstractClass_bad.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/plain/test/PlainMBeanAbstractClass_bad.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+   <mbean name="jboss.test:type=test" code="org.jboss.test.system.controller.support.AbstractSimple"/>
+</server>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/plain/test/PlainMBeanCodeClassNotFound_bad.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/plain/test/PlainMBeanCodeClassNotFound_bad.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/plain/test/PlainMBeanCodeClassNotFound_bad.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+   <mbean name="jboss.test:type=test" code="THIS_CLASS_DOES_NOT_EXIST"/>
+</server>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/plain/test/PlainMBeanConstructorError_bad.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/plain/test/PlainMBeanConstructorError_bad.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/plain/test/PlainMBeanConstructorError_bad.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+   <mbean name="jboss.test:type=test" code="org.jboss.test.system.controller.support.Simple">
+      <constructor>
+         <arg type="java.lang.String" value="error"/>
+      </constructor>
+   </mbean>
+</server>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/plain/test/PlainMBeanConstructorException_bad.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/plain/test/PlainMBeanConstructorException_bad.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/plain/test/PlainMBeanConstructorException_bad.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+   <mbean name="jboss.test:type=test" code="org.jboss.test.system.controller.support.Simple">
+      <constructor>
+         <arg type="java.lang.String" value="exception"/>
+      </constructor>
+   </mbean>
+</server>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/plain/test/PlainMBeanConstructorInvalidType_bad.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/plain/test/PlainMBeanConstructorInvalidType_bad.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/plain/test/PlainMBeanConstructorInvalidType_bad.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+   <mbean name="jboss.test:type=test" code="org.jboss.test.system.controller.support.Simple">
+      <constructor>
+         <arg type="java.lang.Object" value="unused"/>
+      </constructor>
+   </mbean>
+</server>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/plain/test/PlainMBeanConstructorInvalidValue_bad.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/plain/test/PlainMBeanConstructorInvalidValue_bad.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/plain/test/PlainMBeanConstructorInvalidValue_bad.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+   <mbean name="jboss.test:type=test" code="org.jboss.test.system.controller.support.Simple">
+      <constructor>
+         <arg type="int" value="INVALID"/>
+      </constructor>
+   </mbean>
+</server>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/plain/test/PlainMBeanConstructorTypeNotFound_bad.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/plain/test/PlainMBeanConstructorTypeNotFound_bad.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/plain/test/PlainMBeanConstructorTypeNotFound_bad.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+   <mbean name="jboss.test:type=test" code="org.jboss.test.system.controller.support.Simple">
+      <constructor>
+         <arg type="THIS_CLASS_DOES_NOT_EXIST" value="unused"/>
+      </constructor>
+   </mbean>
+</server>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/plain/test/PlainMBeanNotMBean_bad.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/plain/test/PlainMBeanNotMBean_bad.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/plain/test/PlainMBeanNotMBean_bad.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+   <mbean name="jboss.test:type=test" code="java.lang.Object"/>
+</server>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/plain/test/PlainMBean_install.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/plain/test/PlainMBean_install.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/plain/test/PlainMBean_install.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+   <mbean name="jboss.test:type=test" code="org.jboss.test.system.controller.support.Simple"/>
+</server>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/standard/test/StandardMBeanAbstractClass_bad.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/standard/test/StandardMBeanAbstractClass_bad.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/standard/test/StandardMBeanAbstractClass_bad.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+   <mbean name="jboss.test:type=test" code="org.jboss.test.system.controller.support.AbstractSimple"
+          interface="org.jboss.test.system.controller.support.SimpleMBean">
+   </mbean>
+</server>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/standard/test/StandardMBeanCodeClassNotFound_bad.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/standard/test/StandardMBeanCodeClassNotFound_bad.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/standard/test/StandardMBeanCodeClassNotFound_bad.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+   <mbean name="jboss.test:type=test" code="THIS_CLASS_DOES_NOT_EXIST"
+          interface="org.jboss.test.system.controller.support.SimpleMBean">
+   </mbean>
+</server>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/standard/test/StandardMBeanConstructorError_bad.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/standard/test/StandardMBeanConstructorError_bad.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/standard/test/StandardMBeanConstructorError_bad.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+   <mbean name="jboss.test:type=test" code="org.jboss.test.system.controller.support.Simple"
+          interface="org.jboss.test.system.controller.support.SimpleMBean">
+      <constructor>
+         <arg type="java.lang.String" value="error"/>
+      </constructor>
+   </mbean>
+</server>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/standard/test/StandardMBeanConstructorException_bad.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/standard/test/StandardMBeanConstructorException_bad.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/standard/test/StandardMBeanConstructorException_bad.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+   <mbean name="jboss.test:type=test" code="org.jboss.test.system.controller.support.Simple"
+          interface="org.jboss.test.system.controller.support.SimpleMBean">
+      <constructor>
+         <arg type="java.lang.String" value="exception"/>
+      </constructor>
+   </mbean>
+</server>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/standard/test/StandardMBeanConstructorInvalidType_bad.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/standard/test/StandardMBeanConstructorInvalidType_bad.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/standard/test/StandardMBeanConstructorInvalidType_bad.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+   <mbean name="jboss.test:type=test" code="org.jboss.test.system.controller.support.Simple"
+          interface="org.jboss.test.system.controller.support.SimpleMBean">
+      <constructor>
+         <arg type="java.lang.Object" value="unused"/>
+      </constructor>
+   </mbean>
+</server>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/standard/test/StandardMBeanConstructorInvalidValue_bad.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/standard/test/StandardMBeanConstructorInvalidValue_bad.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/standard/test/StandardMBeanConstructorInvalidValue_bad.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+   <mbean name="jboss.test:type=test" code="org.jboss.test.system.controller.support.Simple"
+          interface="org.jboss.test.system.controller.support.SimpleMBean">
+      <constructor>
+         <arg type="int" value="INVALID"/>
+      </constructor>
+   </mbean>
+</server>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/standard/test/StandardMBeanConstructorTypeNotFound_bad.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/standard/test/StandardMBeanConstructorTypeNotFound_bad.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/standard/test/StandardMBeanConstructorTypeNotFound_bad.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+   <mbean name="jboss.test:type=test" code="org.jboss.test.system.controller.support.Simple"
+          interface="org.jboss.test.system.controller.support.SimpleMBean">
+      <constructor>
+         <arg type="THIS_CLASS_DOES_NOT_EXIST" value="unused"/>
+      </constructor>
+   </mbean>
+</server>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/standard/test/StandardMBeanInterfaceNotFound_bad.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/standard/test/StandardMBeanInterfaceNotFound_bad.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/standard/test/StandardMBeanInterfaceNotFound_bad.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+   <mbean name="jboss.test:type=test" code="org.jboss.test.system.controller.support.Simple"
+          interface="THIS_CLASS_DOES_NOT_EXIST">
+   </mbean>
+</server>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/standard/test/StandardMBeanInterfaceNotImplemented_bad.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/standard/test/StandardMBeanInterfaceNotImplemented_bad.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/standard/test/StandardMBeanInterfaceNotImplemented_bad.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+   <mbean name="jboss.test:type=test" code="org.jboss.test.system.controller.support.Simple"
+          interface="org.jboss.test.system.controller.support.NotSimpleStandardMBeanInterface">
+   </mbean>
+</server>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/standard/test/StandardMBeanInterface_install.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/standard/test/StandardMBeanInterface_install.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/standard/test/StandardMBeanInterface_install.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+   <mbean name="jboss.test:type=test" code="org.jboss.test.system.controller.support.Simple"
+          interface="org.jboss.test.system.controller.support.SimpleStandardMBeanInterface">
+   </mbean>
+</server>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/standard/test/StandardMBean_install.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/standard/test/StandardMBean_install.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/standard/test/StandardMBean_install.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+   <mbean name="jboss.test:type=test" code="org.jboss.test.system.controller.support.Simple"
+          interface="org.jboss.test.system.controller.support.SimpleMBean">
+   </mbean>
+</server>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/test/PlainMBeanNoArg_install.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/test/PlainMBeanNoArg_install.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/test/PlainMBeanNoArg_install.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+   <mbean name="jboss.test:type=test" code="org.jboss.test.system.controller.support.Simple"/>
+</server>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/test/PlainMBeanOneArg_install.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/test/PlainMBeanOneArg_install.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/test/PlainMBeanOneArg_install.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+   <mbean name="jboss.test:type=test" code="org.jboss.test.system.controller.support.Simple">
+      <constructor>
+         <arg type="int" value="5"/>
+      </constructor>
+   </mbean>
+</server>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/test/PlainMBeanTwoArg_install.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/test/PlainMBeanTwoArg_install.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/test/PlainMBeanTwoArg_install.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+   <mbean name="jboss.test:type=test" code="org.jboss.test.system.controller.support.Simple">
+      <constructor>
+         <arg type="int" value="5"/>
+         <arg type="float" value="3.14"/>
+      </constructor>
+   </mbean>
+</server>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/test/StandardMBeanNoArg_install.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/test/StandardMBeanNoArg_install.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/test/StandardMBeanNoArg_install.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+   <mbean name="jboss.test:type=test" code="org.jboss.test.system.controller.support.Simple"
+          interface="org.jboss.test.system.controller.support.SimpleMBean">
+   </mbean>
+</server>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/test/StandardMBeanOneArg_install.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/test/StandardMBeanOneArg_install.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/test/StandardMBeanOneArg_install.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+   <mbean name="jboss.test:type=test" code="org.jboss.test.system.controller.support.Simple"
+          interface="org.jboss.test.system.controller.support.SimpleMBean">
+      <constructor>
+         <arg type="int" value="5"/>
+      </constructor>
+   </mbean>
+</server>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/test/StandardMBeanTwoArg_install.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/test/StandardMBeanTwoArg_install.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/controller/instantiate/test/StandardMBeanTwoArg_install.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+   <mbean name="jboss.test:type=test" code="org.jboss.test.system.controller.support.Simple"
+          interface="org.jboss.test.system.controller.support.SimpleMBean">
+      <constructor>
+         <arg type="int" value="5"/>
+         <arg type="float" value="3.14"/>
+      </constructor>
+   </mbean>
+</server>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsListNested_NotAutomatic.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsListNested_NotAutomatic.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsListNested_NotAutomatic.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+   <mbean name="test:name=1" code="org.jboss.test.system.controller.support.Simple">
+      <depends-list>
+         <depends-list-element>
+            <mbean name="test:name=2" code="org.jboss.test.system.controller.support.Simple"/>
+         </depends-list-element>
+      </depends-list>
+   </mbean>
+</server>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsList_NotAutomatic.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsList_NotAutomatic.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsList_NotAutomatic.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+   <mbean name="test:name=1" code="org.jboss.test.system.controller.support.Simple">
+      <depends-list>
+         <depends-list-element>test:name=2</depends-list-element>
+      </depends-list>
+   </mbean>
+   <mbean name="test:name=2" code="org.jboss.test.system.controller.support.Simple"/>
+</server>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsNested_NotAutomatic.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsNested_NotAutomatic.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsNested_NotAutomatic.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+   <mbean name="test:name=1" code="org.jboss.test.system.controller.support.Simple">
+      <depends>
+         <mbean name="test:name=2" code="org.jboss.test.system.controller.support.Simple"/>
+      </depends>
+   </mbean>
+</server>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsOptionalAttributeListNested_NotAutomatic.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsOptionalAttributeListNested_NotAutomatic.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsOptionalAttributeListNested_NotAutomatic.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+   <mbean name="test:name=1" code="org.jboss.test.system.controller.support.Simple">
+      <depends-list optional-attribute-name="ObjectNames">
+         <depends-list-element>
+            <mbean name="test:name=2" code="org.jboss.test.system.controller.support.Simple"/>
+         </depends-list-element>
+      </depends-list>
+   </mbean>
+</server>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsOptionalAttributeList_NotAutomatic.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsOptionalAttributeList_NotAutomatic.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsOptionalAttributeList_NotAutomatic.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+   <mbean name="test:name=1" code="org.jboss.test.system.controller.support.Simple">
+      <depends-list optional-attribute-name="ObjectNames">
+         <depends-list-element>test:name=2</depends-list-element>
+      </depends-list>
+   </mbean>
+   <mbean name="test:name=2" code="org.jboss.test.system.controller.support.Simple"/>
+</server>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsOptionalAttributeNested_NotAutomatic.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsOptionalAttributeNested_NotAutomatic.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsOptionalAttributeNested_NotAutomatic.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+   <mbean name="test:name=1" code="org.jboss.test.system.controller.support.Simple">
+      <depends optional-attribute-name="ObjectName">
+         <mbean name="test:name=2" code="org.jboss.test.system.controller.support.Simple"/>
+      </depends>
+   </mbean>
+</server>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsOptionalAttribute_NotAutomatic.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsOptionalAttribute_NotAutomatic.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsOptionalAttribute_NotAutomatic.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+   <mbean name="test:name=1" code="org.jboss.test.system.controller.support.Simple">
+      <depends optional-attribute-name="ObjectName">test:name=2</depends>
+   </mbean>
+   <mbean name="test:name=2" code="org.jboss.test.system.controller.support.Simple"/>
+</server>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDepends_NotAutomatic.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDepends_NotAutomatic.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDepends_NotAutomatic.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+   <mbean name="test:name=1" code="org.jboss.test.system.controller.support.Simple">
+      <depends>test:name=2</depends>
+   </mbean>
+   <mbean name="test:name=2" code="org.jboss.test.system.controller.support.Simple"/>
+</server>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicLifecycle_NotAutomatic.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicLifecycle_NotAutomatic.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicLifecycle_NotAutomatic.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+   <mbean name="jboss.test:type=test" code="org.jboss.test.system.controller.support.Simple"/>
+</server>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/controller/lifecycle/seperated/test/SeperatedDependencyDepends_1.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/controller/lifecycle/seperated/test/SeperatedDependencyDepends_1.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/controller/lifecycle/seperated/test/SeperatedDependencyDepends_1.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+   <mbean name="test:name=1" code="org.jboss.test.system.controller.support.Simple"/>
+</server>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/controller/lifecycle/seperated/test/SeperatedDependencyDepends_2.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/controller/lifecycle/seperated/test/SeperatedDependencyDepends_2.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/controller/lifecycle/seperated/test/SeperatedDependencyDepends_2.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+   <mbean name="test:name=2" code="org.jboss.test.system.controller.support.Simple">
+      <depends>test:name=1</depends>
+   </mbean>
+</server>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/controller/parse/test/CodeEmpty.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/controller/parse/test/CodeEmpty.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/controller/parse/test/CodeEmpty.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+   <mbean name="jboss.test:type=test" code=""/>
+</server>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/controller/parse/test/CodeMissing.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/controller/parse/test/CodeMissing.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/controller/parse/test/CodeMissing.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+   <mbean name="jboss.test:type=test"/>
+</server>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/controller/parse/test/ConstructorTypeEmpty.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/controller/parse/test/ConstructorTypeEmpty.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/controller/parse/test/ConstructorTypeEmpty.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+   <mbean name="jboss.test:type=test" code="org.jboss.test.system.controller.support.Simple">
+      <constructor>
+         <arg value="param1"/>
+      </constructor>
+   </mbean>
+</server>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/controller/parse/test/ConstructorTypeMissing.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/controller/parse/test/ConstructorTypeMissing.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/controller/parse/test/ConstructorTypeMissing.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+   <mbean name="jboss.test:type=test" code="org.jboss.test.system.controller.support.Simple">
+      <constructor>
+         <arg value="param1"/>
+      </constructor>
+   </mbean>
+</server>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/controller/parse/test/ConstructorValueMissing.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/controller/parse/test/ConstructorValueMissing.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/controller/parse/test/ConstructorValueMissing.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+   <mbean name="jboss.test:type=test" code="org.jboss.test.system.controller.support.Simple">
+      <constructor>
+         <arg type="int"/>
+      </constructor>
+   </mbean>
+</server>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/controller/parse/test/NameEmpty.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/controller/parse/test/NameEmpty.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/controller/parse/test/NameEmpty.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+   <mbean name="" code="org.jboss.test.system.controller.support.Simple"/>
+</server>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/controller/parse/test/NameInvalid.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/controller/parse/test/NameInvalid.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/controller/parse/test/NameInvalid.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+   <mbean name="InvalidObjectName" code="org.jboss.test.system.controller.support.Simple"/>
+</server>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/controller/parse/test/NameMissing.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/controller/parse/test/NameMissing.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/controller/parse/test/NameMissing.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+   <mbean code="org.jboss.test.system.controller.support.Simple"/>
+</server>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/metadata/basic/test/BasicMBean.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/metadata/basic/test/BasicMBean.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/metadata/basic/test/BasicMBean.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,3 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<mbean name="jboss.test:type=BasicMBeanName" code="BasicMBeanCode"/>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/metadata/basic/test/BasicMBeanEmptyCode.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/metadata/basic/test/BasicMBeanEmptyCode.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/metadata/basic/test/BasicMBeanEmptyCode.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,3 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<mbean name="jboss.test:type=BasicMBeanName" code=""/>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/metadata/basic/test/BasicMBeanEmptyName.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/metadata/basic/test/BasicMBeanEmptyName.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/metadata/basic/test/BasicMBeanEmptyName.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,3 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<mbean name="" code="BasicMBeanCode"/>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/metadata/basic/test/BasicMBeanInterface.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/metadata/basic/test/BasicMBeanInterface.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/metadata/basic/test/BasicMBeanInterface.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,3 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<mbean name="jboss.test:type=BasicMBeanName" code="BasicMBeanCode" interface="BasicMBeanInterface"/>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/metadata/basic/test/BasicMBeanInvalidName.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/metadata/basic/test/BasicMBeanInvalidName.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/metadata/basic/test/BasicMBeanInvalidName.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,3 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<mbean name="INVALID" code="BasicMBeanCode"/>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/metadata/basic/test/BasicMBeanNoCode.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/metadata/basic/test/BasicMBeanNoCode.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/metadata/basic/test/BasicMBeanNoCode.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,3 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<mbean name="jboss.test:type=BasicMBeanName"/>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/metadata/basic/test/BasicMBeanNoName.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/metadata/basic/test/BasicMBeanNoName.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/metadata/basic/test/BasicMBeanNoName.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,3 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<mbean code="BasicMBeanCode"/>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/metadata/constructor/test/ConstructorDefault.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/metadata/constructor/test/ConstructorDefault.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/metadata/constructor/test/ConstructorDefault.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<mbean name="jboss.test:type=BasicMBeanName" code="BasicMBeanCode">
+   <constructor/>
+</mbean>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/metadata/constructor/test/ConstructorEmptyType.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/metadata/constructor/test/ConstructorEmptyType.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/metadata/constructor/test/ConstructorEmptyType.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<mbean name="jboss.test:type=BasicMBeanName" code="BasicMBeanCode">
+   <constructor>
+      <arg type="" value="param1"/>
+   </constructor>
+</mbean>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/metadata/constructor/test/ConstructorEmptyValue.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/metadata/constructor/test/ConstructorEmptyValue.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/metadata/constructor/test/ConstructorEmptyValue.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<mbean name="jboss.test:type=BasicMBeanName" code="BasicMBeanCode">
+   <constructor>
+      <arg type="signature1" value=""/>
+   </constructor>
+</mbean>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/metadata/constructor/test/ConstructorNoType.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/metadata/constructor/test/ConstructorNoType.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/metadata/constructor/test/ConstructorNoType.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<mbean name="jboss.test:type=BasicMBeanName" code="BasicMBeanCode">
+   <constructor>
+      <arg value="param1"/>
+   </constructor>
+</mbean>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/metadata/constructor/test/ConstructorNoValue.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/metadata/constructor/test/ConstructorNoValue.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/metadata/constructor/test/ConstructorNoValue.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<mbean name="jboss.test:type=BasicMBeanName" code="BasicMBeanCode">
+   <constructor>
+      <arg type="signature1"/>
+   </constructor>
+</mbean>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/metadata/constructor/test/ConstructorOneArg.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/metadata/constructor/test/ConstructorOneArg.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/metadata/constructor/test/ConstructorOneArg.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<mbean name="jboss.test:type=BasicMBeanName" code="BasicMBeanCode">
+   <constructor>
+      <arg type="signature1" value="param1"/>
+   </constructor>
+</mbean>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/metadata/constructor/test/ConstructorTwoArgs.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/metadata/constructor/test/ConstructorTwoArgs.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/metadata/constructor/test/ConstructorTwoArgs.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<mbean name="jboss.test:type=BasicMBeanName" code="BasicMBeanCode">
+   <constructor>
+      <arg type="signature1" value="param1"/>
+      <arg type="signature2" value="param2"/>
+   </constructor>
+</mbean>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsEmpty.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsEmpty.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsEmpty.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<mbean name="jboss.test:type=BasicMBeanName" code="BasicMBeanCode">
+   <depends/>
+</mbean>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsInvalidObjectName.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsInvalidObjectName.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsInvalidObjectName.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<mbean name="jboss.test:type=BasicMBeanName" code="BasicMBeanCode">
+   <depends>InvalidObjectName</depends>
+</mbean>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsListElementEmpty.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsListElementEmpty.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsListElementEmpty.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<mbean name="jboss.test:type=BasicMBeanName" code="BasicMBeanCode">
+   <depends-list>
+      <depends-list-element/>
+   </depends-list>
+</mbean>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsListElementNoNestedMBean.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsListElementNoNestedMBean.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsListElementNoNestedMBean.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<mbean name="jboss.test:type=BasicMBeanName" code="BasicMBeanCode">
+   <depends-list>
+      <depends-list-element><dummy/></depends-list-element>
+   </depends-list>
+</mbean>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsListInvalidObjectName.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsListInvalidObjectName.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsListInvalidObjectName.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<mbean name="jboss.test:type=BasicMBeanName" code="BasicMBeanCode">
+   <depends-list>
+      <depends-list-element>InvalidObjectName</depends-list-element>
+   </depends-list>
+</mbean>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsListNestedMBean.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsListNestedMBean.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsListNestedMBean.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<mbean name="jboss.test:type=BasicMBeanName" code="BasicMBeanCode">
+   <depends-list>
+      <depends-list-element>
+          <mbean name="test:test=1" code="NestedMBeanCode"/>
+      </depends-list-element>
+   </depends-list>
+</mbean>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsListNone.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsListNone.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsListNone.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<mbean name="jboss.test:type=BasicMBeanName" code="BasicMBeanCode">
+   <depends-list/>
+</mbean>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsListOne.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsListOne.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsListOne.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<mbean name="jboss.test:type=BasicMBeanName" code="BasicMBeanCode">
+   <depends-list>
+      <depends-list-element>test:test=1</depends-list-element>
+   </depends-list>
+</mbean>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsListOptionalAttribute.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsListOptionalAttribute.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsListOptionalAttribute.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<mbean name="jboss.test:type=BasicMBeanName" code="BasicMBeanCode">
+   <depends-list optional-attribute-name="AttributeName">
+      <depends-list-element>test:test=1</depends-list-element>
+   </depends-list>
+</mbean>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsListOptionalAttributeElementEmpty.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsListOptionalAttributeElementEmpty.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsListOptionalAttributeElementEmpty.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<mbean name="jboss.test:type=BasicMBeanName" code="BasicMBeanCode">
+   <depends-list optional-attribute-name="AttributeName">
+      <depends-list-element/>
+   </depends-list>
+</mbean>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsListOptionalAttributeElementNoNestedMBean.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsListOptionalAttributeElementNoNestedMBean.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsListOptionalAttributeElementNoNestedMBean.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<mbean name="jboss.test:type=BasicMBeanName" code="BasicMBeanCode">
+   <depends-list optional-attribute-name="AttributeName">
+      <depends-list-element><dummy/></depends-list-element>
+   </depends-list>
+</mbean>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsListOptionalAttributeInvalidObjectName.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsListOptionalAttributeInvalidObjectName.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsListOptionalAttributeInvalidObjectName.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<mbean name="jboss.test:type=BasicMBeanName" code="BasicMBeanCode">
+   <depends-list optional-attribute-name="AttributeName">
+      <depends-list-element>InvalidObjectName</depends-list-element>
+   </depends-list>
+</mbean>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsListOptionalAttributeNestedMBean.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsListOptionalAttributeNestedMBean.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsListOptionalAttributeNestedMBean.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<mbean name="jboss.test:type=BasicMBeanName" code="BasicMBeanCode">
+   <depends-list optional-attribute-name="AttributeName">
+      <depends-list-element>
+          <mbean name="test:test=1" code="NestedMBeanCode"/>
+      </depends-list-element>
+   </depends-list>
+</mbean>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsListTwo.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsListTwo.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsListTwo.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<mbean name="jboss.test:type=BasicMBeanName" code="BasicMBeanCode">
+   <depends-list>
+      <depends-list-element>test:test=1</depends-list-element>
+      <depends-list-element>test:test=2</depends-list-element>
+   </depends-list>
+</mbean>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsNestedMBean.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsNestedMBean.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsNestedMBean.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<mbean name="jboss.test:type=BasicMBeanName" code="BasicMBeanCode">
+   <depends>
+      <mbean name="test:test=1" code="NestedMBeanCode"/>
+   </depends>
+</mbean>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsNoNestedMBean.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsNoNestedMBean.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsNoNestedMBean.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<mbean name="jboss.test:type=BasicMBeanName" code="BasicMBeanCode">
+   <depends><dummy/></depends>
+</mbean>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsNone.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsNone.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsNone.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,3 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<mbean name="jboss.test:type=BasicMBeanName" code="BasicMBeanCode"/>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsOne.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsOne.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsOne.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<mbean name="jboss.test:type=BasicMBeanName" code="BasicMBeanCode">
+   <depends>test:test=1</depends>
+</mbean>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsOptionalAttribute.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsOptionalAttribute.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsOptionalAttribute.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<mbean name="jboss.test:type=BasicMBeanName" code="BasicMBeanCode">
+   <depends optional-attribute-name="AttributeName">test:test=1</depends>
+</mbean>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsOptionalAttributeEmpty.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsOptionalAttributeEmpty.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsOptionalAttributeEmpty.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<mbean name="jboss.test:type=BasicMBeanName" code="BasicMBeanCode">
+   <depends optional-attribute-name="AttributeName"/>
+</mbean>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsOptionalAttributeInvalidObjectName.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsOptionalAttributeInvalidObjectName.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsOptionalAttributeInvalidObjectName.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<mbean name="jboss.test:type=BasicMBeanName" code="BasicMBeanCode">
+   <depends optional-attribute-name="AttributeName">InvalidObjectName</depends>
+</mbean>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsOptionalAttributeNestedMBean.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsOptionalAttributeNestedMBean.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsOptionalAttributeNestedMBean.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<mbean name="jboss.test:type=BasicMBeanName" code="BasicMBeanCode">
+   <depends optional-attribute-name="AttributeName">
+      <mbean name="test:test=1" code="NestedMBeanCode"/>
+   </depends>
+</mbean>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsOptionalAttributeNoNestedMBean.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsOptionalAttributeNoNestedMBean.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsOptionalAttributeNoNestedMBean.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<mbean name="jboss.test:type=BasicMBeanName" code="BasicMBeanCode">
+   <depends optional-attribute-name="AttributeName"><dummy/></depends>
+</mbean>
\ No newline at end of file

Added: trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsTwo.xml
===================================================================
--- trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsTwo.xml	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/resources/tests/org/jboss/test/system/metadata/depends/test/DependsTwo.xml	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<mbean name="jboss.test:type=BasicMBeanName" code="BasicMBeanCode">
+   <depends>test:test=1</depends>
+   <depends>test:test=2</depends>
+</mbean>
\ No newline at end of file

Added: trunk/system/src/tests/org/jboss/test/AbstractSystemTest.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/AbstractSystemTest.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/AbstractSystemTest.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,84 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test;
+
+import org.jboss.logging.Logger;
+import org.jboss.util.UnexpectedThrowable;
+
+/**
+ * A SystemTest.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.2 $
+ */
+public class AbstractSystemTest extends AbstractTestCaseWithSetup
+{
+   private static Logger staticLog = Logger.getLogger(AbstractSystemTest.class);
+   
+   // @fixme move to AbstractTestCase
+   public static void checkThrowableDeep(Class<? extends Throwable> expected, Throwable throwable) throws Exception
+   {
+      assertNotNull(expected);
+      assertNotNull(throwable);
+      
+      Throwable original = throwable;
+      
+      while (throwable.getCause() != null)
+         throwable = throwable.getCause();
+      
+      if (expected.equals(throwable.getClass()) == false)
+      {
+         if (original instanceof Exception)
+            throw (Exception) original;
+         else
+            throw new UnexpectedThrowable("UnexpectedThrowable", original);
+      }
+      else
+      {
+         staticLog.debug("Got expected " + expected.getName() + "(" + throwable + ")");
+      }
+   }
+   
+   /**
+    * Create a new ContainerTest.
+    * 
+    * @param name the test name
+    */
+   public AbstractSystemTest(String name)
+   {
+      super(name);
+   }
+   
+   /**
+    * Default setup with security manager enabled
+    * 
+    * @param clazz the class
+    * @return the delegate
+    * @throws Exception for any error
+    */
+   public static AbstractTestDelegate getDelegate(Class clazz) throws Exception
+   {
+      AbstractTestDelegate delegate = new AbstractTestDelegate(clazz);
+      delegate.enableSecurity = true;
+      return delegate;
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/SystemAllTestSuite.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/SystemAllTestSuite.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/SystemAllTestSuite.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,51 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test;
+
+import org.jboss.test.system.SystemTestSuite;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * All Test Suite.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.8 $
+ */
+public class SystemAllTestSuite extends TestSuite
+{
+   public static void main(String[] args)
+   {
+      TestRunner.run(suite());
+   }
+
+   public static Test suite()
+   {
+      TestSuite suite = new TestSuite("All Tests");
+
+      suite.addTest(SystemTestSuite.suite());
+      
+      return suite;
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/SystemTestSuite.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/SystemTestSuite.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/SystemTestSuite.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,53 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+import org.jboss.test.system.controller.test.ControllerTestSuite;
+import org.jboss.test.system.metadata.test.MetaDataTestSuite;
+
+/**
+ * System Test Suite.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.8 $
+ */
+public class SystemTestSuite extends TestSuite
+{
+   public static void main(String[] args)
+   {
+      TestRunner.run(suite());
+   }
+
+   public static Test suite()
+   {
+      TestSuite suite = new TestSuite("System Tests");
+
+      suite.addTest(MetaDataTestSuite.suite());
+      suite.addTest(ControllerTestSuite.suite());
+      
+      return suite;
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/AbstractControllerTest.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/AbstractControllerTest.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/AbstractControllerTest.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,268 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller;
+
+import java.net.URL;
+import java.util.Collections;
+import java.util.List;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.jboss.system.ServiceContext;
+import org.jboss.system.ServiceControllerMBean;
+import org.jboss.test.AbstractSystemTest;
+import org.jboss.test.AbstractTestDelegate;
+import org.jboss.test.system.controller.support.Order;
+import org.jboss.test.system.controller.support.SimpleMBean;
+
+/**
+ * A Controller Test.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.2 $
+ */
+public abstract class AbstractControllerTest extends AbstractSystemTest
+{
+   public static boolean OLD_NOT_REGISTERED = false; 
+   public static boolean OLD_REGISTERED = true;
+   
+   /**
+    * Create a new ContainerTest.
+    * 
+    * @param name the test name
+    */
+   public AbstractControllerTest(String name)
+   {
+      super(name);
+   }
+   
+   public static AbstractTestDelegate getNewControllerDelegate(Class clazz) throws Exception
+   {
+      ControllerTestDelegate delegate = new NewControllerTestDelegate(clazz);
+      // @todo delegate.enableSecurity = true;
+      return delegate;
+   }
+   
+   public static AbstractTestDelegate getOldControllerDelegate(Class clazz) throws Exception
+   {
+      ControllerTestDelegate delegate = new OldControllerTestDelegate(clazz);
+      // @todo delegate.enableSecurity = true;
+      return delegate;
+   }
+   
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+      Order.reset();
+   }
+
+   protected void tearDown() throws Exception
+   {
+      getControllerDelegate().uninstallTemporary();
+      super.tearDown();
+   }
+
+   protected ControllerTestDelegate getControllerDelegate()
+   {
+      return (ControllerTestDelegate) getDelegate();
+   }
+   
+   protected MBeanServer getServer()
+   {
+      return getControllerDelegate().getServer();
+   }
+   
+   protected ServiceControllerMBean getController()
+   {
+      return getControllerDelegate().getController();
+   }
+   
+   protected List<ObjectName> deploy(URL url) throws Exception
+   {
+      return getControllerDelegate().deploy(url, true);
+   }
+   
+   protected List<ObjectName> deploy(String resource) throws Exception
+   {
+      URL url = getResourceURL(resource);
+      return deploy(url);
+   }
+   
+   protected void undeploy(List<ObjectName> objectNames)
+   {
+      getControllerDelegate().undeploy(objectNames);
+   }
+   
+   protected List<ObjectName> install(String resource) throws Exception
+   {
+      URL url = getResourceURL(resource);
+      return install(url);
+   }
+   
+   protected List<ObjectName> install(URL url) throws Exception
+   {
+      return getControllerDelegate().install(url);
+   }
+   
+   protected void uninstall(List<ObjectName> objectNames)
+   {
+      getControllerDelegate().uninstall(objectNames);
+   }
+
+   protected void assertInstall(ObjectName name) throws Exception
+   {
+      
+      String resource = getName();
+      resource = resource.substring(4) + "_install.xml";
+      install(resource);
+      
+      assertServiceConfigured(name);
+      assertRegistered(name);
+   }
+
+   protected void assertUninstall(ObjectName name) throws Exception
+   {
+      uninstall(Collections.singletonList(name));
+      assertNoService(name);
+      assertNotRegistered(name);
+   }
+   
+   protected void validate() throws Exception
+   {
+      getControllerDelegate().validate();
+   }
+   
+   protected void assertInvalidDeployments() throws Exception
+   {
+      getControllerDelegate().assertInvalidDeployments();
+   }
+   
+   protected void assertDeployFailure(String resource, Class<? extends Throwable> expected) throws Exception
+   {
+      try
+      {
+         deploy(resource);
+         fail("Should have got a " + expected.getName());
+      }
+      catch (Throwable t)
+      {
+         AbstractSystemTest.checkThrowableDeep(expected, t);
+      }
+   }
+   
+   protected void assertMaybeDeployFailure(ObjectName name, Class<? extends Throwable> expected) throws Exception
+   {
+      String resource = getName();
+      resource = resource.substring(4) + "_bad.xml";
+      assertMaybeDeployFailure(resource, name, expected);
+   }
+   
+   protected void assertMaybeDeployFailure(String resource, ObjectName name, Class<? extends Throwable> expected) throws Exception
+   {
+      URL url = getResourceURL(resource);
+      getControllerDelegate().assertMaybeDeployFailure(url, name, expected);
+      assertServiceFailed(SimpleMBean.OBJECT_NAME, false);
+   }
+   
+   protected ServiceContext getServiceContext(ObjectName name) throws Exception
+   {
+      assertNotNull(name);
+      return getController().getServiceContext(name);
+   }
+   
+   protected void assertServiceFailed(ObjectName name) throws Exception
+   {
+      assertServiceFailed(name, OLD_REGISTERED);
+   }
+   
+   protected void assertServiceFailed(ObjectName name, boolean registered) throws Exception
+   {
+      assertServiceState(name, ServiceContext.FAILED, registered);
+      getControllerDelegate().assertMBeanFailed(name, registered);
+   }
+   
+   protected void assertServiceConfigured(ObjectName name) throws Exception
+   {
+      assertServiceState(name, ServiceContext.CONFIGURED, true);
+   }
+   
+   protected void assertServiceCreated(ObjectName name) throws Exception
+   {
+      assertServiceState(name, ServiceContext.CREATED, true);
+   }
+   
+   protected void assertServiceRunning(ObjectName name) throws Exception
+   {
+      assertServiceState(name, ServiceContext.RUNNING, true);
+   }
+   
+   protected void assertServiceStopped(ObjectName name) throws Exception
+   {
+      assertServiceState(name, ServiceContext.STOPPED, true);
+   }
+   
+   protected void assertServiceDestroyed(ObjectName name) throws Exception
+   {
+      assertServiceState(name, ServiceContext.DESTROYED, true);
+   }
+   
+   protected void assertServiceState(ObjectName name, int expectedState) throws Exception
+   {
+      ServiceContext ctx = getServiceContext(name);
+      assertTrue("Incorrect state for " + name + " expected " + ServiceContext.getStateString(expectedState) + " got " + ctx.getStateString(), expectedState == ctx.state);
+   }
+   
+   protected void assertServiceState(ObjectName name, int expectedState, boolean registered) throws Exception
+   {
+      ServiceContext ctx = getServiceContext(name);
+      if (registered == false && ctx == null)
+         return;
+      assertTrue("Incorrect state for " + name + " expected " + ServiceContext.getStateString(expectedState) + " got " + ctx.getStateString(), expectedState == ctx.state);
+   }
+   
+   protected void assertNoService(ObjectName name) throws Exception
+   {
+      ServiceContext ctx = getServiceContext(name);
+      assertNull("Should not be a service context for " + name, ctx);
+   }
+   
+   protected URL getResourceURL(String resource) throws Exception
+   {
+      URL url = getClass().getResource(resource);
+      if (url == null)
+         throw new IllegalArgumentException("Resource not found: " + resource);
+      return url;
+   }
+   
+   protected void assertRegistered(ObjectName name) throws Exception
+   {
+      MBeanServer server = getServer();
+      assertTrue(name + " should be registered in the MBeanServer", server.isRegistered(name));
+   }
+   
+   protected void assertNotRegistered(ObjectName name) throws Exception
+   {
+      MBeanServer server = getServer();
+      assertFalse(name + " should NOT be registered in the MBeanServer", server.isRegistered(name));
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/ControllerTestDelegate.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/ControllerTestDelegate.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/ControllerTestDelegate.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,225 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller;
+
+import java.net.URL;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+import javax.management.ObjectName;
+
+import junit.framework.AssertionFailedError;
+
+import org.jboss.deployment.IncompleteDeploymentException;
+import org.jboss.system.ServiceContext;
+import org.jboss.system.ServiceControllerMBean;
+import org.jboss.test.AbstractSystemTest;
+import org.jboss.test.AbstractTestDelegate;
+import org.jboss.test.system.controller.support.Order;
+
+/**
+ * ControllerTestDelegate.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class ControllerTestDelegate extends AbstractTestDelegate
+{
+   private MBeanServer server; 
+   
+   private ServiceControllerMBean serviceController;
+
+   private SimpleSARDeployer deployer;
+   
+   public ControllerTestDelegate(Class clazz)
+   {
+      super(clazz);
+   }
+
+   public MBeanServer getServer()
+   {
+      return server;
+   }
+
+   public ServiceControllerMBean getController()
+   {
+      return serviceController;
+   }
+   
+   public void setUp() throws Exception
+   {
+      super.setUp();
+      
+      //System.setProperty(ServerConstants.MBEAN_SERVER_BUILDER_CLASS_PROPERTY, ServerConstants.DEFAULT_MBEAN_SERVER_BUILDER_CLASS);
+      server = MBeanServerFactory.createMBeanServer("jboss");
+      serviceController = createServiceController();
+      server.registerMBean(serviceController, ServiceControllerMBean.OBJECT_NAME);
+      
+      deployer = new SimpleSARDeployer(server, serviceController);
+
+      Order.reset();
+      
+      deploy();
+      
+      validate();
+   }
+
+   public abstract ServiceControllerMBean createServiceController();
+   
+   public void tearDown() throws Exception
+   {
+      deployer.uninstall();
+      super.tearDown();
+   }
+
+   protected void uninstallTemporary() throws Exception
+   {
+      deployer.uninstallTemporary();
+   }
+   
+   protected void validate() throws Exception
+   {
+      Collection<ServiceContext> waitingForClasses = new HashSet<ServiceContext>();
+      Collection<ServiceContext> waitingForDepends = serviceController.listIncompletelyDeployed();
+      Collection<ServiceContext> allServices = serviceController.listDeployed();
+      
+      // Weed services that are waiting for other deployments
+      Collection<ServiceContext> rootCause = new HashSet<ServiceContext>(waitingForDepends);
+      Collection<ServiceContext> missing = new HashSet<ServiceContext>();
+      for (Iterator i = rootCause.iterator(); i.hasNext();)
+      {
+         ServiceContext ctx = (ServiceContext) i.next();
+         for (Iterator j = ctx.iDependOn.iterator(); j.hasNext(); )
+         {
+            ServiceContext dependee = (ServiceContext) j.next();
+            if (dependee.state != ServiceContext.RUNNING)
+            {
+               // Add missing mbean
+               if (allServices.contains(dependee) == false)
+                  missing.add(dependee);
+               // We are not a root cause
+               i.remove();
+               break;
+            }
+         }
+      }
+      // Add missing mbeans to the root cause
+      rootCause.addAll(missing);
+      
+      IncompleteDeploymentException ide = new IncompleteDeploymentException(
+         waitingForClasses,
+         waitingForDepends,
+         rootCause,
+         Collections.emptyList(),
+         Collections.emptyList());
+
+      if (ide.isEmpty() == false)
+         throw ide;
+   }
+   
+   protected void deploy() throws Exception
+   {
+      String testName = clazz.getName();
+      testName = testName.replace('.', '/');
+
+      int index = testName.indexOf("NewUnitTestCase");
+      if (index != -1)
+         testName = testName.substring(0, index);
+      index = testName.indexOf("OldUnitTestCase");
+      if (index != -1)
+         testName = testName.substring(0, index);
+      
+      testName += ".xml";
+      
+      URL url = clazz.getClassLoader().getResource(testName);
+      if (url != null)
+         deploy(url, false);
+      else
+         log.debug("No test specific deployment " + testName);
+   }
+
+   protected List<ObjectName> deploy(URL url, boolean temporary) throws Exception
+   {
+      return deployer.deploy(url, temporary);
+   }
+   
+   protected void undeploy(List<ObjectName> objectNames)
+   {
+      deployer.undeploy(objectNames);
+   }
+
+   protected List<ObjectName> install(URL url) throws Exception
+   {
+      return deployer.install(url);
+   }
+   
+   protected void uninstall(List<ObjectName> objectNames)
+   {
+      deployer.uninstall(objectNames);
+   }
+   
+   public abstract void assertMBeanFailed(ObjectName name, boolean registered) throws Exception;
+   
+   protected IncompleteDeploymentException assertInvalidDeployments() throws Exception
+   {
+      try
+      {
+         validate();
+         throw new AssertionFailedError("Deployments should not be valid!");
+      }
+      catch (IncompleteDeploymentException expected)
+      {
+         log.debug("Got expected " + expected.getClass().getName());
+         return expected;
+      }
+   }
+   
+   public void assertMaybeDeployFailure(URL url, ObjectName name, Class<? extends Throwable> expected) throws Exception
+   {
+      deploy(url, true);
+      IncompleteDeploymentException e = assertInvalidDeployments();
+      checkIncomplete(e, name, expected);
+   }
+   
+   protected void checkIncomplete(IncompleteDeploymentException e, ObjectName name, Class<? extends Throwable> expected) throws Exception
+   {
+      Collection incomplete = e.getMbeansWaitingForDepends();
+      for (Iterator i = incomplete.iterator(); i.hasNext();)
+      {
+         ServiceContext ctx = (ServiceContext) i.next();
+         if (name.equals(ctx.objectName))
+         {
+            if (ctx.problem == null)
+               throw new AssertionFailedError("Did got get expected " + expected.getName() + " for " + ctx);
+            AbstractSystemTest.checkThrowableDeep(expected, ctx.problem);
+            return;
+         }
+      }
+      
+      throw new AssertionFailedError("Did not find " + name + " in incomplete deployments " + incomplete);
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/NewControllerTestDelegate.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/NewControllerTestDelegate.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/NewControllerTestDelegate.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,56 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.jboss.system.ServiceController;
+import org.jboss.system.ServiceControllerMBean;
+
+import junit.framework.AssertionFailedError;
+
+/**
+ * ControllerTestDelegate.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class NewControllerTestDelegate extends ControllerTestDelegate
+{
+   public NewControllerTestDelegate(Class clazz)
+   {
+      super(clazz);
+   }
+   
+   public ServiceControllerMBean createServiceController()
+   {
+      return new ServiceController();
+   }
+
+   public void assertMBeanFailed(ObjectName name, boolean registered) throws Exception
+   {
+      MBeanServer server = getServer();
+      if (server.isRegistered(name))
+         throw new AssertionFailedError(name + " should not be registered after a failure");
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/OldControllerTestDelegate.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/OldControllerTestDelegate.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/OldControllerTestDelegate.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,81 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller;
+
+import java.net.URL;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import junit.framework.AssertionFailedError;
+
+import org.jboss.system.ServiceControllerMBean;
+import org.jboss.test.AbstractSystemTest;
+import org.jboss.test.system.controller.legacy.OldServiceController;
+
+/**
+ * ControllerTestDelegate.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class OldControllerTestDelegate extends ControllerTestDelegate
+{
+   public OldControllerTestDelegate(Class clazz)
+   {
+      super(clazz);
+   }
+   
+   public ServiceControllerMBean createServiceController()
+   {
+      return new OldServiceController();
+   }
+   
+   public void assertMBeanFailed(ObjectName name, boolean registered) throws Exception
+   {
+      MBeanServer server = getServer();
+      if (registered == false && server.isRegistered(name))
+         throw new AssertionFailedError(name + " should not be registered after a failure");
+      if (registered && server.isRegistered(name) == false)
+         throw new AssertionFailedError(name + " should be registered after a failure");
+   }
+
+   public void assertMaybeDeployFailure(URL url, ObjectName name, Class<? extends Throwable> expected) throws Exception
+   {
+      if (expected != null)
+      {
+         try
+         {
+            deploy(url, true);
+            throw new AssertionFailedError("Should have got a " + expected.getName());
+         }
+         catch (Throwable throwable)
+         {
+            AbstractSystemTest.checkThrowableDeep(expected, throwable);
+         }
+      }
+      else
+      {
+         super.assertMaybeDeployFailure(url, name, expected);
+      }
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/SimpleSARDeployer.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/SimpleSARDeployer.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/SimpleSARDeployer.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,235 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller;
+
+import java.io.InputStream;
+import java.net.URL;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.jboss.deployment.DeploymentException;
+import org.jboss.logging.Logger;
+import org.jboss.mx.util.ObjectNameFactory;
+import org.jboss.system.ServiceControllerMBean;
+import org.jboss.util.xml.JBossEntityResolver;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.InputSource;
+
+/**
+ * SimpleSARDeployer.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class SimpleSARDeployer
+{
+   private static Logger log = Logger.getLogger(SimpleSARDeployer.class);
+   
+   public static ObjectName classLoaderObjectName = ObjectNameFactory.create("test:classloader=test");
+   
+   private ServiceControllerMBean serviceController;
+
+   private List<ObjectName> deployed = new CopyOnWriteArrayList<ObjectName>();
+
+   private List<ObjectName> tempDeployed = new CopyOnWriteArrayList<ObjectName>();
+   
+   private DocumentBuilder parser;
+   
+   public SimpleSARDeployer(MBeanServer server, ServiceControllerMBean serviceController) throws Exception
+   {
+      this.serviceController = serviceController;
+      
+      TestClassLoader classLoader = new TestClassLoader();
+      server.registerMBean(classLoader, classLoaderObjectName);
+
+      DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+      parser = factory.newDocumentBuilder();
+   }
+
+   public List<ObjectName> deploy(URL url, boolean temporary) throws Exception
+   {
+      long start = System.currentTimeMillis();
+      
+      List<ObjectName> result = doInstall(url, temporary);
+
+      try
+      {
+         create(result);
+         try
+         {
+            start(result);
+         }
+         catch (Throwable t)
+         {
+            stop(result);
+            throw t;
+         }
+      }
+      catch (Throwable t)
+      {
+         destroy(result);
+         remove(result);
+         DeploymentException.rethrowAsDeploymentException("Error", t);
+      }
+      
+      log.debug("Deployed " + url + " took " + (System.currentTimeMillis() - start) + "ms");
+      return result;
+   }
+   
+   public void uninstall()
+   {
+      undeploy(deployed);
+   }
+   
+   public void uninstallTemporary()
+   {
+      undeploy(tempDeployed);
+   }
+   
+   public void undeploy(List<ObjectName> objectNames)
+   {
+      stop(objectNames);
+      destroy(objectNames);
+      remove(objectNames);
+   }
+   
+   public void create(List<ObjectName> services) throws Exception
+   {
+      for (ObjectName name: services)
+         serviceController.create(name);
+   }
+   
+   public void start(List<ObjectName> services) throws Exception
+   {
+      for (ObjectName name: services)
+         serviceController.start(name);
+   }
+   
+   public void stop(List<ObjectName> services)
+   {
+      for (ListIterator<ObjectName> i = services.listIterator(services.size()); i.hasPrevious();)
+      {
+         ObjectName name = i.previous();
+         try
+         {
+            serviceController.stop(name);
+         }
+         catch (Throwable ignored)
+         {
+            log.debug("Ignored", ignored);
+         }
+      }
+   }
+   
+   public void destroy(List<ObjectName> services)
+   {
+      for (ListIterator<ObjectName> i = services.listIterator(services.size()); i.hasPrevious();)
+      {
+         ObjectName name = i.previous();
+         try
+         {
+            serviceController.destroy(name);
+         }
+         catch (Throwable ignored)
+         {
+            log.debug("Ignored", ignored);
+         }
+      }
+   }
+   
+   public void remove(List<ObjectName> services)
+   {
+      for (ObjectName name: services)
+      {
+         deployed.remove(name);
+         tempDeployed.remove(name);
+         try
+         {
+            serviceController.remove(name);
+         }
+         catch (Throwable ignored)
+         {
+            log.debug("Ignored", ignored);
+         }
+      }
+   }
+   
+   public List<ObjectName> install(URL url) throws Exception
+   {
+      long start = System.currentTimeMillis();
+      
+      List<ObjectName> result = doInstall(url, true);
+      
+      log.debug("Deployed " + url + " took " + (System.currentTimeMillis() - start) + "ms");
+      return result;
+   }
+   
+   public void uninstall(List<ObjectName> services)
+   {
+      remove(services);
+   }
+   
+   protected List<ObjectName> doInstall(URL url, boolean temporary) throws Exception
+   {
+      List<ObjectName> result = null;
+      
+      Element element = null;
+
+      try
+      {
+         InputStream stream = url.openStream();
+         try
+         {
+            InputSource is = new InputSource(stream);
+            is.setSystemId(url.toString());
+            parser.setEntityResolver(new JBossEntityResolver());
+
+            Document document = parser.parse(is);
+            element = document.getDocumentElement();
+         }
+         finally
+         {
+            stream.close();
+         }
+
+         result = serviceController.install(element, classLoaderObjectName);
+
+         deployed.addAll(result);
+         if (temporary)
+            tempDeployed.addAll(result);
+      }
+      catch (Exception e)
+      {
+         log.debug("Error deploying: " + url + ": " + e);
+         throw e;
+      }
+      
+      return result;
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/TestClassLoader.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/TestClassLoader.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/TestClassLoader.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,39 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller;
+
+import java.net.URL;
+import java.net.URLClassLoader;
+
+/**
+ * TestClassLoader.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestClassLoader extends URLClassLoader implements TestClassLoaderMBean
+{
+   public TestClassLoader()
+   {
+      super(new URL[0], Thread.currentThread().getContextClassLoader());
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/TestClassLoaderMBean.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/TestClassLoaderMBean.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/TestClassLoaderMBean.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,26 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller;
+
+public interface TestClassLoaderMBean
+{
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/basic/test/BasicNewUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/basic/test/BasicNewUnitTestCase.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/basic/test/BasicNewUnitTestCase.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,50 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.basic.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.AbstractTestDelegate;
+
+/**
+ * BasicNewUnitTestCase.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class BasicNewUnitTestCase extends BasicTest
+{
+   public static Test suite()
+   {
+      return suite(BasicNewUnitTestCase.class);
+   }
+
+   public BasicNewUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static AbstractTestDelegate getDelegate(Class clazz) throws Exception
+   {
+      return getNewControllerDelegate(clazz);
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/basic/test/BasicOldUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/basic/test/BasicOldUnitTestCase.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/basic/test/BasicOldUnitTestCase.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,50 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.basic.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.AbstractTestDelegate;
+
+/**
+ * BasicOldUnitTestCase.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class BasicOldUnitTestCase extends BasicTest
+{
+   public static Test suite()
+   {
+      return suite(BasicOldUnitTestCase.class);
+   }
+
+   public BasicOldUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static AbstractTestDelegate getDelegate(Class clazz) throws Exception
+   {
+      return getOldControllerDelegate(clazz);
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/basic/test/BasicTest.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/basic/test/BasicTest.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/basic/test/BasicTest.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,55 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.basic.test;
+
+import javax.management.MBeanServer;
+
+import org.jboss.test.system.controller.AbstractControllerTest;
+import org.jboss.test.system.controller.support.Simple;
+import org.jboss.test.system.controller.support.SimpleMBean;
+
+/**
+ * BasicTest.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class BasicTest extends AbstractControllerTest
+{
+   public BasicTest(String name)
+   {
+      super(name);
+   }
+   
+   public void testBasics() throws Exception
+   {
+      assertServiceRunning(SimpleMBean.OBJECT_NAME);
+      
+      MBeanServer server = getServer();
+      Simple test = (Simple) server.getAttribute(SimpleMBean.OBJECT_NAME, "Instance");
+      assertEquals("()", test.constructorUsed);
+      assertEquals(1, test.createOrder);
+      assertEquals(2, test.startOrder);
+      assertEquals(0, test.stopOrder);
+      assertEquals(0, test.destroyOrder);
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/basic/test/ControllerBasicTestSuite.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/basic/test/ControllerBasicTestSuite.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/basic/test/ControllerBasicTestSuite.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,52 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.basic.test;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * Controller Basic Test Suite.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.8 $
+ */
+public class ControllerBasicTestSuite extends TestSuite
+{
+   public static void main(String[] args)
+   {
+      TestRunner.run(suite());
+   }
+
+   public static Test suite()
+   {
+      TestSuite suite = new TestSuite("Controller Basic Tests");
+
+      suite.addTest(BasicOldUnitTestCase.suite());
+      suite.addTest(BasicNewUnitTestCase.suite());
+      suite.addTest(DoubleInstallOldUnitTestCase.suite());
+      suite.addTest(DoubleInstallNewUnitTestCase.suite());
+      
+      return suite;
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/basic/test/DoubleInstallNewUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/basic/test/DoubleInstallNewUnitTestCase.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/basic/test/DoubleInstallNewUnitTestCase.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,50 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.basic.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.AbstractTestDelegate;
+
+/**
+ * DoubleInstallNewUnitTestCase.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class DoubleInstallNewUnitTestCase extends DoubleInstallTest
+{
+   public static Test suite()
+   {
+      return suite(DoubleInstallNewUnitTestCase.class);
+   }
+
+   public DoubleInstallNewUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static AbstractTestDelegate getDelegate(Class clazz) throws Exception
+   {
+      return getNewControllerDelegate(clazz);
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/basic/test/DoubleInstallOldUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/basic/test/DoubleInstallOldUnitTestCase.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/basic/test/DoubleInstallOldUnitTestCase.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,50 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.basic.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.AbstractTestDelegate;
+
+/**
+ * DoubleInstallOldUnitTestCase.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class DoubleInstallOldUnitTestCase extends DoubleInstallTest
+{
+   public static Test suite()
+   {
+      return suite(DoubleInstallOldUnitTestCase.class);
+   }
+
+   public DoubleInstallOldUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static AbstractTestDelegate getDelegate(Class clazz) throws Exception
+   {
+      return getOldControllerDelegate(clazz);
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/basic/test/DoubleInstallTest.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/basic/test/DoubleInstallTest.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/basic/test/DoubleInstallTest.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,54 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.basic.test;
+
+import org.jboss.deployment.DeploymentException;
+import org.jboss.test.system.controller.AbstractControllerTest;
+import org.jboss.test.system.controller.support.SimpleMBean;
+
+/**
+ * DoubleInstallTest.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class DoubleInstallTest extends AbstractControllerTest
+{
+   public DoubleInstallTest(String name)
+   {
+      super(name);
+   }
+   
+   public void testDoubleInstall() throws Exception
+   {
+      try
+      {
+         deploy("DoubleInstall.xml");
+         fail("Should not be able to deploy twice");
+      }
+      catch (Throwable t)
+      {
+         checkThrowable(DeploymentException.class, t);
+      }
+      assertServiceRunning(SimpleMBean.OBJECT_NAME);
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/configure/test/ConfigureNewUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/configure/test/ConfigureNewUnitTestCase.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/configure/test/ConfigureNewUnitTestCase.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,50 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.configure.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.AbstractTestDelegate;
+
+/**
+ * ConfigureNewUnitTestCase.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ConfigureNewUnitTestCase extends ConfigureTest
+{
+   public static Test suite()
+   {
+      return suite(ConfigureNewUnitTestCase.class);
+   }
+
+   public ConfigureNewUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static AbstractTestDelegate getDelegate(Class clazz) throws Exception
+   {
+      return getNewControllerDelegate(clazz);
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/configure/test/ConfigureOldUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/configure/test/ConfigureOldUnitTestCase.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/configure/test/ConfigureOldUnitTestCase.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,50 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.configure.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.AbstractTestDelegate;
+
+/**
+ * ConfigureOldUnitTestCase.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ConfigureOldUnitTestCase extends ConfigureTest
+{
+   public static Test suite()
+   {
+      return suite(ConfigureOldUnitTestCase.class);
+   }
+
+   public ConfigureOldUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static AbstractTestDelegate getDelegate(Class clazz) throws Exception
+   {
+      return getOldControllerDelegate(clazz);
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/configure/test/ConfigureTest.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/configure/test/ConfigureTest.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/configure/test/ConfigureTest.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,106 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.configure.test;
+
+import java.math.BigDecimal;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import javax.management.MBeanServer;
+
+import org.jboss.test.system.controller.AbstractControllerTest;
+import org.jboss.test.system.controller.support.Simple;
+import org.jboss.test.system.controller.support.SimpleMBean;
+import org.jboss.util.NestedRuntimeException;
+
+/**
+ * ConfigureTest.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class ConfigureTest extends AbstractControllerTest
+{
+   private static DateFormat dateFormat = new SimpleDateFormat("EEE MMM d HH:mm:ss z yyyy");
+   
+   String stringValue =  new String("StringValue");
+   Byte byteValue = new Byte("12");
+   Boolean booleanValue = Boolean.TRUE;
+   // TODO character
+   // Character characterValue = new Character('a'); 
+   Short shortValue = new Short("123");
+   Integer integerValue = new Integer("1234");
+   Long longValue = new Long("12345");
+   Float floatValue = new Float("3.14");
+   Double doubleValue = new Double("3.14e12");
+   Date dateValue = createDate("Mon Jan 01 00:00:00 CET 2001");
+   BigDecimal bigDecimalValue = new BigDecimal("12e4");
+   //BigInteger bigIntegerValue = new BigInteger("123456");
+
+   public ConfigureTest(String name)
+   {
+      super(name);
+   }
+   
+   public void testConfigure() throws Exception
+   {
+      MBeanServer server = getServer();
+      Simple test = (Simple) server.getAttribute(SimpleMBean.OBJECT_NAME, "Instance");
+
+      assertEquals(stringValue, test.getAString());
+      assertEquals(byteValue, test.getAByte());
+      assertEquals(booleanValue, test.getABoolean());
+      // TODO character 
+      // assertEquals(characterValue, test.getACharacter());
+      assertEquals(shortValue, test.getAShort());
+      assertEquals(integerValue, test.getAnInt());
+      assertEquals(longValue, test.getALong());
+      assertEquals(floatValue, test.getAFloat());
+      assertEquals(doubleValue, test.getADouble());
+      assertEquals(dateValue, test.getADate());
+      assertEquals(bigDecimalValue, test.getABigDecimal());
+      // TODO BigInteger
+      //assertEquals(bigIntegerValue, test.getABigInteger());
+      assertEquals(byteValue.byteValue(), test.getAbyte());
+      assertEquals(booleanValue.booleanValue(), test.isAboolean());
+      // TODO character
+      // assertEquals(characterValue.charValue(), test.getAchar()); 
+      assertEquals(shortValue.shortValue(), test.getAshort());
+      assertEquals(integerValue.intValue(), test.getAnint());
+      assertEquals(longValue.longValue(), test.getAlong());
+      assertEquals(floatValue.floatValue(), test.getAfloat());
+      assertEquals(doubleValue.doubleValue(), test.getAdouble());
+   }
+
+   protected Date createDate(String date)
+   {
+      try
+      {
+         return dateFormat.parse(date);
+      }
+      catch (Exception e)
+      {
+         throw new NestedRuntimeException(e);
+      }
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/configure/test/ControllerConfigureTestSuite.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/configure/test/ControllerConfigureTestSuite.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/configure/test/ControllerConfigureTestSuite.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,50 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.configure.test;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * Controller Configure Test Suite.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.8 $
+ */
+public class ControllerConfigureTestSuite extends TestSuite
+{
+   public static void main(String[] args)
+   {
+      TestRunner.run(suite());
+   }
+
+   public static Test suite()
+   {
+      TestSuite suite = new TestSuite("Controller Configure Tests");
+
+      suite.addTest(ConfigureOldUnitTestCase.suite());
+      suite.addTest(ConfigureNewUnitTestCase.suite());
+      
+      return suite;
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/configure/test/ErrorNewUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/configure/test/ErrorNewUnitTestCase.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/configure/test/ErrorNewUnitTestCase.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,50 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.configure.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.AbstractTestDelegate;
+
+/**
+ * ErrorNewUnitTestCase.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ErrorNewUnitTestCase extends ErrorTest
+{
+   public static Test suite()
+   {
+      return suite(ErrorNewUnitTestCase.class);
+   }
+
+   public ErrorNewUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static AbstractTestDelegate getDelegate(Class clazz) throws Exception
+   {
+      return getNewControllerDelegate(clazz);
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/configure/test/ErrorOldUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/configure/test/ErrorOldUnitTestCase.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/configure/test/ErrorOldUnitTestCase.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,50 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.configure.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.AbstractTestDelegate;
+
+/**
+ * ErrorOldUnitTestCase.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ErrorOldUnitTestCase extends ErrorTest
+{
+   public static Test suite()
+   {
+      return suite(ErrorOldUnitTestCase.class);
+   }
+
+   public ErrorOldUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static AbstractTestDelegate getDelegate(Class clazz) throws Exception
+   {
+      return getOldControllerDelegate(clazz);
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/configure/test/ErrorTest.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/configure/test/ErrorTest.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/configure/test/ErrorTest.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,45 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.configure.test;
+
+import org.jboss.test.system.controller.AbstractControllerTest;
+import org.jboss.test.system.controller.support.SimpleMBean;
+
+/**
+ * ErrorTest.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class ErrorTest extends AbstractControllerTest
+{
+   public ErrorTest(String name)
+   {
+      super(name);
+   }
+   
+   public void testErrorInConfigure() throws Exception
+   {
+      deploy("ErrorInConfigure_NotAutomatic.xml");
+      assertServiceFailed(SimpleMBean.OBJECT_NAME);
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/instantiate/plain/test/PlainMBeanNewUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/instantiate/plain/test/PlainMBeanNewUnitTestCase.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/instantiate/plain/test/PlainMBeanNewUnitTestCase.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,50 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.instantiate.plain.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.AbstractTestDelegate;
+
+/**
+ * PlainMBeanNewUnitTestCase.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class PlainMBeanNewUnitTestCase extends PlainMBeanTest
+{
+   public static Test suite()
+   {
+      return suite(PlainMBeanNewUnitTestCase.class);
+   }
+
+   public PlainMBeanNewUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static AbstractTestDelegate getDelegate(Class clazz) throws Exception
+   {
+      return getNewControllerDelegate(clazz);
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/instantiate/plain/test/PlainMBeanOldUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/instantiate/plain/test/PlainMBeanOldUnitTestCase.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/instantiate/plain/test/PlainMBeanOldUnitTestCase.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,59 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.instantiate.plain.test;
+
+import javax.management.NotCompliantMBeanException;
+
+import junit.framework.Test;
+
+import org.jboss.test.AbstractTestDelegate;
+import org.jboss.test.system.controller.support.SimpleMBean;
+
+/**
+ * PlainMBeanOldUnitTestCase.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class PlainMBeanOldUnitTestCase extends PlainMBeanTest
+{
+   public static Test suite()
+   {
+      return suite(PlainMBeanOldUnitTestCase.class);
+   }
+
+   public PlainMBeanOldUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static AbstractTestDelegate getDelegate(Class clazz) throws Exception
+   {
+      return getOldControllerDelegate(clazz);
+   }
+   
+   public void testPlainMBeanAbstractClass() throws Exception
+   {
+      assertMaybeDeployFailure(SimpleMBean.OBJECT_NAME, NotCompliantMBeanException.class);
+   }
+
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/instantiate/plain/test/PlainMBeanTest.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/instantiate/plain/test/PlainMBeanTest.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/instantiate/plain/test/PlainMBeanTest.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,90 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.instantiate.plain.test;
+
+import javax.management.NotCompliantMBeanException;
+import javax.management.ObjectName;
+
+import org.jboss.system.ConfigurationException;
+import org.jboss.test.system.controller.AbstractControllerTest;
+import org.jboss.test.system.controller.support.SimpleMBean;
+
+/**
+ * PlainMBeanTest.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class PlainMBeanTest extends AbstractControllerTest
+{
+   public PlainMBeanTest(String name)
+   {
+      super(name);
+   }
+   
+   public void testPlainMBean() throws Exception
+   {
+      ObjectName name = SimpleMBean.OBJECT_NAME;
+      assertInstall(name);
+      assertUninstall(name);
+   }
+   
+   public void testPlainMBeanCodeClassNotFound() throws Exception
+   {
+      assertMaybeDeployFailure(SimpleMBean.OBJECT_NAME, ClassNotFoundException.class);
+   }
+   
+   public void testPlainMBeanNotMBean() throws Exception
+   {
+      assertMaybeDeployFailure(SimpleMBean.OBJECT_NAME, NotCompliantMBeanException.class);
+   }
+   
+   public void testPlainMBeanAbstractClass() throws Exception
+   {
+      assertMaybeDeployFailure(SimpleMBean.OBJECT_NAME, InstantiationException.class);
+   }
+   
+   public void testPlainMBeanConstructorError() throws Exception
+   {
+      assertMaybeDeployFailure(SimpleMBean.OBJECT_NAME, Error.class);
+   }
+   
+   public void testPlainMBeanConstructorException() throws Exception
+   {
+      assertMaybeDeployFailure(SimpleMBean.OBJECT_NAME, RuntimeException.class);
+   }
+   
+   public void testPlainMBeanConstructorTypeNotFound() throws Exception
+   {
+      assertMaybeDeployFailure(SimpleMBean.OBJECT_NAME, ClassNotFoundException.class);
+   }
+   
+   public void testPlainMBeanConstructorInvalidType() throws Exception
+   {
+      assertMaybeDeployFailure(SimpleMBean.OBJECT_NAME, ConfigurationException.class);
+   }
+   
+   public void testPlainMBeanConstructorInvalidValue() throws Exception
+   {
+      assertMaybeDeployFailure(SimpleMBean.OBJECT_NAME, NumberFormatException.class);
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/instantiate/standard/test/StandardMBeanNewUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/instantiate/standard/test/StandardMBeanNewUnitTestCase.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/instantiate/standard/test/StandardMBeanNewUnitTestCase.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,50 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.instantiate.standard.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.AbstractTestDelegate;
+
+/**
+ * StandardMBeanNewUnitTestCase.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class StandardMBeanNewUnitTestCase extends StandardMBeanTest
+{
+   public static Test suite()
+   {
+      return suite(StandardMBeanNewUnitTestCase.class);
+   }
+
+   public StandardMBeanNewUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static AbstractTestDelegate getDelegate(Class clazz) throws Exception
+   {
+      return getNewControllerDelegate(clazz);
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/instantiate/standard/test/StandardMBeanOldUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/instantiate/standard/test/StandardMBeanOldUnitTestCase.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/instantiate/standard/test/StandardMBeanOldUnitTestCase.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,50 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.instantiate.standard.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.AbstractTestDelegate;
+
+/**
+ * StandardMBeanOldUnitTestCase.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class StandardMBeanOldUnitTestCase extends StandardMBeanTest
+{
+   public static Test suite()
+   {
+      return suite(StandardMBeanOldUnitTestCase.class);
+   }
+
+   public StandardMBeanOldUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static AbstractTestDelegate getDelegate(Class clazz) throws Exception
+   {
+      return getOldControllerDelegate(clazz);
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/instantiate/standard/test/StandardMBeanTest.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/instantiate/standard/test/StandardMBeanTest.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/instantiate/standard/test/StandardMBeanTest.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,104 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.instantiate.standard.test;
+
+import javax.management.NotCompliantMBeanException;
+import javax.management.ObjectName;
+
+import org.jboss.system.ConfigurationException;
+import org.jboss.test.system.controller.AbstractControllerTest;
+import org.jboss.test.system.controller.support.SimpleMBean;
+
+/**
+ * StandardMBeanTest.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class StandardMBeanTest extends AbstractControllerTest
+{
+   public StandardMBeanTest(String name)
+   {
+      super(name);
+   }
+   
+   public void testStandardMBean() throws Exception
+   {
+      ObjectName name = SimpleMBean.OBJECT_NAME;
+      assertInstall(name);
+      assertUninstall(name);
+   }
+   
+   public void testStandardMBeanInterface() throws Exception
+   {
+      ObjectName name = SimpleMBean.OBJECT_NAME;
+      assertInstall(name);
+      String result = (String) getServer().invoke(name, "echoReverse", new Object[] { "12345" }, new String[] { String.class.getName() });
+      assertEquals("54321", result);
+      assertUninstall(name);
+   }
+
+   public void testStandardMBeanInterfaceNotFound() throws Exception
+   {
+      assertMaybeDeployFailure(SimpleMBean.OBJECT_NAME, ClassNotFoundException.class);
+   }
+
+   public void testStandardMBeanInterfaceNotImplemented() throws Exception
+   {
+      assertMaybeDeployFailure(SimpleMBean.OBJECT_NAME, NotCompliantMBeanException.class);
+   }
+
+   public void testStandardMBeanCodeClassNotFound() throws Exception
+   {
+      assertMaybeDeployFailure(SimpleMBean.OBJECT_NAME, ClassNotFoundException.class);
+   }
+   
+   public void testStandardMBeanAbstractClass() throws Exception
+   {
+      assertMaybeDeployFailure(SimpleMBean.OBJECT_NAME, InstantiationException.class);
+   }
+
+   public void testStandardMBeanConstructorError() throws Exception
+   {
+      assertMaybeDeployFailure(SimpleMBean.OBJECT_NAME, Error.class);
+   }
+   
+   public void testStandardMBeanConstructorException() throws Exception
+   {
+      assertMaybeDeployFailure(SimpleMBean.OBJECT_NAME, RuntimeException.class);
+   }
+   
+   public void testStandardMBeanConstructorTypeNotFound() throws Exception
+   {
+      assertMaybeDeployFailure(SimpleMBean.OBJECT_NAME, ClassNotFoundException.class);
+   }
+   
+   public void testStandardMBeanConstructorInvalidType() throws Exception
+   {
+      assertMaybeDeployFailure(SimpleMBean.OBJECT_NAME, ConfigurationException.class);
+   }
+
+   public void testStandardMBeanConstructorInvalidValue() throws Exception
+   {
+      assertMaybeDeployFailure(SimpleMBean.OBJECT_NAME, NumberFormatException.class);
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/instantiate/test/ConstructorArgsNewUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/instantiate/test/ConstructorArgsNewUnitTestCase.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/instantiate/test/ConstructorArgsNewUnitTestCase.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,50 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.instantiate.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.AbstractTestDelegate;
+
+/**
+ * InstallMBeanNewUnitTestCase.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ConstructorArgsNewUnitTestCase extends ConstructorArgsTest
+{
+   public static Test suite()
+   {
+      return suite(ConstructorArgsNewUnitTestCase.class);
+   }
+
+   public ConstructorArgsNewUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static AbstractTestDelegate getDelegate(Class clazz) throws Exception
+   {
+      return getNewControllerDelegate(clazz);
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/instantiate/test/ConstructorArgsOldUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/instantiate/test/ConstructorArgsOldUnitTestCase.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/instantiate/test/ConstructorArgsOldUnitTestCase.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,50 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.instantiate.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.AbstractTestDelegate;
+
+/**
+ * InstallMBeanOldUnitTestCase.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ConstructorArgsOldUnitTestCase extends ConstructorArgsTest
+{
+   public static Test suite()
+   {
+      return suite(ConstructorArgsOldUnitTestCase.class);
+   }
+
+   public ConstructorArgsOldUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static AbstractTestDelegate getDelegate(Class clazz) throws Exception
+   {
+      return getOldControllerDelegate(clazz);
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/instantiate/test/ConstructorArgsTest.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/instantiate/test/ConstructorArgsTest.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/instantiate/test/ConstructorArgsTest.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,118 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.instantiate.test;
+
+import javax.management.MBeanServer;
+
+import org.jboss.test.system.controller.AbstractControllerTest;
+import org.jboss.test.system.controller.support.Simple;
+import org.jboss.test.system.controller.support.SimpleMBean;
+
+/**
+ * InstallTest.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class ConstructorArgsTest extends AbstractControllerTest
+{
+   public ConstructorArgsTest(String name)
+   {
+      super(name);
+   }
+   
+   public void testPlainMBeanNoArg() throws Exception
+   {
+      noArg();
+   }
+   
+   public void testPlainMBeanOneArg() throws Exception
+   {
+      oneArg();
+   }
+   
+   public void testPlainMBeanTwoArg() throws Exception
+   {
+      twoArg();
+   }
+   
+   public void testStandardMBeanNoArg() throws Exception
+   {
+      noArg();
+   }
+   
+   public void testStandardMBeanOneArg() throws Exception
+   {
+      oneArg();
+   }
+   
+   public void testStandardMBeanTwoArg() throws Exception
+   {
+      twoArg();
+   }
+   
+   protected void noArg() throws Exception
+   {
+      Simple simple = getSimple();
+      assertEquals("()", simple.constructorUsed);
+   }
+   
+   protected void oneArg() throws Exception
+   {
+      Simple simple = getSimple();
+      assertEquals("(int)", simple.constructorUsed);
+      assertEquals(5, simple.getAnint());
+   }
+   
+   protected void twoArg() throws Exception
+   {
+      Simple simple = getSimple();
+      assertEquals("(int,float)", simple.constructorUsed);
+      assertEquals(5, simple.getAnint());
+      assertEquals(3.14f, simple.getAfloat());
+   }
+
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+
+      assertInstall(SimpleMBean.OBJECT_NAME);
+   }
+   
+   protected void tearDown() throws Exception
+   {
+      try
+      {
+         assertUninstall(SimpleMBean.OBJECT_NAME);
+      }
+      finally
+      {
+         super.tearDown();
+      }
+   }
+
+   protected Simple getSimple() throws Exception
+   {
+      MBeanServer server = getServer();
+      return (Simple) server.getAttribute(SimpleMBean.OBJECT_NAME, "Instance");
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/instantiate/test/ControllerInstantiateTestSuite.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/instantiate/test/ControllerInstantiateTestSuite.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/instantiate/test/ControllerInstantiateTestSuite.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,60 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.instantiate.test;
+
+import org.jboss.test.system.controller.instantiate.plain.test.PlainMBeanNewUnitTestCase;
+import org.jboss.test.system.controller.instantiate.plain.test.PlainMBeanOldUnitTestCase;
+import org.jboss.test.system.controller.instantiate.standard.test.StandardMBeanNewUnitTestCase;
+import org.jboss.test.system.controller.instantiate.standard.test.StandardMBeanOldUnitTestCase;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * Controller Instantiate Test Suite.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.8 $
+ */
+public class ControllerInstantiateTestSuite extends TestSuite
+{
+   public static void main(String[] args)
+   {
+      TestRunner.run(suite());
+   }
+
+   public static Test suite()
+   {
+      TestSuite suite = new TestSuite("Controller Instantiate Tests");
+
+      suite.addTest(NewNoMetaDataInstantiateUnitTestCase.suite());
+      suite.addTest(ConstructorArgsOldUnitTestCase.suite());
+      suite.addTest(ConstructorArgsNewUnitTestCase.suite());
+      suite.addTest(PlainMBeanOldUnitTestCase.suite());
+      suite.addTest(PlainMBeanNewUnitTestCase.suite());
+      suite.addTest(StandardMBeanOldUnitTestCase.suite());
+      suite.addTest(StandardMBeanNewUnitTestCase.suite());
+      
+      return suite;
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/instantiate/test/NewNoMetaDataInstantiateUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/instantiate/test/NewNoMetaDataInstantiateUnitTestCase.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/instantiate/test/NewNoMetaDataInstantiateUnitTestCase.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,119 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.instantiate.test;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import junit.framework.Test;
+
+import org.jboss.system.ServiceController;
+import org.jboss.test.AbstractTestDelegate;
+import org.jboss.test.system.controller.AbstractControllerTest;
+import org.jboss.test.system.controller.support.Simple;
+import org.jboss.test.system.controller.support.SimpleMBean;
+
+/**
+ * NewNoMetaDataInstantiateUnitTestCase.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class NewNoMetaDataInstantiateUnitTestCase extends AbstractControllerTest
+{
+   public static Test suite()
+   {
+      return suite(NewNoMetaDataInstantiateUnitTestCase.class);
+   }
+
+   public NewNoMetaDataInstantiateUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static AbstractTestDelegate getDelegate(Class clazz) throws Exception
+   {
+      return getNewControllerDelegate(clazz);
+   }
+   
+   public void testNoMetaData() throws Throwable
+   {
+      ObjectName name = SimpleMBean.OBJECT_NAME;
+      Simple test = new Simple();
+
+      ServiceController serviceController = (ServiceController) getController();
+      serviceController.install(name, test);
+      try
+      {
+         assertServiceConfigured(name);
+         
+         MBeanServer server = getServer();
+         Object instance = server.getAttribute(name, "Instance");
+         assertNotNull(instance);
+         assertTrue(test == instance);
+      }
+      finally
+      {
+         try
+         {
+            serviceController.remove(name);
+         }
+         catch (Exception ignored)
+         {
+         }
+      }
+   }
+   
+   public void testNoMetaDataNoName() throws Throwable
+   {
+      ObjectName name = SimpleMBean.OBJECT_NAME;
+
+      Simple test = new Simple();
+      
+      ServiceController serviceController = (ServiceController) getController();
+      try
+      {
+         serviceController.install(null, test);
+      }
+      catch (Throwable t)
+      {
+         checkThrowableDeep(IllegalArgumentException.class, t);
+      }
+      
+      assertNoService(name);
+   }
+   
+   public void testNoMetaDataNoObject() throws Throwable
+   {
+      ObjectName name = SimpleMBean.OBJECT_NAME;
+
+      ServiceController serviceController = (ServiceController) getController();
+      try
+      {
+         serviceController.install(name, null);
+      }
+      catch (Throwable t)
+      {
+         checkThrowableDeep(IllegalArgumentException.class, t);
+      }
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/legacy/OldServiceConfigurator.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/legacy/OldServiceConfigurator.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/legacy/OldServiceConfigurator.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,841 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.system.controller.legacy;
+
+import java.beans.PropertyEditor;
+import java.beans.PropertyEditorManager;
+import java.io.IOException;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Properties;
+
+import javax.management.Attribute;
+import javax.management.InstanceNotFoundException;
+import javax.management.MBeanAttributeInfo;
+import javax.management.MBeanInfo;
+import javax.management.MBeanServer;
+import javax.management.ObjectInstance;
+import javax.management.ObjectName;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.jboss.deployment.DeploymentException;
+import org.jboss.logging.Logger;
+import org.jboss.mx.util.JMXExceptionDecoder;
+import org.jboss.mx.util.MBeanProxyExt;
+import org.jboss.mx.util.ObjectNameFactory;
+import org.jboss.system.ServiceBinding;
+import org.jboss.system.ServiceContext;
+import org.jboss.util.Classes;
+import org.jboss.util.StringPropertyReplacer;
+import org.jboss.util.propertyeditor.PropertyEditors;
+import org.jboss.util.xml.DOMWriter;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultSchemaResolver;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+
+/**
+ * Service configuration helper.
+ * @author <a href="mailto:marc at jboss.org">Marc Fleury</a>
+ * @author <a href="mailto:hiram at jboss.org">Hiram Chirino</a>
+ * @author <a href="mailto:d_jencks at users.sourceforge.net">David Jencks</a>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
+ * @version <tt>$Revision: 1.45 $</tt>
+ */
+public class OldServiceConfigurator
+{
+   /** 
+    * Augment the PropertyEditorManager search path to incorporate the JBoss
+    * specific editors. This simply references the PropertyEditors.class to
+    * invoke its static initialization block.
+    */
+   static
+   {
+      PropertyEditors.init();
+   }
+
+   // Private Data --------------------------------------------------
+   
+   /** The MBean server which this service is registered in. */
+   private final MBeanServer server;
+   
+   /** The parent service controller */
+   private final OldServiceController serviceController;
+   
+   /** The ServiceCreator */
+   private final OldServiceCreator serviceCreator;
+   
+   /** The ServiceBinding plugin policy */
+   private ServiceBinding serviceBinding;
+
+   /**
+    * The instance logger.
+    */
+   private final Logger log = Logger.getLogger(getClass());
+
+   // Constructor ---------------------------------------------------
+   
+   /**
+    * Constructor
+    * 
+    * @param server
+    * @param serviceController
+    * @param serviceCreator
+    */
+   public OldServiceConfigurator(MBeanServer server,
+         OldServiceController serviceController, OldServiceCreator serviceCreator)
+   {
+      this.server = server;
+      this.serviceController = serviceController;
+      this.serviceCreator = serviceCreator;
+      this.serviceBinding = null;
+   }
+
+   // Public --------------------------------------------------------
+   
+   /**
+    * Dynamically plug-in a ServiceBinding policy
+    * to possibly override the configuration of a service.
+    * 
+    * @param serviceBinding policy
+    */   
+   public void setServiceBinding(ServiceBinding serviceBinding)
+   {
+      this.serviceBinding = serviceBinding;
+   }
+   
+   /**
+    * The <code>install</code> method iterates through the mbean tags in the
+    * supplied xml configuration and creates and configures the mbeans shown.
+    * The mbean configuration can be nested.
+    * @param config the xml <code>Element</code> containing the configuration of
+    * the mbeans to create and configure.
+    * @return a <code>List</code> of ObjectNames of created mbeans.
+    * @throws DeploymentException if an error occurs
+    */
+   public List<ObjectName> install(Element config, ObjectName loaderName) throws DeploymentException
+   {
+      List<ObjectName> mbeans = new ArrayList<ObjectName>();
+      try
+      {
+         if (config.getTagName().equals("mbean"))
+         {
+            internalInstall(config, mbeans, loaderName, true);
+         }
+         else
+         {
+            NodeList nl = config.getChildNodes();
+
+            for (int i = 0; i < nl.getLength(); i++)
+            {
+               if (nl.item(i).getNodeType() == Node.ELEMENT_NODE)
+               {
+                  Element element = (Element) nl.item(i);
+                  if (element.getTagName().equals("mbean"))
+                  {
+                     Element mbean = (Element) nl.item(i);
+                     internalInstall(mbean, mbeans, loaderName, true);
+                  } // end of if ()
+               } // end of if ()
+            }//end of for
+         } //end of else
+         return mbeans;
+      }
+      catch (Exception e)
+      {
+         for (ListIterator li = mbeans.listIterator(mbeans.size()); li.hasPrevious();)
+         {
+            ObjectName mbean = (ObjectName) li.previous();
+            try
+            {
+               serviceCreator.remove(mbean);
+            }
+            catch (Exception n)
+            {
+               log.error("exception removing mbean after failed deployment: " + mbean, n);
+            }
+         }
+
+         if (e instanceof DeploymentException)
+            throw (DeploymentException) e;
+
+         throw new DeploymentException(e);
+      }
+   }
+
+   /**
+    * Builds a string that consists of the configuration elements of the
+    * currently running MBeans registered in the server.
+    * @throws Exception Failed to construct configuration.
+    * @todo replace with more sophisticated mbean persistence mechanism.
+    */
+   public String getConfiguration(ObjectName[] objectNames)
+      throws Exception
+   {
+      Writer out = new StringWriter();
+
+      DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+      DocumentBuilder builder = factory.newDocumentBuilder();
+      Document doc = builder.newDocument();
+
+      Element serverElement = doc.createElement("server");
+
+      // Store attributes as XML
+      for (int j = 0; j < objectNames.length; j++)
+      {
+         Element mbeanElement = internalGetConfiguration(doc, objectNames[j]);
+         serverElement.appendChild(mbeanElement);
+      }
+
+      doc.appendChild(serverElement);
+
+      // Write configuration
+      new DOMWriter(out).setPrettyprint(true).print(doc);
+
+      out.close();
+
+      // Return configuration
+      return out.toString();
+   }
+   
+   // Protected -----------------------------------------------------
+   
+   /**
+    * The <code>configure</code> method configures an mbean based on the xml
+    * element configuration passed in.  Three formats are supported:
+    * &lt;attribute name="(name)"&gt;(value)&lt;/attribute&gt; &lt;depends
+    * optional-attribute-name="(name)"&gt;(object name of mbean
+    * referenced)&lt;/depends&gt; &lt;depends-list optional-attribute-name="(name)"&gt;
+    * [list of]  &lt;/depends-list-element&gt;(object name)&lt;/depends-list-element&gt;
+    * &lt;/depends-list&gt;
+    *
+    * The last two can include nested mbean configurations or ObjectNames.
+    * SIDE-EFFECT: adds all mbeans this one depends on to the ServiceContext
+    * structures.
+    * @param mbeanElement an <code>Element</code> value
+    * @throws Exception if an error occurs
+    */
+   protected void configure(ObjectName objectName, ObjectName loaderName,
+      Element mbeanElement, List<ObjectName> mbeans)
+      throws Exception
+   {
+      // Set configuration to MBeans from XML
+
+      MBeanInfo info;
+      try
+      {
+         info = server.getMBeanInfo(objectName);
+      }
+      catch (InstanceNotFoundException e)
+      {
+         // The MBean is no longer available
+         throw new DeploymentException("trying to configure nonexistent mbean: " + objectName);
+      }
+      catch (Exception e)
+      {
+         throw new DeploymentException("Could not get mbeanInfo", JMXExceptionDecoder.decode(e));
+      } // end of catch
+
+      if (info == null)
+      {
+         throw new DeploymentException("MBeanInfo is null for mbean: " + objectName);
+      } // end of if ()
+
+      // Get the classloader for loading attribute classes.
+      ClassLoader cl = server.getClassLoader(loaderName);
+      // Initialize the mbean using the configuration supplied defaults
+      MBeanAttributeInfo[] attributes = info.getAttributes();
+      HashMap<String, MBeanAttributeInfo> attributeMap = new HashMap<String, MBeanAttributeInfo>();
+      for (int i = 0; i < attributes.length; i++)
+      {
+         MBeanAttributeInfo attr = attributes[i];
+         attributeMap.put(attr.getName(), attr);
+      }
+
+      NodeList attrs = mbeanElement.getChildNodes();
+      for (int j = 0; j < attrs.getLength(); j++)
+      {
+         // skip over non-element nodes
+         if (attrs.item(j).getNodeType() != Node.ELEMENT_NODE)
+         {
+            continue;
+         }
+
+         Element element = (Element) attrs.item(j);
+
+         boolean replace = true;
+
+         // Set attributes
+         if (element.getTagName().equals("attribute"))
+         {
+            String attributeName = element.getAttribute("name");
+            boolean trim = true;
+            String replaceAttr = element.getAttribute("replace");
+            if (replaceAttr.length() > 0)
+               replace = Boolean.valueOf(replaceAttr).booleanValue();
+            String trimAttr = element.getAttribute("trim");
+            if (trimAttr.length() > 0)
+               trim = Boolean.valueOf(trimAttr).booleanValue();
+            String serialDataType = element.getAttribute("serialDataType");
+
+            // Get the MBeanAttributeInfo
+            MBeanAttributeInfo attr = attributeMap.get(attributeName);
+            if (attr == null)
+               throw new DeploymentException("No Attribute found with name: " + attributeName);
+
+            if (element.hasChildNodes())
+            {
+               Object value = null;
+               // Unmarshall the attribute value based on the serialDataType
+               if (serialDataType.equals("javaBean"))
+                  value = parseJavaBeanSerialData(attr, cl, element, replace, trim);
+               else if (serialDataType.equals("jbxb"))
+                  value = parseJbxbSerialData(attr, cl, element, replace, trim);
+               else
+                  value = parseTextSerialData(attr, cl, element, replace, trim);
+               
+               log.debug(attributeName + " set to " + value + " in " + objectName);
+               setAttribute(objectName, new Attribute(attributeName, value));
+            }//if has children
+
+         }
+         //end of "attribute
+         else if (element.getTagName().equals("depends"))
+         {
+            if (!element.hasChildNodes())
+            {
+               throw new DeploymentException("No ObjectName supplied for depends in  " + objectName);
+            }
+
+            String mbeanRefName = element.getAttribute("optional-attribute-name");
+            if ("".equals(mbeanRefName))
+               mbeanRefName = null;
+            else
+               mbeanRefName = StringPropertyReplacer.replaceProperties(mbeanRefName);
+
+            String proxyType = element.getAttribute("proxy-type");
+            if ("".equals(proxyType))
+               proxyType = null;
+            else
+               proxyType = StringPropertyReplacer.replaceProperties(proxyType);
+
+            // Get the mbeanRef value
+            ObjectName dependsObjectName = processDependency(objectName, loaderName, element, mbeans, replace);
+            log.debug("considering " + ((mbeanRefName == null) ? "<anonymous>" : mbeanRefName.toString()) + " with object name " + dependsObjectName);
+
+            if (mbeanRefName != null)
+            {
+               Object attribute = dependsObjectName;
+               if (proxyType != null)
+               {
+                  if (mbeanRefName == null)
+                     throw new DeploymentException("You cannot use a proxy-type without an optional-attribute-name");
+                  if (proxyType.equals("attribute"))
+                  {
+                     MBeanAttributeInfo attr = attributeMap.get(mbeanRefName);
+                     if (attr == null)
+                        throw new DeploymentException("No Attribute found with name: " + mbeanRefName);
+                     proxyType = attr.getType();
+                  }
+                  Class proxyClass = cl.loadClass(proxyType);
+                  attribute = MBeanProxyExt.create(proxyClass, dependsObjectName,
+                     server, true);
+               }
+
+               //if if doesn't exist or has wrong type, we'll get an exception
+               setAttribute(objectName, new Attribute(mbeanRefName, attribute));
+            } // end of if ()
+         }
+         //end of depends
+         else if (element.getTagName().equals("depends-list"))
+         {
+            String dependsListName = element.getAttribute("optional-attribute-name");
+            if ("".equals(dependsListName))
+            {
+               dependsListName = null;
+            } // end of if ()
+
+            NodeList dependsList = element.getChildNodes();
+            ArrayList<ObjectName> dependsListNames = new ArrayList<ObjectName>();
+            for (int l = 0; l < dependsList.getLength(); l++)
+            {
+               if (dependsList.item(l).getNodeType() != Node.ELEMENT_NODE)
+               {
+                  continue;
+               }
+
+               Element dependsElement = (Element) dependsList.item(l);
+               if (dependsElement.getTagName().equals("depends-list-element"))
+               {
+                  if (!dependsElement.hasChildNodes())
+                  {
+                     throw new DeploymentException("Empty depends-list-element!");
+                  } // end of if ()
+
+                  // Get the depends value
+                  ObjectName dependsObjectName = processDependency(objectName, loaderName, dependsElement, mbeans, replace);
+                  if (!dependsListNames.contains(dependsObjectName))
+                  {
+                     dependsListNames.add(dependsObjectName);
+                  } // end of if ()
+               }
+
+            } // end of for ()
+            if (dependsListName != null)
+            {
+               setAttribute(objectName, new Attribute(dependsListName, dependsListNames));
+            } // end of if ()
+         }//end of depends-list
+      }
+
+      // If a ServiceBinding policy is plugged-in, check for overriden attributes
+      if (serviceBinding != null)
+      {
+         try
+         {
+            serviceBinding.applyServiceConfig(objectName);
+         }
+         catch (Exception e)
+         {
+            // serviceBinding is most probably a dynamic mbean proxy
+            Throwable t = JMXExceptionDecoder.decode(e);            
+            log.warn("Failed to apply service binding override", t);         
+         }
+      }
+   }
+
+   // Private -------------------------------------------------------
+   
+   private ObjectName internalInstall(Element mbeanElement, List<ObjectName> mbeans,
+         ObjectName loaderName, boolean replace) throws Exception
+      {
+         ObjectInstance instance = null;
+         ObjectName mbeanName = parseObjectName(mbeanElement, replace);
+
+         instance = serviceCreator.install(mbeanName, loaderName, mbeanElement);
+
+         // just in case it changed...
+         mbeanName = instance.getObjectName();
+
+         mbeans.add(mbeanName);
+         if (mbeanName != null)
+         {
+            ServiceContext ctx = serviceController.createServiceContext(mbeanName);
+            try
+            {
+               configure(mbeanName, loaderName, mbeanElement, mbeans);
+               ctx.state = ServiceContext.CONFIGURED;
+               ctx.problem = null;
+            }
+            catch (Exception e)
+            {
+               ctx.state = ServiceContext.FAILED;
+               ctx.problem = e;
+               log.info("Problem configuring service " + mbeanName, e);
+               //throw e;
+            }
+         }
+
+         return mbeanName;
+      }
+   
+   /**
+    * Configure the mbean attribute using the element text and PropertyEditor for the
+    * attribute type. 
+    * @param attr - the mbean attribute
+    * @param cl - the class loader to use
+    * @param element - the mbean attribute element from the jboss-service descriptor
+    * @param replace - flag indicating if ${x} system property refs should be replaced
+    * @param trim - flag indicating if the element text shold be trimmed 
+    * @return the configured attribute value
+    * @throws Exception
+    */ 
+   private Object parseTextSerialData(MBeanAttributeInfo attr, ClassLoader cl,
+      Element element, boolean replace, boolean trim)
+      throws Exception
+   {
+      // Get the attribute value
+      String attributeName = attr.getName();
+      String attributeText = getElementContent(element, trim, replace);
+      String typeName = attr.getType();
+
+      // see if it is a primitive type first
+      Class typeClass = Classes.getPrimitiveTypeForName(typeName);
+      if (typeClass == null)
+      {
+         // nope try look up
+         try
+         {
+            typeClass = cl.loadClass(typeName);
+         }
+         catch (ClassNotFoundException e)
+         {
+            throw new DeploymentException
+               ("Class not found for attribute: " + attributeName, e);
+         }
+      }
+
+      Object value = null;
+
+      /* Attributes of type Element are passed as is after optionally
+      performing system property replacement
+      */
+      if (typeClass.equals(Element.class))
+      {
+         // Use the first child Element of this element as the value
+         NodeList nl = element.getChildNodes();
+         for (int i = 0; i < nl.getLength(); i++)
+         {
+            Node n = nl.item(i);
+            if (n.getNodeType() == Node.ELEMENT_NODE)
+            {
+               value = n;
+               break;
+            }
+         }
+         // Replace any ${x} references in the element text
+         if (replace)
+         {
+            PropertyEditor editor = PropertyEditorManager.findEditor(typeClass);
+            if (editor == null)
+            {
+               log.warn("Cannot perform property replace on Element");
+            }
+            else
+            {
+               editor.setValue(value);
+               String text = editor.getAsText();
+               text = StringPropertyReplacer.replaceProperties(text);
+               editor.setAsText(text);
+               value = editor.getValue();
+            }
+         }
+      }
+
+      if (value == null)
+      {
+         PropertyEditor editor = PropertyEditorManager.findEditor(typeClass);
+         if (editor == null)
+         {
+            throw new DeploymentException
+               ("No property editor for attribute: " + attributeName +
+               "; type=" + typeClass);
+         }
+
+         // JBAS-1709, temporarily switch the TCL so that property
+         // editors have access to the actual deployment ClassLoader.
+         ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+         Thread.currentThread().setContextClassLoader(cl);
+         try 
+         {
+            editor.setAsText(attributeText);
+            value = editor.getValue();
+         }
+         finally 
+         {
+            Thread.currentThread().setContextClassLoader(tcl);
+         }
+      }
+      return value;
+   }
+
+   /**
+    * Configure the mbean attribute as a javabean with the bean properties given by
+    * nested property elements.
+    * @param attr - the mbean attribute
+    * @param cl - the class loader to use
+    * @param element - the mbean attribute element from the jboss-service descriptor
+    * @param replace - flag indicating if ${x} system property refs should be replaced
+    * @param trim - flag indicating if the element text shold be trimmed 
+    * @return the configured attribute java bean
+    * @throws Exception
+    */ 
+   private Object parseJavaBeanSerialData(MBeanAttributeInfo attr, ClassLoader cl,
+      Element element, boolean replace, boolean trim)
+      throws Exception
+   {
+      // Extract the property elements
+      String attributeClassName = element.getAttribute("attributeClass");
+      if( attributeClassName == null || attributeClassName.length() == 0 )
+         attributeClassName = attr.getType();
+      Class attributeClass = cl.loadClass(attributeClassName);
+      // Create the bean instance
+      Object bean = attributeClass.newInstance();
+      // Get the JavaBean properties
+      NodeList properties = element.getElementsByTagName("property");
+      Properties beanProps = new Properties();
+      for(int n = 0; n < properties.getLength(); n ++)
+      {
+         // Skip over non-element nodes
+         Node node = properties.item(n);
+         if (node.getNodeType() != Node.ELEMENT_NODE)
+         {
+            continue;
+         }
+         Element property = (Element) node;
+         String name = property.getAttribute("name");
+         String value = getElementContent(property, trim, replace);
+         beanProps.setProperty(name, value);
+      }
+
+      // Apply the properties to the bean
+      PropertyEditors.mapJavaBeanProperties(bean, beanProps);
+      return bean;
+   }
+
+   /**
+    * Configure the mbean attribute as a bean with the bean unmarshalled from
+    * the attribute xml contents using the JBossXB unmarshaller.
+    * 
+    * @param attr - the mbean attribute
+    * @param cl - the class loader to use
+    * @param element - the mbean attribute element from the jboss-service descriptor
+    * @param replace - ignored
+    * @param trim - ignored 
+    * @return the configured attribute bean
+    * @throws Exception
+    */ 
+   private Object parseJbxbSerialData(MBeanAttributeInfo attr, ClassLoader cl,
+      Element element, boolean replace, boolean trim)
+      throws Exception
+   {
+      // Get the attribute element content in a parsable form
+      StringBuffer buffer = getElementContent(element);
+
+      // Parse the attribute element content
+      DefaultSchemaResolver resolver = new DefaultSchemaResolver();
+      Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+      StringReader reader = new StringReader(buffer.toString());
+      Object bean = unmarshaller.unmarshal(reader, resolver);
+      return bean;
+   }
+
+   private ObjectName processDependency(ObjectName container, ObjectName loaderName,
+      Element element, List<ObjectName> mbeans, boolean replace)
+      throws Exception
+   {
+      ObjectName dependsObjectName = null;
+      NodeList nl = element.getChildNodes();
+      for (int i = 0; i < nl.getLength(); i++)
+      {
+         Node childNode = nl.item(i);
+         if (childNode.getNodeType() == Node.ELEMENT_NODE)
+         {
+            Element child = (Element) childNode;
+            if (child.getTagName().equals("mbean"))
+            {
+               dependsObjectName = internalInstall(child, mbeans, loaderName, replace);
+               break;
+            }
+            else
+            {
+               throw new DeploymentException("Non mbean child element in depends tag: " + child);
+            } // end of else
+         } // end of if ()
+      } // end of for ()
+
+      if (dependsObjectName == null)
+      {
+         String name = getElementContent(element, true, replace);
+         dependsObjectName = ObjectNameFactory.create(name);
+      }
+      if (dependsObjectName == null)
+      {
+         throw new DeploymentException("No object name found for attribute!");
+      } // end of if ()
+
+      serviceController.registerDependency(container, dependsObjectName);
+
+      return dependsObjectName;
+   }
+
+   /**
+    * A helper to deal with those pesky JMX exceptions.
+    */
+   private void setAttribute(ObjectName name, Attribute attr)
+      throws Exception
+   {
+      try
+      {
+         server.setAttribute(name, attr);
+      }
+      catch (Exception e)
+      {
+         throw new DeploymentException("Exception setting attribute " +
+            attr + " on mbean " + name, JMXExceptionDecoder.decode(e));
+      }
+   }
+
+   private Element internalGetConfiguration(Document doc, ObjectName name)
+      throws Exception
+   {
+      Element mbeanElement = doc.createElement("mbean");
+      mbeanElement.setAttribute("name", name.toString());
+
+      MBeanInfo info = server.getMBeanInfo(name);
+      mbeanElement.setAttribute("code", info.getClassName());
+      MBeanAttributeInfo[] attributes = info.getAttributes();
+      boolean trace = log.isTraceEnabled();
+      for (int i = 0; i < attributes.length; i++)
+      {
+         if (trace)
+            log.trace("considering attribute: " + attributes[i]);
+         if (attributes[i].isReadable() && attributes[i].isWritable())
+         {
+            Element attributeElement = null;
+            if (attributes[i].getType().equals("javax.management.ObjectName"))
+            {
+               attributeElement = doc.createElement("depends");
+               attributeElement.setAttribute("optional-attribute-name", attributes[i].getName());
+            }
+            else
+            {
+               attributeElement = doc.createElement("attribute");
+               attributeElement.setAttribute("name", attributes[i].getName());
+            }
+            Object value = server.getAttribute(name, attributes[i].getName());
+
+            if (value != null)
+            {
+               if (value instanceof Element)
+               {
+                  attributeElement.appendChild(doc.importNode((Element) value, true));
+               }
+               else
+               {
+                  attributeElement.appendChild(doc.createTextNode(value.toString()));
+               }
+            }
+            mbeanElement.appendChild(attributeElement);
+         }
+      }
+
+      ServiceContext sc = serviceController.getServiceContext(name);
+      for (Iterator i = sc.iDependOn.iterator(); i.hasNext();)
+      {
+         ServiceContext needs = (ServiceContext) i.next();
+         Element dependsElement = doc.createElement("depends");
+         dependsElement.appendChild(doc.createTextNode(needs.objectName.toString()));
+         mbeanElement.appendChild(dependsElement);
+      }
+
+      return mbeanElement;
+   }
+
+   /**
+    * Parse an object name from the given element attribute 'name'.
+    * @param element Element to parse name from.
+    * @return Object name.
+    * @throws ConfigurationException Missing attribute 'name' (thrown if 'name'
+    * is null or "").
+    * @throws Exception
+    */
+   private ObjectName parseObjectName(final Element element, boolean replace)
+      throws Exception
+   {
+      String name = element.getAttribute("name");
+
+      if (name == null || name.trim().equals(""))
+      {
+         throw new DeploymentException("MBean attribute 'name' must be given.");
+      }
+
+      if (replace)
+         name = StringPropertyReplacer.replaceProperties(name);
+
+      return new ObjectName(name);
+   }
+
+   private String getElementContent(Element element, boolean trim, boolean replace)
+      throws Exception
+   {
+      NodeList nl = element.getChildNodes();
+      String attributeText = "";
+      for (int i = 0; i < nl.getLength(); i++)
+      {
+         Node n = nl.item(i);
+         if (n instanceof Text)
+         {
+            attributeText += ((Text) n).getData();
+         }
+      } // end of for ()
+      if (trim)
+         attributeText = attributeText.trim();
+      if (replace)
+         attributeText = StringPropertyReplacer.replaceProperties(attributeText);
+      return attributeText;
+   }
+
+   /**
+    * A utility method that transforms the contents of the argument element into
+    * a StringBuffer representation that can be reparsed.
+    * 
+    * [FIXME] This is not a general DOMUtils method because of its funny contract. It does not 
+    * support multiple child elements neither can it deal with text content.
+    * 
+    * @param element - the parent dom element whose contents are to be extracted as an xml document string. 
+    * @return the xml document string.
+    */
+   public static StringBuffer getElementContent(Element element) throws IOException, TransformerException
+   {
+      NodeList children = element.getChildNodes();
+      Element content = null;
+      for (int n = 0; n < children.getLength(); n++)
+      {
+         Node node = children.item(n);
+         if (node.getNodeType() == Node.ELEMENT_NODE)
+         {
+            content = (Element)node;
+            break;
+         }
+      }
+      if (content == null)
+         return null;
+
+      // Get a parsable representation of this elements content
+      DOMSource source = new DOMSource(content);
+      TransformerFactory tFactory = TransformerFactory.newInstance();
+      Transformer transformer = tFactory.newTransformer();
+      StringWriter sw = new StringWriter();
+      StreamResult result = new StreamResult(sw);
+      transformer.transform(source, result);
+      sw.close();
+      return sw.getBuffer();
+   }
+}
\ No newline at end of file

Added: trunk/system/src/tests/org/jboss/test/system/controller/legacy/OldServiceController.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/legacy/OldServiceController.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/legacy/OldServiceController.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,902 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.system.controller.legacy;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+
+import javax.management.JMException;
+import javax.management.MBeanInfo;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanRegistration;
+import javax.management.MBeanServer;
+import javax.management.Notification;
+import javax.management.ObjectName;
+
+import org.jboss.deployment.DeploymentException;
+import org.jboss.deployment.DeploymentInfo;
+import org.jboss.deployment.DeploymentState;
+import org.jboss.logging.Logger;
+import org.jboss.mx.server.ServerConstants;
+import org.jboss.mx.util.JBossNotificationBroadcasterSupport;
+import org.jboss.mx.util.JMXExceptionDecoder;
+import org.jboss.mx.util.ObjectNameFactory;
+import org.jboss.system.Service;
+import org.jboss.system.ServiceBinding;
+import org.jboss.system.ServiceContext;
+import org.jboss.system.ServiceFactory;
+import org.jboss.system.ServiceMBean;
+import org.w3c.dom.Element;
+
+/**
+ * This is the main Service Controller. A controller can deploy a service to a
+ * jboss.system It installs by delegating, it configures by delegating
+ *
+ * @see org.jboss.system.Service
+ *
+ * @author <a href="mailto:marc.fleury at jboss.org">Marc Fleury</a>
+ * @author <a href="mailto:d_jencks at users.sourceforge.net">David Jencks</a>
+ * @author <a href="mailto:scott.stark at jboss.org">Scott Stark</a>
+ * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
+ * @version $Revision: 1.61 $
+ */
+public class OldServiceController extends JBossNotificationBroadcasterSupport
+   implements OldServiceControllerMBean, MBeanRegistration
+{
+   /** The ObjectName of the default loader repository */
+   public static final ObjectName DEFAULT_LOADER_REPOSITORY = ObjectNameFactory.create(ServerConstants.DEFAULT_LOADER_NAME);
+
+   /** The operation name for lifecycle */
+   public static final String JBOSS_INTERNAL_LIFECYCLE = "jbossInternalLifecycle";
+
+   /** The signature for lifecycle operations */
+   public static final String[] JBOSS_INTERNAL_LIFECYCLE_SIG = new String[] { String.class.getName() };
+
+   /** Class logger. */
+   private static final Logger log = Logger.getLogger(OldServiceController.class);
+
+   /** A callback to the JMX MBeanServer */
+   protected MBeanServer server;
+
+   /** Creator, helper class to instantiate MBeans **/
+   protected OldServiceCreator creator;
+
+   /** Configurator, helper class to configure MBeans **/
+   protected OldServiceConfigurator configurator;
+
+   /** ObjectName to ServiceContext map **/
+   protected Map<ObjectName, ServiceContext> nameToServiceMap = Collections.synchronizedMap(new HashMap<ObjectName, ServiceContext>());
+
+   /** A linked list of services in the order they were created **/
+   protected List<ServiceContext> installedServices = new LinkedList<ServiceContext>();
+
+   /**
+    * Plugin a ServiceBinding policy
+    * 
+    * @param serviceBinding policy
+    */   
+   public void setServiceBinding(ServiceBinding serviceBinding)
+   {
+      if (configurator != null)
+      {
+         configurator.setServiceBinding(serviceBinding);
+      }
+   }
+   
+   public List<ServiceContext> listDeployed()
+   {
+      return new ArrayList<ServiceContext>(installedServices);
+   }
+
+   public List<ServiceContext> listIncompletelyDeployed()
+   {
+      List<ServiceContext> id = new ArrayList<ServiceContext>();
+      for (Iterator<ServiceContext> i = installedServices.iterator(); i.hasNext();)
+      {
+         ServiceContext sc = i.next();
+         if ( sc.state != ServiceContext.CREATED &&
+              sc.state != ServiceContext.RUNNING &&
+              sc.state != ServiceContext.STOPPED &&
+              sc.state != ServiceContext.DESTROYED )
+         {
+            id.add(sc);
+         }
+      }
+      return id;
+   }
+
+   public List<ObjectName> listDeployedNames()
+   {
+      List<ObjectName> names = new ArrayList<ObjectName>(installedServices.size());
+      for (Iterator<ServiceContext> i = installedServices.iterator(); i.hasNext();)
+      {
+         ServiceContext ctx = i.next();
+         names.add(ctx.objectName);
+      }
+
+      return names;
+   }
+
+   public String listConfiguration(ObjectName[] objectNames) throws Exception
+   {
+      return configurator.getConfiguration(objectNames);
+   }
+
+   public void validateDeploymentState(DeploymentInfo di, DeploymentState state)
+   {
+      ArrayList<ObjectName> mbeans = new ArrayList<ObjectName>(di.mbeans);
+      if (di.deployedObject != null)
+         mbeans.add(di.deployedObject);
+      boolean mbeansStateIsValid = true;
+      for (int m = 0; m < mbeans.size(); m++)
+      {
+         ObjectName serviceName = mbeans.get(m);
+         ServiceContext ctx = this.getServiceContext(serviceName);
+         if (ctx != null && state == DeploymentState.STARTED)
+            mbeansStateIsValid &= ctx.state == ServiceContext.RUNNING;
+      }
+      if (mbeansStateIsValid == true)
+         di.state = state;
+   }
+
+   public synchronized List<ObjectName> install(Element config, ObjectName loaderName)
+         throws DeploymentException
+   {
+      List<ObjectName> mbeans = configurator.install(config, loaderName);
+      for (Iterator<ObjectName> i = mbeans.iterator(); i.hasNext();)
+      {
+         ObjectName mbean = i.next();
+         installedServices.add(createServiceContext(mbean));
+      }
+      return mbeans;
+   }
+
+   public synchronized void register(ObjectName serviceName) throws Exception
+   {
+      register(serviceName, null);
+   }
+
+   public synchronized void register(ObjectName serviceName, Collection<ObjectName> depends)
+         throws Exception
+   {
+      if (serviceName == null)
+      {
+         log.warn("Ignoring request to register null service: ", new Exception("STACKTRACE"));
+         return;
+      }
+      
+      log.debug("Registering service " + serviceName);
+      ServiceContext ctx = createServiceContext(serviceName);
+
+      register(ctx, depends);
+   }
+
+   public synchronized void create(ObjectName serviceName) throws Exception
+   {
+      create(serviceName, null);
+   }
+
+   public synchronized void create(ObjectName serviceName, Collection<ObjectName> depends)
+         throws Exception
+   {
+      if (serviceName == null)
+      {
+         log.warn("Ignoring request to create null service: ", new Exception("STACKTRACE"));
+         return;
+      }
+      
+      log.debug("Creating service " + serviceName);
+      ServiceContext ctx = createServiceContext(serviceName);
+
+      // Register the context and its dependencies if necessary
+      register(ctx, depends);
+
+      // If we are already created (can happen in dependencies) or failed just return
+      if (ctx.state == ServiceContext.CREATED
+            || ctx.state == ServiceContext.RUNNING
+            || ctx.state == ServiceContext.FAILED)
+      {
+         log.debug("Ignoring create request for service: " + ctx.objectName);
+         return;
+      }
+
+      // JSR 77, and to avoid circular dependencies
+      int oldState = ctx.state;
+      ctx.state = ServiceContext.CREATED;
+
+      // Are all the mbeans I depend on created?   if not just return
+      for (Iterator iterator = ctx.iDependOn.iterator(); iterator.hasNext();)
+      {
+         ServiceContext sc = (ServiceContext) iterator.next();
+         int state = sc.state;
+
+         // A dependent is not created or running
+         if (!(state == ServiceContext.CREATED || state == ServiceContext.RUNNING))
+         {
+            log.debug("waiting in create of " + serviceName +
+                  " waiting on " + sc.objectName);
+            ctx.state = oldState;
+            return;
+         }
+      }
+
+      // Call create on the service Proxy
+      try
+      {
+         ctx.proxy.create();
+         sendControllerNotification(ServiceMBean.CREATE_EVENT, serviceName);            
+      }
+      catch (Throwable e)
+      {
+         ctx.state = ServiceContext.FAILED;
+         ctx.problem = e;
+         log.warn("Problem creating service " + serviceName, e);
+         return;
+      }
+
+      // Those that depend on me are waiting for my creation, recursively create them
+      log.debug("Creating dependent components for: " + serviceName
+            + " dependents are: " + ctx.dependsOnMe);
+      ArrayList<ServiceContext> tmp = new ArrayList<ServiceContext>(ctx.dependsOnMe);
+      for (int n = 0; n < tmp.size(); n++)
+      {
+         // marcf fixme circular dependencies?
+         ServiceContext ctx2 = tmp.get(n);
+         create(ctx2.objectName);
+      }
+      tmp.clear();
+   }
+
+   public synchronized void start(ObjectName serviceName) throws Exception
+   {
+      if (serviceName == null)
+      {
+         log.warn("Ignoring request to start null service: ", new Exception("STACKTRACE"));
+         return;
+      }
+
+      log.debug("starting service " + serviceName);
+
+      ServiceContext ctx = createServiceContext(serviceName);
+
+      if (!installedServices.contains(ctx))
+         installedServices.add(ctx);
+
+      // If we are already started (can happen in dependencies) just return
+      if (ctx.state == ServiceContext.RUNNING || ctx.state == ServiceContext.FAILED)
+      {
+         log.debug("Ignoring start request for service: " + ctx.objectName);
+         return;
+      }
+
+      // Start() is called before create(), so call create() to compensate
+      if (ctx.state != ServiceContext.CREATED && ctx.state != ServiceContext.STOPPED)
+      {
+         log.debug("Start requested before create, calling create now for service: " + serviceName);
+         create(serviceName);
+      }
+      
+      // Get the fancy service proxy (for the lifecycle API)
+      if (ctx.proxy == null)
+         ctx.proxy = getServiceProxy(ctx.objectName, null);
+
+      // JSR 77, and to avoid circular dependencies
+      int oldState = ctx.state;
+      ctx.state = ServiceContext.RUNNING;
+
+      // Are all the mbeans I depend on started?   if not just return
+      for (Iterator iterator = ctx.iDependOn.iterator(); iterator.hasNext();)
+      {
+         ServiceContext sctx = (ServiceContext) iterator.next();
+
+         int state = sctx.state;
+
+         // A dependent is not running
+         if (!(state == ServiceContext.RUNNING))
+         {
+            log.debug("waiting in start " + serviceName + " on " + sctx.objectName);
+            ctx.state = oldState;
+            return;
+         }
+      }
+
+      // Call start on the service Proxy
+      try
+      {
+         ctx.proxy.start();
+         sendControllerNotification(ServiceMBean.START_EVENT, serviceName);            
+      }
+      catch (Throwable e)
+      {
+         ctx.state = ServiceContext.FAILED;
+         ctx.problem = e;
+         log.warn("Problem starting service " + serviceName, e);
+         return;
+      }
+      // Those that depend on me are waiting for my start, recursively start them
+      log.debug("Starting dependent components for: " + serviceName
+            + " dependent components: " + ctx.dependsOnMe);
+      ArrayList<ServiceContext> tmp = new ArrayList<ServiceContext>(ctx.dependsOnMe);
+      for (int n = 0; n < tmp.size(); n++)
+      {
+         // marcf fixme circular dependencies?
+         ServiceContext ctx2 = tmp.get(n);
+         start(ctx2.objectName);
+      }
+      tmp.clear();
+   }
+
+   public void restart(ObjectName serviceName) throws Exception
+   {
+      if (serviceName == null)
+      {
+         log.warn("Ignoring request to restart null service: ", new Exception("STACKTRACE"));
+         return;
+      }
+
+      log.debug("restarting service " + serviceName);
+      stop(serviceName);
+      start(serviceName);
+   }
+
+   public void stop(ObjectName serviceName) throws Exception
+   {
+      if (serviceName == null)
+      {
+         log.warn("Ignoring request to stop null service: ", new Exception("STACKTRACE"));
+         return;
+      }
+
+      ServiceContext ctx = nameToServiceMap.get(serviceName);
+      log.debug("stopping service: " + serviceName);
+
+      if (ctx == null)
+      {
+         log.warn("Ignoring request to stop nonexistent service: " + serviceName);
+         return;
+      }
+
+      // If we are already stopped (can happen in dependencies) just return
+      if (ctx.state != ServiceContext.RUNNING) return;
+
+      // JSR 77 and to avoid circular dependencies
+      ctx.state = ServiceContext.STOPPED;
+
+      log.debug("stopping dependent services for: " + serviceName
+            + " dependent services are: " + ctx.dependsOnMe);
+      
+      ArrayList<ServiceContext> tmp = new ArrayList<ServiceContext>(ctx.dependsOnMe);
+      for (int n = 0; n < tmp.size(); n++)
+      {
+         // stop all the mbeans that depend on me
+         ServiceContext ctx2 = tmp.get(n);
+         ObjectName other = ctx2.objectName;
+         stop(other);
+      }
+      tmp.clear();
+
+      // Call stop on the service Proxy
+      if (ctx.proxy != null)
+      {
+         try
+         {
+            ctx.proxy.stop();
+            sendControllerNotification(ServiceMBean.STOP_EVENT, serviceName);
+         }
+         catch (Throwable e)
+         {
+            ctx.state = ServiceContext.FAILED;
+            ctx.problem = e;
+            log.warn("Problem stopping service " + serviceName, e);
+         }
+      }
+   }
+
+   public void destroy(ObjectName serviceName) throws Exception
+   {
+      if (serviceName == null)
+      {
+         log.warn("Ignoring request to destroy null service: ", new Exception("STACKTRACE"));
+         return;
+      }
+
+      ServiceContext ctx = nameToServiceMap.get(serviceName);
+      log.debug("destroying service: " + serviceName);
+
+      if (ctx == null)
+      {
+         log.warn("Ignoring request to destroy nonexistent service: " + serviceName);
+         return;
+      }
+
+      // If we are already destroyed (can happen in dependencies) just return
+      if (ctx.state == ServiceContext.DESTROYED ||
+          ctx.state == ServiceContext.NOTYETINSTALLED)
+         return;
+      
+      // If we are still running, stop service first
+      if (ctx.state == ServiceContext.RUNNING)
+      {
+         log.debug("Destroy requested before stop, calling stop now for service: " + serviceName);
+         stop(serviceName);
+      }
+
+      // JSR 77, and to avoid circular dependencies
+      ctx.state = ServiceContext.DESTROYED;
+
+      log.debug("destroying dependent services for: " + serviceName
+            + " dependent services are: " + ctx.dependsOnMe);
+      
+      ArrayList<ServiceContext> tmp = new ArrayList<ServiceContext>(ctx.dependsOnMe);
+      for (int n = 0; n < tmp.size(); n++)
+      {
+         // destroy all the mbeans that depend on me
+         ServiceContext ctx2 = tmp.get(n);
+         ObjectName other = ctx2.objectName;
+         destroy(other);
+      }
+      tmp.clear();
+
+      // Call destroy on the service Proxy
+      if (ctx.proxy != null)
+      {
+         try
+         {
+            ctx.proxy.destroy();
+            sendControllerNotification(ServiceMBean.DESTROY_EVENT, serviceName);
+         }
+         catch (Throwable e)
+         {
+            ctx.state = ServiceContext.FAILED;
+            ctx.problem = e;
+            log.warn("Problem destroying service " + serviceName, e);
+         }
+      }
+   }
+
+   public void remove(ObjectName objectName) throws Exception
+   {
+      if (objectName == null)
+      {
+         log.warn("Ignoring request to remove null service: ", new Exception("STACKTRACE"));
+         return;
+      }
+
+      ServiceContext ctx = nameToServiceMap.get(objectName);
+      if (ctx == null)
+      {
+         log.debug("Ignoring request to remove nonexistent service: " + objectName);
+         return;
+      }
+      log.debug("removing service: " + objectName);
+
+      // Notify those that think I depend on them
+      Iterator iterator = ctx.iDependOn.iterator();
+      while (iterator.hasNext())
+      {
+         ServiceContext iDependOnContext = (ServiceContext) iterator.next();
+         iDependOnContext.dependsOnMe.remove(ctx);
+
+         // Remove any context whose only reason for existence is that
+         // we depend on it, i.e. it otherwise unknown to the system
+         if (iDependOnContext.state == ServiceContext.NOTYETINSTALLED
+               && iDependOnContext.dependsOnMe.size() == 0)
+         {
+            nameToServiceMap.remove(iDependOnContext.objectName);
+            log.debug("Removing context for nonexistent service it is " +
+                  "no longer recording dependencies: " + iDependOnContext);
+         }
+      }
+      //We remove all traces of our dependency configuration, since we
+      //don't know what will show up the next time we are deployed.
+      ctx.iDependOn.clear();
+
+      // Do we have a deployed MBean?
+      if (server.isRegistered(objectName))
+      {
+         log.debug("removing " + objectName + " from server");
+
+         // Remove the context, unless it is still recording dependencies
+         if (ctx.dependsOnMe.size() == 0)
+            nameToServiceMap.remove(objectName);
+         else
+         {
+            log.debug("Context not removed, it is recording " +
+                  "dependencies: " + ctx);
+            ctx.proxy = null;
+         }
+
+         // remove the mbean from the instaled ones
+         installedServices.remove(ctx);
+         creator.remove(objectName);
+      }
+      else
+      {
+         // Remove the context, unless it is still recording dependencies
+         installedServices.remove(ctx);
+         if (ctx.dependsOnMe.size() == 0)
+         {
+            log.debug("removing already unregistered " + objectName + " from server");
+            nameToServiceMap.remove(objectName);
+         }
+         else
+         {
+            log.debug("no need to remove " + objectName + " from server");
+            ctx.proxy = null;
+         }
+      }
+      // This context is no longer installed, but it may still exist
+      // to record dependent services
+      ctx.state = ServiceContext.NOTYETINSTALLED;
+   }
+
+   /**
+    * Lookup the ServiceContext for the given serviceName
+    *
+    * @jmx.managed-operation
+    */
+   public ServiceContext getServiceContext(ObjectName serviceName)
+   {
+      ServiceContext ctx = nameToServiceMap.get(serviceName);
+      return ctx;
+   }
+   
+   public void shutdown()
+   {
+      log.debug("Stopping " + nameToServiceMap.size() + " services");
+
+      List<ServiceContext> servicesCopy = new ArrayList<ServiceContext>(installedServices);
+
+      int serviceCounter = 0;
+      ObjectName name = null;
+
+      ListIterator i = servicesCopy.listIterator(servicesCopy.size());
+      while (i.hasPrevious())
+      {
+         ServiceContext ctx = (ServiceContext) i.previous();
+         name = ctx.objectName;
+
+         // Go through the full stop/destroy cycle
+         try
+         {
+            stop(name);
+         }
+         catch (Throwable e)
+         {
+            log.error("Could not stop mbean: " + name, e);
+         }
+         try
+         {
+            destroy(name);
+         }
+         catch (Throwable e)
+         {
+            log.error("Could not destroy mbean: " + name, e);
+         }
+         try
+         {
+            remove(name);
+            serviceCounter++;
+         }
+         catch (Throwable e)
+         {
+            log.error("Could not remove mbean: " + name, e);
+         }
+      }
+      log.debug("Stopped " + serviceCounter + " services");
+   }
+   
+   // MBeanRegistration implementation ----------------------------------------
+
+   /**
+    * #Description of the Method
+    *
+    * @param server Description of Parameter
+    * @param name Description of Parameter
+    * @return Description of the Returned Value
+    * @exception Exception Description of Exception
+    */
+   public ObjectName preRegister(MBeanServer server, ObjectName name)
+         throws Exception
+   {
+      this.server = server;
+
+      creator = new OldServiceCreator(server);
+      configurator = new OldServiceConfigurator(server, this, creator);
+
+      // Register the ServiceController as a running service
+      ServiceContext sc = this.createServiceContext(name);
+      sc.state = ServiceContext.RUNNING;
+
+      log.debug("Controller MBean online");
+      return name == null ? OBJECT_NAME : name;
+   }
+
+   public void postRegister(Boolean registrationDone)
+   {
+      if (!registrationDone.booleanValue())
+      {
+         log.info("Registration of ServiceController failed");
+      }
+   }
+
+   public void preDeregister()
+         throws Exception
+   {
+   }
+
+   public void postDeregister()
+   {
+      nameToServiceMap.clear();
+      installedServices.clear();
+      creator.shutdown();
+      creator = null;
+      configurator = null;
+      server = null;
+   }
+
+   // Package Protected ---------------------------------------------
+   
+   // Create a Service Context for the service, or get one if it exists
+   synchronized ServiceContext createServiceContext(ObjectName objectName)
+   {
+      // If it is already there just return it
+      if (nameToServiceMap.containsKey(objectName))
+         return nameToServiceMap.get(objectName);
+
+      // If not create it, add it and return it
+      ServiceContext ctx = new ServiceContext();
+      ctx.objectName = objectName;
+
+      // we keep track of these here
+      nameToServiceMap.put(objectName, ctx);
+
+      return ctx;
+   }
+
+   void registerDependency(ObjectName needs, ObjectName used)
+   {
+      log.debug("recording that " + needs + " depends on " + used);
+      ServiceContext needsCtx = createServiceContext(needs);
+      ServiceContext usedCtx = createServiceContext(used);
+
+
+      if (!needsCtx.iDependOn.contains(usedCtx))
+      {
+         // needsCtx depends on usedCtx
+         needsCtx.iDependOn.add(usedCtx);
+         // UsedCtx needs to know I depend on him
+         usedCtx.dependsOnMe.add(needsCtx);
+      }
+   }
+
+   // Private -------------------------------------------------------
+   
+   /**
+    * Register the service context and its dependencies against the microkernel.
+    * If the context is already registered it does nothing.
+    * 
+    * @param ctx the ServiceContext to register
+    * @param depends a collection of ObjectNames of services the registered service depends on
+    */
+   private void register(ServiceContext ctx, Collection depends) throws Exception
+   {
+      if (!installedServices.contains(ctx))
+         installedServices.add(ctx);
+      
+      if (depends != null)
+      {
+         log.debug("adding depends in ServiceController.register: " + depends);
+         for (Iterator i = depends.iterator(); i.hasNext();)
+         {
+            registerDependency(ctx.objectName, (ObjectName) i.next());
+         }
+      }
+
+      // Get the fancy service proxy (for the lifecycle API), if needed
+      if (ctx.proxy == null)
+         ctx.proxy = getServiceProxy(ctx.objectName, null);
+   }
+   
+   /**
+    * Get the Service interface through which the mbean given by objectName
+    * will be managed.
+    *
+    * @param objectName
+    * @param serviceFactory
+    * @return The Service value
+    *
+    * @throws ClassNotFoundException
+    * @throws InstantiationException
+    * @throws IllegalAccessException
+    */
+   private Service getServiceProxy(ObjectName objectName, String serviceFactory)
+         throws ClassNotFoundException, InstantiationException,
+         IllegalAccessException, JMException
+   {
+      Service service = null;
+      ClassLoader loader = Thread.currentThread().getContextClassLoader();
+      if (serviceFactory != null && serviceFactory.length() > 0)
+      {
+         Class clazz = loader.loadClass(serviceFactory);
+         ServiceFactory factory = (ServiceFactory) clazz.newInstance();
+         service = factory.createService(server, objectName);
+      }
+      else
+      {
+         MBeanInfo info = server.getMBeanInfo(objectName);
+         MBeanOperationInfo[] opInfo = info.getOperations();
+         Class[] interfaces = {Service.class};
+         InvocationHandler handler = new ServiceProxy(objectName, opInfo);
+         service = (Service) Proxy.newProxyInstance(Service.class.getClassLoader(), interfaces, handler);
+      }
+
+      return service;
+   }
+
+   /**
+    * Sends outs controller notifications about service lifecycle events 
+    */
+   private void sendControllerNotification(String type, ObjectName serviceName)
+   {
+      Notification notification = new Notification(type, this, super.nextNotificationSequenceNumber());
+      notification.setUserData(serviceName);
+      sendNotification(notification);
+   }
+   
+   // Inner classes -------------------------------------------------
+
+   /**
+    * A mapping from the Service interface method names to the corresponding
+    * index into the ServiceProxy.hasOp array.
+    */
+   private static HashMap<String, Integer> serviceOpMap = new HashMap<String, Integer>();
+
+   /**
+    * An implementation of InvocationHandler used to proxy of the Service
+    * interface for mbeans. It determines which of the start/stop
+    * methods of the Service interface an mbean implements by inspecting its
+    * MBeanOperationInfo values. Each Service interface method that has a
+    * matching operation is forwarded to the mbean by invoking the method
+    * through the MBeanServer object.
+    */
+   public class ServiceProxy implements InvocationHandler
+   {
+      private boolean[] hasOp = {false, false, false, false};
+      private ObjectName objectName;
+
+      /** Whether we have the lifecycle method */
+      private boolean hasJBossInternalLifecycle;
+
+      /**
+       * Go through the opInfo array and for each operation that matches on of
+       * the Service interface methods set the corresponding hasOp array value
+       * to true.
+       *
+       * @param objectName
+       * @param opInfo
+       */
+      public ServiceProxy(ObjectName objectName, MBeanOperationInfo[] opInfo)
+      {
+         this.objectName = objectName;
+
+         for (int op = 0; op < opInfo.length; op++)
+         {
+            MBeanOperationInfo info = opInfo[op];
+            String name = info.getName();
+
+            if (name.equals(JBOSS_INTERNAL_LIFECYCLE))
+            {
+               hasJBossInternalLifecycle = true;
+               continue;
+            }
+
+            Integer opID = serviceOpMap.get(name);
+            if (opID == null)
+            {
+               continue;
+            }
+
+            // Validate that is a no-arg void return type method
+            if (info.getReturnType().equals("void") == false)
+            {
+               continue;
+            }
+            if (info.getSignature().length != 0)
+            {
+               continue;
+            }
+
+            hasOp[opID.intValue()] = true;
+         }
+      }
+
+      /**
+       * Map the method name to a Service interface method index and if the
+       * corresponding hasOp array element is true, dispatch the method to the
+       * mbean we are proxying.
+       *
+       * @param proxy
+       * @param method
+       * @param args
+       * @return             Always null.
+       * @throws Throwable
+       */
+      public Object invoke(Object proxy, Method method, Object[] args)
+            throws Throwable
+      {
+         String name = method.getName();
+
+         if (hasJBossInternalLifecycle)
+         {
+            try
+            {
+               server.invoke(objectName, JBOSS_INTERNAL_LIFECYCLE, new Object[] { name }, JBOSS_INTERNAL_LIFECYCLE_SIG);
+               return null;
+            }
+            catch (Exception e)
+            {
+               throw JMXExceptionDecoder.decode(e);
+            }
+         }
+
+         Integer opID = serviceOpMap.get(name);
+
+         if (opID != null && hasOp[opID.intValue()] == true)
+         {
+            // deal with those pesky JMX exceptions
+            try
+            {
+               String[] sig = {};
+               server.invoke(objectName, name, args, sig);
+            }
+            catch (Exception e)
+            {
+               throw JMXExceptionDecoder.decode(e);
+            }
+         }
+
+         return null;
+      }
+   }
+
+   /**
+    * Initialize the service operation map.
+    */
+   static
+   {
+      serviceOpMap.put("create", new Integer(0));
+      serviceOpMap.put("start", new Integer(1));
+      serviceOpMap.put("destroy", new Integer(2));
+      serviceOpMap.put("stop", new Integer(3));
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/legacy/OldServiceControllerMBean.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/legacy/OldServiceControllerMBean.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/legacy/OldServiceControllerMBean.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.system.controller.legacy;
+
+import org.jboss.system.ServiceControllerMBean;
+
+/**
+ * ServiceController MBean interface.
+ * 
+ * @see org.jboss.system.Service
+ */
+public interface OldServiceControllerMBean extends ServiceControllerMBean
+{
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/legacy/OldServiceCreator.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/legacy/OldServiceCreator.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/legacy/OldServiceCreator.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,378 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.system.controller.legacy;
+
+import java.beans.PropertyEditor;
+import java.beans.PropertyEditorManager;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.UndeclaredThrowableException;
+import java.net.URL;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectInstance;
+import javax.management.ObjectName;
+
+import org.jboss.deployment.DeploymentException;
+import org.jboss.logging.Logger;
+import org.jboss.mx.service.ServiceConstants;
+import org.jboss.mx.util.JMXExceptionDecoder;
+import org.jboss.system.ConfigurationException;
+import org.jboss.util.Classes;
+import org.jboss.util.StringPropertyReplacer;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+/**
+ * A helper class for the controller.
+ *
+ * @see Service
+ *
+ * @author <a href="mailto:marc.fleury at jboss.org">Marc Fleury</a>
+ * @author <a href="mailto:d_jencks at users.sourceforge.net">David Jencks</a>
+ * @version $Revision: 1.22 $
+ */
+public class OldServiceCreator
+{
+   // Static --------------------------------------------------------
+   
+   /** The default XMBean class, when one is not specified */
+   private static final String XMBEAN_CODE = "org.jboss.mx.modelmbean.XMBean";
+   
+   /** Instance logger. */
+   private static final Logger log = Logger.getLogger(OldServiceCreator.class);
+
+   // Attributes ----------------------------------------------------
+   
+   /** The server */
+   private MBeanServer server;
+
+   // Constructors --------------------------------------------------
+   
+   /**
+    * CTOR
+    */
+   public OldServiceCreator(final MBeanServer server)
+   {
+      this.server = server;
+   }
+
+   // Public --------------------------------------------------------
+   
+   /**
+    * Clean shutdown
+    */
+   public void shutdown()
+   {
+      this.server = null;
+   } 
+   
+   /**
+    * Parses the given configuration document and creates MBean
+    * instances in the current MBean server.
+    *
+    * @param configuration     The configuration document.
+    *
+    * @throws ConfigurationException   The configuration document contains
+    *                                  invalid or missing syntax.
+    * @throws Exception                Failed for some other reason.
+    */
+   public ObjectInstance install(ObjectName mbeanName, ObjectName loaderName,
+      Element mbeanElement) throws Exception
+   {
+      if (server.isRegistered(mbeanName))
+      {
+         throw new DeploymentException("Trying to install an already registered mbean: " + mbeanName);
+      }
+      // If class is given, instantiate it
+      String code = mbeanElement.getAttribute("code");
+      if ( code == null || "".equals(code))
+      {
+         throw new ConfigurationException("missing 'code' attribute");
+      }
+
+      // get the constructor params/sig to use
+      ConstructorInfo constructor = ConstructorInfo.create(mbeanElement);
+
+      // Check for xmbean specific attributes
+      String xmbeandd = null;
+      Attr xmbeanddAttr = mbeanElement.getAttributeNode("xmbean-dd");
+      if( xmbeanddAttr != null )
+         xmbeandd = xmbeanddAttr.getValue();
+      String xmbeanCode = mbeanElement.getAttribute("xmbean-code");
+      if( xmbeanCode.length() == 0 )
+         xmbeanCode = XMBEAN_CODE;
+
+      // Create the mbean instance
+      ObjectInstance instance = null;
+      try
+      {
+         if ( xmbeandd == null )
+         {
+            // Check for the explicit management interface in case of a standard MBean
+            Attr itfAttr = mbeanElement.getAttributeNode("interface");
+            if (itfAttr != null)
+            {
+               // Get the good class loader
+               ClassLoader classLoader = server.getClassLoader(loaderName);
+
+               // Load interface class
+               String itf = itfAttr.getValue();
+               Class itfClass = classLoader.loadClass(itf);
+               log.debug("About to create bean resource: " + mbeanName + " with code: " + code);
+               Object resource = server.instantiate(code,
+                                                    loaderName,
+                                                    constructor.params,
+                                                    constructor.signature);
+               //
+               log.debug("About to register StandardMBean : " + mbeanName);
+               instance = server.createMBean("javax.management.StandardMBean",
+                                             mbeanName,
+                                             loaderName,
+                                             new Object[]{resource,itfClass},
+                                             new String[]{Object.class.getName(),Class.class.getName()});
+            }
+            else
+            {
+               // This is a standard or dynamic mbean
+               log.debug("About to create bean: " + mbeanName + " with code: " + code);
+               instance = server.createMBean(code,
+                                             mbeanName,
+                                             loaderName,
+                                             constructor.params,
+                                             constructor.signature);
+            }
+         } // end of if ()
+         else if( xmbeandd.length() == 0 )
+         {
+            // This is an xmbean with an embedded mbean descriptor
+            log.debug("About to create xmbean object: " + mbeanName
+               + " with code: " + code + " with embedded descriptor");
+            //xmbean: construct object first.
+            Object resource = server.instantiate(code, loaderName,
+                  constructor.params, constructor.signature);
+
+            NodeList mbeans = mbeanElement.getElementsByTagName("xmbean");
+            if( mbeans.getLength() == 0 )
+               throw new ConfigurationException("No nested mbean element given for xmbean");
+            Element mbeanDescriptor = (Element) mbeans.item(0);
+            Object[] args = {resource, mbeanDescriptor,
+                             ServiceConstants.PUBLIC_JBOSSMX_XMBEAN_DTD_1_0};
+            String[] sig = {Object.class.getName(), Element.class.getName(),
+                            String.class.getName()};
+            instance = server.createMBean(xmbeanCode,
+                                          mbeanName,
+                                          loaderName,
+                                          args,
+                                          sig);
+         }
+         else
+         {
+            // This is an xmbean with an external descriptor
+            log.debug("About to create xmbean object: " + mbeanName
+               + " with code: " + code + " with descriptor: "+xmbeandd);
+            //xmbean: construct object first.
+            Object resource = server.instantiate(code, loaderName,
+                  constructor.params, constructor.signature);
+            // Try to find the dd first as a resource then as a URL
+            URL xmbeanddUrl = null;
+            try
+            {
+               xmbeanddUrl = resource.getClass().getClassLoader().getResource(xmbeandd);
+            }
+            catch (Exception e)
+            {
+            } // end of try-catch
+            if (xmbeanddUrl == null)
+            {
+               xmbeanddUrl = new URL(xmbeandd);
+            } // end of if ()
+
+            //now create the mbean
+            Object[] args = {resource, xmbeanddUrl};
+            String[] sig = {Object.class.getName(), URL.class.getName()};
+            instance = server.createMBean(xmbeanCode,
+                                          mbeanName,
+                                          loaderName,
+                                          args,
+                                          sig);
+         } // end of else
+      }
+      catch (Throwable e)
+      {
+         Throwable newE = JMXExceptionDecoder.decode(e);
+
+         // didn't work, unregister in case the jmx agent is screwed.
+         try
+         {
+            server.unregisterMBean(mbeanName);
+         }
+         catch (Throwable ignore)
+         {
+         }
+
+         if (newE instanceof Exception)
+         {
+            throw (Exception)newE;
+         } // end of if ()
+         throw new UndeclaredThrowableException(newE);
+      }
+
+      log.debug("Created bean: "+mbeanName);
+      return instance;
+   }
+
+   public void remove(ObjectName name) throws Exception
+   {
+      // add defaut domain if there isn't one in this name
+      String domain = name.getDomain();
+      if (domain == null || "".equals(domain))
+      {
+         name = new ObjectName(server.getDefaultDomain() + name);
+      }
+
+      // Remove the MBean from the MBeanServer
+      server.unregisterMBean(name);
+   }
+
+   // Inner Class  --------------------------------------------------
+   
+   /**
+    * Provides a wrapper around the information about which constructor
+    * that MBeanServer should use to construct a MBean.
+    * Please note that only basic datatypes (type is then the same as
+    * you use to declare it "short", "int", "float" etc.) and any class
+    * having a constructor taking a single "String" as only parameter.
+    *
+    * <p>XML syntax for contructor:
+    *   <pre>
+    *      <constructor>
+    *         <arg type="xxx" value="yyy"/>
+    *         ...
+    *         <arg type="xxx" value="yyy"/>
+    *      </constructor>
+    *   </pre>
+    */
+   private static class ConstructorInfo
+   {
+      /** An empty parameters list. */
+      public static final Object EMPTY_PARAMS[] = {};
+
+      /** An signature list. */
+      public static final String EMPTY_SIGNATURE[] = {};
+
+      /** The constructor signature. */
+      public String[] signature = EMPTY_SIGNATURE;
+
+      /** The constructor parameters. */
+      public Object[] params = EMPTY_PARAMS;
+
+      /**
+       * Create a ConstructorInfo object for the given configuration.
+       *
+       * @param element   The element to build info for.
+       * @return          A constructor information object.
+       *
+       * @throws ConfigurationException   Failed to create info object.
+       */
+      public static ConstructorInfo create(Element element)
+         throws ConfigurationException
+      {
+         ConstructorInfo info = new ConstructorInfo();
+         NodeList list = element.getElementsByTagName("constructor");
+         if (list.getLength() > 1 && list.item(0).getParentNode() == element)
+         {
+            throw new ConfigurationException
+            ("only one <constructor> element may be defined");
+         }
+         else if (list.getLength() == 1)
+         {
+            element = (Element)list.item(0);
+
+            // get all of the "arg" elements
+            list = element.getElementsByTagName("arg");
+            int length = list.getLength();
+            info.params = new Object[length];
+            info.signature = new String[length];
+            ClassLoader loader = Thread.currentThread().getContextClassLoader();
+
+            // decode the values into params & signature
+            for (int j=0; j<length; j++)
+            {
+               Element arg = (Element)list.item(j);
+               String signature = arg.getAttribute("type");
+               String value = arg.getAttribute("value");
+               // Allow for system property reference replacement
+               value = StringPropertyReplacer.replaceProperties(arg.getAttribute("value")); 
+               Object realValue = value;
+
+               if( signature != null )
+               {
+                  // See if it is a primitive type first
+                  Class typeClass = Classes.getPrimitiveTypeForName(signature);
+                  if (typeClass == null)
+                  {
+                     // Try to load the class
+                     try
+                     {
+                        typeClass = loader.loadClass(signature);
+                     }
+                     catch (ClassNotFoundException e)
+                     {
+                        throw new ConfigurationException
+                           ("Class not found for type: " + signature, e);
+                     }
+                  }
+
+                  // Convert the string to the real value
+                  PropertyEditor editor = PropertyEditorManager.findEditor(typeClass);
+                  if (editor == null)
+                  {
+                     try
+                     {
+                        // See if there is a ctor(String) for the type
+                        Class[] sig = {String.class};
+                        Constructor ctor = typeClass.getConstructor(sig);
+                        Object[] args = {value};
+                        realValue = ctor.newInstance(args);
+                     }
+                     catch (Exception e)
+                     {
+                        throw new ConfigurationException("No property editor for type: " + typeClass);
+                     }
+                  }
+                  else
+                  {
+                     editor.setAsText(value);
+                     realValue = editor.getValue();
+                  }
+               }
+               info.signature[j] = signature;
+               info.params[j] = realValue;
+            }
+         }
+
+         return info;
+      }
+   }
+
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsListNestedNewUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsListNestedNewUnitTestCase.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsListNestedNewUnitTestCase.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,50 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.lifecycle.basic.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.AbstractTestDelegate;
+
+/**
+ * BasicDependencyDependsListNestedNewUnitTestCase.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class BasicDependencyDependsListNestedNewUnitTestCase extends BasicDependencyTest
+{
+   public static Test suite()
+   {
+      return suite(BasicDependencyDependsListNestedNewUnitTestCase.class);
+   }
+
+   public BasicDependencyDependsListNestedNewUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static AbstractTestDelegate getDelegate(Class clazz) throws Exception
+   {
+      return getNewControllerDelegate(clazz);
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsListNestedOldUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsListNestedOldUnitTestCase.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsListNestedOldUnitTestCase.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,50 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.lifecycle.basic.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.AbstractTestDelegate;
+
+/**
+ * BasicDependencyDependsListNestedOldUnitTestCase.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class BasicDependencyDependsListNestedOldUnitTestCase extends BasicDependencyTest
+{
+   public static Test suite()
+   {
+      return suite(BasicDependencyDependsListNestedOldUnitTestCase.class);
+   }
+
+   public BasicDependencyDependsListNestedOldUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static AbstractTestDelegate getDelegate(Class clazz) throws Exception
+   {
+      return getOldControllerDelegate(clazz);
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsListNewUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsListNewUnitTestCase.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsListNewUnitTestCase.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,50 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.lifecycle.basic.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.AbstractTestDelegate;
+
+/**
+ * BasicDependencyDependsListNewUnitTestCase.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class BasicDependencyDependsListNewUnitTestCase extends BasicDependencyTest
+{
+   public static Test suite()
+   {
+      return suite(BasicDependencyDependsListNewUnitTestCase.class);
+   }
+
+   public BasicDependencyDependsListNewUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static AbstractTestDelegate getDelegate(Class clazz) throws Exception
+   {
+      return getNewControllerDelegate(clazz);
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsListOldUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsListOldUnitTestCase.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsListOldUnitTestCase.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,50 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.lifecycle.basic.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.AbstractTestDelegate;
+
+/**
+ * BasicDependencyDependsListOldUnitTestCase.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class BasicDependencyDependsListOldUnitTestCase extends BasicDependencyTest
+{
+   public static Test suite()
+   {
+      return suite(BasicDependencyDependsListOldUnitTestCase.class);
+   }
+
+   public BasicDependencyDependsListOldUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static AbstractTestDelegate getDelegate(Class clazz) throws Exception
+   {
+      return getOldControllerDelegate(clazz);
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsNestedNewUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsNestedNewUnitTestCase.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsNestedNewUnitTestCase.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,50 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.lifecycle.basic.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.AbstractTestDelegate;
+
+/**
+ * BasicDependencyDependsNestedNewUnitTestCase.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class BasicDependencyDependsNestedNewUnitTestCase extends BasicDependencyTest
+{
+   public static Test suite()
+   {
+      return suite(BasicDependencyDependsNestedNewUnitTestCase.class);
+   }
+
+   public BasicDependencyDependsNestedNewUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static AbstractTestDelegate getDelegate(Class clazz) throws Exception
+   {
+      return getNewControllerDelegate(clazz);
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsNestedOldUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsNestedOldUnitTestCase.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsNestedOldUnitTestCase.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,50 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.lifecycle.basic.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.AbstractTestDelegate;
+
+/**
+ * BasicDependencyDependsNestedOldUnitTestCase.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class BasicDependencyDependsNestedOldUnitTestCase extends BasicDependencyTest
+{
+   public static Test suite()
+   {
+      return suite(BasicDependencyDependsNestedOldUnitTestCase.class);
+   }
+
+   public BasicDependencyDependsNestedOldUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static AbstractTestDelegate getDelegate(Class clazz) throws Exception
+   {
+      return getOldControllerDelegate(clazz);
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsNewUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsNewUnitTestCase.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsNewUnitTestCase.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,50 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.lifecycle.basic.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.AbstractTestDelegate;
+
+/**
+ * BasicDependencyDependsNewUnitTestCase.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class BasicDependencyDependsNewUnitTestCase extends BasicDependencyTest
+{
+   public static Test suite()
+   {
+      return suite(BasicDependencyDependsNewUnitTestCase.class);
+   }
+
+   public BasicDependencyDependsNewUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static AbstractTestDelegate getDelegate(Class clazz) throws Exception
+   {
+      return getNewControllerDelegate(clazz);
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsOldUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsOldUnitTestCase.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsOldUnitTestCase.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,50 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.lifecycle.basic.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.AbstractTestDelegate;
+
+/**
+ * BasicDependencyDependsOldUnitTestCase.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class BasicDependencyDependsOldUnitTestCase extends BasicDependencyTest
+{
+   public static Test suite()
+   {
+      return suite(BasicDependencyDependsOldUnitTestCase.class);
+   }
+
+   public BasicDependencyDependsOldUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static AbstractTestDelegate getDelegate(Class clazz) throws Exception
+   {
+      return getOldControllerDelegate(clazz);
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsOptionalAttributeListNestedNewUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsOptionalAttributeListNestedNewUnitTestCase.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsOptionalAttributeListNestedNewUnitTestCase.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,50 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.lifecycle.basic.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.AbstractTestDelegate;
+
+/**
+ * BasicDependencyDependsOptionalAttributeListNestedNewUnitTestCase.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class BasicDependencyDependsOptionalAttributeListNestedNewUnitTestCase extends BasicDependencyTest
+{
+   public static Test suite()
+   {
+      return suite(BasicDependencyDependsOptionalAttributeListNestedNewUnitTestCase.class);
+   }
+
+   public BasicDependencyDependsOptionalAttributeListNestedNewUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static AbstractTestDelegate getDelegate(Class clazz) throws Exception
+   {
+      return getNewControllerDelegate(clazz);
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsOptionalAttributeListNestedOldUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsOptionalAttributeListNestedOldUnitTestCase.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsOptionalAttributeListNestedOldUnitTestCase.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,50 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.lifecycle.basic.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.AbstractTestDelegate;
+
+/**
+ * BasicDependencyDependsOptionalAttributeListNestedOldUnitTestCase.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class BasicDependencyDependsOptionalAttributeListNestedOldUnitTestCase extends BasicDependencyTest
+{
+   public static Test suite()
+   {
+      return suite(BasicDependencyDependsOptionalAttributeListNestedOldUnitTestCase.class);
+   }
+
+   public BasicDependencyDependsOptionalAttributeListNestedOldUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static AbstractTestDelegate getDelegate(Class clazz) throws Exception
+   {
+      return getOldControllerDelegate(clazz);
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsOptionalAttributeListNewUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsOptionalAttributeListNewUnitTestCase.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsOptionalAttributeListNewUnitTestCase.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,50 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.lifecycle.basic.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.AbstractTestDelegate;
+
+/**
+ * BasicDependencyDependsOptionalAttributeListNewUnitTestCase.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class BasicDependencyDependsOptionalAttributeListNewUnitTestCase extends BasicDependencyTest
+{
+   public static Test suite()
+   {
+      return suite(BasicDependencyDependsOptionalAttributeListNewUnitTestCase.class);
+   }
+
+   public BasicDependencyDependsOptionalAttributeListNewUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static AbstractTestDelegate getDelegate(Class clazz) throws Exception
+   {
+      return getNewControllerDelegate(clazz);
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsOptionalAttributeListOldUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsOptionalAttributeListOldUnitTestCase.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsOptionalAttributeListOldUnitTestCase.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,50 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.lifecycle.basic.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.AbstractTestDelegate;
+
+/**
+ * BasicDependencyDependsOptionalAttributeListOldUnitTestCase.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class BasicDependencyDependsOptionalAttributeListOldUnitTestCase extends BasicDependencyTest
+{
+   public static Test suite()
+   {
+      return suite(BasicDependencyDependsOptionalAttributeListOldUnitTestCase.class);
+   }
+
+   public BasicDependencyDependsOptionalAttributeListOldUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static AbstractTestDelegate getDelegate(Class clazz) throws Exception
+   {
+      return getOldControllerDelegate(clazz);
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsOptionalAttributeNestedNewUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsOptionalAttributeNestedNewUnitTestCase.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsOptionalAttributeNestedNewUnitTestCase.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,50 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.lifecycle.basic.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.AbstractTestDelegate;
+
+/**
+ * BasicDependencyDependsOptionalAttributeNestedNewUnitTestCase.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class BasicDependencyDependsOptionalAttributeNestedNewUnitTestCase extends BasicDependencyTest
+{
+   public static Test suite()
+   {
+      return suite(BasicDependencyDependsOptionalAttributeNestedNewUnitTestCase.class);
+   }
+
+   public BasicDependencyDependsOptionalAttributeNestedNewUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static AbstractTestDelegate getDelegate(Class clazz) throws Exception
+   {
+      return getNewControllerDelegate(clazz);
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsOptionalAttributeNestedOldUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsOptionalAttributeNestedOldUnitTestCase.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsOptionalAttributeNestedOldUnitTestCase.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,50 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.lifecycle.basic.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.AbstractTestDelegate;
+
+/**
+ * BasicDependencyDependsOptionalAttributeNestedOldUnitTestCase.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class BasicDependencyDependsOptionalAttributeNestedOldUnitTestCase extends BasicDependencyTest
+{
+   public static Test suite()
+   {
+      return suite(BasicDependencyDependsOptionalAttributeNestedOldUnitTestCase.class);
+   }
+
+   public BasicDependencyDependsOptionalAttributeNestedOldUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static AbstractTestDelegate getDelegate(Class clazz) throws Exception
+   {
+      return getOldControllerDelegate(clazz);
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsOptionalAttributeNewUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsOptionalAttributeNewUnitTestCase.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsOptionalAttributeNewUnitTestCase.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,50 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.lifecycle.basic.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.AbstractTestDelegate;
+
+/**
+ * BasicDependencyDependsOptionalAttributeNewUnitTestCase.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class BasicDependencyDependsOptionalAttributeNewUnitTestCase extends BasicDependencyTest
+{
+   public static Test suite()
+   {
+      return suite(BasicDependencyDependsOptionalAttributeNewUnitTestCase.class);
+   }
+
+   public BasicDependencyDependsOptionalAttributeNewUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static AbstractTestDelegate getDelegate(Class clazz) throws Exception
+   {
+      return getNewControllerDelegate(clazz);
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsOptionalAttributeOldUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsOptionalAttributeOldUnitTestCase.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyDependsOptionalAttributeOldUnitTestCase.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,50 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.lifecycle.basic.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.AbstractTestDelegate;
+
+/**
+ * BasicDependencyDependsOptionalAttributeOldUnitTestCase.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class BasicDependencyDependsOptionalAttributeOldUnitTestCase extends BasicDependencyTest
+{
+   public static Test suite()
+   {
+      return suite(BasicDependencyDependsOptionalAttributeOldUnitTestCase.class);
+   }
+
+   public BasicDependencyDependsOptionalAttributeOldUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static AbstractTestDelegate getDelegate(Class clazz) throws Exception
+   {
+      return getOldControllerDelegate(clazz);
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyTest.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyTest.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicDependencyTest.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,390 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.lifecycle.basic.test;
+
+import java.util.List;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.jboss.mx.util.ObjectNameFactory;
+import org.jboss.system.ServiceControllerMBean;
+import org.jboss.test.system.controller.AbstractControllerTest;
+import org.jboss.test.system.controller.support.Simple;
+
+/**
+ * BasicLifecycleTest.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class BasicDependencyTest extends AbstractControllerTest
+{
+   private static ObjectName NAME_ONE = ObjectNameFactory.create("test:name=1"); 
+   private static ObjectName NAME_TWO = ObjectNameFactory.create("test:name=2"); 
+   
+   private String resourceName;
+   
+   public BasicDependencyTest(String name)
+   {
+      super(name);
+
+      resourceName = getClass().getName();
+      int index= resourceName.lastIndexOf('.'); 
+      if (index != -1)
+         resourceName= resourceName.substring(index + 1, resourceName.length());
+      index = resourceName.indexOf("NewUnitTestCase");
+      if (index != -1)
+         resourceName = resourceName.substring(0, index);
+      index = resourceName.indexOf("OldUnitTestCase");
+      if (index != -1)
+         resourceName = resourceName.substring(0, index);
+      
+      resourceName = resourceName + "_NotAutomatic.xml";
+   }
+   
+   public void testBasicDependency() throws Exception
+   {
+      Simple test1 = null;
+      Simple test2 = null;
+      
+      boolean error = false;
+      
+      List<ObjectName> mbeans = deploy(resourceName);
+      try
+      {
+         assertServiceRunning(NAME_ONE);
+         assertServiceRunning(NAME_TWO);
+         
+         MBeanServer server = getServer();
+         test1 = (Simple) server.getAttribute(NAME_ONE, "Instance");
+         assertEquals("()", test1.constructorUsed);
+         assertEquals(2, test1.createOrder);
+         assertEquals(4, test1.startOrder);
+         assertEquals(0, test1.stopOrder);
+         assertEquals(0, test1.destroyOrder);
+         test2 = (Simple) server.getAttribute(NAME_TWO, "Instance");
+         assertEquals("()", test2.constructorUsed);
+         assertEquals(1, test2.createOrder);
+         assertEquals(3, test2.startOrder);
+         assertEquals(0, test2.stopOrder);
+         assertEquals(0, test2.destroyOrder);
+      }
+      catch (Exception e)
+      {
+         error = true;
+         throw e;
+      }
+      catch (Error e)
+      {
+         error = true;
+         throw e;
+      }
+      finally
+      {
+         undeploy(mbeans);
+
+         if (error == false)
+         {
+            assertNoService(NAME_ONE);
+            assertNotRegistered(NAME_ONE);
+            assertEquals(2, test1.createOrder);
+            assertEquals(4, test1.startOrder);
+            assertEquals(5, test1.stopOrder);
+            assertEquals(7, test1.destroyOrder);
+            assertNoService(NAME_TWO);
+            assertNotRegistered(NAME_TWO);
+            assertEquals(1, test2.createOrder);
+            assertEquals(3, test2.startOrder);
+            assertEquals(6, test2.stopOrder);
+            assertEquals(8, test2.destroyOrder);
+         }
+      }
+   }
+   
+   public void testBasicRedeploy() throws Exception
+   {
+      Simple test1 = null;
+      Simple test2 = null;
+      
+      boolean error = false;
+      
+      List<ObjectName> mbeans = deploy(resourceName);
+      try
+      {
+         assertServiceRunning(NAME_ONE);
+         assertServiceRunning(NAME_TWO);
+         
+         MBeanServer server = getServer();
+         test1 = (Simple) server.getAttribute(NAME_ONE, "Instance");
+         assertEquals("()", test1.constructorUsed);
+         assertEquals(2, test1.createOrder);
+         assertEquals(4, test1.startOrder);
+         assertEquals(0, test1.stopOrder);
+         assertEquals(0, test1.destroyOrder);
+         test2 = (Simple) server.getAttribute(NAME_TWO, "Instance");
+         assertEquals("()", test2.constructorUsed);
+         assertEquals(1, test2.createOrder);
+         assertEquals(3, test2.startOrder);
+         assertEquals(0, test2.stopOrder);
+         assertEquals(0, test2.destroyOrder);
+      }
+      catch (Exception e)
+      {
+         error = true;
+         throw e;
+      }
+      catch (Error e)
+      {
+         error = true;
+         throw e;
+      }
+      finally
+      {
+         undeploy(mbeans);
+
+         if (error == false)
+         {
+            assertNoService(NAME_ONE);
+            assertNotRegistered(NAME_ONE);
+            assertEquals(2, test1.createOrder);
+            assertEquals(4, test1.startOrder);
+            assertEquals(5, test1.stopOrder);
+            assertEquals(7, test1.destroyOrder);
+            assertNoService(NAME_TWO);
+            assertNotRegistered(NAME_TWO);
+            assertEquals(1, test2.createOrder);
+            assertEquals(3, test2.startOrder);
+            assertEquals(6, test2.stopOrder);
+            assertEquals(8, test2.destroyOrder);
+         }
+      }
+      
+      mbeans = deploy(resourceName);
+      try
+      {
+         assertServiceRunning(NAME_ONE);
+         assertServiceRunning(NAME_TWO);
+         
+         MBeanServer server = getServer();
+         test1 = (Simple) server.getAttribute(NAME_ONE, "Instance");
+         assertEquals("()", test1.constructorUsed);
+         assertEquals(10, test1.createOrder);
+         assertEquals(12, test1.startOrder);
+         assertEquals(0, test1.stopOrder);
+         assertEquals(0, test1.destroyOrder);
+         test2 = (Simple) server.getAttribute(NAME_TWO, "Instance");
+         assertEquals("()", test2.constructorUsed);
+         assertEquals(9, test2.createOrder);
+         assertEquals(11, test2.startOrder);
+         assertEquals(0, test2.stopOrder);
+         assertEquals(0, test2.destroyOrder);
+      }
+      catch (Exception e)
+      {
+         error = true;
+         throw e;
+      }
+      catch (Error e)
+      {
+         error = true;
+         throw e;
+      }
+      finally
+      {
+         undeploy(mbeans);
+
+         if (error == false)
+         {
+            assertNoService(NAME_ONE);
+            assertNotRegistered(NAME_ONE);
+            assertEquals(10, test1.createOrder);
+            assertEquals(12, test1.startOrder);
+            assertEquals(13, test1.stopOrder);
+            assertEquals(15, test1.destroyOrder);
+            assertNoService(NAME_TWO);
+            assertNotRegistered(NAME_TWO);
+            assertEquals(9, test2.createOrder);
+            assertEquals(11, test2.startOrder);
+            assertEquals(14, test2.stopOrder);
+            assertEquals(16, test2.destroyOrder);
+         }
+      }
+   }
+   
+   public void testBasicDependencyManualLifecycle() throws Exception
+   {
+      Simple test1 = null;
+      Simple test2 = null;
+      
+      boolean error = false;
+      
+      List<ObjectName> mbeans = deploy(resourceName);
+      try
+      {
+         assertServiceRunning(NAME_ONE);
+         assertServiceRunning(NAME_TWO);
+         
+         MBeanServer server = getServer();
+         test1 = (Simple) server.getAttribute(NAME_ONE, "Instance");
+         assertEquals("()", test1.constructorUsed);
+         assertEquals(2, test1.createOrder);
+         assertEquals(4, test1.startOrder);
+         assertEquals(0, test1.stopOrder);
+         assertEquals(0, test1.destroyOrder);
+         test2 = (Simple) server.getAttribute(NAME_TWO, "Instance");
+         assertEquals("()", test2.constructorUsed);
+         assertEquals(1, test2.createOrder);
+         assertEquals(3, test2.startOrder);
+         assertEquals(0, test2.stopOrder);
+         assertEquals(0, test2.destroyOrder);
+         
+         ServiceControllerMBean controller = getController();
+         
+         controller.stop(NAME_ONE);
+         assertServiceStopped(NAME_ONE);
+         assertServiceRunning(NAME_TWO);
+         assertEquals(2, test1.createOrder);
+         assertEquals(4, test1.startOrder);
+         assertEquals(5, test1.stopOrder);
+         assertEquals(0, test1.destroyOrder);
+         assertEquals(1, test2.createOrder);
+         assertEquals(3, test2.startOrder);
+         assertEquals(0, test2.stopOrder);
+         assertEquals(0, test2.destroyOrder);
+         
+         controller.destroy(NAME_ONE);
+         assertServiceDestroyed(NAME_ONE);
+         assertServiceRunning(NAME_TWO);
+         assertEquals(2, test1.createOrder);
+         assertEquals(4, test1.startOrder);
+         assertEquals(5, test1.stopOrder);
+         assertEquals(6, test1.destroyOrder);
+         assertEquals(1, test2.createOrder);
+         assertEquals(3, test2.startOrder);
+         assertEquals(0, test2.stopOrder);
+         assertEquals(0, test2.destroyOrder);
+         
+         controller.create(NAME_ONE);
+         assertServiceCreated(NAME_ONE);
+         assertServiceRunning(NAME_TWO);
+         assertEquals(7, test1.createOrder);
+         assertEquals(4, test1.startOrder);
+         assertEquals(5, test1.stopOrder);
+         assertEquals(6, test1.destroyOrder);
+         assertEquals(1, test2.createOrder);
+         assertEquals(3, test2.startOrder);
+         assertEquals(0, test2.stopOrder);
+         assertEquals(0, test2.destroyOrder);
+         
+         controller.start(NAME_ONE);
+         assertServiceRunning(NAME_ONE);
+         assertServiceRunning(NAME_TWO);
+         assertEquals(7, test1.createOrder);
+         assertEquals(8, test1.startOrder);
+         assertEquals(5, test1.stopOrder);
+         assertEquals(6, test1.destroyOrder);
+         assertEquals(1, test2.createOrder);
+         assertEquals(3, test2.startOrder);
+         assertEquals(0, test2.stopOrder);
+         assertEquals(0, test2.destroyOrder);
+         
+         controller.stop(NAME_TWO);
+         assertServiceStopped(NAME_ONE);
+         assertServiceStopped(NAME_TWO);
+         assertEquals(7, test1.createOrder);
+         assertEquals(8, test1.startOrder);
+         assertEquals(9, test1.stopOrder);
+         assertEquals(6, test1.destroyOrder);
+         assertEquals(1, test2.createOrder);
+         assertEquals(3, test2.startOrder);
+         assertEquals(10, test2.stopOrder);
+         assertEquals(0, test2.destroyOrder);
+         
+         controller.destroy(NAME_TWO);
+         assertServiceDestroyed(NAME_ONE);
+         assertServiceDestroyed(NAME_TWO);
+         assertEquals(7, test1.createOrder);
+         assertEquals(8, test1.startOrder);
+         assertEquals(9, test1.stopOrder);
+         assertEquals(11, test1.destroyOrder);
+         assertEquals(1, test2.createOrder);
+         assertEquals(3, test2.startOrder);
+         assertEquals(10, test2.stopOrder);
+         assertEquals(12, test2.destroyOrder);
+         
+         controller.create(NAME_TWO);
+         assertServiceCreated(NAME_ONE);
+         assertServiceCreated(NAME_TWO);
+         assertEquals(14, test1.createOrder);
+         assertEquals(8, test1.startOrder);
+         assertEquals(9, test1.stopOrder);
+         assertEquals(11, test1.destroyOrder);
+         assertEquals(13, test2.createOrder);
+         assertEquals(3, test2.startOrder);
+         assertEquals(10, test2.stopOrder);
+         assertEquals(12, test2.destroyOrder);
+         
+         controller.start(NAME_TWO);
+         assertServiceRunning(NAME_ONE);
+         assertServiceRunning(NAME_TWO);
+         assertEquals(14, test1.createOrder);
+         assertEquals(16, test1.startOrder);
+         assertEquals(9, test1.stopOrder);
+         assertEquals(11, test1.destroyOrder);
+         assertEquals(13, test2.createOrder);
+         assertEquals(15, test2.startOrder);
+         assertEquals(10, test2.stopOrder);
+         assertEquals(12, test2.destroyOrder);
+      }
+      catch (Exception e)
+      {
+         error = true;
+         throw e;
+      }
+      catch (Error e)
+      {
+         error = true;
+         throw e;
+      }
+      finally
+      {
+         undeploy(mbeans);
+
+         if (error == false)
+         {
+            assertNoService(NAME_ONE);
+            assertNotRegistered(NAME_ONE);
+            assertEquals(14, test1.createOrder);
+            assertEquals(16, test1.startOrder);
+            assertEquals(17, test1.stopOrder);
+            assertEquals(19, test1.destroyOrder);
+            assertNoService(NAME_TWO);
+            assertNotRegistered(NAME_TWO);
+            assertEquals(13, test2.createOrder);
+            assertEquals(15, test2.startOrder);
+            assertEquals(18, test2.stopOrder);
+            assertEquals(20, test2.destroyOrder);
+         }
+      }
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicLifecycleNewUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicLifecycleNewUnitTestCase.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicLifecycleNewUnitTestCase.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,50 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.lifecycle.basic.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.AbstractTestDelegate;
+
+/**
+ * BasicLifecycleNewUnitTestCase.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class BasicLifecycleNewUnitTestCase extends BasicLifecycleTest
+{
+   public static Test suite()
+   {
+      return suite(BasicLifecycleNewUnitTestCase.class);
+   }
+
+   public BasicLifecycleNewUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static AbstractTestDelegate getDelegate(Class clazz) throws Exception
+   {
+      return getNewControllerDelegate(clazz);
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicLifecycleOldUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicLifecycleOldUnitTestCase.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicLifecycleOldUnitTestCase.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,50 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.lifecycle.basic.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.AbstractTestDelegate;
+
+/**
+ * BasicLifecycleOldUnitTestCase.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class BasicLifecycleOldUnitTestCase extends BasicLifecycleTest
+{
+   public static Test suite()
+   {
+      return suite(BasicLifecycleOldUnitTestCase.class);
+   }
+
+   public BasicLifecycleOldUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static AbstractTestDelegate getDelegate(Class clazz) throws Exception
+   {
+      return getOldControllerDelegate(clazz);
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicLifecycleTest.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicLifecycleTest.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/BasicLifecycleTest.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,236 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.lifecycle.basic.test;
+
+import java.util.List;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.jboss.system.ServiceControllerMBean;
+import org.jboss.test.system.controller.AbstractControllerTest;
+import org.jboss.test.system.controller.support.Simple;
+import org.jboss.test.system.controller.support.SimpleMBean;
+
+/**
+ * BasicLifecycleTest.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class BasicLifecycleTest extends AbstractControllerTest
+{
+   public BasicLifecycleTest(String name)
+   {
+      super(name);
+   }
+   
+   public void testBasicLifecyle() throws Exception
+   {
+      ObjectName name = SimpleMBean.OBJECT_NAME;
+      Simple test = null;
+      
+      boolean error = false;
+      
+      List<ObjectName> mbeans = deploy("BasicLifecycle_NotAutomatic.xml");
+      try
+      {
+         assertServiceRunning(name);
+         
+         MBeanServer server = getServer();
+         test = (Simple) server.getAttribute(name, "Instance");
+         assertEquals("()", test.constructorUsed);
+         assertEquals(1, test.createOrder);
+         assertEquals(2, test.startOrder);
+         assertEquals(0, test.stopOrder);
+         assertEquals(0, test.destroyOrder);
+      }
+      catch (Exception e)
+      {
+         error = true;
+         throw e;
+      }
+      finally
+      {
+         undeploy(mbeans);
+
+         if (error == false)
+         {
+            assertNoService(name);
+            assertNotRegistered(name);
+            
+            assertEquals(1, test.createOrder);
+            assertEquals(2, test.startOrder);
+            assertEquals(3, test.stopOrder);
+            assertEquals(4, test.destroyOrder);
+         }
+      }
+   }
+   
+   public void testBasicRedeploy() throws Exception
+   {
+      ObjectName name = SimpleMBean.OBJECT_NAME;
+      Simple test = null;
+      
+      boolean error = false;
+      
+      List<ObjectName> mbeans = deploy("BasicLifecycle_NotAutomatic.xml");
+      try
+      {
+         assertServiceRunning(name);
+         
+         MBeanServer server = getServer();
+         test = (Simple) server.getAttribute(name, "Instance");
+         assertEquals("()", test.constructorUsed);
+         assertEquals(1, test.createOrder);
+         assertEquals(2, test.startOrder);
+         assertEquals(0, test.stopOrder);
+         assertEquals(0, test.destroyOrder);
+      }
+      catch (Exception e)
+      {
+         error = true;
+         throw e;
+      }
+      finally
+      {
+         undeploy(mbeans);
+
+         if (error == false)
+         {
+            assertNoService(name);
+            assertNotRegistered(name);
+            
+            assertEquals(1, test.createOrder);
+            assertEquals(2, test.startOrder);
+            assertEquals(3, test.stopOrder);
+            assertEquals(4, test.destroyOrder);
+         }
+      }
+      
+      mbeans = deploy("BasicLifecycle_NotAutomatic.xml");
+      try
+      {
+         assertServiceRunning(name);
+         
+         MBeanServer server = getServer();
+         test = (Simple) server.getAttribute(name, "Instance");
+         assertEquals("()", test.constructorUsed);
+         assertEquals(5, test.createOrder);
+         assertEquals(6, test.startOrder);
+         assertEquals(0, test.stopOrder);
+         assertEquals(0, test.destroyOrder);
+      }
+      catch (Exception e)
+      {
+         error = true;
+         throw e;
+      }
+      finally
+      {
+         undeploy(mbeans);
+
+         if (error == false)
+         {
+            assertNoService(name);
+            assertNotRegistered(name);
+            
+            assertEquals(5, test.createOrder);
+            assertEquals(6, test.startOrder);
+            assertEquals(7, test.stopOrder);
+            assertEquals(8, test.destroyOrder);
+         }
+      }
+   }
+   
+   public void testBasicManualLifecycle() throws Exception
+   {
+      ObjectName name = SimpleMBean.OBJECT_NAME;
+      Simple test = null;
+      
+      boolean error = false;
+      
+      List<ObjectName> mbeans = deploy("BasicLifecycle_NotAutomatic.xml");
+      try
+      {
+         assertServiceRunning(name);
+
+         MBeanServer server = getServer();
+         test = (Simple) server.getAttribute(name, "Instance");
+         assertEquals("()", test.constructorUsed);
+         assertEquals(1, test.createOrder);
+         assertEquals(2, test.startOrder);
+         assertEquals(0, test.stopOrder);
+         assertEquals(0, test.destroyOrder);
+
+         ServiceControllerMBean controller = getController();
+
+         controller.stop(name);
+         assertServiceStopped(name);
+         assertEquals(1, test.createOrder);
+         assertEquals(2, test.startOrder);
+         assertEquals(3, test.stopOrder);
+         assertEquals(0, test.destroyOrder);
+
+         controller.destroy(name);
+         assertServiceDestroyed(name);
+         assertEquals(1, test.createOrder);
+         assertEquals(2, test.startOrder);
+         assertEquals(3, test.stopOrder);
+         assertEquals(4, test.destroyOrder);
+
+         controller.create(name);
+         assertServiceCreated(name);
+         assertEquals(5, test.createOrder);
+         assertEquals(2, test.startOrder);
+         assertEquals(3, test.stopOrder);
+         assertEquals(4, test.destroyOrder);
+
+         controller.start(name);
+         assertServiceRunning(name);
+         assertEquals(5, test.createOrder);
+         assertEquals(6, test.startOrder);
+         assertEquals(3, test.stopOrder);
+         assertEquals(4, test.destroyOrder);
+      }
+      catch (Exception e)
+      {
+         error = true;
+         throw e;
+      }
+      finally
+      {
+         undeploy(mbeans);
+
+         if (error == false)
+         {
+            assertNoService(name);
+            assertNotRegistered(name);
+            
+            assertEquals(5, test.createOrder);
+            assertEquals(6, test.startOrder);
+            assertEquals(7, test.stopOrder);
+            assertEquals(8, test.destroyOrder);
+         }
+      }
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/ControllerLifecycleBasicTestSuite.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/ControllerLifecycleBasicTestSuite.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/basic/test/ControllerLifecycleBasicTestSuite.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,66 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.lifecycle.basic.test;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * Controller Lifecycle Basic Test Suite.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.8 $
+ */
+public class ControllerLifecycleBasicTestSuite extends TestSuite
+{
+   public static void main(String[] args)
+   {
+      TestRunner.run(suite());
+   }
+
+   public static Test suite()
+   {
+      TestSuite suite = new TestSuite("Controller Lifecycle Basic Tests");
+
+      suite.addTest(BasicLifecycleOldUnitTestCase.suite());
+      suite.addTest(BasicLifecycleNewUnitTestCase.suite());
+      suite.addTest(BasicDependencyDependsOldUnitTestCase.suite());
+      suite.addTest(BasicDependencyDependsNewUnitTestCase.suite());
+      suite.addTest(BasicDependencyDependsNestedOldUnitTestCase.suite());
+      suite.addTest(BasicDependencyDependsNestedNewUnitTestCase.suite());
+      suite.addTest(BasicDependencyDependsListOldUnitTestCase.suite());
+      suite.addTest(BasicDependencyDependsListNewUnitTestCase.suite());
+      suite.addTest(BasicDependencyDependsListNestedOldUnitTestCase.suite());
+      suite.addTest(BasicDependencyDependsListNestedNewUnitTestCase.suite());
+      suite.addTest(BasicDependencyDependsOptionalAttributeOldUnitTestCase.suite());
+      suite.addTest(BasicDependencyDependsOptionalAttributeNewUnitTestCase.suite());
+      suite.addTest(BasicDependencyDependsOptionalAttributeNestedOldUnitTestCase.suite());
+      suite.addTest(BasicDependencyDependsOptionalAttributeNestedNewUnitTestCase.suite());
+      suite.addTest(BasicDependencyDependsOptionalAttributeListOldUnitTestCase.suite());
+      suite.addTest(BasicDependencyDependsOptionalAttributeListNewUnitTestCase.suite());
+      suite.addTest(BasicDependencyDependsOptionalAttributeListNestedOldUnitTestCase.suite());
+      suite.addTest(BasicDependencyDependsOptionalAttributeListNestedNewUnitTestCase.suite());
+      
+      return suite;
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/seperated/test/ControllerLifecycleSeperatedTestSuite.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/seperated/test/ControllerLifecycleSeperatedTestSuite.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/seperated/test/ControllerLifecycleSeperatedTestSuite.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,50 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.lifecycle.seperated.test;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * Controller Lifecycle Seperated Test Suite.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.8 $
+ */
+public class ControllerLifecycleSeperatedTestSuite extends TestSuite
+{
+   public static void main(String[] args)
+   {
+      TestRunner.run(suite());
+   }
+
+   public static Test suite()
+   {
+      TestSuite suite = new TestSuite("Controller Lifecycle Seperated Tests");
+
+      suite.addTest(SeperatedDependencyDependsOldUnitTestCase.suite());
+      suite.addTest(SeperatedDependencyDependsNewUnitTestCase.suite());
+      
+      return suite;
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/seperated/test/SeperatedDependencyDependsNewUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/seperated/test/SeperatedDependencyDependsNewUnitTestCase.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/seperated/test/SeperatedDependencyDependsNewUnitTestCase.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,50 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.lifecycle.seperated.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.AbstractTestDelegate;
+
+/**
+ * SeperatedDependencyDependsNewUnitTestCase.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class SeperatedDependencyDependsNewUnitTestCase extends SeperatedDependencyTest
+{
+   public static Test suite()
+   {
+      return suite(SeperatedDependencyDependsNewUnitTestCase.class);
+   }
+
+   public SeperatedDependencyDependsNewUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static AbstractTestDelegate getDelegate(Class clazz) throws Exception
+   {
+      return getNewControllerDelegate(clazz);
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/seperated/test/SeperatedDependencyDependsOldUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/seperated/test/SeperatedDependencyDependsOldUnitTestCase.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/seperated/test/SeperatedDependencyDependsOldUnitTestCase.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,50 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.lifecycle.seperated.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.AbstractTestDelegate;
+
+/**
+ * SeperatedDependencyDependsOldUnitTestCase.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class SeperatedDependencyDependsOldUnitTestCase extends SeperatedDependencyTest
+{
+   public static Test suite()
+   {
+      return suite(SeperatedDependencyDependsOldUnitTestCase.class);
+   }
+
+   public SeperatedDependencyDependsOldUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static AbstractTestDelegate getDelegate(Class clazz) throws Exception
+   {
+      return getOldControllerDelegate(clazz);
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/seperated/test/SeperatedDependencyTest.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/seperated/test/SeperatedDependencyTest.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/seperated/test/SeperatedDependencyTest.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,519 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.lifecycle.seperated.test;
+
+import java.util.List;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.jboss.mx.util.ObjectNameFactory;
+import org.jboss.test.system.controller.AbstractControllerTest;
+import org.jboss.test.system.controller.support.Simple;
+
+/**
+ * BasicLifecycleTest.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class SeperatedDependencyTest extends AbstractControllerTest
+{
+   private static ObjectName NAME_ONE = ObjectNameFactory.create("test:name=1"); 
+   private static ObjectName NAME_TWO = ObjectNameFactory.create("test:name=2"); 
+   
+   private String resourceName1;
+   private String resourceName2;
+   
+   public SeperatedDependencyTest(String name)
+   {
+      super(name);
+
+      String resourceName = getClass().getName();
+      int index= resourceName.lastIndexOf('.'); 
+      if (index != -1)
+         resourceName= resourceName.substring(index + 1, resourceName.length());
+      index = resourceName.indexOf("NewUnitTestCase");
+      if (index != -1)
+         resourceName = resourceName.substring(0, index);
+      index = resourceName.indexOf("OldUnitTestCase");
+      if (index != -1)
+         resourceName = resourceName.substring(0, index);
+      
+      resourceName1 = resourceName + "_1.xml";
+      resourceName2 = resourceName + "_2.xml";
+   }
+   
+   public void testDeployCorrectOrder() throws Exception
+   {
+      Simple test1 = null;
+      Simple test2 = null;
+      
+      boolean error = false;
+      
+      List<ObjectName> mbeans1 = deploy(resourceName1);
+      try
+      {
+         assertServiceRunning(NAME_ONE);
+         assertNoService(NAME_TWO);
+         
+         MBeanServer server = getServer();
+         test1 = (Simple) server.getAttribute(NAME_ONE, "Instance");
+         assertEquals("()", test1.constructorUsed);
+         assertEquals(1, test1.createOrder);
+         assertEquals(2, test1.startOrder);
+         assertEquals(0, test1.stopOrder);
+         assertEquals(0, test1.destroyOrder);
+
+         List<ObjectName> mbeans2 = deploy(resourceName2);
+         try
+         {
+            assertServiceRunning(NAME_ONE);
+            assertServiceRunning(NAME_TWO);
+            
+            assertEquals(1, test1.createOrder);
+            assertEquals(2, test1.startOrder);
+            assertEquals(0, test1.stopOrder);
+            assertEquals(0, test1.destroyOrder);
+            test2 = (Simple) server.getAttribute(NAME_TWO, "Instance");
+            assertEquals("()", test2.constructorUsed);
+            assertEquals(3, test2.createOrder);
+            assertEquals(4, test2.startOrder);
+            assertEquals(0, test2.stopOrder);
+            assertEquals(0, test2.destroyOrder);
+         }
+         catch (Exception e)
+         {
+            error = true;
+            throw e;
+         }
+         catch (Error e)
+         {
+            error = true;
+            throw e;
+         }
+         finally
+         {
+            undeploy(mbeans2);
+
+            if (error == false)
+            {
+               assertServiceRunning(NAME_ONE);
+               assertEquals(1, test1.createOrder);
+               assertEquals(2, test1.startOrder);
+               assertEquals(0, test1.stopOrder);
+               assertEquals(0, test1.destroyOrder);
+               assertNoService(NAME_TWO);
+               assertNotRegistered(NAME_TWO);
+               assertEquals(3, test2.createOrder);
+               assertEquals(4, test2.startOrder);
+               assertEquals(5, test2.stopOrder);
+               assertEquals(6, test2.destroyOrder);
+            }
+         }
+      }
+      catch (Exception e)
+      {
+         error = true;
+         throw e;
+      }
+      catch (Error e)
+      {
+         error = true;
+         throw e;
+      }
+      finally
+      {
+         undeploy(mbeans1);
+
+         if (error == false)
+         {
+            assertNoService(NAME_ONE);
+            assertNotRegistered(NAME_ONE);
+            assertEquals(1, test1.createOrder);
+            assertEquals(2, test1.startOrder);
+            assertEquals(7, test1.stopOrder);
+            assertEquals(8, test1.destroyOrder);
+            assertNoService(NAME_TWO);
+            assertNotRegistered(NAME_TWO);
+            if (test2 != null)
+            {
+               assertEquals(3, test2.createOrder);
+               assertEquals(4, test2.startOrder);
+               assertEquals(5, test2.stopOrder);
+               assertEquals(6, test2.destroyOrder);
+            }
+         }
+      }
+   }
+   
+   public void testDeployWrongOrder() throws Exception
+   {
+      Simple test1 = null;
+      Simple test2 = null;
+      
+      boolean error = false;
+      
+      List<ObjectName> mbeans2 = deploy(resourceName2);
+      try
+      {
+         assertServiceConfigured(NAME_TWO);
+         
+         MBeanServer server = getServer();
+         test2 = (Simple) server.getAttribute(NAME_TWO, "Instance");
+         assertEquals("()", test2.constructorUsed);
+         assertEquals(0, test2.createOrder);
+         assertEquals(0, test2.startOrder);
+         assertEquals(0, test2.stopOrder);
+         assertEquals(0, test2.destroyOrder);
+
+         List<ObjectName> mbeans1 = deploy(resourceName1);
+         try
+         {
+            assertServiceRunning(NAME_TWO);
+            assertServiceRunning(NAME_ONE);
+            
+            assertEquals(2, test2.createOrder);
+            assertEquals(4, test2.startOrder);
+            assertEquals(0, test2.stopOrder);
+            assertEquals(0, test2.destroyOrder);
+            test1 = (Simple) server.getAttribute(NAME_ONE, "Instance");
+            assertEquals("()", test1.constructorUsed);
+            assertEquals(1, test1.createOrder);
+            assertEquals(3, test1.startOrder);
+            assertEquals(0, test1.stopOrder);
+            assertEquals(0, test1.destroyOrder);
+         }
+         catch (Exception e)
+         {
+            error = true;
+            throw e;
+         }
+         catch (Error e)
+         {
+            error = true;
+            throw e;
+         }
+         finally
+         {
+            undeploy(mbeans1);
+
+            if (error == false)
+            {
+               assertServiceDestroyed(NAME_TWO);
+               assertEquals(2, test2.createOrder);
+               assertEquals(4, test2.startOrder);
+               assertEquals(5, test2.stopOrder);
+               assertEquals(7, test2.destroyOrder);
+               assertNotRegistered(NAME_ONE);
+               assertEquals(1, test1.createOrder);
+               assertEquals(3, test1.startOrder);
+               assertEquals(6, test1.stopOrder);
+               assertEquals(8, test1.destroyOrder);
+            }
+         }
+      }
+      catch (Exception e)
+      {
+         error = true;
+         throw e;
+      }
+      catch (Error e)
+      {
+         error = true;
+         throw e;
+      }
+      finally
+      {
+         undeploy(mbeans2);
+
+         if (error == false)
+         {
+            assertNoService(NAME_TWO);
+            assertNotRegistered(NAME_TWO);
+            assertEquals(2, test2.createOrder);
+            assertEquals(4, test2.startOrder);
+            assertEquals(5, test2.stopOrder);
+            assertEquals(7, test2.destroyOrder);
+            assertNoService(NAME_ONE);
+            assertNotRegistered(NAME_ONE);
+            if (test1 != null)
+            {
+               assertEquals(1, test1.createOrder);
+               assertEquals(3, test1.startOrder);
+               assertEquals(6, test1.stopOrder);
+               assertEquals(8, test1.destroyOrder);
+            }
+         }
+      }
+   }
+   
+   public void testRedeployOne() throws Exception
+   {
+      Simple test1 = null;
+      Simple test2 = null;
+      
+      boolean error = false;
+      
+      List<ObjectName> mbeans1 = deploy(resourceName1);
+      try
+      {
+         List<ObjectName> mbeans2 = deploy(resourceName2);
+         try
+         {
+            assertServiceRunning(NAME_ONE);
+            assertServiceRunning(NAME_TWO);
+            
+            MBeanServer server = getServer();
+            test1 = (Simple) server.getAttribute(NAME_ONE, "Instance");
+            assertEquals("()", test1.constructorUsed);
+            assertEquals(1, test1.createOrder);
+            assertEquals(2, test1.startOrder);
+            assertEquals(0, test1.stopOrder);
+            assertEquals(0, test1.destroyOrder);
+            test2 = (Simple) server.getAttribute(NAME_TWO, "Instance");
+            assertEquals("()", test2.constructorUsed);
+            assertEquals(3, test2.createOrder);
+            assertEquals(4, test2.startOrder);
+            assertEquals(0, test2.stopOrder);
+            assertEquals(0, test2.destroyOrder);
+            
+            undeploy(mbeans1);
+
+            assertNotRegistered(NAME_ONE);
+            assertServiceDestroyed(NAME_TWO);
+            
+            assertEquals(1, test1.createOrder);
+            assertEquals(2, test1.startOrder);
+            assertEquals(6, test1.stopOrder);
+            assertEquals(8, test1.destroyOrder);
+            assertEquals(3, test2.createOrder);
+            assertEquals(4, test2.startOrder);
+            assertEquals(5, test2.stopOrder);
+            assertEquals(7, test2.destroyOrder);
+            
+            mbeans1 = deploy(resourceName1);
+
+            assertServiceRunning(NAME_ONE);
+            assertServiceRunning(NAME_TWO);
+            
+            test1 = (Simple) server.getAttribute(NAME_ONE, "Instance");
+            assertEquals("()", test1.constructorUsed);
+            assertEquals(9, test1.createOrder);
+            assertEquals(11, test1.startOrder);
+            assertEquals(0, test1.stopOrder);
+            assertEquals(0, test1.destroyOrder);
+            assertEquals(10, test2.createOrder);
+            assertEquals(12, test2.startOrder);
+            assertEquals(5, test2.stopOrder);
+            assertEquals(7, test2.destroyOrder);
+         }
+         catch (Exception e)
+         {
+            error = true;
+            throw e;
+         }
+         catch (Error e)
+         {
+            error = true;
+            throw e;
+         }
+         finally
+         {
+            undeploy(mbeans2);
+
+            if (error == false)
+            {
+               assertServiceRunning(NAME_ONE);
+               assertEquals(9, test1.createOrder);
+               assertEquals(11, test1.startOrder);
+               assertEquals(0, test1.stopOrder);
+               assertEquals(0, test1.destroyOrder);
+               assertNoService(NAME_TWO);
+               assertNotRegistered(NAME_TWO);
+               assertEquals(10, test2.createOrder);
+               assertEquals(12, test2.startOrder);
+               assertEquals(13, test2.stopOrder);
+               assertEquals(14, test2.destroyOrder);
+            }
+         }
+      }
+      catch (Exception e)
+      {
+         error = true;
+         throw e;
+      }
+      catch (Error e)
+      {
+         error = true;
+         throw e;
+      }
+      finally
+      {
+         undeploy(mbeans1);
+
+         if (error == false)
+         {
+            assertNoService(NAME_ONE);
+            assertNotRegistered(NAME_ONE);
+            assertEquals(9, test1.createOrder);
+            assertEquals(11, test1.startOrder);
+            assertEquals(15, test1.stopOrder);
+            assertEquals(16, test1.destroyOrder);
+            assertNoService(NAME_TWO);
+            assertNotRegistered(NAME_TWO);
+            if (test2 != null)
+            {
+               assertEquals(10, test2.createOrder);
+               assertEquals(12, test2.startOrder);
+               assertEquals(13, test2.stopOrder);
+               assertEquals(14, test2.destroyOrder);
+            }
+         }
+      }
+   }
+   
+   public void testRedeployTwo() throws Exception
+   {
+      Simple test1 = null;
+      Simple test2 = null;
+      
+      boolean error = false;
+      
+      List<ObjectName> mbeans1 = deploy(resourceName1);
+      try
+      {
+         List<ObjectName> mbeans2 = deploy(resourceName2);
+         try
+         {
+            assertServiceRunning(NAME_ONE);
+            assertServiceRunning(NAME_TWO);
+            
+            MBeanServer server = getServer();
+            test1 = (Simple) server.getAttribute(NAME_ONE, "Instance");
+            assertEquals("()", test1.constructorUsed);
+            assertEquals(1, test1.createOrder);
+            assertEquals(2, test1.startOrder);
+            assertEquals(0, test1.stopOrder);
+            assertEquals(0, test1.destroyOrder);
+            test2 = (Simple) server.getAttribute(NAME_TWO, "Instance");
+            assertEquals("()", test2.constructorUsed);
+            assertEquals(3, test2.createOrder);
+            assertEquals(4, test2.startOrder);
+            assertEquals(0, test2.stopOrder);
+            assertEquals(0, test2.destroyOrder);
+            
+            undeploy(mbeans2);
+
+            assertServiceRunning(NAME_ONE);
+            assertNoService(NAME_TWO);
+            
+            assertEquals(1, test1.createOrder);
+            assertEquals(2, test1.startOrder);
+            assertEquals(0, test1.stopOrder);
+            assertEquals(0, test1.destroyOrder);
+            assertEquals(3, test2.createOrder);
+            assertEquals(4, test2.startOrder);
+            assertEquals(5, test2.stopOrder);
+            assertEquals(6, test2.destroyOrder);
+            
+            mbeans2 = deploy(resourceName2);
+
+            assertServiceRunning(NAME_ONE);
+            assertServiceRunning(NAME_TWO);
+            
+            assertEquals(1, test1.createOrder);
+            assertEquals(2, test1.startOrder);
+            assertEquals(0, test1.stopOrder);
+            assertEquals(0, test1.destroyOrder);
+            test2 = (Simple) server.getAttribute(NAME_TWO, "Instance");
+            assertEquals("()", test1.constructorUsed);
+            assertEquals(7, test2.createOrder);
+            assertEquals(8, test2.startOrder);
+            assertEquals(0, test2.stopOrder);
+            assertEquals(0, test2.destroyOrder);
+         }
+         catch (Exception e)
+         {
+            error = true;
+            throw e;
+         }
+         catch (Error e)
+         {
+            error = true;
+            throw e;
+         }
+         finally
+         {
+            undeploy(mbeans2);
+
+            if (error == false)
+            {
+               assertServiceRunning(NAME_ONE);
+               assertEquals(1, test1.createOrder);
+               assertEquals(2, test1.startOrder);
+               assertEquals(0, test1.stopOrder);
+               assertEquals(0, test1.destroyOrder);
+               assertNoService(NAME_TWO);
+               assertNotRegistered(NAME_TWO);
+               assertEquals(7, test2.createOrder);
+               assertEquals(8, test2.startOrder);
+               assertEquals(9, test2.stopOrder);
+               assertEquals(10, test2.destroyOrder);
+            }
+         }
+      }
+      catch (Exception e)
+      {
+         error = true;
+         throw e;
+      }
+      catch (Error e)
+      {
+         error = true;
+         throw e;
+      }
+      finally
+      {
+         undeploy(mbeans1);
+
+         if (error == false)
+         {
+            assertNoService(NAME_ONE);
+            assertNotRegistered(NAME_ONE);
+            assertEquals(1, test1.createOrder);
+            assertEquals(2, test1.startOrder);
+            assertEquals(11, test1.stopOrder);
+            assertEquals(12, test1.destroyOrder);
+            assertNoService(NAME_TWO);
+            assertNotRegistered(NAME_TWO);
+            if (test2 != null)
+            {
+               assertEquals(7, test2.createOrder);
+               assertEquals(8, test2.startOrder);
+               assertEquals(9, test2.stopOrder);
+               assertEquals(10, test2.destroyOrder);
+            }
+         }
+      }
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/test/ControllerLifecycleTestSuite.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/test/ControllerLifecycleTestSuite.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/lifecycle/test/ControllerLifecycleTestSuite.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,53 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.lifecycle.test;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+import org.jboss.test.system.controller.lifecycle.basic.test.ControllerLifecycleBasicTestSuite;
+import org.jboss.test.system.controller.lifecycle.seperated.test.ControllerLifecycleSeperatedTestSuite;
+
+/**
+ * Controller Lifecycle Test Suite.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.8 $
+ */
+public class ControllerLifecycleTestSuite extends TestSuite
+{
+   public static void main(String[] args)
+   {
+      TestRunner.run(suite());
+   }
+
+   public static Test suite()
+   {
+      TestSuite suite = new TestSuite("Controller Lifecycle Tests");
+
+      suite.addTest(ControllerLifecycleBasicTestSuite.suite());
+      suite.addTest(ControllerLifecycleSeperatedTestSuite.suite());
+      
+      return suite;
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/parse/test/ControllerParseTestSuite.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/parse/test/ControllerParseTestSuite.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/parse/test/ControllerParseTestSuite.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,50 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.parse.test;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * Controller Parse Test Suite.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.8 $
+ */
+public class ControllerParseTestSuite extends TestSuite
+{
+   public static void main(String[] args)
+   {
+      TestRunner.run(suite());
+   }
+
+   public static Test suite()
+   {
+      TestSuite suite = new TestSuite("Controller Parsing Tests");
+
+      suite.addTest(ErrorInParseOldUnitTestCase.suite());
+      suite.addTest(ErrorInParseNewUnitTestCase.suite());
+      
+      return suite;
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/parse/test/ErrorInParseNewUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/parse/test/ErrorInParseNewUnitTestCase.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/parse/test/ErrorInParseNewUnitTestCase.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,50 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.parse.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.AbstractTestDelegate;
+
+/**
+ * ErrorInParseNewUnitTestCase.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ErrorInParseNewUnitTestCase extends ErrorInParseTest
+{
+   public static Test suite()
+   {
+      return suite(ErrorInParseNewUnitTestCase.class);
+   }
+
+   public ErrorInParseNewUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static AbstractTestDelegate getDelegate(Class clazz) throws Exception
+   {
+      return getNewControllerDelegate(clazz);
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/parse/test/ErrorInParseOldUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/parse/test/ErrorInParseOldUnitTestCase.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/parse/test/ErrorInParseOldUnitTestCase.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,68 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.parse.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.AbstractTestDelegate;
+
+/**
+ * ErrorInParseOldUnitTestCase.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ErrorInParseOldUnitTestCase extends ErrorInParseTest
+{
+   public static Test suite()
+   {
+      return suite(ErrorInParseOldUnitTestCase.class);
+   }
+
+   public ErrorInParseOldUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static AbstractTestDelegate getDelegate(Class clazz) throws Exception
+   {
+      return getOldControllerDelegate(clazz);
+   }
+   
+   // Attempts to load an empty class name
+   public void testConstructorTypeMissing() throws Exception
+   {
+      errorInParse(ClassNotFoundException.class);
+   }
+   
+   // Attempts to load an empty class name
+   public void testConstructorTypeEmpty() throws Exception
+   {
+      errorInParse(ClassNotFoundException.class);
+   }
+   
+   // Allows missing values?
+   public void testConstructorValueMissing() throws Exception
+   {
+      errorInParse(NumberFormatException.class);
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/parse/test/ErrorInParseTest.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/parse/test/ErrorInParseTest.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/parse/test/ErrorInParseTest.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,91 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.parse.test;
+
+import javax.management.MalformedObjectNameException;
+
+import org.jboss.deployment.DeploymentException;
+import org.jboss.system.ConfigurationException;
+import org.jboss.test.system.controller.AbstractControllerTest;
+import org.jboss.test.system.controller.support.SimpleMBean;
+
+/**
+ * ErrorInParseTest.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class ErrorInParseTest extends AbstractControllerTest
+{
+   public ErrorInParseTest(String name)
+   {
+      super(name);
+   }
+
+   protected void errorInParse(Class<? extends Throwable> expected) throws Exception
+   {
+      String resource = getName();
+      resource = resource.substring(4) + ".xml";
+      assertDeployFailure(resource, expected);
+      assertNoService(SimpleMBean.OBJECT_NAME);
+   }
+   
+   public void testNameMissing() throws Exception
+   {
+      errorInParse(DeploymentException.class);
+   }
+   
+   public void testNameEmpty() throws Exception
+   {
+      errorInParse(DeploymentException.class);
+   }
+   
+   public void testNameInvalid() throws Exception
+   {
+      errorInParse(MalformedObjectNameException.class);
+   }
+   
+   public void testCodeMissing() throws Exception
+   {
+      errorInParse(ConfigurationException.class);
+   }
+   
+   public void testCodeEmpty() throws Exception
+   {
+      errorInParse(ConfigurationException.class);
+   }
+   
+   public void testConstructorTypeMissing() throws Exception
+   {
+      errorInParse(ConfigurationException.class);
+   }
+   
+   public void testConstructorTypeEmpty() throws Exception
+   {
+      errorInParse(ConfigurationException.class);
+   }
+   
+   public void testConstructorValueMissing() throws Exception
+   {
+      errorInParse(ConfigurationException.class);
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/support/AbstractSimple.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/support/AbstractSimple.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/support/AbstractSimple.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,32 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.support;
+
+/**
+ * AbstractSimple.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractSimple extends Simple
+{
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/support/NotSimpleStandardMBeanInterface.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/support/NotSimpleStandardMBeanInterface.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/support/NotSimpleStandardMBeanInterface.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,32 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.support;
+
+/**
+ * NotSimpleStandardMBeanInterface.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public interface NotSimpleStandardMBeanInterface
+{
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/support/Order.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/support/Order.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/support/Order.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,43 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.support;
+
+/**
+ * Order.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class Order
+{
+   private static int order = 0;
+   
+   public static synchronized int getOrder()
+   {
+      return ++order;
+   }
+   
+   public static synchronized void reset()
+   {
+      order = 0;
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/support/Simple.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/support/Simple.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/support/Simple.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,404 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.support;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.Collection;
+import java.util.Date;
+
+import javax.management.ObjectName;
+
+import org.jboss.system.ServiceMBeanSupport;
+
+/**
+ * Simple.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class Simple extends ServiceMBeanSupport implements SimpleMBean, SimpleStandardMBeanInterface
+{
+   public String constructorUsed;
+   
+   public int createOrder;
+   public int startOrder;
+   public int stopOrder;
+   public int destroyOrder;
+   
+   /** A string */
+   private String aString;
+
+   /** Byte */
+   private Byte aByte;
+
+   /** Boolean */
+   private Boolean aBoolean;
+
+   /** Character */
+   private Character aCharacter;
+
+   /** Short */
+   private Short aShort;
+
+   /** Int */
+   private Integer anInt;
+
+   /** Long */
+   private Long aLong;
+
+   /** Float */
+   private Float aFloat;
+
+   /** Double */
+   private Double aDouble;
+
+   /** Date */
+   private Date aDate;
+
+   /** BigDecimal */
+   private BigDecimal aBigDecimal;
+
+   /** BigDecimal */
+   private BigInteger aBigInteger;
+
+   /** byte */
+   private byte abyte;
+
+   /** boolean */
+   private boolean aboolean;
+
+   /** char */
+   private char achar;
+
+   /** short */
+   private short ashort;
+
+   /** int */
+   private int anint;
+
+   /** long */
+   private long along;
+
+   /** float */
+   private float afloat;
+
+   /** double */
+   private double adouble;
+
+   /** number */
+   private Number aNumber;
+   
+   /** objectName */
+   private ObjectName objectName;
+   
+   /** objectNames */
+   private Collection<ObjectName> objectNames;
+   
+   public Simple()
+   {
+      constructorUsed = "()";
+   }
+   
+   public Simple(String string)
+   {
+      constructorUsed = "(java.lang.String)";
+      if ("error".equals(string))
+         throw new Error();
+      if ("exception".equals(string))
+         throw new RuntimeException();
+   }
+   
+   public Simple(int integer)
+   {
+      constructorUsed = "(int)";
+      anint = integer;
+   }
+   
+   public Simple(int integer, float number)
+   {
+      constructorUsed = "(int,float)";
+      anint = integer;
+      afloat = number;
+   }
+   
+   public Simple getInstance()
+   {
+      return this;
+   }
+   
+   protected void createService()
+   {
+      createOrder = Order.getOrder();
+   }
+   
+   protected void startService()
+   {
+      startOrder = Order.getOrder();
+   }
+   
+   protected void stopService()
+   {
+      stopOrder = Order.getOrder();
+   }
+   
+   protected void destroyService()
+   {
+      destroyOrder = Order.getOrder();
+   }
+
+   public BigDecimal getABigDecimal()
+   {
+      return aBigDecimal;
+   }
+
+   public void setABigDecimal(BigDecimal bigDecimal)
+   {
+      aBigDecimal = bigDecimal;
+   }
+
+   public BigInteger getABigInteger()
+   {
+      return aBigInteger;
+   }
+
+   public void setABigInteger(BigInteger bigInteger)
+   {
+      aBigInteger = bigInteger;
+   }
+
+   public boolean isAboolean()
+   {
+      return aboolean;
+   }
+
+   public void setAboolean(boolean aboolean)
+   {
+      this.aboolean = aboolean;
+   }
+
+   public Boolean getABoolean()
+   {
+      return aBoolean;
+   }
+
+   public void setABoolean(Boolean boolean1)
+   {
+      aBoolean = boolean1;
+   }
+
+   public Number getANumber()
+   {
+      return aNumber;
+   }
+
+   public void setANumber(Number number)
+   {
+      aNumber = number;
+   }
+
+   public byte getAbyte()
+   {
+      return abyte;
+   }
+
+   public void setAbyte(byte abyte)
+   {
+      this.abyte = abyte;
+   }
+
+   public Byte getAByte()
+   {
+      return aByte;
+   }
+
+   public void setAByte(Byte byte1)
+   {
+      aByte = byte1;
+   }
+
+   public char getAchar()
+   {
+      return achar;
+   }
+
+   public void setAchar(char achar)
+   {
+      this.achar = achar;
+   }
+
+   public Character getACharacter()
+   {
+      return aCharacter;
+   }
+
+   public void setACharacter(Character character)
+   {
+      aCharacter = character;
+   }
+
+   public Date getADate()
+   {
+      return aDate;
+   }
+
+   public void setADate(Date date)
+   {
+      aDate = date;
+   }
+
+   public double getAdouble()
+   {
+      return adouble;
+   }
+
+   public void setAdouble(double adouble)
+   {
+      this.adouble = adouble;
+   }
+
+   public Double getADouble()
+   {
+      return aDouble;
+   }
+
+   public void setADouble(Double double1)
+   {
+      aDouble = double1;
+   }
+
+   public float getAfloat()
+   {
+      return afloat;
+   }
+
+   public void setAfloat(float afloat)
+   {
+      this.afloat = afloat;
+   }
+
+   public Float getAFloat()
+   {
+      return aFloat;
+   }
+
+   public void setAFloat(Float float1)
+   {
+      aFloat = float1;
+   }
+
+   public long getAlong()
+   {
+      return along;
+   }
+
+   public void setAlong(long along)
+   {
+      this.along = along;
+   }
+
+   public Long getALong()
+   {
+      return aLong;
+   }
+
+   public void setALong(Long long1)
+   {
+      aLong = long1;
+   }
+
+   public int getAnint()
+   {
+      return anint;
+   }
+
+   public void setAnint(int anint)
+   {
+      this.anint = anint;
+   }
+
+   public Integer getAnInt()
+   {
+      return anInt;
+   }
+
+   public void setAnInt(Integer anInt)
+   {
+      this.anInt = anInt;
+   }
+
+   public short getAshort()
+   {
+      return ashort;
+   }
+
+   public void setAshort(short ashort)
+   {
+      this.ashort = ashort;
+   }
+
+   public Short getAShort()
+   {
+      return aShort;
+   }
+
+   public void setAShort(Short short1)
+   {
+      aShort = short1;
+   }
+
+   public String getAString()
+   {
+      return aString;
+   }
+
+   public void setAString(String string)
+   {
+      aString = string;
+   }
+
+   public ObjectName getObjectName()
+   {
+      return objectName;
+   }
+
+   public void setObjectName(ObjectName objectName)
+   {
+      this.objectName = objectName;
+   }
+
+   public Collection<ObjectName> getObjectNames()
+   {
+      return objectNames;
+   }
+
+   public void setObjectNames(Collection<ObjectName> objectNames)
+   {
+      this.objectNames = objectNames;
+   }
+
+   public String echoReverse(String test)
+   {
+      StringBuilder builder = new StringBuilder(test);
+      return builder.reverse().toString();
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/support/SimpleMBean.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/support/SimpleMBean.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/support/SimpleMBean.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,137 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General 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 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.system.controller.support;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.Collection;
+import java.util.Date;
+
+import javax.management.ObjectName;
+
+import org.jboss.mx.util.ObjectNameFactory;
+import org.jboss.system.ServiceMBean;
+
+/**
+ * SimpleMBean.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public interface SimpleMBean extends ServiceMBean
+{
+   ObjectName OBJECT_NAME = ObjectNameFactory.create("jboss.test:type=test");
+   
+   Simple getInstance();
+
+   BigDecimal getABigDecimal();
+
+   void setABigDecimal(BigDecimal bigDecimal);
+
+   BigInteger getABigInteger();
+
+   void setABigInteger(BigInteger bigInteger);
+
+   boolean isAboolean();
+
+   void setAboolean(boolean aboolean);
+
+   Boolean getABoolean();
+
+   void setABoolean(Boolean boolean1);
+
+   Number getANumber();
+
+   void setANumber(Number number);
+
+   byte getAbyte();
+
+   void setAbyte(byte abyte);
+
+   Byte getAByte();
+
+   void setAByte(Byte byte1);
+
+   char getAchar();
+
+   void setAchar(char achar);
+
+   Character getACharacter();
+
+   void setACharacter(Character character);
+
+   Date getADate();
+
+   void setADate(Date date);
+
+   double getAdouble();
+
+   void setAdouble(double adouble);
+
+   Double getADouble();
+
+   void setADouble(Double double1);
+
+   float getAfloat();
+
+   void setAfloat(float afloat);
+
+   Float getAFloat();
+
+   void setAFloat(Float float1);
+
+   long getAlong();
+
+   void setAlong(long along);
+
+   Long getALong();
+
+   void setALong(Long long1);
+
+   int getAnint();
+
+   void setAnint(int anint);
+
+   Integer getAnInt();
+
+   void setAnInt(Integer anInt);
+
+   short getAshort();
+
+   void setAshort(short ashort);
+
+   Short getAShort();
+
+   void setAShort(Short short1);
+
+   String getAString();
+
+   void setAString(String string);
+
+   ObjectName getObjectName();
+
+   void setObjectName(ObjectName objectName);
+
+   Collection<ObjectName> getObjectNames();
+
+   void setObjectNames(Collection<ObjectName> objectNames);
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/support/SimpleStandardMBeanInterface.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/support/SimpleStandardMBeanInterface.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/support/SimpleStandardMBeanInterface.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,33 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.support;
+
+/**
+ * TestStandardMBeanInterface.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public interface SimpleStandardMBeanInterface
+{
+   String echoReverse(String test);
+}

Added: trunk/system/src/tests/org/jboss/test/system/controller/test/ControllerTestSuite.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/controller/test/ControllerTestSuite.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/controller/test/ControllerTestSuite.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,59 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.test;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+import org.jboss.test.system.controller.basic.test.ControllerBasicTestSuite;
+import org.jboss.test.system.controller.configure.test.ControllerConfigureTestSuite;
+import org.jboss.test.system.controller.instantiate.test.ControllerInstantiateTestSuite;
+import org.jboss.test.system.controller.lifecycle.test.ControllerLifecycleTestSuite;
+import org.jboss.test.system.controller.parse.test.ControllerParseTestSuite;
+
+/**
+ * Controller Test Suite.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.8 $
+ */
+public class ControllerTestSuite extends TestSuite
+{
+   public static void main(String[] args)
+   {
+      TestRunner.run(suite());
+   }
+
+   public static Test suite()
+   {
+      TestSuite suite = new TestSuite("Controller Tests");
+
+      suite.addTest(ControllerBasicTestSuite.suite());
+      suite.addTest(ControllerParseTestSuite.suite());
+      suite.addTest(ControllerInstantiateTestSuite.suite());
+      suite.addTest(ControllerConfigureTestSuite.suite());
+      suite.addTest(ControllerLifecycleTestSuite.suite());
+      
+      return suite;
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/metadata/basic/test/BasicMBeanUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/metadata/basic/test/BasicMBeanUnitTestCase.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/metadata/basic/test/BasicMBeanUnitTestCase.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,94 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.metadata.basic.test;
+
+import javax.management.MalformedObjectNameException;
+
+import org.jboss.deployment.DeploymentException;
+import org.jboss.system.ConfigurationException;
+import org.jboss.system.metadata.ServiceMetaData;
+import org.jboss.test.system.metadata.test.AbstractMetaDataTest;
+
+/**
+ * BasicMBeanUnitTestCase.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class BasicMBeanUnitTestCase extends AbstractMetaDataTest
+{
+   public BasicMBeanUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testBasicMBean() throws Exception
+   {
+      ServiceMetaData metaData = unmarshalSingleMBean();
+      assertEquals(testBasicMBeanName, metaData.getObjectName());
+      assertEquals(testBasicMBeanCode, metaData.getCode());
+      assertNull(metaData.getInterfaceName());
+      assertOthers(metaData);
+   }
+
+   public void testBasicMBeanNoName() throws Exception
+   {
+      assertFailUnmarshal(DeploymentException.class);
+   }
+
+   public void testBasicMBeanEmptyName() throws Exception
+   {
+      assertFailUnmarshal(DeploymentException.class);
+   }
+
+   public void testBasicMBeanInvalidName() throws Exception
+   {
+      assertFailUnmarshal(MalformedObjectNameException.class);
+   }
+
+   public void testBasicMBeanNoCode() throws Exception
+   {
+      assertFailUnmarshal(ConfigurationException.class);
+   }
+
+   public void testBasicMBeanEmptyCode() throws Exception
+   {
+      assertFailUnmarshal(ConfigurationException.class);
+   }
+
+   public void testBasicMBeanInterface() throws Exception
+   {
+      ServiceMetaData metaData = unmarshalSingleMBean();
+      assertEquals(testBasicMBeanName, metaData.getObjectName());
+      assertEquals(testBasicMBeanCode, metaData.getCode());
+      assertEquals(testBasicMBeanInterface, metaData.getInterfaceName());
+      assertOthers(metaData);
+   }
+   
+   protected void assertOthers(ServiceMetaData metaData) throws Exception
+   {
+      assertDefaultConstructor(metaData);
+      assertNoAttributes(metaData);
+      assertNoDependencies(metaData);
+      assertNoXMBean(metaData);
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/metadata/constructor/test/ConstructorUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/metadata/constructor/test/ConstructorUnitTestCase.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/metadata/constructor/test/ConstructorUnitTestCase.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,105 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.metadata.constructor.test;
+
+import org.jboss.system.ConfigurationException;
+import org.jboss.system.metadata.ServiceMetaData;
+import org.jboss.test.system.metadata.test.AbstractMetaDataTest;
+
+/**
+ * ConstructorUnitTestCase.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ConstructorUnitTestCase extends AbstractMetaDataTest
+{
+   public ConstructorUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testConstructorDefault() throws Exception
+   {
+      ServiceMetaData metaData = unmarshalSingleMBean();
+      assertDefaultConstructor(metaData);
+      assertOthers(metaData);
+   }
+
+   public void testConstructorOneArg() throws Exception
+   {
+      ServiceMetaData metaData = unmarshalSingleMBean();
+      
+      String[] expectedSignature = new String[] { "signature1" };
+      String[] expectedParams = new String[] { "param1" };
+      
+      assertConstructor(expectedSignature, expectedParams, metaData);
+      assertOthers(metaData);
+   }
+
+   public void testConstructorTwoArgs() throws Exception
+   {
+      ServiceMetaData metaData = unmarshalSingleMBean();
+      
+      String[] expectedSignature = new String[] { "signature1", "signature2" };
+      String[] expectedParams = new String[] { "param1", "param2" };
+      
+      assertConstructor(expectedSignature, expectedParams, metaData);
+      assertOthers(metaData);
+   }
+
+   public void testConstructorNoType() throws Exception
+   {
+      assertFailUnmarshal(ConfigurationException.class);
+   }
+
+   public void testConstructorEmptyType() throws Exception
+   {
+      assertFailUnmarshal(ConfigurationException.class);
+   }
+
+   public void testConstructorNoValue() throws Exception
+   {
+      assertFailUnmarshal(ConfigurationException.class);
+   }
+
+   public void testConstructorEmptyValue() throws Exception
+   {
+      ServiceMetaData metaData = unmarshalSingleMBean();
+      
+      String[] expectedSignature = new String[] { "signature1" };
+      String[] expectedParams = new String[] { "" };
+      
+      assertConstructor(expectedSignature, expectedParams, metaData);
+      assertOthers(metaData);
+   }
+
+   protected void assertOthers(ServiceMetaData metaData) throws Exception
+   {
+      assertEquals(testBasicMBeanName, metaData.getObjectName());
+      assertEquals(testBasicMBeanCode, metaData.getCode());
+      assertNull(metaData.getInterfaceName());
+      assertNoAttributes(metaData);
+      assertNoDependencies(metaData);
+      assertNoXMBean(metaData);
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/metadata/depends/test/DependsOptionalAttributeUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/metadata/depends/test/DependsOptionalAttributeUnitTestCase.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/metadata/depends/test/DependsOptionalAttributeUnitTestCase.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,119 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.metadata.depends.test;
+
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+
+import org.jboss.deployment.DeploymentException;
+import org.jboss.system.metadata.ServiceMetaData;
+import org.jboss.test.system.metadata.test.AbstractMetaDataTest;
+
+/**
+ * DependsOptionalAttributeUnitTestCase.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class DependsOptionalAttributeUnitTestCase extends AbstractMetaDataTest
+{
+   public DependsOptionalAttributeUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testDependsOptionalAttribute() throws Exception
+   {
+      dependsOne();
+   }
+
+   public void testDependsOptionalAttributeEmpty() throws Exception
+   {
+      assertFailUnmarshal(DeploymentException.class);
+   }
+
+   public void testDependsOptionalAttributeNoNestedMBean() throws Exception
+   {
+      assertFailUnmarshal(DeploymentException.class);
+   }
+
+   public void testDependsInvalidObjectName() throws Exception
+   {
+      assertFailUnmarshal(MalformedObjectNameException.class);
+   }
+
+   public void testDependsOptionalAttributeNestedMBean() throws Exception
+   {
+      dependsOne();
+   }
+
+   public void testDependsListOptionalAttribute() throws Exception
+   {
+      dependsOne();
+   }
+
+   public void testDependsListOptionalAttributeNestedMBean() throws Exception
+   {
+      dependsOne();
+   }
+
+   public void testDependsListOptionalAttributeElementEmpty() throws Exception
+   {
+      assertFailUnmarshal(DeploymentException.class);
+   }
+
+   public void testDependsListOptionalAttributeElementNoNestedMBean() throws Exception
+   {
+      assertFailUnmarshal(DeploymentException.class);
+   }
+
+   public void testDependsListOptionalAttributeInvalidObjectName() throws Exception
+   {
+      assertFailUnmarshal(MalformedObjectNameException.class);
+   }
+
+   protected void dependsOne() throws Exception
+   {
+      ServiceMetaData metaData = unmarshalSingleMBean();
+      ObjectName[] expected = { new ObjectName("test:test=1") };
+      assertDependencies(metaData, expected);
+      assertOthers(metaData);
+   }
+
+   protected void dependsTwo() throws Exception
+   {
+      ServiceMetaData metaData = unmarshalSingleMBean();
+      ObjectName[] expected = { new ObjectName("test:test=1"), new ObjectName("test:test=2") };
+      assertDependencies(metaData, expected);
+      assertOthers(metaData);
+   }
+
+   protected void assertOthers(ServiceMetaData metaData) throws Exception
+   {
+      assertEquals(testBasicMBeanName, metaData.getObjectName());
+      assertEquals(testBasicMBeanCode, metaData.getCode());
+      assertNull(metaData.getInterfaceName());
+      assertDefaultConstructor(metaData);
+      // TODO assertAttributes(metaData);
+      assertNoXMBean(metaData);
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/metadata/depends/test/DependsUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/metadata/depends/test/DependsUnitTestCase.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/metadata/depends/test/DependsUnitTestCase.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,147 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.metadata.depends.test;
+
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+
+import org.jboss.deployment.DeploymentException;
+import org.jboss.system.metadata.ServiceMetaData;
+import org.jboss.test.system.metadata.test.AbstractMetaDataTest;
+
+/**
+ * DependsUnitTestCase.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class DependsUnitTestCase extends AbstractMetaDataTest
+{
+   public DependsUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testDependsNone() throws Exception
+   {
+      dependsNone();
+   }
+
+   public void testDependsOne() throws Exception
+   {
+      dependsOne();
+   }
+
+   public void testDependsTwo() throws Exception
+   {
+      dependsTwo();
+   }
+
+   public void testDependsNestedMBean() throws Exception
+   {
+      dependsOne();
+   }
+
+   public void testDependsEmpty() throws Exception
+   {
+      assertFailUnmarshal(DeploymentException.class);
+   }
+
+   public void testDependsNoNestedMBean() throws Exception
+   {
+      assertFailUnmarshal(DeploymentException.class);
+   }
+
+   public void testDependsInvalidObjectName() throws Exception
+   {
+      assertFailUnmarshal(MalformedObjectNameException.class);
+   }
+
+   // @review shouldn't an empty depends-list be an error?
+   public void testDependsListNone() throws Exception
+   {
+      dependsNone();
+   }
+
+   public void testDependsListOne() throws Exception
+   {
+      dependsOne();
+   }
+
+   public void testDependsListTwo() throws Exception
+   {
+      dependsTwo();
+   }
+
+   public void testDependsListNestedMBean() throws Exception
+   {
+      dependsOne();
+   }
+
+   public void testDependsListElementEmpty() throws Exception
+   {
+      assertFailUnmarshal(DeploymentException.class);
+   }
+
+   public void testDependsListElementNoNestedMBean() throws Exception
+   {
+      assertFailUnmarshal(DeploymentException.class);
+   }
+
+   public void testDependsListInvalidObjectName() throws Exception
+   {
+      assertFailUnmarshal(MalformedObjectNameException.class);
+   }
+
+   protected void dependsNone() throws Exception
+   {
+      ServiceMetaData metaData = unmarshalSingleMBean();
+      assertNoDependencies(metaData);
+      assertOthers(metaData);
+   }
+
+   protected void dependsOne() throws Exception
+   {
+      ServiceMetaData metaData = unmarshalSingleMBean();
+      ObjectName[] expected = { new ObjectName("test:test=1") };
+      assertDependencies(metaData, expected);
+      assertOthers(metaData);
+   }
+
+   protected void dependsTwo() throws Exception
+   {
+      ServiceMetaData metaData = unmarshalSingleMBean();
+      ObjectName[] expected = { new ObjectName("test:test=1"), new ObjectName("test:test=2") };
+      assertDependencies(metaData, expected);
+      assertOthers(metaData);
+   }
+
+   protected void assertOthers(ServiceMetaData metaData) throws Exception
+   {
+      assertEquals(testBasicMBeanName, metaData.getObjectName());
+      assertEquals(testBasicMBeanCode, metaData.getCode());
+      assertNull(metaData.getInterfaceName());
+      assertDefaultConstructor(metaData);
+      assertNoAttributes(metaData);
+      assertNoXMBean(metaData);
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/metadata/test/AbstractMetaDataTest.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/metadata/test/AbstractMetaDataTest.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/metadata/test/AbstractMetaDataTest.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,220 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.metadata.test;
+
+import java.net.URL;
+import java.util.HashSet;
+import java.util.List;
+
+import javax.management.ObjectName;
+
+import junit.framework.AssertionFailedError;
+
+import org.jboss.mx.util.ObjectNameFactory;
+import org.jboss.system.metadata.ServiceAttributeMetaData;
+import org.jboss.system.metadata.ServiceConstructorMetaData;
+import org.jboss.system.metadata.ServiceDependencyMetaData;
+import org.jboss.system.metadata.ServiceMetaData;
+import org.jboss.test.AbstractSystemTest;
+import org.jboss.test.AbstractTestDelegate;
+
+/**
+ * A MetaDataTest.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.2 $
+ */
+public class AbstractMetaDataTest extends AbstractSystemTest
+{
+   protected ObjectName testBasicMBeanName = ObjectNameFactory.create("jboss.test:type=BasicMBeanName");
+   protected String testBasicMBeanCode = "BasicMBeanCode";
+   protected String testBasicMBeanInterface = "BasicMBeanInterface";
+   
+   /**
+    * Create a new ContainerTest.
+    * 
+    * @param name the test name
+    */
+   public AbstractMetaDataTest(String name)
+   {
+      super(name);
+   }
+   
+   /**
+    * Default setup with security manager enabled
+    * 
+    * @param clazz the class
+    * @return the delegate
+    * @throws Exception for any error
+    */
+   public static AbstractTestDelegate getDelegate(Class clazz) throws Exception
+   {
+      MetaDataTestDelegate delegate = new MetaDataTestDelegate(clazz);
+      delegate.enableSecurity = true;
+      return delegate;
+   }
+   
+   /**
+    * Unmarshal some xml
+    * 
+    * @param name the name
+    * @return the list of services
+    * @throws Exception for any error
+    */
+   protected List<ServiceMetaData> unmarshal(String name) throws Exception
+   {
+      URL url = findXML(name);
+      return getMetaDataDelegate().unmarshal(url);
+   }
+   
+   /**
+    * Unmarshal a single mbean
+    * 
+    * @return the single service
+    * @throws Exception for any error
+    */
+   protected ServiceMetaData unmarshalSingleMBean() throws Exception
+   {
+      String name = getName();
+      name = name.substring(4) + ".xml";
+      return unmarshalSingleMBean(name);
+   }
+   
+   /**
+    * Unmarshal a single mbean
+    * 
+    * @param name the name
+    * @return the single service
+    * @throws Exception for any error
+    */
+   protected ServiceMetaData unmarshalSingleMBean(String name) throws Exception
+   {
+      URL url = findXML(name);
+      List<ServiceMetaData> services = getMetaDataDelegate().unmarshal(url);
+      assertFalse(url + " should contain an mbean ", services.isEmpty());
+      ServiceMetaData service = services.get(services.size()-1);
+      assertNotNull(service);
+      return service;
+   }
+   
+   protected void assertFailUnmarshal(Class<? extends Throwable> expected) throws Exception
+   {
+      String name = getName();
+      name = name.substring(4) + ".xml";
+      assertFailUnmarshal(name, expected);
+   }
+   
+   protected void assertFailUnmarshal(String name, Class<? extends Throwable> expected) throws Exception
+   {
+      try
+      {
+         unmarshal(name);
+         fail("Should fail to unmarshal " + name);
+      }
+      catch (AssertionFailedError e)
+      {
+         throw e;
+      }
+      catch (Throwable error)
+      {
+         AbstractSystemTest.checkThrowableDeep(expected, error);
+      }
+   }
+   
+   /**
+    * Find the xml
+    * 
+    * @param name the name
+    * @return the url of the xml
+    */
+   protected URL findXML(String name)
+   {
+      URL url = getResource(name);
+      if (url == null)
+         fail(name + " not found");
+      return url;
+   }
+
+   protected MetaDataTestDelegate getMetaDataDelegate()
+   {
+      return (MetaDataTestDelegate) getDelegate();
+   }
+   
+   protected void assertDefaultConstructor(ServiceMetaData metaData) throws Exception
+   {
+      ServiceConstructorMetaData constructor = metaData.getConstructor();
+      assertNotNull(constructor);
+      String[] signature = constructor.getSignature();
+      assertNotNull(signature);
+      assertEquals(0, signature.length);
+      String[] params = constructor.getParams();
+      assertNotNull(params);
+      assertEquals(0, params.length);
+   }
+   
+   protected void assertConstructor(String[] expectedSignature, String[] expectedParams, ServiceMetaData metaData) throws Exception
+   {
+      ServiceConstructorMetaData constructor = metaData.getConstructor();
+      assertNotNull(constructor);
+      String[] signature = constructor.getSignature();
+      assertNotNull(signature);
+      assertEquals(expectedSignature, signature);
+      String[] params = constructor.getParams();
+      assertNotNull(params);
+      assertEquals(expectedParams, params);
+   }
+   
+   protected void assertNoAttributes(ServiceMetaData metaData) throws Exception
+   {
+      List<ServiceAttributeMetaData> attributes = metaData.getAttributes();
+      assertNotNull(attributes);
+      assertEquals(0, attributes.size());
+   }
+   
+   protected void assertNoDependencies(ServiceMetaData metaData) throws Exception
+   {
+      List<ServiceDependencyMetaData> dependencies = metaData.getDependencies();
+      assertNotNull(dependencies);
+      assertEquals(0, dependencies.size());
+   }
+   
+   protected void assertDependencies(ServiceMetaData metaData, ObjectName[] expected) throws Exception
+   {
+      List<ServiceDependencyMetaData> dependencies = metaData.getDependencies();
+      assertNotNull(dependencies);
+      assertEquals(expected.length, dependencies.size());
+      HashSet<ObjectName> expectedSet = new HashSet<ObjectName>();
+      for (ObjectName expect : expected)
+         expectedSet.add(expect);
+      HashSet<ObjectName> actual = new HashSet<ObjectName>();
+      for (ServiceDependencyMetaData depends : dependencies)
+         actual.add(depends.getIDependOn());
+      assertEquals(expectedSet, actual);
+   }
+   
+   protected void assertNoXMBean(ServiceMetaData metaData) throws Exception
+   {
+      assertNull(metaData.getXMBeanDD());
+      assertEquals(ServiceMetaData.XMBEAN_CODE, metaData.getXMBeanCode());
+      assertNull(metaData.getXMBeanDescriptor());
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/metadata/test/MetaDataTestDelegate.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/metadata/test/MetaDataTestDelegate.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/metadata/test/MetaDataTestDelegate.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,104 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.metadata.test;
+
+import java.io.InputStream;
+import java.net.URL;
+import java.util.List;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.jboss.system.metadata.ServiceMetaData;
+import org.jboss.system.metadata.ServiceMetaDataParser;
+import org.jboss.test.AbstractTestDelegate;
+import org.jboss.util.xml.JBossEntityResolver;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.InputSource;
+
+/**
+ * MetaDataTestDelegate.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class MetaDataTestDelegate extends AbstractTestDelegate
+{
+   /** The parser */
+   private DocumentBuilder parser;
+   
+   public MetaDataTestDelegate(Class clazz)
+   {
+      super(clazz);
+   }
+
+   public void setUp() throws Exception
+   {
+      super.setUp();
+      DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+      parser = factory.newDocumentBuilder();
+   }
+
+   /**
+    * Unmarshal an object
+    * 
+    * @param url the url
+    * @return the list of services
+    * @throws Exception for any error
+    */
+   public List<ServiceMetaData> unmarshal(URL url) throws Exception
+   {
+      long start = System.currentTimeMillis();
+
+      Element element = null;
+
+      try
+      {
+         InputStream stream = url.openStream();
+         try
+         {
+            InputSource is = new InputSource(stream);
+            is.setSystemId(url.toString());
+            parser.setEntityResolver(new JBossEntityResolver());
+            log.debug("Initialized parsing in " + (System.currentTimeMillis() - start) + "ms");
+
+            Document document = parser.parse(is);
+            element = document.getDocumentElement();
+         }
+         finally
+         {
+            stream.close();
+         }
+
+         ServiceMetaDataParser parser = new ServiceMetaDataParser(element);
+         List<ServiceMetaData> result = parser.parse();
+         log.debug("Total parse for " + url + " took " + (System.currentTimeMillis() - start) + "ms");
+         return result;
+      }
+      catch (Exception e)
+      {
+         log.debug("Error during parsing: " + url + ": " + e);
+         throw e;
+      }
+   }
+}

Added: trunk/system/src/tests/org/jboss/test/system/metadata/test/MetaDataTestSuite.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/system/metadata/test/MetaDataTestSuite.java	2006-08-03 15:52:46 UTC (rev 55117)
+++ trunk/system/src/tests/org/jboss/test/system/metadata/test/MetaDataTestSuite.java	2006-08-03 16:33:33 UTC (rev 55118)
@@ -0,0 +1,55 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.metadata.test;
+
+import org.jboss.test.system.metadata.basic.test.BasicMBeanUnitTestCase;
+import org.jboss.test.system.metadata.constructor.test.ConstructorUnitTestCase;
+import org.jboss.test.system.metadata.depends.test.DependsUnitTestCase;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * MetaData Test Suite.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.8 $
+ */
+public class MetaDataTestSuite extends TestSuite
+{
+   public static void main(String[] args)
+   {
+      TestRunner.run(suite());
+   }
+
+   public static Test suite()
+   {
+      TestSuite suite = new TestSuite("MetaData Tests");
+
+      suite.addTest(new TestSuite(BasicMBeanUnitTestCase.class));
+      suite.addTest(new TestSuite(ConstructorUnitTestCase.class));
+      suite.addTest(new TestSuite(DependsUnitTestCase.class));
+      
+      return suite;
+   }
+}




More information about the jboss-cvs-commits mailing list