[jboss-cvs] JBossAS SVN: r61033 - in trunk/profileservice/src: main/org/jboss/profileservice/management/builders and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Mar 1 15:43:34 EST 2007


Author: scott.stark at jboss.org
Date: 2007-03-01 15:43:34 -0500 (Thu, 01 Mar 2007)
New Revision: 61033

Modified:
   trunk/profileservice/src/main/org/jboss/profileservice/management/ComponentTypeOverridesVisitor.java
   trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java
   trunk/profileservice/src/main/org/jboss/profileservice/management/builders/DomDataSourceManagedObject.java
   trunk/profileservice/src/main/org/jboss/profileservice/management/templates/DsXmlDataSourceTemplate.java
   trunk/profileservice/src/main/org/jboss/profileservice/management/templates/DsXmlDataSourceTemplateInfo.java
   trunk/profileservice/src/resources/profileservice-beans.xml
Log:
Update the DataSource handling and jms destination identification

Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/ComponentTypeOverridesVisitor.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/ComponentTypeOverridesVisitor.java	2007-03-01 20:32:23 UTC (rev 61032)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/ComponentTypeOverridesVisitor.java	2007-03-01 20:43:34 UTC (rev 61033)
@@ -110,9 +110,9 @@
          String code = smd.getCode();
          if( code.startsWith("org.jboss.jms.server.destination") )
          {
-            if( code.endsWith(".Queue") )
+            if( code.contains(".Queue") )
                type = new ComponentType("JMSDestination", "Queue");
-            else if( code.endsWith(".Topic") )
+            else if( code.contains(".Topic") )
                type = new ComponentType("JMSDestination", "Topic");
          }
       }

Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java	2007-03-01 20:32:23 UTC (rev 61032)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java	2007-03-01 20:43:34 UTC (rev 61033)
@@ -378,7 +378,9 @@
          String msg = formatter.format(args);
          throw new NoSuchDeploymentException(msg);
       }
-      mainDeployer.removeDeploymentContext(deploymentName);
+      // TODO i18n
+      if( mainDeployer.removeDeploymentContext(ctx.getName()) == false )
+         throw new NoSuchDeploymentException("MainDeployer failed to remove: "+ctx.getName());
    }
 
    /**

Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/builders/DomDataSourceManagedObject.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/builders/DomDataSourceManagedObject.java	2007-03-01 20:32:23 UTC (rev 61032)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/builders/DomDataSourceManagedObject.java	2007-03-01 20:43:34 UTC (rev 61033)
@@ -154,7 +154,11 @@
 
    public String prettyPrint()
    {
-      return DOMWriter.printNode(document, true);
+      StringBuffer tmp = new StringBuffer(super.toString());
+      tmp.append('[');
+      tmp.append(DOMWriter.printNode(document, true));
+      tmp.append(']');
+      return tmp.toString();
    }
 
    @Override

Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/templates/DsXmlDataSourceTemplate.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/templates/DsXmlDataSourceTemplate.java	2007-03-01 20:32:23 UTC (rev 61032)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/templates/DsXmlDataSourceTemplate.java	2007-03-01 20:43:34 UTC (rev 61033)
@@ -69,8 +69,9 @@
    }
 
    /**
-    * Update the ctx with the metadata values that correspond to the
-    * template info values.
+    * There is no update of the ctx by this template since the data model
+    * is driven from the descriptor created by applyTemplate.
+    * 
     * @param ctx - the DeploymentContext to associate metadata to
     * @param values - the managed property values passed to apply.
     */
@@ -78,27 +79,6 @@
          DeploymentTemplateInfo values)
       throws Exception
    {
-      // Add the -ds.xml Document metadata
-      Document document = null;
-      try
-      {
-         DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
-         DocumentBuilder builder = factory.newDocumentBuilder();
-         DOMImplementation impl = builder.getDOMImplementation();
-         document = impl.createDocument(null, null, null);
-         Element element = document.createElement("datasources");
-         document.appendChild(element);
-      }
-      catch (RuntimeException e)
-      {
-         throw e;
-      }
-      catch (Exception e)
-      {
-         throw new RuntimeException("Error creating dom", e);
-      }
-
-      ctx.getPredeterminedManagedObjects().addAttachment(Document.class, document);   
    }
 
    public DeploymentTemplateInfo getInfo()
