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

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Jan 18 07:04:09 EST 2007


Author: scott.stark at jboss.org
Date: 2007-01-18 07:04:09 -0500 (Thu, 18 Jan 2007)
New Revision: 59760

Added:
   trunk/profileservice/src/main/org/jboss/profileservice/management/builders/DomDataSourceManagedObject.java
   trunk/profileservice/src/main/org/jboss/profileservice/management/builders/DomFields.java
   trunk/profileservice/src/main/org/jboss/profileservice/management/messages.properties
   trunk/profileservice/src/main/org/jboss/profileservice/management/templates/DsXmlDataSourceTemplateInfo.java
Removed:
   trunk/profileservice/build.log
Modified:
   trunk/profileservice/.classpath
   trunk/profileservice/build.xml
   trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java
   trunk/profileservice/src/main/org/jboss/profileservice/management/builders/ConnectionFactoryDeployerManagedObjectBuilder.java
   trunk/profileservice/src/main/org/jboss/profileservice/management/plugins/BasicDeploymentTemplateInfo.java
Log:
Get the template to apply updated properties

Modified: trunk/profileservice/.classpath
===================================================================
--- trunk/profileservice/.classpath	2007-01-18 12:02:10 UTC (rev 59759)
+++ trunk/profileservice/.classpath	2007-01-18 12:04:09 UTC (rev 59760)
@@ -24,5 +24,6 @@
 	<classpathentry combineaccessrules="false" kind="src" path="/aspects"/>
 	<classpathentry combineaccessrules="false" kind="src" path="/system"/>
 	<classpathentry combineaccessrules="false" kind="src" path="/system-jmx"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/microcontainer/lib/jboss-metatype.jar" sourcepath="/thirdparty/jboss/microcontainer/lib/jboss-metatype-src.zip"/>
 	<classpathentry kind="output" path="output/eclipse-classes"/>
 </classpath>

Deleted: trunk/profileservice/build.log
===================================================================
--- trunk/profileservice/build.log	2007-01-18 12:02:10 UTC (rev 59759)
+++ trunk/profileservice/build.log	2007-01-18 12:04:09 UTC (rev 59760)
@@ -1,25 +0,0 @@
-
-configure:
-Overriding previous definition of reference to jboss.test.classpath
-
-_default:task-init:
-
-init:
-
-_buildmagic:build-bypass-checker:
-
-_buildmagic:build-bypass-notice:
-     [echo] 
-Build disabled because module is already built. To force the module
-to build define build-bypass.disabled=true.
-  
-
-_buildmagic:build-bypass-check:
-
-jars:
-
-most:
-
-main:
-
-BUILD SUCCESSFUL

Modified: trunk/profileservice/build.xml
===================================================================
--- trunk/profileservice/build.xml	2007-01-18 12:02:10 UTC (rev 59759)
+++ trunk/profileservice/build.xml	2007-01-18 12:04:09 UTC (rev 59760)
@@ -128,6 +128,10 @@
     <!-- -->
     <jar jarfile="${build.lib}/jboss-profileservice.jar" manifest="${build.etc}/default.mf">
       <fileset dir="${build.classes}" />
+      <!-- Get the property-files -->
+      <fileset dir="${source.java}">
+        <include name="org/jboss/**/*.properties"/>
+      </fileset>
       <fileset dir="${build.resources}">
         <include name="dtd/**"/>
       </fileset>

Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java	2007-01-18 12:02:10 UTC (rev 59759)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java	2007-01-18 12:04:09 UTC (rev 59760)
@@ -24,10 +24,13 @@
 
 import java.io.IOException;
 import java.io.Serializable;
+import java.text.MessageFormat;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.Locale;
 import java.util.Map;
+import java.util.ResourceBundle;
 import java.util.Set;
 
 import org.jboss.deployers.plugins.structure.AbstractDeploymentContext;
@@ -41,6 +44,7 @@
 import org.jboss.deployers.spi.management.DeploymentTemplateInfo;
 import org.jboss.deployers.spi.management.ManagementView;
 import org.jboss.deployers.spi.structure.DeploymentContext;
