Author: [email protected]
Date: Tue Mar 17 09:52:15 2009
New Revision: 5097

Modified:
trunk/servers/jain-slee/core/deployer/src/main/java/org/mobicents/slee/container/deployment/jboss/DeployableComponent.java trunk/servers/jain-slee/core/deployer/src/main/java/org/mobicents/slee/container/deployment/jboss/DeployableUnit.java trunk/servers/jain-slee/core/deployer/src/main/java/org/mobicents/slee/container/deployment/jboss/DeploymentManager.java trunk/servers/jain-slee/core/deployer/src/main/java/org/mobicents/slee/container/deployment/jboss/SLEEDeployer.java trunk/servers/jain-slee/core/deployer/src/main/java/org/mobicents/slee/container/deployment/jboss/SLEESubDeployer.java trunk/servers/jain-slee/core/jmx-property-editors/src/main/java/org/mobicents/slee/container/management/jmx/editors/ComponentIDPropertyEditor.java

Log:
Fixing deployer for new component model and container changes.

Modified: trunk/servers/jain-slee/core/deployer/src/main/java/org/mobicents/slee/container/deployment/jboss/DeployableComponent.java
==============================================================================
--- trunk/servers/jain-slee/core/deployer/src/main/java/org/mobicents/slee/container/deployment/jboss/DeployableComponent.java (original) +++ trunk/servers/jain-slee/core/deployer/src/main/java/org/mobicents/slee/container/deployment/jboss/DeployableComponent.java Tue Mar 17 09:52:15 2009
@@ -5,39 +5,27 @@
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
 import java.util.List;
+import java.util.Set;

 import javax.slee.ComponentID;
-import javax.slee.profile.ProfileSpecificationID;
-import javax.slee.resource.ResourceAdaptorTypeID;

 import org.jboss.logging.Logger;
