[jboss-cvs] JBossAS SVN: r87006 - in projects/jboss-man/tags: 2.1.0.CR7 and 9 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Apr 8 17:47:06 EDT 2009
Author: scott.stark at jboss.org
Date: 2009-04-08 17:47:06 -0400 (Wed, 08 Apr 2009)
New Revision: 87006
Added:
projects/jboss-man/tags/2.1.0.CR7/
projects/jboss-man/tags/2.1.0.CR7/build/pom.xml
projects/jboss-man/tags/2.1.0.CR7/managed/pom.xml
projects/jboss-man/tags/2.1.0.CR7/managed/src/main/java/org/jboss/managed/api/ManagedOperation.java
projects/jboss-man/tags/2.1.0.CR7/managed/src/main/java/org/jboss/managed/api/ManagedParameter.java
projects/jboss-man/tags/2.1.0.CR7/managed/src/main/java/org/jboss/managed/api/ManagedProperty.java
projects/jboss-man/tags/2.1.0.CR7/managed/src/main/java/org/jboss/managed/api/TransientAttachments.java
projects/jboss-man/tags/2.1.0.CR7/managed/src/main/java/org/jboss/managed/plugins/ManagedOperationImpl.java
projects/jboss-man/tags/2.1.0.CR7/managed/src/main/java/org/jboss/managed/plugins/ManagedParameterImpl.java
projects/jboss-man/tags/2.1.0.CR7/managed/src/main/java/org/jboss/managed/plugins/factory/AbstractManagedObjectFactory.java
projects/jboss-man/tags/2.1.0.CR7/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/JBMessage.java
projects/jboss-man/tags/2.1.0.CR7/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/JmsDestination.java
projects/jboss-man/tags/2.1.0.CR7/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/MessageListMapper.java
projects/jboss-man/tags/2.1.0.CR7/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/QueueDestination.java
projects/jboss-man/tags/2.1.0.CR7/managed/src/test/java/org/jboss/test/managed/factory/test/AbstractManagedObjectFactoryUnitTestCase.java
projects/jboss-man/tags/2.1.0.CR7/metatype/pom.xml
projects/jboss-man/tags/2.1.0.CR7/metatype/src/main/java/org/jboss/metatype/api/annotations/MetaMapping.java
projects/jboss-man/tags/2.1.0.CR7/pom.xml
Removed:
projects/jboss-man/tags/2.1.0.CR7/build/pom.xml
projects/jboss-man/tags/2.1.0.CR7/managed/pom.xml
projects/jboss-man/tags/2.1.0.CR7/managed/src/main/java/org/jboss/managed/api/ManagedOperation.java
projects/jboss-man/tags/2.1.0.CR7/managed/src/main/java/org/jboss/managed/api/ManagedParameter.java
projects/jboss-man/tags/2.1.0.CR7/managed/src/main/java/org/jboss/managed/api/ManagedProperty.java
projects/jboss-man/tags/2.1.0.CR7/managed/src/main/java/org/jboss/managed/plugins/ManagedOperationImpl.java
projects/jboss-man/tags/2.1.0.CR7/managed/src/main/java/org/jboss/managed/plugins/ManagedParameterImpl.java
projects/jboss-man/tags/2.1.0.CR7/managed/src/main/java/org/jboss/managed/plugins/factory/AbstractManagedObjectFactory.java
projects/jboss-man/tags/2.1.0.CR7/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/JmsDestination.java
projects/jboss-man/tags/2.1.0.CR7/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/QueueDestination.java
projects/jboss-man/tags/2.1.0.CR7/managed/src/test/java/org/jboss/test/managed/factory/test/AbstractManagedObjectFactoryUnitTestCase.java
projects/jboss-man/tags/2.1.0.CR7/metatype/pom.xml
projects/jboss-man/tags/2.1.0.CR7/metatype/src/main/java/org/jboss/metatype/api/annotations/MetaMapping.java
projects/jboss-man/tags/2.1.0.CR7/pom.xml
Log:
[maven-release-plugin] copy for tag 2.1.0.CR7
Copied: projects/jboss-man/tags/2.1.0.CR7 (from rev 87000, projects/jboss-man/branches/Branch_2_1)
Deleted: projects/jboss-man/tags/2.1.0.CR7/build/pom.xml
===================================================================
--- projects/jboss-man/branches/Branch_2_1/build/pom.xml 2009-04-08 21:28:11 UTC (rev 87000)
+++ projects/jboss-man/tags/2.1.0.CR7/build/pom.xml 2009-04-08 21:47:06 UTC (rev 87006)
@@ -1,54 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>org.jboss.man</groupId>
- <artifactId>jboss-man-parent</artifactId>
- <version>2.1.0-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.jboss.man</groupId>
- <artifactId>jboss-man</artifactId>
- <version>2.1.0-SNAPSHOT</version>
- <packaging>pom</packaging>
- <name>JBoss Managed Distribution</name>
- <url>http://www.jboss.org/jbossmc</url>
- <description>JBoss Managed Distribution Build</description>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-assembly-plugin</artifactId>
- <version>2.2-beta-2</version>
- <executions>
- <execution>
- <id>make-assembly</id>
- <phase>package</phase>
- <goals>
- <goal>attached</goal>
- </goals>
- <configuration>
- <finalName>jboss-man-${project.version}</finalName>
- <descriptors>
- <descriptor>src/assembly/dist.xml</descriptor>
- <descriptor>src/assembly/dist-with-deps.xml</descriptor>
- <descriptor>src/assembly/src.xml</descriptor>
- </descriptors>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
- <dependency>
- <groupId>org.jboss.man</groupId>
- <artifactId>jboss-managed</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.man</groupId>
- <artifactId>jboss-metatype</artifactId>
- </dependency>
- </dependencies>
-
-</project>
Copied: projects/jboss-man/tags/2.1.0.CR7/build/pom.xml (from rev 87005, projects/jboss-man/branches/Branch_2_1/build/pom.xml)
===================================================================
--- projects/jboss-man/tags/2.1.0.CR7/build/pom.xml (rev 0)
+++ projects/jboss-man/tags/2.1.0.CR7/build/pom.xml 2009-04-08 21:47:06 UTC (rev 87006)
@@ -0,0 +1,54 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.jboss.man</groupId>
+ <artifactId>jboss-man-parent</artifactId>
+ <version>2.1.0.CR7</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.jboss.man</groupId>
+ <artifactId>jboss-man</artifactId>
+ <version>2.1.0.CR7</version>
+ <packaging>pom</packaging>
+ <name>JBoss Managed Distribution</name>
+ <url>http://www.jboss.org/jbossmc</url>
+ <description>JBoss Managed Distribution Build</description>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <version>2.2-beta-2</version>
+ <executions>
+ <execution>
+ <id>make-assembly</id>
+ <phase>package</phase>
+ <goals>
+ <goal>attached</goal>
+ </goals>
+ <configuration>
+ <finalName>jboss-man-${project.version}</finalName>
+ <descriptors>
+ <descriptor>src/assembly/dist.xml</descriptor>
+ <descriptor>src/assembly/dist-with-deps.xml</descriptor>
+ <descriptor>src/assembly/src.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.man</groupId>
+ <artifactId>jboss-managed</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.man</groupId>
+ <artifactId>jboss-metatype</artifactId>
+ </dependency>
+ </dependencies>
+
+</project>
Deleted: projects/jboss-man/tags/2.1.0.CR7/managed/pom.xml
===================================================================
--- projects/jboss-man/branches/Branch_2_1/managed/pom.xml 2009-04-08 21:28:11 UTC (rev 87000)
+++ projects/jboss-man/tags/2.1.0.CR7/managed/pom.xml 2009-04-08 21:47:06 UTC (rev 87006)
@@ -1,66 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>org.jboss.man</groupId>
- <artifactId>jboss-man-parent</artifactId>
- <version>2.1.0-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <artifactId>jboss-managed</artifactId>
- <packaging>jar</packaging>
- <name>JBoss Managed</name>
- <url>http://www.jboss.org/jbossmc</url>
- <description>JBoss Managed</description>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-assembly-plugin</artifactId>
- <configuration>
- <descriptors>
- <descriptor>src/assembly/api.xml</descriptor>
- <descriptor>src/assembly/plugins.xml</descriptor>
- </descriptors>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- <!-- Do not add version information here, use ../pom.xml instead -->
- <dependencies>
- <!-- Global dependencies -->
- <dependency>
- <groupId>org.jboss.man</groupId>
- <artifactId>jboss-metatype</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss</groupId>
- <artifactId>jboss-mdr</artifactId>
- </dependency>
- <!-- Test dependencies -->
- <dependency>
- <groupId>sun-jaxb</groupId>
- <artifactId>jaxb-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.logging</groupId>
- <artifactId>jboss-logging-log4j</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.test</groupId>
- <artifactId>jboss-test</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>javassist</groupId>
- <artifactId>javassist</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-</project>
\ No newline at end of file
Copied: projects/jboss-man/tags/2.1.0.CR7/managed/pom.xml (from rev 87005, projects/jboss-man/branches/Branch_2_1/managed/pom.xml)
===================================================================
--- projects/jboss-man/tags/2.1.0.CR7/managed/pom.xml (rev 0)
+++ projects/jboss-man/tags/2.1.0.CR7/managed/pom.xml 2009-04-08 21:47:06 UTC (rev 87006)
@@ -0,0 +1,66 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.jboss.man</groupId>
+ <artifactId>jboss-man-parent</artifactId>
+ <version>2.1.0.CR7</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>jboss-managed</artifactId>
+ <packaging>jar</packaging>
+ <name>JBoss Managed</name>
+ <url>http://www.jboss.org/jbossmc</url>
+ <description>JBoss Managed</description>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <configuration>
+ <descriptors>
+ <descriptor>src/assembly/api.xml</descriptor>
+ <descriptor>src/assembly/plugins.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <!-- Do not add version information here, use ../pom.xml instead -->
+ <dependencies>
+ <!-- Global dependencies -->
+ <dependency>
+ <groupId>org.jboss.man</groupId>
+ <artifactId>jboss-metatype</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-mdr</artifactId>
+ </dependency>
+ <!-- Test dependencies -->
+ <dependency>
+ <groupId>sun-jaxb</groupId>
+ <artifactId>jaxb-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-log4j</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.test</groupId>
+ <artifactId>jboss-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>javassist</groupId>
+ <artifactId>javassist</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
Deleted: projects/jboss-man/tags/2.1.0.CR7/managed/src/main/java/org/jboss/managed/api/ManagedOperation.java
===================================================================
--- projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/api/ManagedOperation.java 2009-04-08 21:28:11 UTC (rev 87000)
+++ projects/jboss-man/tags/2.1.0.CR7/managed/src/main/java/org/jboss/managed/api/ManagedOperation.java 2009-04-08 21:47:06 UTC (rev 87006)
@@ -1,94 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, 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.managed.api;
-
-import java.io.Serializable;
-
-import org.jboss.metatype.api.types.MetaType;
-import org.jboss.metatype.api.values.MetaValue;
-
-/**
- * A representation of a managed operation.
- *
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public interface ManagedOperation extends Serializable
-{
- /**
- * The side-effect impact of invoking an operation
- */
- public enum Impact {
- /** There is not modification of the ManagedObject */
- ReadOnly,
- /** The impact may modify the ManagedObject */
- ReadWrite,
- /** The impact is to modify the ManagedObject */
- WriteOnly,
- /** The impact is not known */
- Unknown
- };
-
- /**
- * Get the operation description
- * @return the operation description
- */
- public String getDescription();
- /**
- * Get the name of the operation
- * @return the name of the operation
- */
- public String getName();
-
- /**
- * Get the impact of the operation
- * @return the side-effect type invoking the operation has.
- */
- public Impact getImpact();
-
- /**
- * The MetaType for the operation return value.
- * @return MetaType for the operation return value.
- */
- public MetaType getReturnType();
-
- /**
- * The parameter information for the operation arguments. An empty
- * signature array is returned if the operation takes no arguments.
- * @return parameter information for the operation arguments.
- */
- public ManagedParameter[] getParameters();
-
- /**
- * Get the operation signature
- * @return
- */
- public String[] getReflectionSignature();
-
- /**
- * Invoke the operation given its parameter values.
- *
- * @param param the varags for the operation parameters.
- * @return the MetaValue for the result.
- */
- public MetaValue invoke(MetaValue... param);
-}
Copied: projects/jboss-man/tags/2.1.0.CR7/managed/src/main/java/org/jboss/managed/api/ManagedOperation.java (from rev 87004, projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/api/ManagedOperation.java)
===================================================================
--- projects/jboss-man/tags/2.1.0.CR7/managed/src/main/java/org/jboss/managed/api/ManagedOperation.java (rev 0)
+++ projects/jboss-man/tags/2.1.0.CR7/managed/src/main/java/org/jboss/managed/api/ManagedOperation.java 2009-04-08 21:47:06 UTC (rev 87006)
@@ -0,0 +1,95 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.managed.api;
+
+import java.io.Serializable;
+
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.values.MetaValue;
+
+/**
+ * A representation of a managed operation.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public interface ManagedOperation extends Serializable, TransientAttachments
+{
+ /**
+ * The side-effect impact of invoking an operation
+ */
+ public enum Impact {
+ /** There is not modification of the ManagedObject */
+ ReadOnly,
+ /** The impact may modify the ManagedObject */
+ ReadWrite,
+ /** The impact is to modify the ManagedObject */
+ WriteOnly,
+ /** The impact is not known */
+ Unknown
+ };
+
+ /**
+ * Get the operation description
+ * @return the operation description
+ */
+ public String getDescription();
+ /**
+ * Get the name of the operation
+ * @return the name of the operation
+ */
+ public String getName();
+
+ /**
+ * Get the impact of the operation
+ * @return the side-effect type invoking the operation has.
+ */
+ public Impact getImpact();
+
+ /**
+ * The MetaType for the operation return value.
+ * @return MetaType for the operation return value.
+ */
+ public MetaType getReturnType();
+
+ /**
+ * The parameter information for the operation arguments. An empty
+ * signature array is returned if the operation takes no arguments.
+ * @return parameter information for the operation arguments.
+ */
+ public ManagedParameter[] getParameters();
+
+ /**
+ * Get the operation signature
+ * @return
+ */
+ public String[] getReflectionSignature();
+
+ /**
+ * Invoke the operation given its parameter values.
+ *
+ * @param param the varags for the operation parameters.
+ * @return the MetaValue for the result.
+ */
+ public MetaValue invoke(MetaValue... param);
+
+}
Deleted: projects/jboss-man/tags/2.1.0.CR7/managed/src/main/java/org/jboss/managed/api/ManagedParameter.java
===================================================================
--- projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/api/ManagedParameter.java 2009-04-08 21:28:11 UTC (rev 87000)
+++ projects/jboss-man/tags/2.1.0.CR7/managed/src/main/java/org/jboss/managed/api/ManagedParameter.java 2009-04-08 21:47:06 UTC (rev 87006)
@@ -1,127 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, 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.managed.api;
-
-import java.io.Serializable;
-import java.util.Set;
-
-import org.jboss.metatype.api.types.MetaType;
-import org.jboss.metatype.api.values.MetaValue;
-
-/**
- * A representation of a ManagedOperation parameter
- *
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public interface ManagedParameter extends Serializable
-{
- /**
- * Get the fields
- *
- * @return the fields
- */
- Fields getFields();
-
- /**
- * Get a field
- *
- * @param <T> the expected type
- * @param fieldName the field name
- * @param expected the expected type
- * @return the value
- */
- <T> T getField(String fieldName, Class<T> expected);
-
- /**
- * Set a field
- *
- * @param fieldName the field name
- * @param value the value
- */
- void setField(String fieldName, Serializable value);
-
- /**
- * Get the property's name
- *
- * @return the property's name
- */
- String getName();
-
- /**
- * Get the description
- *
- * @return the description
- */
- String getDescription();
-
- /**
- * Get the type
- *
- * @return the type
- */
- MetaType getMetaType();
-
- /**
- * Get the value
- *
- * @return the value
- */
- MetaValue getValue();
-
- /**
- * Set the value
- *
- * @param value the value
- */
- void setValue(MetaValue value);
-
- /**
- * Get the legal values
- *
- * @return the legal values
- */
- Set<MetaValue> getLegalValues();
-
- /**
- * Get the minimum value
- *
- * @return the minimum value
- */
- Comparable<?> getMinimumValue();
-
- /**
- * Get the miximum value
- *
- * @return the maximum value
- */
- Comparable<?> getMaximumValue();
-
- /**
- * Check whether this is a valid value
- *
- * @param value the value
- * @return null for a valid value, an error message otherwise
- */
- String checkValidValue(MetaValue value);
-
-}
Copied: projects/jboss-man/tags/2.1.0.CR7/managed/src/main/java/org/jboss/managed/api/ManagedParameter.java (from rev 87004, projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/api/ManagedParameter.java)
===================================================================
--- projects/jboss-man/tags/2.1.0.CR7/managed/src/main/java/org/jboss/managed/api/ManagedParameter.java (rev 0)
+++ projects/jboss-man/tags/2.1.0.CR7/managed/src/main/java/org/jboss/managed/api/ManagedParameter.java 2009-04-08 21:47:06 UTC (rev 87006)
@@ -0,0 +1,127 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.managed.api;
+
+import java.io.Serializable;
+import java.util.Set;
+
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.values.MetaValue;
+
+/**
+ * A representation of a ManagedOperation parameter
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public interface ManagedParameter extends Serializable, TransientAttachments
+{
+ /**
+ * Get the fields
+ *
+ * @return the fields
+ */
+ Fields getFields();
+
+ /**
+ * Get a field
+ *
+ * @param <T> the expected type
+ * @param fieldName the field name
+ * @param expected the expected type
+ * @return the value
+ */
+ <T> T getField(String fieldName, Class<T> expected);
+
+ /**
+ * Set a field
+ *
+ * @param fieldName the field name
+ * @param value the value
+ */
+ void setField(String fieldName, Serializable value);
+
+ /**
+ * Get the property's name
+ *
+ * @return the property's name
+ */
+ String getName();
+
+ /**
+ * Get the description
+ *
+ * @return the description
+ */
+ String getDescription();
+
+ /**
+ * Get the type
+ *
+ * @return the type
+ */
+ MetaType getMetaType();
+
+ /**
+ * Get the value
+ *
+ * @return the value
+ */
+ MetaValue getValue();
+
+ /**
+ * Set the value
+ *
+ * @param value the value
+ */
+ void setValue(MetaValue value);
+
+ /**
+ * Get the legal values
+ *
+ * @return the legal values
+ */
+ Set<MetaValue> getLegalValues();
+
+ /**
+ * Get the minimum value
+ *
+ * @return the minimum value
+ */
+ Comparable<?> getMinimumValue();
+
+ /**
+ * Get the miximum value
+ *
+ * @return the maximum value
+ */
+ Comparable<?> getMaximumValue();
+
+ /**
+ * Check whether this is a valid value
+ *
+ * @param value the value
+ * @return null for a valid value, an error message otherwise
+ */
+ String checkValidValue(MetaValue value);
+
+}
Deleted: projects/jboss-man/tags/2.1.0.CR7/managed/src/main/java/org/jboss/managed/api/ManagedProperty.java
===================================================================
--- projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/api/ManagedProperty.java 2009-04-08 21:28:11 UTC (rev 87000)
+++ projects/jboss-man/tags/2.1.0.CR7/managed/src/main/java/org/jboss/managed/api/ManagedProperty.java 2009-04-08 21:47:06 UTC (rev 87006)
@@ -1,266 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, 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.managed.api;
-
-import java.io.Serializable;
-import java.lang.annotation.Annotation;
-import java.util.Map;
-import java.util.Set;
-
-import org.jboss.managed.api.annotation.ActivationPolicy;
-import org.jboss.managed.api.annotation.ManagementObjectRef;
-import org.jboss.managed.api.annotation.ViewUse;
-import org.jboss.metatype.api.types.MetaType;
-import org.jboss.metatype.api.values.MetaValue;
-
-/**
- * ManagedProperty.
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @author Scott.Stark at jboss.org
- * @version $Revision: 1.1 $
- */
-public interface ManagedProperty extends Serializable
-{
- /**
- * Get the managed object the property is associated with.
- *
- * @return the managed object
- */
- ManagedObject getManagedObject();
- void setManagedObject(ManagedObject managedObject);
-
- /**
- * Get the ManagedObject
- * @see {@linkplain ManagementObjectRef}
- * @return the ManagedObject the property references, null
- * if there is no reference or its unresolved.
- */
- ManagedObject getTargetManagedObject();
- void setTargetManagedObject(ManagedObject target);
-
- /**
- * Get the fields
- *
- * @return the fields
- */
- Fields getFields();
-
- /**
- * Create a copy of the managed property. This is a copy that whose fields
- * are copies of the original property. Changes to the copies fields have
- * not affect on the original.
- * @return a copy of the managed property.
- */
- ManagedProperty copy();
-
- /**
- * Get a field
- *
- * @param <T> the expected type
- * @param fieldName the field name
- * @param expected the expected type
- * @return the value
- */
- <T> T getField(String fieldName, Class<T> expected);
-
- /**
- * Set a field
- *
- * @param fieldName the field name
- * @param value the value
- */
- void setField(String fieldName, Serializable value);
-
- /**
- * Get the property's name
- *
- * @return the property's name
- */
- String getName();
-
- /**
- * Get the property's mapped name. This is an optional name
- * that allows for an external name to be mapped to an
- * internal one.
- *
- * @return the mapped name if it exists, null if there is no
- * mapped name.
- */
- String getMappedName();
-
- /**
- * Get the description
- *
- * @return the description
- */
- String getDescription();
-
- /**
- * Get the type
- *
- * @return the type
- */
- MetaType getMetaType();
-
- /**
- * Get the annotations associated with the property
- * @return the annotations associated with the property
- */
- Map<String, Annotation> getAnnotations();
-
- /**
- * Does the property have the annotation referenced by key.
- * @param key the key into {@link #getAnnotations()}
- * @return true if the annotation exists, false otherwise.
- */
- boolean hasAnnotation(String key);
-
- /**
- * See if the property has the indicated ViewUse among its
- * @ManagementProperty annotation uses.
- *
- * @param use - the ViewUse to check for
- * @return true if the ViewUse exists in the property uses, false otherwise
- */
- boolean hasViewUse(ViewUse use);
-
- /**
- * Get the activation policy for property value updates.
- * @return the property activation policy
- */
- ActivationPolicy getActivationPolicy();
-
- /**
- * Get the value
- *
- * @return the value
- */
- MetaValue getValue();
-
- /**
- * Set the value
- *
- * @param value the value
- */
- void setValue(MetaValue value);
-
- /**
- * Get the legal values
- *
- * @return the legal values
- */
- Set<MetaValue> getLegalValues();
-
- /**
- * Get the minimum value
- *
- * @return the minimum value, a MetaValue implementing Comparable
- */
- Comparable<? extends MetaValue> getMinimumValue();
-
- /**
- * Get the maximum value
- *
- * @return the maximum value, a MetaValue implementing Comparable
- */
- Comparable<? extends MetaValue> getMaximumValue();
-
- /**
- * Check whether this is a valid value
- *
- * @param value the value
- * @return null for a valid value, an error message otherwise
- */
- String checkValidValue(MetaValue value);
-
- /**
- * Whether the property is mandatory
- *
- * @return true when mandatory
- */
- boolean isMandatory();
-
- /**
- * Whether the property is read only
- * @return true when read only
- */
- boolean isReadOnly();
-
- /**
- * Whether the property has been edited/modified.
- *
- * @return true when modified
- */
- boolean isModified();
-
- /**
- * Set the modified state of the property value.
- * @param flag - whether the property has been modified
- */
- public void setModified(boolean flag);
-
- /**
- * Whether the property has been marked as removed from its ManagedObject.
- * @return true is the property has been removed.
- */
- boolean isRemoved();
- /**
- * Set whether a property has been marked as removed from its ManagedObject.
- * @param flag - true is the property has been removed, false if not.
- */
- void setRemoved(boolean flag);
-
- /**
- * Get a transient attachment from the property.
- *
- * @see #setTransientAttachment(String, Object)
- *
- * @param name the name
- * @return the attachment
- */
- Object getTransientAttachment(String name);
-
- /**
- * Get an attachment from the property,
- * uses the expected type as both the name
- * and to cast the resulting object.
- *
- * @param <T> the expected type
- * @param expectedType the expected type
- * @return the attachment
- * @throws ClassCastException when the object is not of the expected type
- */
- <T> T getTransientAttachment(Class<T> expectedType);
-
- /**
- * Set an transient attachment against the property. A transient attachment
- * is one that will not be available to clients of the property, typically
- * admin tools. Such attachments are used by the server side where the
- * underlying metadata to which the property is
- *
- * @param name the name
- * @param attachment the attachment, pass null to remove an attachment
- * @throws IllegalArgumentException for a null name
- */
- void setTransientAttachment(String name, Object attachment);
-}
Copied: projects/jboss-man/tags/2.1.0.CR7/managed/src/main/java/org/jboss/managed/api/ManagedProperty.java (from rev 87004, projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/api/ManagedProperty.java)
===================================================================
--- projects/jboss-man/tags/2.1.0.CR7/managed/src/main/java/org/jboss/managed/api/ManagedProperty.java (rev 0)
+++ projects/jboss-man/tags/2.1.0.CR7/managed/src/main/java/org/jboss/managed/api/ManagedProperty.java 2009-04-08 21:47:06 UTC (rev 87006)
@@ -0,0 +1,233 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.managed.api;
+
+import java.io.Serializable;
+import java.lang.annotation.Annotation;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.managed.api.annotation.ActivationPolicy;
+import org.jboss.managed.api.annotation.ManagementObjectRef;
+import org.jboss.managed.api.annotation.ViewUse;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.values.MetaValue;
+
+/**
+ * ManagedProperty.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public interface ManagedProperty extends Serializable, TransientAttachments
+{
+ /**
+ * Get the managed object the property is associated with.
+ *
+ * @return the managed object
+ */
+ ManagedObject getManagedObject();
+ void setManagedObject(ManagedObject managedObject);
+
+ /**
+ * Get the ManagedObject
+ * @see {@linkplain ManagementObjectRef}
+ * @return the ManagedObject the property references, null
+ * if there is no reference or its unresolved.
+ */
+ ManagedObject getTargetManagedObject();
+ void setTargetManagedObject(ManagedObject target);
+
+ /**
+ * Get the fields
+ *
+ * @return the fields
+ */
+ Fields getFields();
+
+ /**
+ * Create a copy of the managed property. This is a copy that whose fields
+ * are copies of the original property. Changes to the copies fields have
+ * not affect on the original.
+ * @return a copy of the managed property.
+ */
+ ManagedProperty copy();
+
+ /**
+ * Get a field
+ *
+ * @param <T> the expected type
+ * @param fieldName the field name
+ * @param expected the expected type
+ * @return the value
+ */
+ <T> T getField(String fieldName, Class<T> expected);
+
+ /**
+ * Set a field
+ *
+ * @param fieldName the field name
+ * @param value the value
+ */
+ void setField(String fieldName, Serializable value);
+
+ /**
+ * Get the property's name
+ *
+ * @return the property's name
+ */
+ String getName();
+
+ /**
+ * Get the property's mapped name. This is an optional name
+ * that allows for an external name to be mapped to an
+ * internal one.
+ *
+ * @return the mapped name if it exists, null if there is no
+ * mapped name.
+ */
+ String getMappedName();
+
+ /**
+ * Get the description
+ *
+ * @return the description
+ */
+ String getDescription();
+
+ /**
+ * Get the type
+ *
+ * @return the type
+ */
+ MetaType getMetaType();
+
+ /**
+ * Get the annotations associated with the property
+ * @return the annotations associated with the property
+ */
+ Map<String, Annotation> getAnnotations();
+
+ /**
+ * Does the property have the annotation referenced by key.
+ * @param key the key into {@link #getAnnotations()}
+ * @return true if the annotation exists, false otherwise.
+ */
+ boolean hasAnnotation(String key);
+
+ /**
+ * See if the property has the indicated ViewUse among its
+ * @ManagementProperty annotation uses.
+ *
+ * @param use - the ViewUse to check for
+ * @return true if the ViewUse exists in the property uses, false otherwise
+ */
+ boolean hasViewUse(ViewUse use);
+
+ /**
+ * Get the activation policy for property value updates.
+ * @return the property activation policy
+ */
+ ActivationPolicy getActivationPolicy();
+
+ /**
+ * Get the value
+ *
+ * @return the value
+ */
+ MetaValue getValue();
+
+ /**
+ * Set the value
+ *
+ * @param value the value
+ */
+ void setValue(MetaValue value);
+
+ /**
+ * Get the legal values
+ *
+ * @return the legal values
+ */
+ Set<MetaValue> getLegalValues();
+
+ /**
+ * Get the minimum value
+ *
+ * @return the minimum value, a MetaValue implementing Comparable
+ */
+ Comparable<? extends MetaValue> getMinimumValue();
+
+ /**
+ * Get the maximum value
+ *
+ * @return the maximum value, a MetaValue implementing Comparable
+ */
+ Comparable<? extends MetaValue> getMaximumValue();
+
+ /**
+ * Check whether this is a valid value
+ *
+ * @param value the value
+ * @return null for a valid value, an error message otherwise
+ */
+ String checkValidValue(MetaValue value);
+
+ /**
+ * Whether the property is mandatory
+ *
+ * @return true when mandatory
+ */
+ boolean isMandatory();
+
+ /**
+ * Whether the property is read only
+ * @return true when read only
+ */
+ boolean isReadOnly();
+
+ /**
+ * Whether the property has been edited/modified.
+ *
+ * @return true when modified
+ */
+ boolean isModified();
+
+ /**
+ * Set the modified state of the property value.
+ * @param flag - whether the property has been modified
+ */
+ public void setModified(boolean flag);
+
+ /**
+ * Whether the property has been marked as removed from its ManagedObject.
+ * @return true is the property has been removed.
+ */
+ boolean isRemoved();
+ /**
+ * Set whether a property has been marked as removed from its ManagedObject.
+ * @param flag - true is the property has been removed, false if not.
+ */
+ void setRemoved(boolean flag);
+
+}
Copied: projects/jboss-man/tags/2.1.0.CR7/managed/src/main/java/org/jboss/managed/api/TransientAttachments.java (from rev 87004, projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/api/TransientAttachments.java)
===================================================================
--- projects/jboss-man/tags/2.1.0.CR7/managed/src/main/java/org/jboss/managed/api/TransientAttachments.java (rev 0)
+++ projects/jboss-man/tags/2.1.0.CR7/managed/src/main/java/org/jboss/managed/api/TransientAttachments.java 2009-04-08 21:47:06 UTC (rev 87006)
@@ -0,0 +1,65 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.api;
+
+/**
+ * A common interface for managed elements that support transient attachments
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public interface TransientAttachments
+{
+ /**
+ * Get a transient attachment from the parameter.
+ *
+ * @see #setTransientAttachment(String, Object)
+ *
+ * @param name the name
+ * @return the attachment
+ */
+ Object getTransientAttachment(String name);
+
+ /**
+ * Get an attachment from the parameter,
+ * uses the expected type as both the name
+ * and to cast the resulting object.
+ *
+ * @param <T> the expected type
+ * @param expectedType the expected type
+ * @return the attachment
+ * @throws ClassCastException when the object is not of the expected type
+ */
+ <T> T getTransientAttachment(Class<T> expectedType);
+
+ /**
+ * Set an transient attachment against the parameter. A transient attachment
+ * is one that will not be available to clients of the parameter, typically
+ * admin tools. Such attachments are used by the server side where the
+ * underlying metadata to which the parameter is associated is available.
+ *
+ * @param name the name
+ * @param attachment the attachment, pass null to remove an attachment
+ * @throws IllegalArgumentException for a null name
+ */
+ void setTransientAttachment(String name, Object attachment);
+}
Deleted: projects/jboss-man/tags/2.1.0.CR7/managed/src/main/java/org/jboss/managed/plugins/ManagedOperationImpl.java
===================================================================
--- projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/plugins/ManagedOperationImpl.java 2009-04-08 21:28:11 UTC (rev 87000)
+++ projects/jboss-man/tags/2.1.0.CR7/managed/src/main/java/org/jboss/managed/plugins/ManagedOperationImpl.java 2009-04-08 21:47:06 UTC (rev 87006)
@@ -1,148 +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.managed.plugins;
-
-import org.jboss.managed.api.ManagedOperation;
-import org.jboss.managed.api.ManagedParameter;
-import org.jboss.metatype.api.types.MetaType;
-import org.jboss.metatype.api.types.SimpleMetaType;
-import org.jboss.metatype.api.values.MetaValue;
-
-/**
- * A default implementation of ManagedOperation
- *
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public class ManagedOperationImpl implements ManagedOperation
-{
- private static final long serialVersionUID = 1;
- private String description;
- private Impact impact;
- private String name;
- private ManagedParameter[] parameters;
- private MetaType returnType;
-
-
- public ManagedOperationImpl(String name, String description)
- {
- this(description, name, Impact.Unknown, new ManagedParameter[0], SimpleMetaType.VOID);
- }
- public ManagedOperationImpl(String name, String description, Impact impact,
- ManagedParameter[] parameters, MetaType returnType)
- {
- super();
- this.description = description;
- this.impact = impact;
- this.name = name;
- this.setParameters(parameters);
- this.returnType = returnType;
- }
-
- public String getDescription()
- {
- return description;
- }
-
- public void setDescription(String description)
- {
- this.description = description;
- }
-
- public Impact getImpact()
- {
- return impact;
- }
-
- public void setImpact(Impact impact)
- {
- this.impact = impact;
- }
-
- public String getName()
- {
- return name;
- }
-
- public void setName(String name)
- {
- this.name = name;
- }
-
- public ManagedParameter[] getParameters()
- {
- return parameters;
- }
-
- public void setParameters(ManagedParameter[] parameters)
- {
- this.parameters = parameters;
- if(this.parameters == null)
- this.parameters = new ManagedParameter[0];
- }
-
- public MetaType getReturnType()
- {
- return returnType;
- }
-
- public void setReturnType(MetaType returnType)
- {
- this.returnType = returnType;
- }
-
-
- public String[] getReflectionSignature()
- {
- String[] signature = new String[parameters.length];
- for(int i=0; i < parameters.length; i++)
- {
- signature[i] = parameters[i].getMetaType().getTypeName();
- }
- return signature;
- }
-
- /**
- * This does not have a meaningful implementation because the target
- * is unknown. A runtime aspect that understand the context of this
- * operation needs to perform the invocation.
- */
- public MetaValue invoke(MetaValue... param)
- {
- return null;
- }
-
- public String toString()
- {
- StringBuilder tmp = new StringBuilder();
- tmp.append("ManagedOperation(name=");
- tmp.append(name);
- tmp.append(",description=");
- tmp.append(description);
- tmp.append(",impact=");
- tmp.append(impact);
- tmp.append(")");
-
- return tmp.toString();
- }
-
-}
Copied: projects/jboss-man/tags/2.1.0.CR7/managed/src/main/java/org/jboss/managed/plugins/ManagedOperationImpl.java (from rev 87004, projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/plugins/ManagedOperationImpl.java)
===================================================================
--- projects/jboss-man/tags/2.1.0.CR7/managed/src/main/java/org/jboss/managed/plugins/ManagedOperationImpl.java (rev 0)
+++ projects/jboss-man/tags/2.1.0.CR7/managed/src/main/java/org/jboss/managed/plugins/ManagedOperationImpl.java 2009-04-08 21:47:06 UTC (rev 87006)
@@ -0,0 +1,175 @@
+/*
+ * 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.managed.plugins;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.managed.api.ManagedOperation;
+import org.jboss.managed.api.ManagedParameter;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.MetaValue;
+
+/**
+ * A default implementation of ManagedOperation
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class ManagedOperationImpl implements ManagedOperation
+{
+ private static final long serialVersionUID = 1;
+ private String description;
+ private Impact impact;
+ private String name;
+ private ManagedParameter[] parameters;
+ private MetaType returnType;
+ /** The transient attachments map */
+ private transient Map<String, Object> transientAttachments;
+
+ public ManagedOperationImpl(String name, String description)
+ {
+ this(description, name, Impact.Unknown, new ManagedParameter[0], SimpleMetaType.VOID);
+ }
+ public ManagedOperationImpl(String name, String description, Impact impact,
+ ManagedParameter[] parameters, MetaType returnType)
+ {
+ super();
+ this.description = description;
+ this.impact = impact;
+ this.name = name;
+ this.setParameters(parameters);
+ this.returnType = returnType;
+ }
+
+ public String getDescription()
+ {
+ return description;
+ }
+
+ public void setDescription(String description)
+ {
+ this.description = description;
+ }
+
+ public Impact getImpact()
+ {
+ return impact;
+ }
+
+ public void setImpact(Impact impact)
+ {
+ this.impact = impact;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public ManagedParameter[] getParameters()
+ {
+ return parameters;
+ }
+
+ public void setParameters(ManagedParameter[] parameters)
+ {
+ this.parameters = parameters;
+ if(this.parameters == null)
+ this.parameters = new ManagedParameter[0];
+ }
+
+ public MetaType getReturnType()
+ {
+ return returnType;
+ }
+
+ public void setReturnType(MetaType returnType)
+ {
+ this.returnType = returnType;
+ }
+
+
+ public String[] getReflectionSignature()
+ {
+ String[] signature = new String[parameters.length];
+ for(int i=0; i < parameters.length; i++)
+ {
+ signature[i] = parameters[i].getMetaType().getTypeName();
+ }
+ return signature;
+ }
+
+ /**
+ * This does not have a meaningful implementation because the target
+ * is unknown. A runtime aspect that understand the context of this
+ * operation needs to perform the invocation.
+ */
+ public MetaValue invoke(MetaValue... param)
+ {
+ return null;
+ }
+
+ public String toString()
+ {
+ StringBuilder tmp = new StringBuilder();
+ tmp.append("ManagedOperation(name=");
+ tmp.append(name);
+ tmp.append(",description=");
+ tmp.append(description);
+ tmp.append(",impact=");
+ tmp.append(impact);
+ tmp.append(")");
+
+ return tmp.toString();
+ }
+
+ public <T> T getTransientAttachment(Class<T> expectedType)
+ {
+ T tvalue = null;
+ Object value = getTransientAttachment(expectedType.getName());
+ if(value != null)
+ tvalue = expectedType.cast(value);
+ return tvalue;
+ }
+
+ public Object getTransientAttachment(String name)
+ {
+ Object value = null;
+ if(transientAttachments != null)
+ value = transientAttachments.get(name);
+ return value;
+ }
+
+ public synchronized void setTransientAttachment(String name, Object attachment)
+ {
+ if(transientAttachments == null)
+ transientAttachments = new HashMap<String, Object>();
+ transientAttachments.put(name, attachment);
+ }
+}
Deleted: projects/jboss-man/tags/2.1.0.CR7/managed/src/main/java/org/jboss/managed/plugins/ManagedParameterImpl.java
===================================================================
--- projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/plugins/ManagedParameterImpl.java 2009-04-08 21:28:11 UTC (rev 87000)
+++ projects/jboss-man/tags/2.1.0.CR7/managed/src/main/java/org/jboss/managed/plugins/ManagedParameterImpl.java 2009-04-08 21:47:06 UTC (rev 87006)
@@ -1,328 +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.managed.plugins;
-
-import java.io.IOException;
-import java.io.InvalidObjectException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
-import java.lang.annotation.Annotation;
-import java.util.Map;
-import java.util.Set;
-
-import org.jboss.managed.api.Fields;
-import org.jboss.managed.api.ManagedParameter;
-import org.jboss.metatype.api.types.MetaType;
-import org.jboss.metatype.api.values.MetaValue;
-import org.jboss.metatype.api.values.SimpleValue;
-
-/**
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public class ManagedParameterImpl implements ManagedParameter
-{
- private static final long serialVersionUID = 1;
- private static final int VERSION1 = 1;
- /** The serialization version used by writeObject */
- private static final int STREAM_VERSION = VERSION1;
- /** The fields */
- private Fields fields;
-
- /** The property name */
- private transient String name;
-
- /**
- * Create a new ManagedProperty that is not associated to
- * a ManagedObject.
- *
- * @param name the managed property name
- * @throws IllegalArgumentException for null fields or
- * missing Fields.NAME
- */
- public ManagedParameterImpl(String name)
- {
- this(new DefaultFieldsImpl(name));
- }
-
- /**
- * Create a new ManagedProperty that is not associated to
- * a ManagedObject.
- *
- * @param fields the fields
- * @throws IllegalArgumentException for null fields or
- * missing Fields.NAME
- */
- public ManagedParameterImpl(Fields fields)
- {
- init(fields);
- }
-
- public Fields getFields()
- {
- return fields;
- }
-
- // TODO general reconstruction code for metatypes
- @SuppressWarnings("unchecked")
- public <T> T getField(String fieldName, Class<T> expected)
- {
- if (fieldName == null)
- throw new IllegalArgumentException("Null field name");
- if (expected == null)
- throw new IllegalArgumentException("Null expected type");
-
- Object field = getFields().getField(fieldName);
-
- if (field == null)
- return null;
-
- if (expected.isInstance(field))
- return expected.cast(field);
-
- if (field instanceof SimpleValue)
- {
- SimpleValue value = (SimpleValue) field;
- Object result = value.getValue();
- if (result == null)
- return null;
- return expected.cast(result);
- }
-
- throw new IllegalStateException("Field " + fieldName + " with value " + field + " is not of the expected type: " + expected.getName());
- }
-
- // TODO metaType stuff
- public void setField(String fieldName, Serializable value)
- {
- if (fieldName == null)
- throw new IllegalArgumentException("Null field name");
-
- getFields().setField(fieldName, value);
- }
-
- public String getName()
- {
- return name;
- }
-
- public String getDescription()
- {
- return getField(Fields.DESCRIPTION, String.class);
- }
-
- /**
- * Set the description
- *
- * @param description the description
- */
- public void setDescription(String description)
- {
- setField(Fields.DESCRIPTION, description);
- }
-
-
- /**
- * Get the annotations associated with the property
- * @return the annotations associated with the property
- */
- @SuppressWarnings("unchecked")
- public Map<String, Annotation> getAnnotations()
- {
- Object set = getField(Fields.ANNOTATIONS, Object.class);
- return (Map<String, Annotation>) set;
- }
- public void setAnnotations(Map<String, Annotation> annotations)
- {
- setField(Fields.ANNOTATIONS, (Serializable) annotations);
- }
-
- public MetaType getMetaType()
- {
- return getField(Fields.META_TYPE, MetaType.class);
- }
-
- /**
- * Set the meta type
- *
- * @param type the meta type
- */
- public void setMetaType(MetaType type)
- {
- setField(Fields.META_TYPE, type);
- }
-
- public MetaValue getValue()
- {
- return getField(Fields.VALUE, MetaValue.class);
- }
-
- public void setValue(MetaValue value)
- {
- setField(Fields.VALUE, value);
- }
-
- @SuppressWarnings("unchecked")
- public Set<MetaValue> getLegalValues()
- {
- return getField(Fields.LEGAL_VALUES, Set.class);
- }
-
- /**
- * Set the legal values
- *
- * @param values the values
- */
- public void setLegalValues(Set<MetaValue> values)
- {
- setField(Fields.LEGAL_VALUES, (Serializable)values);
- }
-
- public Comparable<?> getMinimumValue()
- {
- return getField(Fields.MINIMUM_VALUE, Comparable.class);
- }
-
- /**
- * Set the minimum value
- *
- * @param value the value
- */
- public void setMinimumValue(Comparable<?> value)
- {
- setField(Fields.MINIMUM_VALUE, (Serializable)value);
- }
-
- public Comparable<?> getMaximumValue()
- {
- return getField(Fields.MAXIMUM_VALUE, Comparable.class);
- }
-
- /**
- * Set the maximum value
- *
- * @param value the value
- */
- public void setMaximumValue(Comparable<?> value)
- {
- setField(Fields.MAXIMUM_VALUE, (Serializable)value);
- }
-
- public String checkValidValue(MetaValue value)
- {
- // TODO check min/max/etc.
- return null;
- }
-
- @Override
- public String toString()
- {
- StringBuilder tmp = new StringBuilder("ManagedProperty");
- tmp.append('{');
- tmp.append(name);
- tmp.append(",metaType=");
- tmp.append(this.getMetaType());
- tmp.append('}');
- return tmp.toString();
- }
-
- @Override
- public int hashCode()
- {
- return name.hashCode();
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj == this)
- return true;
- if (obj == null || obj instanceof ManagedParameter == false)
- return false;
-
- ManagedParameter other = (ManagedParameter) obj;
- return getName().equals(other.getName());
- }
-
- /**
- * Initialise a ManagedPropertyImpl.
- *
- * @param managedObject the managed object, may be null
- * @param fields the fields
- * @throws IllegalArgumentException for null fields or
- * missing Fields.NAME
- */
- private void init(Fields fields)
- {
- if (fields == null)
- throw new IllegalArgumentException("Null fields");
-
- this.fields = fields;
-
- name = getField(Fields.NAME, String.class);
- if (name == null)
- throw new IllegalArgumentException("No " + Fields.NAME + " in fields");
- }
-
- /**
- * Read from a stream
- *
- * @param in the stream
- * @throws IOException for IO problem
- * @throws ClassNotFoundException for a classloading problem
- */
- private void readObject(ObjectInputStream in)
- throws IOException, ClassNotFoundException
- {
- int version = in.readInt();
- if( version == VERSION1 )
- readVersion1(in);
- else
- throw new InvalidObjectException("Unknown version="+version);
- }
- /**
- * Write out the property fields
- * @param out
- * @throws IOException
- */
- private void writeObject(ObjectOutputStream out)
- throws IOException
- {
- out.writeInt(STREAM_VERSION);
- out.writeObject(fields);
- }
-
- /**
- * The VERSION1 expected format:
- * - Fields fields
- */
- private void readVersion1(ObjectInputStream in)
- throws IOException, ClassNotFoundException
- {
- fields = (Fields) in.readObject();
- name = getField(Fields.NAME, String.class);
- if (name == null)
- throw new IOException("No " + Fields.NAME + " in fields");
- }
-
-}
Copied: projects/jboss-man/tags/2.1.0.CR7/managed/src/main/java/org/jboss/managed/plugins/ManagedParameterImpl.java (from rev 87004, projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/plugins/ManagedParameterImpl.java)
===================================================================
--- projects/jboss-man/tags/2.1.0.CR7/managed/src/main/java/org/jboss/managed/plugins/ManagedParameterImpl.java (rev 0)
+++ projects/jboss-man/tags/2.1.0.CR7/managed/src/main/java/org/jboss/managed/plugins/ManagedParameterImpl.java 2009-04-08 21:47:06 UTC (rev 87006)
@@ -0,0 +1,355 @@
+/*
+ * 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.managed.plugins;
+
+import java.io.IOException;
+import java.io.InvalidObjectException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.lang.annotation.Annotation;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.managed.api.Fields;
+import org.jboss.managed.api.ManagedParameter;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValue;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class ManagedParameterImpl implements ManagedParameter
+{
+ private static final long serialVersionUID = 1;
+ private static final int VERSION1 = 1;
+ /** The serialization version used by writeObject */
+ private static final int STREAM_VERSION = VERSION1;
+ /** The fields */
+ private Fields fields;
+
+ /** The parameter name */
+ private transient String name;
+ /** The transient attachments map */
+ private transient Map<String, Object> transientAttachments;
+
+ /**
+ * Create a new ManagedProperty that is not associated to
+ * a ManagedObject.
+ *
+ * @param name the managed property name
+ * @throws IllegalArgumentException for null fields or
+ * missing Fields.NAME
+ */
+ public ManagedParameterImpl(String name)
+ {
+ this(new DefaultFieldsImpl(name));
+ }
+
+ /**
+ * Create a new ManagedProperty that is not associated to
+ * a ManagedObject.
+ *
+ * @param fields the fields
+ * @throws IllegalArgumentException for null fields or
+ * missing Fields.NAME
+ */
+ public ManagedParameterImpl(Fields fields)
+ {
+ init(fields);
+ }
+
+ public Fields getFields()
+ {
+ return fields;
+ }
+
+ // TODO general reconstruction code for metatypes
+ @SuppressWarnings("unchecked")
+ public <T> T getField(String fieldName, Class<T> expected)
+ {
+ if (fieldName == null)
+ throw new IllegalArgumentException("Null field name");
+ if (expected == null)
+ throw new IllegalArgumentException("Null expected type");
+
+ Object field = getFields().getField(fieldName);
+
+ if (field == null)
+ return null;
+
+ if (expected.isInstance(field))
+ return expected.cast(field);
+
+ if (field instanceof SimpleValue)
+ {
+ SimpleValue value = (SimpleValue) field;
+ Object result = value.getValue();
+ if (result == null)
+ return null;
+ return expected.cast(result);
+ }
+
+ throw new IllegalStateException("Field " + fieldName + " with value " + field + " is not of the expected type: " + expected.getName());
+ }
+
+ // TODO metaType stuff
+ public void setField(String fieldName, Serializable value)
+ {
+ if (fieldName == null)
+ throw new IllegalArgumentException("Null field name");
+
+ getFields().setField(fieldName, value);
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public String getDescription()
+ {
+ return getField(Fields.DESCRIPTION, String.class);
+ }
+
+ /**
+ * Set the description
+ *
+ * @param description the description
+ */
+ public void setDescription(String description)
+ {
+ setField(Fields.DESCRIPTION, description);
+ }
+
+
+ /**
+ * Get the annotations associated with the property
+ * @return the annotations associated with the property
+ */
+ @SuppressWarnings("unchecked")
+ public Map<String, Annotation> getAnnotations()
+ {
+ Object set = getField(Fields.ANNOTATIONS, Object.class);
+ return (Map<String, Annotation>) set;
+ }
+ public void setAnnotations(Map<String, Annotation> annotations)
+ {
+ setField(Fields.ANNOTATIONS, (Serializable) annotations);
+ }
+
+ public MetaType getMetaType()
+ {
+ return getField(Fields.META_TYPE, MetaType.class);
+ }
+
+ /**
+ * Set the meta type
+ *
+ * @param type the meta type
+ */
+ public void setMetaType(MetaType type)
+ {
+ setField(Fields.META_TYPE, type);
+ }
+
+ public MetaValue getValue()
+ {
+ return getField(Fields.VALUE, MetaValue.class);
+ }
+
+ public void setValue(MetaValue value)
+ {
+ setField(Fields.VALUE, value);
+ }
+
+ @SuppressWarnings("unchecked")
+ public Set<MetaValue> getLegalValues()
+ {
+ return getField(Fields.LEGAL_VALUES, Set.class);
+ }
+
+ /**
+ * Set the legal values
+ *
+ * @param values the values
+ */
+ public void setLegalValues(Set<MetaValue> values)
+ {
+ setField(Fields.LEGAL_VALUES, (Serializable)values);
+ }
+
+ public Comparable<?> getMinimumValue()
+ {
+ return getField(Fields.MINIMUM_VALUE, Comparable.class);
+ }
+
+ /**
+ * Set the minimum value
+ *
+ * @param value the value
+ */
+ public void setMinimumValue(Comparable<?> value)
+ {
+ setField(Fields.MINIMUM_VALUE, (Serializable)value);
+ }
+
+ public Comparable<?> getMaximumValue()
+ {
+ return getField(Fields.MAXIMUM_VALUE, Comparable.class);
+ }
+
+ /**
+ * Set the maximum value
+ *
+ * @param value the value
+ */
+ public void setMaximumValue(Comparable<?> value)
+ {
+ setField(Fields.MAXIMUM_VALUE, (Serializable)value);
+ }
+
+ public String checkValidValue(MetaValue value)
+ {
+ // TODO check min/max/etc.
+ return null;
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuilder tmp = new StringBuilder("ManagedProperty");
+ tmp.append('{');
+ tmp.append(name);
+ tmp.append(",metaType=");
+ tmp.append(this.getMetaType());
+ tmp.append('}');
+ return tmp.toString();
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return name.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ return true;
+ if (obj == null || obj instanceof ManagedParameter == false)
+ return false;
+
+ ManagedParameter other = (ManagedParameter) obj;
+ return getName().equals(other.getName());
+ }
+
+ public <T> T getTransientAttachment(Class<T> expectedType)
+ {
+ T tvalue = null;
+ Object value = getTransientAttachment(expectedType.getName());
+ if(value != null)
+ tvalue = expectedType.cast(value);
+ return tvalue;
+ }
+
+ public Object getTransientAttachment(String name)
+ {
+ Object value = null;
+ if(transientAttachments != null)
+ value = transientAttachments.get(name);
+ return value;
+ }
+
+ public synchronized void setTransientAttachment(String name, Object attachment)
+ {
+ if(transientAttachments == null)
+ transientAttachments = new HashMap<String, Object>();
+ transientAttachments.put(name, attachment);
+ }
+
+ /**
+ * Initialise a ManagedPropertyImpl.
+ *
+ * @param managedObject the managed object, may be null
+ * @param fields the fields
+ * @throws IllegalArgumentException for null fields or
+ * missing Fields.NAME
+ */
+ private void init(Fields fields)
+ {
+ if (fields == null)
+ throw new IllegalArgumentException("Null fields");
+
+ this.fields = fields;
+
+ name = getField(Fields.NAME, String.class);
+ if (name == null)
+ throw new IllegalArgumentException("No " + Fields.NAME + " in fields");
+ }
+
+ /**
+ * Read from a stream
+ *
+ * @param in the stream
+ * @throws IOException for IO problem
+ * @throws ClassNotFoundException for a classloading problem
+ */
+ private void readObject(ObjectInputStream in)
+ throws IOException, ClassNotFoundException
+ {
+ int version = in.readInt();
+ if( version == VERSION1 )
+ readVersion1(in);
+ else
+ throw new InvalidObjectException("Unknown version="+version);
+ }
+ /**
+ * Write out the property fields
+ * @param out
+ * @throws IOException
+ */
+ private void writeObject(ObjectOutputStream out)
+ throws IOException
+ {
+ out.writeInt(STREAM_VERSION);
+ out.writeObject(fields);
+ }
+
+ /**
+ * The VERSION1 expected format:
+ * - Fields fields
+ */
+ private void readVersion1(ObjectInputStream in)
+ throws IOException, ClassNotFoundException
+ {
+ fields = (Fields) in.readObject();
+ name = getField(Fields.NAME, String.class);
+ if (name == null)
+ throw new IOException("No " + Fields.NAME + " in fields");
+ }
+
+}
Deleted: projects/jboss-man/tags/2.1.0.CR7/managed/src/main/java/org/jboss/managed/plugins/factory/AbstractManagedObjectFactory.java
===================================================================
--- projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/plugins/factory/AbstractManagedObjectFactory.java 2009-04-08 21:28:11 UTC (rev 87000)
+++ projects/jboss-man/tags/2.1.0.CR7/managed/src/main/java/org/jboss/managed/plugins/factory/AbstractManagedObjectFactory.java 2009-04-08 21:47:06 UTC (rev 87006)
@@ -1,1070 +0,0 @@
-/*
-* 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.managed.plugins.factory;
-
-import java.io.Serializable;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Constructor;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.WeakHashMap;
-
-import org.jboss.beans.info.spi.BeanInfo;
-import org.jboss.beans.info.spi.PropertyInfo;
-import org.jboss.config.spi.Configuration;
-import org.jboss.logging.Logger;
-import org.jboss.managed.api.Fields;
-import org.jboss.managed.api.ManagedObject;
-import org.jboss.managed.api.ManagedOperation;
-import org.jboss.managed.api.ManagedParameter;
-import org.jboss.managed.api.ManagedProperty;
-import org.jboss.managed.api.MutableManagedObject;
-import org.jboss.managed.api.ManagedOperation.Impact;
-import org.jboss.managed.api.annotation.ActivationPolicy;
-import org.jboss.managed.api.annotation.AnnotationDefaults;
-import org.jboss.managed.api.annotation.ConstraintsPopulatorFactory;
-import org.jboss.managed.api.annotation.FieldsFactory;
-import org.jboss.managed.api.annotation.ManagementComponent;
-import org.jboss.managed.api.annotation.ManagementConstants;
-import org.jboss.managed.api.annotation.ManagementDeployment;
-import org.jboss.managed.api.annotation.ManagementObject;
-import org.jboss.managed.api.annotation.ManagementObjectID;
-import org.jboss.managed.api.annotation.ManagementObjectRef;
-import org.jboss.managed.api.annotation.ManagementOperation;
-import org.jboss.managed.api.annotation.ManagementParameter;
-import org.jboss.managed.api.annotation.ManagementProperties;
-import org.jboss.managed.api.annotation.ManagementProperty;
-import org.jboss.managed.api.annotation.ManagementPropertyFactory;
-import org.jboss.managed.api.annotation.ManagementRuntimeRef;
-import org.jboss.managed.api.annotation.RunStateProperty;
-import org.jboss.managed.api.annotation.ViewUse;
-import org.jboss.managed.api.factory.ManagedObjectFactory;
-import org.jboss.managed.api.factory.ManagedObjectDefinition;
-import org.jboss.managed.plugins.DefaultFieldsImpl;
-import org.jboss.managed.plugins.ManagedObjectImpl;
-import org.jboss.managed.plugins.ManagedOperationImpl;
-import org.jboss.managed.plugins.ManagedParameterImpl;
-import org.jboss.managed.plugins.WritethroughManagedPropertyImpl;
-import org.jboss.managed.spi.factory.InstanceClassFactory;
-import org.jboss.managed.spi.factory.ManagedObjectBuilder;
-import org.jboss.managed.spi.factory.ManagedObjectPopulator;
-import org.jboss.managed.spi.factory.ManagedParameterConstraintsPopulator;
-import org.jboss.managed.spi.factory.ManagedParameterConstraintsPopulatorFactory;
-import org.jboss.managed.spi.factory.ManagedPropertyConstraintsPopulator;
-import org.jboss.managed.spi.factory.ManagedPropertyConstraintsPopulatorFactory;
-import org.jboss.metadata.spi.MetaData;
-import org.jboss.metadata.spi.signature.FieldSignature;
-import org.jboss.metadata.spi.signature.MethodSignature;
-import org.jboss.metadata.spi.signature.Signature;
-import org.jboss.metatype.api.annotations.MetaMapping;
-import org.jboss.metatype.api.annotations.MetaMappingFactory;
-import org.jboss.metatype.api.types.ArrayMetaType;
-import org.jboss.metatype.api.types.CollectionMetaType;
-import org.jboss.metatype.api.types.GenericMetaType;
-import org.jboss.metatype.api.types.MetaType;
-import org.jboss.metatype.api.types.MetaTypeFactory;
-import org.jboss.metatype.api.values.MetaValueFactory;
-import org.jboss.metatype.spi.values.MetaMapper;
-import org.jboss.metatype.spi.values.MetaMapperFactory;
-import org.jboss.reflect.spi.AnnotatedInfo;
-import org.jboss.reflect.spi.ClassInfo;
-import org.jboss.reflect.spi.MethodInfo;
-import org.jboss.reflect.spi.ParameterInfo;
-import org.jboss.reflect.spi.TypeInfo;
-
-/**
- * The base ManagedObjectFactory implementation.
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public class AbstractManagedObjectFactory extends ManagedObjectFactory
- implements ManagedObjectBuilder
-{
- private static final Logger log = Logger.getLogger(AbstractManagedObjectFactory.class);
-
- /** The configuration */
- private static final Configuration configuration = PropertyConfigurationAccess.getConfiguration();
-
- /** The managed object meta type */
- public static final GenericMetaType MANAGED_OBJECT_META_TYPE = new GenericMetaType(ManagedObject.class.getName(), ManagedObject.class.getName());
-
- /** The meta type factory */
- private MetaTypeFactory metaTypeFactory = MetaTypeFactory.getInstance();
-
- /** The meta value factory */
- private MetaValueFactory metaValueFactory = MetaValueFactory.getInstance();
- /** A default InstanceClassFactory used when there is no explicit ICF for a given class */
- private InstanceClassFactory<?> defaultInstanceFactory;
- /** A default ManagedObjectPopulator used when there is no explicit ManagedObjectBuilder for a given class */
- private ManagedObjectPopulator<?> defaultManagedObjectPopulator;
-
- /** The managed object builders */
- private Map<Class<?>, ManagedObjectBuilder> builders = new WeakHashMap<Class<?>, ManagedObjectBuilder>();
-
- /** The instance to class factories */
- private Map<Class<?>, InstanceClassFactory<?>> instanceFactories = new WeakHashMap<Class<?>, InstanceClassFactory<?>>();
-
- /**
- * Create a ManagedProperty by looking to the factory for ctor(Fields)
- * @param factory - the ManagedProperty implementation class
- * @param fields - the fields to pass to the ctor
- * @return the managed property if successful, null otherwise
- */
- public static ManagedProperty createManagedProperty(Class<? extends ManagedProperty> factory, Fields fields)
- {
- ManagedProperty property = null;
- try
- {
- Class<?>[] sig = {Fields.class};
- Constructor<? extends ManagedProperty> ctor = factory.getConstructor(sig);
- Object[] args = {fields};
- property = ctor.newInstance(args);
- }
- catch(Exception e)
- {
- log.debug("Failed to create ManagedProperty", e);
- }
- return property;
- }
-
- /**
- * Create an AbstractManagedObjectFactory that uses an AbstractInstanceClassFactory
- * as the defaultInstanceFactory and AbstractManagedObjectPopulator as the
- * defaultManagedObjectPopulator. The MetaTypeFactory, MetaValueFactory are
- * obtained from the respective getInstance() factory methods.
- */
- public AbstractManagedObjectFactory()
- {
- // Create an AbstractInstanceClassFactory as the default ICF
- DefaultInstanceClassFactory icf = new DefaultInstanceClassFactory();
- icf.setMof(this);
- defaultInstanceFactory = icf;
- // Create an AbstractManagedObjectPopulator as the default
- defaultManagedObjectPopulator = new AbstractManagedObjectPopulator<Serializable>(configuration, icf, instanceFactories);
- }
- /**
- * Create an AbstractManagedObjectFactory the given factories, supporting
- * information.
- *
- * @param metaTypeFactory
- * @param metaValueFactory
- * @param defaultInstanceFactory
- * @param defaultManagedObjectPopulator
- * @param builders
- * @param instanceFactories
- */
- public AbstractManagedObjectFactory(MetaTypeFactory metaTypeFactory,
- MetaValueFactory metaValueFactory,
- InstanceClassFactory<?> defaultInstanceFactory,
- ManagedObjectPopulator<?> defaultManagedObjectPopulator,
- Map<Class<?>, ManagedObjectBuilder> builders,
- Map<Class<?>, InstanceClassFactory<?>> instanceFactories)
- {
- this.metaTypeFactory = metaTypeFactory;
- this.metaValueFactory = metaValueFactory;
- this.defaultInstanceFactory = defaultInstanceFactory;
- this.defaultManagedObjectPopulator = defaultManagedObjectPopulator;
- this.builders = builders;
- this.instanceFactories = instanceFactories;
- }
-
- /**
- * Add managed object definition.
- *
- * @param definition the MO definition
- */
- public void addManagedObjectDefinition(ManagedObjectDefinition definition)
- {
- if (definition == null || definition.isValid() == false)
- throw new IllegalArgumentException("Invalid MO definition: " + definition);
-
- setBuilder(definition.getType(), definition.getBuilder());
- }
-
- /**
- * Remove managed object definition.
- *
- * @param definition the MO definition
- */
- public void removeManagedObjectDefinition(ManagedObjectDefinition definition)
- {
- if (definition == null)
- return;
-
- setBuilder(definition.getType(), null);
- }
-
- /**
- * Get the configuration
- *
- * @return the configuration
- */
- public Configuration getConfiguration()
- {
- return configuration;
- }
-
-
- public MetaTypeFactory getMetaTypeFactory()
- {
- return metaTypeFactory;
- }
-
- public void setMetaTypeFactory(MetaTypeFactory metaTypeFactory)
- {
- this.metaTypeFactory = metaTypeFactory;
- }
-
- public MetaValueFactory getMetaValueFactory()
- {
- return metaValueFactory;
- }
-
- public void setMetaValueFactory(MetaValueFactory metaValueFactory)
- {
- this.metaValueFactory = metaValueFactory;
- }
-
- public Map<Class<?>, ManagedObjectBuilder> getBuilders()
- {
- return builders;
- }
-
- public void setBuilders(Map<Class<?>, ManagedObjectBuilder> builders)
- {
- this.builders = builders;
- }
-
- public Map<Class<?>, InstanceClassFactory<?>> getInstanceFactories()
- {
- return instanceFactories;
- }
-
- public void setInstanceFactories(
- Map<Class<?>, InstanceClassFactory<?>> instanceFactories)
- {
- this.instanceFactories = instanceFactories;
- }
-
- /**
- * Get the default InstanceClassFactory
- * @return the current default InstanceClassFactory
- */
- public InstanceClassFactory<?> getDefaultInstanceFactory()
- {
- return defaultInstanceFactory;
- }
- /**
- * Set the default InstanceClassFactory. This is used when there is not
- * match an exact match by the {@linkplain #getInstanceClassFactory(Class)}
- * factory method.
- *
- * @param defaultInstanceFactory the default InstanceClassFactory to fall
- * back to. It may be null if no default should be used.
- */
- public void setDefaultInstanceFactory(
- InstanceClassFactory<? extends Serializable> defaultInstanceFactory)
- {
- this.defaultInstanceFactory = defaultInstanceFactory;
- }
-
-
- public ManagedObjectPopulator<?> getDefaultManagedObjectPopulator()
- {
- return defaultManagedObjectPopulator;
- }
-
- /**
- * A default implementation of ManagedObjectPopulator that is used when
- * there is no ManagedObjectBuilder registered for a given type.
- * @see #getBuilder(Class)
- * @param defaultManagedObjectPopulator
- */
- public void setDefaultManagedObjectPopulator(
- ManagedObjectPopulator<? extends Serializable> defaultManagedObjectPopulator)
- {
- this.defaultManagedObjectPopulator = defaultManagedObjectPopulator;
- }
-
- @Override
- public <T> ManagedObject createManagedObject(Class<T> clazz, MetaData metaData)
- {
- if (clazz == null)
- throw new IllegalArgumentException("Null class");
-
- ManagedObject result = createSkeletonManagedObject(clazz, metaData);
- ManagedObjectPopulator<T> populator = getPopulator(clazz);
- populator.createObject(result, clazz, metaData);
-
- return result;
- }
-
- public ManagedObject initManagedObject(Object instance, Class<?> instanceType,
- MetaData metaData, String name, String nameType)
- {
- if (instance == null)
- throw new IllegalArgumentException("instance cannot be null");
-
- Class<?> clazz = instance.getClass();
- InstanceClassFactory icf = defaultInstanceFactory;
- if(instanceType != null && instanceType != clazz)
- icf = getInstanceClassFactory(instanceType, metaData);
- if(icf == defaultInstanceFactory)
- icf = getInstanceClassFactory(clazz, metaData);
-
- Class<Object> moClass;
- try
- {
- moClass = icf.getManagedObjectClass(instance);
- }
- catch(ClassNotFoundException e)
- {
- log.debug("Failed to load class for ManagedObject", e);
- return null;
- }
- if(moClass == null)
- {
- log.debug("ICF returned null class: "+instance);
- return null;
- }
-
- ManagedObject result = createSkeletonManagedObject(moClass, metaData);
- if (result == null)
- {
- log.debug("Null ManagedObject created for: "+moClass);
- return null;
- }
- log.debug("Created skeleton ManagedObject: "+result);
-
- if(result instanceof MutableManagedObject)
- {
- MutableManagedObject mmo = (MutableManagedObject) result;
- ManagedObjectPopulator<Object> populator = getPopulator(moClass);
- populator.populateManagedObject(mmo, instance, metaData);
- }
-
- return result;
- }
-
- @Override
- public void setBuilder(Class<?> clazz, ManagedObjectBuilder builder)
- {
- synchronized (builders)
- {
- if (builder == null)
- builders.remove(clazz);
- else
- builders.put(clazz, builder);
- }
- }
-
- @Override
- public <T> void setInstanceClassFactory(Class<T> clazz, InstanceClassFactory<T> factory)
- {
- synchronized (instanceFactories)
- {
- if (factory == null)
- {
- instanceFactories.remove(clazz);
- log.debug("Removed ICF for: "+clazz);
- }
- else
- {
- instanceFactories.put(clazz, factory);
- log.debug("Set ICF for: "+clazz+", to: "+factory);
- }
- }
- }
-
- /**
- * Create a skeleton managed object
- *
- * @param <T> the type
- * @param clazz the clazz
- * @return the skeleton managed object, null if clazz is not
- * marked as a ManagementObject.
- * {@linkplain ManagementObject}
- */
- protected <T> ManagedObject createSkeletonManagedObject(Class<T> clazz, MetaData metaData)
- {
- if (clazz == null)
- throw new IllegalArgumentException("Null class");
-
- ManagedObjectBuilder builder = getBuilder(clazz);
- return builder.buildManagedObject(clazz, metaData);
- }
-
- /**
- * The ManagedObjectBuilder.buildManagedObject implementation. This is based
- * on the org.jboss.managed.api.annotation.* package annotations.
- * @param clazz the attachment class
- * @param metaData - the optional metadata repository accessor used to query
- * for management annotation overrides/additions to the clazz
- * @return the ManagementObject if clazz is properly annotated, null if
- * it does not have a ManagementObject annotation on the class or metaData.
- * The BeanInfo used by this method is stored as a transient attachment
- * under the BeanInfo.class.getName() ket.
- */
- @SuppressWarnings("unchecked")
- public ManagedObject buildManagedObject(Class<?> clazz, MetaData metaData)
- {
- boolean trace = log.isTraceEnabled();
- BeanInfo beanInfo = configuration.getBeanInfo(clazz);
- ClassInfo classInfo = beanInfo.getClassInfo();
-
- ManagementObject managementObject = getAnnotation(ManagementObject.class, classInfo, metaData);
- if( managementObject == null )
- {
- if (trace)
- log.trace("No ManagementObject annotation, skipping ManagedObject for class: "+clazz);
- // Skip the ManagedObject creation
- return null;
- }
-
- // If a targetInterface exists, rebuild the BeanInfo from that
- Class<?> targetInterface = managementObject.targetInterface();
- if(targetInterface != Object.class)
- {
- beanInfo = getBeanInfo(targetInterface);
- classInfo = beanInfo.getClassInfo();
- }
- HashMap<String, Annotation> moAnnotations = new HashMap<String, Annotation>();
- moAnnotations.put(ManagementObject.class.getName(), managementObject);
- ManagementDeployment mnagementDeployment = getAnnotation(ManagementDeployment.class, classInfo, metaData);
- if(mnagementDeployment != null)
- moAnnotations.put(ManagementDeployment.class.getName(), mnagementDeployment);
- ManagementObjectID moID = getAnnotation(ManagementObjectID.class, classInfo, metaData);
- if (moID != null)
- moAnnotations.put(ManagementObjectID.class.getName(), moID);
-
- // Process the ManagementObject fields
- boolean isRuntime = managementObject.isRuntime();
- String name = classInfo.getName();
- String nameType = null;
- String attachmentName = classInfo.getName();
- Class<? extends Fields> moFieldsFactory = null;
- ConstraintsPopulatorFactory moCPF = null;
- Class<? extends ManagedPropertyConstraintsPopulatorFactory> moConstraintsFactory = null;
- Class<? extends ManagedProperty> moPropertyFactory = null;
- if (managementObject != null)
- {
- name = managementObject.name();
- if (name.length() == 0 || name.equals(ManagementConstants.GENERATED))
- name = classInfo.getName();
- nameType = managementObject.type();
- if (nameType.length() == 0)
- nameType = null;
- attachmentName = managementObject.attachmentName();
- if (attachmentName.length() == 0)
- attachmentName = classInfo.getName();
- // Check for a component specification
- ManagementComponent mc = managementObject.componentType();
- // Work around JBMDR-51 by checking type/subtype
- // if (mc.equals(AnnotationDefaults.COMP_TYPE) == false)
- if (mc.type().length() > 0 || mc.subtype().length() > 0)
- {
- log.debug("ManagedObject("+name+") is ManagedComponent type: "+mc);
- moAnnotations.put(ManagementComponent.class.getName(), mc);
- }
- // ManagementObject level default factory classes
- FieldsFactory ff = getAnnotation(FieldsFactory.class, classInfo, metaData);
- if(ff != null)
- moFieldsFactory = ff.value();
- moCPF = getAnnotation(ConstraintsPopulatorFactory.class, classInfo, metaData);
- if(moCPF != null)
- moConstraintsFactory = moCPF.value();
- ManagementPropertyFactory mpf = getAnnotation(ManagementPropertyFactory.class, classInfo, metaData);
- if(mpf != null)
- moPropertyFactory = mpf.value();
- }
-
- if (trace)
- {
- log.trace("Building MangedObject(name="+name+",nameType="+nameType
- +",attachmentName="+attachmentName+",isRuntime="+isRuntime+")");
- }
-
- ManagementProperties propertyType = ManagementProperties.ALL;
- Set<String> classProperties = null;
- if (managementObject != null)
- {
- propertyType = managementObject.properties();
- if(propertyType == ManagementProperties.CLASS || propertyType == ManagementProperties.CLASS_AND_EXPLICIT)
- {
- classProperties = new HashSet<String>();
- for(ManagementProperty mp : managementObject.classProperties())
- {
- if(mp.name().length() > 0)
- classProperties.add(mp.name());
- if(mp.mappedName().length() > 0)
- classProperties.add(mp.mappedName());
- }
- }
- }
-
- // Build the ManagedProperties
- Set<ManagedProperty> properties = new HashSet<ManagedProperty>();
-
- Set<PropertyInfo> propertyInfos = beanInfo.getProperties();
- if (propertyInfos != null && propertyInfos.isEmpty() == false)
- {
- for (PropertyInfo propertyInfo : propertyInfos)
- {
- // Ignore the "class" property
- if ("class".equals(propertyInfo.getName()))
- continue;
-
- ManagementProperty managementProperty = getAnnotation(ManagementProperty.class, propertyInfo, metaData);
- ManagementObjectID id = getAnnotation(ManagementObjectID.class, propertyInfo, metaData);
- ManagementObjectRef ref = getAnnotation(ManagementObjectRef.class, propertyInfo, metaData);
- ManagementRuntimeRef runtimeRef = getAnnotation(ManagementRuntimeRef.class, propertyInfo, metaData);
- RunStateProperty rsp = getAnnotation(RunStateProperty.class, propertyInfo, metaData);
- HashMap<String, Annotation> propAnnotations = new HashMap<String, Annotation>();
- if (managementProperty != null)
- propAnnotations.put(ManagementProperty.class.getName(), managementProperty);
- if (id != null)
- {
- propAnnotations.put(ManagementObjectID.class.getName(), id);
- // This overrides the MO nameType
- nameType = id.type();
- }
- if (ref != null)
- propAnnotations.put(ManagementObjectRef.class.getName(), ref);
- if (runtimeRef != null)
- propAnnotations.put(ManagementRuntimeRef.class.getName(), runtimeRef);
- if (rsp != null)
- propAnnotations.put(RunStateProperty.class.getName(), rsp);
-
- // Check whether this property should be included
- boolean includeProperty = false;
- switch(propertyType)
- {
- // Only if the property as a ManagementProperty
- case EXPLICIT:
- includeProperty = managementProperty != null &&
- (managementProperty.ignored() == false);
- break;
- // Only if the property is listed in the classProperties
- case CLASS:
- includeProperty = classProperties.contains(propertyInfo.getName());
- break;
- // Only if the property is listed in the classProperties
- case CLASS_AND_EXPLICIT:
- includeProperty = classProperties.contains(propertyInfo.getName())
- || (managementProperty != null && managementProperty.ignored() == false);
- break;
- // Any property that is not ignored
- case ALL:
- includeProperty = managementProperty == null
- || managementProperty.ignored() == false;
- break;
- }
-
- if (includeProperty)
- {
- Fields fields = null;
- Class<? extends Fields> factory = moFieldsFactory;
- FieldsFactory ff = getAnnotation(FieldsFactory.class, propertyInfo, metaData);
- if(ff != null)
- factory = ff.value();
- if (factory != null)
- {
- try
- {
- fields = factory.newInstance();
- }
- catch (Exception e)
- {
- log.debug("Failed to created Fields", e);
- }
- }
- if (fields == null)
- fields = new DefaultFieldsImpl();
-
- if( propertyInfo instanceof Serializable )
- {
- Serializable info = Serializable.class.cast(propertyInfo);
- fields.setField(Fields.PROPERTY_INFO, info);
- }
-
- String propertyName = propertyInfo.getName();
- if (managementProperty != null)
- propertyName = managementProperty.name();
- if( propertyName.length() == 0 )
- propertyName = propertyInfo.getName();
- fields.setField(Fields.NAME, propertyName);
-
- // This should probably always the the propertyInfo name?
- String mappedName = propertyInfo.getName();
- if (managementProperty != null)
- mappedName = managementProperty.mappedName();
- if( mappedName.length() == 0 )
- mappedName = propertyInfo.getName();
- fields.setField(Fields.MAPPED_NAME, mappedName);
-
- String description = ManagementConstants.GENERATED;
- if (managementProperty != null)
- description = managementProperty.description();
- if (description.equals(ManagementConstants.GENERATED))
- description = propertyName;
- fields.setField(Fields.DESCRIPTION, description);
-
- if (trace)
- {
- log.trace("Building MangedProperty(name="+propertyName
- +",mappedName="+mappedName
- +") ,annotations="+propAnnotations);
- }
-
- boolean mandatory = false;
- if (managementProperty != null)
- mandatory = managementProperty.mandatory();
- if (mandatory)
- fields.setField(Fields.MANDATORY, Boolean.TRUE);
-
- boolean readOnly = propertyInfo.isWritable() == false;
- if (readOnly == false && managementProperty != null)
- readOnly = managementProperty.readOnly();
- if (readOnly)
- fields.setField(Fields.READ_ONLY, Boolean.TRUE);
-
- boolean managed = false;
- if (managementProperty != null)
- managed = managementProperty.managed();
- // View Use
- if (managementProperty != null)
- {
- ViewUse[] use = managementProperty.use();
- fields.setField(Fields.VIEW_USE, use);
- }
- // ActivationPolicy
- ActivationPolicy apolicy = ActivationPolicy.IMMEDIATE;
- if (managementProperty != null)
- {
- apolicy = managementProperty.activationPolicy();
- }
- fields.setField(Fields.ACTIVATION_POLICY, apolicy);
-
- // The managed property type
- MetaType metaType = null;
- MetaMapper<?> metaMapper = null;
- MetaMapping metaMapping = getAnnotation(MetaMapping.class, propertyInfo, metaData);
- MetaMappingFactory metaMappingFactory = getAnnotation(MetaMappingFactory.class, propertyInfo, metaData);
- if(metaMappingFactory != null)
- {
- Class<? extends MetaMapperFactory<?>> mmfClass = metaMappingFactory.value();
- try
- {
- MetaMapperFactory<?> mmf = mmfClass.newInstance();
- String[] args = metaMappingFactory.args();
- if(args.length > 0)
- metaMapper = mmf.newInstance(args);
- else
- metaMapper = mmf.newInstance();
- }
- catch(Exception e)
- {
- log.debug("Failed to create MetaMapperFactory: "+metaMappingFactory, e);
- }
- }
- if(metaMapping != null)
- {
- // Use the mapping for the type
- Class<? extends MetaMapper<?>> mapperClass = metaMapping.value();
- try
- {
- metaMapper = mapperClass.newInstance();
- }
- catch(Exception e)
- {
- log.debug("Failed to create MetaMapper: "+metaMapping, e);
- }
- }
- if(metaMapper != null)
- metaType = metaMapper.getMetaType();
-
- // Determine meta type based on property type
- if(metaType == null)
- {
- if (managed)
- {
- TypeInfo typeInfo = propertyInfo.getType();
- if(typeInfo.isArray())
- metaType = new ArrayMetaType(1, MANAGED_OBJECT_META_TYPE);
- else if (typeInfo.isCollection())
- metaType = new CollectionMetaType(typeInfo.getName(), MANAGED_OBJECT_META_TYPE);
- else
- metaType = MANAGED_OBJECT_META_TYPE;
- }
- else
- {
- metaType = metaTypeFactory.resolve(propertyInfo.getType());
- }
- }
- fields.setField(Fields.META_TYPE, metaType);
- // Property annotations
- if (propAnnotations.isEmpty() == false)
- fields.setField(Fields.ANNOTATIONS, propAnnotations);
-
- // Delegate others (legal values, min/max etc.) to the constraints factory
- try
- {
- Class<? extends ManagedPropertyConstraintsPopulatorFactory> factoryClass = moConstraintsFactory;
- ConstraintsPopulatorFactory cpf = getAnnotation(ConstraintsPopulatorFactory.class, propertyInfo, metaData);
- if(cpf != null)
- factoryClass = cpf.value();
- else
- cpf = moCPF;
- if(factoryClass != null)
- {
- ManagedPropertyConstraintsPopulatorFactory mpcpf = factoryClass.newInstance();
- ManagedPropertyConstraintsPopulator populator = mpcpf.newInstance(cpf.min(), cpf.max(), cpf.legalValues(), cpf.args());
- if (populator != null)
- populator.populateManagedProperty(clazz, propertyInfo, fields);
- }
- }
- catch(Exception e)
- {
- log.debug("Failed to populate constraints for: "+propertyInfo, e);
- }
-
- ManagedProperty property = null;
- Class<? extends ManagedProperty> mpClass = moPropertyFactory;
- ManagementPropertyFactory mpf = getAnnotation(ManagementPropertyFactory.class, propertyInfo, metaData);
- if (mpf != null)
- mpClass = mpf.value();
- if (mpClass != null)
- property = getManagedProperty(mpClass, fields);
- // we should have write-through by default
- // use factory to change this default behavior
- if (property == null)
- property = createDefaultManagedProperty(fields);
- // Pass the MetaMapper as an attachment
- if(metaMapper != null)
- property.setTransientAttachment(MetaMapper.class.getName(), metaMapper);
- properties.add(property);
- }
- else if (trace)
- log.trace("Ignoring property: " + propertyInfo);
- }
- }
-
- /* TODO: Operations. In general the bean metadata does not contain
- operation information.
- */
- Set<ManagedOperation> operations = new HashSet<ManagedOperation>();
-
- Set<MethodInfo> methodInfos = beanInfo.getMethods();
- if (methodInfos != null && methodInfos.isEmpty() == false)
- {
- for (MethodInfo methodInfo : methodInfos)
- {
- ManagementOperation managementOp = getAnnotation(ManagementOperation.class, methodInfo, metaData);
- if (managementOp == null)
- continue;
-
- ManagedOperation op = getManagedOperation(methodInfo, managementOp);
- operations.add(op);
- }
- }
-
- ManagedObjectImpl result = new ManagedObjectImpl(name, properties);
- result.setAnnotations(moAnnotations);
- // Set the component name to name if this is a runtime MO with a name specified
- if (isRuntime && name.equals(classInfo.getName()) == false)
- result.setComponentName(name);
- if (nameType != null)
- result.setNameType(nameType);
- if (attachmentName != null)
- result.setAttachmentName(attachmentName);
- if (operations.size() > 0 )
- result.setOperations(operations);
- for (ManagedProperty property : properties)
- property.setManagedObject(result);
- result.setTransientAttachment(BeanInfo.class.getName(), beanInfo);
- return result;
- }
-
- /**
- * Create default MangedProperty instance.
- * Override this method for different default.
- *
- * @param fields the fields
- * @return new ManagedProperty instance
- */
- protected ManagedProperty createDefaultManagedProperty(Fields fields)
- {
- return new WritethroughManagedPropertyImpl(fields, metaValueFactory, this);
- }
-
- /**
- * Get the property name.
- *
- * @param property managed property
- * @return property name
- */
- protected String getPropertyName(ManagedProperty property)
- {
- // First look to the mapped name
- String name = property.getMappedName();
- if (name == null)
- property.getName();
- return name;
- }
-
- /**
- *
- * @param methodInfo
- * @param opAnnotation
- * @return the managed operation
- */
- protected ManagedOperation getManagedOperation(MethodInfo methodInfo, ManagementOperation opAnnotation)
- {
- String name = methodInfo.getName();
- String description = opAnnotation.description();
- Impact impact = opAnnotation.impact();
- ManagementParameter[] params = opAnnotation.params();
- ParameterInfo[] paramInfo = methodInfo.getParameters();
- TypeInfo returnInfo = methodInfo.getReturnType();
- MetaType returnType = metaTypeFactory.resolve(returnInfo);
- ArrayList<ManagedParameter> mparams = new ArrayList<ManagedParameter>();
- Class<? extends ManagedParameterConstraintsPopulatorFactory> opConstraintsFactor = opAnnotation.constraintsFactory();
-
- if( paramInfo != null )
- {
- for(int i = 0; i < paramInfo.length; i ++)
- {
- ParameterInfo pinfo = paramInfo[i];
- String pname = pinfo.getName();
- String pdescription = null;
- ManagementParameter mpa = null;
- // Look to ManagementParameter for info
- if (i < params.length)
- {
- mpa = params[i];
- if (mpa.name().equals(AnnotationDefaults.EMPTY_STRING) == false)
- pname = mpa.name();
- if (mpa.description().equals(AnnotationDefaults.EMPTY_STRING) == false)
- pdescription = mpa.description();
- }
- // Generate a name if there is none
- if (pname == null)
- pname = "arg#" + i;
- Fields fields = new DefaultFieldsImpl(pname);
- if (pdescription != null)
- fields.setField(Fields.DESCRIPTION, pdescription);
- MetaType metaType = metaTypeFactory.resolve(pinfo.getParameterType());
- fields.setField(Fields.META_TYPE, metaType);
- // Delegate others (legal values, min/max etc.) to the constraints factory
- try
- {
- Class<? extends ManagedParameterConstraintsPopulatorFactory> factoryClass = opConstraintsFactor;
- if (factoryClass == ManagementParameter.NULL_CONSTRAINTS.class)
- {
- if (mpa != null)
- factoryClass = mpa.constraintsFactory();
- }
- ManagedParameterConstraintsPopulatorFactory factory = factoryClass.newInstance();
- ManagedParameterConstraintsPopulator populator = factory.newInstance();
- if (populator != null)
- populator.populateManagedParameter(name, pinfo, fields);
- }
- catch(Exception e)
- {
- log.debug("Failed to populate constraints for: "+pinfo, e);
- }
-
- ManagedParameterImpl mp = new ManagedParameterImpl(fields);
- mparams.add(mp);
- }
- }
- ManagedParameter[] parameters = new ManagedParameter[mparams.size()];
- mparams.toArray(parameters);
-
- return new ManagedOperationImpl(name, description, impact, parameters, returnType);
- }
-
- /**
- * Get the builder for a class
- *
- * @param clazz the class
- * @return the builder
- */
- protected ManagedObjectBuilder getBuilder(Class<?> clazz)
- {
- synchronized (builders)
- {
- ManagedObjectBuilder builder = builders.get(clazz);
- if (builder != null)
- return builder;
- }
- return this;
- }
-
- /**
- * Get the instance factory for a class
- *
- * @param clazz the class
- * @return the InstanceClassFactory
- */
- @SuppressWarnings("unchecked")
- public <X> InstanceClassFactory<X> getInstanceClassFactory(Class<X> clazz,
- MetaData metaData)
- {
- InstanceClassFactory defaultFactory = defaultInstanceFactory;
- if(metaData != null)
- {
- InstanceClassFactory mdrFactory = metaData.getMetaData(InstanceClassFactory.class);
- if(mdrFactory != null)
- defaultFactory = mdrFactory;
- }
- InstanceClassFactory<X> factory = (InstanceClassFactory<X>)
- Utility.getInstanceClassFactory(clazz, instanceFactories,
- defaultFactory);
- return factory;
- }
-
- /**
- * Get the populator for a class
- *
- * @param clazz the class
- * @return the populator
- */
- @SuppressWarnings("unchecked")
- protected <X> ManagedObjectPopulator<X> getPopulator(Class<X> clazz)
- {
- ManagedObjectBuilder builder = getBuilder(clazz);
- if (builder instanceof ManagedObjectPopulator)
- return (ManagedObjectPopulator) builder;
- ManagedObjectPopulator<X> mop = (ManagedObjectPopulator<X>) defaultManagedObjectPopulator;
- return mop;
- }
-
- protected Collection<?> getAsCollection(Object value)
- {
- if( value.getClass().isArray() )
- return Arrays.asList(value);
- else if (value instanceof Collection)
- return Collection.class.cast(value);
- return null;
- }
-
- /**
- * Look for ctor(Fields)
- * @param factory - the ManagedProperty implementation class
- * @param fields - the fields to pass to the ctor
- * @return the managed property
- */
- protected ManagedProperty getManagedProperty(Class<? extends ManagedProperty> factory, Fields fields)
- {
- return createManagedProperty(factory, fields);
- }
-
- protected <X extends Annotation> X getAnnotation(Class<X> annotationType,
- AnnotatedInfo info, MetaData metaData)
- {
- X annotation = null;
- if(metaData != null)
- {
- annotation = metaData.getAnnotation(annotationType);
- if(annotation == null && info instanceof MethodInfo)
- {
- MethodInfo mi = (MethodInfo) info;
- Signature mis = Signature.getSignature(mi);
- MetaData imetaData = metaData.getComponentMetaData(mis);
- if (imetaData != null)
- annotation = imetaData.getAnnotation(annotationType);
- }
- if (annotation == null && info instanceof PropertyInfo)
- {
- PropertyInfo pi = (PropertyInfo) info;
- if(pi.getGetter() != null)
- {
- Signature mis = new MethodSignature(pi.getGetter());
- MetaData imetaData = metaData.getComponentMetaData(mis);
- if (imetaData != null)
- annotation = imetaData.getAnnotation(annotationType);
- }
- if(annotation == null && pi.getSetter() != null)
- {
- Signature mis = new MethodSignature(pi.getSetter());
- MetaData imetaData = metaData.getComponentMetaData(mis);
- if (imetaData != null)
- annotation = imetaData.getAnnotation(annotationType);
- }
- if(annotation == null && pi.getFieldInfo() != null)
- {
- Signature fis = new FieldSignature(pi.getFieldInfo());
- MetaData imetaData = metaData.getComponentMetaData(fis);
- if (imetaData != null)
- annotation = imetaData.getAnnotation(annotationType);
- }
- }
- if(annotation != null)
- log.trace("Loaded "+annotationType+" from MetaData");
- }
- if(annotation == null)
- annotation = info.getUnderlyingAnnotation(annotationType);
- return annotation;
- }
-
- /**
- * Build up a BeanInfo from the interface class and all interfaces it
- * implements.
- *
- * @param iface - the interface for the managed object
- * @return the full BeanInfo for the iface
- */
- protected BeanInfo getBeanInfo(Class<?> iface)
- {
- BeanInfo ifaceBI = configuration.getBeanInfo(iface);
- Class<?>[] superIfaces = iface.getInterfaces();
- if(superIfaces != null && superIfaces.length > 0)
- {
- // Combine all properties
- Set<PropertyInfo> allProps = new HashSet<PropertyInfo>(ifaceBI.getProperties());
- // Combine all operations
- Set<MethodInfo> allMethods = new HashSet<MethodInfo>(ifaceBI.getMethods());
- for(Class<?> superIface : superIfaces)
- {
- BeanInfo cBI = configuration.getBeanInfo(superIface);
- Set<PropertyInfo> props = cBI.getProperties();
- if(props != null)
- allProps.addAll(props);
- Set<MethodInfo> methods = cBI.getMethods();
- if(methods != null)
- allMethods.addAll(methods);
- }
-
- ifaceBI.setProperties(allProps);
- ifaceBI.setMethods(allMethods);
- }
- return ifaceBI;
- }
-}
Copied: projects/jboss-man/tags/2.1.0.CR7/managed/src/main/java/org/jboss/managed/plugins/factory/AbstractManagedObjectFactory.java (from rev 87004, projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/plugins/factory/AbstractManagedObjectFactory.java)
===================================================================
--- projects/jboss-man/tags/2.1.0.CR7/managed/src/main/java/org/jboss/managed/plugins/factory/AbstractManagedObjectFactory.java (rev 0)
+++ projects/jboss-man/tags/2.1.0.CR7/managed/src/main/java/org/jboss/managed/plugins/factory/AbstractManagedObjectFactory.java 2009-04-08 21:47:06 UTC (rev 87006)
@@ -0,0 +1,1108 @@
+/*
+* 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.managed.plugins.factory;
+
+import java.io.Serializable;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.WeakHashMap;
+
+import org.jboss.beans.info.spi.BeanInfo;
+import org.jboss.beans.info.spi.PropertyInfo;
+import org.jboss.config.spi.Configuration;
+import org.jboss.logging.Logger;
+import org.jboss.managed.api.Fields;
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.api.ManagedOperation;
+import org.jboss.managed.api.ManagedParameter;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.managed.api.MutableManagedObject;
+import org.jboss.managed.api.ManagedOperation.Impact;
+import org.jboss.managed.api.annotation.ActivationPolicy;
+import org.jboss.managed.api.annotation.AnnotationDefaults;
+import org.jboss.managed.api.annotation.ConstraintsPopulatorFactory;
+import org.jboss.managed.api.annotation.FieldsFactory;
+import org.jboss.managed.api.annotation.ManagementComponent;
+import org.jboss.managed.api.annotation.ManagementConstants;
+import org.jboss.managed.api.annotation.ManagementDeployment;
+import org.jboss.managed.api.annotation.ManagementObject;
+import org.jboss.managed.api.annotation.ManagementObjectID;
+import org.jboss.managed.api.annotation.ManagementObjectRef;
+import org.jboss.managed.api.annotation.ManagementOperation;
+import org.jboss.managed.api.annotation.ManagementParameter;
+import org.jboss.managed.api.annotation.ManagementProperties;
+import org.jboss.managed.api.annotation.ManagementProperty;
+import org.jboss.managed.api.annotation.ManagementPropertyFactory;
+import org.jboss.managed.api.annotation.ManagementRuntimeRef;
+import org.jboss.managed.api.annotation.RunStateProperty;
+import org.jboss.managed.api.annotation.ViewUse;
+import org.jboss.managed.api.factory.ManagedObjectFactory;
+import org.jboss.managed.api.factory.ManagedObjectDefinition;
+import org.jboss.managed.plugins.DefaultFieldsImpl;
+import org.jboss.managed.plugins.ManagedObjectImpl;
+import org.jboss.managed.plugins.ManagedOperationImpl;
+import org.jboss.managed.plugins.ManagedParameterImpl;
+import org.jboss.managed.plugins.WritethroughManagedPropertyImpl;
+import org.jboss.managed.spi.factory.InstanceClassFactory;
+import org.jboss.managed.spi.factory.ManagedObjectBuilder;
+import org.jboss.managed.spi.factory.ManagedObjectPopulator;
+import org.jboss.managed.spi.factory.ManagedParameterConstraintsPopulator;
+import org.jboss.managed.spi.factory.ManagedParameterConstraintsPopulatorFactory;
+import org.jboss.managed.spi.factory.ManagedPropertyConstraintsPopulator;
+import org.jboss.managed.spi.factory.ManagedPropertyConstraintsPopulatorFactory;
+import org.jboss.metadata.spi.MetaData;
+import org.jboss.metadata.spi.signature.FieldSignature;
+import org.jboss.metadata.spi.signature.MethodSignature;
+import org.jboss.metadata.spi.signature.Signature;
+import org.jboss.metatype.api.annotations.MetaMapping;
+import org.jboss.metatype.api.annotations.MetaMappingFactory;
+import org.jboss.metatype.api.types.ArrayMetaType;
+import org.jboss.metatype.api.types.CollectionMetaType;
+import org.jboss.metatype.api.types.GenericMetaType;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.MetaTypeFactory;
+import org.jboss.metatype.api.values.MetaValueFactory;
+import org.jboss.metatype.spi.values.MetaMapper;
+import org.jboss.metatype.spi.values.MetaMapperFactory;
+import org.jboss.reflect.spi.AnnotatedInfo;
+import org.jboss.reflect.spi.ClassInfo;
+import org.jboss.reflect.spi.MethodInfo;
+import org.jboss.reflect.spi.ParameterInfo;
+import org.jboss.reflect.spi.TypeInfo;
+
+/**
+ * The base ManagedObjectFactory implementation.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class AbstractManagedObjectFactory extends ManagedObjectFactory
+ implements ManagedObjectBuilder
+{
+ private static final Logger log = Logger.getLogger(AbstractManagedObjectFactory.class);
+
+ /** The configuration */
+ private static final Configuration configuration = PropertyConfigurationAccess.getConfiguration();
+
+ /** The managed object meta type */
+ public static final GenericMetaType MANAGED_OBJECT_META_TYPE = new GenericMetaType(ManagedObject.class.getName(), ManagedObject.class.getName());
+
+ /** The meta type factory */
+ private MetaTypeFactory metaTypeFactory = MetaTypeFactory.getInstance();
+
+ /** The meta value factory */
+ private MetaValueFactory metaValueFactory = MetaValueFactory.getInstance();
+ /** A default InstanceClassFactory used when there is no explicit ICF for a given class */
+ private InstanceClassFactory<?> defaultInstanceFactory;
+ /** A default ManagedObjectPopulator used when there is no explicit ManagedObjectBuilder for a given class */
+ private ManagedObjectPopulator<?> defaultManagedObjectPopulator;
+
+ /** The managed object builders */
+ private Map<Class<?>, ManagedObjectBuilder> builders = new WeakHashMap<Class<?>, ManagedObjectBuilder>();
+
+ /** The instance to class factories */
+ private Map<Class<?>, InstanceClassFactory<?>> instanceFactories = new WeakHashMap<Class<?>, InstanceClassFactory<?>>();
+
+ /**
+ * Create a ManagedProperty by looking to the factory for ctor(Fields)
+ * @param factory - the ManagedProperty implementation class
+ * @param fields - the fields to pass to the ctor
+ * @return the managed property if successful, null otherwise
+ */
+ public static ManagedProperty createManagedProperty(Class<? extends ManagedProperty> factory, Fields fields)
+ {
+ ManagedProperty property = null;
+ try
+ {
+ Class<?>[] sig = {Fields.class};
+ Constructor<? extends ManagedProperty> ctor = factory.getConstructor(sig);
+ Object[] args = {fields};
+ property = ctor.newInstance(args);
+ }
+ catch(Exception e)
+ {
+ log.debug("Failed to create ManagedProperty", e);
+ }
+ return property;
+ }
+
+ /**
+ * Create an AbstractManagedObjectFactory that uses an AbstractInstanceClassFactory
+ * as the defaultInstanceFactory and AbstractManagedObjectPopulator as the
+ * defaultManagedObjectPopulator. The MetaTypeFactory, MetaValueFactory are
+ * obtained from the respective getInstance() factory methods.
+ */
+ public AbstractManagedObjectFactory()
+ {
+ // Create an AbstractInstanceClassFactory as the default ICF
+ DefaultInstanceClassFactory icf = new DefaultInstanceClassFactory();
+ icf.setMof(this);
+ defaultInstanceFactory = icf;
+ // Create an AbstractManagedObjectPopulator as the default
+ defaultManagedObjectPopulator = new AbstractManagedObjectPopulator<Serializable>(configuration, icf, instanceFactories);
+ }
+ /**
+ * Create an AbstractManagedObjectFactory the given factories, supporting
+ * information.
+ *
+ * @param metaTypeFactory
+ * @param metaValueFactory
+ * @param defaultInstanceFactory
+ * @param defaultManagedObjectPopulator
+ * @param builders
+ * @param instanceFactories
+ */
+ public AbstractManagedObjectFactory(MetaTypeFactory metaTypeFactory,
+ MetaValueFactory metaValueFactory,
+ InstanceClassFactory<?> defaultInstanceFactory,
+ ManagedObjectPopulator<?> defaultManagedObjectPopulator,
+ Map<Class<?>, ManagedObjectBuilder> builders,
+ Map<Class<?>, InstanceClassFactory<?>> instanceFactories)
+ {
+ this.metaTypeFactory = metaTypeFactory;
+ this.metaValueFactory = metaValueFactory;
+ this.defaultInstanceFactory = defaultInstanceFactory;
+ this.defaultManagedObjectPopulator = defaultManagedObjectPopulator;
+ this.builders = builders;
+ this.instanceFactories = instanceFactories;
+ }
+
+ /**
+ * Add managed object definition.
+ *
+ * @param definition the MO definition
+ */
+ public void addManagedObjectDefinition(ManagedObjectDefinition definition)
+ {
+ if (definition == null || definition.isValid() == false)
+ throw new IllegalArgumentException("Invalid MO definition: " + definition);
+
+ setBuilder(definition.getType(), definition.getBuilder());
+ }
+
+ /**
+ * Remove managed object definition.
+ *
+ * @param definition the MO definition
+ */
+ public void removeManagedObjectDefinition(ManagedObjectDefinition definition)
+ {
+ if (definition == null)
+ return;
+
+ setBuilder(definition.getType(), null);
+ }
+
+ /**
+ * Get the configuration
+ *
+ * @return the configuration
+ */
+ public Configuration getConfiguration()
+ {
+ return configuration;
+ }
+
+
+ public MetaTypeFactory getMetaTypeFactory()
+ {
+ return metaTypeFactory;
+ }
+
+ public void setMetaTypeFactory(MetaTypeFactory metaTypeFactory)
+ {
+ this.metaTypeFactory = metaTypeFactory;
+ }
+
+ public MetaValueFactory getMetaValueFactory()
+ {
+ return metaValueFactory;
+ }
+
+ public void setMetaValueFactory(MetaValueFactory metaValueFactory)
+ {
+ this.metaValueFactory = metaValueFactory;
+ }
+
+ public Map<Class<?>, ManagedObjectBuilder> getBuilders()
+ {
+ return builders;
+ }
+
+ public void setBuilders(Map<Class<?>, ManagedObjectBuilder> builders)
+ {
+ this.builders = builders;
+ }
+
+ public Map<Class<?>, InstanceClassFactory<?>> getInstanceFactories()
+ {
+ return instanceFactories;
+ }
+
+ public void setInstanceFactories(
+ Map<Class<?>, InstanceClassFactory<?>> instanceFactories)
+ {
+ this.instanceFactories = instanceFactories;
+ }
+
+ /**
+ * Get the default InstanceClassFactory
+ * @return the current default InstanceClassFactory
+ */
+ public InstanceClassFactory<?> getDefaultInstanceFactory()
+ {
+ return defaultInstanceFactory;
+ }
+ /**
+ * Set the default InstanceClassFactory. This is used when there is not
+ * match an exact match by the {@linkplain #getInstanceClassFactory(Class)}
+ * factory method.
+ *
+ * @param defaultInstanceFactory the default InstanceClassFactory to fall
+ * back to. It may be null if no default should be used.
+ */
+ public void setDefaultInstanceFactory(
+ InstanceClassFactory<? extends Serializable> defaultInstanceFactory)
+ {
+ this.defaultInstanceFactory = defaultInstanceFactory;
+ }
+
+
+ public ManagedObjectPopulator<?> getDefaultManagedObjectPopulator()
+ {
+ return defaultManagedObjectPopulator;
+ }
+
+ /**
+ * A default implementation of ManagedObjectPopulator that is used when
+ * there is no ManagedObjectBuilder registered for a given type.
+ * @see #getBuilder(Class)
+ * @param defaultManagedObjectPopulator
+ */
+ public void setDefaultManagedObjectPopulator(
+ ManagedObjectPopulator<? extends Serializable> defaultManagedObjectPopulator)
+ {
+ this.defaultManagedObjectPopulator = defaultManagedObjectPopulator;
+ }
+
+ @Override
+ public <T> ManagedObject createManagedObject(Class<T> clazz, MetaData metaData)
+ {
+ if (clazz == null)
+ throw new IllegalArgumentException("Null class");
+
+ ManagedObject result = createSkeletonManagedObject(clazz, metaData);
+ ManagedObjectPopulator<T> populator = getPopulator(clazz);
+ populator.createObject(result, clazz, metaData);
+
+ return result;
+ }
+
+ public ManagedObject initManagedObject(Object instance, Class<?> instanceType,
+ MetaData metaData, String name, String nameType)
+ {
+ if (instance == null)
+ throw new IllegalArgumentException("instance cannot be null");
+
+ Class<?> clazz = instance.getClass();
+ InstanceClassFactory icf = defaultInstanceFactory;
+ if(instanceType != null && instanceType != clazz)
+ icf = getInstanceClassFactory(instanceType, metaData);
+ if(icf == defaultInstanceFactory)
+ icf = getInstanceClassFactory(clazz, metaData);
+
+ Class<Object> moClass;
+ try
+ {
+ moClass = icf.getManagedObjectClass(instance);
+ }
+ catch(ClassNotFoundException e)
+ {
+ log.debug("Failed to load class for ManagedObject", e);
+ return null;
+ }
+ if(moClass == null)
+ {
+ log.debug("ICF returned null class: "+instance);
+ return null;
+ }
+
+ ManagedObject result = createSkeletonManagedObject(moClass, metaData);
+ if (result == null)
+ {
+ log.debug("Null ManagedObject created for: "+moClass);
+ return null;
+ }
+ log.debug("Created skeleton ManagedObject: "+result);
+
+ if(result instanceof MutableManagedObject)
+ {
+ MutableManagedObject mmo = (MutableManagedObject) result;
+ ManagedObjectPopulator<Object> populator = getPopulator(moClass);
+ populator.populateManagedObject(mmo, instance, metaData);
+ }
+
+ return result;
+ }
+
+ @Override
+ public void setBuilder(Class<?> clazz, ManagedObjectBuilder builder)
+ {
+ synchronized (builders)
+ {
+ if (builder == null)
+ builders.remove(clazz);
+ else
+ builders.put(clazz, builder);
+ }
+ }
+
+ @Override
+ public <T> void setInstanceClassFactory(Class<T> clazz, InstanceClassFactory<T> factory)
+ {
+ synchronized (instanceFactories)
+ {
+ if (factory == null)
+ {
+ instanceFactories.remove(clazz);
+ log.debug("Removed ICF for: "+clazz);
+ }
+ else
+ {
+ instanceFactories.put(clazz, factory);
+ log.debug("Set ICF for: "+clazz+", to: "+factory);
+ }
+ }
+ }
+
+ /**
+ * Create a skeleton managed object
+ *
+ * @param <T> the type
+ * @param clazz the clazz
+ * @return the skeleton managed object, null if clazz is not
+ * marked as a ManagementObject.
+ * {@linkplain ManagementObject}
+ */
+ protected <T> ManagedObject createSkeletonManagedObject(Class<T> clazz, MetaData metaData)
+ {
+ if (clazz == null)
+ throw new IllegalArgumentException("Null class");
+
+ ManagedObjectBuilder builder = getBuilder(clazz);
+ return builder.buildManagedObject(clazz, metaData);
+ }
+
+ /**
+ * The ManagedObjectBuilder.buildManagedObject implementation. This is based
+ * on the org.jboss.managed.api.annotation.* package annotations.
+ * @param clazz the attachment class
+ * @param metaData - the optional metadata repository accessor used to query
+ * for management annotation overrides/additions to the clazz
+ * @return the ManagementObject if clazz is properly annotated, null if
+ * it does not have a ManagementObject annotation on the class or metaData.
+ * The BeanInfo used by this method is stored as a transient attachment
+ * under the BeanInfo.class.getName() ket.
+ */
+ @SuppressWarnings("unchecked")
+ public ManagedObject buildManagedObject(Class<?> clazz, MetaData metaData)
+ {
+ boolean trace = log.isTraceEnabled();
+ BeanInfo beanInfo = configuration.getBeanInfo(clazz);
+ ClassInfo classInfo = beanInfo.getClassInfo();
+
+ ManagementObject managementObject = getAnnotation(ManagementObject.class, classInfo, metaData);
+ if( managementObject == null )
+ {
+ if (trace)
+ log.trace("No ManagementObject annotation, skipping ManagedObject for class: "+clazz);
+ // Skip the ManagedObject creation
+ return null;
+ }
+
+ // If a targetInterface exists, rebuild the BeanInfo from that
+ Class<?> targetInterface = managementObject.targetInterface();
+ if(targetInterface != Object.class)
+ {
+ beanInfo = getBeanInfo(targetInterface);
+ classInfo = beanInfo.getClassInfo();
+ }
+ HashMap<String, Annotation> moAnnotations = new HashMap<String, Annotation>();
+ moAnnotations.put(ManagementObject.class.getName(), managementObject);
+ ManagementDeployment mnagementDeployment = getAnnotation(ManagementDeployment.class, classInfo, metaData);
+ if(mnagementDeployment != null)
+ moAnnotations.put(ManagementDeployment.class.getName(), mnagementDeployment);
+ ManagementObjectID moID = getAnnotation(ManagementObjectID.class, classInfo, metaData);
+ if (moID != null)
+ moAnnotations.put(ManagementObjectID.class.getName(), moID);
+
+ // Process the ManagementObject fields
+ boolean isRuntime = managementObject.isRuntime();
+ String name = classInfo.getName();
+ String nameType = null;
+ String attachmentName = classInfo.getName();
+ Class<? extends Fields> moFieldsFactory = null;
+ ConstraintsPopulatorFactory moCPF = null;
+ Class<? extends ManagedPropertyConstraintsPopulatorFactory> moConstraintsFactory = null;
+ Class<? extends ManagedProperty> moPropertyFactory = null;
+ if (managementObject != null)
+ {
+ name = managementObject.name();
+ if (name.length() == 0 || name.equals(ManagementConstants.GENERATED))
+ name = classInfo.getName();
+ nameType = managementObject.type();
+ if (nameType.length() == 0)
+ nameType = null;
+ attachmentName = managementObject.attachmentName();
+ if (attachmentName.length() == 0)
+ attachmentName = classInfo.getName();
+ // Check for a component specification
+ ManagementComponent mc = managementObject.componentType();
+ // Work around JBMDR-51 by checking type/subtype
+ // if (mc.equals(AnnotationDefaults.COMP_TYPE) == false)
+ if (mc.type().length() > 0 || mc.subtype().length() > 0)
+ {
+ log.debug("ManagedObject("+name+") is ManagedComponent type: "+mc);
+ moAnnotations.put(ManagementComponent.class.getName(), mc);
+ }
+ // ManagementObject level default factory classes
+ FieldsFactory ff = getAnnotation(FieldsFactory.class, classInfo, metaData);
+ if(ff != null)
+ moFieldsFactory = ff.value();
+ moCPF = getAnnotation(ConstraintsPopulatorFactory.class, classInfo, metaData);
+ if(moCPF != null)
+ moConstraintsFactory = moCPF.value();
+ ManagementPropertyFactory mpf = getAnnotation(ManagementPropertyFactory.class, classInfo, metaData);
+ if(mpf != null)
+ moPropertyFactory = mpf.value();
+ }
+
+ if (trace)
+ {
+ log.trace("Building MangedObject(name="+name+",nameType="+nameType
+ +",attachmentName="+attachmentName+",isRuntime="+isRuntime+")");
+ }
+
+ ManagementProperties propertyType = ManagementProperties.ALL;
+ Set<String> classProperties = null;
+ if (managementObject != null)
+ {
+ propertyType = managementObject.properties();
+ if(propertyType == ManagementProperties.CLASS || propertyType == ManagementProperties.CLASS_AND_EXPLICIT)
+ {
+ classProperties = new HashSet<String>();
+ for(ManagementProperty mp : managementObject.classProperties())
+ {
+ if(mp.name().length() > 0)
+ classProperties.add(mp.name());
+ if(mp.mappedName().length() > 0)
+ classProperties.add(mp.mappedName());
+ }
+ }
+ }
+
+ // Build the ManagedProperties
+ Set<ManagedProperty> properties = new HashSet<ManagedProperty>();
+
+ Set<PropertyInfo> propertyInfos = beanInfo.getProperties();
+ if (propertyInfos != null && propertyInfos.isEmpty() == false)
+ {
+ for (PropertyInfo propertyInfo : propertyInfos)
+ {
+ // Ignore the "class" property
+ if ("class".equals(propertyInfo.getName()))
+ continue;
+
+ ManagementProperty managementProperty = getAnnotation(ManagementProperty.class, propertyInfo, metaData);
+ ManagementObjectID id = getAnnotation(ManagementObjectID.class, propertyInfo, metaData);
+ ManagementObjectRef ref = getAnnotation(ManagementObjectRef.class, propertyInfo, metaData);
+ ManagementRuntimeRef runtimeRef = getAnnotation(ManagementRuntimeRef.class, propertyInfo, metaData);
+ RunStateProperty rsp = getAnnotation(RunStateProperty.class, propertyInfo, metaData);
+ HashMap<String, Annotation> propAnnotations = new HashMap<String, Annotation>();
+ if (managementProperty != null)
+ propAnnotations.put(ManagementProperty.class.getName(), managementProperty);
+ if (id != null)
+ {
+ propAnnotations.put(ManagementObjectID.class.getName(), id);
+ // This overrides the MO nameType
+ nameType = id.type();
+ }
+ if (ref != null)
+ propAnnotations.put(ManagementObjectRef.class.getName(), ref);
+ if (runtimeRef != null)
+ propAnnotations.put(ManagementRuntimeRef.class.getName(), runtimeRef);
+ if (rsp != null)
+ propAnnotations.put(RunStateProperty.class.getName(), rsp);
+
+ // Check whether this property should be included
+ boolean includeProperty = false;
+ switch(propertyType)
+ {
+ // Only if the property as a ManagementProperty
+ case EXPLICIT:
+ includeProperty = managementProperty != null &&
+ (managementProperty.ignored() == false);
+ break;
+ // Only if the property is listed in the classProperties
+ case CLASS:
+ includeProperty = classProperties.contains(propertyInfo.getName());
+ break;
+ // Only if the property is listed in the classProperties
+ case CLASS_AND_EXPLICIT:
+ includeProperty = classProperties.contains(propertyInfo.getName())
+ || (managementProperty != null && managementProperty.ignored() == false);
+ break;
+ // Any property that is not ignored
+ case ALL:
+ includeProperty = managementProperty == null
+ || managementProperty.ignored() == false;
+ break;
+ }
+
+ if (includeProperty)
+ {
+ Fields fields = null;
+ Class<? extends Fields> factory = moFieldsFactory;
+ FieldsFactory ff = getAnnotation(FieldsFactory.class, propertyInfo, metaData);
+ if(ff != null)
+ factory = ff.value();
+ if (factory != null)
+ {
+ try
+ {
+ fields = factory.newInstance();
+ }
+ catch (Exception e)
+ {
+ log.debug("Failed to created Fields", e);
+ }
+ }
+ if (fields == null)
+ fields = new DefaultFieldsImpl();
+
+ if( propertyInfo instanceof Serializable )
+ {
+ Serializable info = Serializable.class.cast(propertyInfo);
+ fields.setField(Fields.PROPERTY_INFO, info);
+ }
+
+ String propertyName = propertyInfo.getName();
+ if (managementProperty != null)
+ propertyName = managementProperty.name();
+ if( propertyName.length() == 0 )
+ propertyName = propertyInfo.getName();
+ fields.setField(Fields.NAME, propertyName);
+
+ // This should probably always the the propertyInfo name?
+ String mappedName = propertyInfo.getName();
+ if (managementProperty != null)
+ mappedName = managementProperty.mappedName();
+ if( mappedName.length() == 0 )
+ mappedName = propertyInfo.getName();
+ fields.setField(Fields.MAPPED_NAME, mappedName);
+
+ String description = ManagementConstants.GENERATED;
+ if (managementProperty != null)
+ description = managementProperty.description();
+ if (description.equals(ManagementConstants.GENERATED))
+ description = propertyName;
+ fields.setField(Fields.DESCRIPTION, description);
+
+ if (trace)
+ {
+ log.trace("Building MangedProperty(name="+propertyName
+ +",mappedName="+mappedName
+ +") ,annotations="+propAnnotations);
+ }
+
+ boolean mandatory = false;
+ if (managementProperty != null)
+ mandatory = managementProperty.mandatory();
+ if (mandatory)
+ fields.setField(Fields.MANDATORY, Boolean.TRUE);
+
+ boolean readOnly = propertyInfo.isWritable() == false;
+ if (readOnly == false && managementProperty != null)
+ readOnly = managementProperty.readOnly();
+ if (readOnly)
+ fields.setField(Fields.READ_ONLY, Boolean.TRUE);
+
+ boolean managed = false;
+ if (managementProperty != null)
+ managed = managementProperty.managed();
+ // View Use
+ if (managementProperty != null)
+ {
+ ViewUse[] use = managementProperty.use();
+ fields.setField(Fields.VIEW_USE, use);
+ }
+ // ActivationPolicy
+ ActivationPolicy apolicy = ActivationPolicy.IMMEDIATE;
+ if (managementProperty != null)
+ {
+ apolicy = managementProperty.activationPolicy();
+ }
+ fields.setField(Fields.ACTIVATION_POLICY, apolicy);
+
+ // The managed property type
+ MetaMapper[] mapperReturn = {null};
+ MetaType metaType = this.getMetaType(propertyInfo, propertyInfo.getType(), metaData, false, mapperReturn);
+
+ // Determine meta type based on property type
+ if(metaType == null)
+ {
+ if (managed)
+ {
+ TypeInfo typeInfo = propertyInfo.getType();
+ if(typeInfo.isArray())
+ metaType = new ArrayMetaType(1, MANAGED_OBJECT_META_TYPE);
+ else if (typeInfo.isCollection())
+ metaType = new CollectionMetaType(typeInfo.getName(), MANAGED_OBJECT_META_TYPE);
+ else
+ metaType = MANAGED_OBJECT_META_TYPE;
+ }
+ else
+ {
+ metaType = metaTypeFactory.resolve(propertyInfo.getType());
+ }
+ }
+ fields.setField(Fields.META_TYPE, metaType);
+ // Property annotations
+ if (propAnnotations.isEmpty() == false)
+ fields.setField(Fields.ANNOTATIONS, propAnnotations);
+
+ // Delegate others (legal values, min/max etc.) to the constraints factory
+ try
+ {
+ Class<? extends ManagedPropertyConstraintsPopulatorFactory> factoryClass = moConstraintsFactory;
+ ConstraintsPopulatorFactory cpf = getAnnotation(ConstraintsPopulatorFactory.class, propertyInfo, metaData);
+ if(cpf != null)
+ factoryClass = cpf.value();
+ else
+ cpf = moCPF;
+ if(factoryClass != null)
+ {
+ ManagedPropertyConstraintsPopulatorFactory mpcpf = factoryClass.newInstance();
+ ManagedPropertyConstraintsPopulator populator = mpcpf.newInstance(cpf.min(), cpf.max(), cpf.legalValues(), cpf.args());
+ if (populator != null)
+ populator.populateManagedProperty(clazz, propertyInfo, fields);
+ }
+ }
+ catch(Exception e)
+ {
+ log.debug("Failed to populate constraints for: "+propertyInfo, e);
+ }
+
+ ManagedProperty property = null;
+ Class<? extends ManagedProperty> mpClass = moPropertyFactory;
+ ManagementPropertyFactory mpf = getAnnotation(ManagementPropertyFactory.class, propertyInfo, metaData);
+ if (mpf != null)
+ mpClass = mpf.value();
+ if (mpClass != null)
+ property = getManagedProperty(mpClass, fields);
+ // we should have write-through by default
+ // use factory to change this default behavior
+ if (property == null)
+ property = createDefaultManagedProperty(fields);
+ // Pass the MetaMapper as an attachment
+ if (mapperReturn[0] != null)
+ property.setTransientAttachment(MetaMapper.class.getName(), mapperReturn[0]);
+ properties.add(property);
+ }
+ else if (trace)
+ log.trace("Ignoring property: " + propertyInfo);
+ }
+ }
+
+ /* TODO: Operations. In general the bean metadata does not contain
+ operation information.
+ */
+ Set<ManagedOperation> operations = new HashSet<ManagedOperation>();
+
+ Set<MethodInfo> methodInfos = beanInfo.getMethods();
+ if (methodInfos != null && methodInfos.isEmpty() == false)
+ {
+ for (MethodInfo methodInfo : methodInfos)
+ {
+ ManagementOperation managementOp = getAnnotation(ManagementOperation.class, methodInfo, metaData);
+ if (managementOp == null)
+ continue;
+
+ ManagedOperation op = getManagedOperation(methodInfo, managementOp, metaData);
+ operations.add(op);
+ }
+ }
+
+ ManagedObjectImpl result = new ManagedObjectImpl(name, properties);
+ result.setAnnotations(moAnnotations);
+ // Set the component name to name if this is a runtime MO with a name specified
+ if (isRuntime && name.equals(classInfo.getName()) == false)
+ result.setComponentName(name);
+ if (nameType != null)
+ result.setNameType(nameType);
+ if (attachmentName != null)
+ result.setAttachmentName(attachmentName);
+ if (operations.size() > 0 )
+ result.setOperations(operations);
+ for (ManagedProperty property : properties)
+ property.setManagedObject(result);
+ result.setTransientAttachment(BeanInfo.class.getName(), beanInfo);
+ return result;
+ }
+
+ /**
+ * Create default MangedProperty instance.
+ * Override this method for different default.
+ *
+ * @param fields the fields
+ * @return new ManagedProperty instance
+ */
+ protected ManagedProperty createDefaultManagedProperty(Fields fields)
+ {
+ return new WritethroughManagedPropertyImpl(fields, metaValueFactory, this);
+ }
+
+ /**
+ * Get the property name.
+ *
+ * @param property managed property
+ * @return property name
+ */
+ protected String getPropertyName(ManagedProperty property)
+ {
+ // First look to the mapped name
+ String name = property.getMappedName();
+ if (name == null)
+ property.getName();
+ return name;
+ }
+
+ /**
+ *
+ * @param methodInfo
+ * @param opAnnotation
+ * @return the managed operation
+ */
+ protected ManagedOperation getManagedOperation(MethodInfo methodInfo,
+ ManagementOperation opAnnotation, MetaData metaData)
+ {
+ String name = methodInfo.getName();
+ String description = opAnnotation.description();
+ Impact impact = opAnnotation.impact();
+ ManagementParameter[] params = opAnnotation.params();
+ ParameterInfo[] paramInfo = methodInfo.getParameters();
+ ArrayList<ManagedParameter> mparams = new ArrayList<ManagedParameter>();
+ Class<? extends ManagedParameterConstraintsPopulatorFactory> opConstraintsFactor = opAnnotation.constraintsFactory();
+
+ // The op return type
+ MetaMapper[] returnTypeMapper = {null};
+ MetaType returnType = getMetaType(methodInfo, methodInfo.getReturnType(), metaData, true, returnTypeMapper);
+
+ // Process the op parameters
+ if( paramInfo != null )
+ {
+ for(int i = 0; i < paramInfo.length; i ++)
+ {
+ ParameterInfo pinfo = paramInfo[i];
+ String pname = pinfo.getName();
+ String pdescription = null;
+ ManagementParameter mpa = null;
+ // Look to ManagementParameter for info
+ if (i < params.length)
+ {
+ mpa = params[i];
+ if (mpa.name().equals(AnnotationDefaults.EMPTY_STRING) == false)
+ pname = mpa.name();
+ if (mpa.description().equals(AnnotationDefaults.EMPTY_STRING) == false)
+ pdescription = mpa.description();
+ }
+ // Generate a name if there is none
+ if (pname == null)
+ pname = "arg#" + i;
+ Fields fields = new DefaultFieldsImpl(pname);
+ if (pdescription != null)
+ fields.setField(Fields.DESCRIPTION, pdescription);
+ MetaMapper[] paramMapper = {null};
+ MetaType metaType = getMetaType(pinfo, pinfo.getParameterType(), metaData, true, paramMapper);
+ fields.setField(Fields.META_TYPE, metaType);
+ // Delegate others (legal values, min/max etc.) to the constraints factory
+ try
+ {
+ Class<? extends ManagedParameterConstraintsPopulatorFactory> factoryClass = opConstraintsFactor;
+ if (factoryClass == ManagementParameter.NULL_CONSTRAINTS.class)
+ {
+ if (mpa != null)
+ factoryClass = mpa.constraintsFactory();
+ }
+ ManagedParameterConstraintsPopulatorFactory factory = factoryClass.newInstance();
+ ManagedParameterConstraintsPopulator populator = factory.newInstance();
+ if (populator != null)
+ populator.populateManagedParameter(name, pinfo, fields);
+ }
+ catch(Exception e)
+ {
+ log.debug("Failed to populate constraints for: "+pinfo, e);
+ }
+
+ ManagedParameterImpl mp = new ManagedParameterImpl(fields);
+ if(paramMapper[0] != null)
+ mp.setTransientAttachment(MetaMapper.class.getName(), paramMapper[0]);
+ mparams.add(mp);
+ }
+ }
+ ManagedParameter[] parameters = new ManagedParameter[mparams.size()];
+ mparams.toArray(parameters);
+
+ ManagedOperationImpl op = new ManagedOperationImpl(name, description, impact, parameters, returnType);
+ if(returnTypeMapper[0] != null)
+ op.setTransientAttachment(MetaMapper.class.getName(), returnTypeMapper[0]);
+ return op;
+ }
+
+ /**
+ * Get the MetaType for info by looking for MetaMapping/MetaMappingFactory
+ * annotations in addition to the info type.
+ *
+ * @param methodInfo
+ * @param metaData
+ * @return the MetaType for info's type
+ */
+ protected MetaType getMetaType(AnnotatedInfo info, TypeInfo infoType, MetaData metaData,
+ boolean useTypeFactory, MetaMapper[] mapperReturn)
+ {
+ MetaType returnType = null;
+ // First look for meta mappings
+ MetaMapper<?> metaMapper = null;
+ MetaMapping metaMapping = getAnnotation(MetaMapping.class, info, metaData);
+ MetaMappingFactory metaMappingFactory = getAnnotation(MetaMappingFactory.class, info, metaData);
+ if(metaMappingFactory != null)
+ {
+ Class<? extends MetaMapperFactory<?>> mmfClass = metaMappingFactory.value();
+ try
+ {
+ MetaMapperFactory<?> mmf = mmfClass.newInstance();
+ String[] args = metaMappingFactory.args();
+ if(args.length > 0)
+ metaMapper = mmf.newInstance(args);
+ else
+ metaMapper = mmf.newInstance();
+ }
+ catch(Exception e)
+ {
+ log.debug("Failed to create MetaMapperFactory: "+metaMappingFactory, e);
+ }
+ }
+ if(metaMapping != null)
+ {
+ // Use the mapping for the type
+ Class<? extends MetaMapper<?>> mapperClass = metaMapping.value();
+ try
+ {
+ metaMapper = mapperClass.newInstance();
+ }
+ catch(Exception e)
+ {
+ log.debug("Failed to create MetaMapper: "+metaMapping, e);
+ }
+ }
+ if(metaMapper != null)
+ {
+ returnType = metaMapper.getMetaType();
+ // Return the MetaMapper
+ if(mapperReturn != null && mapperReturn.length > 0)
+ mapperReturn[0] = metaMapper;
+ }
+
+ if(returnType == null && useTypeFactory)
+ {
+ // Use the type factory to convert the info type
+ returnType = metaTypeFactory.resolve(infoType);
+ }
+ return returnType;
+ }
+
+ /**
+ * Get the builder for a class
+ *
+ * @param clazz the class
+ * @return the builder
+ */
+ protected ManagedObjectBuilder getBuilder(Class<?> clazz)
+ {
+ synchronized (builders)
+ {
+ ManagedObjectBuilder builder = builders.get(clazz);
+ if (builder != null)
+ return builder;
+ }
+ return this;
+ }
+
+ /**
+ * Get the instance factory for a class
+ *
+ * @param clazz the class
+ * @return the InstanceClassFactory
+ */
+ @SuppressWarnings("unchecked")
+ public <X> InstanceClassFactory<X> getInstanceClassFactory(Class<X> clazz,
+ MetaData metaData)
+ {
+ InstanceClassFactory defaultFactory = defaultInstanceFactory;
+ if(metaData != null)
+ {
+ InstanceClassFactory mdrFactory = metaData.getMetaData(InstanceClassFactory.class);
+ if(mdrFactory != null)
+ defaultFactory = mdrFactory;
+ }
+ InstanceClassFactory<X> factory = (InstanceClassFactory<X>)
+ Utility.getInstanceClassFactory(clazz, instanceFactories,
+ defaultFactory);
+ return factory;
+ }
+
+ /**
+ * Get the populator for a class
+ *
+ * @param clazz the class
+ * @return the populator
+ */
+ @SuppressWarnings("unchecked")
+ protected <X> ManagedObjectPopulator<X> getPopulator(Class<X> clazz)
+ {
+ ManagedObjectBuilder builder = getBuilder(clazz);
+ if (builder instanceof ManagedObjectPopulator)
+ return (ManagedObjectPopulator) builder;
+ ManagedObjectPopulator<X> mop = (ManagedObjectPopulator<X>) defaultManagedObjectPopulator;
+ return mop;
+ }
+
+ protected Collection<?> getAsCollection(Object value)
+ {
+ if( value.getClass().isArray() )
+ return Arrays.asList(value);
+ else if (value instanceof Collection)
+ return Collection.class.cast(value);
+ return null;
+ }
+
+ /**
+ * Look for ctor(Fields)
+ * @param factory - the ManagedProperty implementation class
+ * @param fields - the fields to pass to the ctor
+ * @return the managed property
+ */
+ protected ManagedProperty getManagedProperty(Class<? extends ManagedProperty> factory, Fields fields)
+ {
+ return createManagedProperty(factory, fields);
+ }
+
+ protected <X extends Annotation> X getAnnotation(Class<X> annotationType,
+ AnnotatedInfo info, MetaData metaData)
+ {
+ X annotation = null;
+ if(metaData != null)
+ {
+ annotation = metaData.getAnnotation(annotationType);
+ if(annotation == null && info instanceof MethodInfo)
+ {
+ MethodInfo mi = (MethodInfo) info;
+ Signature mis = Signature.getSignature(mi);
+ MetaData imetaData = metaData.getComponentMetaData(mis);
+ if (imetaData != null)
+ annotation = imetaData.getAnnotation(annotationType);
+ }
+ if (annotation == null && info instanceof PropertyInfo)
+ {
+ PropertyInfo pi = (PropertyInfo) info;
+ if(pi.getGetter() != null)
+ {
+ Signature mis = new MethodSignature(pi.getGetter());
+ MetaData imetaData = metaData.getComponentMetaData(mis);
+ if (imetaData != null)
+ annotation = imetaData.getAnnotation(annotationType);
+ }
+ if(annotation == null && pi.getSetter() != null)
+ {
+ Signature mis = new MethodSignature(pi.getSetter());
+ MetaData imetaData = metaData.getComponentMetaData(mis);
+ if (imetaData != null)
+ annotation = imetaData.getAnnotation(annotationType);
+ }
+ if(annotation == null && pi.getFieldInfo() != null)
+ {
+ Signature fis = new FieldSignature(pi.getFieldInfo());
+ MetaData imetaData = metaData.getComponentMetaData(fis);
+ if (imetaData != null)
+ annotation = imetaData.getAnnotation(annotationType);
+ }
+ }
+ if(annotation != null)
+ log.trace("Loaded "+annotationType+" from MetaData");
+ }
+ if(annotation == null)
+ annotation = info.getUnderlyingAnnotation(annotationType);
+ return annotation;
+ }
+
+ /**
+ * Build up a BeanInfo from the interface class and all interfaces it
+ * implements.
+ *
+ * @param iface - the interface for the managed object
+ * @return the full BeanInfo for the iface
+ */
+ protected BeanInfo getBeanInfo(Class<?> iface)
+ {
+ BeanInfo ifaceBI = configuration.getBeanInfo(iface);
+ Class<?>[] superIfaces = iface.getInterfaces();
+ if(superIfaces != null && superIfaces.length > 0)
+ {
+ // Combine all properties
+ Set<PropertyInfo> allProps = new HashSet<PropertyInfo>(ifaceBI.getProperties());
+ // Combine all operations
+ Set<MethodInfo> allMethods = new HashSet<MethodInfo>(ifaceBI.getMethods());
+ for(Class<?> superIface : superIfaces)
+ {
+ BeanInfo cBI = configuration.getBeanInfo(superIface);
+ Set<PropertyInfo> props = cBI.getProperties();
+ if(props != null)
+ allProps.addAll(props);
+ Set<MethodInfo> methods = cBI.getMethods();
+ if(methods != null)
+ allMethods.addAll(methods);
+ }
+
+ ifaceBI.setProperties(allProps);
+ ifaceBI.setMethods(allMethods);
+ }
+ return ifaceBI;
+ }
+}
Copied: projects/jboss-man/tags/2.1.0.CR7/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/JBMessage.java (from rev 87004, projects/jboss-man/branches/Branch_2_1/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/JBMessage.java)
===================================================================
--- projects/jboss-man/tags/2.1.0.CR7/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/JBMessage.java (rev 0)
+++ projects/jboss-man/tags/2.1.0.CR7/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/JBMessage.java 2009-04-08 21:47:06 UTC (rev 87006)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.test.managed.factory.support.deployment;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class JBMessage
+{
+
+ public String getJMSMessageID()
+ {
+ return "JMSMessageID";
+ }
+
+ public long getJMSTimestamp()
+ {
+ return 12345;
+ }
+
+ public String getJMSCorrelationID()
+ {
+ return "JMSCorrelationID";
+ }
+
+}
Deleted: projects/jboss-man/tags/2.1.0.CR7/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/JmsDestination.java
===================================================================
--- projects/jboss-man/branches/Branch_2_1/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/JmsDestination.java 2009-04-08 21:28:11 UTC (rev 87000)
+++ projects/jboss-man/tags/2.1.0.CR7/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/JmsDestination.java 2009-04-08 21:47:06 UTC (rev 87006)
@@ -1,85 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, 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.test.managed.factory.support.deployment;
-
-import java.io.Serializable;
-
-import org.jboss.managed.api.annotation.ManagementObject;
-import org.jboss.managed.api.annotation.ManagementProperty;
-import org.jboss.managed.api.annotation.RunStateProperty;
-import org.jboss.managed.api.annotation.ViewUse;
-import org.jboss.managed.plugins.factory.StringRunStateMapper;
-
-/**
- * @author Scott.Stark at jboss.org
- * @version $Revision:$
- */
- at ManagementObject
-public class JmsDestination
- implements Serializable
-{
- private static final long serialVersionUID = 1;
- private String jndiName;
- private SecDomainMD domain;
- private String state;
-
-
- @ManagementProperty(description="The destination state",
- use={ViewUse.STATISTIC}, includeInTemplate=false)
- @RunStateProperty(value=StringRunStateMapper.class,
- metaValues={"State0", "State1", "ErrorState"},
- enumValues={"RUNNING", "STOPPED", "FAILED"}
- )
- public String getState()
- {
- return state;
- }
- public void setState(String state)
- {
- this.state = state;
- }
-
- @ManagementProperty(description="JNDI binding location of destination", includeInTemplate=true)
- public String getJndiName()
- {
- return jndiName;
- }
- public void setJndiName(String jndiName)
- {
- this.jndiName = jndiName;
- }
-
- @ManagementProperty(use={ViewUse.STATISTIC}, includeInTemplate=false)
- public int getMsgCount()
- {
- return 0;
- }
- @ManagementProperty(description="Security domain information", managed=true)
- public SecDomainMD getDomain()
- {
- return domain;
- }
- public void setDomain(SecDomainMD domain)
- {
- this.domain = domain;
- }
-}
Copied: projects/jboss-man/tags/2.1.0.CR7/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/JmsDestination.java (from rev 87004, projects/jboss-man/branches/Branch_2_1/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/JmsDestination.java)
===================================================================
--- projects/jboss-man/tags/2.1.0.CR7/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/JmsDestination.java (rev 0)
+++ projects/jboss-man/tags/2.1.0.CR7/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/JmsDestination.java 2009-04-08 21:47:06 UTC (rev 87006)
@@ -0,0 +1,102 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.test.managed.factory.support.deployment;
+
+import java.io.Serializable;
+
+import javax.management.ObjectName;
+
+import org.jboss.managed.api.annotation.ManagementObject;
+import org.jboss.managed.api.annotation.ManagementProperty;
+import org.jboss.managed.api.annotation.RunStateProperty;
+import org.jboss.managed.api.annotation.ViewUse;
+import org.jboss.managed.plugins.factory.StringRunStateMapper;
+import org.jboss.metatype.api.annotations.MetaMapping;
+import org.jboss.metatype.plugins.values.mappers.StringObjectNameMetaMapper;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+ at ManagementObject
+public class JmsDestination
+ implements Serializable
+{
+ private static final long serialVersionUID = 1;
+ private String jndiName;
+ private SecDomainMD domain;
+ private String state;
+ private ObjectName expiryQueue;
+
+
+ @ManagementProperty(description="The expiry queue",
+ use={ViewUse.RUNTIME}, includeInTemplate=true)
+ @MetaMapping(StringObjectNameMetaMapper.class)
+ protected ObjectName getExpiryQueue()
+ {
+ return expiryQueue;
+ }
+ protected void setExpiryQueue(ObjectName expiryQueue)
+ {
+ this.expiryQueue = expiryQueue;
+ }
+
+ @ManagementProperty(description="The destination state",
+ use={ViewUse.STATISTIC}, includeInTemplate=false)
+ @RunStateProperty(value=StringRunStateMapper.class,
+ metaValues={"State0", "State1", "ErrorState"},
+ enumValues={"RUNNING", "STOPPED", "FAILED"}
+ )
+ public String getState()
+ {
+ return state;
+ }
+ public void setState(String state)
+ {
+ this.state = state;
+ }
+
+ @ManagementProperty(description="JNDI binding location of destination", includeInTemplate=true)
+ public String getJndiName()
+ {
+ return jndiName;
+ }
+ public void setJndiName(String jndiName)
+ {
+ this.jndiName = jndiName;
+ }
+
+ @ManagementProperty(use={ViewUse.STATISTIC}, includeInTemplate=false)
+ public int getMsgCount()
+ {
+ return 0;
+ }
+ @ManagementProperty(description="Security domain information", managed=true)
+ public SecDomainMD getDomain()
+ {
+ return domain;
+ }
+ public void setDomain(SecDomainMD domain)
+ {
+ this.domain = domain;
+ }
+}
Copied: projects/jboss-man/tags/2.1.0.CR7/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/MessageListMapper.java (from rev 87004, projects/jboss-man/branches/Branch_2_1/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/MessageListMapper.java)
===================================================================
--- projects/jboss-man/tags/2.1.0.CR7/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/MessageListMapper.java (rev 0)
+++ projects/jboss-man/tags/2.1.0.CR7/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/MessageListMapper.java 2009-04-08 21:47:06 UTC (rev 87006)
@@ -0,0 +1,110 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.test.managed.factory.support.deployment;
+
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.metatype.api.types.CollectionMetaType;
+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.CollectionValueSupport;
+import org.jboss.metatype.api.values.MapCompositeValueSupport;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.metatype.spi.values.MetaMapper;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class MessageListMapper extends MetaMapper<List<JBMessage>>
+{
+ public static final CollectionMetaType TYPE;
+ public static final CompositeMetaType MSG_TYPE;
+
+ static
+ {
+ String[] itemNames = {
+ "JMSMessageID",
+ "JMSTimestamp",
+ "JMSCorrelationID"
+ };
+ String[] itemDescriptions = {
+ "JMSMessageID",
+ "JMSTimestamp",
+ "JMSCorrelationID"
+ };
+ MetaType[] itemTypes = {
+ SimpleMetaType.STRING,
+ SimpleMetaType.LONG,
+ SimpleMetaType.STRING
+ };
+ MSG_TYPE = new ImmutableCompositeMetaType("javax.jms.Message", "JMS Message",
+ itemNames, itemDescriptions, itemTypes);
+ TYPE = new CollectionMetaType("java.util.List", MSG_TYPE);
+ }
+
+ @Override
+ public MetaValue createMetaValue(MetaType metaType, List<JBMessage> object)
+ {
+ ArrayList<MetaValue> tmp = new ArrayList<MetaValue>();
+ if(object != null)
+ {
+ for(JBMessage m : object)
+ {
+ MapCompositeValueSupport cvs = new MapCompositeValueSupport(MSG_TYPE);
+ cvs.put("JMSCorrelationID", SimpleValueSupport.wrap(m.getJMSCorrelationID()));
+ cvs.put("JMSTimestamp", SimpleValueSupport.wrap(m.getJMSTimestamp()));
+ cvs.put("JMSMessageID", SimpleValueSupport.wrap(m.getJMSMessageID()));
+ tmp.add(cvs);
+ }
+ }
+ MetaValue[] elements = new MetaValue[tmp.size()];
+ tmp.toArray(elements);
+ CollectionValueSupport msgs = new CollectionValueSupport(TYPE, elements);
+ return msgs;
+ }
+
+ @Override
+ public MetaType getMetaType()
+ {
+ return TYPE;
+ }
+
+ @Override
+ public Type mapToType()
+ {
+ return List.class;
+ }
+
+ @Override
+ public List<JBMessage> unwrapMetaValue(MetaValue metaValue)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Deleted: projects/jboss-man/tags/2.1.0.CR7/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/QueueDestination.java
===================================================================
--- projects/jboss-man/branches/Branch_2_1/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/QueueDestination.java 2009-04-08 21:28:11 UTC (rev 87000)
+++ projects/jboss-man/tags/2.1.0.CR7/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/QueueDestination.java 2009-04-08 21:47:06 UTC (rev 87006)
@@ -1,39 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, 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.test.managed.factory.support.deployment;
-
-import java.io.Serializable;
-
-import org.jboss.managed.api.annotation.ManagementComponent;
-import org.jboss.managed.api.annotation.ManagementObject;
-
-/**
- * @author Scott.Stark at jboss.org
- * @version $Revision:$
- */
- at ManagementObject(componentType=@ManagementComponent(type="JMSDestination", subtype="Queue"))
-public class QueueDestination extends JmsDestination
- implements Serializable
-{
- private static final long serialVersionUID = 1;
-
-}
Copied: projects/jboss-man/tags/2.1.0.CR7/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/QueueDestination.java (from rev 87004, projects/jboss-man/branches/Branch_2_1/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/QueueDestination.java)
===================================================================
--- projects/jboss-man/tags/2.1.0.CR7/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/QueueDestination.java (rev 0)
+++ projects/jboss-man/tags/2.1.0.CR7/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/QueueDestination.java 2009-04-08 21:47:06 UTC (rev 87006)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.test.managed.factory.support.deployment;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.management.ObjectName;
+
+import org.jboss.managed.api.annotation.ManagementComponent;
+import org.jboss.managed.api.annotation.ManagementObject;
+import org.jboss.managed.api.annotation.ManagementOperation;
+import org.jboss.metatype.api.annotations.MetaMapping;
+import org.jboss.metatype.plugins.values.mappers.StringObjectNameMetaMapper;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+ at ManagementObject(componentType=@ManagementComponent(type="JMSDestination", subtype="Queue"))
+public class QueueDestination extends JmsDestination
+ implements Serializable
+{
+ private static final long serialVersionUID = 1;
+
+ @ManagementOperation(description="List all undelivered msgs")
+ @MetaMapping(MessageListMapper.class)
+ public List listAllMessages()
+ {
+ ArrayList<JBMessage> msgs = new ArrayList<JBMessage>();
+ msgs.add(new JBMessage());
+ return msgs;
+ }
+
+ @ManagementOperation(description="List all undelivered msgs")
+ @MetaMapping(MessageListMapper.class)
+ public List listAllMessages(@MetaMapping(StringObjectNameMetaMapper.class) ObjectName x)
+ {
+ ArrayList<JBMessage> msgs = new ArrayList<JBMessage>();
+ msgs.add(new JBMessage());
+ return msgs;
+ }
+}
Deleted: projects/jboss-man/tags/2.1.0.CR7/managed/src/test/java/org/jboss/test/managed/factory/test/AbstractManagedObjectFactoryUnitTestCase.java
===================================================================
--- projects/jboss-man/branches/Branch_2_1/managed/src/test/java/org/jboss/test/managed/factory/test/AbstractManagedObjectFactoryUnitTestCase.java 2009-04-08 21:28:11 UTC (rev 87000)
+++ projects/jboss-man/tags/2.1.0.CR7/managed/src/test/java/org/jboss/test/managed/factory/test/AbstractManagedObjectFactoryUnitTestCase.java 2009-04-08 21:47:06 UTC (rev 87006)
@@ -1,538 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, 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.test.managed.factory.test;
-
-import java.lang.annotation.Annotation;
-import java.math.BigDecimal;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.jboss.annotation.factory.AnnotationCreator;
-import org.jboss.managed.api.ManagedObject;
-import org.jboss.managed.api.ManagedProperty;
-import org.jboss.managed.api.annotation.ManagementComponent;
-import org.jboss.managed.api.annotation.ManagementObject;
-import org.jboss.managed.api.factory.ManagedObjectFactory;
-import org.jboss.managed.plugins.factory.AbstractInstanceClassFactory;
-import org.jboss.managed.plugins.factory.AbstractManagedObjectFactory;
-import org.jboss.managed.plugins.factory.DefaultInstanceClassFactory;
-import org.jboss.managed.spi.factory.InstanceClassFactory;
-import org.jboss.metadata.plugins.loader.memory.MemoryMetaDataLoader;
-import org.jboss.metadata.spi.MetaData;
-import org.jboss.metadata.spi.retrieval.MetaDataRetrievalToMetaDataBridge;
-import org.jboss.metatype.api.types.CollectionMetaType;
-import org.jboss.metatype.api.types.MapCompositeMetaType;
-import org.jboss.metatype.api.types.MetaType;
-import org.jboss.metatype.api.values.CollectionValue;
-import org.jboss.metatype.api.values.CompositeValue;
-import org.jboss.metatype.api.values.GenericValue;
-import org.jboss.metatype.api.values.MetaValue;
-import org.jboss.metatype.api.values.SimpleValue;
-import org.jboss.metatype.api.values.SimpleValueSupport;
-import org.jboss.test.managed.factory.AbstractManagedObjectFactoryTest;
-import org.jboss.test.managed.factory.support.ManagementObjectChangedName;
-import org.jboss.test.managed.factory.support.ManagementPropertySimpleManaged;
-import org.jboss.test.managed.factory.support.Simple;
-import org.jboss.test.managed.factory.support.SimpleUnannotated;
-import org.jboss.test.managed.factory.support.amof.CustomName;
-import org.jboss.test.managed.factory.support.amof.ManagementObjectWithRuntimeRef;
-import org.jboss.test.managed.factory.support.amof.ManagementObjectWithRuntimeRefICF;
-import org.jboss.test.managed.factory.support.amof.TestICF;
-import org.jboss.test.managed.factory.support.amof.TestMOP;
-import org.jboss.test.managed.factory.support.amof.TestSimpleICF;
-import org.jboss.test.managed.factory.support.beans.ABeanMetaData;
-import org.jboss.test.managed.factory.support.beans.AKernelDeployment;
-import org.jboss.test.managed.factory.support.beans.APropertyMetaData;
-import org.jboss.test.managed.factory.support.beans.BeanMetaDataICF;
-import org.jboss.test.managed.factory.support.beans.IBeanMetaData;
-import org.jboss.test.managed.factory.support.beans.IBeanMetaDataFactory;
-import org.jboss.test.managed.factory.support.deployment.JmsDestination;
-import org.jboss.test.managed.factory.support.deployment.JmsDestinationICF;
-import org.jboss.test.managed.factory.support.deployment.JmsDestinations;
-import org.jboss.test.managed.factory.support.deployment.QueueDestination;
-import org.jboss.test.managed.factory.support.deployment.SecurityDomain;
-import org.jboss.test.managed.factory.support.mcf.ConnectionFactoryProperty;
-import org.jboss.test.managed.factory.support.mcf.DBMSMetaData;
-import org.jboss.test.managed.factory.support.mcf.DataSourceConnectionPropertyMetaData;
-import org.jboss.test.managed.factory.support.mcf.LocalDSInstanceClassFactory;
-import org.jboss.test.managed.factory.support.mcf.LocalDataSourceDeploymentMetaData;
-import org.jboss.test.managed.factory.support.mcf.ManagedConnectionFactoryDeploymentGroup;
-import org.jboss.test.managed.factory.support.mcf.ManagedConnectionFactoryDeploymentMetaData;
-import org.jboss.test.managed.factory.support.mcf.ManagedConnectionFactoryPropertyMetaData;
-import org.jboss.test.managed.factory.support.mcf.NoTxConnectionFactoryDeploymentMetaData;
-import org.jboss.test.managed.factory.support.mcf.NoTxICF;
-import org.jboss.test.managed.factory.support.mcf.SecurityMetaData;
-
-/**
- * Test of behavior of the AbstractManagedObjectFactory
- *
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public class AbstractManagedObjectFactoryUnitTestCase extends AbstractManagedObjectFactoryTest
-{
- private ManagedObjectFactory testMOF;
-
- public static Test suite()
- {
- return new TestSuite(AbstractManagedObjectFactoryUnitTestCase.class);
- }
-
- public AbstractManagedObjectFactoryUnitTestCase(String name)
- {
- super(name);
- }
-
- /**
- * Test overriding the AbstractManagedObjectFactory.defaultInstanceFactory
- */
- public void testDefaultInstanceFactory()
- {
- AbstractManagedObjectFactory mof = new AbstractManagedObjectFactory();
- mof.setDefaultInstanceFactory(new TestICF());
- TestSimpleICF icf = new TestSimpleICF();
- mof.setInstanceClassFactory(Simple.class, icf);
- testMOF = mof;
-
- BigDecimal bigDecimal = new BigDecimal(10);
- Simple simple = new Simple();
- simple.setBigDecimalValue(bigDecimal);
-
- ManagedObject managedObject = initManagedObject(simple);
- checkManagedObjectDefaults(Simple.class, managedObject);
- checkDefaultManagedProperties(managedObject, Simple.class);
-
- checkPropertyDefaults(managedObject, "bigDecimalValue", BigDecimal.class, bigDecimal);
- assertTrue("TestBigDecimalICF.isGetValueCalled", icf.isGetValueCalled());
-
- //
- managedObject = super.createManagedObject(ManagementPropertySimpleManaged.class);
- checkManagedObjectDefaults(ManagementPropertySimpleManaged.class, managedObject);
- checkDefaultManagedProperties(managedObject, ManagementPropertySimpleManaged.class);
- }
-
- /**
- * Test that the setDefaultManagedObjectPopulator overrides the MOF
- * default ManagedObjectPopulator
- */
- public void testDefaultManagedObjectPopulator()
- {
- AbstractManagedObjectFactory mof = new AbstractManagedObjectFactory();
- TestMOP mop = new TestMOP(mof.getConfiguration(), new TestSimpleICF(), mof.getInstanceFactories());
- mof.setDefaultManagedObjectPopulator(mop);
- testMOF = mof;
-
- BigDecimal bigDecimal = new BigDecimal(10);
- Simple simple = new Simple();
- simple.setBigDecimalValue(bigDecimal);
-
- ManagedObject managedObject = initManagedObject(simple);
- checkManagedObjectDefaults(Simple.class, managedObject);
- checkDefaultManagedProperties(managedObject, Simple.class);
- checkPropertyDefaults(managedObject, "bigDecimalValue", BigDecimal.class, bigDecimal);
- assertTrue("isPopulateManagedObjectCalled", mop.isPopulateManagedObjectCalled());
- //
- managedObject = createManagedObject(ManagementPropertySimpleManaged.class);
- checkManagedObjectDefaults(ManagementPropertySimpleManaged.class, managedObject);
- checkDefaultManagedProperties(managedObject, ManagementPropertySimpleManaged.class);
- assertTrue("isCreateObjectCalled", mop.isCreateObjectCalled());
-
- }
-
- public void testInstanceClassFactoryAddition()
- {
- AbstractManagedObjectFactory mof = new AbstractManagedObjectFactory();
- testMOF = mof;
-
- BeanMetaDataICF bicf = new BeanMetaDataICF();
- mof.addInstanceClassFactory(bicf);
- LocalDSInstanceClassFactory dsicf = new LocalDSInstanceClassFactory();
- mof.addInstanceClassFactory(dsicf);
- NoTxICF nticf = new NoTxICF();
- mof.addInstanceClassFactory(nticf);
-
- InstanceClassFactory icf = mof.getInstanceClassFactory(IBeanMetaData.class);
- assertEquals("IBeanMetaData ICF", bicf, icf);
- icf = mof.getInstanceClassFactory(LocalDataSourceDeploymentMetaData.class);
- assertEquals("LocalDataSourceDeploymentMetaData ICF", dsicf, icf);
- icf = mof.getInstanceClassFactory(NoTxConnectionFactoryDeploymentMetaData.class);
- assertEquals("NoTxConnectionFactoryDeploymentMetaData ICF", nticf, icf);
- }
-
- /**
- * Test that the MetaData repository annotations override/augment the class
- * annotations.
- */
- public void testMetaDataRepositoryOverride()
- throws Exception
- {
- MemoryMetaDataLoader memory = new MemoryMetaDataLoader();
- String annotationExpr = "@org.jboss.managed.api.annotation.ManagementObject(name=\"testMetaDataRepositoryOverride\",componentType=@org.jboss.managed.api.annotation.ManagementComponent(type=\"MCBean\", subtype=\"MetaDataTest\"))";
- ManagementObject override = (ManagementObject) AnnotationCreator.createAnnotation(annotationExpr, ManagementObject.class);
- memory.addAnnotation(override);
- MetaData metaData = new MetaDataRetrievalToMetaDataBridge(memory);
-
- BigDecimal bigDecimal = new BigDecimal(10);
- SimpleUnannotated simple = new SimpleUnannotated();
- simple.setBigDecimalValue(bigDecimal);
-
- ManagedObjectFactory mof = getMOF();
- ManagedObject managedObject = mof.initManagedObject(simple, metaData);
- assertEquals("testMetaDataRepositoryOverride", managedObject.getName());
- Map<String, Annotation> moAnnotations = managedObject.getAnnotations();
- assertEquals("MO annotations == 2;", 2, moAnnotations.size());
- ManagementObject moAnn = (ManagementObject) moAnnotations.get(ManagementObject.class.getName());
- ManagementComponent componentType = moAnn.componentType();
- assertEquals("componentType.type", "MCBean", componentType.type());
- assertEquals("componentType.subtype", "MetaDataTest", componentType.subtype());
- checkPropertyDefaults(managedObject, "bigDecimalValue", BigDecimal.class, bigDecimal);
- checkDefaultManagedProperties(managedObject, SimpleUnannotated.class);
- }
-
- @SuppressWarnings("unchecked")
- public void testGenericValueUpdate()
- {
- super.enableTrace("org.jboss.managed");
- AbstractManagedObjectFactory mof = new AbstractManagedObjectFactory();
- mof.setInstanceClassFactory(JmsDestination.class, new JmsDestinationICF(mof));
- testMOF = mof;
-
- JmsDestinations destinations = new JmsDestinations();
- List<JmsDestination> queues = new ArrayList<JmsDestination>();
- QueueDestination q1 = new QueueDestination();
- q1.setJndiName("queues/Q1");
- q1.setDomain(new SecurityDomain("java:/jaas/JMS"));
- queues.add(q1);
- destinations.setDestinations(queues);
-
- ManagedObject managedObject = initManagedObject(destinations);
- checkManagedObjectDefaults(JmsDestinations.class, managedObject);
-
- ManagedProperty destinationsMP = managedObject.getProperty("destinations");
- assertNotNull(destinationsMP);
- CollectionValue destinationsValue = (CollectionValue) destinationsMP.getValue();
- assertNotNull(destinationsValue);
- assertEquals(1, destinationsValue.getSize());
- GenericValue q1GV = (GenericValue) destinationsValue.getElements()[0];
- assertNotNull(q1GV);
-
- ManagedObject q1MO = (ManagedObject) q1GV.getValue();
- assertNotNull(q1MO);
- ManagedProperty domain = q1MO.getProperty("domain");
- getLog().info(domain);
- GenericValue domainGV = (GenericValue) domain.getValue();
- assertNotNull(domainGV);
- ManagedObject domainMO = (ManagedObject) domainGV.getValue();
- assertNotNull(domainMO);
-
- ManagedProperty domainName = domainMO.getProperty("domain");
- assertEquals(SimpleValueSupport.wrap("java:/jaas/JMS"), domainName.getValue());
-
- ManagedObject domainUpdateMO = initManagedObject(new SecurityDomain("java:/jaas/JMS2"));
- DefaultInstanceClassFactory icf = new DefaultInstanceClassFactory(mof);
- GenericValue domainUpdateGV = icf.getManagedObjectValue(domain, domainUpdateMO);
- assertNotNull(domainUpdateGV.getValue());
- domain.setValue(domainUpdateGV);
- // Validate this has been written through
- assertEquals("java:/jaas/JMS2", q1.getDomain().getDomain());
- }
-
- /**
- * Test the transformer value of the ManagementRuntimeRef annotation when
- * there is a custom ICF
- */
- public void testTransformer()
- {
- AbstractManagedObjectFactory mof = new AbstractManagedObjectFactory();
- mof.setInstanceClassFactory(ManagementObjectWithRuntimeRef.class, new ManagementObjectWithRuntimeRefICF());
- testMOF = mof;
-
- ManagementObjectWithRuntimeRef mowref = new ManagementObjectWithRuntimeRef();
- mowref.setRefName(new CustomName("jboss:test=testTransformer"));
- ManagedObject managedObject = initManagedObject(mowref);
- createManagedObject(ManagementObjectChangedName.class);
- assertEquals("jboss:test=testTransformer", managedObject.getComponentName());
- }
-
- /**
- * Test the
- * @throws Exception
- */
- public void testMCFHierarchy()
- throws Exception
- {
- ManagedConnectionFactoryDeploymentGroup mcf = initMCFDG();
- ManagedObjectFactory mof = getMOF();
- ManagedObject mcfMO = mof.initManagedObject(mcf, "ManagedConnectionFactoryDeploymentGroup", null);
- ManagedProperty deployments = mcfMO.getProperty("deployments");
- Object dvalue = deployments.getValue();
- assertTrue(dvalue.getClass()+"", dvalue instanceof CollectionValue);
- CollectionValue cv = (CollectionValue) dvalue;
- assertEquals(1, cv.getSize());
- Object cv0 = cv.iterator().next();
- assertTrue(cv0 instanceof GenericValue);
- GenericValue gv0 = (GenericValue) cv0;
- assertTrue(gv0.getValue() instanceof ManagedObject);
- ManagedObject mo = (ManagedObject) gv0.getValue();
- assertEquals(LocalDataSourceDeploymentMetaData.class.getName(), mo.getAttachmentName());
- assertEquals(mcfMO, mo.getParent());
-
- // Validate the security-domain
- ManagedProperty secDomain = mo.getProperty("security-domain");
- assertNotNull("security-domain", secDomain);
- GenericValue sdGV = (GenericValue) secDomain.getValue();
- assertNotNull("security-domain.GV", sdGV);
- ManagedObject secDomainMO = (ManagedObject) sdGV.getValue();
-
- assertNotNull("security-domain.MO", secDomainMO);
- assertEquals(mo, secDomainMO.getParent());
- ManagedProperty domainName = secDomainMO.getProperty("domain");
- assertNotNull("security-domain.MO.domain", domainName);
- assertEquals(SimpleValueSupport.wrap("java:/jaas/SomeDomain"), domainName.getValue());
- }
-
- /**
- * Test the custom ConnectionFactoryProperty used for the config-property of
- * ManagedConnectionFactoryDeploymentMetaData
- * @throws Exception
- */
- public void testManagedConnectionFactoryPropertyMetaData()
- throws Exception
- {
- ManagedConnectionFactoryDeploymentGroup mcf = initMCFDG();
- ManagedObjectFactory mof = getMOF();
- LocalDSInstanceClassFactory dsicf = new LocalDSInstanceClassFactory();
- mof.addInstanceClassFactory(dsicf);
- ManagedObject mcfMO = mof.initManagedObject(mcf, "ManagedConnectionFactoryDeploymentGroup", null);
- ManagedProperty deployments = mcfMO.getProperty("deployments");
- Object dvalue = deployments.getValue();
- assertTrue(dvalue.getClass()+"", dvalue instanceof CollectionValue);
- CollectionValue cv = (CollectionValue) dvalue;
- assertEquals(1, cv.getSize());
- Object cv0 = cv.iterator().next();
- assertTrue(cv0 instanceof GenericValue);
- GenericValue gv0 = (GenericValue) cv0;
- assertTrue(gv0.getValue() instanceof ManagedObject);
- ManagedObject mo = (ManagedObject) gv0.getValue();
- assertEquals(LocalDataSourceDeploymentMetaData.class.getName(), mo.getAttachmentName());
-
- ManagedProperty cpMP = mo.getProperty("config-property");
- assertNotNull("config-property", cpMP);
- assertTrue("config-property("+cpMP+") isa ConnectionFactoryProperty", cpMP instanceof ConnectionFactoryProperty);
- MetaType type = cpMP.getMetaType();
- assertTrue("config-property type("+type+") is MapCompositeMetaType", type instanceof MapCompositeMetaType);
- MetaValue value = cpMP.getValue();
- assertTrue("config-property("+value+") MapCompositeMetaType.isValue", value instanceof CompositeValue);
- CompositeValue cvalue = (CompositeValue) value;
- SimpleValue connectionPropertiesValue = (SimpleValue) cvalue.get("value");
- assertEquals("cp1-name=cp1-value\ncp2-name=cp2-value", connectionPropertiesValue.getValue().toString().trim());
- assertEquals(SimpleValueSupport.wrap("java.lang.String"), cvalue.get("type"));
- }
-
- public void testKernelDeployment()
- {
- AbstractManagedObjectFactory mof = new AbstractManagedObjectFactory();
- BeanMetaDataICF icf = new BeanMetaDataICF();
- icf.setDelegateICF(new DefaultInstanceClassFactory(mof));
- mof.setInstanceClassFactory(IBeanMetaData.class, icf);
- testMOF = mof;
-
- AKernelDeployment ad = new AKernelDeployment();
- ABeanMetaData bean1 = new ABeanMetaData();
- bean1.setBean(Simple.class.getName());
- bean1.setName("SimpleBean#1");
- ABeanMetaData bean2 = new ABeanMetaData();
- bean2.setBean(Simple.class.getName());
- bean2.setName("SimpleBean#2");
- ABeanMetaData bean3 = new ABeanMetaData();
- bean3.setBean(SimpleUnannotated.class.getName());
- bean3.setName("SimpleUnannotated#3");
- APropertyMetaData bean3P1 = new APropertyMetaData();
- bean3P1.setName("properties");
- bean3P1.setDescription("The bean properties");
- bean3P1.setPropertyType("java.util.Set<IPropertyMetaData>");
- bean3.addProperty(bean3P1);
-
- Simple simple1 = new Simple();
- simple1.setBigDecimalValue(new BigDecimal(123456));
- Simple simple2 = new Simple();
- simple2.setBigDecimalValue(new BigDecimal(222222));
- SimpleUnannotated simple3 = new SimpleUnannotated();
- simple3.setBigDecimalValue(new BigDecimal(333333));
- // Setup the bean name mappings
- BeanMetaDataICF.setBean("SimpleBean#1", simple1);
- BeanMetaDataICF.setBean("SimpleBean#2", simple2);
- BeanMetaDataICF.setBean("SimpleUnannotated#3", simple3);
- List<IBeanMetaDataFactory> beanFactories = new ArrayList<IBeanMetaDataFactory>();
- beanFactories.add(bean1);
- beanFactories.add(bean2);
- beanFactories.add(bean3);
- ad.setBeanFactories(beanFactories);
-
- ManagedObject mo = mof.initManagedObject(ad, "KernelDeployment", null);
- ManagedProperty beanFactoriesMP = mo.getProperty("beanFactories");
- assertNotNull("beanFactories MP", beanFactoriesMP);
- Object beanFactoriesMPValue = beanFactoriesMP.getValue();
- getLog().debug("beanFactories MP value: "+beanFactoriesMPValue);
- assertTrue(beanFactoriesMPValue instanceof CollectionValue);
- // The beanFactories
- CollectionValue cv = CollectionValue.class.cast(beanFactoriesMPValue);
- MetaValue[] cvs = cv.getElements();
-
-
- assertEquals(3, cv.getSize());
- // ABeanMetaData ManagedObject for SimpleBean#1
- MetaValue mv0 = cvs[0];
- assertTrue(mv0 instanceof GenericValue);
- GenericValue gv0 = GenericValue.class.cast(mv0);
- Object gv0Value = gv0.getValue();
- assertTrue(gv0Value instanceof ManagedObject);
- ManagedObject mo0 = ManagedObject.class.cast(gv0Value);
- assertEquals(bean1, mo0.getAttachment());
- ManagedProperty bigDecimalValueMP = mo0.getProperty("bigDecimalValue");
- assertNotNull(bigDecimalValueMP);
- assertEquals(SimpleValueSupport.wrap(new BigDecimal(123456)), bigDecimalValueMP.getValue());
- bigDecimalValueMP.setValue(SimpleValueSupport.wrap(new BigDecimal(987654)));
- assertEquals(new BigDecimal(987654), simple1.getBigDecimalValue());
-
- // ABeanMetaData ManagedObject for SimpleBean#2
- MetaValue mv1 = cvs[1];
- assertTrue(mv1 instanceof GenericValue);
- GenericValue gv1 = GenericValue.class.cast(mv1);
- Object gv1Value = gv1.getValue();
- assertTrue(gv1Value instanceof ManagedObject);
- ManagedObject mo1 = ManagedObject.class.cast(gv1Value);
- ManagedProperty bigDecimalValueMP1 = mo1.getProperty("bigDecimalValue");
- assertNotNull(bigDecimalValueMP1);
- assertEquals(SimpleValueSupport.wrap(new BigDecimal(222222)), bigDecimalValueMP1.getValue());
- bigDecimalValueMP1.setValue(SimpleValueSupport.wrap(new BigDecimal(12222221)));
- assertEquals(new BigDecimal(12222221), simple2.getBigDecimalValue());
-
- // ABeanMetaData ManagedObject for SimpleUnannotated#3
- MetaValue mv2 = cvs[2];
- assertTrue(mv2 instanceof GenericValue);
- GenericValue gv2 = GenericValue.class.cast(mv2);
- Object gv2Value = gv2.getValue();
- assertTrue(gv2Value instanceof ManagedObject);
- ManagedObject mo2 = ManagedObject.class.cast(gv2Value);
- ManagedProperty properties = mo2.getProperty("properties");
- assertNotNull(properties);
- assertTrue(properties.getMetaType().isCollection());
- CollectionMetaType amt = (CollectionMetaType) properties.getMetaType();
- MetaType etype = amt.getElementType();
- if (etype == AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE)
- {
- CollectionValue avalue = (CollectionValue) properties.getValue();
- assertNotNull(avalue);
- MetaValue[] elements = avalue.getElements();
- for(int n = 0; n < avalue.getSize(); n ++)
- {
- GenericValue gv = (GenericValue) elements[n];
- ManagedObject propMO = (ManagedObject) gv.getValue();
- //...
- }
- }
-
-
- }
-
- /**
- * Override to allow test specific ManagedObjectFactory
- */
- @Override
- protected ManagedObjectFactory getMOF()
- {
- ManagedObjectFactory mof = testMOF;
- if (mof == null)
- mof = super.getMOF();
- return mof;
- }
-
- protected ManagedConnectionFactoryDeploymentGroup initMCFDG()
- throws Exception
- {
- ManagedConnectionFactoryDeploymentGroup mcfs = new ManagedConnectionFactoryDeploymentGroup();
- LocalDataSourceDeploymentMetaData lds = new LocalDataSourceDeploymentMetaData();
- lds.setBackgroundValidation(true);
- lds.setBackgroundValidationMillis(5000);
- lds.setBlockingTimeoutMilliSeconds(5000);
- lds.setCheckValidConnectionSQL("select something from somewhere");
- lds.setConnectionDefinition("conn def");
- lds.setConnectionUrl("jdbc:xyz:a=b");
- DataSourceConnectionPropertyMetaData cp1 = new DataSourceConnectionPropertyMetaData();
- cp1.setName("cp1-name");
- cp1.setValue("cp1-value");
- DataSourceConnectionPropertyMetaData cp2 = new DataSourceConnectionPropertyMetaData();
- cp2.setName("cp2-name");
- cp2.setValue("cp2-value");
- DataSourceConnectionPropertyMetaData[] cps = {
- cp1, cp2
- };
- lds.setDataSourceConnectionProperties(Arrays.asList(cps));
- List<ManagedConnectionFactoryPropertyMetaData> mcps = new ArrayList<ManagedConnectionFactoryPropertyMetaData>();
- ManagedConnectionFactoryPropertyMetaData mcp1 = new ManagedConnectionFactoryPropertyMetaData();
- mcp1.setName("mcp1-name");
- mcp1.setValue("mcp1-value");
- mcp1.setType("java.lang.String");
- mcps.add(mcp1);
- ManagedConnectionFactoryPropertyMetaData mcp2 = new ManagedConnectionFactoryPropertyMetaData();
- mcp2.setName("mcp2-name");
- mcp2.setValue("mcp2-value");
- mcp2.setType("java.lang.String");
- mcps.add(mcp2);
- lds.setManagedConnectionFactoryProperties(mcps);
- lds.setDriverClass("org.jboss.jdbc.SomeDriver");
- lds.setExceptionSorterClassName("org.jboss.jdbc.SomeExceptionSorter");
- String[] depends = {"jboss:service=Naming", "jboss:service=Hypersonic,database=localDB"};
- lds.setDependsNames(Arrays.asList(depends));
- lds.setIdleTimeoutMinutes(15);
- lds.setInterleaving(false);
- lds.setMaxSize(100);
- lds.setMinSize(1);
- DBMSMetaData md = new DBMSMetaData();
- md.setTypeMapping("Hypersonic SQL");
- lds.setDBMSMetaData(md);
- lds.setNewConnectionSQL("run this on a new conn");
- lds.setPassWord("password");
- lds.setPrefill(true);
- lds.setPreparedStatementCacheSize(50);
- lds.setQueryTimeout(30000);
- lds.setUserName("user");
- // Set a SecurityMetaData to validate its MO
- SecurityMetaData smd = new SecurityMetaData();
- smd.setDomain("java:/jaas/SomeDomain");
- lds.setSecurityMetaData(smd);
-
- ManagedConnectionFactoryDeploymentMetaData[] mds = {lds};
- mcfs.setDeployments(Arrays.asList(mds));
- mcfs.setUrl(new URL("file:/deploy/some-ds.xml"));
- return mcfs;
- }
-
-}
Copied: projects/jboss-man/tags/2.1.0.CR7/managed/src/test/java/org/jboss/test/managed/factory/test/AbstractManagedObjectFactoryUnitTestCase.java (from rev 87004, projects/jboss-man/branches/Branch_2_1/managed/src/test/java/org/jboss/test/managed/factory/test/AbstractManagedObjectFactoryUnitTestCase.java)
===================================================================
--- projects/jboss-man/tags/2.1.0.CR7/managed/src/test/java/org/jboss/test/managed/factory/test/AbstractManagedObjectFactoryUnitTestCase.java (rev 0)
+++ projects/jboss-man/tags/2.1.0.CR7/managed/src/test/java/org/jboss/test/managed/factory/test/AbstractManagedObjectFactoryUnitTestCase.java 2009-04-08 21:47:06 UTC (rev 87006)
@@ -0,0 +1,583 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.test.managed.factory.test;
+
+import java.lang.annotation.Annotation;
+import java.math.BigDecimal;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jboss.annotation.factory.AnnotationCreator;
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.api.ManagedOperation;
+import org.jboss.managed.api.ManagedParameter;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.managed.api.annotation.ManagementComponent;
+import org.jboss.managed.api.annotation.ManagementObject;
+import org.jboss.managed.api.factory.ManagedObjectFactory;
+import org.jboss.managed.plugins.ManagedOperationMatcher;
+import org.jboss.managed.plugins.factory.AbstractInstanceClassFactory;
+import org.jboss.managed.plugins.factory.AbstractManagedObjectFactory;
+import org.jboss.managed.plugins.factory.DefaultInstanceClassFactory;
+import org.jboss.managed.spi.factory.InstanceClassFactory;
+import org.jboss.metadata.plugins.loader.memory.MemoryMetaDataLoader;
+import org.jboss.metadata.spi.MetaData;
+import org.jboss.metadata.spi.retrieval.MetaDataRetrievalToMetaDataBridge;
+import org.jboss.metatype.api.types.CollectionMetaType;
+import org.jboss.metatype.api.types.MapCompositeMetaType;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.CollectionValue;
+import org.jboss.metatype.api.values.CompositeValue;
+import org.jboss.metatype.api.values.GenericValue;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.metatype.plugins.values.mappers.StringObjectNameMetaMapper;
+import org.jboss.metatype.spi.values.MetaMapper;
+import org.jboss.test.managed.factory.AbstractManagedObjectFactoryTest;
+import org.jboss.test.managed.factory.support.ManagementObjectChangedName;
+import org.jboss.test.managed.factory.support.ManagementPropertySimpleManaged;
+import org.jboss.test.managed.factory.support.Simple;
+import org.jboss.test.managed.factory.support.SimpleUnannotated;
+import org.jboss.test.managed.factory.support.amof.CustomName;
+import org.jboss.test.managed.factory.support.amof.ManagementObjectWithRuntimeRef;
+import org.jboss.test.managed.factory.support.amof.ManagementObjectWithRuntimeRefICF;
+import org.jboss.test.managed.factory.support.amof.TestICF;
+import org.jboss.test.managed.factory.support.amof.TestMOP;
+import org.jboss.test.managed.factory.support.amof.TestSimpleICF;
+import org.jboss.test.managed.factory.support.beans.ABeanMetaData;
+import org.jboss.test.managed.factory.support.beans.AKernelDeployment;
+import org.jboss.test.managed.factory.support.beans.APropertyMetaData;
+import org.jboss.test.managed.factory.support.beans.BeanMetaDataICF;
+import org.jboss.test.managed.factory.support.beans.IBeanMetaData;
+import org.jboss.test.managed.factory.support.beans.IBeanMetaDataFactory;
+import org.jboss.test.managed.factory.support.deployment.JmsDestination;
+import org.jboss.test.managed.factory.support.deployment.JmsDestinationICF;
+import org.jboss.test.managed.factory.support.deployment.JmsDestinations;
+import org.jboss.test.managed.factory.support.deployment.MessageListMapper;
+import org.jboss.test.managed.factory.support.deployment.QueueDestination;
+import org.jboss.test.managed.factory.support.deployment.SecurityDomain;
+import org.jboss.test.managed.factory.support.mcf.ConnectionFactoryProperty;
+import org.jboss.test.managed.factory.support.mcf.DBMSMetaData;
+import org.jboss.test.managed.factory.support.mcf.DataSourceConnectionPropertyMetaData;
+import org.jboss.test.managed.factory.support.mcf.LocalDSInstanceClassFactory;
+import org.jboss.test.managed.factory.support.mcf.LocalDataSourceDeploymentMetaData;
+import org.jboss.test.managed.factory.support.mcf.ManagedConnectionFactoryDeploymentGroup;
+import org.jboss.test.managed.factory.support.mcf.ManagedConnectionFactoryDeploymentMetaData;
+import org.jboss.test.managed.factory.support.mcf.ManagedConnectionFactoryPropertyMetaData;
+import org.jboss.test.managed.factory.support.mcf.NoTxConnectionFactoryDeploymentMetaData;
+import org.jboss.test.managed.factory.support.mcf.NoTxICF;
+import org.jboss.test.managed.factory.support.mcf.SecurityMetaData;
+
+/**
+ * Test of behavior of the AbstractManagedObjectFactory
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class AbstractManagedObjectFactoryUnitTestCase extends AbstractManagedObjectFactoryTest
+{
+ private ManagedObjectFactory testMOF;
+
+ public static Test suite()
+ {
+ return new TestSuite(AbstractManagedObjectFactoryUnitTestCase.class);
+ }
+
+ public AbstractManagedObjectFactoryUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Test overriding the AbstractManagedObjectFactory.defaultInstanceFactory
+ */
+ public void testDefaultInstanceFactory()
+ {
+ AbstractManagedObjectFactory mof = new AbstractManagedObjectFactory();
+ mof.setDefaultInstanceFactory(new TestICF());
+ TestSimpleICF icf = new TestSimpleICF();
+ mof.setInstanceClassFactory(Simple.class, icf);
+ testMOF = mof;
+
+ BigDecimal bigDecimal = new BigDecimal(10);
+ Simple simple = new Simple();
+ simple.setBigDecimalValue(bigDecimal);
+
+ ManagedObject managedObject = initManagedObject(simple);
+ checkManagedObjectDefaults(Simple.class, managedObject);
+ checkDefaultManagedProperties(managedObject, Simple.class);
+
+ checkPropertyDefaults(managedObject, "bigDecimalValue", BigDecimal.class, bigDecimal);
+ assertTrue("TestBigDecimalICF.isGetValueCalled", icf.isGetValueCalled());
+
+ //
+ managedObject = super.createManagedObject(ManagementPropertySimpleManaged.class);
+ checkManagedObjectDefaults(ManagementPropertySimpleManaged.class, managedObject);
+ checkDefaultManagedProperties(managedObject, ManagementPropertySimpleManaged.class);
+ }
+
+ /**
+ * Test that the setDefaultManagedObjectPopulator overrides the MOF
+ * default ManagedObjectPopulator
+ */
+ public void testDefaultManagedObjectPopulator()
+ {
+ AbstractManagedObjectFactory mof = new AbstractManagedObjectFactory();
+ TestMOP mop = new TestMOP(mof.getConfiguration(), new TestSimpleICF(), mof.getInstanceFactories());
+ mof.setDefaultManagedObjectPopulator(mop);
+ testMOF = mof;
+
+ BigDecimal bigDecimal = new BigDecimal(10);
+ Simple simple = new Simple();
+ simple.setBigDecimalValue(bigDecimal);
+
+ ManagedObject managedObject = initManagedObject(simple);
+ checkManagedObjectDefaults(Simple.class, managedObject);
+ checkDefaultManagedProperties(managedObject, Simple.class);
+ checkPropertyDefaults(managedObject, "bigDecimalValue", BigDecimal.class, bigDecimal);
+ assertTrue("isPopulateManagedObjectCalled", mop.isPopulateManagedObjectCalled());
+ //
+ managedObject = createManagedObject(ManagementPropertySimpleManaged.class);
+ checkManagedObjectDefaults(ManagementPropertySimpleManaged.class, managedObject);
+ checkDefaultManagedProperties(managedObject, ManagementPropertySimpleManaged.class);
+ assertTrue("isCreateObjectCalled", mop.isCreateObjectCalled());
+
+ }
+
+ public void testInstanceClassFactoryAddition()
+ {
+ AbstractManagedObjectFactory mof = new AbstractManagedObjectFactory();
+ testMOF = mof;
+
+ BeanMetaDataICF bicf = new BeanMetaDataICF();
+ mof.addInstanceClassFactory(bicf);
+ LocalDSInstanceClassFactory dsicf = new LocalDSInstanceClassFactory();
+ mof.addInstanceClassFactory(dsicf);
+ NoTxICF nticf = new NoTxICF();
+ mof.addInstanceClassFactory(nticf);
+
+ InstanceClassFactory icf = mof.getInstanceClassFactory(IBeanMetaData.class);
+ assertEquals("IBeanMetaData ICF", bicf, icf);
+ icf = mof.getInstanceClassFactory(LocalDataSourceDeploymentMetaData.class);
+ assertEquals("LocalDataSourceDeploymentMetaData ICF", dsicf, icf);
+ icf = mof.getInstanceClassFactory(NoTxConnectionFactoryDeploymentMetaData.class);
+ assertEquals("NoTxConnectionFactoryDeploymentMetaData ICF", nticf, icf);
+ }
+
+ /**
+ * Test that the MetaData repository annotations override/augment the class
+ * annotations.
+ */
+ public void testMetaDataRepositoryOverride()
+ throws Exception
+ {
+ MemoryMetaDataLoader memory = new MemoryMetaDataLoader();
+ String annotationExpr = "@org.jboss.managed.api.annotation.ManagementObject(name=\"testMetaDataRepositoryOverride\",componentType=@org.jboss.managed.api.annotation.ManagementComponent(type=\"MCBean\", subtype=\"MetaDataTest\"))";
+ ManagementObject override = (ManagementObject) AnnotationCreator.createAnnotation(annotationExpr, ManagementObject.class);
+ memory.addAnnotation(override);
+ MetaData metaData = new MetaDataRetrievalToMetaDataBridge(memory);
+
+ BigDecimal bigDecimal = new BigDecimal(10);
+ SimpleUnannotated simple = new SimpleUnannotated();
+ simple.setBigDecimalValue(bigDecimal);
+
+ ManagedObjectFactory mof = getMOF();
+ ManagedObject managedObject = mof.initManagedObject(simple, metaData);
+ assertEquals("testMetaDataRepositoryOverride", managedObject.getName());
+ Map<String, Annotation> moAnnotations = managedObject.getAnnotations();
+ assertEquals("MO annotations == 2;", 2, moAnnotations.size());
+ ManagementObject moAnn = (ManagementObject) moAnnotations.get(ManagementObject.class.getName());
+ ManagementComponent componentType = moAnn.componentType();
+ assertEquals("componentType.type", "MCBean", componentType.type());
+ assertEquals("componentType.subtype", "MetaDataTest", componentType.subtype());
+ checkPropertyDefaults(managedObject, "bigDecimalValue", BigDecimal.class, bigDecimal);
+ checkDefaultManagedProperties(managedObject, SimpleUnannotated.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testGenericValueUpdate()
+ {
+ super.enableTrace("org.jboss.managed");
+ AbstractManagedObjectFactory mof = new AbstractManagedObjectFactory();
+ mof.setInstanceClassFactory(JmsDestination.class, new JmsDestinationICF(mof));
+ testMOF = mof;
+
+ JmsDestinations destinations = new JmsDestinations();
+ List<JmsDestination> queues = new ArrayList<JmsDestination>();
+ QueueDestination q1 = new QueueDestination();
+ q1.setJndiName("queues/Q1");
+ q1.setDomain(new SecurityDomain("java:/jaas/JMS"));
+ queues.add(q1);
+ destinations.setDestinations(queues);
+
+ ManagedObject managedObject = initManagedObject(destinations);
+ checkManagedObjectDefaults(JmsDestinations.class, managedObject);
+
+ ManagedProperty destinationsMP = managedObject.getProperty("destinations");
+ assertNotNull(destinationsMP);
+ CollectionValue destinationsValue = (CollectionValue) destinationsMP.getValue();
+ assertNotNull(destinationsValue);
+ assertEquals(1, destinationsValue.getSize());
+ GenericValue q1GV = (GenericValue) destinationsValue.getElements()[0];
+ assertNotNull(q1GV);
+
+ ManagedObject q1MO = (ManagedObject) q1GV.getValue();
+ assertNotNull(q1MO);
+ ManagedProperty domain = q1MO.getProperty("domain");
+ getLog().info(domain);
+ GenericValue domainGV = (GenericValue) domain.getValue();
+ assertNotNull(domainGV);
+ ManagedObject domainMO = (ManagedObject) domainGV.getValue();
+ assertNotNull(domainMO);
+
+ ManagedProperty domainName = domainMO.getProperty("domain");
+ assertEquals(SimpleValueSupport.wrap("java:/jaas/JMS"), domainName.getValue());
+
+ ManagedObject domainUpdateMO = initManagedObject(new SecurityDomain("java:/jaas/JMS2"));
+ DefaultInstanceClassFactory icf = new DefaultInstanceClassFactory(mof);
+ GenericValue domainUpdateGV = icf.getManagedObjectValue(domain, domainUpdateMO);
+ assertNotNull(domainUpdateGV.getValue());
+ domain.setValue(domainUpdateGV);
+ // Validate this has been written through
+ assertEquals("java:/jaas/JMS2", q1.getDomain().getDomain());
+ }
+
+ public void testManagedObjectReturnType()
+ {
+ QueueDestination q1 = new QueueDestination();
+ q1.setJndiName("queues/Q1");
+ q1.setDomain(new SecurityDomain("java:/jaas/JMS"));
+
+ ManagedObject q1MO = initManagedObject(q1);
+ Set<ManagedOperation> ops = q1MO.getOperations();
+ ManagedOperation listAllMessages = ManagedOperationMatcher.findOperation(ops, "listAllMessages");
+ assertNotNull(listAllMessages);
+ MetaType returnType = listAllMessages.getReturnType();
+ assertEquals(MessageListMapper.TYPE, returnType);
+ MetaMapper returnTypeMapper = listAllMessages.getTransientAttachment(MetaMapper.class);
+ assertNotNull(returnTypeMapper);
+ assertTrue(returnTypeMapper instanceof MessageListMapper);
+ }
+
+ public void testManagedObjectParamsType()
+ {
+ QueueDestination q1 = new QueueDestination();
+ q1.setJndiName("queues/Q1");
+ q1.setDomain(new SecurityDomain("java:/jaas/JMS"));
+
+ ManagedObject q1MO = initManagedObject(q1);
+ Set<ManagedOperation> ops = q1MO.getOperations();
+ ManagedOperation listAllMessages = ManagedOperationMatcher.findOperation(ops, "listAllMessages", SimpleMetaType.STRING);
+ assertNotNull(listAllMessages);
+ MetaType returnType = listAllMessages.getReturnType();
+ assertEquals(MessageListMapper.TYPE, returnType);
+ ManagedParameter[] params = listAllMessages.getParameters();
+ assertEquals(1, params.length);
+ assertEquals(SimpleMetaType.STRING, params[0].getMetaType());
+ MetaMapper mapper = params[0].getTransientAttachment(MetaMapper.class);
+ assertNotNull(mapper);
+ assertTrue(mapper instanceof StringObjectNameMetaMapper);
+ }
+
+ /**
+ * Test the transformer value of the ManagementRuntimeRef annotation when
+ * there is a custom ICF
+ */
+ public void testTransformer()
+ {
+ AbstractManagedObjectFactory mof = new AbstractManagedObjectFactory();
+ mof.setInstanceClassFactory(ManagementObjectWithRuntimeRef.class, new ManagementObjectWithRuntimeRefICF());
+ testMOF = mof;
+
+ ManagementObjectWithRuntimeRef mowref = new ManagementObjectWithRuntimeRef();
+ mowref.setRefName(new CustomName("jboss:test=testTransformer"));
+ ManagedObject managedObject = initManagedObject(mowref);
+ createManagedObject(ManagementObjectChangedName.class);
+ assertEquals("jboss:test=testTransformer", managedObject.getComponentName());
+ }
+
+ /**
+ * Test the
+ * @throws Exception
+ */
+ public void testMCFHierarchy()
+ throws Exception
+ {
+ ManagedConnectionFactoryDeploymentGroup mcf = initMCFDG();
+ ManagedObjectFactory mof = getMOF();
+ ManagedObject mcfMO = mof.initManagedObject(mcf, "ManagedConnectionFactoryDeploymentGroup", null);
+ ManagedProperty deployments = mcfMO.getProperty("deployments");
+ Object dvalue = deployments.getValue();
+ assertTrue(dvalue.getClass()+"", dvalue instanceof CollectionValue);
+ CollectionValue cv = (CollectionValue) dvalue;
+ assertEquals(1, cv.getSize());
+ Object cv0 = cv.iterator().next();
+ assertTrue(cv0 instanceof GenericValue);
+ GenericValue gv0 = (GenericValue) cv0;
+ assertTrue(gv0.getValue() instanceof ManagedObject);
+ ManagedObject mo = (ManagedObject) gv0.getValue();
+ assertEquals(LocalDataSourceDeploymentMetaData.class.getName(), mo.getAttachmentName());
+ assertEquals(mcfMO, mo.getParent());
+
+ // Validate the security-domain
+ ManagedProperty secDomain = mo.getProperty("security-domain");
+ assertNotNull("security-domain", secDomain);
+ GenericValue sdGV = (GenericValue) secDomain.getValue();
+ assertNotNull("security-domain.GV", sdGV);
+ ManagedObject secDomainMO = (ManagedObject) sdGV.getValue();
+
+ assertNotNull("security-domain.MO", secDomainMO);
+ assertEquals(mo, secDomainMO.getParent());
+ ManagedProperty domainName = secDomainMO.getProperty("domain");
+ assertNotNull("security-domain.MO.domain", domainName);
+ assertEquals(SimpleValueSupport.wrap("java:/jaas/SomeDomain"), domainName.getValue());
+ }
+
+ /**
+ * Test the custom ConnectionFactoryProperty used for the config-property of
+ * ManagedConnectionFactoryDeploymentMetaData
+ * @throws Exception
+ */
+ public void testManagedConnectionFactoryPropertyMetaData()
+ throws Exception
+ {
+ ManagedConnectionFactoryDeploymentGroup mcf = initMCFDG();
+ ManagedObjectFactory mof = getMOF();
+ LocalDSInstanceClassFactory dsicf = new LocalDSInstanceClassFactory();
+ mof.addInstanceClassFactory(dsicf);
+ ManagedObject mcfMO = mof.initManagedObject(mcf, "ManagedConnectionFactoryDeploymentGroup", null);
+ ManagedProperty deployments = mcfMO.getProperty("deployments");
+ Object dvalue = deployments.getValue();
+ assertTrue(dvalue.getClass()+"", dvalue instanceof CollectionValue);
+ CollectionValue cv = (CollectionValue) dvalue;
+ assertEquals(1, cv.getSize());
+ Object cv0 = cv.iterator().next();
+ assertTrue(cv0 instanceof GenericValue);
+ GenericValue gv0 = (GenericValue) cv0;
+ assertTrue(gv0.getValue() instanceof ManagedObject);
+ ManagedObject mo = (ManagedObject) gv0.getValue();
+ assertEquals(LocalDataSourceDeploymentMetaData.class.getName(), mo.getAttachmentName());
+
+ ManagedProperty cpMP = mo.getProperty("config-property");
+ assertNotNull("config-property", cpMP);
+ assertTrue("config-property("+cpMP+") isa ConnectionFactoryProperty", cpMP instanceof ConnectionFactoryProperty);
+ MetaType type = cpMP.getMetaType();
+ assertTrue("config-property type("+type+") is MapCompositeMetaType", type instanceof MapCompositeMetaType);
+ MetaValue value = cpMP.getValue();
+ assertTrue("config-property("+value+") MapCompositeMetaType.isValue", value instanceof CompositeValue);
+ CompositeValue cvalue = (CompositeValue) value;
+ SimpleValue connectionPropertiesValue = (SimpleValue) cvalue.get("value");
+ assertEquals("cp1-name=cp1-value\ncp2-name=cp2-value", connectionPropertiesValue.getValue().toString().trim());
+ assertEquals(SimpleValueSupport.wrap("java.lang.String"), cvalue.get("type"));
+ }
+
+ public void testKernelDeployment()
+ {
+ AbstractManagedObjectFactory mof = new AbstractManagedObjectFactory();
+ BeanMetaDataICF icf = new BeanMetaDataICF();
+ icf.setDelegateICF(new DefaultInstanceClassFactory(mof));
+ mof.setInstanceClassFactory(IBeanMetaData.class, icf);
+ testMOF = mof;
+
+ AKernelDeployment ad = new AKernelDeployment();
+ ABeanMetaData bean1 = new ABeanMetaData();
+ bean1.setBean(Simple.class.getName());
+ bean1.setName("SimpleBean#1");
+ ABeanMetaData bean2 = new ABeanMetaData();
+ bean2.setBean(Simple.class.getName());
+ bean2.setName("SimpleBean#2");
+ ABeanMetaData bean3 = new ABeanMetaData();
+ bean3.setBean(SimpleUnannotated.class.getName());
+ bean3.setName("SimpleUnannotated#3");
+ APropertyMetaData bean3P1 = new APropertyMetaData();
+ bean3P1.setName("properties");
+ bean3P1.setDescription("The bean properties");
+ bean3P1.setPropertyType("java.util.Set<IPropertyMetaData>");
+ bean3.addProperty(bean3P1);
+
+ Simple simple1 = new Simple();
+ simple1.setBigDecimalValue(new BigDecimal(123456));
+ Simple simple2 = new Simple();
+ simple2.setBigDecimalValue(new BigDecimal(222222));
+ SimpleUnannotated simple3 = new SimpleUnannotated();
+ simple3.setBigDecimalValue(new BigDecimal(333333));
+ // Setup the bean name mappings
+ BeanMetaDataICF.setBean("SimpleBean#1", simple1);
+ BeanMetaDataICF.setBean("SimpleBean#2", simple2);
+ BeanMetaDataICF.setBean("SimpleUnannotated#3", simple3);
+ List<IBeanMetaDataFactory> beanFactories = new ArrayList<IBeanMetaDataFactory>();
+ beanFactories.add(bean1);
+ beanFactories.add(bean2);
+ beanFactories.add(bean3);
+ ad.setBeanFactories(beanFactories);
+
+ ManagedObject mo = mof.initManagedObject(ad, "KernelDeployment", null);
+ ManagedProperty beanFactoriesMP = mo.getProperty("beanFactories");
+ assertNotNull("beanFactories MP", beanFactoriesMP);
+ Object beanFactoriesMPValue = beanFactoriesMP.getValue();
+ getLog().debug("beanFactories MP value: "+beanFactoriesMPValue);
+ assertTrue(beanFactoriesMPValue instanceof CollectionValue);
+ // The beanFactories
+ CollectionValue cv = CollectionValue.class.cast(beanFactoriesMPValue);
+ MetaValue[] cvs = cv.getElements();
+
+
+ assertEquals(3, cv.getSize());
+ // ABeanMetaData ManagedObject for SimpleBean#1
+ MetaValue mv0 = cvs[0];
+ assertTrue(mv0 instanceof GenericValue);
+ GenericValue gv0 = GenericValue.class.cast(mv0);
+ Object gv0Value = gv0.getValue();
+ assertTrue(gv0Value instanceof ManagedObject);
+ ManagedObject mo0 = ManagedObject.class.cast(gv0Value);
+ assertEquals(bean1, mo0.getAttachment());
+ ManagedProperty bigDecimalValueMP = mo0.getProperty("bigDecimalValue");
+ assertNotNull(bigDecimalValueMP);
+ assertEquals(SimpleValueSupport.wrap(new BigDecimal(123456)), bigDecimalValueMP.getValue());
+ bigDecimalValueMP.setValue(SimpleValueSupport.wrap(new BigDecimal(987654)));
+ assertEquals(new BigDecimal(987654), simple1.getBigDecimalValue());
+
+ // ABeanMetaData ManagedObject for SimpleBean#2
+ MetaValue mv1 = cvs[1];
+ assertTrue(mv1 instanceof GenericValue);
+ GenericValue gv1 = GenericValue.class.cast(mv1);
+ Object gv1Value = gv1.getValue();
+ assertTrue(gv1Value instanceof ManagedObject);
+ ManagedObject mo1 = ManagedObject.class.cast(gv1Value);
+ ManagedProperty bigDecimalValueMP1 = mo1.getProperty("bigDecimalValue");
+ assertNotNull(bigDecimalValueMP1);
+ assertEquals(SimpleValueSupport.wrap(new BigDecimal(222222)), bigDecimalValueMP1.getValue());
+ bigDecimalValueMP1.setValue(SimpleValueSupport.wrap(new BigDecimal(12222221)));
+ assertEquals(new BigDecimal(12222221), simple2.getBigDecimalValue());
+
+ // ABeanMetaData ManagedObject for SimpleUnannotated#3
+ MetaValue mv2 = cvs[2];
+ assertTrue(mv2 instanceof GenericValue);
+ GenericValue gv2 = GenericValue.class.cast(mv2);
+ Object gv2Value = gv2.getValue();
+ assertTrue(gv2Value instanceof ManagedObject);
+ ManagedObject mo2 = ManagedObject.class.cast(gv2Value);
+ ManagedProperty properties = mo2.getProperty("properties");
+ assertNotNull(properties);
+ assertTrue(properties.getMetaType().isCollection());
+ CollectionMetaType amt = (CollectionMetaType) properties.getMetaType();
+ MetaType etype = amt.getElementType();
+ if (etype == AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE)
+ {
+ CollectionValue avalue = (CollectionValue) properties.getValue();
+ assertNotNull(avalue);
+ MetaValue[] elements = avalue.getElements();
+ for(int n = 0; n < avalue.getSize(); n ++)
+ {
+ GenericValue gv = (GenericValue) elements[n];
+ ManagedObject propMO = (ManagedObject) gv.getValue();
+ //...
+ }
+ }
+
+
+ }
+
+ /**
+ * Override to allow test specific ManagedObjectFactory
+ */
+ @Override
+ protected ManagedObjectFactory getMOF()
+ {
+ ManagedObjectFactory mof = testMOF;
+ if (mof == null)
+ mof = super.getMOF();
+ return mof;
+ }
+
+ protected ManagedConnectionFactoryDeploymentGroup initMCFDG()
+ throws Exception
+ {
+ ManagedConnectionFactoryDeploymentGroup mcfs = new ManagedConnectionFactoryDeploymentGroup();
+ LocalDataSourceDeploymentMetaData lds = new LocalDataSourceDeploymentMetaData();
+ lds.setBackgroundValidation(true);
+ lds.setBackgroundValidationMillis(5000);
+ lds.setBlockingTimeoutMilliSeconds(5000);
+ lds.setCheckValidConnectionSQL("select something from somewhere");
+ lds.setConnectionDefinition("conn def");
+ lds.setConnectionUrl("jdbc:xyz:a=b");
+ DataSourceConnectionPropertyMetaData cp1 = new DataSourceConnectionPropertyMetaData();
+ cp1.setName("cp1-name");
+ cp1.setValue("cp1-value");
+ DataSourceConnectionPropertyMetaData cp2 = new DataSourceConnectionPropertyMetaData();
+ cp2.setName("cp2-name");
+ cp2.setValue("cp2-value");
+ DataSourceConnectionPropertyMetaData[] cps = {
+ cp1, cp2
+ };
+ lds.setDataSourceConnectionProperties(Arrays.asList(cps));
+ List<ManagedConnectionFactoryPropertyMetaData> mcps = new ArrayList<ManagedConnectionFactoryPropertyMetaData>();
+ ManagedConnectionFactoryPropertyMetaData mcp1 = new ManagedConnectionFactoryPropertyMetaData();
+ mcp1.setName("mcp1-name");
+ mcp1.setValue("mcp1-value");
+ mcp1.setType("java.lang.String");
+ mcps.add(mcp1);
+ ManagedConnectionFactoryPropertyMetaData mcp2 = new ManagedConnectionFactoryPropertyMetaData();
+ mcp2.setName("mcp2-name");
+ mcp2.setValue("mcp2-value");
+ mcp2.setType("java.lang.String");
+ mcps.add(mcp2);
+ lds.setManagedConnectionFactoryProperties(mcps);
+ lds.setDriverClass("org.jboss.jdbc.SomeDriver");
+ lds.setExceptionSorterClassName("org.jboss.jdbc.SomeExceptionSorter");
+ String[] depends = {"jboss:service=Naming", "jboss:service=Hypersonic,database=localDB"};
+ lds.setDependsNames(Arrays.asList(depends));
+ lds.setIdleTimeoutMinutes(15);
+ lds.setInterleaving(false);
+ lds.setMaxSize(100);
+ lds.setMinSize(1);
+ DBMSMetaData md = new DBMSMetaData();
+ md.setTypeMapping("Hypersonic SQL");
+ lds.setDBMSMetaData(md);
+ lds.setNewConnectionSQL("run this on a new conn");
+ lds.setPassWord("password");
+ lds.setPrefill(true);
+ lds.setPreparedStatementCacheSize(50);
+ lds.setQueryTimeout(30000);
+ lds.setUserName("user");
+ // Set a SecurityMetaData to validate its MO
+ SecurityMetaData smd = new SecurityMetaData();
+ smd.setDomain("java:/jaas/SomeDomain");
+ lds.setSecurityMetaData(smd);
+
+ ManagedConnectionFactoryDeploymentMetaData[] mds = {lds};
+ mcfs.setDeployments(Arrays.asList(mds));
+ mcfs.setUrl(new URL("file:/deploy/some-ds.xml"));
+ return mcfs;
+ }
+
+}
Deleted: projects/jboss-man/tags/2.1.0.CR7/metatype/pom.xml
===================================================================
--- projects/jboss-man/branches/Branch_2_1/metatype/pom.xml 2009-04-08 21:28:11 UTC (rev 87000)
+++ projects/jboss-man/tags/2.1.0.CR7/metatype/pom.xml 2009-04-08 21:47:06 UTC (rev 87006)
@@ -1,74 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>org.jboss.man</groupId>
- <artifactId>jboss-man-parent</artifactId>
- <version>2.1.0-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <artifactId>jboss-metatype</artifactId>
- <packaging>jar</packaging>
- <name>JBoss Metatype</name>
- <url>http://www.jboss.org/jbossmc</url>
- <description>JBoss Metatype</description>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <testFailureIgnore>false</testFailureIgnore>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- <!-- Do not add version information here, use ../pom.xml instead -->
- <dependencies>
- <!-- Global dependencies -->
- <dependency>
- <groupId>org.jboss</groupId>
- <artifactId>jboss-reflect</artifactId>
- <exclusions>
- <exclusion>
- <groupId>org.jboss</groupId>
- <artifactId>jboss-common-core</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.jboss.logging</groupId>
- <artifactId>jboss-logging-spi</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.jboss.logging</groupId>
- <artifactId>jboss-logging-spi</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss</groupId>
- <artifactId>jboss-common-core</artifactId>
- </dependency>
- <!-- Test dependencies -->
- <dependency>
- <groupId>org.jboss.logging</groupId>
- <artifactId>jboss-logging-log4j</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.test</groupId>
- <artifactId>jboss-test</artifactId>
- <scope>test</scope>
- <exclusions>
- <exclusion>
- <groupId>org.jboss.man</groupId>
- <artifactId>jboss-managed</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-</project>
Copied: projects/jboss-man/tags/2.1.0.CR7/metatype/pom.xml (from rev 87005, projects/jboss-man/branches/Branch_2_1/metatype/pom.xml)
===================================================================
--- projects/jboss-man/tags/2.1.0.CR7/metatype/pom.xml (rev 0)
+++ projects/jboss-man/tags/2.1.0.CR7/metatype/pom.xml 2009-04-08 21:47:06 UTC (rev 87006)
@@ -0,0 +1,74 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.jboss.man</groupId>
+ <artifactId>jboss-man-parent</artifactId>
+ <version>2.1.0.CR7</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>jboss-metatype</artifactId>
+ <packaging>jar</packaging>
+ <name>JBoss Metatype</name>
+ <url>http://www.jboss.org/jbossmc</url>
+ <description>JBoss Metatype</description>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <testFailureIgnore>false</testFailureIgnore>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <!-- Do not add version information here, use ../pom.xml instead -->
+ <dependencies>
+ <!-- Global dependencies -->
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-reflect</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-common-core</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-spi</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-spi</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-common-core</artifactId>
+ </dependency>
+ <!-- Test dependencies -->
+ <dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-log4j</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.test</groupId>
+ <artifactId>jboss-test</artifactId>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.jboss.man</groupId>
+ <artifactId>jboss-managed</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
Deleted: projects/jboss-man/tags/2.1.0.CR7/metatype/src/main/java/org/jboss/metatype/api/annotations/MetaMapping.java
===================================================================
--- projects/jboss-man/branches/Branch_2_1/metatype/src/main/java/org/jboss/metatype/api/annotations/MetaMapping.java 2009-04-08 21:28:11 UTC (rev 87000)
+++ projects/jboss-man/tags/2.1.0.CR7/metatype/src/main/java/org/jboss/metatype/api/annotations/MetaMapping.java 2009-04-08 21:47:06 UTC (rev 87006)
@@ -1,48 +0,0 @@
-/*
-* 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.metatype.api.annotations;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-import org.jboss.metatype.spi.values.MetaMapper;
-
-/**
- * MetaMapper.
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
- at Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})
- at Retention(RetentionPolicy.RUNTIME)
-public @interface MetaMapping
-{
- /**
- * The meta mapper
- *
- * @return mapper class
- */
- Class<? extends MetaMapper<?>> value();
-}
Copied: projects/jboss-man/tags/2.1.0.CR7/metatype/src/main/java/org/jboss/metatype/api/annotations/MetaMapping.java (from rev 87004, projects/jboss-man/branches/Branch_2_1/metatype/src/main/java/org/jboss/metatype/api/annotations/MetaMapping.java)
===================================================================
--- projects/jboss-man/tags/2.1.0.CR7/metatype/src/main/java/org/jboss/metatype/api/annotations/MetaMapping.java (rev 0)
+++ projects/jboss-man/tags/2.1.0.CR7/metatype/src/main/java/org/jboss/metatype/api/annotations/MetaMapping.java 2009-04-08 21:47:06 UTC (rev 87006)
@@ -0,0 +1,48 @@
+/*
+* 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.metatype.api.annotations;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import org.jboss.metatype.spi.values.MetaMapper;
+
+/**
+ * MetaMapper.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+ at Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER})
+ at Retention(RetentionPolicy.RUNTIME)
+public @interface MetaMapping
+{
+ /**
+ * The meta mapper
+ *
+ * @return mapper class
+ */
+ Class<? extends MetaMapper<?>> value();
+}
Deleted: projects/jboss-man/tags/2.1.0.CR7/pom.xml
===================================================================
--- projects/jboss-man/branches/Branch_2_1/pom.xml 2009-04-08 21:28:11 UTC (rev 87000)
+++ projects/jboss-man/tags/2.1.0.CR7/pom.xml 2009-04-08 21:47:06 UTC (rev 87006)
@@ -1,250 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.jboss</groupId>
- <artifactId>jboss-parent</artifactId>
- <version>4</version>
- </parent>
- <groupId>org.jboss.man</groupId>
- <artifactId>jboss-man-parent</artifactId>
- <version>2.1.0-SNAPSHOT</version>
- <packaging>pom</packaging>
- <name>JBoss Managed Parent POM</name>
- <url>http://www.jboss.org/jbossmc</url>
- <description>JBoss Managed Parent POM</description>
- <scm>
- <connection>scm:svn:http://anonsvn.jboss.org/repos/jbossas/projects/jboss-man/branches/</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/jbossas/projects/jboss-man/branches/</developerConnection>
- <url>http://viewvc.jboss.org/cgi-bin/viewvc.cgi/jbossas/projects/jboss-man/trunk/</url>
- </scm>
-
- <properties>
- <version.jboss.common.core>2.2.10.GA</version.jboss.common.core>
- <version.jboss.common.logging.spi>2.0.5.GA</version.jboss.common.logging.spi>
- <version.jboss.common.logging.log4j>2.0.5.GA</version.jboss.common.logging.log4j>
- <version.org.jboss.reflect>2.0.2.GA</version.org.jboss.reflect>
- <version.org.jboss.mdr>2.0.1.GA</version.org.jboss.mdr>
- <version.org.jboss.test>1.1.3.GA</version.org.jboss.test>
- <version.junit>4.4</version.junit>
- <version.sun.jaxb>2.1.4</version.sun.jaxb>
- <version.javassist>3.9.0.GA</version.javassist>
- </properties>
-
- <modules>
- <module>metatype</module>
- <module>managed</module>
- <module>build</module>
- </modules>
-
- <build>
- <outputDirectory>${microcontainer.outputDirectory}</outputDirectory>
- <testOutputDirectory>${microcontainer.testOutputDirectory}</testOutputDirectory>
- <finalName>${artifactId}</finalName>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>2.0.2</version>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- <showDeprecation>true</showDeprecation>
- <showWarnings>true</showWarnings>
- <optimize>true</optimize>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-release-plugin</artifactId>
- <version>2.0-beta-7</version>
- <configuration>
- <tagBase>https://svn.jboss.org/repos/jbossas/projects/jboss-man/tags</tagBase>
- <autoVersionSubmodules>true</autoVersionSubmodules>
- </configuration>
- </plugin>
- </plugins>
-
- <pluginManagement>
- <plugins>
- <plugin>
- <artifactId>maven-idea-plugin</artifactId>
- <configuration>
- <downloadSources>true</downloadSources>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <version>2.2</version>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <version>2.4.2</version>
- <configuration>
- <redirectTestOutputToFile>true</redirectTestOutputToFile>
- <includes>
- <include>org/jboss/test/**/*TestCase.java</include>
- </includes>
- </configuration>
- </plugin>
- </plugins>
- </pluginManagement>
- </build>
-
- <reporting>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-project-info-reports-plugin</artifactId>
- <reportSets>
- <reportSet>
- <reports>
- <report>dependencies</report>
- <report>issue-tracking</report>
- <report>license</report>
- <report>scm</report>
- </reports>
- </reportSet>
- </reportSets>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>findbugs-maven-plugin</artifactId>
- <version>1.0.0</version>
- </plugin>
- </plugins>
- </reporting>
- <dependencyManagement>
- <!-- The parent pom manages the inter-dependencies of the modules. -->
- <dependencies>
- <dependency>
- <groupId>org.jboss.man</groupId>
- <artifactId>jboss-managed</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.jboss.man</groupId>
- <artifactId>jboss-metatype</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.jboss</groupId>
- <artifactId>jboss-common-core</artifactId>
- <version>${version.jboss.common.core}</version>
- </dependency>
- <dependency>
- <groupId>org.jboss.logging</groupId>
- <artifactId>jboss-logging-spi</artifactId>
- <version>${version.jboss.common.logging.spi}</version>
- </dependency>
- <dependency>
- <groupId>org.jboss.logging</groupId>
- <artifactId>jboss-logging-log4j</artifactId>
- <version>${version.jboss.common.logging.log4j}</version>
- </dependency>
- <dependency>
- <groupId>org.jboss</groupId>
- <artifactId>jboss-reflect</artifactId>
- <version>${version.org.jboss.reflect}</version>
- </dependency>
- <dependency>
- <groupId>org.jboss</groupId>
- <artifactId>jboss-mdr</artifactId>
- <version>${version.org.jboss.mdr}</version>
- </dependency>
- <!-- test dependencies -->
- <dependency>
- <groupId>org.jboss.test</groupId>
- <artifactId>jboss-test</artifactId>
- <version>${version.org.jboss.test}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>${version.junit}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>sun-jaxb</groupId>
- <artifactId>jaxb-api</artifactId>
- <version>${version.sun.jaxb}</version>
- </dependency>
- <dependency>
- <groupId>javassist</groupId>
- <artifactId>javassist</artifactId>
- <version>${version.javassist}</version>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
- <repositories>
- <repository>
- <id>repository.jboss.org</id>
- <name>JBoss Repository</name>
- <layout>default</layout>
- <url>http://repository.jboss.org/maven2/</url>
- <releases>
- <enabled>true</enabled>
- </releases>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- </repository>
- <repository>
- <id>snapshots.jboss.org</id>
- <name>JBoss Snapshots Repository</name>
- <layout>default</layout>
- <url>http://snapshots.jboss.org/maven2/</url>
- <snapshots>
- <enabled>true</enabled>
- </snapshots>
- <releases>
- <enabled>false</enabled>
- </releases>
- </repository>
- </repositories>
-
- <profiles>
- <profile>
- <id>default</id>
- <activation>
- <activeByDefault>true</activeByDefault>
- </activation>
- <properties>
- <microcontainer.outputDirectory>target/classes</microcontainer.outputDirectory>
- <microcontainer.testOutputDirectory>target/tests-classes</microcontainer.testOutputDirectory>
- </properties>
- </profile>
- <profile>
- <id>eclipse</id>
- <build>
- <defaultGoal>process-test-resources</defaultGoal>
- <plugins>
- <plugin>
- <artifactId>maven-eclipse-plugin</artifactId>
- <executions>
- <execution>
- <id>eclipse</id>
- <phase>process-test-resources</phase>
- <goals>
- <goal>eclipse</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <downloadSources>true</downloadSources>
- <buildOutputDirectory>${microcontainer.outputDirectory}</buildOutputDirectory>
- </configuration>
- </plugin>
- </plugins>
- </build>
- <properties>
- <microcontainer.outputDirectory>eclipse-target/classes</microcontainer.outputDirectory>
- <microcontainer.testOutputDirectory>eclipse-target/tests-classes</microcontainer.testOutputDirectory>
- </properties>
- </profile>
- </profiles>
-
-</project>
Copied: projects/jboss-man/tags/2.1.0.CR7/pom.xml (from rev 87005, projects/jboss-man/branches/Branch_2_1/pom.xml)
===================================================================
--- projects/jboss-man/tags/2.1.0.CR7/pom.xml (rev 0)
+++ projects/jboss-man/tags/2.1.0.CR7/pom.xml 2009-04-08 21:47:06 UTC (rev 87006)
@@ -0,0 +1,250 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-parent</artifactId>
+ <version>4</version>
+ </parent>
+ <groupId>org.jboss.man</groupId>
+ <artifactId>jboss-man-parent</artifactId>
+ <version>2.1.0.CR7</version>
+ <packaging>pom</packaging>
+ <name>JBoss Managed Parent POM</name>
+ <url>http://www.jboss.org/jbossmc</url>
+ <description>JBoss Managed Parent POM</description>
+ <scm>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/jbossas/projects/jboss-man/tags/2.1.0.CR7</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/jbossas/projects/jboss-man/tags/2.1.0.CR7</developerConnection>
+ <url>scm:svn:https://svn.jboss.org/repos/jbossas/projects/jboss-man/tags/2.1.0.CR7</url>
+ </scm>
+
+ <properties>
+ <version.jboss.common.core>2.2.10.GA</version.jboss.common.core>
+ <version.jboss.common.logging.spi>2.0.5.GA</version.jboss.common.logging.spi>
+ <version.jboss.common.logging.log4j>2.0.5.GA</version.jboss.common.logging.log4j>
+ <version.org.jboss.reflect>2.0.2.GA</version.org.jboss.reflect>
+ <version.org.jboss.mdr>2.0.1.GA</version.org.jboss.mdr>
+ <version.org.jboss.test>1.1.3.GA</version.org.jboss.test>
+ <version.junit>4.4</version.junit>
+ <version.sun.jaxb>2.1.4</version.sun.jaxb>
+ <version.javassist>3.9.0.GA</version.javassist>
+ </properties>
+
+ <modules>
+ <module>metatype</module>
+ <module>managed</module>
+ <module>build</module>
+ </modules>
+
+ <build>
+ <outputDirectory>${microcontainer.outputDirectory}</outputDirectory>
+ <testOutputDirectory>${microcontainer.testOutputDirectory}</testOutputDirectory>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.0.2</version>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ <showDeprecation>true</showDeprecation>
+ <showWarnings>true</showWarnings>
+ <optimize>true</optimize>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-release-plugin</artifactId>
+ <version>2.0-beta-7</version>
+ <configuration>
+ <tagBase>https://svn.jboss.org/repos/jbossas/projects/jboss-man/tags</tagBase>
+ <autoVersionSubmodules>true</autoVersionSubmodules>
+ </configuration>
+ </plugin>
+ </plugins>
+
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <artifactId>maven-idea-plugin</artifactId>
+ <configuration>
+ <downloadSources>true</downloadSources>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>2.2</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.4.2</version>
+ <configuration>
+ <redirectTestOutputToFile>true</redirectTestOutputToFile>
+ <includes>
+ <include>org/jboss/test/**/*TestCase.java</include>
+ </includes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-project-info-reports-plugin</artifactId>
+ <reportSets>
+ <reportSet>
+ <reports>
+ <report>dependencies</report>
+ <report>issue-tracking</report>
+ <report>license</report>
+ <report>scm</report>
+ </reports>
+ </reportSet>
+ </reportSets>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>findbugs-maven-plugin</artifactId>
+ <version>1.0.0</version>
+ </plugin>
+ </plugins>
+ </reporting>
+ <dependencyManagement>
+ <!-- The parent pom manages the inter-dependencies of the modules. -->
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.man</groupId>
+ <artifactId>jboss-managed</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.man</groupId>
+ <artifactId>jboss-metatype</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-common-core</artifactId>
+ <version>${version.jboss.common.core}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-spi</artifactId>
+ <version>${version.jboss.common.logging.spi}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-log4j</artifactId>
+ <version>${version.jboss.common.logging.log4j}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-reflect</artifactId>
+ <version>${version.org.jboss.reflect}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-mdr</artifactId>
+ <version>${version.org.jboss.mdr}</version>
+ </dependency>
+ <!-- test dependencies -->
+ <dependency>
+ <groupId>org.jboss.test</groupId>
+ <artifactId>jboss-test</artifactId>
+ <version>${version.org.jboss.test}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${version.junit}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>sun-jaxb</groupId>
+ <artifactId>jaxb-api</artifactId>
+ <version>${version.sun.jaxb}</version>
+ </dependency>
+ <dependency>
+ <groupId>javassist</groupId>
+ <artifactId>javassist</artifactId>
+ <version>${version.javassist}</version>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <repositories>
+ <repository>
+ <id>repository.jboss.org</id>
+ <name>JBoss Repository</name>
+ <layout>default</layout>
+ <url>http://repository.jboss.org/maven2/</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ <repository>
+ <id>snapshots.jboss.org</id>
+ <name>JBoss Snapshots Repository</name>
+ <layout>default</layout>
+ <url>http://snapshots.jboss.org/maven2/</url>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ </repository>
+ </repositories>
+
+ <profiles>
+ <profile>
+ <id>default</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <properties>
+ <microcontainer.outputDirectory>target/classes</microcontainer.outputDirectory>
+ <microcontainer.testOutputDirectory>target/tests-classes</microcontainer.testOutputDirectory>
+ </properties>
+ </profile>
+ <profile>
+ <id>eclipse</id>
+ <build>
+ <defaultGoal>process-test-resources</defaultGoal>
+ <plugins>
+ <plugin>
+ <artifactId>maven-eclipse-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>eclipse</id>
+ <phase>process-test-resources</phase>
+ <goals>
+ <goal>eclipse</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <downloadSources>true</downloadSources>
+ <buildOutputDirectory>${microcontainer.outputDirectory}</buildOutputDirectory>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <properties>
+ <microcontainer.outputDirectory>eclipse-target/classes</microcontainer.outputDirectory>
+ <microcontainer.testOutputDirectory>eclipse-target/tests-classes</microcontainer.testOutputDirectory>
+ </properties>
+ </profile>
+ </profiles>
+
+</project>
More information about the jboss-cvs-commits
mailing list