+import org.jboss.logging.Logger;
 import org.jboss.managed.api.ManagedObject;
 import org.jboss.managed.api.ManagedProperty;
 import org.jboss.profileservice.spi.NoSuchDeploymentException;
@@ -49,6 +53,7 @@
 import org.jboss.profileservice.spi.NoSuchProfileException;
 import org.jboss.profileservice.spi.ProfileService;
 import org.jboss.profileservice.spi.Profile.DeploymentPhase;
+import org.jboss.util.graph.Graph;
 import org.jboss.virtual.VirtualFile;
 
 /**
@@ -58,10 +63,29 @@
 public class ManagementViewImpl
    implements ManagementView
 {
+   private static Logger log = Logger.getLogger(ManagementViewImpl.class);
+   private static final String BUNDLE_NAME = "org.jboss.profileservice.management.messages"; //$NON-NLS-1$
+
+   /** */
    private ProfileService ps;
+   /** */
    private MainDeployer mainDeployer;
+   /** */
    private HashMap<String, DeploymentTemplate> templates = new HashMap<String, DeploymentTemplate>();
+   /** */
+   private ResourceBundle i18n;
+   /** */
+   private Locale currentLocale;
+   /** */
+   private MessageFormat formatter = new MessageFormat("");
 
+   public ManagementViewImpl()
+   {
+      currentLocale = Locale.getDefault();
+      formatter.setLocale(currentLocale);
+      i18n = ResourceBundle.getBundle(BUNDLE_NAME, currentLocale);
+   }
+
    public ProfileService getProfileService()
    {
       return ps;
@@ -69,6 +93,7 @@
    public void setProfileService(ProfileService ps)
    {
       this.ps = ps;
+      log.debug("setProfileService: "+ps);
    }
 
    public MainDeployer getMainDeployer()
@@ -78,9 +103,29 @@
    public void setMainDeployer(MainDeployer mainDeployer)
    {
       this.mainDeployer = mainDeployer;
+      log.debug("setMainDeployer: "+mainDeployer);
    }
 
    /**
+    * Get the names of the deployment in the profile.
+    * @param key - the profile containing the deployment
+    */
+   public Set<String> getDeploymentNames(ProfileKey key)
+      throws NoSuchProfileException
+   {
+      Profile profile = ps.getProfile(key);
+      if( profile == null )
+      {
+         formatter.applyPattern(i18n.getString("ManagementView.NoSuchProfileException")); //$NON-NLS-1$
+         Object[] args = {key};
+         String msg = formatter.format(args);
+         throw new NoSuchProfileException(msg);
+      }
+      Set<String> names = profile.getDeploymentNames();
+      return names;   
+   }
+
+   /**
     * Get the names of the deployment in the profile that have the
     * given deployment type.
     * @param key - the profile containing the deployment
@@ -90,8 +135,13 @@
       throws NoSuchProfileException
    {
       Profile profile = ps.getProfile(key);
-      if(ps == null )
-         throw new NoSuchProfileException("No profile for key: "+key);
+      if( profile == null )
+      {
+         formatter.applyPattern(i18n.getString("ManagementView.NoSuchProfileException")); //$NON-NLS-1$
+         Object[] args = {key};
+         String msg = formatter.format(args);
+         throw new NoSuchProfileException(msg);
+      }
       Set<String> names = profile.getDeploymentNamesForType(type);
       return names;
    }
@@ -104,20 +154,30 @@
    public void addTemplate(DeploymentTemplate template)
    {
       this.templates.put(template.getInfo().getName(), template);
+      log.debug("addTemplate: "+template);
    }
    public void removeTemplate(DeploymentTemplate template)
    {
       this.templates.remove(template.getInfo().getName());
+      log.debug("removeTemplate: "+template);
    }
 
-   public ManagedObject getView(ProfileKey key, String deploymentName, DeploymentPhase phase)
+   public Graph<Map<String, ManagedObject>> getView(ProfileKey key, String deploymentName, DeploymentPhase phase)
       throws NoSuchProfileException, NoSuchDeploymentException, Exception
    {
       Profile profile = ps.getProfile(key);
+      if( profile == null )
+      {
+         formatter.applyPattern(i18n.getString("ManagementView.NoSuchProfileException")); //$NON-NLS-1$
+         Object[] args = {key};
+         String msg = formatter.format(args);
+         throw new NoSuchProfileException(msg);
+      }
       DeploymentContext d = profile.getDeployment(deploymentName, phase);
-      mainDeployer.getManagedObjects(deploymentName);
-      // return mo;
-      return null;
+      Graph<Map<String, ManagedObject>> view = mainDeployer.getManagedObjects(deploymentName);
+      if( log.isTraceEnabled() )
+         log.trace("getView, key="+key+", deploymentName="+deploymentName+", phase="+phase+", :"+view);
+      return view;
    }
 
    public void setView(ProfileKey key, String deploymentName, HashMap<String, ManagedProperty> view)
@@ -130,7 +190,13 @@
    {
       DeploymentTemplate template = templates.get(name);
       if( template == null )
-         throw new NoSuchDeploymentException("No template for: "+name);
+      {
+         formatter.applyPattern(i18n.getString("ManagementView.NoSuchTemplate")); //$NON-NLS-1$
+         Object[] args = {name};
+         String msg = formatter.format(args);
+         throw new IllegalStateException(msg);
+      }
+
       DeploymentTemplateInfo info = template.getInfo();
       return info;
    }
@@ -142,15 +208,25 @@
       DeploymentTemplate template = templates.get(info.getName());
       if( template == null )
       {
-         throw new IllegalStateException("Failed to find template for: "+info.getName());
+         formatter.applyPattern(i18n.getString("ManagementView.NoSuchTemplate")); //$NON-NLS-1$
+         Object[] args = {info.getName()};
+         String msg = formatter.format(args);
+         throw new IllegalStateException(msg);
       }
 
       Profile profile = ps.getProfile(key);
       if( profile == null )
-         throw new NoSuchProfileException("No profile for key: "+key);
+      {
+         formatter.applyPattern(i18n.getString("ManagementView.NoSuchProfileException")); //$NON-NLS-1$
+         Object[] args = {key};
+         String msg = formatter.format(args);
+         throw new NoSuchProfileException(msg);
+      }
 
       // Create a deployment base from the template
       VirtualFile root = profile.getRootFile(phase);
+      if( log.isTraceEnabled() )
+         log.trace("applyTemplate, key="+key+", deploymentBaseName="+deploymentBaseName+", phase="+phase+", info="+info);
       VirtualFile deployment = template.applyTemplate(root, deploymentBaseName, info);
       AbstractDeploymentContext ctx = new AbstractDeploymentContext(deployment);
       profile.addDeployment(ctx, phase);
@@ -161,19 +237,25 @@
       checkIncomplete();
       for (DeploymentContext d : ctxs)
       {
-         profile.updateDeployment(d, DeploymentPhase.BOOTSTRAP);
+         profile.updateDeployment(d, phase);
       }
+
       // Apply the managed properties
       Map<String, ManagedObject> mos = mainDeployer.getManagedObjects(ctx);
-      // Now 
-
-      for(ManagedProperty prop : info.getProperties())
+      if( log.isTraceEnabled() )
+         log.trace("applyTemplate, key="+key+", deploymentBaseName="+deploymentBaseName+", phase="+phase+", :"+mos);
+      for(ManagedProperty prop : info.getProperties().values())
       {
          ManagedObject mo = prop.getManagedObject();
          ManagedObject ctxMO = mos.get(mo.getName());
          ManagedProperty ctxProp = ctxMO.getProperty(prop.getName());
          ctxProp.setValue((Serializable)prop.getValue());
       }
+      log.info("Updated mo: "+mos);
+
+      // Process the updated deployment
+      mainDeployer.process(Deployer.CLASSLOADER_DEPLOYER, Integer.MAX_VALUE);
+      checkIncomplete();      
    }
 
    /**

Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/builders/ConnectionFactoryDeployerManagedObjectBuilder.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/builders/ConnectionFactoryDeployerManagedObjectBuilder.java	2007-01-18 12:02:10 UTC (rev 59759)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/builders/ConnectionFactoryDeployerManagedObjectBuilder.java	2007-01-18 12:04:09 UTC (rev 59760)
@@ -31,10 +31,14 @@
 import org.jboss.deployers.spi.managed.ManagedObjectBuilder;
 import org.jboss.deployers.spi.structure.DeploymentContext;
 import org.jboss.logging.Logger;
+import org.jboss.managed.api.Fields;
 import org.jboss.managed.api.ManagedObject;
 import org.jboss.managed.api.ManagedProperty;
+import org.jboss.managed.plugins.DefaultFieldsImpl;
 import org.jboss.managed.plugins.ManagedObjectImpl;
 import org.jboss.managed.plugins.ManagedPropertyImpl;
+import org.jboss.managed.plugins.advice.WrapperAdvice;
+import org.jboss.metatype.api.types.SimpleMetaType;
 import org.jboss.system.metadata.ServiceDeployment;
 import org.jboss.system.metadata.ServiceMetaData;
 
@@ -55,20 +59,13 @@
       String name = unit.getSimpleName();
       if(name.endsWith("-ds.xml"))
       {
-         // This is just dumping out info to see what we should map...
          Map<String, Object> attachments = unit.getAttachments();
          log.info(name+" attachments: "+attachments);
          ServiceDeployment dsMetaData = unit.getAttachment(ServiceDeployment.class);
-         List<ServiceMetaData> services = dsMetaData.getServices();
-         log.info(name+" services: "+services);
          String attachName = ServiceDeployment.class.getName();
-         HashSet<ManagedProperty> props = new HashSet<ManagedProperty>();
-         ManagedObject mo = new ManagedObjectImpl(attachName, props);
-         /*
-         ManagedProperty config = new ManagedPropertyImpl(mo);
-         props.add(new )
-         map.put(attachName, mo);
-         */
+         ManagedObject mo = new DomDataSourceManagedObject(attachName);
+         ManagedObject wrapMO = WrapperAdvice.wrapManagedObject(mo);
+         map.put(attachName, wrapMO);
       }
    }
 }