-import org.mobicents.slee.container.SleeContainer;
-import org.mobicents.slee.container.component.ComponentKey;
-import org.mobicents.slee.container.component.EventTypeIDImpl;
-import org.mobicents.slee.container.component.MobicentsEventTypeDescriptorInternalImpl; -import org.mobicents.slee.container.component.MobicentsSbbDescriptorInternalImpl; -import org.mobicents.slee.container.component.ProfileSpecificationDescriptorImpl;
-import org.mobicents.slee.container.component.ResourceAdaptorEntityBinding;
-import org.mobicents.slee.container.component.ResourceAdaptorIDImpl;
-import org.mobicents.slee.container.component.SbbEventEntry;
-import org.mobicents.slee.container.component.SbbIDImpl;
-import org.mobicents.slee.container.component.SbbRef;
-import org.mobicents.slee.container.component.ServiceIDImpl;
-import org.mobicents.slee.container.component.deployment.EventTypeDeploymentDescriptorParser; -import org.mobicents.slee.container.component.deployment.ProfileSpecificationDescriptorParser; -import org.mobicents.slee.container.component.deployment.ResourceAdaptorDescriptorParser; -import org.mobicents.slee.container.component.deployment.ResourceAdaptorTypeDescriptorParser; -import org.mobicents.slee.container.component.deployment.SbbDeploymentDescriptorParser;
-import org.mobicents.slee.container.management.xml.XMLConstants;
-import org.mobicents.slee.container.management.xml.XMLUtils;
-import org.mobicents.slee.resource.ResourceAdaptorDescriptorImpl;
-import org.mobicents.slee.resource.ResourceAdaptorTypeDescriptorImpl;
-import org.mobicents.slee.resource.ResourceAdaptorTypeIDImpl;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
+import org.mobicents.slee.container.component.deployment.jaxb.descriptors.EventTypeDescriptorFactory; +import org.mobicents.slee.container.component.deployment.jaxb.descriptors.EventTypeDescriptorImpl; +import org.mobicents.slee.container.component.deployment.jaxb.descriptors.ProfileSpecificationDescriptorFactory; +import org.mobicents.slee.container.component.deployment.jaxb.descriptors.ProfileSpecificationDescriptorImpl; +import org.mobicents.slee.container.component.deployment.jaxb.descriptors.ResourceAdaptorDescriptorFactory; +import org.mobicents.slee.container.component.deployment.jaxb.descriptors.ResourceAdaptorDescriptorImpl; +import org.mobicents.slee.container.component.deployment.jaxb.descriptors.ResourceAdaptorTypeDescriptorFactory; +import org.mobicents.slee.container.component.deployment.jaxb.descriptors.ResourceAdaptorTypeDescriptorImpl; +import org.mobicents.slee.container.component.deployment.jaxb.descriptors.SbbDescriptorFactory; +import org.mobicents.slee.container.component.deployment.jaxb.descriptors.SbbDescriptorImpl; +import org.mobicents.slee.container.component.deployment.jaxb.descriptors.ServiceDescriptorFactory; +import org.mobicents.slee.container.component.deployment.jaxb.descriptors.ServiceDescriptorImpl; +import org.mobicents.slee.container.component.deployment.jaxb.descriptors.sbb.MResourceAdaptorEntityBinding; +import org.mobicents.slee.container.component.deployment.jaxb.descriptors.sbb.MResourceAdaptorTypeBinding; +import org.mobicents.slee.container.management.jmx.editors.ComponentIDPropertyEditor;

 /**
* This class represents a SLEE Deployable Component such as a Profile Specification,
@@ -179,37 +167,23 @@
       {
         is = diURL.openStream();

-        // Parse the descriptor
-        org.w3c.dom.Document doc2 = XMLUtils.parseDocument( is, true );
+        ServiceDescriptorFactory sdf = new ServiceDescriptorFactory();
+        List<ServiceDescriptorImpl> serviceDescriptors = sdf.parse( is );

-        NodeList nodeList = doc2.getElementsByTagName( "service" );
-
-        for( int i=0; i < nodeList.getLength(); i++ )
+        for(ServiceDescriptorImpl sd : serviceDescriptors)
         {
-          Element curElement = (Element) nodeList.item(i);
-
- String serviceName = curElement.getElementsByTagName( "service-name" ).item(0).getTextContent().trim(); - String serviceVendor = curElement.getElementsByTagName( "service-vendor" ).item(0).getTextContent().trim(); - String serviceVersion = curElement.getElementsByTagName( "service-version" ).item(0).getTextContent().trim();
-
           DeployableComponent dc = new DeployableComponent( this );

- dc.componentID = new ServiceIDImpl( new ComponentKey( serviceName, serviceVendor, serviceVersion ) );
+          dc.componentID = sd.getServiceID();

-          dc.componentKey = dc.componentID.toString();
+          dc.componentKey = getComponentIdAsString( dc.componentID );

           dc.componentType = SERVICE_COMPONENT;

           if( logger.isTraceEnabled() )
             logger.trace( "Component ID: " + dc.componentKey );

- Element rootSbbElem = (Element) curElement.getElementsByTagName( XMLConstants.ROOT_SBB_ND ).item( 0 );
-
- String rootSbbName = rootSbbElem.getElementsByTagName( XMLConstants.SBB_NAME_ND ).item(0).getTextContent().trim(); - String rootSbbVendor = rootSbbElem.getElementsByTagName( XMLConstants.SBB_VENDOR_ND ).item(0).getTextContent().trim(); - String rootSbbVersion = rootSbbElem.getElementsByTagName( XMLConstants.SBB_VERSION_ND ).item(0).getTextContent().trim();
-
- String rootSbb = new SbbIDImpl( new ComponentKey(rootSbbName, rootSbbVendor, rootSbbVersion) ).toString();
+          String rootSbb = getComponentIdAsString( sd.getRootSbbID() );

           if( logger.isTraceEnabled() )
           {
@@ -255,8 +229,6 @@
     {
       URL descriptorXML = null;

-      org.w3c.dom.Document doc = null;
-
// Determine whether the type of this instance is an sbb, event, RA type, etc. if( ( descriptorXML = duWrapper.getEntry( "META-INF/sbb-jar.xml" ) ) != null )
       {
@@ -269,34 +241,27 @@
         {
           is = descriptorXML.openStream();

-          // Create the XML document from file
-          doc = XMLUtils.parseDocument( is, true );
-          org.w3c.dom.Element sbbJarNode = doc.getDocumentElement();
+          // Parse the descriptor using the factory
+          SbbDescriptorFactory sbbdf = new SbbDescriptorFactory();
+          List<SbbDescriptorImpl> sbbDescriptors = sbbdf.parse( is );

-          // Get a list of the SBBs in the descriptor
- List<org.w3c.dom.Element> sbbNodes = XMLUtils.getAllChildElements( sbbJarNode, XMLConstants.SBB_ND );
-
-          if( sbbNodes.size() == 0 )
+          if( sbbDescriptors.size() == 0 )
           {
logger.warn( "The " + duWrapper.getFileName() + " deployment descriptor contains no sbb definitions" );
             return null;
           }

-          for( int i = sbbNodes.size() - 1; i >= 0; i-- )
+          for( SbbDescriptorImpl sbbDescriptor : sbbDescriptors)
           {
             DeployableComponent dc = new DeployableComponent( this );

             dc.componentType = SBB_COMPONENT;

-            org.w3c.dom.Element sbbNode = sbbNodes.get( i );
- SbbDeploymentDescriptorParser parser = new SbbDeploymentDescriptorParser(); - MobicentsSbbDescriptorInternalImpl descriptor = (MobicentsSbbDescriptorInternalImpl) parser.parseSbbComponent( sbbNode, new MobicentsSbbDescriptorInternalImpl() );
-
             // Get the Component ID
-            dc.componentID = descriptor.getID();
+            dc.componentID = sbbDescriptor.getSbbID();

             // Get the Component Key
-            dc.componentKey = dc.componentID.toString();
+            dc.componentKey = getComponentIdAsString( dc.componentID );

             if( logger.isTraceEnabled() )
             {
@@ -305,68 +270,36 @@
logger.trace( "------------------------------ Dependencies ------------------------------" );
             }

-            // Get the list of sbb references
-            HashSet<SbbRef> sbbRefs = descriptor.getSbbRef();
+            // Get the set of this sbb dependencies
+ Set<ComponentID> sbbDependencies = sbbDescriptor.getDependenciesSet();

-            // Iterate through the SbbRef nodes
-            for( SbbRef sbbRef : sbbRefs )
+            // Iterate through dependencies set
+            for( ComponentID dependencyId : sbbDependencies )
             {
-              // Add the SbbRef as a dependency
- dc.dependencies.add( "SbbID[" + sbbRef.getComponentKey() + "]" );
+              // Add the dependency
+ dc.dependencies.add( getComponentIdAsString( dependencyId ) );

               if( logger.isTraceEnabled() )
-                logger.trace( "SbbID[" + sbbRef.getComponentKey() + "]" );
+              {
+                logger.trace( getComponentIdAsString( dependencyId ) );
+              }
             }

-            // Get the list of RA Types in the descriptor
- ResourceAdaptorTypeID[] rasList = descriptor.getResourceAdaptorTypes();
-
-            // Iterate through the RA Types nodes
-            for( int n = 0; n < rasList.length; n++ )
+ // FIXME: This is special case for Links. Maybe it should be treated in SbbDescriptorImpl? + for(MResourceAdaptorTypeBinding raTypeBinding : sbbDescriptor.getResourceAdaptorTypeBindings())
             {
- // Add the RA Type to the dependencies (maybe not needed due to the link)
-              dc.dependencies.add( rasList[n].toString() );
-
-              if( logger.isTraceEnabled() )
-                logger.trace( rasList[n] );
-
-              // Get the entity links from the descriptor
- Iterator<ResourceAdaptorEntityBinding> raebIt = descriptor.getResourceAdaptorEntityBindings( (ResourceAdaptorTypeIDImpl) rasList[n] );
-
-              while( raebIt.hasNext() )
+ for(MResourceAdaptorEntityBinding raEntityBinding : raTypeBinding.getResourceAdaptorEntityBinding())
               {
- // Generate a special identifier for the links: linkna...@_ratype[name#vendor#version] - String raLink = raebIt.next().getResourceAdaptorEntityLink() + "_...@_" + rasList[n]; + String raLink = raEntityBinding.getResourceAdaptorEntityLink() + "_...@_" + getComponentIdAsString( raTypeBinding.getResourceAdaptorTypeRef() );

-                // Add it to dependencies
+                // Add the dependency
                 dc.dependencies.add( raLink );

                 if( logger.isTraceEnabled() )
                   logger.trace( raLink );
               }
             }
-
-            // Get the event types from descriptor...
- HashSet<SbbEventEntry> eventsList = descriptor.getSbbEventEntries();
-            for( SbbEventEntry event : eventsList )
-            {
- String eventTypeID = "EventTypeID[" + event.getEventTypeRefKey() + "]";
-
-              dc.dependencies.add( eventTypeID );
-
-              if( logger.isTraceEnabled() )
-                logger.trace( eventTypeID );
-            }
-
-            // Get the profile specifications from descriptor...
- ProfileSpecificationID[] profilesList = descriptor.getProfileSpecifications();
-            for( int n = 0; n < profilesList.length; n++ )
-            {
-              dc.dependencies.add( profilesList[n].toString() );
-
-              if( logger.isTraceEnabled() )
-                logger.trace( profilesList[n] );
-            }
+
             if( logger.isTraceEnabled() )
logger.trace( "--------------------------- End of Dependencies --------------------------" );

@@ -405,43 +338,56 @@
           // Get the InputStream
           is = descriptorXML.openStream();

-          // Create the XML document from file
-          doc = XMLUtils.parseDocument( is, true );
-          org.w3c.dom.Element profileJarNode = doc.getDocumentElement();
-
+          // Parse the descriptor using the factory
+ ProfileSpecificationDescriptorFactory psdf = new ProfileSpecificationDescriptorFactory(); + List<ProfileSpecificationDescriptorImpl> psDescriptors = psdf.parse( is );
+
// Get a list of the profile specifications in the deployable unit. - List<org.w3c.dom.Element> profileSpecNodes = XMLUtils.getAllChildElements( profileJarNode, XMLConstants.PROFILE_SPEC_ND );
-          if( profileSpecNodes.size() == 0 )
+          if( psDescriptors.size() == 0 )
           {
logger.warn( "The " + duWrapper.getFileName() + " deployment descriptor contains no profile-spec definitions" );
             return null;
           }

           // Iterate through the profile spec nodes
-          for( int i = profileSpecNodes.size() - 1; i >= 0; i-- )
+ for( ProfileSpecificationDescriptorImpl psDescriptor : psDescriptors )
           {
             DeployableComponent dc = new DeployableComponent( this );

             // Set Component Type
             dc.componentType = PROFILESPEC_COMPONENT;

-            // Do the parsing...
- org.w3c.dom.Element profileSpecNode = profileSpecNodes.get( i ); - ProfileSpecificationDescriptorParser parser = new ProfileSpecificationDescriptorParser(); - ProfileSpecificationDescriptorImpl descriptor = parser.parseProfileComponent( profileSpecNode, new ProfileSpecificationDescriptorImpl() );
-
             // Get the Component ID
-            dc.componentID = descriptor.getID();
+            dc.componentID = psDescriptor.getProfileSpecificationID();

             // Get the Component Key
-            dc.componentKey = dc.componentID.toString();
+            dc.componentKey = getComponentIdAsString(dc.componentID);

             if( logger.isTraceEnabled() )
+            {
               logger.trace( "Component ID: " + dc.componentKey );
+
+ logger.trace( "------------------------------ Dependencies ------------------------------" );
+            }
+
+            // Get the set of this sbb dependencies
+ Set<ComponentID> psDependencies = psDescriptor.getDependenciesSet();
+
+            // Iterate through dependencies set
+            for( ComponentID dependencyId : psDependencies )
+            {
+              // Add the dependency
+ dc.dependencies.add( getComponentIdAsString( dependencyId ) );
+
+              if( logger.isTraceEnabled() )
+                logger.trace( getComponentIdAsString( dependencyId ) );
+            }
+
+            if( logger.isTraceEnabled() )
+ logger.trace( "--------------------------- End of Dependencies --------------------------" );

             deployableComponents.add( dc );
           }
-
         }
         catch ( Exception e )
         {
@@ -475,35 +421,53 @@
           // Get the InputStream
           is = descriptorXML.openStream();

-          // Create the XML document from file
-          doc = XMLUtils.parseDocument( is, true );
-          org.w3c.dom.Element docElement = doc.getDocumentElement();
+          // Parse the descriptor using the factory
+ EventTypeDescriptorFactory etdf = new EventTypeDescriptorFactory();
+          List<EventTypeDescriptorImpl> etDescriptors = etdf.parse( is );

- // Get a list of the event definitions in the deployment descriptor - List<org.w3c.dom.Element> nodes = XMLUtils.getAllChildElements( docElement, XMLConstants.EVENT_DEFINITION_ND );
-
-          for( int i = 0; i < nodes.size(); i++ )
+          if( etDescriptors == null || etDescriptors.size() == 0 )
+          {
+ logger.warn( "The " + duWrapper.getFileName() + " deployment descriptor contains no event-type definitions" );
+            return null;
+          }
+
+          for( EventTypeDescriptorImpl etDescriptor : etDescriptors )
           {
             DeployableComponent dc = new DeployableComponent( this );

             // Set Component Type
             dc.componentType = EVENTTYPE_COMPONENT;

-            // Do the parsing...
- MobicentsEventTypeDescriptorInternalImpl descriptorImpl = new MobicentsEventTypeDescriptorInternalImpl();
-            org.w3c.dom.Element eventDefinitionNode = nodes.get( i );
- EventTypeDeploymentDescriptorParser parser = new EventTypeDeploymentDescriptorParser();
-            parser.parse( eventDefinitionNode, descriptorImpl );
-
             // Get the Component ID
- dc.componentID = new EventTypeIDImpl( new ComponentKey(descriptorImpl.getName(), descriptorImpl.getVendor(), descriptorImpl.getVersion() ));
+            dc.componentID = etDescriptor.getEventTypeID();

             // Get the Component Key
- dc.componentKey = dc.componentID.toString().substring( 0, dc.componentID.toString().indexOf( ',' ) );
-
+ // FIXME: Does the ComponentID still comes with the , ## ? dc.componentKey = dc.componentID.toString().substring( 0, dc.componentID.toString().indexOf( ',' ) );
+            dc.componentKey = getComponentIdAsString( dc.componentID );
+
             if( logger.isTraceEnabled() )
+            {
               logger.trace( "Component ID: " + dc.componentKey );
+
+ logger.trace( "------------------------------ Dependencies ------------------------------" );
+            }

+            // Get the set of this sbb dependencies
+ Set<ComponentID> etDependencies = etDescriptor.getDependenciesSet();
+
+            // Iterate through dependencies set
+            for( ComponentID dependencyId : etDependencies )
+            {
+              // Add the dependency
+ dc.dependencies.add( getComponentIdAsString( dependencyId ) );
+
+              if( logger.isTraceEnabled() )
+                logger.trace( getComponentIdAsString( dependencyId ) );
+            }
+
+            if( logger.isTraceEnabled() )
+ logger.trace( "--------------------------- End of Dependencies --------------------------" );
+
             deployableComponents.add( dc );
           }

@@ -540,59 +504,54 @@
           // Get the InputStream
           is = descriptorXML.openStream();

-          // Create the XML document from file
-          doc = XMLUtils.parseDocument( is, true );
-          org.w3c.dom.Element raJarNode = doc.getDocumentElement();
+          // Parse the descriptor using the factory
+ ResourceAdaptorTypeDescriptorFactory ratdf = new ResourceAdaptorTypeDescriptorFactory(); + List<ResourceAdaptorTypeDescriptorImpl> ratDescriptors = ratdf.parse( is );

-          // Get a list of resource adaptor types in the deployable unit.
- List<org.w3c.dom.Element> raTypeNodes = XMLUtils.getAllChildElements( raJarNode, XMLConstants.RESOURCE_ADAPTOR_TYPE_ND );
-
-          if( raTypeNodes != null )
+          if( ratDescriptors == null || ratDescriptors.size() == 0 )
+          {
+ logger.warn( "The " + duWrapper.getFileName() + " deployment descriptor contains no resource-adaptor-type definitions" );
+            return null;
+          }
+
+          // Go through all the Resource Adaptor Type Elements
+ for( ResourceAdaptorTypeDescriptorImpl ratDescriptor : ratDescriptors )
           {
-            // Go through all the Resource Adaptor Type Elements
- for( Iterator<org.w3c.dom.Element> it = raTypeNodes.iterator(); it.hasNext(); )
+            DeployableComponent dc = new DeployableComponent( this );
+
+            // Set Component Type
+            dc.componentType = RATYPE_COMPONENT;
+
+            // Get the Component ID
+            dc.componentID = ratDescriptor.getResourceAdaptorTypeID();
+
+            // Get the Component Key
+            dc.componentKey = getComponentIdAsString(dc.componentID);
+
+            if( logger.isTraceEnabled() )
             {
-              DeployableComponent dc = new DeployableComponent( this );
-
-              // Set Component Type
-              dc.componentType = RATYPE_COMPONENT;
-
-              // Do the parsing...
- ResourceAdaptorTypeDescriptorImpl raTypeDescriptor = new ResourceAdaptorTypeDescriptorImpl(); - ResourceAdaptorTypeDescriptorParser parser = new ResourceAdaptorTypeDescriptorParser(); - parser.parseResourceAdaptorTypeDescriptor( it.next(), raTypeDescriptor );
-
-              // Get the Component ID
-              dc.componentID = raTypeDescriptor.getID();
-
-              // Get the Component Key
-              dc.componentKey = dc.componentID.toString();
-
-              if( logger.isTraceEnabled() )
-              {
-                logger.trace( "Component ID: " + dc.componentKey );
-
- logger.trace( "------------------------------ Dependencies ------------------------------" );
-              }
+              logger.trace( "Component ID: " + dc.componentKey );

-              // Get the events this RA Type depends on
- ComponentKey[] eventsList = raTypeDescriptor.getEventTypeRefEntries();
-
-              // Iterate them...
-              for( int i = 0; i < eventsList.length; i++ )
-              {
-                if( logger.isTraceEnabled() )
- logger.trace( "EventTypeID[" + eventsList[i].toString() + "]" );
-
-                // Add it to the dependencies list
- dc.dependencies.add( "EventTypeID[" + eventsList[i].toString() + "]" );
-              }
+ logger.trace( "------------------------------ Dependencies ------------------------------" );
+            }
+
+            // Get the set of this sbb dependencies
+ Set<ComponentID> ratDependencies = ratDescriptor.getDependenciesSet();
+
+            // Iterate through dependencies set
+            for( ComponentID dependencyId : ratDependencies )
+            {
+              // Add the dependency
+ dc.dependencies.add( getComponentIdAsString( dependencyId ) );

               if( logger.isTraceEnabled() )
- logger.trace( "--------------------------- End of Dependencies --------------------------" );
-
-              deployableComponents.add( dc );
+                logger.trace( getComponentIdAsString( dependencyId ) );
             }
+
+            if( logger.isTraceEnabled() )
+ logger.trace( "--------------------------- End of Dependencies --------------------------" );
+
+            deployableComponents.add( dc );
           }
         }
         catch ( Exception e )
@@ -627,42 +586,46 @@
           // Get the InputStream
           is = descriptorXML.openStream();

-          // Create the XML document from file
-          doc = XMLUtils.parseDocument( is, true );
+          // Parse the descriptor using the factory
+ ResourceAdaptorDescriptorFactory radf = new ResourceAdaptorDescriptorFactory(); + List<ResourceAdaptorDescriptorImpl> raDescriptors = radf.parse( is );

           // Go through all the Resource Adaptor Elements
- for( Iterator<org.w3c.dom.Element> it = XMLUtils.getAllChildElements( doc.getDocumentElement(), XMLConstants.RESOURCE_ADAPTOR ).iterator(); it.hasNext(); )
+          for( ResourceAdaptorDescriptorImpl raDescriptor : raDescriptors )
           {
             DeployableComponent dc = new DeployableComponent( this );

             // Set Component Type
             dc.componentType = RA_COMPONENT;

-            // Get the next element
-            org.w3c.dom.Element raNode = it.next();
-
-            // Do the parsing...
- ResourceAdaptorDescriptorImpl raDescriptor = new ResourceAdaptorDescriptorImpl(); - ResourceAdaptorDescriptorParser parser = new ResourceAdaptorDescriptorParser();
-            parser.parseResourceAdaptorDescriptor( raNode, raDescriptor );
-
             // Set the Component ID
-            dc.componentID = raDescriptor.getID();
+            dc.componentID = raDescriptor.getResourceAdaptorID();

             // Set the Component Key
-            dc.componentKey = dc.componentID.toString();
-
-            // Add the dependencies
- dc.dependencies.add( raDescriptor.getResourceAdaptorType().toString() );
+            dc.componentKey = getComponentIdAsString(dc.componentID);

             if( logger.isTraceEnabled() )
             {
               logger.trace( "Component ID: " + dc.componentKey );
-
+
logger.trace( "------------------------------ Dependencies ------------------------------" );
-              logger.trace( raDescriptor.getResourceAdaptorType() );
- logger.trace( "--------------------------- End of Dependencies --------------------------" );
             }
+
+            // Get the set of this sbb dependencies
+ Set<ComponentID> raDependencies = raDescriptor.getDependenciesSet();
+
+            // Iterate through dependencies set
+            for( ComponentID dependencyId : raDependencies )
+            {
+              // Add the dependency
+ dc.dependencies.add( getComponentIdAsString( dependencyId ) );
+
+              if( logger.isTraceEnabled() )
+                logger.trace( getComponentIdAsString( dependencyId ) );
+            }
+
+            if( logger.isTraceEnabled() )
+ logger.trace( "--------------------------- End of Dependencies --------------------------" );

             deployableComponents.add( dc );
           }
@@ -755,8 +718,6 @@
    */
   public boolean isUndeployable(DeployableUnit du)
   {
-    SleeContainer sC = SleeContainer.lookupFromJndi();
-
     boolean result = false;

     switch( componentType )
@@ -768,20 +729,21 @@
       result = true;
       break;
     case RATYPE_COMPONENT:
+      // FIXME: Check if this is still needed in SLEE 2.x
+      //SleeContainer sC = SleeContainer.lookupFromJndi();
       // Get the DU componennts
-      Collection<String> duComponents = du.getComponents();
+      //Collection<String> duComponents = du.getComponents();

       // Obtaining the RAs using this RA Type
- HashSet<ResourceAdaptorIDImpl> raIDs = sC.getResourceManagement().getResourceAdaptorType( (ResourceAdaptorTypeID) componentID ).getResourceAdaptorIDs(); + //HashSet<ResourceAdaptorIDImpl> raIDs = sC.getResourceManagement().getResourceAdaptorType( (ResourceAdaptorTypeID) componentID ).getResourceAdaptorIDs();

       // Check if the referring RAs are in the same DU
-      for( ResourceAdaptorIDImpl raID : raIDs )
-        if( !duComponents.contains( raID.getAsText() ) )
-          return false;
+      //for( ResourceAdaptorIDImpl raID : raIDs )
+      //  if( !duComponents.contains( raID.getAsText() ) )
+      //    return false;

       // All aboard! Move on..
       result = true;
-
       break;
     case RA_COMPONENT:
       result = true;
@@ -797,4 +759,12 @@
     return result;
   }

