[jboss-cvs] JBossAS SVN: r86410 - in branches/Branch_5_x: profileservice/src/main/org/jboss/profileservice/management and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Mar 27 05:05:25 EDT 2009


Author: emuckenhuber
Date: 2009-03-27 05:05:25 -0400 (Fri, 27 Mar 2009)
New Revision: 86410

Removed:
   branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/templates/DsXmlDataSourceTemplate.java
   branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/templates/DsXmlDataSourceTemplateInfo.java
Modified:
   branches/Branch_5_x/messaging/src/etc/deploy/common/messaging-jboss-beans.xml
   branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java
   branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/templates/JmsDestinationTemplate.java
   branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/templates/JmsDestinationTemplateInfo.java
Log:
[JBAS-6683] update jms destination deployment templates

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

Modified: branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java
===================================================================
--- branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java	2009-03-27 08:56:28 UTC (rev 86409)
+++ branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java	2009-03-27 09:05:25 UTC (rev 86410)
@@ -176,7 +176,7 @@
       stateMappings.put("Installed", RunState.RUNNING.name());
    }
    
-   public synchronized void load()
+   public void load()
    {
       // If the profile is not modified do nothing
       if(isReload() == false)
@@ -996,6 +996,9 @@
    public void applyTemplate(String deploymentBaseName, DeploymentTemplateInfo info)
       throws Exception
    {
+      if(info == null)
+         throw new IllegalArgumentException("Null template info.");
+      
       DeploymentTemplate template = templates.get(info.getName());
       if( template == null )
       {
@@ -1007,7 +1010,7 @@
 
       // Create a deployment base from the template
       if( log.isTraceEnabled() )
-         log.trace("applyTemplate, deploymentBaseName="+deploymentBaseName +", info="+info);
+         log.trace("applyTemplate, deploymentBaseName="+deploymentBaseName +", info="+info);      
       
       // Create, distribute and start a deployment template
       String deploymentName = super.applyTemplate(template, deploymentBaseName, info);

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

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

Modified: branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/templates/JmsDestinationTemplate.java
===================================================================
--- branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/templates/JmsDestinationTemplate.java	2009-03-27 08:56:28 UTC (rev 86409)
+++ branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/templates/JmsDestinationTemplate.java	2009-03-27 09:05:25 UTC (rev 86410)
@@ -48,6 +48,7 @@
  * A template for creating jms destinations
  * 
  * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
  * @version <tt>$Revision$</tt>
  */
 public class JmsDestinationTemplate
@@ -104,24 +105,33 @@
    private void writeTemplate(File dsXml, DeploymentTemplateInfo info)
       throws Exception
    {
+      if(info == null)
+         throw new IllegalArgumentException("Null template info.");
+      if(info.getProperties() == null)
+         throw new IllegalArgumentException("Null template info.");
+      
       JmsDestinationTemplateInfo destinationInfo = (JmsDestinationTemplateInfo)info;
       String destinationType = destinationInfo.getDestinationType();
 
       JmsDestinationMetaData destination = new JmsDestinationMetaData();
-      String jndiName = "" + getProperty(info, "JNDIName");
-      if("queue".equals(destinationType))
+      String jndiName = (String) getProperty(info, "JNDIName");
+      
+      if(jndiName == null)
+         throw new IllegalStateException("Null jndi name.");
+      
+      if("QueueTemplate".equals(destinationType))
       {
          destination.className = "org.jboss.jms.server.destination.QueueService";
-         destination.annotation =
-            "@org.jboss.system.deployers.managed.ManagementObjectClass(code=org.jboss.jms.server.destination.QueueServiceMO)";
+//         destination.annotation =
+//            "@org.jboss.system.deployers.managed.ManagementObjectClass(code=org.jboss.jms.server.destination.QueueServiceMO)";
          destination.xmbeanDd = "xmdesc/Queue-xmbean.xml";
          destination.jmxName = "jboss.messaging.destination:service=Queue,name=" + jndiName;
       }
-      else if("topic".equals(destinationType))
+      else if("TopicTemplate".equals(destinationType))
       {
          destination.className = "org.jboss.jms.server.destination.TopicService";
-         destination.annotation =
-            "@org.jboss.system.deployers.managed.ManagementObjectClass(code=org.jboss.jms.server.destination.TopicServiceMO)";
+//         destination.annotation =
+//            "@org.jboss.system.deployers.managed.ManagementObjectClass(code=org.jboss.jms.server.destination.TopicServiceMO)";
          destination.xmbeanDd = "xmdesc/Topic-xmbean.xml";
          destination.jmxName = "jboss.messaging.destination:service=Topic,name=" + jndiName;
       }
@@ -131,9 +141,22 @@
       }
       List<JmsAttributeMetaData> attributes = new ArrayList<JmsAttributeMetaData>();
 
-      JmsAttributeMetaData jndiNameMD = new JmsAttributeMetaData("JNDIName", jndiName);
-      destination.attribute = attributes;
-      attributes.add(jndiNameMD);
+      Map<String, ManagedProperty> properties = info.getProperties();
+      for(ManagedProperty p : properties.values())
+      {
+         MetaValue v = p.getValue();
+         if(v == null)
+            continue;
+         
+         if(v.getMetaType().isSimple())
+         {
+            JmsAttributeMetaData jndiNameMD = new JmsAttributeMetaData(p.getName(), "" + ((SimpleValue)v).getValue());
+            destination.attribute = attributes;
+            attributes.add(jndiNameMD);            
+         }
+         else
+            throw new IllegalArgumentException("Not handled value: " + v);
+      }
 
       List<JmsDependencyMetaData> depends = new ArrayList<JmsDependencyMetaData>();
       destination.depends = depends;
@@ -143,7 +166,7 @@
       JmsDestinationDeployment deployment = new JmsDestinationDeployment();
       deployment.destination = destination;
 
-      Class[] classes = {JmsDestinationDeployment.class};
+      Class<?>[] classes = {JmsDestinationDeployment.class};
       JAXBContext context = JAXBContext.newInstance(classes);
       Marshaller marshaller = context.createMarshaller();
       marshaller.setProperty("jaxb.formatted.output", Boolean.TRUE);

Modified: branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/templates/JmsDestinationTemplateInfo.java
===================================================================
--- branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/templates/JmsDestinationTemplateInfo.java	2009-03-27 08:56:28 UTC (rev 86409)
+++ branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/templates/JmsDestinationTemplateInfo.java	2009-03-27 09:05:25 UTC (rev 86410)
@@ -21,40 +21,41 @@
  */
 package org.jboss.profileservice.management.templates;
 
-import java.lang.annotation.Annotation;
-import java.lang.reflect.UndeclaredThrowableException;
-import java.util.Collections;
-import java.util.HashMap;
 import java.util.Map;
 
-import org.jboss.annotation.factory.AnnotationProxy;
 import org.jboss.managed.api.Fields;
-import org.jboss.managed.api.annotation.ManagementObjectID;
+import org.jboss.managed.api.ManagedProperty;
 import org.jboss.managed.plugins.BasicDeploymentTemplateInfo;
-import org.jboss.managed.plugins.DefaultFieldsImpl;
-import org.jboss.managed.plugins.ManagedObjectImpl;
 import org.jboss.managed.plugins.ManagedPropertyImpl;
-import org.jboss.metatype.api.types.MetaType;
-import org.jboss.metatype.api.types.SimpleMetaType;
-import org.jboss.metatype.api.values.MetaValue;
 
 /**
  * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
  * @version <tt>$Revision$</tt>
  */
 public class JmsDestinationTemplateInfo extends BasicDeploymentTemplateInfo
 {
    private static final long serialVersionUID = 1;
-   private String destinationType = "queue";
-
-   public JmsDestinationTemplateInfo(String name, String description, String destinationType)
+   private String destinationType = "QueueTemplate";
+   
+   protected static String checkNullName(String name)
    {
-      super(name, description);
-      this.destinationType = destinationType;
+      if(name == null)
+         throw new IllegalArgumentException("Null name.");
+      return name;
+   }
+   
+   public JmsDestinationTemplateInfo(String name, String description, Map<String, ManagedProperty> arg2)
+   {
+      super(checkNullName(name), description, arg2);      
       super.setRootManagedPropertyName("services");
    }
 
-
+   public void setDestinationType(String destinationType)
+   {
+      this.destinationType = destinationType;
+   }
+   
    public String getDestinationType()
    {
       return destinationType;
@@ -68,7 +69,8 @@
    @Override
    public JmsDestinationTemplateInfo copy()
    {
-      JmsDestinationTemplateInfo copy = new JmsDestinationTemplateInfo(getName(), getDescription(), destinationType);
+      JmsDestinationTemplateInfo copy = new JmsDestinationTemplateInfo(getName(), getDescription(), getProperties());
+      copy.setDestinationType(getDestinationType());
       super.copy(copy);
       copy.populate();
       return copy;
@@ -76,74 +78,18 @@
 
    private void populate()
    {
-      ManagedObjectImpl mo;
-      if("queue".equals(destinationType))
-         mo = new ManagedObjectImpl("org.jboss.jms.server.destination.QueueServiceMO");
-      else if("topic".equals(destinationType))
-         mo = new ManagedObjectImpl("org.jboss.jms.server.destination.TopicServiceMO");
-      else
-         throw new IllegalStateException("Unexpected destination type: " + destinationType);
-
-      addManagedProperty("name", "The destination name", true, false, SimpleMetaType.STRING, mo);
-      addManagedProperty("JNDIName", "The destination's JNDI name", false, true, SimpleMetaType.STRING, mo);
-   }
-
-   private void addManagedProperty(String fieldName,
-                                   String fieldDescr,
-                                   boolean mandatory,
-                                   boolean isID,
-                                   MetaType metaType,
-                                   ManagedObjectImpl mo)
-   {
-      
-      addManagedProperty(fieldName, fieldDescr, mandatory, isID, metaType, null, mo);
-   }
-
-   private void addManagedProperty(String fieldName,
-                                   String fieldDescr,
-                                   boolean mandatory,
-                                   boolean isID,
-                                   MetaType metaType,
-                                   MetaValue value,
-                                   ManagedObjectImpl mo)
-   {
-      DefaultFieldsImpl fields = new DefaultFieldsImpl();
-      setFieldName(fieldName, fields);
-      fields.setDescription(fieldDescr);
-      fields.setMandatory(mandatory);
-      fields.setMetaType(metaType);
-      ManagedPropertyImpl mp = new ManagedPropertyImpl(mo, fields);
-      if(isID)
+      // FIXME
+      if(getProperties() == null) return;
+      for(ManagedProperty property : getProperties().values())
       {
-         Map<String, Annotation> annotations = new HashMap<String, Annotation>();
-         Map<String, Object> idFields = Collections.emptyMap();
-         try
-         {
-            ManagementObjectID id = (ManagementObjectID) AnnotationProxy.createProxy(idFields, ManagementObjectID.class);
-            annotations.put(ManagementObjectID.class.getName(), id);
-            mp.setAnnotations(annotations);
-         }
-         catch(Exception e)
-         {
-            throw new UndeclaredThrowableException(e);
-         }
+         // Create a new (non-writethrough) managed property
+         Fields f = property.getFields();
+         
+         ManagedPropertyImpl newProperty = new ManagedPropertyImpl(f);
+         
+         // Override
+         addProperty(newProperty);
       }
-
-      super.addProperty(mp);
-      if(value != null)
-         mp.setValue(value);
    }
 
-   protected void setFieldName(String name, Fields f)
-   {
-      f.setField(Fields.NAME, name);
-/*
-      if( propertyNameMappings != null )
-      {
-         String mappedName = propertyNameMappings.get(name);
-         if( mappedName != null )
-            f.setField(Fields.MAPPED_NAME, mappedName);
-      }
-*/
-   }
 }




More information about the jboss-cvs-commits mailing list