Added: trunk/profileservice/src/main/org/jboss/profileservice/management/builders/DomDataSourceManagedObject.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/builders/DomDataSourceManagedObject.java	                        (rev 0)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/builders/DomDataSourceManagedObject.java	2007-01-18 12:04:09 UTC (rev 59760)
@@ -0,0 +1,122 @@
+/*
+ * 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.builders;
+
+import java.util.Set;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.jboss.managed.api.Fields;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.managed.plugins.ManagedObjectImpl;
+import org.jboss.managed.plugins.ManagedPropertyImpl;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.util.xml.DOMWriter;
+import org.w3c.dom.DOMImplementation;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class DomDataSourceManagedObject extends ManagedObjectImpl
+{
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 1L;
+
+   /** The document */
+   private Document document;
+
+   /**
+    * MockDataSourceManaged ctor
+    */
+   public DomDataSourceManagedObject(String attachmentName)
+   {
+      super(attachmentName);
+      Element element;
+      try
+      {
+         DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+         DocumentBuilder builder = factory.newDocumentBuilder();
+         DOMImplementation impl = builder.getDOMImplementation();
+         document = impl.createDocument(null, null, null);
+         
+         element = document.createElement("data-source");
+         document.appendChild(element);
+      }
+      catch (RuntimeException e)
+      {
+         throw e;
+      }
+      catch (Exception e)
+      {
+         throw new RuntimeException("Error creating dom", e);
+      }
+      
+      Set<ManagedProperty> properties = getProperties();
+      // The jndi name field info
+      DomFields jndiName = new DomFields(element, "jndi-name");
+      jndiName.setField(Fields.DESCRIPTION, "The jndi name to bind the DataSource under");
+      jndiName.setField(Fields.MANDATORY, Boolean.TRUE);
+      jndiName.setField(Fields.META_TYPE, SimpleMetaType.STRING);
+      // The connection-url field info
+      DomFields connURL = new DomFields(element, "connection-url");
+      jndiName.setField(Fields.DESCRIPTION, "The jdbc url of the DataSource");
+      jndiName.setField(Fields.MANDATORY, Boolean.TRUE);
+      jndiName.setField(Fields.META_TYPE, SimpleMetaType.STRING);
+      // The user field info
+      DomFields user = new DomFields(element, "user-name");
+      jndiName.setField(Fields.DESCRIPTION, "The username for the connection-url");
+      jndiName.setField(Fields.MANDATORY, Boolean.FALSE);
+      jndiName.setField(Fields.META_TYPE, SimpleMetaType.STRING);
+      // The user field info
+      DomFields password = new DomFields(element, "password");
+      jndiName.setField(Fields.DESCRIPTION, "The password for the connection-url");
+      jndiName.setField(Fields.MANDATORY, Boolean.FALSE);
+      jndiName.setField(Fields.META_TYPE, SimpleMetaType.STRING);
+      // The security-domain field info
+      DomFields secDomain = new DomFields(element, "security-domain");
+      jndiName.setField(Fields.DESCRIPTION, "The security-domain used to validate connections");
+      jndiName.setField(Fields.MANDATORY, Boolean.FALSE);
+      jndiName.setField(Fields.META_TYPE, SimpleMetaType.STRING);
+
+      properties.add(new ManagedPropertyImpl(this, jndiName));
+      properties.add(new ManagedPropertyImpl(this, connURL));
+      properties.add(new ManagedPropertyImpl(this, user));
+      properties.add(new ManagedPropertyImpl(this, password));
+      properties.add(new ManagedPropertyImpl(this, secDomain));
+   }
+
+   public String prettyPrint()
+   {
+      return DOMWriter.printNode(document, true);
+   }
+
+   @Override
+   public String toString()
+   {
+      return prettyPrint();
+   }
+   
+}