+  private String getComponentIdAsString(ComponentID componentId)
+  {
+ ComponentIDPropertyEditor cidPropertyEditor = new ComponentIDPropertyEditor();
+    cidPropertyEditor.setValue( componentId );
+
+    return cidPropertyEditor.getAsText();
+
+  }
 }

Modified: trunk/servers/jain-slee/core/deployer/src/main/java/org/mobicents/slee/container/deployment/jboss/DeployableUnit.java
==============================================================================
--- trunk/servers/jain-slee/core/deployer/src/main/java/org/mobicents/slee/container/deployment/jboss/DeployableUnit.java (original) +++ trunk/servers/jain-slee/core/deployer/src/main/java/org/mobicents/slee/container/deployment/jboss/DeployableUnit.java Tue Mar 17 09:52:15 2009
@@ -15,13 +15,10 @@

 import org.jboss.logging.Logger;
 import org.mobicents.slee.container.SleeContainer;
-import org.mobicents.slee.container.component.ComponentIDImpl;
-import org.mobicents.slee.container.component.ComponentKey;
-import org.mobicents.slee.container.component.ResourceAdaptorIDImpl;
-import org.mobicents.slee.container.component.deployment.DeployableUnitDescriptorImpl;
-import org.mobicents.slee.container.management.ResourceManagement;
+import org.mobicents.slee.container.component.ComponentRepositoryImpl;
+import org.mobicents.slee.container.component.ResourceAdaptorComponent;
+import org.mobicents.slee.container.management.jmx.editors.ComponentIDPropertyEditor;
 import org.mobicents.slee.container.management.xml.XMLUtils;
