[jboss-cvs] JBossAS SVN: r86659 - in branches/Branch_5_x: profileservice/src/main/org/jboss/profileservice/management/templates and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Apr 2 07:39:38 EDT 2009
Author: emuckenhuber
Date: 2009-04-02 07:39:37 -0400 (Thu, 02 Apr 2009)
New Revision: 86659
Modified:
branches/Branch_5_x/messaging/src/main/org/jboss/jms/server/destination/QueueServiceMO.java
branches/Branch_5_x/messaging/src/main/org/jboss/jms/server/destination/TopicServiceMO.java
branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/templates/JmsDestinationTemplate.java
branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/template/test/JMSDestinationTemplateUnitTestCase.java
Log:
[JBAS-6721], [JBAS-6716] update jms destination MOs and template
Modified: branches/Branch_5_x/messaging/src/main/org/jboss/jms/server/destination/QueueServiceMO.java
===================================================================
--- branches/Branch_5_x/messaging/src/main/org/jboss/jms/server/destination/QueueServiceMO.java 2009-04-02 11:13:30 UTC (rev 86658)
+++ branches/Branch_5_x/messaging/src/main/org/jboss/jms/server/destination/QueueServiceMO.java 2009-04-02 11:39:37 UTC (rev 86659)
@@ -58,13 +58,14 @@
// Management Properties
- @ManagementProperty(use={ViewUse.RUNTIME},
- description="The destination name")
+ @ManagementProperty(use={ViewUse.STATISTIC},
+ description="The destination name",
+ includeInTemplate=true, mandatory=true)
public String getName() { return null; }
@ManagementProperty(use={ViewUse.CONFIGURATION},
description="The destination's JNDI name",
- includeInTemplate=true)
+ mandatory=true, includeInTemplate=true)
@ManagementObjectID(type="Queue")
public String getJNDIName() { return null; }
public void setJNDIName(String arg0) throws Exception { }
@@ -98,11 +99,12 @@
@ManagementProperty(use={ViewUse.CONFIGURATION},
description="The destination's security configuration",
- includeInTemplate=true)
+ includeInTemplate=true)
+ @MetaMapping(SecurityConfigMapper.class)
public Element getSecurityConfig() { return null; }
public void setSecurityConfig(Element arg0) { }
- @ManagementProperty(use={ViewUse.RUNTIME},
+ @ManagementProperty(use={ViewUse.STATISTIC},
description="True if this destination was created programmatically")
public boolean isCreatedProgrammatically() { return false; }
Modified: branches/Branch_5_x/messaging/src/main/org/jboss/jms/server/destination/TopicServiceMO.java
===================================================================
--- branches/Branch_5_x/messaging/src/main/org/jboss/jms/server/destination/TopicServiceMO.java 2009-04-02 11:13:30 UTC (rev 86658)
+++ branches/Branch_5_x/messaging/src/main/org/jboss/jms/server/destination/TopicServiceMO.java 2009-04-02 11:39:37 UTC (rev 86659)
@@ -57,7 +57,8 @@
// Management Properties
@ManagementProperty(use={ViewUse.RUNTIME},
- description="The destination name")
+ description="The destination name",
+ mandatory=true, includeInTemplate=true)
public String getName() { return null; }
@ManagementProperty(use={ViewUse.CONFIGURATION},
@@ -97,6 +98,7 @@
@ManagementProperty(use={ViewUse.CONFIGURATION},
description="The destination's security configuration",
includeInTemplate=true)
+ @MetaMapping(SecurityConfigMapper.class)
public Element getSecurityConfig() { return null; }
public void setSecurityConfig(Element arg0) { }
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-04-02 11:13:30 UTC (rev 86658)
+++ branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/templates/JmsDestinationTemplate.java 2009-04-02 11:39:37 UTC (rev 86659)
@@ -31,21 +31,30 @@
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.Marshaller;
+import javax.xml.bind.annotation.XmlAnyElement;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElements;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlValue;
+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.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.MapCompositeValueSupport;
import org.jboss.metatype.api.values.MetaValue;
import org.jboss.metatype.api.values.MetaValueFactory;
import org.jboss.metatype.api.values.SimpleValue;
import org.jboss.metatype.plugins.values.MetaValueFactoryBuilder;
import org.jboss.virtual.VFS;
import org.jboss.virtual.VirtualFile;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
/**
* A template for creating jms destinations
@@ -61,6 +70,9 @@
/** The file suffix. */
private static final String FILE_SUFFIX = "-service.xml";
+ /** The role attributes. */
+ protected static final String[] attributes = new String[] { "read", "write", "create"};
+
private static final MetaValueFactory mvf = MetaValueFactoryBuilder.create();
private DeploymentTemplateInfo info;
@@ -119,10 +131,14 @@
String destinationType = destinationInfo.getDestinationType();
JmsDestinationMetaData destination = new JmsDestinationMetaData();
+
+ String destinationName = (String) getProperty(info, "name");
String jndiName = (String) getProperty(info, "JNDIName");
if(jndiName == null)
throw new IllegalStateException("Null jndi name.");
+ if(destinationName == null)
+ destinationName = jndiName;
if("QueueTemplate".equals(destinationType))
{
@@ -130,7 +146,7 @@
// 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;
+ destination.jmxName = "jboss.messaging.destination:service=Queue,name=" + destinationName;
}
else if("TopicTemplate".equals(destinationType))
{
@@ -138,13 +154,13 @@
// 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;
+ destination.jmxName = "jboss.messaging.destination:service=Topic,name=" + destinationName;
}
else
{
throw new IllegalStateException("Unsupported destination type: " + destinationType);
}
- List<JmsAttributeMetaData> attributes = new ArrayList<JmsAttributeMetaData>();
+ List<JmsAttribute> attributes = new ArrayList<JmsAttribute>();
destination.attribute = attributes;
Map<String, ManagedProperty> properties = info.getProperties();
@@ -176,7 +192,12 @@
ObjectName n = (ObjectName) mvf.unwrap(v);
attributes.add(new JmsAttributeMetaData("ExpiryQueue", n.getCanonicalName()));
}
- // TODO securityConfig
+ else if(name.equals("SecurityConfig"))
+ {
+ Element e = unwrapMetaValue((MapCompositeValueSupport) v);
+ attributes.add(new JmsElementMetaData("SecurityConfig", e));
+ }
+
}
}
@@ -248,6 +269,61 @@
return value;
}
+ /**
+ * Unwrap the value.
+ * TODO This should actually be done by the SecurityConfigMapper and
+ * the metaValueFacotyr
+ *
+ * @param metaValue the meta value
+ * @return the element
+ */
+ protected Element unwrapMetaValue(MapCompositeValueSupport metaValue)
+ {
+ if(metaValue == null)
+ return null;
+
+ MapCompositeValueSupport value = (MapCompositeValueSupport) metaValue;
+ CompositeMetaType metaType = value.getMetaType();
+ // Create the dom document
+ Document d = createDocument();
+ // Security
+ Element security = d.createElement("security");
+ // Get the roles
+ for(String name : metaType.itemSet())
+ {
+ // Role
+ CompositeValue row = (CompositeValue) value.get(name);
+ Element role = d.createElement("role");
+ role.setAttribute("name", name);
+
+ // For each attribute: read, write, create
+ for(String attribute : attributes)
+ {
+ SimpleValue v = (SimpleValue) row.get(attribute);
+ if(v != null && v.getValue() != null)
+ {
+ role.setAttribute(attribute, ((Boolean)v.getValue()).toString());
+ }
+ }
+ security.appendChild(role);
+ }
+ return security;
+ }
+
+ protected static Document createDocument()
+ {
+ try
+ {
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ DocumentBuilder db = dbf.newDocumentBuilder();
+ return db.newDocument();
+ }
+ catch(Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
// the classes below should go away and ServiceDeployment and MetaData
// API should be used instead once their bound with JAXB
@@ -272,11 +348,14 @@
@XmlElement
String annotation;
- public List<JmsAttributeMetaData> attribute;
+ @XmlElements(value = {
+ @XmlElement(type = JmsAttributeMetaData.class),
+ @XmlElement(type = JmsElementMetaData.class) })
+ public List<JmsAttribute> attribute;
public List<JmsDependencyMetaData> depends;
}
- public static class JmsAttributeMetaData
+ public static class JmsAttributeMetaData implements JmsAttribute
{
@XmlAttribute
String name;
@@ -291,13 +370,27 @@
this.value = value;
}
}
+ public static class JmsElementMetaData implements JmsAttribute
+ {
+ @XmlAttribute
+ String name;
+ @XmlAnyElement
+ Element value;
+ public JmsElementMetaData()
+ {
+ }
+ public JmsElementMetaData(String name, Element value)
+ {
+ this.name = name;
+ this.value = value;
+ }
+ }
public static class JmsDependencyMetaData
{
@XmlAttribute(name = "optional-attribute-name")
String attribute;
@XmlValue
String value;
-
public JmsDependencyMetaData()
{
}
@@ -313,4 +406,8 @@
this.value = value;
}
}
+ public static interface JmsAttribute
+ {
+ // workaround jaxb
+ }
}
Modified: branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/template/test/JMSDestinationTemplateUnitTestCase.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/template/test/JMSDestinationTemplateUnitTestCase.java 2009-04-02 11:13:30 UTC (rev 86658)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/template/test/JMSDestinationTemplateUnitTestCase.java 2009-04-02 11:39:37 UTC (rev 86659)
@@ -66,7 +66,8 @@
// DeploymentTemplateInfo info = assertTemplate("QueueTemplate",
// QueueServiceMO.class);
//
-// info.getProperties().get("JNDIName").setValue(new SimpleValueSupport(SimpleMetaType.STRING, "Test"));
+// info.getProperties().get("name").setValue(new SimpleValueSupport(SimpleMetaType.STRING, "Test"));
+// info.getProperties().get("JNDIName").setValue(new SimpleValueSupport(SimpleMetaType.STRING, "TestJNDIName"));
//
// info.getProperties().get("serverPeer").setValue(getMvf().create(new ObjectName("jboss.messaging.destination:service=Queue")));
// info.getProperties().get("DLQ").setValue(getMvf().create(new ObjectName("jboss.messaging.destination:service=Queue,name=PrivateDLQ")));
@@ -84,7 +85,8 @@
// DeploymentTemplateInfo info = assertTemplate("TopicTemplate",
// TopicServiceMO.class);
//
-// info.getProperties().get("JNDIName").setValue(new SimpleValueSupport(SimpleMetaType.STRING, "Test"));
+// info.getProperties().get("name").setValue(new SimpleValueSupport(SimpleMetaType.STRING, "Test"));
+// info.getProperties().get("JNDIName").setValue(new SimpleValueSupport(SimpleMetaType.STRING, "TestJNDIName"));
//
// info.getProperties().get("serverPeer").setValue(getMvf().create(new ObjectName("jboss.messaging.destination:service=Queue")));
// info.getProperties().get("DLQ").setValue(getMvf().create(new ObjectName("jboss.messaging.destination:service=Queue,name=PrivateDLQ")));
More information about the jboss-cvs-commits
mailing list