Property changes on: trunk/profileservice/src/main/org/jboss/profileservice/management/builders/DomDataSourceManagedObject.java
___________________________________________________________________
Name: svn:keywords
   + Id,Revision
Name: svn:eol-style
   + native

Added: trunk/profileservice/src/main/org/jboss/profileservice/management/builders/DomFields.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/builders/DomFields.java	                        (rev 0)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/builders/DomFields.java	2007-01-18 12:04:09 UTC (rev 59760)
@@ -0,0 +1,102 @@
+/*
+ * 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.builders;
+
+import java.io.Serializable;
+
+import org.jboss.managed.api.Fields;
+import org.jboss.managed.plugins.DefaultFieldsImpl;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+public class DomFields extends DefaultFieldsImpl
+{
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 1L;
+
+   /** The datasource element */
+   private Element element; 
+   
+   /**
+    * Create a new DOMFields.
+    *
+    * @param element the data source element
+    * @param elementName the element name
+    */
+   public DomFields(Element element, String elementName)
+   {
+      this.element = element;
+      this.setField(Fields.NAME, elementName);
+   }
+
+   public String getElementName()
+   {
+      return (String) super.getField(Fields.NAME);
+   }
+   public Serializable getField(String name)
+   {
+      if (VALUE.equals(name))
+      {
+         String elementName = getElementName();
+         NodeList nodes = element.getElementsByTagName(elementName);
+         if (nodes.getLength() == 0)
+            return null;
+         else
+         {
+            Element element = (Element) nodes.item(0);
+            return element.getTextContent();
+         }
+      }
+      return super.getField(name);
+   }
+
+   public void setField(String name, Serializable value)
+   {
+      if (VALUE.equals(name))
+      {
+         String string = (String) value;
+         String elementName = getElementName();
+         NodeList nodes = element.getElementsByTagName(elementName);
+         Element childElement = null;
+         if (nodes.getLength() == 0)
+         {
+            if (string == null || string.length() == 0)
+               return;
+            childElement = element.getOwnerDocument().createElement(elementName);
+            element.appendChild(childElement);
+         }
+         else
+         {
+            childElement = (Element) nodes.item(0);
+            if (string == null || string.length() == 0)
+            {
+               element.removeChild(childElement);
+               return;
+            }
+         }
+         childElement.setTextContent(string);
+         return;
+      }
+      super.setField(name, value);
+   }
+
+}