-import org.mobicents.slee.resource.ResourceAdaptorType;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.NodeList;
@@ -335,13 +332,33 @@
         */
        private boolean hasReferringDU() throws Exception {
                
+    // Check if its safe to remove the deployable unit.
+
                // Get SleeContainer instance from JNDI
                SleeContainer sC = SleeContainer.lookupFromJndi();

-               // Get this DU Descriptor
- DeployableUnitDescriptorImpl dudesc = sC.getDeployableUnitManagement().getDeployableUnitDescriptor(this.diURL.toString());
+    for (String componentIdString : this.getComponents())
+    {
+      ComponentIDPropertyEditor cidpe = new ComponentIDPropertyEditor();
+      cidpe.setAsText( componentIdString );
+
+      ComponentID componentId = (ComponentID) cidpe.getValue();
+
+ for (ComponentID referringComponentId : sC.getComponentRepositoryImpl().getReferringComponents(componentId))
+      {
+        ComponentIDPropertyEditor rcidpe = new ComponentIDPropertyEditor();
+        rcidpe.setValue( referringComponentId );
+
+        String referringComponentIdString = rcidpe.getAsText();
+
+        if (!this.getComponents().contains( referringComponentIdString ))
+        {
+          return true;
+        }
+      }
+    }

-               return sC.getDeployableUnitManagement().hasReferringDU(dudesc);
+    return false;
        }

        /**
@@ -410,16 +427,13 @@
                                        Element raEntity = (Element) 
raEntities.item(i);

                                        // Get the component ID
-                                       raId = ComponentIDImpl.RESOURCE_ADAPTOR_ID + 
"["
-                                                       + 
raEntity.getAttribute("resource-adaptor-id")
-                                                       + "]";
+ raId = "ResourceAdaptorID[" + raEntity.getAttribute("resource-adaptor-id") + "]";

                                        // The RA Entity Name
                                        String entityName = 
raEntity.getAttribute("entity-name");

                                        // Select the properties node
-                                       NodeList propsNodeList = raEntity
-                                                       
.getElementsByTagName("properties");
+                                       NodeList propsNodeList = 
raEntity.getElementsByTagName("properties");

                                        if (propsNodeList.getLength() > 1)
                                                logger
@@ -461,10 +475,11 @@
                                                }
                                        }

-                                       // Create the Resource Adaptor ID
-                                       ResourceAdaptorID componentID = new 
ResourceAdaptorIDImpl(
-                                                       new 
ComponentKey(raEntity
-                                                                       
.getAttribute("resource-adaptor-id")));
+          // Create the Resource Adaptor ID
+                                       ComponentIDPropertyEditor cidpe = new 
ComponentIDPropertyEditor();
+ cidpe.setAsText( "ResourceAdaptorID[" + raEntity.getAttribute("resource-adaptor-id") + "]" );
+                                       
+                                       ResourceAdaptorID componentID = 
(ResourceAdaptorID) cidpe.getValue();

// Add the Create and Activate RA Entity actions to the Post-Install Actions
                                        cPostInstallActions.add(new Object[] {
@@ -486,27 +501,17 @@
                                                cPreUninstallActions.add(new 
Object[] {
                                                                
"unbindLinkName", linkName });

-                                               final ResourceManagement 
resourceManagement = SleeContainer
-                                                               
.lookupFromJndi().getResourceManagement();
-                                               ResourceAdaptorTypeID[] 
existingRATypeIDs = resourceManagement
-                                                               
.getResourceAdaptorTypeIDs();
-
-                                               String raTypeFromRa = null;
-
- for (ResourceAdaptorTypeID resourceAdaptorTypeID : existingRATypeIDs) {
-                                                       ResourceAdaptorType 
raType = resourceManagement
-                                                                       
.getResourceAdaptorType(resourceAdaptorTypeID);
-
-                                                       if (raType != null
-                                                                       && 
raType.getResourceAdaptorIDs().contains(
-                                                                               
        componentID))
-                                                               raTypeFromRa = 
raType
-                                                                               
.getResourceAdaptorTypeID().toString();
+                                               // FIXME: Not tested! Make sure 
it works...
+ ComponentRepositoryImpl componentRepository = SleeContainer.lookupFromJndi().getComponentRepositoryImpl(); + ResourceAdaptorComponent raComponent = componentRepository.getComponentByID(componentID);
+
+                                               if( raComponent != null)
+                                               {
+ for (ResourceAdaptorTypeID resourceAdaptorTypeID : raComponent.getSpecsDescriptor().getResourceAdaptorTypes())
+                                       {
+ this.componentIDs.add(linkName + "_...@_" + resourceAdaptorTypeID);
+                                       }
                                                }
-
-                                               if (raTypeFromRa != null)
-                                                       this.componentIDs.add(linkName + 
"_...@_"
-                                                                       + 
raTypeFromRa);
                                        }

// Add the Deactivate and Remove RA Entity actions to the Pre-Uninstall Actions

Modified: trunk/servers/jain-slee/core/deployer/src/main/java/org/mobicents/slee/container/deployment/jboss/DeploymentManager.java
==============================================================================
--- trunk/servers/jain-slee/core/deployer/src/main/java/org/mobicents/slee/container/deployment/jboss/DeploymentManager.java (original) +++ trunk/servers/jain-slee/core/deployer/src/main/java/org/mobicents/slee/container/deployment/jboss/DeploymentManager.java Tue Mar 17 09:52:15 2009
@@ -10,16 +10,11 @@
 import javax.management.MBeanServer;
 import javax.management.ObjectName;
 import javax.slee.ComponentID;
-import javax.slee.EventTypeID;
 import javax.slee.InvalidStateException;
-import javax.slee.SbbID;
-import javax.slee.ServiceID;
 import javax.slee.management.DeployableUnitID;
 import javax.slee.management.ResourceAdaptorEntityAlreadyExistsException;
 import javax.slee.management.ResourceAdaptorEntityState;
 import javax.slee.management.UnrecognizedLinkNameException;
-import javax.slee.profile.ProfileSpecificationID;
-import javax.slee.resource.ResourceAdaptorID;
 import javax.slee.resource.ResourceAdaptorTypeID;

 import org.jboss.deployment.DeploymentException;
@@ -159,18 +154,18 @@
                                                
.getResourceManagement().getResourceAdaptorEntity(
                                                                entityNames[i]);

-                               if (rae != null
-                                               && rae.getState() == 
ResourceAdaptorEntityState.ACTIVE) {
-                                       String raTypeId = 
rae.getInstalledResourceAdaptor()
-                                                       
.getRaType().getResourceAdaptorTypeID().toString();
-
-                                       String[] entityLinks = sleeContainer
-                                                       .getResourceManagement()
-                                                       
.getLinkNames(rae.getName());
-
-                                       for (String entityLink : entityLinks) {
-                                               newDeployedComponents
-                                                               .add(entityLink + 
"_...@_" + raTypeId);
+                               if (rae != null && rae.getState() == 
ResourceAdaptorEntityState.ACTIVE)
+                               {
+ ResourceAdaptorTypeID[] raTypeIds = rae.getComponent().getSpecsDescriptor().getResourceAdaptorTypes();
+
+                                       for(ResourceAdaptorTypeID raTypeId : 
raTypeIds )
+                                       {
+ String[] entityLinks = sleeContainer.getResourceManagement().getLinkNames(rae.getName());
+
+                                         for (String entityLink : entityLinks)
+                                         {
+                                                 newDeployedComponents.add(entityLink + 
"_...@_" + raTypeId);
+                                         }
                                        }
                                }
                        }

Modified: trunk/servers/jain-slee/core/deployer/src/main/java/org/mobicents/slee/container/deployment/jboss/SLEEDeployer.java
==============================================================================
--- trunk/servers/jain-slee/core/deployer/src/main/java/org/mobicents/slee/container/deployment/jboss/SLEEDeployer.java (original) +++ trunk/servers/jain-slee/core/deployer/src/main/java/org/mobicents/slee/container/deployment/jboss/SLEEDeployer.java Tue Mar 17 09:52:15 2009
@@ -1,13 +1,10 @@
 package org.mobicents.slee.container.deployment.jboss;

-import java.net.URL;
-
 import org.jboss.deployers.spi.DeploymentException;
 import org.jboss.deployers.vfs.spi.deployer.AbstractSimpleVFSRealDeployer;
 import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
 import org.jboss.logging.Logger;
 import org.jboss.system.ServiceController;
-import org.jboss.virtual.VFS;
 import org.jboss.virtual.VFSUtils;

public class SLEEDeployer extends AbstractSimpleVFSRealDeployer<SLEEDeploymentMetaData>

Modified: trunk/servers/jain-slee/core/deployer/src/main/java/org/mobicents/slee/container/deployment/jboss/SLEESubDeployer.java
==============================================================================
--- trunk/servers/jain-slee/core/deployer/src/main/java/org/mobicents/slee/container/deployment/jboss/SLEESubDeployer.java (original) +++ trunk/servers/jain-slee/core/deployer/src/main/java/org/mobicents/slee/container/deployment/jboss/SLEESubDeployer.java Tue Mar 17 09:52:15 2009
@@ -1,11 +1,7 @@
 package org.mobicents.slee.container.deployment.jboss;

 import java.io.IOException;
-import java.io.InputStream;
 import java.net.URL;
-import java.util.Collection;
-import java.util.Date;
-import java.util.List;
 import java.util.Timer;
 import java.util.TimerTask;
 import java.util.concurrent.ConcurrentHashMap;
@@ -19,12 +15,9 @@
 import org.jboss.deployment.DeploymentException;
 import org.jboss.deployment.SubDeployerSupport;
 import org.jboss.logging.Logger;
-import org.mobicents.slee.container.component.deployment.DeployableUnitDescriptorImpl; +import org.mobicents.slee.container.component.deployment.jaxb.descriptors.DeployableUnitDescriptorFactory; +import org.mobicents.slee.container.component.deployment.jaxb.descriptors.DeployableUnitDescriptorImpl;
 import org.mobicents.slee.container.management.jmx.MobicentsManagement;
-import org.mobicents.slee.container.management.xml.XMLConstants;
-import org.mobicents.slee.container.management.xml.XMLUtils;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;

 /**
* This is the Deployer main class where the AS will invoke the lifecycle methods
@@ -248,17 +241,15 @@
             DeployableUnit deployerDU = new DeployableUnit( du );

             // Let's parse the descriptor to see what we've got...
- DeployableUnitDescriptorImpl duDesc = parseDUDescriptor( duJarFile ); + DeployableUnitDescriptorFactory dudf = new DeployableUnitDescriptorFactory(); + DeployableUnitDescriptorImpl duDesc = dudf.parse( duJarFile.getInputStream( duXmlEntry ) );

             // Add it to the deployable units map.
             deployableUnits.put( fileName, deployerDU );

             // Go through each jar entry in the DU descriptor
-            for( Element elem : (Collection<Element>)duDesc.getJarNodes() )
+            for( String componentJarName : duDesc.getJarEntries() )
             {
-              // Get the name of the jar
-              String componentJarName = elem.getTextContent().trim();
-
               // Might have path... strip it!
               int beginIndex;

@@ -275,11 +266,8 @@
             }

             // Do the same as above... but for services
- for( Element elem : (Collection<Element>)duDesc.getServiceNodes() )
+            for( String serviceXMLName : duDesc.getServiceEndtries() )
             {
-              // Get the name of the service XML
-              String serviceXMLName = elem.getTextContent().trim();
-
               // Might have path... strip it!
               int beginIndex;

@@ -514,88 +502,88 @@

// Aux Functions ------------------------------------------------------------

-  /**
- * Method for parsing a Deployable Unit descriptor. Gotten from DeployableUnitDeployer.
-   */
- private DeployableUnitDescriptorImpl parseDUDescriptor( JarFile unitJarFile ) throws DeploymentException
-  {
-    // Get the deployable unit descriptor entry
- JarEntry duXmlEntry = unitJarFile.getJarEntry( "META-INF/deployable-unit.xml" );
-
-    // Don't have one? Go away!
-    if( duXmlEntry == null )
- throw new DeploymentException( "No DeployableUnitDeploymentDescriptor descriptor (META-INF/deployable-unit.xml) was found in deployable unit" + unitJarFile.getName() );
-
-    // The Document
-    Document doc = null;
-
-    InputStream is = null;
-
-    try
-    {
-      // Get the InputStream
-      is = unitJarFile.getInputStream( duXmlEntry );
-
-      // Parse the descriptor
-      doc = XMLUtils.parseDocument( is, false );
-    }
-    catch ( IOException ex )
-    {
- throw new DeploymentException( "Failed to extract the DU depl " + "descriptor from " + unitJarFile.getName() );
-    }
-    finally
-    {
-      // Clean up!
-      if( is != null )
-      {
-        try
-        {
-          is.close();
-        }
-        catch ( IOException ignore )
-        {
-        }
-        finally
-        {
-          is = null;
-        }
-      }
-    }
-
-    Element duNode = doc.getDocumentElement();
- DeployableUnitDescriptorImpl deployableUnitDescriptor = new DeployableUnitDescriptorImpl( unitJarFile.getName(), new Date() ); // getDescriptor();
-
-    try
-    {
-      // Get the description, if any.
- String description = XMLUtils.getElementTextValue( duNode, XMLConstants.DESCRIPTION_ND );
-
-      // Store it.
-      if( description != null )
-        deployableUnitDescriptor.setDescription( description );
-    }
-    catch ( Exception ex )
-    {
-      throw new DeploymentException( ex.getMessage() );
-    }
-
-    // Get a list of the jars in the deployable unit.
- List<Element> jarNodes = XMLUtils.getAllChildElements( duNode, XMLConstants.JAR_ND );
-    deployableUnitDescriptor.setJarNodes( jarNodes );
-
-    // Same for the services
- List<Element> serviceNodes = XMLUtils.getAllChildElements( duNode, XMLConstants.SERVICE_XML_ND );
-    deployableUnitDescriptor.setServiceNodes( serviceNodes );
-
-    // Got nothing on this DU?
-    if( jarNodes.size() == 0 && serviceNodes.size() == 0 )
-    {
- throw new DeploymentException( "The " + unitJarFile.getName() + " deployable unit contains no jars or services" );
-    }
-
-    // All good. Return the parsed descriptor.
-    return deployableUnitDescriptor;
-  }
+//  /**
+// * Method for parsing a Deployable Unit descriptor. Gotten from DeployableUnitDeployer.
+//   */
+// private DeployableUnitDescriptorImpl parseDUDescriptor( JarFile unitJarFile ) throws DeploymentException
+//  {
+//    // Get the deployable unit descriptor entry
+// JarEntry duXmlEntry = unitJarFile.getJarEntry( "META-INF/deployable-unit.xml" );
+//
+//    // Don't have one? Go away!
+//    if( duXmlEntry == null )
+// throw new DeploymentException( "No DeployableUnitDeploymentDescriptor descriptor (META-INF/deployable-unit.xml) was found in deployable unit" + unitJarFile.getName() );
+//
+//    // The Document
+//    Document doc = null;
+//
+//    InputStream is = null;
+//
+//    try
+//    {
+//      // Get the InputStream
+//      is = unitJarFile.getInputStream( duXmlEntry );
+//
+//      // Parse the descriptor
+//      doc = XMLUtils.parseDocument( is, false );
+//    }
+//    catch ( IOException ex )
+//    {
+// throw new DeploymentException( "Failed to extract the DU depl " + "descriptor from " + unitJarFile.getName() );
+//    }
+//    finally
+//    {
+//      // Clean up!
+//      if( is != null )
+//      {
+//        try
+//        {
+//          is.close();
+//        }
+//        catch ( IOException ignore )
+//        {
+//        }
+//        finally
+//        {
+//          is = null;
+//        }
+//      }
+//    }
+//
+//    Element duNode = doc.getDocumentElement();
+// DeployableUnitDescriptorImpl deployableUnitDescriptor = new DeployableUnitDescriptorImpl( unitJarFile.getName(), new Date() ); // getDescriptor();
+//
+//    try
+//    {
+//      // Get the description, if any.
+// String description = XMLUtils.getElementTextValue( duNode, XMLConstants.DESCRIPTION_ND );
+//
+//      // Store it.
+//      if( description != null )
+//        deployableUnitDescriptor.setDescription( description );
+//    }
+//    catch ( Exception ex )
+//    {
+//      throw new DeploymentException( ex.getMessage() );
+//    }
+//
+//    // Get a list of the jars in the deployable unit.
+// List<Element> jarNodes = XMLUtils.getAllChildElements( duNode, XMLConstants.JAR_ND );
+//    deployableUnitDescriptor.setJarNodes( jarNodes );
+//
+//    // Same for the services
+// List<Element> serviceNodes = XMLUtils.getAllChildElements( duNode, XMLConstants.SERVICE_XML_ND );
+//    deployableUnitDescriptor.setServiceNodes( serviceNodes );
+//
+//    // Got nothing on this DU?
+//    if( jarNodes.size() == 0 && serviceNodes.size() == 0 )
+//    {
+// throw new DeploymentException( "The " + unitJarFile.getName() + " deployable unit contains no jars or services" );
+//    }
+//
+//    // All good. Return the parsed descriptor.
+//    return deployableUnitDescriptor;
+//  }

   private class UndeploymentTask extends TimerTask
   {

Modified: trunk/servers/jain-slee/core/jmx-property-editors/src/main/java/org/mobicents/slee/container/management/jmx/editors/ComponentIDPropertyEditor.java
==============================================================================
--- trunk/servers/jain-slee/core/jmx-property-editors/src/main/java/org/mobicents/slee/container/management/jmx/editors/ComponentIDPropertyEditor.java (original) +++ trunk/servers/jain-slee/core/jmx-property-editors/src/main/java/org/mobicents/slee/container/management/jmx/editors/ComponentIDPropertyEditor.java Tue Mar 17 09:52:15 2009
@@ -1,5 +1,6 @@
 package org.mobicents.slee.container.management.jmx.editors;

+import javax.slee.ComponentID;
 import javax.slee.EventTypeID;
 import javax.slee.SbbID;
 import javax.slee.ServiceID;
@@ -58,5 +59,25 @@
         } catch (Throwable ex) {
             throw new IllegalArgumentException(ex.getMessage(),ex);
         }
+    }
+
+    public String getAsText()
+    {
+      String sep = "#";
+
+      Object o = getValue();
+      if(o instanceof ComponentID)
+      {
+        ComponentID componentId = (ComponentID)o;
+
+        String className = o.getClass().getName();
+ String componentType = className.substring(className.lastIndexOf('.') + 1);
+
+ return componentType + "[" + componentId.getName() + sep + componentId.getVendor() + sep + componentId.getVersion() + "]";
+      }
+      else
+      {
+        return ("" + getValue());
+      }
     }
 }

Reply via email to