@@ -115,10 +95,38 @@
    {
       FileWriter fw = new FileWriter(dsXml);
       fw.write("<datasources>\n");
-      fw.write("<local-tx-datasource>\n");
-      fw.write("<jndi-name>DefaultDS</jndi-name>\n");
-      fw.write("<connection-url>jdbc:...</connection-url>\n");
-      fw.write("</local-tx-datasource>\n");
+      Map<String, ManagedProperty> properties = values.getProperties();
+      // Get the datasource-type
+      ManagedProperty dsType = properties.get("datasource-type");
+      if( dsType == null || dsType.getValue() == null )
+         throw new IllegalStateException("Required datasource-type value not found");
+      fw.write('<');
+      fw.write(dsType.getValue().toString());
+      fw.write(">\n");
+
+      // All other properties are simple text child elements
+      for(ManagedProperty p : properties.values())
+      {
+         String tagName = p.getName();
+         if( tagName.equals("datasource-type") )
+            continue;
+         if( p.isMandatory() && p.getValue() == null )
+            throw new IllegalStateException("Required "+tagName+" value not found");
+         fw.write("  <");
+         fw.write(tagName);
+         fw.write('>');
+         Object value = p.getValue();
+         if( value == null )
+            value = "";
+         fw.write(value.toString());
+         fw.write("</");
+         fw.write(tagName);
+         fw.write(">\n");
+      }
+      // close dsType tag
+      fw.write("</");
+      fw.write(dsType.getValue().toString());
+      fw.write(">\n");
       fw.write("</datasources>\n");
       fw.flush();
       fw.close();
@@ -145,6 +153,8 @@
       for(ManagedProperty p : properties.values())
       {
          String tagName = p.getName();
+         if( tagName.equals("datasource-type") )
+            continue;
          if( p.isMandatory() && p.getValue() == null )
             throw new IllegalStateException("Required "+tagName+" value not found");
          Element element = document.createElement(tagName);

Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/templates/DsXmlDataSourceTemplateInfo.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/templates/DsXmlDataSourceTemplateInfo.java	2007-03-01 20:32:23 UTC (rev 61032)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/templates/DsXmlDataSourceTemplateInfo.java	2007-03-01 20:43:34 UTC (rev 61033)
@@ -45,16 +45,18 @@
    private static final long serialVersionUID = 1;
    private Map<String, String> propertyNameMappings;
    private String attachmentName;
+   private String dsTypeAttachmentName;
 
-   public DsXmlDataSourceTemplateInfo(String name, String description)
+   public DsXmlDataSourceTemplateInfo(String name, String description, String attachmentName)
    {
-      this(name, description, ServiceDeployment.class.getName());
+      this(name, description, attachmentName, attachmentName);
    }
    public DsXmlDataSourceTemplateInfo(String name, String description,
-         String attachmentName)
+         String attachmentName, String dsTypeAttachmentName)
    {
       super(name, description);
       this.attachmentName = attachmentName;
+      this.dsTypeAttachmentName = dsTypeAttachmentName;
    }
 
    public Map<String, String> getPropertyNameMappings()
@@ -119,7 +121,7 @@
       super.addProperty(driverClass);
 
       // The type of the datasource
-      ManagedObjectImpl mo2 = new ManagedObjectImpl("FakeConnectionFactoryDeployer.datasource-type");
+      ManagedObjectImpl mo2 = new ManagedObjectImpl(dsTypeAttachmentName);
       DefaultFieldsImpl f21 = new DefaultFieldsImpl();
       setFieldName("datasource-type", f21);
       f21.setDescription("The type of the DataSource");

Modified: trunk/profileservice/src/resources/profileservice-beans.xml
===================================================================
--- trunk/profileservice/src/resources/profileservice-beans.xml	2007-03-01 20:32:23 UTC (rev 61032)
+++ trunk/profileservice/src/resources/profileservice-beans.xml	2007-03-01 20:43:34 UTC (rev 61033)
@@ -102,6 +102,7 @@
             <parameter>FakeDsXmlDataSourceTemplate</parameter>
             <parameter>A template for *-dsf.xml deployments</parameter>
             <parameter>org.jboss.system.metadata.ServiceMetaData</parameter>
+            <parameter>FakeConnectionFactoryDeployer.datasource-type</parameter>
         </constructor>
         <!-- Specify a mapping from service attribute names used by the datasource
             deployment ServiceMetaData to ManagedProperty names. 




More information about the jboss-cvs-commits mailing list