Property changes on: trunk/profileservice/src/main/org/jboss/profileservice/management/builders/DomFields.java
___________________________________________________________________
Name: svn:keywords
   + Id,Revision
Name: svn:eol-style
   + native

Added: trunk/profileservice/src/main/org/jboss/profileservice/management/messages.properties
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/messages.properties	                        (rev 0)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/messages.properties	2007-01-18 12:04:09 UTC (rev 59760)
@@ -0,0 +1,3 @@
+# 
+ManagementView.NoSuchProfileException=Failed to find profile for key: {0}
+ManagementViewImp.NoSuchTemplate=Failed to find template for: {0}

Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/plugins/BasicDeploymentTemplateInfo.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/plugins/BasicDeploymentTemplateInfo.java	2007-01-18 12:02:10 UTC (rev 59759)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/plugins/BasicDeploymentTemplateInfo.java	2007-01-18 12:04:09 UTC (rev 59760)
@@ -22,24 +22,31 @@
 package org.jboss.profileservice.management.plugins;
 
 import java.io.Serializable;
-import java.util.Set;
+import java.util.HashMap;
+import java.util.Map;
 
 import org.jboss.deployers.spi.management.DeploymentTemplateInfo;
 import org.jboss.managed.api.ManagedProperty;
 
+/**
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
 public class BasicDeploymentTemplateInfo
    implements DeploymentTemplateInfo, Serializable
 {
    private static final long serialVersionUID = 1;
    private String name;
    private String description;
-   private Set<ManagedProperty> properties;
+   private Map<String, ManagedProperty> properties;
 
    public BasicDeploymentTemplateInfo(String name, String description)
    {
-      this(name, description, null);
+      this(name, description, new HashMap<String, ManagedProperty>());
    }
-   public BasicDeploymentTemplateInfo(String name, String description, Set<ManagedProperty> properties)
+   public BasicDeploymentTemplateInfo(String name, String description,
+         HashMap<String, ManagedProperty> properties)
    {
       this.name = name;
       this.description = description;
@@ -56,17 +63,17 @@
       return name;
    }
 
-   public Set<ManagedProperty> getProperties()
+   public Map<String, ManagedProperty> getProperties()
    {
       return properties;
    }
-   public void setProperties(Set<ManagedProperty> properties)
+   public void setProperties(Map<String, ManagedProperty> properties)
    {
       this.properties = properties;
    }
    public void addProperty(ManagedProperty property)
    {
-      this.properties.add(property);
+      this.properties.put(property.getName(), property);
    }
    
 }

Added: trunk/profileservice/src/main/org/jboss/profileservice/management/templates/DsXmlDataSourceTemplateInfo.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/templates/DsXmlDataSourceTemplateInfo.java	                        (rev 0)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/templates/DsXmlDataSourceTemplateInfo.java	2007-01-18 12:04:09 UTC (rev 59760)
@@ -0,0 +1,87 @@
+/*
+ * 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 org.jboss.managed.plugins.DefaultFieldsImpl;
+import org.jboss.managed.plugins.ManagedObjectImpl;
+import org.jboss.managed.plugins.ManagedPropertyImpl;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.profileservice.management.plugins.BasicDeploymentTemplateInfo;
+import org.jboss.system.metadata.ServiceDeployment;
+
+/**
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class DsXmlDataSourceTemplateInfo extends BasicDeploymentTemplateInfo
+{
+   private static final long serialVersionUID = 1;
+
+   public DsXmlDataSourceTemplateInfo(String name, String description)
+   {
+      super(name, description);
+
+      ManagedObjectImpl mo = new ManagedObjectImpl(ServiceDeployment.class.getName());
+      // The jndi name field info
+      DefaultFieldsImpl f0 = new DefaultFieldsImpl();
+      f0.setName("jndi-name");
+      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();
+      f1.setName("connection-url");
+      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();
+      f2.setName("user-name");
+      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();
+      f3.setName("password");
+      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();
+      f4.setName("security-domain");
+      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);
+   }
+
+}


Property changes on: trunk/profileservice/src/main/org/jboss/profileservice/management/templates/DsXmlDataSourceTemplateInfo.java
___________________________________________________________________
Name: svn:keywords
   + Id,Revision
Name: svn:eol-style
   + native




More information about the jboss-cvs-commits mailing list