[jboss-cvs] JBossAS SVN: r70420 - in projects/microcontainer/trunk/managed/src: main/org/jboss/managed/plugins/factory and 3 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Mar 5 08:11:44 EST 2008
Author: scott.stark at jboss.org
Date: 2008-03-05 08:11:44 -0500 (Wed, 05 Mar 2008)
New Revision: 70420
Added:
projects/microcontainer/trunk/managed/src/main/org/jboss/managed/plugins/BasicDeploymentTemplateInfo.java
projects/microcontainer/trunk/managed/src/main/org/jboss/managed/plugins/factory/DeploymentTemplateInfoFactory.java
projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/support/template/
projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/support/template/ManagementObjectAll.java
projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/support/template/ManagementObjectExplicit.java
projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/test/DeploymentTemplateInfoUnitTestCase.java
Log:
JBMICROCONT-252, add a DeploymentTemplateInfoFactory class and default DeploymentTemplateInfo implementation
Added: projects/microcontainer/trunk/managed/src/main/org/jboss/managed/plugins/BasicDeploymentTemplateInfo.java
===================================================================
--- projects/microcontainer/trunk/managed/src/main/org/jboss/managed/plugins/BasicDeploymentTemplateInfo.java (rev 0)
+++ projects/microcontainer/trunk/managed/src/main/org/jboss/managed/plugins/BasicDeploymentTemplateInfo.java 2008-03-05 13:11:44 UTC (rev 70420)
@@ -0,0 +1,110 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, 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.managed.plugins;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.managed.api.DeploymentTemplateInfo;
+import org.jboss.managed.api.ManagedProperty;
+
+/**
+ * A simple bean type of implementation of DeploymentTemplateInfo
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class BasicDeploymentTemplateInfo
+ implements DeploymentTemplateInfo, Serializable
+{
+ private static final long serialVersionUID = 1;
+ /** The name the template is registered under with the profile service */
+ private String name;
+ /** The template description */
+ private String description;
+ /** The name of the ManagedProperty in the Map<String, ManagedObject> map
+ * obtained from the mainDeployer.getManagedObjects(VFSDeployment)
+ * for the DeploymentTemplate this info is associated with.
+ */
+ private String rootManagedPropertyName;
+ /**
+ * The template properties
+ */
+ private Map<String, ManagedProperty> properties;
+
+ public BasicDeploymentTemplateInfo(String name, String description)
+ {
+ this(name, description, new HashMap<String, ManagedProperty>());
+ }
+ public BasicDeploymentTemplateInfo(String name, String description,
+ Map<String, ManagedProperty> properties)
+ {
+ this.name = name;
+ this.description = description;
+ this.properties = properties;
+ }
+
+ public String getDescription()
+ {
+ return description;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public String getRootManagedPropertyName()
+ {
+ return rootManagedPropertyName;
+ }
+ public void setRootManagedPropertyName(String rootManagedPropertyName)
+ {
+ this.rootManagedPropertyName = rootManagedPropertyName;
+ }
+
+ public Map<String, ManagedProperty> getProperties()
+ {
+ return properties;
+ }
+ public void setProperties(Map<String, ManagedProperty> properties)
+ {
+ this.properties = properties;
+ }
+ public void addProperty(ManagedProperty property)
+ {
+ this.properties.put(property.getName(), property);
+ }
+
+ public String toString()
+ {
+ StringBuilder tmp = new StringBuilder(super.toString());
+ tmp.append('{');
+ tmp.append(name);
+ tmp.append(",description=");
+ tmp.append(description);
+ tmp.append(",properties=");
+ tmp.append(properties);
+ tmp.append('}');
+ return tmp.toString();
+ }
+}
Property changes on: projects/microcontainer/trunk/managed/src/main/org/jboss/managed/plugins/BasicDeploymentTemplateInfo.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/microcontainer/trunk/managed/src/main/org/jboss/managed/plugins/factory/DeploymentTemplateInfoFactory.java
===================================================================
--- projects/microcontainer/trunk/managed/src/main/org/jboss/managed/plugins/factory/DeploymentTemplateInfoFactory.java (rev 0)
+++ projects/microcontainer/trunk/managed/src/main/org/jboss/managed/plugins/factory/DeploymentTemplateInfoFactory.java 2008-03-05 13:11:44 UTC (rev 70420)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, 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.managed.plugins.factory;
+
+import java.lang.annotation.Annotation;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.managed.api.DeploymentTemplateInfo;
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.managed.api.annotation.ManagementProperty;
+import org.jboss.managed.plugins.BasicDeploymentTemplateInfo;
+
+/**
+ * Creates the DeploymentTemplateInfo from the ManagedObject view.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class DeploymentTemplateInfoFactory
+{
+ /**
+ * Create a DeploymentTemplateInfo from the ManagedObject view. This is
+ * based on locating the ManagedPropertys with a ManagementProperty
+ * annotation with a includeInTemplate=true field.
+ * @param mo - the ManagedObject for the deployment template
+ * @param name - the name of the deployment template
+ * @param description - a description of the deployment template
+ * @return a DeploymentTemplateInfo containing the template properties.
+ */
+ public DeploymentTemplateInfo createTemplateInfo(ManagedObject mo, String name,
+ String description)
+ {
+ Map<String, ManagedProperty> infoProps = new HashMap<String, ManagedProperty>();
+ Map<String, ManagedProperty> props = mo.getProperties();
+ if(props != null)
+ {
+ for(ManagedProperty prop : props.values())
+ {
+ Map<String, Annotation> pannotations = prop.getAnnotations();
+ if(pannotations != null)
+ {
+ ManagementProperty mp = (ManagementProperty) pannotations.get(ManagementProperty.class.getName());
+ if(mp != null && mp.includeInTemplate())
+ infoProps.put(prop.getName(), prop);
+ }
+ }
+ }
+ DeploymentTemplateInfo info = new BasicDeploymentTemplateInfo(name, description, infoProps);
+ return info;
+ }
+}
Property changes on: projects/microcontainer/trunk/managed/src/main/org/jboss/managed/plugins/factory/DeploymentTemplateInfoFactory.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/support/template/ManagementObjectAll.java
===================================================================
--- projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/support/template/ManagementObjectAll.java (rev 0)
+++ projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/support/template/ManagementObjectAll.java 2008-03-05 13:11:44 UTC (rev 70420)
@@ -0,0 +1,60 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2007, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.managed.factory.support.template;
+
+import java.io.Serializable;
+
+import org.jboss.managed.api.annotation.ManagementObject;
+import org.jboss.managed.api.annotation.ManagementProperties;
+
+/**
+ * ManagementObjectAll.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision$
+ */
+ at ManagementObject(properties=ManagementProperties.ALL)
+public class ManagementObjectAll implements Serializable
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -1L;
+
+ /**
+ * Get property 1
+ *
+ * @return null
+ */
+ public String getProperty1()
+ {
+ return null;
+ }
+
+ /**
+ * Get property 2
+ *
+ * @return null
+ */
+ public String getProperty2()
+ {
+ return null;
+ }
+}
Property changes on: projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/support/template/ManagementObjectAll.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/support/template/ManagementObjectExplicit.java
===================================================================
--- projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/support/template/ManagementObjectExplicit.java (rev 0)
+++ projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/support/template/ManagementObjectExplicit.java 2008-03-05 13:11:44 UTC (rev 70420)
@@ -0,0 +1,62 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2007, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.managed.factory.support.template;
+
+import java.io.Serializable;
+
+import org.jboss.managed.api.annotation.ManagementObject;
+import org.jboss.managed.api.annotation.ManagementProperties;
+import org.jboss.managed.api.annotation.ManagementProperty;
+
+/**
+ * Test explicit properties.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+ at ManagementObject(properties=ManagementProperties.EXPLICIT)
+public class ManagementObjectExplicit implements Serializable
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -1L;
+
+ /**
+ * Get property 1
+ *
+ * @return null
+ */
+ @ManagementProperty(includeInTemplate=true)
+ public String getProperty1()
+ {
+ return null;
+ }
+
+ /**
+ * Get property 2
+ *
+ * @return null
+ */
+ public String getProperty2()
+ {
+ return null;
+ }
+}
Property changes on: projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/support/template/ManagementObjectExplicit.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/test/DeploymentTemplateInfoUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/test/DeploymentTemplateInfoUnitTestCase.java (rev 0)
+++ projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/test/DeploymentTemplateInfoUnitTestCase.java 2008-03-05 13:11:44 UTC (rev 70420)
@@ -0,0 +1,79 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2007, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.managed.factory.test;
+
+import junit.framework.Test;
+
+import org.jboss.managed.api.DeploymentTemplateInfo;
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.plugins.factory.DeploymentTemplateInfoFactory;
+import org.jboss.test.managed.factory.AbstractManagedObjectFactoryTest;
+import org.jboss.test.managed.factory.support.ManagementObjectAll;
+import org.jboss.test.managed.factory.support.template.ManagementObjectExplicit;
+
+
+/**
+ * DeploymentTemplateInfo factory tests.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class DeploymentTemplateInfoUnitTestCase extends AbstractManagedObjectFactoryTest
+{
+ /**
+ * Create a testsuite for this test
+ *
+ * @return the testsuite
+ */
+ public static Test suite()
+ {
+ return suite(DeploymentTemplateInfoUnitTestCase.class);
+ }
+
+ /**
+ * Create a new DeploymentTemplateInfoUnitTestCase.
+ *
+ * @param name the test name
+ */
+ public DeploymentTemplateInfoUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Test Explicit properties included
+ */
+ public void testExplicit()
+ {
+ ManagedObject managedObject = createManagedObject(ManagementObjectExplicit.class);
+ checkManagedObjectDefaults(ManagementObjectExplicit.class, managedObject);
+ checkManagedProperties(managedObject, "property1");
+ DeploymentTemplateInfoFactory factory = new DeploymentTemplateInfoFactory();
+ DeploymentTemplateInfo info = factory.createTemplateInfo(managedObject, "testExplicit", "testExplicit");
+ log.info(info);
+ assertEquals("testExplicit", info.getName());
+ assertEquals("testExplicit", info.getDescription());
+ assertTrue("property1 is in template info", info.getProperties().containsKey("property1"));
+ }
+
+
+}
\ No newline at end of file
Property changes on: projects/microcontainer/trunk/managed/src/tests/org/jboss/test/managed/factory/test/DeploymentTemplateInfoUnitTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
More information about the jboss-cvs-commits
mailing list