[jboss-cvs] JBossAS SVN: r81334 - in projects/jboss-man/tags: 2.0.0.CR5 and 10 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Nov 19 17:43:42 EST 2008
Author: scott.stark at jboss.org
Date: 2008-11-19 17:43:42 -0500 (Wed, 19 Nov 2008)
New Revision: 81334
Added:
projects/jboss-man/tags/2.0.0.CR5/
projects/jboss-man/tags/2.0.0.CR5/build/pom.xml
projects/jboss-man/tags/2.0.0.CR5/managed/pom.xml
projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/api/Fields.java
projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/api/ManagedObject.java
projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/api/ManagedOperation.java
projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/api/ManagedParameter.java
projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/api/ManagedProperty.java
projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/api/MutableManagedObject.java
projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/plugins/DefaultFieldsImpl.java
projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/plugins/ManagedOperationImpl.java
projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/plugins/ManagedParameterImpl.java
projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/plugins/ManagedPropertyImpl.java
projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/plugins/WritethroughManagedPropertyImpl.java
projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/plugins/factory/AbstractManagedObjectFactory.java
projects/jboss-man/tags/2.0.0.CR5/managed/src/test/java/org/jboss/test/managed/factory/test/ManagementPropertyUnitTestCase.java
projects/jboss-man/tags/2.0.0.CR5/managed/src/test/java/org/jboss/test/managed/mock/MockDOMFields.java
projects/jboss-man/tags/2.0.0.CR5/managed/src/test/java/org/jboss/test/managed/mock/MockTest.java
projects/jboss-man/tags/2.0.0.CR5/metatype/pom.xml
projects/jboss-man/tags/2.0.0.CR5/metatype/src/main/java/org/jboss/metatype/plugins/values/CompositeValueInvocationHandler.java
projects/jboss-man/tags/2.0.0.CR5/metatype/src/main/java/org/jboss/metatype/plugins/values/DefaultMetaValueFactory.java
projects/jboss-man/tags/2.0.0.CR5/metatype/src/test/java/org/jboss/test/metatype/values/factory/test/UnwrapValueUnitTestCase.java
projects/jboss-man/tags/2.0.0.CR5/pom.xml
Removed:
projects/jboss-man/tags/2.0.0.CR5/build/pom.xml
projects/jboss-man/tags/2.0.0.CR5/managed/pom.xml
projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/api/Fields.java
projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/api/ManagedObject.java
projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/api/ManagedOperation.java
projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/api/ManagedParameter.java
projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/api/ManagedProperty.java
projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/api/MutableManagedObject.java
projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/plugins/DefaultFieldsImpl.java
projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/plugins/ManagedOperationImpl.java
projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/plugins/ManagedParameterImpl.java
projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/plugins/ManagedPropertyImpl.java
projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/plugins/WritethroughManagedPropertyImpl.java
projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/plugins/factory/AbstractManagedObjectFactory.java
projects/jboss-man/tags/2.0.0.CR5/managed/src/test/java/org/jboss/test/managed/factory/test/ManagementPropertyUnitTestCase.java
projects/jboss-man/tags/2.0.0.CR5/managed/src/test/java/org/jboss/test/managed/mock/MockDOMFields.java
projects/jboss-man/tags/2.0.0.CR5/managed/src/test/java/org/jboss/test/managed/mock/MockTest.java
projects/jboss-man/tags/2.0.0.CR5/metatype/pom.xml
projects/jboss-man/tags/2.0.0.CR5/metatype/src/main/java/org/jboss/metatype/plugins/values/CompositeValueInvocationHandler.java
projects/jboss-man/tags/2.0.0.CR5/metatype/src/main/java/org/jboss/metatype/plugins/values/DefaultMetaValueFactory.java
projects/jboss-man/tags/2.0.0.CR5/metatype/src/test/java/org/jboss/test/metatype/values/factory/test/UnwrapValueUnitTestCase.java
projects/jboss-man/tags/2.0.0.CR5/pom.xml
Log:
[maven-release-plugin] copy for tag 2.0.0.CR5
Copied: projects/jboss-man/tags/2.0.0.CR5 (from rev 81300, projects/jboss-man/branches/Branch_2_0)
Deleted: projects/jboss-man/tags/2.0.0.CR5/build/pom.xml
===================================================================
--- projects/jboss-man/branches/Branch_2_0/build/pom.xml 2008-11-19 16:43:01 UTC (rev 81300)
+++ projects/jboss-man/tags/2.0.0.CR5/build/pom.xml 2008-11-19 22:43:42 UTC (rev 81334)
@@ -1,31 +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</artifactId>
- <version>2.0.0-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.jboss.man</groupId>
- <artifactId>jboss-man-dist</artifactId>
- <version>2.0.0-SNAPSHOT</version>
- <packaging>pom</packaging>
- <name>JBoss Managed Distribution Build</name>
- <url>http://www.jboss.com/products/jbossmc</url>
- <description>JBoss Managed Distribution Build</description>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-assembly-plugin</artifactId>
- <configuration>
- <descriptors>
- <descriptor>src/assembly/dist.xml</descriptor>
- <descriptor>src/assembly/src.xml</descriptor>
- </descriptors>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-</project>
\ No newline at end of file
Copied: projects/jboss-man/tags/2.0.0.CR5/build/pom.xml (from rev 81333, projects/jboss-man/branches/Branch_2_0/build/pom.xml)
===================================================================
--- projects/jboss-man/tags/2.0.0.CR5/build/pom.xml (rev 0)
+++ projects/jboss-man/tags/2.0.0.CR5/build/pom.xml 2008-11-19 22:43:42 UTC (rev 81334)
@@ -0,0 +1,31 @@
+<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</artifactId>
+ <version>2.0.0.CR5</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.jboss.man</groupId>
+ <artifactId>jboss-man-dist</artifactId>
+ <version>2.0.0.CR5</version>
+ <packaging>pom</packaging>
+ <name>JBoss Managed Distribution Build</name>
+ <url>http://www.jboss.com/products/jbossmc</url>
+ <description>JBoss Managed Distribution Build</description>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <configuration>
+ <descriptors>
+ <descriptor>src/assembly/dist.xml</descriptor>
+ <descriptor>src/assembly/src.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
\ No newline at end of file
Deleted: projects/jboss-man/tags/2.0.0.CR5/managed/pom.xml
===================================================================
--- projects/jboss-man/branches/Branch_2_0/managed/pom.xml 2008-11-19 16:43:01 UTC (rev 81300)
+++ projects/jboss-man/tags/2.0.0.CR5/managed/pom.xml 2008-11-19 22:43:42 UTC (rev 81334)
@@ -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</artifactId>
- <version>2.0.0-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <artifactId>jboss-managed</artifactId>
- <packaging>jar</packaging>
- <name>JBoss Managed</name>
- <url>http://www.jboss.com/products/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.0.0.CR5/managed/pom.xml (from rev 81333, projects/jboss-man/branches/Branch_2_0/managed/pom.xml)
===================================================================
--- projects/jboss-man/tags/2.0.0.CR5/managed/pom.xml (rev 0)
+++ projects/jboss-man/tags/2.0.0.CR5/managed/pom.xml 2008-11-19 22:43:42 UTC (rev 81334)
@@ -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</artifactId>
+ <version>2.0.0.CR5</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>jboss-managed</artifactId>
+ <packaging>jar</packaging>
+ <name>JBoss Managed</name>
+ <url>http://www.jboss.com/products/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.0.0.CR5/managed/src/main/java/org/jboss/managed/api/Fields.java
===================================================================
--- projects/jboss-man/branches/Branch_2_0/managed/src/main/java/org/jboss/managed/api/Fields.java 2008-11-19 16:43:01 UTC (rev 81300)
+++ projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/api/Fields.java 2008-11-19 22:43:42 UTC (rev 81334)
@@ -1,88 +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;
-
-/**
- * Fields.
- *
- * TODO the fields names should be annotation class names (where relevant) when the annotations exist
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
-public interface Fields extends Serializable
-{
- /** The name field name */
- String NAME = "name";
-
- /** The mapped name field name */
- String MAPPED_NAME = "mappedName";
-
- /** The description field name */
- String DESCRIPTION = "description";
-
- /** The meta type field name */
- String META_TYPE = "metaType";
-
- /** The value */
- String VALUE = "value";
-
- /** The legal values */
- String LEGAL_VALUES = "legalValues";
-
- /** The minimum value */
- String MINIMUM_VALUE = "minValue";
-
- /** The maximum value */
- String MAXIMUM_VALUE = "maxValue";
-
- /** The mandatory */
- String MANDATORY = "mandatory";
-
- /** The PropertyInfo info for the ManagedObject attachment */
- String PROPERTY_INFO = "propertyInfo";
-
- /** The annotations associated with the property */
- String ANNOTATIONS = "annotations";
-
- /** The attachment */
- String ATTACHMENT = "attachment";
-
- // TODO other standard fields here
-
- /**
- * Get a field with the given name
- *
- * @param name the name
- * @return the field value
- */
- Serializable getField(String name);
-
- /**
- * Set a field with the given name
- *
- * @param name the name
- * @param value the field value
- */
- void setField(String name, Serializable value);
-}
Copied: projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/api/Fields.java (from rev 81330, projects/jboss-man/branches/Branch_2_0/managed/src/main/java/org/jboss/managed/api/Fields.java)
===================================================================
--- projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/api/Fields.java (rev 0)
+++ projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/api/Fields.java 2008-11-19 22:43:42 UTC (rev 81334)
@@ -0,0 +1,93 @@
+/*
+* 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;
+
+/**
+ * Fields.
+ *
+ * TODO the fields names should be annotation class names (where relevant)
+ * when the annotations exist
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public interface Fields extends Serializable
+{
+ /** The name field name */
+ String NAME = "name";
+
+ /** The mapped name field name */
+ String MAPPED_NAME = "mappedName";
+
+ /** The description field name */
+ String DESCRIPTION = "description";
+
+ /** The meta type field name */
+ String META_TYPE = "metaType";
+
+ /** The value */
+ String VALUE = "value";
+
+ /** The legal values */
+ String LEGAL_VALUES = "legalValues";
+
+ /** The minimum value */
+ String MINIMUM_VALUE = "minValue";
+
+ /** The maximum value */
+ String MAXIMUM_VALUE = "maxValue";
+
+ /** The mandatory */
+ String MANDATORY = "mandatory";
+
+ /** The PropertyInfo info for the ManagedObject attachment */
+ String PROPERTY_INFO = "propertyInfo";
+
+ /** The annotations associated with the property */
+ String ANNOTATIONS = "annotations";
+
+ /** The attachment */
+ String ATTACHMENT = "attachment";
+
+ /** The ViewUses */
+ String VIEW_USE = "viewUse";
+
+ // TODO other standard fields here
+
+ /**
+ * Get a field with the given name
+ *
+ * @param name the name
+ * @return the field value
+ */
+ Object getField(String name);
+
+ /**
+ * Set a field with the given name
+ *
+ * @param name the name
+ * @param value the field value
+ */
+ void setField(String name, Object value);
+}
Deleted: projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/api/ManagedObject.java
===================================================================
--- projects/jboss-man/branches/Branch_2_0/managed/src/main/java/org/jboss/managed/api/ManagedObject.java 2008-11-19 16:43:01 UTC (rev 81300)
+++ projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/api/ManagedObject.java 2008-11-19 22:43:42 UTC (rev 81334)
@@ -1,69 +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 org.jboss.managed.api.annotation.ManagementRuntimeRef;
-
-/**
- * ManagedObject is an interface for a manageable element. It
- * consists of:
- * - a name/name type for a registry/references
- * - an attachment name to associate the ManagedObject with a
- * deployment attachment
- * - annotations from the metadata making up the ManagedObject
- * - the attachment instance
- * - the ManagedPropertys for the interface
- * - the ManagedOperations for the interface
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @author Scott.Stark at jboss.org
- * @version $Revision: 1.1 $
- */
-public interface ManagedObject extends ManagedCommon
-{
- /**
- * Get the underlying object
- *
- * @return the underlying object
- */
- Object getAttachment();
-
- /**
- * Get the annotations associated with the property
- * @return the annotations associated with the property
- */
- public Map<String, Annotation> getAnnotations();
-
- /**
- * Get the runtime component name.
- *
- * @see {@linkplain ManagementRuntimeRef}
- * @return name of runtime component if one exists, null if no component exists.
- */
- Object getComponentName();
-
- public ManagedObject getParent();
-}
Copied: projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/api/ManagedObject.java (from rev 81330, projects/jboss-man/branches/Branch_2_0/managed/src/main/java/org/jboss/managed/api/ManagedObject.java)
===================================================================
--- projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/api/ManagedObject.java (rev 0)
+++ projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/api/ManagedObject.java 2008-11-19 22:43:42 UTC (rev 81334)
@@ -0,0 +1,75 @@
+/*
+* 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.lang.annotation.Annotation;
+import java.util.Map;
+
+import org.jboss.managed.api.annotation.ManagementRuntimeRef;
+
+/**
+ * ManagedObject is an interface for a manageable element. It
+ * consists of:
+ * - a name/name type for a registry/references
+ * - an attachment name to associate the ManagedObject with a
+ * deployment attachment
+ * - annotations from the metadata making up the ManagedObject
+ * - the attachment instance
+ * - the ManagedPropertys for the interface
+ * - the ManagedOperations for the interface
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public interface ManagedObject extends ManagedCommon
+{
+ /**
+ * Get the underlying object. Note that this is only useful in the server
+ * environment where the ManagedObject is associated with a deployment
+ * attachment. In a client environment (admin tool for example), this is
+ * most likely null.
+ *
+ * @return the underlying object
+ */
+ Object getAttachment();
+
+ /**
+ * Get the annotations associated with the property
+ * @return the annotations associated with the property
+ */
+ public Map<String, Annotation> getAnnotations();
+
+ /**
+ * Get the runtime component name.
+ *
+ * @see {@linkplain ManagementRuntimeRef}
+ * @return name of runtime component if one exists, null if no component exists.
+ */
+ Object getComponentName();
+
+ /**
+ * Get the parent ManagedObject
+ * @return the parent if one exists, null otherwise
+ */
+ public ManagedObject getParent();
+}
Deleted: projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/api/ManagedOperation.java
===================================================================
--- projects/jboss-man/branches/Branch_2_0/managed/src/main/java/org/jboss/managed/api/ManagedOperation.java 2008-11-19 16:43:01 UTC (rev 81300)
+++ projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/api/ManagedOperation.java 2008-11-19 22:43:42 UTC (rev 81334)
@@ -1,88 +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();
-
- /**
- * Invoke the operation given its parameter values.
- *
- * @param param the varags for the operation parameters.
- * @return the MetaValue for the result.
- */
- public Object invoke(MetaValue... param);
-}
Copied: projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/api/ManagedOperation.java (from rev 81330, projects/jboss-man/branches/Branch_2_0/managed/src/main/java/org/jboss/managed/api/ManagedOperation.java)
===================================================================
--- projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/api/ManagedOperation.java (rev 0)
+++ projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/api/ManagedOperation.java 2008-11-19 22:43:42 UTC (rev 81334)
@@ -0,0 +1,88 @@
+/*
+* 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();
+
+ /**
+ * 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.0.0.CR5/managed/src/main/java/org/jboss/managed/api/ManagedParameter.java
===================================================================
--- projects/jboss-man/branches/Branch_2_0/managed/src/main/java/org/jboss/managed/api/ManagedParameter.java 2008-11-19 16:43:01 UTC (rev 81300)
+++ projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/api/ManagedParameter.java 2008-11-19 22:43:42 UTC (rev 81334)
@@ -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
- */
- Object getValue();
-
- /**
- * Set the value
- *
- * @param value the value
- */
- void setValue(Serializable 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(Serializable value);
-
-}
Copied: projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/api/ManagedParameter.java (from rev 81330, projects/jboss-man/branches/Branch_2_0/managed/src/main/java/org/jboss/managed/api/ManagedParameter.java)
===================================================================
--- projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/api/ManagedParameter.java (rev 0)
+++ projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/api/ManagedParameter.java 2008-11-19 22:43:42 UTC (rev 81334)
@@ -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
+{
+ /**
+ * 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.0.0.CR5/managed/src/main/java/org/jboss/managed/api/ManagedProperty.java
===================================================================
--- projects/jboss-man/branches/Branch_2_0/managed/src/main/java/org/jboss/managed/api/ManagedProperty.java 2008-11-19 16:43:01 UTC (rev 81300)
+++ projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/api/ManagedProperty.java 2008-11-19 22:43:42 UTC (rev 81334)
@@ -1,180 +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.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();
-
- /**
- * 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();
-
- /**
- * 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 value
- *
- * @return the value
- */
- Object getValue();
-
- /**
- * Set the value
- *
- * @param value the value
- */
- void setValue(Serializable 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(Serializable value);
-
- /**
- * Whether the property is mandatory
- *
- * @return true when mandatory
- */
- boolean isMandatory();
-}
Copied: projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/api/ManagedProperty.java (from rev 81330, projects/jboss-man/branches/Branch_2_0/managed/src/main/java/org/jboss/managed/api/ManagedProperty.java)
===================================================================
--- projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/api/ManagedProperty.java (rev 0)
+++ projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/api/ManagedProperty.java 2008-11-19 22:43:42 UTC (rev 81334)
@@ -0,0 +1,180 @@
+/*
+* 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.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();
+
+ /**
+ * 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();
+
+ /**
+ * 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 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(Serializable value);
+
+ /**
+ * Whether the property is mandatory
+ *
+ * @return true when mandatory
+ */
+ boolean isMandatory();
+}
Deleted: projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/api/MutableManagedObject.java
===================================================================
--- projects/jboss-man/branches/Branch_2_0/managed/src/main/java/org/jboss/managed/api/MutableManagedObject.java 2008-11-19 16:43:01 UTC (rev 81300)
+++ projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/api/MutableManagedObject.java 2008-11-19 22:43:42 UTC (rev 81334)
@@ -1,74 +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.managed.api;
-
-import java.util.Map;
-import java.util.Set;
-
-import org.jboss.managed.api.annotation.ManagementObject;
-import org.jboss.managed.api.annotation.ManagementObjectID;
-import org.jboss.managed.api.annotation.ManagementRuntimeRef;
-
-/**
- * An extension of ManagedObject that allows setting of key values after
- * the ManagedObject has been created.
- *
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public interface MutableManagedObject extends ManagedObject
-{
- /**
- * Set the external name by which the ManagedObject is known
- * @see {@linkplain ManagementObject#name}}
- * @see {@linkplain ManagementObjectID#name}}
- * @return the name
- */
- public void setName(String name);
- /**
- * Set the runtime component name.
- *
- * @see {@linkplain ManagementRuntimeRef}
- * @return name of runtime component if one exists, null if no component exists.
- */
- public void setComponentName(Object name);
- /**
- * Set the parent ManagedObject.
- * @param parent - the parent ManagedObject, null if no parent exists.
- */
- public void setParent(ManagedObject parent);
- /**
- * Set the metadata attachment.
- * @param attachment - the metadata attachment this ManagedObject maps to.
- */
- public void setAttachment(Object attachment);
- /**
- * Set the ManagedObject ManagedProperty mapping.
- * @param properties - the ManagedProperty mapping.
- */
- public void setProperties(Map<String, ManagedProperty> properties);
- /**
- * Set the ManagedOperation associated with the ManagedObject.
- * @param operations - the ManagedOperations for the ManagedObject.
- */
- public void setOperations(Set<ManagedOperation> operations);
-}
Copied: projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/api/MutableManagedObject.java (from rev 81330, projects/jboss-man/branches/Branch_2_0/managed/src/main/java/org/jboss/managed/api/MutableManagedObject.java)
===================================================================
--- projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/api/MutableManagedObject.java (rev 0)
+++ projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/api/MutableManagedObject.java 2008-11-19 22:43:42 UTC (rev 81334)
@@ -0,0 +1,74 @@
+/*
+ * 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.managed.api;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.managed.api.annotation.ManagementObject;
+import org.jboss.managed.api.annotation.ManagementObjectID;
+import org.jboss.managed.api.annotation.ManagementRuntimeRef;
+
+/**
+ * An extension of ManagedObject that allows setting of key values after
+ * the ManagedObject has been created.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public interface MutableManagedObject extends ManagedObject
+{
+ /**
+ * Set the external name by which the ManagedObject is known
+ * @see {@linkplain ManagementObject#name}}
+ * @see {@linkplain ManagementObjectID#name}}
+ * @return the name
+ */
+ public void setName(String name);
+ /**
+ * Set the runtime component name.
+ *
+ * @see {@linkplain ManagementRuntimeRef}
+ * @return name of runtime component if one exists, null if no component exists.
+ */
+ public void setComponentName(Object name);
+ /**
+ * Set the parent ManagedObject.
+ * @param parent - the parent ManagedObject, null if no parent exists.
+ */
+ public void setParent(ManagedObject parent);
+ /**
+ * Set the metadata attachment. This is only
+ * @param attachment - the metadata attachment this ManagedObject maps to.
+ */
+ public void setAttachment(Object attachment);
+ /**
+ * Set the ManagedObject ManagedProperty mapping.
+ * @param properties - the ManagedProperty mapping.
+ */
+ public void setProperties(Map<String, ManagedProperty> properties);
+ /**
+ * Set the ManagedOperation associated with the ManagedObject.
+ * @param operations - the ManagedOperations for the ManagedObject.
+ */
+ public void setOperations(Set<ManagedOperation> operations);
+}
Deleted: projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/plugins/DefaultFieldsImpl.java
===================================================================
--- projects/jboss-man/branches/Branch_2_0/managed/src/main/java/org/jboss/managed/plugins/DefaultFieldsImpl.java 2008-11-19 16:43:01 UTC (rev 81300)
+++ projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/plugins/DefaultFieldsImpl.java 2008-11-19 22:43:42 UTC (rev 81334)
@@ -1,333 +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.Serializable;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-import org.jboss.managed.api.Fields;
-import org.jboss.metatype.api.types.MetaType;
-import org.jboss.metatype.api.values.MetaValue;
-import org.jboss.metatype.api.values.SimpleValue;
-
-/**
- * A default implementation of the Fields interface.
- *
- * @author Scott.Stark at jboss.org
- * @version $Revision:$
- */
-public class DefaultFieldsImpl
- implements Fields
-{
- private static String END_MARKER = "__END_OF_FIELDS__";
-
- /** The serialVersionUID */
- private static final long serialVersionUID = 1;
-
- /** The fields */
- private HashMap<String, Serializable> fields = new HashMap<String, Serializable>();
-
- /**
- * Create a new DefaultFieldsImpl.
- */
- public DefaultFieldsImpl()
- {
- }
-
- /**
- * Create a new DefaultFieldsImpl.
- *
- * @param name the property name
- */
- public DefaultFieldsImpl(String name)
- {
- this.setName(name);
- }
-
- /**
- * Get the property name
- *
- * @return the name
- */
- public String getName()
- {
- return getField(NAME, String.class);
- }
-
- /**
- * Set the property name
- *
- * @param name the name
- */
- public void setName(String name)
- {
- setField(NAME, name);
- }
-
- /**
- * Get the description
- *
- * @return the description
- */
- public String getDescription()
- {
- return getField(DESCRIPTION, String.class);
- }
-
- /**
- * Set the description
- *
- * @param description the description
- */
- public void setDescription(String description)
- {
- setField(DESCRIPTION, description);
- }
-
- /**
- * Get the meta type
- *
- * @return the meta type
- */
- public MetaType getMetaType()
- {
- return getField(META_TYPE, MetaType.class);
- }
-
- /**
- * Set the meta type
- *
- * @param type the meta type
- */
- public void setMetaType(MetaType type)
- {
- setField(META_TYPE, type);
- }
-
- /**
- * Get the value
- *
- * @return the value
- */
- public Object getValue()
- {
- return getField(VALUE);
- }
-
- /**
- * Set the value
- *
- * @param value the value
- */
- public void setValue(Serializable value)
- {
- setField(VALUE, value);
- }
-
- /**
- * Get the legal values
- *
- * @return the values
- */
- @SuppressWarnings("unchecked")
- public Set<MetaValue> getLegalValues()
- {
- return getField(LEGAL_VALUES, Set.class);
- }
-
- /**
- * Set the legal values
- *
- * @param values the values
- */
- public void setLegalValues(Set<MetaValue> values)
- {
- setField(LEGAL_VALUES, (Serializable)values);
- }
-
- /**
- * Get the minimum value
- *
- * @return the minimum value
- */
- public Comparable<?> getMinimumValue()
- {
- return getField(MINIMUM_VALUE, Comparable.class);
- }
-
- /**
- * Set the minimum value
- *
- * @param value the value
- */
- public void setMinimumValue(Comparable<?> value)
- {
- setField(MINIMUM_VALUE, (Serializable)value);
- }
-
- /**
- * Get the maximum value
- *
- * @return the value
- */
- public Comparable<?> getMaximumValue()
- {
- return getField(MAXIMUM_VALUE, Comparable.class);
- }
-
- /**
- * Get the maximum value
- *
- * @param value the value
- */
- public void setMaximumValue(Comparable<?> value)
- {
- setField(MAXIMUM_VALUE, (Serializable)value);
- }
-
- /**
- * Get whether the property is mandatory
- *
- * @return true when mandaotry
- */
- public boolean isMandatory()
- {
- Boolean result = getField(MANDATORY, Boolean.class);
- if (result == null)
- return false;
- return result;
- }
-
- /**
- * Set the mandatory value
- *
- * @param flag true when mandatory
- */
- public void setMandatory(boolean flag)
- {
- if (flag)
- setField(MANDATORY, flag);
- else
- setField(MANDATORY, null);
- }
-
- /**
- * Get a field
- *
- * @param name the field name
- */
- public Serializable getField(String name)
- {
- return fields.get(name);
- }
-
- /**
- * Set a field
- *
- * @param name the field name
- * @param value the value
- */
- public void setField(String name, Serializable value)
- {
- fields.put(name, value);
- }
-
- /**
- * Get a field
- *
- * @param <T> the expected type
- * @param fieldName the field name
- * @param expected the expected type
- * @return the field value
- */
- @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");
-
- Serializable field = 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 a of the expected type: " + expected.getName());
- }
-
- /**
- * Only write out the fields that should be usable by a remote client.
- * Excludes:
- * PROPERTY_INFO
- * ATTACHMENT
- *
- * @param out
- * @throws IOException
- */
- private void writeObject(java.io.ObjectOutputStream out)
- throws IOException
- {
- for (Map.Entry<String, Serializable> entry : fields.entrySet())
- {
- if(entry.getKey().equals(PROPERTY_INFO))
- continue;
- if(entry.getKey().equals(ATTACHMENT))
- continue;
- out.writeUTF(entry.getKey());
- out.writeObject(entry.getValue());
- }
- out.writeUTF(END_MARKER);
- }
- private void readObject(java.io.ObjectInputStream in)
- throws IOException, ClassNotFoundException
- {
- fields = new HashMap<String, Serializable>();
- String key;
- do
- {
- key = in.readUTF();
- if(key.equals(END_MARKER))
- key = null;
- else
- {
- Serializable value = (Serializable) in.readObject();
- fields.put(key, value);
- }
- } while(key != null);
- }
-}
Copied: projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/plugins/DefaultFieldsImpl.java (from rev 81330, projects/jboss-man/branches/Branch_2_0/managed/src/main/java/org/jboss/managed/plugins/DefaultFieldsImpl.java)
===================================================================
--- projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/plugins/DefaultFieldsImpl.java (rev 0)
+++ projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/plugins/DefaultFieldsImpl.java 2008-11-19 22:43:42 UTC (rev 81334)
@@ -0,0 +1,375 @@
+/*
+ * 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.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.managed.api.Fields;
+import org.jboss.managed.api.annotation.ViewUse;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValue;
+
+/**
+ * A default implementation of the Fields interface.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class DefaultFieldsImpl
+ implements Fields
+{
+ private static String END_MARKER = "__END_OF_FIELDS__";
+
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 1;
+
+ /** The fields */
+ private HashMap<String, Object> fields = new HashMap<String, Object>();
+
+ /**
+ * Create a new DefaultFieldsImpl.
+ */
+ public DefaultFieldsImpl()
+ {
+ }
+
+ /**
+ * Create a new DefaultFieldsImpl.
+ *
+ * @param name the property name
+ */
+ public DefaultFieldsImpl(String name)
+ {
+ this.setName(name);
+ }
+
+ /**
+ * Get the property name
+ *
+ * @return the name
+ */
+ public String getName()
+ {
+ return getField(NAME, String.class);
+ }
+
+ /**
+ * Set the property name
+ *
+ * @param name the name
+ */
+ public void setName(String name)
+ {
+ setField(NAME, name);
+ }
+
+ /**
+ * Get the description
+ *
+ * @return the description
+ */
+ public String getDescription()
+ {
+ return getField(DESCRIPTION, String.class);
+ }
+
+ /**
+ * Set the description
+ *
+ * @param description the description
+ */
+ public void setDescription(String description)
+ {
+ setField(DESCRIPTION, description);
+ }
+
+ /**
+ * Get the meta type
+ *
+ * @return the meta type
+ */
+ public MetaType getMetaType()
+ {
+ return getField(META_TYPE, MetaType.class);
+ }
+
+ /**
+ * Set the meta type
+ *
+ * @param type the meta type
+ */
+ public void setMetaType(MetaType type)
+ {
+ setField(META_TYPE, type);
+ }
+
+ /**
+ * Get the value
+ *
+ * @return the value
+ */
+ public MetaValue getValue()
+ {
+ return getField(VALUE, MetaValue.class);
+ }
+
+ /**
+ * Set the value
+ *
+ * @param value the value
+ */
+ public void setValue(MetaValue value)
+ {
+ setField(VALUE, value);
+ }
+
+ /**
+ * Get the view use
+ * @return the view use field
+ */
+ public ViewUse[] getViewUse()
+ {
+ return getField(VIEW_USE, ViewUse[].class);
+ }
+ /**
+ * Set the view use
+ * @param use - the view use
+ */
+ public void setViewUse(ViewUse[] use)
+ {
+ setField(VIEW_USE, use);
+ }
+
+ /**
+ * Get the legal values
+ *
+ * @return the values
+ */
+ @SuppressWarnings("unchecked")
+ public Set<MetaValue> getLegalValues()
+ {
+ return getField(LEGAL_VALUES, Set.class);
+ }
+
+ /**
+ * Set the legal values
+ *
+ * @param values the values
+ */
+ public void setLegalValues(Set<MetaValue> values)
+ {
+ setField(LEGAL_VALUES, (Serializable)values);
+ }
+
+ /**
+ * Get the minimum value
+ *
+ * @return the minimum value
+ */
+ public Comparable<?> getMinimumValue()
+ {
+ return getField(MINIMUM_VALUE, Comparable.class);
+ }
+
+ /**
+ * Set the minimum value
+ *
+ * @param value the value
+ */
+ public void setMinimumValue(Comparable<?> value)
+ {
+ setField(MINIMUM_VALUE, (Serializable)value);
+ }
+
+ /**
+ * Get the maximum value
+ *
+ * @return the value
+ */
+ public Comparable<?> getMaximumValue()
+ {
+ return getField(MAXIMUM_VALUE, Comparable.class);
+ }
+
+ /**
+ * Get the maximum value
+ *
+ * @param value the value
+ */
+ public void setMaximumValue(Comparable<?> value)
+ {
+ setField(MAXIMUM_VALUE, (Serializable)value);
+ }
+
+ /**
+ * Get whether the property is mandatory
+ *
+ * @return true when mandaotry
+ */
+ public boolean isMandatory()
+ {
+ Boolean result = getField(MANDATORY, Boolean.class);
+ if (result == null)
+ return false;
+ return result;
+ }
+
+ /**
+ * Set the mandatory value
+ *
+ * @param flag true when mandatory
+ */
+ public void setMandatory(boolean flag)
+ {
+ if (flag)
+ setField(MANDATORY, flag);
+ else
+ setField(MANDATORY, null);
+ }
+
+ /**
+ * Get a field
+ *
+ * @param name the field name
+ */
+ public Object getField(String name)
+ {
+ return fields.get(name);
+ }
+
+ /**
+ * Set a field
+ *
+ * @param name the field name
+ * @param value the value
+ */
+ public void setField(String name, Object value)
+ {
+ fields.put(name, value);
+ }
+
+ /**
+ * Get a field
+ *
+ * @param <T> the expected type
+ * @param fieldName the field name
+ * @param expected the expected type
+ * @return the field value
+ */
+ @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 = 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 a of the expected type: " + expected.getName());
+ }
+
+ /**
+ * Display key fields like name, metaType and value
+ */
+ @Override
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder(super.toString());
+ //
+ sb.append('(');
+ sb.append(NAME);
+ sb.append('=');
+ sb.append(getName());
+ sb.append(',');
+ sb.append(META_TYPE);
+ sb.append('=');
+ sb.append(getMetaType());
+ sb.append(',');
+ sb.append(VALUE);
+ sb.append('=');
+ sb.append(getValue());
+ sb.append(')');
+ return sb.toString();
+ }
+
+ /**
+ * Only write out the fields that should be usable by a remote client.
+ * Excludes:
+ * PROPERTY_INFO
+ * ATTACHMENT
+ *
+ * @param out
+ * @throws IOException
+ */
+ private void writeObject(java.io.ObjectOutputStream out)
+ throws IOException
+ {
+ for (Map.Entry<String, Object> entry : fields.entrySet())
+ {
+ if(entry.getKey().equals(PROPERTY_INFO))
+ continue;
+ if(entry.getKey().equals(ATTACHMENT))
+ continue;
+ out.writeUTF(entry.getKey());
+ out.writeObject(entry.getValue());
+ }
+ out.writeUTF(END_MARKER);
+ }
+ private void readObject(java.io.ObjectInputStream in)
+ throws IOException, ClassNotFoundException
+ {
+ fields = new HashMap<String, Object>();
+ String key;
+ do
+ {
+ key = in.readUTF();
+ if(key.equals(END_MARKER))
+ key = null;
+ else
+ {
+ Serializable value = (Serializable) in.readObject();
+ fields.put(key, value);
+ }
+ } while(key != null);
+ }
+}
Deleted: projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/plugins/ManagedOperationImpl.java
===================================================================
--- projects/jboss-man/branches/Branch_2_0/managed/src/main/java/org/jboss/managed/plugins/ManagedOperationImpl.java 2008-11-19 16:43:01 UTC (rev 81300)
+++ projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/plugins/ManagedOperationImpl.java 2008-11-19 22:43:42 UTC (rev 81334)
@@ -1,135 +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.parameters = 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;
- }
-
- public MetaType getReturnType()
- {
- return returnType;
- }
-
- public void setReturnType(MetaType returnType)
- {
- this.returnType = returnType;
- }
-
- /**
- * 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 Object 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.0.0.CR5/managed/src/main/java/org/jboss/managed/plugins/ManagedOperationImpl.java (from rev 81330, projects/jboss-man/branches/Branch_2_0/managed/src/main/java/org/jboss/managed/plugins/ManagedOperationImpl.java)
===================================================================
--- projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/plugins/ManagedOperationImpl.java (rev 0)
+++ projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/plugins/ManagedOperationImpl.java 2008-11-19 22:43:42 UTC (rev 81334)
@@ -0,0 +1,135 @@
+/*
+ * 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.parameters = 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;
+ }
+
+ public MetaType getReturnType()
+ {
+ return returnType;
+ }
+
+ public void setReturnType(MetaType returnType)
+ {
+ this.returnType = returnType;
+ }
+
+ /**
+ * 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();
+ }
+
+}
Deleted: projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/plugins/ManagedParameterImpl.java
===================================================================
--- projects/jboss-man/branches/Branch_2_0/managed/src/main/java/org/jboss/managed/plugins/ManagedParameterImpl.java 2008-11-19 16:43:01 UTC (rev 81300)
+++ projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/plugins/ManagedParameterImpl.java 2008-11-19 22:43:42 UTC (rev 81334)
@@ -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");
-
- Serializable 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 Object getValue()
- {
- return getField(Fields.VALUE, Object.class);
- }
-
- public void setValue(Serializable 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(Serializable 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.0.0.CR5/managed/src/main/java/org/jboss/managed/plugins/ManagedParameterImpl.java (from rev 81330, projects/jboss-man/branches/Branch_2_0/managed/src/main/java/org/jboss/managed/plugins/ManagedParameterImpl.java)
===================================================================
--- projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/plugins/ManagedParameterImpl.java (rev 0)
+++ projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/plugins/ManagedParameterImpl.java 2008-11-19 22:43:42 UTC (rev 81334)
@@ -0,0 +1,328 @@
+/*
+ * 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");
+ }
+
+}
Deleted: projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/plugins/ManagedPropertyImpl.java
===================================================================
--- projects/jboss-man/branches/Branch_2_0/managed/src/main/java/org/jboss/managed/plugins/ManagedPropertyImpl.java 2008-11-19 16:43:01 UTC (rev 81300)
+++ projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/plugins/ManagedPropertyImpl.java 2008-11-19 22:43:42 UTC (rev 81334)
@@ -1,444 +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.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.ManagedObject;
-import org.jboss.managed.api.ManagedProperty;
-import org.jboss.managed.api.annotation.ManagementProperty;
-import org.jboss.managed.api.annotation.ViewUse;
-import org.jboss.metatype.api.types.MetaType;
-import org.jboss.metatype.api.values.MetaValue;
-import org.jboss.metatype.api.values.SimpleValue;
-
-/**
- * ManagedProperty.
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
-public class ManagedPropertyImpl implements ManagedProperty
-{
- /** The serialVersionUID */
- private static final long serialVersionUID = 2;
- /* writeObject format:
- * - int version
- * - Fields fields
- * - ManagedObject managedObject
- * - ManagedObject targetManagedObject
- */
- private static final int VERSION1 = 1;
- /** The serialization version used by writeObject */
- private static final int STREAM_VERSION = VERSION1;
-
- /** The managed object */
- private ManagedObject managedObject;
- /** The managed object target for a ManagementObjectRef */
- private ManagedObject targetManagedObject;
-
- /** 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 ManagedPropertyImpl(String name)
- {
- this(null, 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 ManagedPropertyImpl(Fields fields)
- {
- this(null, fields);
- }
-
- /**
- * Create a new ManagedProperty.
- *
- * @param managedObject the managed object, may be null
- * @param fields the fields
- * @throws IllegalArgumentException for null fields or
- * missing Fields.NAME
- */
- public ManagedPropertyImpl(ManagedObject managedObject, Fields fields)
- {
- init(managedObject, fields);
- }
-
- public ManagedObject getManagedObject()
- {
- return managedObject;
- }
-
- /**
- * Set managed object
- *
- * @param managedObject the managed object
- */
- public void setManagedObject(ManagedObject managedObject)
- {
- this.managedObject = managedObject;
- }
-
- public ManagedObject getTargetManagedObject()
- {
- return targetManagedObject;
- }
-
- public void setTargetManagedObject(ManagedObject target)
- {
- this.targetManagedObject = target;
- }
-
- 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");
-
- Serializable 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 getMappedName()
- {
- return getField(Fields.MAPPED_NAME, String.class);
- }
-
- 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) set;
- }
-
- public void setAnnotations(Map<String, Annotation> annotations)
- {
- setField(Fields.ANNOTATIONS, (Serializable) annotations);
- }
-
- /**
- * 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
- */
- public boolean hasViewUse(ViewUse use)
- {
- boolean hasViewUse = false;
- Map<String, Annotation> annotations = getAnnotations();
- if(annotations != null)
- {
- ManagementProperty mp = (ManagementProperty) annotations.get(ManagementProperty.class.getName());
- if(mp != null)
- {
- for(ViewUse vu : mp.use())
- hasViewUse |= vu == use;
- }
- }
- return hasViewUse;
- }
-
- 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 Object getValue()
- {
- return getField(Fields.VALUE, Object.class);
- }
-
- public void setValue(Serializable 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(Serializable value)
- {
- // TODO check min/max/etc.
- return null;
- }
-
- public boolean isMandatory()
- {
- Boolean result = getField(Fields.MANDATORY, Boolean.class);
- if (result == null)
- return false;
- return result;
- }
-
- /**
- * Set whether the field is mandatory
- *
- * @param flag true for mandatory
- */
- public void setMandatory(boolean flag)
- {
- if (flag)
- setField(Fields.MANDATORY, flag);
- else
- setField(Fields.MANDATORY, null);
- }
-
- @Override
- public String toString()
- {
- StringBuilder tmp = new StringBuilder("ManagedProperty");
- tmp.append('{');
- tmp.append(name);
- if( getMappedName() != null )
- {
- tmp.append(',');
- tmp.append(getMappedName());
- }
- 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 ManagedProperty == false)
- return false;
-
- ManagedProperty other = (ManagedProperty) 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(ManagedObject managedObject, Fields fields)
- {
- if (fields == null)
- throw new IllegalArgumentException("Null fields");
-
- this.managedObject = managedObject;
- 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);
- out.writeObject(managedObject);
- out.writeObject(targetManagedObject);
- }
-
- /**
- * The VERSION1 expected format:
- * - Fields fields
- * - ManagedObject managedObject
- */
- 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");
- managedObject = (ManagedObject) in.readObject();
- targetManagedObject = (ManagedObject) in.readObject();
- }
-}
Copied: projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/plugins/ManagedPropertyImpl.java (from rev 81330, projects/jboss-man/branches/Branch_2_0/managed/src/main/java/org/jboss/managed/plugins/ManagedPropertyImpl.java)
===================================================================
--- projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/plugins/ManagedPropertyImpl.java (rev 0)
+++ projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/plugins/ManagedPropertyImpl.java 2008-11-19 22:43:42 UTC (rev 81334)
@@ -0,0 +1,482 @@
+/*
+* 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.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.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.managed.api.Fields;
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.managed.api.annotation.ManagementProperty;
+import org.jboss.managed.api.annotation.ViewUse;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValue;
+
+/**
+ * ManagedProperty.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ManagedPropertyImpl implements ManagedProperty
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 2;
+ /* writeObject format:
+ * - int version
+ * - Fields fields
+ * - ManagedObject managedObject
+ * - ManagedObject targetManagedObject
+ */
+ private static final int VERSION1 = 1;
+ /** The serialization version used by writeObject */
+ private static final int STREAM_VERSION = VERSION1;
+
+ /** The managed object */
+ private ManagedObject managedObject;
+ /** The managed object target for a ManagementObjectRef */
+ private ManagedObject targetManagedObject;
+
+ /** 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 ManagedPropertyImpl(String name)
+ {
+ this(null, 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 ManagedPropertyImpl(Fields fields)
+ {
+ this(null, fields);
+ }
+
+ /**
+ * Create a new ManagedProperty.
+ *
+ * @param managedObject the managed object, may be null
+ * @param fields the fields
+ * @throws IllegalArgumentException for null fields or
+ * missing Fields.NAME
+ */
+ public ManagedPropertyImpl(ManagedObject managedObject, Fields fields)
+ {
+ init(managedObject, fields);
+ }
+
+ public ManagedObject getManagedObject()
+ {
+ return managedObject;
+ }
+
+ /**
+ * Set managed object
+ *
+ * @param managedObject the managed object
+ */
+ public void setManagedObject(ManagedObject managedObject)
+ {
+ this.managedObject = managedObject;
+ }
+
+ public ManagedObject getTargetManagedObject()
+ {
+ return targetManagedObject;
+ }
+
+ public void setTargetManagedObject(ManagedObject target)
+ {
+ this.targetManagedObject = target;
+ }
+
+ 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 getMappedName()
+ {
+ return getField(Fields.MAPPED_NAME, String.class);
+ }
+
+ 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) set;
+ }
+
+ public void setAnnotations(Map<String, Annotation> annotations)
+ {
+ setField(Fields.ANNOTATIONS, (Serializable) annotations);
+ }
+
+ /**
+ * See if the property has the indicated ViewUse among its
+ * @ManagementProperty annotation or VIEW_USE field uses.
+ *
+ * @param use - the ViewUse to check for
+ * @return true if the ViewUse exists in the property uses, false otherwise
+ */
+ public boolean hasViewUse(ViewUse use)
+ {
+ boolean hasViewUse = false;
+ ViewUse[] uses = getViewUse();
+ if(uses != null)
+ {
+ for(ViewUse vu : uses)
+ {
+ hasViewUse |= vu == use;
+ }
+ }
+ return hasViewUse;
+ }
+
+ 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);
+ }
+
+ public ViewUse[] getViewUse()
+ {
+ ViewUse[] use = {};
+ ViewUse[] useField = getField(Fields.VIEW_USE, ViewUse[].class);
+ // Also look to the ManagementProperty annotation
+ Map<String, Annotation> annotations = getAnnotations();
+ if(annotations != null)
+ {
+ ManagementProperty mp = (ManagementProperty) annotations.get(ManagementProperty.class.getName());
+ if(mp != null)
+ {
+ use = mp.use();
+ if(useField != null && useField.length > 0)
+ {
+ HashSet<ViewUse> uses = new HashSet<ViewUse>();
+ for(ViewUse vu : use)
+ {
+ uses.add(vu);
+ }
+ for(ViewUse vu : useField)
+ {
+ uses.add(vu);
+ }
+ use = new ViewUse[uses.size()];
+ uses.toArray(use);
+ }
+ }
+ }
+ else if(useField != null)
+ {
+ use = useField;
+ }
+ return use;
+ }
+ public void setViewUse(ViewUse[] use)
+ {
+ setField(Fields.VIEW_USE, use);
+ }
+
+ @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(Serializable value)
+ {
+ // TODO check min/max/etc.
+ return null;
+ }
+
+ public boolean isMandatory()
+ {
+ Boolean result = getField(Fields.MANDATORY, Boolean.class);
+ if (result == null)
+ return false;
+ return result;
+ }
+
+ /**
+ * Set whether the field is mandatory
+ *
+ * @param flag true for mandatory
+ */
+ public void setMandatory(boolean flag)
+ {
+ if (flag)
+ setField(Fields.MANDATORY, flag);
+ else
+ setField(Fields.MANDATORY, null);
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuilder tmp = new StringBuilder("ManagedProperty");
+ tmp.append('{');
+ tmp.append(name);
+ if( getMappedName() != null )
+ {
+ tmp.append(',');
+ tmp.append(getMappedName());
+ }
+ 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 ManagedProperty == false)
+ return false;
+
+ ManagedProperty other = (ManagedProperty) 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(ManagedObject managedObject, Fields fields)
+ {
+ if (fields == null)
+ throw new IllegalArgumentException("Null fields");
+
+ this.managedObject = managedObject;
+ 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);
+ out.writeObject(managedObject);
+ out.writeObject(targetManagedObject);
+ }
+
+ /**
+ * The VERSION1 expected format:
+ * - Fields fields
+ * - ManagedObject managedObject
+ */
+ 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");
+ managedObject = (ManagedObject) in.readObject();
+ targetManagedObject = (ManagedObject) in.readObject();
+ }
+}
Deleted: projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/plugins/WritethroughManagedPropertyImpl.java
===================================================================
--- projects/jboss-man/branches/Branch_2_0/managed/src/main/java/org/jboss/managed/plugins/WritethroughManagedPropertyImpl.java 2008-11-19 16:43:01 UTC (rev 81300)
+++ projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/plugins/WritethroughManagedPropertyImpl.java 2008-11-19 22:43:42 UTC (rev 81334)
@@ -1,127 +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.ObjectStreamException;
-import java.io.Serializable;
-
-import org.jboss.beans.info.spi.BeanInfo;
-import org.jboss.beans.info.spi.PropertyInfo;
-import org.jboss.managed.api.Fields;
-import org.jboss.managed.api.ManagedObject;
-import org.jboss.managed.api.factory.ManagedObjectFactory;
-import org.jboss.managed.plugins.factory.ManagedObjectFactoryBuilder;
-import org.jboss.managed.spi.factory.InstanceClassFactory;
-import org.jboss.metatype.api.values.MetaValue;
-import org.jboss.metatype.api.values.MetaValueFactory;
-import org.jboss.metatype.plugins.values.MetaValueFactoryBuilder;
-
-/**
- * An extension of ManagedPropertyImpl.
- *
- * @author Scott.Stark at jboss.org
- * @author Ales.Justin at jboss.org
- * @version $Revision$
- */
-public class WritethroughManagedPropertyImpl extends ManagedPropertyImpl
-{
- private static final long serialVersionUID = 1;
-
- /** The meta value factory */
- private transient MetaValueFactory valueFactory;
- /** The managed object factory */
- private transient ManagedObjectFactory objectFactory;
-
- public WritethroughManagedPropertyImpl(Fields fields)
- {
- super(fields);
- }
-
- public WritethroughManagedPropertyImpl(ManagedObject managedObject, Fields fields)
- {
- super(managedObject, fields);
- }
-
- public WritethroughManagedPropertyImpl(Fields fields, MetaValueFactory valueFactory, ManagedObjectFactory objectFactory)
- {
- super(fields);
- this.valueFactory = valueFactory;
- this.objectFactory = objectFactory;
- }
-
- protected ManagedObjectFactory getObjectFactory()
- {
- if (objectFactory == null)
- objectFactory = ManagedObjectFactoryBuilder.create();
- return objectFactory;
- }
-
- protected MetaValueFactory getValueFactory()
- {
- if (valueFactory == null)
- valueFactory = MetaValueFactoryBuilder.create();
- return valueFactory;
- }
-
- /**
- * Write the value back to the attachment if there is a PropertyInfo
- * in the Fields.PROPERTY_INFO field.
- */
- @Override
- @SuppressWarnings("unchecked")
- public void setValue(Serializable value)
- {
- super.setValue(value);
-
- PropertyInfo propertyInfo = getField(Fields.PROPERTY_INFO, PropertyInfo.class);
- if (propertyInfo != null)
- {
- Object attachment = getManagedObject().getAttachment();
- if (attachment != null)
- {
- MetaValue metaValue;
- if (value instanceof MetaValue == false)
- metaValue = getValueFactory().create(value, propertyInfo.getType());
- else
- metaValue = (MetaValue)value;
-
- ManagedObjectFactory mof = getObjectFactory();
- InstanceClassFactory icf = mof.getInstanceClassFactory(attachment.getClass(), null);
- BeanInfo beanInfo = propertyInfo.getBeanInfo();
- icf.setValue(beanInfo, this, attachment, metaValue);
- }
- }
- }
-
- /**
- * Expose only plain ManangedPropertyImpl.
- *
- * @return simpler ManagedPropertyImpl
- * @throws ObjectStreamException for any error
- */
- private Object writeReplace() throws ObjectStreamException
- {
- ManagedPropertyImpl managedProperty = new ManagedPropertyImpl(getManagedObject(), getFields());
- managedProperty.setTargetManagedObject(getTargetManagedObject());
- return managedProperty;
- }
-}
Copied: projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/plugins/WritethroughManagedPropertyImpl.java (from rev 81330, projects/jboss-man/branches/Branch_2_0/managed/src/main/java/org/jboss/managed/plugins/WritethroughManagedPropertyImpl.java)
===================================================================
--- projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/plugins/WritethroughManagedPropertyImpl.java (rev 0)
+++ projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/plugins/WritethroughManagedPropertyImpl.java 2008-11-19 22:43:42 UTC (rev 81334)
@@ -0,0 +1,121 @@
+/*
+ * 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.ObjectStreamException;
+import java.io.Serializable;
+
+import org.jboss.beans.info.spi.BeanInfo;
+import org.jboss.beans.info.spi.PropertyInfo;
+import org.jboss.managed.api.Fields;
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.api.factory.ManagedObjectFactory;
+import org.jboss.managed.plugins.factory.ManagedObjectFactoryBuilder;
+import org.jboss.managed.spi.factory.InstanceClassFactory;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.MetaValueFactory;
+import org.jboss.metatype.plugins.values.MetaValueFactoryBuilder;
+
+/**
+ * An extension of ManagedPropertyImpl.
+ *
+ * @author Scott.Stark at jboss.org
+ * @author Ales.Justin at jboss.org
+ * @version $Revision$
+ */
+public class WritethroughManagedPropertyImpl extends ManagedPropertyImpl
+{
+ private static final long serialVersionUID = 1;
+
+ /** The meta value factory */
+ private transient MetaValueFactory valueFactory;
+ /** The managed object factory */
+ private transient ManagedObjectFactory objectFactory;
+
+ public WritethroughManagedPropertyImpl(Fields fields)
+ {
+ super(fields);
+ }
+
+ public WritethroughManagedPropertyImpl(ManagedObject managedObject, Fields fields)
+ {
+ super(managedObject, fields);
+ }
+
+ public WritethroughManagedPropertyImpl(Fields fields, MetaValueFactory valueFactory, ManagedObjectFactory objectFactory)
+ {
+ super(fields);
+ this.valueFactory = valueFactory;
+ this.objectFactory = objectFactory;
+ }
+
+ protected ManagedObjectFactory getObjectFactory()
+ {
+ if (objectFactory == null)
+ objectFactory = ManagedObjectFactoryBuilder.create();
+ return objectFactory;
+ }
+
+ protected MetaValueFactory getValueFactory()
+ {
+ if (valueFactory == null)
+ valueFactory = MetaValueFactoryBuilder.create();
+ return valueFactory;
+ }
+
+ /**
+ * Write the value back to the attachment if there is a PropertyInfo
+ * in the Fields.PROPERTY_INFO field.
+ */
+ @Override
+ @SuppressWarnings("unchecked")
+ public void setValue(MetaValue value)
+ {
+ super.setValue(value);
+
+ PropertyInfo propertyInfo = getField(Fields.PROPERTY_INFO, PropertyInfo.class);
+ if (propertyInfo != null)
+ {
+ Object attachment = getManagedObject().getAttachment();
+ if (attachment != null)
+ {
+ ManagedObjectFactory mof = getObjectFactory();
+ InstanceClassFactory icf = mof.getInstanceClassFactory(attachment.getClass(), null);
+ BeanInfo beanInfo = propertyInfo.getBeanInfo();
+ icf.setValue(beanInfo, this, attachment, value);
+ }
+ }
+ }
+
+ /**
+ * Expose only plain ManangedPropertyImpl.
+ *
+ * @return simpler ManagedPropertyImpl
+ * @throws ObjectStreamException for any error
+ */
+ private Object writeReplace() throws ObjectStreamException
+ {
+ ManagedPropertyImpl managedProperty = new ManagedPropertyImpl(getManagedObject(), getFields());
+ managedProperty.setTargetManagedObject(getTargetManagedObject());
+ return managedProperty;
+ }
+}
Deleted: projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/plugins/factory/AbstractManagedObjectFactory.java
===================================================================
--- projects/jboss-man/branches/Branch_2_0/managed/src/main/java/org/jboss/managed/plugins/factory/AbstractManagedObjectFactory.java 2008-11-19 16:43:01 UTC (rev 81300)
+++ projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/plugins/factory/AbstractManagedObjectFactory.java 2008-11-19 22:43:42 UTC (rev 81334)
@@ -1,872 +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.AnnotationDefaults;
-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.ManagementRuntimeRef;
-import org.jboss.managed.api.factory.ManagedObjectFactory;
-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.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.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;
- }
-
- /**
- * 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;
- }
- 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
- */
- @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;
- }
-
- 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;
- 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)
- moAnnotations.put(ManagementComponent.class.getName(), mc);
- // ManagementObject level default factory classes
- moFieldsFactory = managementObject.fieldsFactory();
- moConstraintsFactory = managementObject.constraintsFactory();
- moPropertyFactory = managementObject.propertyFactory();
- }
-
- 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);
- 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);
-
- // 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;
- if (managementProperty != null)
- {
- Class<? extends Fields> factory = moFieldsFactory;
- if (factory == ManagementProperty.NULL_FIELDS_FACTORY.class)
- factory = managementProperty.fieldsFactory();
- if (factory != ManagementProperty.NULL_FIELDS_FACTORY.class)
- {
- 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 managed = false;
- if (managementProperty != null)
- managed = managementProperty.managed();
-
- MetaType metaType;
- 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);
- 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;
- if (factoryClass == ManagementProperty.NULL_CONSTRAINTS.class)
- {
- if (managementProperty != null)
- factoryClass = managementProperty.constraintsFactory();
- }
- ManagedPropertyConstraintsPopulatorFactory factory = factoryClass.newInstance();
- ManagedPropertyConstraintsPopulator populator = factory.newInstance();
- if (populator != null)
- populator.populateManagedProperty(clazz, propertyInfo, fields);
- }
- catch(Exception e)
- {
- log.debug("Failed to populate constraints for: "+propertyInfo, e);
- }
-
- ManagedProperty property = null;
- if (managementProperty != null)
- {
- Class<? extends ManagedProperty> factory = moPropertyFactory;
- if (factory == ManagementProperty.NULL_PROPERTY_FACTORY.class)
- factory = managementProperty.propertyFactory();
- if (factory != ManagementProperty.NULL_PROPERTY_FACTORY.class)
- property = getManagedProperty(factory, fields);
- }
- // we should have write-through by default
- // use factory to change this default behavior
- if (property == null)
- property = createDefaultManagedProperty(fields);
- 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);
- 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);
- 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)
- log.trace("Loaded "+annotationType+" from MetaData");
- }
- if(annotation == null)
- annotation = info.getUnderlyingAnnotation(annotationType);
- return annotation;
- }
-}
Copied: projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/plugins/factory/AbstractManagedObjectFactory.java (from rev 81330, projects/jboss-man/branches/Branch_2_0/managed/src/main/java/org/jboss/managed/plugins/factory/AbstractManagedObjectFactory.java)
===================================================================
--- projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/plugins/factory/AbstractManagedObjectFactory.java (rev 0)
+++ projects/jboss-man/tags/2.0.0.CR5/managed/src/main/java/org/jboss/managed/plugins/factory/AbstractManagedObjectFactory.java 2008-11-19 22:43:42 UTC (rev 81334)
@@ -0,0 +1,877 @@
+/*
+* 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.AnnotationDefaults;
+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.ManagementRuntimeRef;
+import org.jboss.managed.api.factory.ManagedObjectFactory;
+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.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.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;
+ }
+
+ /**
+ * 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
+ */
+ @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;
+ }
+
+ 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;
+ 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
+ moFieldsFactory = managementObject.fieldsFactory();
+ moConstraintsFactory = managementObject.constraintsFactory();
+ moPropertyFactory = managementObject.propertyFactory();
+ }
+
+ 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);
+ 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);
+
+ // 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;
+ if (managementProperty != null)
+ {
+ Class<? extends Fields> factory = moFieldsFactory;
+ if (factory == ManagementProperty.NULL_FIELDS_FACTORY.class)
+ factory = managementProperty.fieldsFactory();
+ if (factory != ManagementProperty.NULL_FIELDS_FACTORY.class)
+ {
+ 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 managed = false;
+ if (managementProperty != null)
+ managed = managementProperty.managed();
+
+ MetaType metaType;
+ 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);
+ 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;
+ if (factoryClass == ManagementProperty.NULL_CONSTRAINTS.class)
+ {
+ if (managementProperty != null)
+ factoryClass = managementProperty.constraintsFactory();
+ }
+ ManagedPropertyConstraintsPopulatorFactory factory = factoryClass.newInstance();
+ ManagedPropertyConstraintsPopulator populator = factory.newInstance();
+ if (populator != null)
+ populator.populateManagedProperty(clazz, propertyInfo, fields);
+ }
+ catch(Exception e)
+ {
+ log.debug("Failed to populate constraints for: "+propertyInfo, e);
+ }
+
+ ManagedProperty property = null;
+ if (managementProperty != null)
+ {
+ Class<? extends ManagedProperty> factory = moPropertyFactory;
+ if (factory == ManagementProperty.NULL_PROPERTY_FACTORY.class)
+ factory = managementProperty.propertyFactory();
+ if (factory != ManagementProperty.NULL_PROPERTY_FACTORY.class)
+ property = getManagedProperty(factory, fields);
+ }
+ // we should have write-through by default
+ // use factory to change this default behavior
+ if (property == null)
+ property = createDefaultManagedProperty(fields);
+ 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);
+ 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);
+ 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)
+ log.trace("Loaded "+annotationType+" from MetaData");
+ }
+ if(annotation == null)
+ annotation = info.getUnderlyingAnnotation(annotationType);
+ return annotation;
+ }
+}
Deleted: projects/jboss-man/tags/2.0.0.CR5/managed/src/test/java/org/jboss/test/managed/factory/test/ManagementPropertyUnitTestCase.java
===================================================================
--- projects/jboss-man/branches/Branch_2_0/managed/src/test/java/org/jboss/test/managed/factory/test/ManagementPropertyUnitTestCase.java 2008-11-19 16:43:01 UTC (rev 81300)
+++ projects/jboss-man/tags/2.0.0.CR5/managed/src/test/java/org/jboss/test/managed/factory/test/ManagementPropertyUnitTestCase.java 2008-11-19 22:43:42 UTC (rev 81334)
@@ -1,128 +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.test.managed.factory.test;
-
-import java.lang.annotation.Annotation;
-import java.util.Map;
-
-import junit.framework.Test;
-
-import org.jboss.managed.api.ManagedObject;
-import org.jboss.managed.api.ManagedProperty;
-import org.jboss.managed.api.annotation.ManagementObjectID;
-import org.jboss.managed.api.annotation.ManagementProperty;
-import org.jboss.managed.api.annotation.ViewUse;
-import org.jboss.test.managed.factory.AbstractManagedObjectFactoryTest;
-import org.jboss.test.managed.factory.support.ManagementPropertyAnnotations;
-import org.jboss.test.managed.factory.support.ManagementPropertyDescription;
-import org.jboss.test.managed.factory.support.ManagementPropertyMandatory;
-import org.jboss.test.managed.factory.support.ManagementPropertySimpleManaged;
-
-/**
- * ManagementPropertyUnitTestCase.
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
-public class ManagementPropertyUnitTestCase extends AbstractManagedObjectFactoryTest
-{
- /**
- * Create a testsuite for this test
- *
- * @return the testsuite
- */
- public static Test suite()
- {
- return suite(ManagementPropertyUnitTestCase.class);
- }
-
- /**
- * Create a new ManagementPropertyUnitTestCase.
- *
- * @param name the test name
- */
- public ManagementPropertyUnitTestCase(String name)
- {
- super(name);
- }
-
- /**
- * Test the overridden description
- */
- public void testDescription()
- {
- ManagedObject managedObject = createAndCheckDefaultManagedObject(ManagementPropertyDescription.class);
- checkProperty(managedObject, "property", String.class, "changed", false, null);
- }
-
- /**
- * Test the overridden mandatory
- */
- public void testMandatory()
- {
- ManagedObject managedObject = createAndCheckDefaultManagedObject(ManagementPropertyMandatory.class);
- checkProperty(managedObject, "property", String.class, "property", true, null);
- }
-
- /**
- * Test the overidden property to managed object
- */
- public void testSimpleManaged()
- {
- ManagementPropertySimpleManaged test = new ManagementPropertySimpleManaged();
- ManagedObject managedObject = checkManagedObject(test);
- checkPropertyIsManagedObject(managedObject, "property", "property", false, test.getProperty());
- }
-
- /**
- * Test property annotations
- */
- public void testAnnotations()
- {
- ManagedObject managedObject = createAndCheckDefaultManagedObject(ManagementPropertyAnnotations.class);
- ManagedProperty managedProperty = managedObject.getProperty("runtime");
- assertNotNull(managedProperty);
- Map<String, Annotation> annotations = managedProperty.getAnnotations();
- assertEquals(2, annotations.size());
- assertTrue(annotations.containsKey(ManagementProperty.class.getName()));
- assertTrue(annotations.containsKey(ManagementObjectID.class.getName()));
- }
-
- /**
- * Test property ViewUse
- */
- public void testViewUse()
- {
- ManagedObject managedObject = createAndCheckDefaultManagedObject(ManagementPropertyAnnotations.class);
- ManagedProperty runtime = managedObject.getProperty("runtime");
- assertNotNull(runtime);
- assertTrue("has ViewUse.RUNTIME", runtime.hasViewUse(ViewUse.RUNTIME));
- assertTrue("!has ViewUse.CONFIGURATION", !runtime.hasViewUse(ViewUse.CONFIGURATION));
- assertTrue("!has ViewUse.STATISTIC", !runtime.hasViewUse(ViewUse.STATISTIC));
-
- ManagedProperty configuration = managedObject.getProperty("configuration");
- assertTrue("has ViewUse.CONFIGURATION", configuration.hasViewUse(ViewUse.CONFIGURATION));
-
- ManagedProperty stat = managedObject.getProperty("stat");
- assertTrue("has ViewUse.STATISTIC", stat.hasViewUse(ViewUse.STATISTIC));
- }
-}
\ No newline at end of file
Copied: projects/jboss-man/tags/2.0.0.CR5/managed/src/test/java/org/jboss/test/managed/factory/test/ManagementPropertyUnitTestCase.java (from rev 81330, projects/jboss-man/branches/Branch_2_0/managed/src/test/java/org/jboss/test/managed/factory/test/ManagementPropertyUnitTestCase.java)
===================================================================
--- projects/jboss-man/tags/2.0.0.CR5/managed/src/test/java/org/jboss/test/managed/factory/test/ManagementPropertyUnitTestCase.java (rev 0)
+++ projects/jboss-man/tags/2.0.0.CR5/managed/src/test/java/org/jboss/test/managed/factory/test/ManagementPropertyUnitTestCase.java 2008-11-19 22:43:42 UTC (rev 81334)
@@ -0,0 +1,164 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2007, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.managed.factory.test;
+
+import java.lang.annotation.Annotation;
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.Test;
+
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.managed.api.annotation.ManagementObjectID;
+import org.jboss.managed.api.annotation.ManagementProperty;
+import org.jboss.managed.api.annotation.ViewUse;
+import org.jboss.managed.plugins.ManagedPropertyImpl;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.test.managed.factory.AbstractManagedObjectFactoryTest;
+import org.jboss.test.managed.factory.support.ManagementPropertyAnnotations;
+import org.jboss.test.managed.factory.support.ManagementPropertyDescription;
+import org.jboss.test.managed.factory.support.ManagementPropertyMandatory;
+import org.jboss.test.managed.factory.support.ManagementPropertySimpleManaged;
+
+/**
+ * ManagementPropertyUnitTestCase.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ManagementPropertyUnitTestCase extends AbstractManagedObjectFactoryTest
+{
+ /**
+ * Create a testsuite for this test
+ *
+ * @return the testsuite
+ */
+ public static Test suite()
+ {
+ return suite(ManagementPropertyUnitTestCase.class);
+ }
+
+ /**
+ * Create a new ManagementPropertyUnitTestCase.
+ *
+ * @param name the test name
+ */
+ public ManagementPropertyUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Test the overridden description
+ */
+ public void testDescription()
+ {
+ ManagedObject managedObject = createAndCheckDefaultManagedObject(ManagementPropertyDescription.class);
+ checkProperty(managedObject, "property", String.class, "changed", false, null);
+ }
+
+ /**
+ * Test the overridden mandatory
+ */
+ public void testMandatory()
+ {
+ ManagedObject managedObject = createAndCheckDefaultManagedObject(ManagementPropertyMandatory.class);
+ checkProperty(managedObject, "property", String.class, "property", true, null);
+ }
+
+ /**
+ * Test the overidden property to managed object
+ */
+ public void testSimpleManaged()
+ {
+ ManagementPropertySimpleManaged test = new ManagementPropertySimpleManaged();
+ ManagedObject managedObject = checkManagedObject(test);
+ checkPropertyIsManagedObject(managedObject, "property", "property", false, test.getProperty());
+ }
+
+ /**
+ * Test property annotations
+ */
+ public void testAnnotations()
+ {
+ ManagedObject managedObject = createAndCheckDefaultManagedObject(ManagementPropertyAnnotations.class);
+ ManagedProperty managedProperty = managedObject.getProperty("runtime");
+ assertNotNull(managedProperty);
+ Map<String, Annotation> annotations = managedProperty.getAnnotations();
+ assertEquals(2, annotations.size());
+ assertTrue(annotations.containsKey(ManagementProperty.class.getName()));
+ assertTrue(annotations.containsKey(ManagementObjectID.class.getName()));
+ }
+
+ /**
+ * Test property ViewUse
+ */
+ public void testViewUse()
+ {
+ ManagedObject managedObject = createAndCheckDefaultManagedObject(ManagementPropertyAnnotations.class);
+ ManagedProperty runtime = managedObject.getProperty("runtime");
+ assertNotNull(runtime);
+ assertTrue("has ViewUse.RUNTIME", runtime.hasViewUse(ViewUse.RUNTIME));
+ assertTrue("!has ViewUse.CONFIGURATION", !runtime.hasViewUse(ViewUse.CONFIGURATION));
+ assertTrue("!has ViewUse.STATISTIC", !runtime.hasViewUse(ViewUse.STATISTIC));
+
+ ManagedProperty configuration = managedObject.getProperty("configuration");
+ assertTrue("has ViewUse.CONFIGURATION", configuration.hasViewUse(ViewUse.CONFIGURATION));
+
+ ManagedProperty stat = managedObject.getProperty("stat");
+ assertTrue("has ViewUse.STATISTIC", stat.hasViewUse(ViewUse.STATISTIC));
+ }
+
+ /**
+ * Test the
+ */
+ @ManagementProperty(name="runtime-stat", use={ViewUse.STATISTIC})
+ public void testViewUseField()
+ throws Exception
+ {
+ ManagedPropertyImpl mp = new ManagedPropertyImpl("runtime");
+ mp.setMetaType(SimpleMetaType.LONG);
+ mp.setValue(SimpleValueSupport.wrap(1000));
+ mp.setViewUse(new ViewUse[]{ViewUse.RUNTIME});
+ assertTrue("has ViewUse.RUNTIME", mp.hasViewUse(ViewUse.RUNTIME));
+
+ ManagedPropertyImpl mp2 = new ManagedPropertyImpl("runtime-stat");
+ mp2.setMetaType(SimpleMetaType.LONG);
+ mp2.setValue(SimpleValueSupport.wrap(1000));
+ mp2.setViewUse(new ViewUse[]{ViewUse.RUNTIME, ViewUse.STATISTIC});
+ assertTrue("has ViewUse.RUNTIME", mp2.hasViewUse(ViewUse.RUNTIME));
+ assertTrue("has ViewUse.STATISTIC", mp2.hasViewUse(ViewUse.STATISTIC));
+
+ ManagedPropertyImpl mp3 = new ManagedPropertyImpl("runtime-stat");
+ mp3.setMetaType(SimpleMetaType.LONG);
+ mp3.setValue(SimpleValueSupport.wrap(1000));
+ mp3.setViewUse(new ViewUse[]{ViewUse.RUNTIME});
+ HashMap<String, Annotation> annotations = new HashMap<String, Annotation>();
+ ManagementProperty mpa = getClass().getMethod("testViewUseField", null).getAnnotation(ManagementProperty.class);
+ annotations.put(ManagementProperty.class.getName(), mpa);
+ mp3.setAnnotations(annotations);
+ assertTrue("has ViewUse.RUNTIME", mp3.hasViewUse(ViewUse.RUNTIME));
+ assertTrue("has ViewUse.STATISTIC", mp3.hasViewUse(ViewUse.STATISTIC));
+}
+}
Deleted: projects/jboss-man/tags/2.0.0.CR5/managed/src/test/java/org/jboss/test/managed/mock/MockDOMFields.java
===================================================================
--- projects/jboss-man/branches/Branch_2_0/managed/src/test/java/org/jboss/test/managed/mock/MockDOMFields.java 2008-11-19 16:43:01 UTC (rev 81300)
+++ projects/jboss-man/tags/2.0.0.CR5/managed/src/test/java/org/jboss/test/managed/mock/MockDOMFields.java 2008-11-19 22:43:42 UTC (rev 81334)
@@ -1,105 +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.test.managed.mock;
-
-import java.io.Serializable;
-
-import org.jboss.managed.api.Fields;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-
-/**
- * DOMFields.
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
-public class MockDOMFields implements Fields
-{
- /** The serialVersionUID */
- private static final long serialVersionUID = 1L;
-
- /** The datasource element */
- private Element element;
-
- /** The element name */
- private String elementName;
-
- /**
- * Create a new DOMFields.
- *
- * @param element the data source element
- * @param elementName the element name
- */
- public MockDOMFields(Element element, String elementName)
- {
- this.element = element;
- this.elementName = elementName;
- }
-
- public Serializable getField(String name)
- {
- if (NAME.equals(name))
- return elementName;
- if (VALUE.equals(name))
- {
- NodeList nodes = element.getElementsByTagName(elementName);
- if (nodes.getLength() == 0)
- return null;
- else
- {
- Element element = (Element) nodes.item(0);
- return element.getTextContent();
- }
- }
- return null;
- }
-
- public void setField(String name, Serializable value)
- {
- if (VALUE.equals(name))
- {
- String string = (String) value;
- NodeList nodes = element.getElementsByTagName(elementName);
- Element childElement = null;
- if (nodes.getLength() == 0)
- {
- if (string == null || string.length() == 0)
- return;
- childElement = element.getOwnerDocument().createElement(elementName);
- element.appendChild(childElement);
- }
- else
- {
- childElement = (Element) nodes.item(0);
- if (string == null || string.length() == 0)
- {
- element.removeChild(childElement);
- return;
- }
- }
- childElement.setTextContent(string);
- return;
- }
- throw new UnsupportedOperationException("setField " + name);
- }
-}
Copied: projects/jboss-man/tags/2.0.0.CR5/managed/src/test/java/org/jboss/test/managed/mock/MockDOMFields.java (from rev 81330, projects/jboss-man/branches/Branch_2_0/managed/src/test/java/org/jboss/test/managed/mock/MockDOMFields.java)
===================================================================
--- projects/jboss-man/tags/2.0.0.CR5/managed/src/test/java/org/jboss/test/managed/mock/MockDOMFields.java (rev 0)
+++ projects/jboss-man/tags/2.0.0.CR5/managed/src/test/java/org/jboss/test/managed/mock/MockDOMFields.java 2008-11-19 22:43:42 UTC (rev 81334)
@@ -0,0 +1,105 @@
+/*
+* 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.test.managed.mock;
+
+import java.io.Serializable;
+
+import org.jboss.managed.api.Fields;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+/**
+ * DOMFields.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class MockDOMFields implements Fields
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 1L;
+
+ /** The datasource element */
+ private Element element;
+
+ /** The element name */
+ private String elementName;
+
+ /**
+ * Create a new DOMFields.
+ *
+ * @param element the data source element
+ * @param elementName the element name
+ */
+ public MockDOMFields(Element element, String elementName)
+ {
+ this.element = element;
+ this.elementName = elementName;
+ }
+
+ public Object getField(String name)
+ {
+ if (NAME.equals(name))
+ return elementName;
+ if (VALUE.equals(name))
+ {
+ NodeList nodes = element.getElementsByTagName(elementName);
+ if (nodes.getLength() == 0)
+ return null;
+ else
+ {
+ Element element = (Element) nodes.item(0);
+ return element.getTextContent();
+ }
+ }
+ return null;
+ }
+
+ public void setField(String name, Object value)
+ {
+ if (VALUE.equals(name))
+ {
+ String string = (String) value;
+ NodeList nodes = element.getElementsByTagName(elementName);
+ Element childElement = null;
+ if (nodes.getLength() == 0)
+ {
+ if (string == null || string.length() == 0)
+ return;
+ childElement = element.getOwnerDocument().createElement(elementName);
+ element.appendChild(childElement);
+ }
+ else
+ {
+ childElement = (Element) nodes.item(0);
+ if (string == null || string.length() == 0)
+ {
+ element.removeChild(childElement);
+ return;
+ }
+ }
+ childElement.setTextContent(string);
+ return;
+ }
+ throw new UnsupportedOperationException("setField " + name);
+ }
+}
Deleted: projects/jboss-man/tags/2.0.0.CR5/managed/src/test/java/org/jboss/test/managed/mock/MockTest.java
===================================================================
--- projects/jboss-man/branches/Branch_2_0/managed/src/test/java/org/jboss/test/managed/mock/MockTest.java 2008-11-19 16:43:01 UTC (rev 81300)
+++ projects/jboss-man/tags/2.0.0.CR5/managed/src/test/java/org/jboss/test/managed/mock/MockTest.java 2008-11-19 22:43:42 UTC (rev 81334)
@@ -1,195 +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.test.managed.mock;
-
-import java.io.Serializable;
-import java.util.HashMap;
-
-import junit.framework.Test;
-
-import org.jboss.managed.api.Fields;
-import org.jboss.managed.api.ManagedObject;
-import org.jboss.managed.api.ManagedProperty;
-import org.jboss.test.managed.ManagedTest;
-
-/**
- * MockTest
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
-public class MockTest extends ManagedTest
-{
- /**
- * Create a testsuite for this this
- *
- * @return the testsuite
- */
- public static Test suite()
- {
- return suite(MockTest.class);
- }
-
- /**
- * Create a new MockTest.
- *
- * @param name the test name
- */
- public MockTest(String name)
- {
- super(name);
- }
-
- /**
- * Test the mock
- *
- * @throws Exception for any problem
- */
- public void testMock() throws Exception
- {
- MockDataSourceManagedObject mock = new MockDataSourceManagedObject();
-
- ManagedObject mo = mock;
-
- getLog().debug("MockDataSourceManagedObject, available propertes...");
- getLog().debug(mock.getPropertyNames());
-
- getLog().debug("Initial MetaData...");
- getLog().debug(mock.prettyPrint());
-
- getLog().debug("Adding jndi-name...");
- mo.getProperty("jndi-name").setValue("DefaultDS");
- getLog().debug(mock.prettyPrint());
-
- getLog().debug("Adding user and password...");
- mo.getProperty("user").setValue("Scott");
- mo.getProperty("password").setValue("Tiger");
- getLog().debug(mock.prettyPrint());
-
- getLog().debug("Changing jndi-name...");
- mo.getProperty("jndi-name").setValue("ChangedDS");
- getLog().debug(mock.prettyPrint());
-
- getLog().debug("Removing jndi-name...");
- mo.getProperty("jndi-name").setValue(null);
- getLog().debug(mock.prettyPrint());
-
- getLog().debug("Displaying properties...");
- for (ManagedProperty property : mo.getProperties().values())
- getLog().debug(property.getName() + "=" + property.getValue());
-
- ManagedProperty jndiName = mo.getProperty("jndi-name");
-
- getLog().debug("Displaying jndi-name field values...");
- getLog().debug("jndi-name name field is: " + jndiName.getFields().getField(Fields.NAME));
- getLog().debug("jndi-name value field is: " + jndiName.getFields().getField(Fields.VALUE));
-
- assertEquals(mo, jndiName.getManagedObject());
- }
-
- /**
- * Test the managed object serialization
- *
- * @throws Exception for any problem
- */
- public void testManagedObjectSerialization()
- throws Exception
- {
- MockDataSourceManagedObject mock = new MockDataSourceManagedObject();
- ManagedObject mo = mock;
-
- mo.getProperty("jndi-name").setValue("DefaultDS");
- mo.getProperty("user").setValue("Scott");
- mo.getProperty("password").setValue("Tiger");
- mo.getProperty("jndi-name").setValue("ChangedDS");
-
- getLog().debug(mock.prettyPrint());
-
- byte[] data = super.serialize(mo);
- ManagedObject mo2 = (ManagedObject) super.deserialize(data);
-
- assertEquals("jndiName", "ChangedDS", mo2.getProperty("jndi-name").getValue());
- assertEquals("user", "Scott", mo2.getProperty("user").getValue());
- assertEquals("password", "Tiger", mo2.getProperty("password").getValue());
- }
-
- /**
- * Test the managed object property map serialization
- *
- * @throws Exception for any problem
- */
- @SuppressWarnings("unchecked")
- public void testManagedPropertyMapSerialization()
- throws Exception
- {
- MockDataSourceManagedObject mock = new MockDataSourceManagedObject();
- ManagedObject mo = mock;
-
- ManagedProperty jndiName = mo.getProperty("jndi-name");
- jndiName.setValue("DefaultDS");
- ManagedProperty user = mo.getProperty("user");
- user.setValue("Scott");
- ManagedProperty password = mo.getProperty("password");
- password.setValue("Tiger");
- jndiName.setValue("ChangedDS");
-
- HashMap<String, ManagedProperty> props = new HashMap<String, ManagedProperty>();
- props.put(jndiName.getName(), jndiName);
- props.put(user.getName(), user);
- props.put(password.getName(), password);
-
- HashMap<String, ManagedProperty> props2 = serializeDeserialize(props, HashMap.class);
-
- ManagedProperty jndiName2 = props2.get("jndi-name");
- assertEquals("jndiName", "ChangedDS", jndiName2.getValue());
- ManagedProperty jndiName3 = jndiName2.getManagedObject().getProperty("jndi-name");
- assertEquals("jndiName", "ChangedDS", jndiName3.getValue());
- ManagedProperty user2 = props2.get("user");
- assertEquals("user", "Scott", user2.getValue());
- ManagedProperty password2 = props2.get("password");
- assertEquals("password", "Tiger", password2.getValue());
- }
-
- /**
- * Serialize/deserialize
- *
- * TODO move to AbstractTestCase
- * @param <T> the expected type
- * @param value the value
- * @param expected the expected type
- * @return the result
- * @throws Exception for any problem
- */
- protected <T> T serializeDeserialize(Serializable value, Class<T> expected) throws Exception
- {
- byte[] bytes = serialize(value);
- Object result = deserialize(bytes);
- return assertInstanceOf(result, expected);
-
- }
-
- @Override
- protected void configureLogging()
- {
- enableTrace("org.jboss.managed.plugins.advice");
- }
-}
Copied: projects/jboss-man/tags/2.0.0.CR5/managed/src/test/java/org/jboss/test/managed/mock/MockTest.java (from rev 81330, projects/jboss-man/branches/Branch_2_0/managed/src/test/java/org/jboss/test/managed/mock/MockTest.java)
===================================================================
--- projects/jboss-man/tags/2.0.0.CR5/managed/src/test/java/org/jboss/test/managed/mock/MockTest.java (rev 0)
+++ projects/jboss-man/tags/2.0.0.CR5/managed/src/test/java/org/jboss/test/managed/mock/MockTest.java 2008-11-19 22:43:42 UTC (rev 81334)
@@ -0,0 +1,199 @@
+/*
+* 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.test.managed.mock;
+
+import java.io.Serializable;
+import java.util.HashMap;
+
+import junit.framework.Test;
+
+import org.jboss.managed.api.Fields;
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.test.managed.ManagedTest;
+
+/**
+ * MockTest
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class MockTest extends ManagedTest
+{
+ /**
+ * Create a testsuite for this this
+ *
+ * @return the testsuite
+ */
+ public static Test suite()
+ {
+ return suite(MockTest.class);
+ }
+
+ /**
+ * Create a new MockTest.
+ *
+ * @param name the test name
+ */
+ public MockTest(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Test the mock
+ *
+ * @throws Exception for any problem
+ */
+ public void testMock() throws Exception
+ {
+ MockDataSourceManagedObject mock = new MockDataSourceManagedObject();
+
+ ManagedObject mo = mock;
+
+ getLog().debug("MockDataSourceManagedObject, available propertes...");
+ getLog().debug(mock.getPropertyNames());
+
+ getLog().debug("Initial MetaData...");
+ getLog().debug(mock.prettyPrint());
+
+ getLog().debug("Adding jndi-name...");
+ mo.getProperty("jndi-name").setValue(SimpleValueSupport.wrap("DefaultDS"));
+ getLog().debug(mock.prettyPrint());
+
+ getLog().debug("Adding user and password...");
+ mo.getProperty("user").setValue(SimpleValueSupport.wrap("Scott"));
+ mo.getProperty("password").setValue(SimpleValueSupport.wrap("Tiger"));
+ getLog().debug(mock.prettyPrint());
+
+ getLog().debug("Changing jndi-name...");
+ mo.getProperty("jndi-name").setValue(SimpleValueSupport.wrap("ChangedDS"));
+ getLog().debug(mock.prettyPrint());
+
+ getLog().debug("Removing jndi-name...");
+ mo.getProperty("jndi-name").setValue(null);
+ getLog().debug(mock.prettyPrint());
+
+ getLog().debug("Displaying properties...");
+ for (ManagedProperty property : mo.getProperties().values())
+ getLog().debug(property.getName() + "=" + property.getValue());
+
+ ManagedProperty jndiName = mo.getProperty("jndi-name");
+
+ getLog().debug("Displaying jndi-name field values...");
+ getLog().debug("jndi-name name field is: " + jndiName.getFields().getField(Fields.NAME));
+ getLog().debug("jndi-name value field is: " + jndiName.getFields().getField(Fields.VALUE));
+
+ assertEquals(mo, jndiName.getManagedObject());
+ }
+
+ /**
+ * Test the managed object serialization
+ *
+ * @throws Exception for any problem
+ */
+ public void testManagedObjectSerialization()
+ throws Exception
+ {
+ MockDataSourceManagedObject mock = new MockDataSourceManagedObject();
+ ManagedObject mo = mock;
+
+ mo.getProperty("jndi-name").setValue(SimpleValueSupport.wrap("DefaultDS"));
+ mo.getProperty("user").setValue(SimpleValueSupport.wrap("Scott"));
+ mo.getProperty("password").setValue(SimpleValueSupport.wrap("Tiger"));
+ mo.getProperty("jndi-name").setValue(SimpleValueSupport.wrap("ChangedDS"));
+
+ getLog().debug(mock.prettyPrint());
+
+ byte[] data = super.serialize(mo);
+ ManagedObject mo2 = (ManagedObject) super.deserialize(data);
+
+ assertEquals("jndiName", SimpleValueSupport.wrap("ChangedDS"),
+ mo2.getProperty("jndi-name").getValue());
+ assertEquals("user", SimpleValueSupport.wrap("Scott"),
+ mo2.getProperty("user").getValue());
+ assertEquals("password",SimpleValueSupport.wrap("Tiger"),
+ mo2.getProperty("password").getValue());
+ }
+
+ /**
+ * Test the managed object property map serialization
+ *
+ * @throws Exception for any problem
+ */
+ @SuppressWarnings("unchecked")
+ public void testManagedPropertyMapSerialization()
+ throws Exception
+ {
+ MockDataSourceManagedObject mock = new MockDataSourceManagedObject();
+ ManagedObject mo = mock;
+
+ ManagedProperty jndiName = mo.getProperty("jndi-name");
+ jndiName.setValue(SimpleValueSupport.wrap("DefaultDS"));
+ ManagedProperty user = mo.getProperty("user");
+ user.setValue(SimpleValueSupport.wrap("Scott"));
+ ManagedProperty password = mo.getProperty("password");
+ password.setValue(SimpleValueSupport.wrap("Tiger"));
+ jndiName.setValue(SimpleValueSupport.wrap("ChangedDS"));
+
+ HashMap<String, ManagedProperty> props = new HashMap<String, ManagedProperty>();
+ props.put(jndiName.getName(), jndiName);
+ props.put(user.getName(), user);
+ props.put(password.getName(), password);
+
+ HashMap<String, ManagedProperty> props2 = serializeDeserialize(props, HashMap.class);
+
+ ManagedProperty jndiName2 = props2.get("jndi-name");
+ assertEquals("jndiName", SimpleValueSupport.wrap("ChangedDS"), jndiName2.getValue());
+ ManagedProperty jndiName3 = jndiName2.getManagedObject().getProperty("jndi-name");
+ assertEquals("jndiName", SimpleValueSupport.wrap("ChangedDS"), jndiName3.getValue());
+ ManagedProperty user2 = props2.get("user");
+ assertEquals("user", SimpleValueSupport.wrap("Scott"), user2.getValue());
+ ManagedProperty password2 = props2.get("password");
+ assertEquals("password", SimpleValueSupport.wrap("Tiger"), password2.getValue());
+ }
+
+ /**
+ * Serialize/deserialize
+ *
+ * TODO move to AbstractTestCase
+ * @param <T> the expected type
+ * @param value the value
+ * @param expected the expected type
+ * @return the result
+ * @throws Exception for any problem
+ */
+ protected <T> T serializeDeserialize(Serializable value, Class<T> expected) throws Exception
+ {
+ byte[] bytes = serialize(value);
+ Object result = deserialize(bytes);
+ return assertInstanceOf(result, expected);
+
+ }
+
+ @Override
+ protected void configureLogging()
+ {
+ enableTrace("org.jboss.managed.plugins.advice");
+ }
+}
Deleted: projects/jboss-man/tags/2.0.0.CR5/metatype/pom.xml
===================================================================
--- projects/jboss-man/branches/Branch_2_0/metatype/pom.xml 2008-11-19 16:43:01 UTC (rev 81300)
+++ projects/jboss-man/tags/2.0.0.CR5/metatype/pom.xml 2008-11-19 22:43:42 UTC (rev 81334)
@@ -1,69 +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</artifactId>
- <version>2.0.0-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <artifactId>jboss-metatype</artifactId>
- <packaging>jar</packaging>
- <name>JBoss Metatype</name>
- <url>http://www.jboss.com/products/jbossmc</url>
- <description>JBoss Metatype</description>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <testFailureIgnore>true</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>
-
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-</project>
\ No newline at end of file
Copied: projects/jboss-man/tags/2.0.0.CR5/metatype/pom.xml (from rev 81333, projects/jboss-man/branches/Branch_2_0/metatype/pom.xml)
===================================================================
--- projects/jboss-man/tags/2.0.0.CR5/metatype/pom.xml (rev 0)
+++ projects/jboss-man/tags/2.0.0.CR5/metatype/pom.xml 2008-11-19 22:43:42 UTC (rev 81334)
@@ -0,0 +1,73 @@
+<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</artifactId>
+ <version>2.0.0.CR5</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>jboss-metatype</artifactId>
+ <packaging>jar</packaging>
+ <name>JBoss Metatype</name>
+ <url>http://www.jboss.com/products/jbossmc</url>
+ <description>JBoss Metatype</description>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <testFailureIgnore>false</testFailureIgnore>
+ <excludes>
+<!-- Exclude until JBMAN-38 is resolved -->
+ <exclude>**/UnwrapValueUnitTestCase.java</exclude>
+ </excludes>
+ </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>
+
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
Deleted: projects/jboss-man/tags/2.0.0.CR5/metatype/src/main/java/org/jboss/metatype/plugins/values/CompositeValueInvocationHandler.java
===================================================================
--- projects/jboss-man/branches/Branch_2_0/metatype/src/main/java/org/jboss/metatype/plugins/values/CompositeValueInvocationHandler.java 2008-11-19 16:43:01 UTC (rev 81300)
+++ projects/jboss-man/tags/2.0.0.CR5/metatype/src/main/java/org/jboss/metatype/plugins/values/CompositeValueInvocationHandler.java 2008-11-19 22:43:42 UTC (rev 81334)
@@ -1,154 +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.metatype.plugins.values;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Type;
-import java.lang.reflect.Proxy;
-import java.util.Map;
-import java.util.Collections;
-import java.util.WeakHashMap;
-
-import org.jboss.util.UnreachableStatementException;
-import org.jboss.metatype.api.values.CompositeValue;
-import org.jboss.metatype.api.values.MetaValueFactory;
-import org.jboss.metatype.api.values.MetaValue;
-
-/**
- * CompositeValueInvocationHandler.
- *
- * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- */
-public class CompositeValueInvocationHandler implements InvocationHandler
-{
- /** The MetaValueFactory */
- private static MetaValueFactory factory = MetaValueFactory.getInstance();
-
- /** A cache of methods to keys */
- private static final Map<Method, String> compositeDataKeyCache = Collections.synchronizedMap(new WeakHashMap<Method, String>());
-
- /** The composite value */
- private CompositeValue compositeValue;
-
- /**
- * Create a new CompositeValueInvocationHandler.
- *
- * @param compositeValue the composite value
- */
- public CompositeValueInvocationHandler(CompositeValue compositeValue)
- {
- if (compositeValue == null)
- throw new IllegalArgumentException("Null compositeValue");
- this.compositeValue = compositeValue;
- }
-
- /**
- * Get the compositeData.
- *
- * @return the compositeData.
- */
- public CompositeValue getCompositeValue()
- {
- return compositeValue;
- }
-
- public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
- {
- if (Object.class.equals(method.getDeclaringClass()))
- return handleObjectInvocation(method.getName(), args);
-
- MetaValue value = compositeValue.get(getCompositeDataKey(method));
- Type returnType = method.getGenericReturnType();
- return factory.unwrap(value, returnType);
- }
-
- private Object handleObjectInvocation(String name, Object[] args) throws Throwable
- {
- if ("equals".equals(name))
- {
- Object object = args[0];
- if (object == null || object instanceof Proxy == false)
- return false;
- InvocationHandler handler = Proxy.getInvocationHandler(object);
- if (handler == this)
- return true;
- if (handler == null || handler instanceof CompositeValueInvocationHandler == false)
- return false;
-
- CompositeValueInvocationHandler other = (CompositeValueInvocationHandler) handler;
- return getCompositeValue().equals(other.getCompositeValue());
- }
- else if ("hashCode".equals(name))
- return getCompositeValue().hashCode();
- else if ("toString".equals(name))
- return getCompositeValue().toString();
- throw new UnreachableStatementException();
- }
-
- /**
- * Get the key for a composite data getter method
- *
- * @param method the method
- * @return the key
- */
- public static String getCompositeDataKey(Method method)
- {
- String key = compositeDataKeyCache.get(method);
- if (key != null)
- return key;
-
- StringBuilder fieldName = null;
-
- Class<?> returnType = method.getReturnType();
- Class<?>[] paramTypes = method.getParameterTypes();
- if (Void.TYPE.equals(returnType) == false && paramTypes.length == 0)
- {
- String name = method.getName();
- if (name.startsWith("is") && name.length() > 2)
- {
- if (Boolean.TYPE.equals(returnType))
- {
- fieldName = new StringBuilder();
- fieldName.append(Character.toLowerCase(name.charAt(2)));
- if (name.length() > 3)
- fieldName.append(name.substring(3));
- }
- }
- else if (name.startsWith("get") && name.length() > 3)
- {
- fieldName = new StringBuilder();
- fieldName.append(Character.toLowerCase(name.charAt(3)));
- if (name.length() > 4)
- fieldName.append(name.substring(4));
- }
- }
-
- if (fieldName == null)
- return null;
-
- String result = fieldName.toString();
- compositeDataKeyCache.put(method, result);
- return result;
- }
-}
Copied: projects/jboss-man/tags/2.0.0.CR5/metatype/src/main/java/org/jboss/metatype/plugins/values/CompositeValueInvocationHandler.java (from rev 81329, projects/jboss-man/branches/Branch_2_0/metatype/src/main/java/org/jboss/metatype/plugins/values/CompositeValueInvocationHandler.java)
===================================================================
--- projects/jboss-man/tags/2.0.0.CR5/metatype/src/main/java/org/jboss/metatype/plugins/values/CompositeValueInvocationHandler.java (rev 0)
+++ projects/jboss-man/tags/2.0.0.CR5/metatype/src/main/java/org/jboss/metatype/plugins/values/CompositeValueInvocationHandler.java 2008-11-19 22:43:42 UTC (rev 81334)
@@ -0,0 +1,160 @@
+/*
+* 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.metatype.plugins.values;
+
+import java.io.Serializable;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+import java.lang.reflect.Proxy;
+import java.util.Map;
+import java.util.Collections;
+import java.util.WeakHashMap;
+
+import org.jboss.util.UnreachableStatementException;
+import org.jboss.metatype.api.values.CompositeValue;
+import org.jboss.metatype.api.values.MetaValueFactory;
+import org.jboss.metatype.api.values.MetaValue;
+
+/**
+ * CompositeValueInvocationHandler.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class CompositeValueInvocationHandler
+ implements InvocationHandler, Serializable
+{
+ private static final long serialVersionUID = 1;
+
+ /** The MetaValueFactory */
+ private static MetaValueFactory factory = MetaValueFactory.getInstance();
+
+ /** A cache of methods to keys */
+ private static final Map<Method, String> compositeDataKeyCache = Collections.synchronizedMap(new WeakHashMap<Method, String>());
+
+ /** The composite value */
+ private CompositeValue compositeValue;
+
+ /**
+ * Create a new CompositeValueInvocationHandler.
+ *
+ * @param compositeValue the composite value
+ */
+ public CompositeValueInvocationHandler(CompositeValue compositeValue)
+ {
+ if (compositeValue == null)
+ throw new IllegalArgumentException("Null compositeValue");
+ this.compositeValue = compositeValue;
+ }
+
+ /**
+ * Get the compositeData.
+ *
+ * @return the compositeData.
+ */
+ public CompositeValue getCompositeValue()
+ {
+ return compositeValue;
+ }
+
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
+ {
+ if (Object.class.equals(method.getDeclaringClass()))
+ return handleObjectInvocation(method.getName(), args);
+
+ MetaValue value = compositeValue.get(getCompositeDataKey(method));
+ Type returnType = method.getGenericReturnType();
+ return factory.unwrap(value, returnType);
+ }
+
+ private Object handleObjectInvocation(String name, Object[] args) throws Throwable
+ {
+ if ("equals".equals(name))
+ {
+ Object object = args[0];
+ if (object == null || object instanceof Proxy == false)
+ return false;
+ InvocationHandler handler = Proxy.getInvocationHandler(object);
+ if (handler == this)
+ return true;
+ if (handler == null || handler instanceof CompositeValueInvocationHandler == false)
+ return false;
+
+ CompositeValueInvocationHandler other = (CompositeValueInvocationHandler) handler;
+ return getCompositeValue().equals(other.getCompositeValue());
+ }
+ else if ("hashCode".equals(name))
+ return getCompositeValue().hashCode();
+ else if ("toString".equals(name))
+ return getCompositeValue().toString();
+ throw new UnreachableStatementException();
+ }
+
+ /**
+ * Get the key for a composite data getter method
+ *
+ * @param method the method
+ * @return the key
+ */
+ public static String getCompositeDataKey(Method method)
+ {
+ String key = compositeDataKeyCache.get(method);
+ if (key != null)
+ return key;
+
+ StringBuilder fieldName = null;
+
+ Class<?> returnType = method.getReturnType();
+ Class<?>[] paramTypes = method.getParameterTypes();
+ if (Void.TYPE.equals(returnType) == false && paramTypes.length == 0)
+ {
+ String name = method.getName();
+ if (name.startsWith("is") && name.length() > 2)
+ {
+ if (Boolean.TYPE.equals(returnType))
+ {
+ fieldName = new StringBuilder();
+ fieldName.append(Character.toLowerCase(name.charAt(2)));
+ if (name.length() > 3)
+ fieldName.append(name.substring(3));
+ }
+ }
+ else if (name.startsWith("get") && name.length() > 3)
+ {
+ fieldName = new StringBuilder();
+ fieldName.append(Character.toLowerCase(name.charAt(3)));
+ if (name.length() > 4)
+ fieldName.append(name.substring(4));
+ }
+ }
+
+ if (fieldName == null)
+ return null;
+
+ String result = fieldName.toString();
+ compositeDataKeyCache.put(method, result);
+ return result;
+ }
+}
Deleted: projects/jboss-man/tags/2.0.0.CR5/metatype/src/main/java/org/jboss/metatype/plugins/values/DefaultMetaValueFactory.java
===================================================================
--- projects/jboss-man/branches/Branch_2_0/metatype/src/main/java/org/jboss/metatype/plugins/values/DefaultMetaValueFactory.java 2008-11-19 16:43:01 UTC (rev 81300)
+++ projects/jboss-man/tags/2.0.0.CR5/metatype/src/main/java/org/jboss/metatype/plugins/values/DefaultMetaValueFactory.java 2008-11-19 22:43:42 UTC (rev 81334)
@@ -1,1064 +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.plugins.values;
-
-import java.io.Serializable;
-import java.lang.ref.WeakReference;
-import java.lang.reflect.Array;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Proxy;
-import java.lang.reflect.Type;
-import java.lang.reflect.UndeclaredThrowableException;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.SortedSet;
-import java.util.Stack;
-import java.util.WeakHashMap;
-import java.util.Map.Entry;
-
-import org.jboss.beans.info.spi.BeanInfo;
-import org.jboss.beans.info.spi.PropertyInfo;
-import org.jboss.config.plugins.property.PropertyConfiguration;
-import org.jboss.config.spi.Configuration;
-import org.jboss.metatype.api.types.ArrayMetaType;
-import org.jboss.metatype.api.types.CollectionMetaType;
-import org.jboss.metatype.api.types.CompositeMetaType;
-import org.jboss.metatype.api.types.EnumMetaType;
-import org.jboss.metatype.api.types.GenericMetaType;
-import org.jboss.metatype.api.types.MapCompositeMetaType;
-import org.jboss.metatype.api.types.MetaType;
-import org.jboss.metatype.api.types.MetaTypeFactory;
-import org.jboss.metatype.api.types.SimpleMetaType;
-import org.jboss.metatype.api.types.TableMetaType;
-import org.jboss.metatype.api.values.ArrayValue;
-import org.jboss.metatype.api.values.ArrayValueSupport;
-import org.jboss.metatype.api.values.CollectionValue;
-import org.jboss.metatype.api.values.CollectionValueSupport;
-import org.jboss.metatype.api.values.CompositeValue;
-import org.jboss.metatype.api.values.CompositeValueSupport;
-import org.jboss.metatype.api.values.EnumValue;
-import org.jboss.metatype.api.values.EnumValueSupport;
-import org.jboss.metatype.api.values.GenericValue;
-import org.jboss.metatype.api.values.GenericValueSupport;
-import org.jboss.metatype.api.values.InstanceFactory;
-import org.jboss.metatype.api.values.MapCompositeValueSupport;
-import org.jboss.metatype.api.values.MetaValue;
-import org.jboss.metatype.api.values.MetaValueFactory;
-import org.jboss.metatype.api.values.SimpleValue;
-import org.jboss.metatype.api.values.SimpleValueSupport;
-import org.jboss.metatype.api.values.TableValue;
-import org.jboss.metatype.api.values.TableValueSupport;
-import org.jboss.metatype.plugins.types.DefaultMetaTypeFactory;
-import org.jboss.metatype.spi.values.MetaMapper;
-import org.jboss.metatype.spi.values.MetaValueBuilder;
-import org.jboss.reflect.plugins.introspection.ParameterizedClassInfo;
-import org.jboss.reflect.spi.ArrayInfo;
-import org.jboss.reflect.spi.ClassInfo;
-import org.jboss.reflect.spi.TypeInfo;
-import org.jboss.reflect.spi.TypeInfoFactory;
-
-/**
- * DefaultMetaValueFactory.
- *
- * @author <a href="ales.justin at jboss.com">Ales Justin</a>
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
-public class DefaultMetaValueFactory extends MetaValueFactory
-{
- /** The metatype factory */
- private MetaTypeFactory metaTypeFactory = MetaTypeFactory.getInstance();
-
- /** The configuration */
- private static Configuration configuration;
-
- static
- {
- configuration = AccessController.doPrivileged(new PrivilegedAction<Configuration>()
- {
- public Configuration run()
- {
- return new PropertyConfiguration();
- }
- });
- }
-
- /** The thread local stack of objects mapped to meta values */
- private ThreadLocal<Stack<Map<Object, MetaValue>>> mappingStack = new ThreadLocal<Stack<Map<Object, MetaValue>>>()
- {
- protected Stack<Map<Object, MetaValue>> initialValue()
- {
- return new Stack<Map<Object, MetaValue>>();
- }
- };
-
- /** The builders */
- private Map<Class<?>, WeakReference<MetaValueBuilder<?>>> builders = new WeakHashMap<Class<?>, WeakReference<MetaValueBuilder<?>>>();
-
- /** The Object type info */
- private static final TypeInfo OBJECT_TYPE_INFO = configuration.getTypeInfo(Object.class);
-
- /** The instance factory builders */
- private Map<Class<?>, InstanceFactory<?>> instanceFactoryMap = new WeakHashMap<Class<?>, InstanceFactory<?>>();
-
- public DefaultMetaValueFactory()
- {
- // set default collection instance factories
- setInstanceFactory(List.class, ListInstanceFactory.INSTANCE);
- setInstanceFactory(Set.class, SetInstanceFactory.INSTANCE);
- setInstanceFactory(SortedSet.class, SortedSetInstanceFactory.INSTANCE);
- }
-
- public void setBuilder(Class<?> clazz, MetaValueBuilder<?> builder)
- {
- synchronized (builders)
- {
- if (builder == null)
- builders.remove(clazz);
- builders.put(clazz, new WeakReference<MetaValueBuilder<?>>(builder));
- }
- }
-
- public <T> void setInstanceFactory(Class<T> clazz, InstanceFactory<T> factory)
- {
- synchronized(instanceFactoryMap)
- {
- if (factory == null)
- instanceFactoryMap.remove(clazz);
- else
- instanceFactoryMap.put(clazz, factory);
- }
- }
-
- /**
- * Create a simple value
- *
- * @param type the type
- * @param value the value
- * @return the simple value
- */
- public static SimpleValue createSimpleValue(SimpleMetaType type, Serializable value)
- {
- if (value == null)
- return null;
-
- return new SimpleValueSupport(type, value);
- }
-
- /**
- * Create an enum value
- *
- * @param <T> the enum type
- * @param type the type
- * @param value the value
- * @return the enum value
- */
- public static <T extends Enum<?>> EnumValue createEnumValue(EnumMetaType type, T value)
- {
- if (value == null)
- return null;
-
- return new EnumValueSupport(type, value.name());
- }
-
- /**
- * Create a generic value
- *
- * @param type the type
- * @param value the value
- * @param mapping the mapping
- * @return the generic value
- */
- public static GenericValue createGenericValue(GenericMetaType type, Object value, Map<Object, MetaValue> mapping)
- {
- if (value == null)
- return null;
-
- if (value instanceof Serializable == false)
- throw new IllegalArgumentException("Not serializable: " + value.getClass().getName());
-
- GenericValue result = new GenericValueSupport(type, (Serializable) value);
- mapping.put(value, result);
- return result;
- }
-
- /**
- * Create a collection value
- *
- * @param type the type
- * @param value the value
- * @param mapping the mapping
- * @return the generic value
- */
- public CollectionValue createCollectionValue(CollectionMetaType type, Object value, Map<Object, MetaValue> mapping)
- {
- if (value == null)
- return null;
-
- Collection<?> collection = (Collection<?>)value;
- MetaValue[] elements = new MetaValue[collection.size()];
- int i = 0;
- for(Object ce : collection)
- {
- // recalculate element info, since usually more deterministic
- TypeInfo typeInfo = configuration.getTypeInfo(ce.getClass());
- MetaType metaType = metaTypeFactory.resolve(typeInfo);
- elements[i++] = internalCreate(ce, typeInfo, metaType);
- }
- CollectionValue result = new CollectionValueSupport(type, elements);
- mapping.put(value, result);
- return result;
- }
-
- /**
- * Transform a primitive array into an Object[]. Converts
- * a primitive array like char[] to Object[].
- *
- * @param type - the primitive array class type info.
- * @param value - the primitive array instance.
- * @return object array
- */
- public static Object[] convertPrimativeArray(TypeInfo type, Object value)
- {
- if (value == null)
- return null;
-
- Object[] oa;
- if( type instanceof ArrayInfo )
- {
- // Get the Object form of the element
- ArrayInfo arrayInfo = ArrayInfo.class.cast(type);
- TypeInfo etype = arrayInfo.getComponentType();
- int size = Array.getLength(value);
- oa = new Object[size];
- for(int n = 0; n < size; n ++)
- {
- Object nvalue = Array.get(value, n);
- // Recursively convert nested array elements
- if (etype.isArray())
- {
- oa[n] = convertPrimativeArray(etype, nvalue);
- }
- oa[n] = nvalue;
- }
- }
- else
- {
- oa = (Object[]) value;
- }
-
- return oa;
- }
-
- /**
- * Transform a primitive array into an Object[]. Converts
- * a primitive array like char[] to Object[].
- *
- * @param value - the primitive array instance.
- * @return object array
- */
- public static Object[] convertPrimativeArray(Object value)
- {
- if (value == null)
- return null;
- return convertPrimativeArray(configuration.getTypeInfo(value.getClass()), value);
- }
-
- /**
- * Create an array value
- *
- * @param type the type
- * @param value the value
- * @param mapping the mapping
- * @return the composite value
- */
- @SuppressWarnings("unchecked")
- public ArrayValue createArrayValue(ArrayMetaType type, Object value, Map<Object, MetaValue> mapping)
- {
- if (value == null)
- return null;
-
- ArrayValueSupport result = new ArrayValueSupport(type);
- mapping.put(value, result);
-
- Object[] array;
-
- MetaType elementType = type.getElementType();
- int dimension = type.getDimension();
-
- Object[] oldArray;
- Class<?> componentType;
- try
- {
- componentType = Class.forName(type.getClassName());
- }
- catch (Exception e)
- {
- throw new RuntimeException("Unable to determine component type for " + type, e);
- }
-
- ClassInfo classInfo = configuration.getClassInfo(value.getClass());
- if (classInfo.isArray())
- {
- // See if this is a primitive array
- ArrayInfo arrayInfo = ArrayInfo.class.cast(classInfo);
- TypeInfo compInfo = arrayInfo.getComponentType();
- while(compInfo instanceof ArrayInfo)
- {
- arrayInfo = ArrayInfo.class.cast(compInfo);
- compInfo = arrayInfo.getComponentType();
- }
- // Translate
- if (compInfo.isPrimitive())
- oldArray = convertPrimativeArray(classInfo, value);
- else
- oldArray = (Object[]) value;
- }
- else
- throw new UnsupportedOperationException("Cannot construct array for " + value.getClass());
-
- array = createArray(elementType, componentType.getComponentType(), dimension, oldArray);
- result.setValue(array);
- return result;
- }
-
- /**
- * Create an array
- *
- * @param elementType the element type
- * @param componentType the component type
- * @param dimension the dimension
- * @param oldArray the old array
- * @return the array
- */
- protected Object[] createArray(MetaType elementType, Class<?> componentType, int dimension, Object[] oldArray)
- {
- if (oldArray == null)
- return null;
-
- Object[] newArray = new Object[oldArray.length];
-
- if (dimension > 1)
- {
- Object[] nestedOld;
- for (int i = 0; i < oldArray.length; ++i)
- {
- if ( !(oldArray[i] instanceof Object[]) )
- nestedOld = convertPrimativeArray(oldArray[i]);
- else
- nestedOld = (Object[]) oldArray[i];
- Object[] result = createArray(elementType, componentType.getComponentType(), dimension-1, nestedOld);
- newArray[i] = result;
- }
- }
- else
- {
- for (int i = 0; i < oldArray.length; ++i)
- newArray[i] = internalCreate(oldArray[i], null, elementType);
- }
-
- return newArray;
- }
-
- /**
- * Create a composite value
- *
- * @param type the type
- * @param value the value
- * @param mapping the mapping
- * @return the composite value
- */
- @SuppressWarnings("unchecked")
- public CompositeValue createCompositeValue(CompositeMetaType type, Object value, Map<Object, MetaValue> mapping)
- {
- if (value == null)
- return null;
-
- // See if this is a Map<String,?> type
- if(type instanceof MapCompositeMetaType)
- {
- if((value instanceof Map) == false)
- throw new RuntimeException("Expected Map value for: " + type+", was: "+(value != null ? value.getClass() : "null"));
- Map<String,?> map = (Map) value;
- MapCompositeMetaType mapType = (MapCompositeMetaType) type;
- MetaType mapValueType = mapType.getValueType();
- MapCompositeValueSupport result = new MapCompositeValueSupport(mapValueType);
- for(Entry<String,?> entry : map.entrySet())
- {
- Object entryValue = entry.getValue();
- MetaValue entryMetaValue = internalCreate(entryValue, null, mapValueType);
- result.put(entry.getKey(), entryMetaValue);
- }
- mapping.put(value, result);
- return result;
- }
-
- CompositeValueSupport result = new CompositeValueSupport(type);
- mapping.put(value, result);
-
- BeanInfo beanInfo;
- try
- {
- ClassLoader cl = value.getClass().getClassLoader();
- if (cl == null)
- beanInfo = configuration.getBeanInfo(value.getClass());
- else
- beanInfo = configuration.getBeanInfo(type.getTypeName(), cl);
- }
- catch (Exception e)
- {
- throw new RuntimeException("Error retrieving BeanInfo for " + type, e);
- }
-
- for (String name : type.itemSet())
- {
- MetaType itemType = type.getType(name);
- Object itemValue;
- try
- {
- itemValue = beanInfo.getProperty(value, name);
- }
- catch (RuntimeException e)
- {
- throw e;
- }
- catch (Error e)
- {
- throw e;
- }
- catch (Throwable t)
- {
- throw new RuntimeException("Error getting property: " + name + " for " + value.getClass(), t);
- }
-
- MetaValue item = internalCreate(itemValue, null, itemType);
- result.set(name, item);
- }
-
- return result;
- }
-
- /**
- * Create a table value
- *
- * @param type the type
- * @param value the value
- * @param mapping the mapping
- * @return the table value
- */
- @SuppressWarnings("unchecked")
- public TableValue createTableValue(TableMetaType type, Map value, Map<Object, MetaValue> mapping)
- {
- if (value == null)
- return null;
-
- TableValueSupport table = new TableValueSupport(type);
- mapping.put(value, table);
-
- CompositeMetaType entryType = type.getRowType();
- MetaType keyType = entryType.getType(DefaultMetaTypeFactory.MAP_KEY);
- MetaType valType = entryType.getType(DefaultMetaTypeFactory.MAP_VALUE);
-
- for (Iterator<Map.Entry> i = value.entrySet().iterator(); i.hasNext();)
- {
- Map.Entry entry = i.next();
- MetaValue key = internalCreate(entry.getKey(), null, keyType);
- MetaValue val = internalCreate(entry.getValue(), null, valType);
- CompositeValueSupport data = new CompositeValueSupport(entryType, DefaultMetaTypeFactory.MAP_ITEM_NAMES, new MetaValue[] { key, val });
- table.put(data);
- }
-
- return table;
- }
-
- @Override
- public MetaValue create(Object value)
- {
- return internalCreate(value, null, null);
- }
-
- @Override
- public MetaValue create(Object value, Type type)
- {
- TypeInfo typeInfo = configuration.getTypeInfo(type);
- return internalCreate(value, typeInfo, null);
- }
-
- @Override
- public MetaValue create(Object value, TypeInfo type)
- {
- return internalCreate(value, type, null);
- }
-
- @Override
- public Object unwrap(MetaValue metaValue)
- {
- return internalUnwrap(metaValue, null);
- }
-
- @Override
- public Object unwrap(MetaValue metaValue, Type type)
- {
- TypeInfo typeInfo = configuration.getTypeInfo(type);
- return internalUnwrap(metaValue, typeInfo);
- }
-
- @Override
- public Object unwrap(MetaValue metaValue, TypeInfo type)
- {
- return internalUnwrap(metaValue, type);
- }
-
- /**
- * Unwrap value from meta value.
- *
- * @param metaValue the meta value
- * @param type expected type info
- * @return unwrapped value
- */
- protected Object internalUnwrap(MetaValue metaValue, TypeInfo type)
- {
- if (metaValue == null)
- return null;
-
- MetaMapper<?> mapper = MetaMapper.getMetaMapper(type);
- if (mapper != null)
- return mapper.unwrapMetaValue(metaValue);
-
- MetaType metaType = metaValue.getMetaType();
-
- if (metaType.isSimple())
- {
- Serializable value = ((SimpleValue)metaValue).getValue();
- return getValue(metaType, type, value);
- }
- else if (metaType.isEnum())
- {
- String value = ((EnumValue)metaValue).getValue();
- return getValue(metaType, type, value);
- }
- else if (metaType.isGeneric())
- {
- Serializable value = ((GenericValue)metaValue).getValue();
- return getValue(metaType, type, value);
- }
- else if (metaType.isArray())
- {
- ArrayValue arrayValue = (ArrayValue)metaValue;
- if (type == null)
- type= getTypeInfo(metaType, arrayValue.getValue());
- Object array = newArrayInstance(type, arrayValue.getLength());
- for (int i = 0; i < Array.getLength(array); i++)
- {
- Object element = arrayValue.getValue(i);
- if (element instanceof MetaValue)
- element = unwrapMetaValue((MetaValue)element, type, array);
- else if (element != null && element.getClass().isArray())
- element = unwrapArray(array, element);
-
- Array.set(array, i, element);
- }
- return array;
- }
- else if (metaType.isComposite())
- {
- CompositeValue compositeValue = (CompositeValue)metaValue;
- return unwrapComposite(compositeValue, type);
- }
- else if (metaType.isCollection())
- {
- CollectionValue collectionValue = (CollectionValue)metaValue;
- return unwrapCollection(collectionValue, type);
- }
- else if (metaType.isTable())
- {
- TableValue tableValue = (TableValue)metaValue;
- return unwrapTable(tableValue, type);
- }
-
- throw new IllegalArgumentException("Unsupported meta value: " + metaValue);
- }
-
- /**
- * Do a simple check.
- * If current type param is null,
- * try getting type info from meta type
- * and value's classloader.
- *
- * @param type the type info
- * @param value tester value
- * @param metaType the meta type
- * @return type info
- */
- protected TypeInfo checkTypeInfo(TypeInfo type, Object value, MetaType metaType)
- {
- if (type == null && value != null)
- type = getTypeInfo(metaType, value);
- return type;
- }
-
- /**
- * Get the value.
- * Join type check and value conversion.
- *
- * @param metaType the meta type
- * @param typeInfo the type info
- * @param value the value
- * @return the converted value
- */
- protected Object getValue(MetaType metaType, TypeInfo typeInfo, Object value)
- {
- typeInfo = checkTypeInfo(typeInfo, value, metaType);
- return convertValue(value, typeInfo);
- }
-
- /**
- * Unwrap MetaValue.
- *
- * @param element the meta value
- * @param type parent type
- * @param array parent array
- * @return unwrapped value
- */
- protected Object unwrapMetaValue(MetaValue element, TypeInfo type, Object array)
- {
- TypeInfo elementType;
- if (type instanceof ClassInfo)
- elementType = ((ClassInfo)type).getComponentType();
- else
- elementType = getTypeInfo(element.getMetaType(), array);
- return unwrap(element, elementType);
- }
-
- /**
- * Unwrap array.
- * @param array parent array
- * @param element current array element
- * @return unwrapped array element
- */
- protected Object unwrapArray(Object array, Object element)
- {
- TypeInfo elementType = configuration.getTypeInfo(array.getClass().getComponentType());
- int subSize = Array.getLength(element);
- Object newElement = newArrayInstance(elementType, subSize);
- for(int i = 0; i < subSize; i++)
- {
- Object subElement = Array.get(element, i);
- if (subElement instanceof MetaValue)
- subElement = unwrapMetaValue((MetaValue)subElement, elementType, newElement);
- if (subElement != null && subElement.getClass().isArray())
- subElement = unwrapArray(newElement, subElement);
-
- Array.set(newElement, i, subElement);
- }
- return newElement;
- }
-
- /**
- * Unwrap composite.
- *
- * @param compositeValue the composite value
- * @param typeInfo expected type info
- * @return unwrapped value
- */
- @SuppressWarnings("deprecation")
- protected Object unwrapComposite(CompositeValue compositeValue, TypeInfo typeInfo)
- {
- CompositeMetaType compositeMetaType = compositeValue.getMetaType();
- String typeName = compositeMetaType.getTypeName();
- ClassLoader cl;
- if (typeInfo != null)
- cl = typeInfo.getType().getClassLoader();
- else
- cl = Thread.currentThread().getContextClassLoader();
-
- try
- {
- BeanInfo beanInfo = configuration.getBeanInfo(typeName, cl);
- ClassInfo classInfo = beanInfo.getClassInfo();
- if (classInfo.isInterface())
- {
- InvocationHandler handler = createCompositeValueInvocationHandler(compositeValue);
- Class<?> clazz = classInfo.getType();
- Class<?>[] interfaces = new Class[]{clazz};
- return Proxy.newProxyInstance(clazz.getClassLoader(), interfaces, handler);
- }
- Object bean = createNewInstance(beanInfo);
- for (String name : compositeMetaType.itemSet())
- {
- MetaValue itemValue = compositeValue.get(name);
- PropertyInfo propertyInfo = beanInfo.getProperty(name);
- Object value = unwrap(itemValue, propertyInfo.getType());
- propertyInfo.set(bean, value);
- }
- return bean;
- }
- catch (Throwable t)
- {
- throw new UndeclaredThrowableException(t);
- }
- }
-
- /**
- * Create composite invocation handler.
- *
- * @param compositeValue the composite value
- * @return composite invocation handler
- */
- protected InvocationHandler createCompositeValueInvocationHandler(CompositeValue compositeValue)
- {
- return new CompositeValueInvocationHandler(compositeValue);
- }
-
- /**
- * Unwrap collection meta value.
- *
- * @param collectionValue the collection value
- * @param type the type info
- * @return unwrapped collection
- */
- @SuppressWarnings("unchecked")
- protected Object unwrapCollection(CollectionValue collectionValue, TypeInfo type)
- {
- try
- {
- BeanInfo collectionInfo;
- // null is not instance of
- if (type instanceof ClassInfo)
- {
- collectionInfo = configuration.getBeanInfo(type);
- }
- else
- {
- MetaType metaType = collectionValue.getMetaType();
- collectionInfo = configuration.getBeanInfo(metaType.getTypeName(), Thread.currentThread().getContextClassLoader());
- }
- ClassInfo classInfo = collectionInfo.getClassInfo();
- Collection collection = (Collection)createNewInstance(collectionInfo);
- Iterator<MetaValue> iter = collectionValue.iterator();
- while (iter.hasNext())
- {
- MetaValue metaValue = iter.next();
- TypeInfo componentType = classInfo.getComponentType();
- // try better
- if (OBJECT_TYPE_INFO.equals(componentType))
- componentType = getTypeInfo(metaValue.getMetaType(), null);
- collection.add(unwrap(metaValue, componentType));
- }
- return collection;
- }
- catch (Throwable t)
- {
- throw new UndeclaredThrowableException(t);
- }
- }
-
- /**
- * Unwrap table meta value.
- *
- * @param tableValue the table value
- * @param type the type info
- * @return unwrapped table (map)
- */
- @SuppressWarnings("deprecation")
- protected Object unwrapTable(TableValue tableValue, TypeInfo type)
- {
- if (type instanceof ParameterizedClassInfo)
- {
- ParameterizedClassInfo parameterizedType = (ParameterizedClassInfo)type;
- ClassInfo rawType = parameterizedType.getRawType();
- if (Map.class.isAssignableFrom(rawType.getType()))
- {
- TypeInfo keyType = parameterizedType.getActualTypeArguments()[0];
- TypeInfo valueType = parameterizedType.getActualTypeArguments()[1];
- return createMap(tableValue, keyType, valueType);
- }
- }
- throw new UnsupportedOperationException("Insufficient information to unwrap table: " + tableValue + ", " + type);
- }
-
- /**
- * Create a map
- *
- * @param tableValue the table value
- * @param keyType the key type
- * @param valueType the value type
- * @return the map
- */
- protected Map<?,?> createMap(TableValue tableValue, TypeInfo keyType, TypeInfo valueType)
- {
- if (tableValue == null)
- return null;
-
- Map<Object, Object> result = new HashMap<Object, Object>();
- Collection<CompositeValue> values = tableValue.values();
- for (CompositeValue entry : values)
- {
- Object key = unwrap(entry.get(DefaultMetaTypeFactory.MAP_KEY), keyType);
- Object val = unwrap(entry.get(DefaultMetaTypeFactory.MAP_VALUE), valueType);
- result.put(key, val);
- }
- return result;
- }
-
- /**
- * Create new instance.
- *
- * @param beanInfo the bean info
- * @return new instance
- * @throws Throwable for any error
- */
- @SuppressWarnings("deprecation")
- protected Object createNewInstance(BeanInfo beanInfo) throws Throwable
- {
- ClassInfo classInfo = beanInfo.getClassInfo();
- if (classInfo.isInterface())
- {
- InstanceFactory<?> instanceFactory = instanceFactoryMap.get(classInfo.getType());
- if (instanceFactory == null)
- throw new IllegalArgumentException("Cannot instantiate interface BeanInfo, missing InstanceFactory: " + classInfo);
-
- return instanceFactory.instantiate(beanInfo);
- }
- return beanInfo.newInstance();
- }
-
- /**
- * Get new array instance.
- *
- * @param typeInfo the type info
- * @param size the size
- * @return new array instance
- */
- protected Object newArrayInstance(TypeInfo typeInfo, int size)
- {
- if (typeInfo == null)
- throw new IllegalArgumentException("Null type info.");
-
- try
- {
- return typeInfo.newArrayInstance(size);
- }
- catch (Throwable t)
- {
- throw new UndeclaredThrowableException(t);
- }
- }
-
- /**
- * Get the class info from meta type.
- *
- * @param metaType the meta type
- * @param value the value which can provide classloader
- * @return type info
- */
- protected TypeInfo getTypeInfo(MetaType metaType, Object value)
- {
- if (metaType == null)
- throw new IllegalArgumentException("Null meta type, cannot determine class name.");
- if (value == null)
- throw new IllegalArgumentException("Null value, cannot determine classloader.");
-
- // get the classloader from the array we plan to fill
- ClassLoader cl = value.getClass().getClassLoader();
- return getTypeInfo(metaType, cl);
- }
-
- /**
- * Get the class info from meta type.
- *
- * @param metaType the meta type
- * @param cl the classloader
- * @return class info
- */
- protected TypeInfo getTypeInfo(MetaType metaType, ClassLoader cl)
- {
- if (cl == null)
- cl = Thread.currentThread().getContextClassLoader();
-
- try
- {
- TypeInfoFactory tif = configuration.getTypeInfoFactory();
- if (metaType.isArray())
- {
- ArrayMetaType arrayMetaType = (ArrayMetaType)metaType;
- MetaType elementMetaType = arrayMetaType.getElementType();
- String elementTypeName = elementMetaType.getTypeName();
- if (arrayMetaType.isPrimitiveArray())
- elementTypeName = ArrayMetaType.getPrimitiveName(elementTypeName);
- TypeInfo elementTypeInfo = tif.getTypeInfo(elementTypeName, cl);
- int dimension = arrayMetaType.getDimension() - 1; // minus 1, since we already use first in next line
- TypeInfo typeInfo = elementTypeInfo.getArrayType();
- while(dimension > 0)
- {
- typeInfo = typeInfo.getArrayType();
- dimension--;
- }
- return typeInfo;
- }
- return tif.getTypeInfo(metaType.getTypeName(), cl);
- }
- catch (ClassNotFoundException e)
- {
- throw new UndeclaredThrowableException(e);
- }
- }
-
- /**
- * Create a meta value from the object
- *
- * @param value the value
- * @param type the type
- * @param metaType the metaType
- * @return the meta value
- */
- @SuppressWarnings("unchecked")
- protected MetaValue internalCreate(Object value, TypeInfo type, MetaType metaType)
- {
- if (value == null)
- return null;
-
- if (type == null)
- type = configuration.getTypeInfo(value.getClass());
-
- value = convertValue(value, type);
-
- boolean start = false;
- if (metaType == null)
- {
- start = true;
- metaType = metaTypeFactory.resolve(type);
- }
-
- // For more complicated values we need to keep a mapping of objects to meta values
- // this avoids duplicate meta value construction and recursion
- Map<Object, MetaValue> mapping;
- if (start)
- {
- // This is the start of the mapping
- mapping = new HashMap<Object, MetaValue>();
- mappingStack.get().push(mapping);
- }
- else
- {
- // Check the existing mapping
- mapping = mappingStack.get().peek();
- MetaValue result = mapping.get(value);
- // Seen this before
- if (result != null)
- return result;
- }
-
- try
- {
- MetaValue result = isBuilder(metaType, type, value, mapping);
-
- if (result == null)
- {
- MetaMapper<Object> mapper = (MetaMapper) MetaMapper.getMetaMapper(type);
- if (mapper != null)
- result = mapper.createMetaValue(metaType, value);
- }
-
- if (result == null)
- {
- if (metaType.isSimple())
- result = createSimpleValue((SimpleMetaType) metaType, (Serializable) value);
- else if (metaType.isEnum())
- result = createEnumValue((EnumMetaType) metaType, (Enum<?>) value);
- else if (metaType.isArray())
- result = createArrayValue((ArrayMetaType) metaType, value, mapping);
- else if (metaType.isComposite())
- result = createCompositeValue((CompositeMetaType) metaType, value, mapping);
- else if (metaType.isTable())
- result = createTableValue((TableMetaType) metaType, (Map<?,?>) value, mapping);
- else if (metaType.isGeneric())
- result = createGenericValue((GenericMetaType) metaType, value, mapping);
- else if (metaType.isCollection())
- result = createCollectionValue((CollectionMetaType) metaType, value, mapping);
- else
- throw new IllegalStateException("Unknown metaType: " + metaType);
- }
- return result;
- }
- finally
- {
- // Remove the mapping from the stack
- if (start)
- mappingStack.get().pop();
- }
- }
-
- /**
- * Convert the value.
- *
- * @param value the value
- * @param typeInfo type info
- * @return converted value if type info not null
- * @throws UndeclaredThrowableException for any error
- */
- protected Object convertValue(Object value, TypeInfo typeInfo)
- {
- try
- {
- return typeInfo != null ? typeInfo.convertValue(value) : value;
- }
- catch (Throwable t)
- {
- throw new UndeclaredThrowableException(t);
- }
- }
-
- /**
- * Check for a builder
- *
- * @param metaType the meta type
- * @param type the type
- * @param value the value
- * @param mapping the mappings
- * @return the meta value
- */
- @SuppressWarnings({"unchecked", "deprecation"})
- protected MetaValue isBuilder(MetaType metaType, TypeInfo type, Object value, Map<Object, MetaValue> mapping)
- {
- MetaValueBuilder builder = null;
- synchronized (builders)
- {
- WeakReference<MetaValueBuilder<?>> weak = builders.get(type.getType());
- if (weak != null)
- builder = weak.get();
- }
- if (builder == null)
- return null;
- MetaValue result = builder.buildMetaValue(metaType, value);
- if (result != null)
- mapping.put(value, result);
-
- return result;
- }
-}
Copied: projects/jboss-man/tags/2.0.0.CR5/metatype/src/main/java/org/jboss/metatype/plugins/values/DefaultMetaValueFactory.java (from rev 81328, projects/jboss-man/branches/Branch_2_0/metatype/src/main/java/org/jboss/metatype/plugins/values/DefaultMetaValueFactory.java)
===================================================================
--- projects/jboss-man/tags/2.0.0.CR5/metatype/src/main/java/org/jboss/metatype/plugins/values/DefaultMetaValueFactory.java (rev 0)
+++ projects/jboss-man/tags/2.0.0.CR5/metatype/src/main/java/org/jboss/metatype/plugins/values/DefaultMetaValueFactory.java 2008-11-19 22:43:42 UTC (rev 81334)
@@ -0,0 +1,1082 @@
+/*
+* 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.plugins.values;
+
+import java.io.Serializable;
+import java.lang.ref.WeakReference;
+import java.lang.reflect.Array;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Proxy;
+import java.lang.reflect.Type;
+import java.lang.reflect.UndeclaredThrowableException;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.Stack;
+import java.util.WeakHashMap;
+import java.util.Map.Entry;
+
+import org.jboss.beans.info.spi.BeanInfo;
+import org.jboss.beans.info.spi.PropertyInfo;
+import org.jboss.config.plugins.property.PropertyConfiguration;
+import org.jboss.config.spi.Configuration;
+import org.jboss.logging.Logger;
+import org.jboss.metatype.api.types.ArrayMetaType;
+import org.jboss.metatype.api.types.CollectionMetaType;
+import org.jboss.metatype.api.types.CompositeMetaType;
+import org.jboss.metatype.api.types.EnumMetaType;
+import org.jboss.metatype.api.types.GenericMetaType;
+import org.jboss.metatype.api.types.MapCompositeMetaType;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.MetaTypeFactory;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.types.TableMetaType;
+import org.jboss.metatype.api.values.ArrayValue;
+import org.jboss.metatype.api.values.ArrayValueSupport;
+import org.jboss.metatype.api.values.CollectionValue;
+import org.jboss.metatype.api.values.CollectionValueSupport;
+import org.jboss.metatype.api.values.CompositeValue;
+import org.jboss.metatype.api.values.CompositeValueSupport;
+import org.jboss.metatype.api.values.EnumValue;
+import org.jboss.metatype.api.values.EnumValueSupport;
+import org.jboss.metatype.api.values.GenericValue;
+import org.jboss.metatype.api.values.GenericValueSupport;
+import org.jboss.metatype.api.values.InstanceFactory;
+import org.jboss.metatype.api.values.MapCompositeValueSupport;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.MetaValueFactory;
+import org.jboss.metatype.api.values.SimpleValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.metatype.api.values.TableValue;
+import org.jboss.metatype.api.values.TableValueSupport;
+import org.jboss.metatype.plugins.types.DefaultMetaTypeFactory;
+import org.jboss.metatype.spi.values.MetaMapper;
+import org.jboss.metatype.spi.values.MetaValueBuilder;
+import org.jboss.reflect.plugins.introspection.ParameterizedClassInfo;
+import org.jboss.reflect.spi.ArrayInfo;
+import org.jboss.reflect.spi.ClassInfo;
+import org.jboss.reflect.spi.TypeInfo;
+import org.jboss.reflect.spi.TypeInfoFactory;
+
+/**
+ * DefaultMetaValueFactory.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision$
+ */
+public class DefaultMetaValueFactory extends MetaValueFactory
+{
+ private static final Logger log = Logger.getLogger(DefaultMetaValueFactory.class);
+
+ /** The metatype factory */
+ private MetaTypeFactory metaTypeFactory = MetaTypeFactory.getInstance();
+
+ /** The configuration */
+ private static Configuration configuration;
+
+ static
+ {
+ configuration = AccessController.doPrivileged(new PrivilegedAction<Configuration>()
+ {
+ public Configuration run()
+ {
+ return new PropertyConfiguration();
+ }
+ });
+ }
+
+ /** The thread local stack of objects mapped to meta values */
+ private ThreadLocal<Stack<Map<Object, MetaValue>>> mappingStack = new ThreadLocal<Stack<Map<Object, MetaValue>>>()
+ {
+ protected Stack<Map<Object, MetaValue>> initialValue()
+ {
+ return new Stack<Map<Object, MetaValue>>();
+ }
+ };
+
+ /** The builders */
+ private Map<Class<?>, WeakReference<MetaValueBuilder<?>>> builders = new WeakHashMap<Class<?>, WeakReference<MetaValueBuilder<?>>>();
+
+ /** The Object type info */
+ private static final TypeInfo OBJECT_TYPE_INFO = configuration.getTypeInfo(Object.class);
+
+ /** The instance factory builders */
+ private Map<Class<?>, InstanceFactory<?>> instanceFactoryMap = new WeakHashMap<Class<?>, InstanceFactory<?>>();
+
+ public DefaultMetaValueFactory()
+ {
+ // set default collection instance factories
+ setInstanceFactory(List.class, ListInstanceFactory.INSTANCE);
+ setInstanceFactory(Set.class, SetInstanceFactory.INSTANCE);
+ setInstanceFactory(SortedSet.class, SortedSetInstanceFactory.INSTANCE);
+ }
+
+ public void setBuilder(Class<?> clazz, MetaValueBuilder<?> builder)
+ {
+ synchronized (builders)
+ {
+ if (builder == null)
+ builders.remove(clazz);
+ builders.put(clazz, new WeakReference<MetaValueBuilder<?>>(builder));
+ }
+ }
+
+ public <T> void setInstanceFactory(Class<T> clazz, InstanceFactory<T> factory)
+ {
+ synchronized(instanceFactoryMap)
+ {
+ if (factory == null)
+ instanceFactoryMap.remove(clazz);
+ else
+ instanceFactoryMap.put(clazz, factory);
+ }
+ }
+
+ /**
+ * Create a simple value
+ *
+ * @param type the type
+ * @param value the value
+ * @return the simple value
+ */
+ public static SimpleValue createSimpleValue(SimpleMetaType type, Serializable value)
+ {
+ if (value == null)
+ return null;
+
+ return new SimpleValueSupport(type, value);
+ }
+
+ /**
+ * Create an enum value
+ *
+ * @param <T> the enum type
+ * @param type the type
+ * @param value the value
+ * @return the enum value
+ */
+ public static <T extends Enum<?>> EnumValue createEnumValue(EnumMetaType type, T value)
+ {
+ if (value == null)
+ return null;
+
+ return new EnumValueSupport(type, value.name());
+ }
+
+ /**
+ * Create a generic value
+ *
+ * @param type the type
+ * @param value the value
+ * @param mapping the mapping
+ * @return the generic value
+ */
+ public static GenericValue createGenericValue(GenericMetaType type, Object value, Map<Object, MetaValue> mapping)
+ {
+ if (value == null)
+ return null;
+
+ if (value instanceof Serializable == false)
+ throw new IllegalArgumentException("Not serializable: " + value.getClass().getName());
+
+ GenericValue result = new GenericValueSupport(type, (Serializable) value);
+ mapping.put(value, result);
+ return result;
+ }
+
+ /**
+ * Create a collection value
+ *
+ * @param type the type
+ * @param value the value
+ * @param mapping the mapping
+ * @return the generic value
+ */
+ public CollectionValue createCollectionValue(CollectionMetaType type, Object value, Map<Object, MetaValue> mapping)
+ {
+ if (value == null)
+ return null;
+
+ Collection<?> collection = (Collection<?>)value;
+ MetaValue[] elements = new MetaValue[collection.size()];
+ int i = 0;
+ for(Object ce : collection)
+ {
+ // recalculate element info, since usually more deterministic
+ TypeInfo typeInfo = configuration.getTypeInfo(ce.getClass());
+ MetaType metaType = metaTypeFactory.resolve(typeInfo);
+ elements[i++] = internalCreate(ce, typeInfo, metaType);
+ }
+ CollectionValue result = new CollectionValueSupport(type, elements);
+ mapping.put(value, result);
+ return result;
+ }
+
+ /**
+ * Transform a primitive array into an Object[]. Converts
+ * a primitive array like char[] to Object[].
+ *
+ * @param type - the primitive array class type info.
+ * @param value - the primitive array instance.
+ * @return object array
+ */
+ public static Object[] convertPrimativeArray(TypeInfo type, Object value)
+ {
+ if (value == null)
+ return null;
+
+ Object[] oa;
+ if( type instanceof ArrayInfo )
+ {
+ // Get the Object form of the element
+ ArrayInfo arrayInfo = ArrayInfo.class.cast(type);
+ TypeInfo etype = arrayInfo.getComponentType();
+ int size = Array.getLength(value);
+ oa = new Object[size];
+ for(int n = 0; n < size; n ++)
+ {
+ Object nvalue = Array.get(value, n);
+ // Recursively convert nested array elements
+ if (etype.isArray())
+ {
+ oa[n] = convertPrimativeArray(etype, nvalue);
+ }
+ oa[n] = nvalue;
+ }
+ }
+ else
+ {
+ oa = (Object[]) value;
+ }
+
+ return oa;
+ }
+
+ /**
+ * Transform a primitive array into an Object[]. Converts
+ * a primitive array like char[] to Object[].
+ *
+ * @param value - the primitive array instance.
+ * @return object array
+ */
+ public static Object[] convertPrimativeArray(Object value)
+ {
+ if (value == null)
+ return null;
+ return convertPrimativeArray(configuration.getTypeInfo(value.getClass()), value);
+ }
+
+ /**
+ * Create an array value
+ *
+ * @param type the type
+ * @param value the value
+ * @param mapping the mapping
+ * @return the composite value
+ */
+ @SuppressWarnings("unchecked")
+ public ArrayValue createArrayValue(ArrayMetaType type, Object value, Map<Object, MetaValue> mapping)
+ {
+ if (value == null)
+ return null;
+
+ ArrayValueSupport result = new ArrayValueSupport(type);
+ mapping.put(value, result);
+
+ Object[] array;
+
+ MetaType elementType = type.getElementType();
+ int dimension = type.getDimension();
+
+ Object[] oldArray;
+ Class<?> componentType;
+ try
+ {
+ componentType = Class.forName(type.getClassName());
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Unable to determine component type for " + type, e);
+ }
+
+ ClassInfo classInfo = configuration.getClassInfo(value.getClass());
+ if (classInfo.isArray())
+ {
+ // See if this is a primitive array
+ ArrayInfo arrayInfo = ArrayInfo.class.cast(classInfo);
+ TypeInfo compInfo = arrayInfo.getComponentType();
+ while(compInfo instanceof ArrayInfo)
+ {
+ arrayInfo = ArrayInfo.class.cast(compInfo);
+ compInfo = arrayInfo.getComponentType();
+ }
+ // Translate
+ if (compInfo.isPrimitive())
+ oldArray = convertPrimativeArray(classInfo, value);
+ else
+ oldArray = (Object[]) value;
+ }
+ else
+ throw new UnsupportedOperationException("Cannot construct array for " + value.getClass());
+
+ array = createArray(elementType, componentType.getComponentType(), dimension, oldArray);
+ result.setValue(array);
+ return result;
+ }
+
+ /**
+ * Create an array
+ *
+ * @param elementType the element type
+ * @param componentType the component type
+ * @param dimension the dimension
+ * @param oldArray the old array
+ * @return the array
+ */
+ protected Object[] createArray(MetaType elementType, Class<?> componentType, int dimension, Object[] oldArray)
+ {
+ if (oldArray == null)
+ return null;
+
+ Object[] newArray = new Object[oldArray.length];
+
+ if (dimension > 1)
+ {
+ Object[] nestedOld;
+ for (int i = 0; i < oldArray.length; ++i)
+ {
+ if ( !(oldArray[i] instanceof Object[]) )
+ nestedOld = convertPrimativeArray(oldArray[i]);
+ else
+ nestedOld = (Object[]) oldArray[i];
+ Object[] result = createArray(elementType, componentType.getComponentType(), dimension-1, nestedOld);
+ newArray[i] = result;
+ }
+ }
+ else
+ {
+ for (int i = 0; i < oldArray.length; ++i)
+ newArray[i] = internalCreate(oldArray[i], null, elementType);
+ }
+
+ return newArray;
+ }
+
+ /**
+ * Create a composite value
+ *
+ * @param type the type
+ * @param value the value
+ * @param mapping the mapping
+ * @return the composite value
+ */
+ @SuppressWarnings("unchecked")
+ public CompositeValue createCompositeValue(CompositeMetaType type, Object value, Map<Object, MetaValue> mapping)
+ {
+ if (value == null)
+ return null;
+
+ // See if this is a Map<String,?> type
+ if(type instanceof MapCompositeMetaType)
+ {
+ if((value instanceof Map) == false)
+ throw new RuntimeException("Expected Map value for: " + type+", was: "+(value != null ? value.getClass() : "null"));
+ Map<String,?> map = (Map) value;
+ MapCompositeMetaType mapType = (MapCompositeMetaType) type;
+ MetaType mapValueType = mapType.getValueType();
+ MapCompositeValueSupport result = new MapCompositeValueSupport(mapValueType);
+ for(Entry<String,?> entry : map.entrySet())
+ {
+ Object entryValue = entry.getValue();
+ MetaValue entryMetaValue = internalCreate(entryValue, null, mapValueType);
+ result.put(entry.getKey(), entryMetaValue);
+ }
+ mapping.put(value, result);
+ return result;
+ }
+
+ CompositeValueSupport result = new CompositeValueSupport(type);
+ mapping.put(value, result);
+
+ BeanInfo beanInfo;
+ try
+ {
+ ClassLoader cl = value.getClass().getClassLoader();
+ if (cl == null)
+ beanInfo = configuration.getBeanInfo(value.getClass());
+ else
+ beanInfo = configuration.getBeanInfo(type.getTypeName(), cl);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Error retrieving BeanInfo for " + type, e);
+ }
+
+ for (String name : type.itemSet())
+ {
+ MetaType itemType = type.getType(name);
+ Object itemValue;
+ try
+ {
+ itemValue = beanInfo.getProperty(value, name);
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (Error e)
+ {
+ throw e;
+ }
+ catch (Throwable t)
+ {
+ throw new RuntimeException("Error getting property: " + name + " for " + value.getClass(), t);
+ }
+
+ MetaValue item = internalCreate(itemValue, null, itemType);
+ result.set(name, item);
+ }
+
+ return result;
+ }
+
+ /**
+ * Create a table value
+ *
+ * @param type the type
+ * @param value the value
+ * @param mapping the mapping
+ * @return the table value
+ */
+ @SuppressWarnings("unchecked")
+ public TableValue createTableValue(TableMetaType type, Map value, Map<Object, MetaValue> mapping)
+ {
+ if (value == null)
+ return null;
+
+ TableValueSupport table = new TableValueSupport(type);
+ mapping.put(value, table);
+
+ CompositeMetaType entryType = type.getRowType();
+ MetaType keyType = entryType.getType(DefaultMetaTypeFactory.MAP_KEY);
+ MetaType valType = entryType.getType(DefaultMetaTypeFactory.MAP_VALUE);
+
+ for (Iterator<Map.Entry> i = value.entrySet().iterator(); i.hasNext();)
+ {
+ Map.Entry entry = i.next();
+ MetaValue key = internalCreate(entry.getKey(), null, keyType);
+ MetaValue val = internalCreate(entry.getValue(), null, valType);
+ CompositeValueSupport data = new CompositeValueSupport(entryType, DefaultMetaTypeFactory.MAP_ITEM_NAMES, new MetaValue[] { key, val });
+ table.put(data);
+ }
+
+ return table;
+ }
+
+ @Override
+ public MetaValue create(Object value)
+ {
+ return internalCreate(value, null, null);
+ }
+
+ @Override
+ public MetaValue create(Object value, Type type)
+ {
+ TypeInfo typeInfo = configuration.getTypeInfo(type);
+ return internalCreate(value, typeInfo, null);
+ }
+
+ @Override
+ public MetaValue create(Object value, TypeInfo type)
+ {
+ return internalCreate(value, type, null);
+ }
+
+ @Override
+ public Object unwrap(MetaValue metaValue)
+ {
+ return internalUnwrap(metaValue, null);
+ }
+
+ @Override
+ public Object unwrap(MetaValue metaValue, Type type)
+ {
+ TypeInfo typeInfo = configuration.getTypeInfo(type);
+ return internalUnwrap(metaValue, typeInfo);
+ }
+
+ @Override
+ public Object unwrap(MetaValue metaValue, TypeInfo type)
+ {
+ return internalUnwrap(metaValue, type);
+ }
+
+ /**
+ * Unwrap value from meta value.
+ *
+ * @param metaValue the meta value
+ * @param type expected type info
+ * @return unwrapped value
+ */
+ protected Object internalUnwrap(MetaValue metaValue, TypeInfo type)
+ {
+ if (metaValue == null)
+ return null;
+
+ MetaMapper<?> mapper = MetaMapper.getMetaMapper(type);
+ if (mapper != null)
+ return mapper.unwrapMetaValue(metaValue);
+
+ MetaType metaType = metaValue.getMetaType();
+
+ if (metaType.isSimple())
+ {
+ Serializable value = ((SimpleValue)metaValue).getValue();
+ return getValue(metaType, type, value);
+ }
+ else if (metaType.isEnum())
+ {
+ String value = ((EnumValue)metaValue).getValue();
+ return getValue(metaType, type, value);
+ }
+ else if (metaType.isGeneric())
+ {
+ Serializable value = ((GenericValue)metaValue).getValue();
+ return getValue(metaType, type, value);
+ }
+ else if (metaType.isArray())
+ {
+ ArrayValue arrayValue = (ArrayValue)metaValue;
+ if (type == null)
+ type= getTypeInfo(metaType, arrayValue.getValue());
+ Object array = newArrayInstance(type, arrayValue.getLength());
+ for (int i = 0; i < Array.getLength(array); i++)
+ {
+ Object element = arrayValue.getValue(i);
+ if (element instanceof MetaValue)
+ element = unwrapMetaValue((MetaValue)element, type, array);
+ else if (element != null && element.getClass().isArray())
+ element = unwrapArray(array, element);
+
+ Array.set(array, i, element);
+ }
+ return array;
+ }
+ else if (metaType.isComposite())
+ {
+ CompositeValue compositeValue = (CompositeValue)metaValue;
+ return unwrapComposite(compositeValue, type);
+ }
+ else if (metaType.isCollection())
+ {
+ CollectionValue collectionValue = (CollectionValue)metaValue;
+ return unwrapCollection(collectionValue, type);
+ }
+ else if (metaType.isTable())
+ {
+ TableValue tableValue = (TableValue)metaValue;
+ return unwrapTable(tableValue, type);
+ }
+
+ throw new IllegalArgumentException("Unsupported meta value: " + metaValue);
+ }
+
+ /**
+ * Do a simple check.
+ * If current type param is null,
+ * try getting type info from meta type
+ * and value's classloader.
+ *
+ * @param type the type info
+ * @param value tester value
+ * @param metaType the meta type
+ * @return type info
+ */
+ protected TypeInfo checkTypeInfo(TypeInfo type, Object value, MetaType metaType)
+ {
+ if (type == null && value != null)
+ type = getTypeInfo(metaType, value);
+ return type;
+ }
+
+ /**
+ * Get the value.
+ * Join type check and value conversion.
+ *
+ * @param metaType the meta type
+ * @param typeInfo the type info
+ * @param value the value
+ * @return the converted value
+ */
+ protected Object getValue(MetaType metaType, TypeInfo typeInfo, Object value)
+ {
+ typeInfo = checkTypeInfo(typeInfo, value, metaType);
+ return convertValue(value, typeInfo);
+ }
+
+ /**
+ * Unwrap MetaValue.
+ *
+ * @param element the meta value
+ * @param type parent type
+ * @param array parent array
+ * @return unwrapped value
+ */
+ protected Object unwrapMetaValue(MetaValue element, TypeInfo type, Object array)
+ {
+ TypeInfo elementType;
+ if (type instanceof ClassInfo)
+ elementType = ((ClassInfo)type).getComponentType();
+ else
+ elementType = getTypeInfo(element.getMetaType(), array);
+ return unwrap(element, elementType);
+ }
+
+ /**
+ * Unwrap array.
+ * @param array parent array
+ * @param element current array element
+ * @return unwrapped array element
+ */
+ protected Object unwrapArray(Object array, Object element)
+ {
+ TypeInfo elementType = configuration.getTypeInfo(array.getClass().getComponentType());
+ int subSize = Array.getLength(element);
+ Object newElement = newArrayInstance(elementType, subSize);
+ for(int i = 0; i < subSize; i++)
+ {
+ Object subElement = Array.get(element, i);
+ if (subElement instanceof MetaValue)
+ subElement = unwrapMetaValue((MetaValue)subElement, elementType, newElement);
+ if (subElement != null && subElement.getClass().isArray())
+ subElement = unwrapArray(newElement, subElement);
+
+ Array.set(newElement, i, subElement);
+ }
+ return newElement;
+ }
+
+ /**
+ * Unwrap composite.
+ *
+ * @param compositeValue the composite value
+ * @param typeInfo expected type info
+ * @return unwrapped value
+ */
+ @SuppressWarnings("deprecation")
+ protected Object unwrapComposite(CompositeValue compositeValue, TypeInfo typeInfo)
+ {
+ CompositeMetaType compositeMetaType = compositeValue.getMetaType();
+ String typeName = compositeMetaType.getTypeName();
+ ClassLoader cl;
+ if (typeInfo != null)
+ cl = typeInfo.getType().getClassLoader();
+ else
+ cl = Thread.currentThread().getContextClassLoader();
+
+ try
+ {
+ BeanInfo beanInfo = configuration.getBeanInfo(typeName, cl);
+ ClassInfo classInfo = beanInfo.getClassInfo();
+ if (classInfo.isInterface())
+ {
+ InvocationHandler handler = createCompositeValueInvocationHandler(compositeValue);
+ Class<?> clazz = classInfo.getType();
+ Class<?>[] interfaces = new Class[]{clazz};
+ return Proxy.newProxyInstance(clazz.getClassLoader(), interfaces, handler);
+ }
+ Object bean = createNewInstance(beanInfo);
+ for (String name : compositeMetaType.itemSet())
+ {
+ MetaValue itemValue = compositeValue.get(name);
+ PropertyInfo propertyInfo = beanInfo.getProperty(name);
+ Object value = unwrap(itemValue, propertyInfo.getType());
+ propertyInfo.set(bean, value);
+ }
+ return bean;
+ }
+ catch (Throwable t)
+ {
+ throw new UndeclaredThrowableException(t);
+ }
+ }
+
+ /**
+ * Create composite invocation handler.
+ *
+ * @param compositeValue the composite value
+ * @return composite invocation handler
+ */
+ protected InvocationHandler createCompositeValueInvocationHandler(CompositeValue compositeValue)
+ {
+ return new CompositeValueInvocationHandler(compositeValue);
+ }
+
+ /**
+ * Unwrap collection meta value.
+ *
+ * @param collectionValue the collection value
+ * @param type the type info
+ * @return unwrapped collection
+ */
+ @SuppressWarnings("unchecked")
+ protected Object unwrapCollection(CollectionValue collectionValue, TypeInfo type)
+ {
+ boolean trace = log.isTraceEnabled();
+ try
+ {
+ if (trace)
+ log.trace("unwrapCollection, type: "+type);
+ BeanInfo collectionInfo;
+ // null is not instance of
+ if (type instanceof ClassInfo)
+ {
+ collectionInfo = configuration.getBeanInfo(type);
+ }
+ else
+ {
+ MetaType metaType = collectionValue.getMetaType();
+ collectionInfo = configuration.getBeanInfo(metaType.getTypeName(), Thread.currentThread().getContextClassLoader());
+ }
+ ClassInfo classInfo = collectionInfo.getClassInfo();
+ Collection collection = (Collection)createNewInstance(collectionInfo);
+ Iterator<MetaValue> iter = collectionValue.iterator();
+ while (iter.hasNext())
+ {
+ MetaValue metaValue = iter.next();
+ TypeInfo componentType = classInfo.getComponentType();
+ if (trace)
+ log.trace("unwrapCollection, componentType: "+componentType);
+ // try better
+ if (OBJECT_TYPE_INFO.equals(componentType))
+ {
+ if (trace)
+ log.trace("unwrapCollection, value.metaType: "+metaValue.getMetaType());
+ componentType = getTypeInfo(metaValue.getMetaType(), null);
+ if (trace)
+ log.trace("unwrapCollection, componentType#2: "+componentType);
+ }
+ collection.add(unwrap(metaValue, componentType));
+ }
+ return collection;
+ }
+ catch (Throwable t)
+ {
+ throw new UndeclaredThrowableException(t);
+ }
+ }
+
+ /**
+ * Unwrap table meta value.
+ *
+ * @param tableValue the table value
+ * @param type the type info
+ * @return unwrapped table (map)
+ */
+ @SuppressWarnings("deprecation")
+ protected Object unwrapTable(TableValue tableValue, TypeInfo type)
+ {
+ if (type instanceof ParameterizedClassInfo)
+ {
+ ParameterizedClassInfo parameterizedType = (ParameterizedClassInfo)type;
+ ClassInfo rawType = parameterizedType.getRawType();
+ if (Map.class.isAssignableFrom(rawType.getType()))
+ {
+ TypeInfo keyType = parameterizedType.getActualTypeArguments()[0];
+ TypeInfo valueType = parameterizedType.getActualTypeArguments()[1];
+ return createMap(tableValue, keyType, valueType);
+ }
+ }
+ throw new UnsupportedOperationException("Insufficient information to unwrap table: " + tableValue + ", " + type);
+ }
+
+ /**
+ * Create a map
+ *
+ * @param tableValue the table value
+ * @param keyType the key type
+ * @param valueType the value type
+ * @return the map
+ */
+ protected Map<?,?> createMap(TableValue tableValue, TypeInfo keyType, TypeInfo valueType)
+ {
+ if (tableValue == null)
+ return null;
+
+ Map<Object, Object> result = new HashMap<Object, Object>();
+ Collection<CompositeValue> values = tableValue.values();
+ for (CompositeValue entry : values)
+ {
+ Object key = unwrap(entry.get(DefaultMetaTypeFactory.MAP_KEY), keyType);
+ Object val = unwrap(entry.get(DefaultMetaTypeFactory.MAP_VALUE), valueType);
+ result.put(key, val);
+ }
+ return result;
+ }
+
+ /**
+ * Create new instance.
+ *
+ * @param beanInfo the bean info
+ * @return new instance
+ * @throws Throwable for any error
+ */
+ @SuppressWarnings("deprecation")
+ protected Object createNewInstance(BeanInfo beanInfo) throws Throwable
+ {
+ ClassInfo classInfo = beanInfo.getClassInfo();
+ if (classInfo.isInterface())
+ {
+ InstanceFactory<?> instanceFactory = instanceFactoryMap.get(classInfo.getType());
+ if (instanceFactory == null)
+ throw new IllegalArgumentException("Cannot instantiate interface BeanInfo, missing InstanceFactory: " + classInfo);
+
+ return instanceFactory.instantiate(beanInfo);
+ }
+ return beanInfo.newInstance();
+ }
+
+ /**
+ * Get new array instance.
+ *
+ * @param typeInfo the type info
+ * @param size the size
+ * @return new array instance
+ */
+ protected Object newArrayInstance(TypeInfo typeInfo, int size)
+ {
+ if (typeInfo == null)
+ throw new IllegalArgumentException("Null type info.");
+
+ try
+ {
+ return typeInfo.newArrayInstance(size);
+ }
+ catch (Throwable t)
+ {
+ throw new UndeclaredThrowableException(t);
+ }
+ }
+
+ /**
+ * Get the class info from meta type.
+ *
+ * @param metaType the meta type
+ * @param value the value which can provide classloader
+ * @return type info
+ */
+ protected TypeInfo getTypeInfo(MetaType metaType, Object value)
+ {
+ if (metaType == null)
+ throw new IllegalArgumentException("Null meta type, cannot determine class name.");
+ if (value == null)
+ throw new IllegalArgumentException("Null value, cannot determine classloader.");
+
+ // get the classloader from the array we plan to fill
+ ClassLoader cl = value.getClass().getClassLoader();
+ return getTypeInfo(metaType, cl);
+ }
+
+ /**
+ * Get the class info from meta type.
+ *
+ * @param metaType the meta type
+ * @param cl the classloader
+ * @return class info
+ */
+ protected TypeInfo getTypeInfo(MetaType metaType, ClassLoader cl)
+ {
+ if (cl == null)
+ cl = Thread.currentThread().getContextClassLoader();
+
+ try
+ {
+ TypeInfoFactory tif = configuration.getTypeInfoFactory();
+ if (metaType.isArray())
+ {
+ ArrayMetaType arrayMetaType = (ArrayMetaType)metaType;
+ MetaType elementMetaType = arrayMetaType.getElementType();
+ String elementTypeName = elementMetaType.getTypeName();
+ if (arrayMetaType.isPrimitiveArray())
+ elementTypeName = ArrayMetaType.getPrimitiveName(elementTypeName);
+ TypeInfo elementTypeInfo = tif.getTypeInfo(elementTypeName, cl);
+ int dimension = arrayMetaType.getDimension() - 1; // minus 1, since we already use first in next line
+ TypeInfo typeInfo = elementTypeInfo.getArrayType();
+ while(dimension > 0)
+ {
+ typeInfo = typeInfo.getArrayType();
+ dimension--;
+ }
+ return typeInfo;
+ }
+ return tif.getTypeInfo(metaType.getTypeName(), cl);
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new UndeclaredThrowableException(e);
+ }
+ }
+
+ /**
+ * Create a meta value from the object
+ *
+ * @param value the value
+ * @param type the type
+ * @param metaType the metaType
+ * @return the meta value
+ */
+ @SuppressWarnings("unchecked")
+ protected MetaValue internalCreate(Object value, TypeInfo type, MetaType metaType)
+ {
+ if (value == null)
+ return null;
+
+ if (type == null)
+ type = configuration.getTypeInfo(value.getClass());
+
+ value = convertValue(value, type);
+
+ boolean start = false;
+ if (metaType == null)
+ {
+ start = true;
+ metaType = metaTypeFactory.resolve(type);
+ }
+
+ // For more complicated values we need to keep a mapping of objects to meta values
+ // this avoids duplicate meta value construction and recursion
+ Map<Object, MetaValue> mapping;
+ if (start)
+ {
+ // This is the start of the mapping
+ mapping = new HashMap<Object, MetaValue>();
+ mappingStack.get().push(mapping);
+ }
+ else
+ {
+ // Check the existing mapping
+ mapping = mappingStack.get().peek();
+ MetaValue result = mapping.get(value);
+ // Seen this before
+ if (result != null)
+ return result;
+ }
+
+ try
+ {
+ MetaValue result = isBuilder(metaType, type, value, mapping);
+
+ if (result == null)
+ {
+ MetaMapper<Object> mapper = (MetaMapper) MetaMapper.getMetaMapper(type);
+ if (mapper != null)
+ result = mapper.createMetaValue(metaType, value);
+ }
+
+ if (result == null)
+ {
+ if (metaType.isSimple())
+ result = createSimpleValue((SimpleMetaType) metaType, (Serializable) value);
+ else if (metaType.isEnum())
+ result = createEnumValue((EnumMetaType) metaType, (Enum<?>) value);
+ else if (metaType.isArray())
+ result = createArrayValue((ArrayMetaType) metaType, value, mapping);
+ else if (metaType.isComposite())
+ result = createCompositeValue((CompositeMetaType) metaType, value, mapping);
+ else if (metaType.isTable())
+ result = createTableValue((TableMetaType) metaType, (Map<?,?>) value, mapping);
+ else if (metaType.isGeneric())
+ result = createGenericValue((GenericMetaType) metaType, value, mapping);
+ else if (metaType.isCollection())
+ result = createCollectionValue((CollectionMetaType) metaType, value, mapping);
+ else
+ throw new IllegalStateException("Unknown metaType: " + metaType);
+ }
+ return result;
+ }
+ finally
+ {
+ // Remove the mapping from the stack
+ if (start)
+ mappingStack.get().pop();
+ }
+ }
+
+ /**
+ * Convert the value.
+ *
+ * @param value the value
+ * @param typeInfo type info
+ * @return converted value if type info not null
+ * @throws UndeclaredThrowableException for any error
+ */
+ protected Object convertValue(Object value, TypeInfo typeInfo)
+ {
+ try
+ {
+ return typeInfo != null ? typeInfo.convertValue(value) : value;
+ }
+ catch (Throwable t)
+ {
+ log.debug("convertValue failure("+t.getMessage()+"), value="+value.toString()
+ + ", value.class: "+value.getClass().getName()
+ + ", typeInfo: "+typeInfo.toString()
+ );
+ throw new UndeclaredThrowableException(t);
+ }
+ }
+
+ /**
+ * Check for a builder
+ *
+ * @param metaType the meta type
+ * @param type the type
+ * @param value the value
+ * @param mapping the mappings
+ * @return the meta value
+ */
+ @SuppressWarnings({"unchecked", "deprecation"})
+ protected MetaValue isBuilder(MetaType metaType, TypeInfo type, Object value, Map<Object, MetaValue> mapping)
+ {
+ MetaValueBuilder builder = null;
+ synchronized (builders)
+ {
+ WeakReference<MetaValueBuilder<?>> weak = builders.get(type.getType());
+ if (weak != null)
+ builder = weak.get();
+ }
+ if (builder == null)
+ return null;
+ MetaValue result = builder.buildMetaValue(metaType, value);
+ if (result != null)
+ mapping.put(value, result);
+
+ return result;
+ }
+}
Deleted: projects/jboss-man/tags/2.0.0.CR5/metatype/src/test/java/org/jboss/test/metatype/values/factory/test/UnwrapValueUnitTestCase.java
===================================================================
--- projects/jboss-man/branches/Branch_2_0/metatype/src/test/java/org/jboss/test/metatype/values/factory/test/UnwrapValueUnitTestCase.java 2008-11-19 16:43:01 UTC (rev 81300)
+++ projects/jboss-man/tags/2.0.0.CR5/metatype/src/test/java/org/jboss/test/metatype/values/factory/test/UnwrapValueUnitTestCase.java 2008-11-19 22:43:42 UTC (rev 81334)
@@ -1,396 +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.test.metatype.values.factory.test;
-
-import java.lang.reflect.Method;
-import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import junit.framework.Test;
-
-import org.jboss.metatype.api.values.MetaValue;
-import org.jboss.test.metatype.values.factory.support.SimpleCompositeInterface;
-import org.jboss.test.metatype.values.factory.support.TestEnum;
-import org.jboss.test.metatype.values.factory.support.TestGeneric;
-import org.jboss.test.metatype.values.factory.support.TestIgnoredCompositeItem;
-import org.jboss.test.metatype.values.factory.support.TestRecursiveSimpleComposite;
-import org.jboss.test.metatype.values.factory.support.TestRenamedCompositeItem;
-import org.jboss.test.metatype.values.factory.support.TestSimpleComposite;
-import org.jboss.test.metatype.values.factory.support.TestSimpleCompositeInterface;
-
-/**
- * UnwrapValueUnitTestCase.
- *
- * @author <a href="ales.justin at jboss.com">Ales Justin</a>
- */
-public class UnwrapValueUnitTestCase extends AbstractMetaValueFactoryTest
-{
- /**
- * Create a testsuite for this test
- *
- * @return the testsuite
- */
- public static Test suite()
- {
- return suite(UnwrapValueUnitTestCase.class);
- }
-
- /**
- * Create a new UnwrapValueUnitTestCase
- *
- * @param name the test name
- */
- public UnwrapValueUnitTestCase(String name)
- {
- super(name);
- }
-
- public void testSimpleUnwrap() throws Exception
- {
- checkSingle(123, true);
- checkSingle(123, false);
- checkSingle(new Date(), true);
- checkSingle(new Date(), false);
- }
-
- public void testEnumUnwrap() throws Exception
- {
- checkSingle(TestEnum.ONE, true);
- checkSingle(TestEnum.ONE, false);
- }
-
- public void testGenericUnwrap() throws Exception
- {
- checkSingle(new TestGeneric("123"), true);
- checkSingle(new TestGeneric("123"), false);
- }
-
- public void testCompositeUnwrap() throws Exception
- {
- TestSimpleComposite composite = new TestSimpleComposite("something");
- checkSingle(composite, true);
- checkSingle(composite, false);
-
- checkSingle(new TestRecursiveSimpleComposite("something", composite), true);
- checkSingle(new TestRecursiveSimpleComposite("something", composite), false);
-
- checkSingle(new TestSimpleCompositeInterface("something"), SimpleCompositeInterface.class);
- }
-
- public void testCollectionUnwrap() throws Exception
- {
- Integer i1 = 123;
- Integer i2 = 123;
- checkCollection(new ArrayList<Integer>(), i1, i2);
- checkCollection(new ArrayList<Integer>(), List.class, i1, i2);
- checkCollection(new ArrayList<Integer>(), getType("Integer", List.class), i1, i2);
- checkCollection(new HashSet<Integer>(), i1, i2);
- checkCollection(new HashSet<Integer>(), Set.class, i1, i2);
- checkCollection(new HashSet<Integer>(), getType("Integer", Set.class), i1, i2);
-
- TestEnum one = TestEnum.ONE;
- TestEnum two = TestEnum.TWO;
- TestEnum three = TestEnum.THREE;
- checkCollection(new ArrayList<TestEnum>(), one, two, three, one);
- checkCollection(new ArrayList<TestEnum>(), List.class, one, two, three, one);
- checkCollection(new ArrayList<TestEnum>(), getType("Enum", List.class), one, two, three, one);
- checkCollection(new HashSet<TestEnum>(), one, two, three, one);
- checkCollection(new HashSet<TestEnum>(), Set.class, one, two, three, one);
- checkCollection(new HashSet<TestEnum>(), getType("Enum", Set.class), one, two, three, one);
-
- TestGeneric g1 = new TestGeneric("123");
- TestGeneric g2 = new TestGeneric("123");
- checkCollection(new ArrayList<TestGeneric>(), g1, g2);
- checkCollection(new ArrayList<TestGeneric>(), List.class, g1, g2);
- checkCollection(new ArrayList<TestGeneric>(), getType("Generic", List.class), g1, g2);
- checkCollection(new HashSet<TestGeneric>(), g1, g2);
- checkCollection(new HashSet<TestGeneric>(), Set.class, g1, g2);
- checkCollection(new HashSet<TestGeneric>(), getType("Generic", Set.class), g1, g2);
-
- TestSimpleComposite c1 = new TestSimpleComposite("123");
- TestSimpleComposite c2 = new TestSimpleComposite("123");
- checkCollection(new ArrayList<TestSimpleComposite>(), c1, c2);
- checkCollection(new ArrayList<TestSimpleComposite>(), List.class, c1, c2);
- checkCollection(new ArrayList<TestSimpleComposite>(), getType("Composite", List.class), c1, c2);
- checkCollection(new HashSet<TestSimpleComposite>(), c1, c2);
- checkCollection(new HashSet<TestSimpleComposite>(), Set.class, c1, c2);
- checkCollection(new HashSet<TestSimpleComposite>(), getType("Composite", Set.class), c1, c2);
- }
-
- public void testArrayUnwrap() throws Exception
- {
- short[] shorts = new short[128];
- Double[] doubles = new Double[128];
- TestEnum[] enums = new TestEnum[128];
- TestGeneric[] generics = new TestGeneric[128];
- TestSimpleComposite[] composits = new TestSimpleComposite[128];
- TestRecursiveSimpleComposite[] recursiveComposites = new TestRecursiveSimpleComposite[128];
- Integer[][] integers = new Integer[128][128];
- Integer[][][] triple = new Integer[10][10][10];
- for(int i = 0; i < 128; i++)
- {
- shorts[i] = (short)i;
- doubles[i] = i / Math.PI;
- enums[i] = TestEnum.values()[i % 3];
- generics[i] = new TestGeneric("#" + i);
- composits[i] = new TestSimpleComposite("#" + i);
- recursiveComposites[i] = new TestRecursiveSimpleComposite("#" + i, composits[i]);
- for(int j = 0; j < 128; j++)
- {
- integers[i][j] = 128 * i + j;
- for(int k = 0; k < 128; k++)
- triple[i % 10][j % 10][k % 10] = (100 * i + 10 * j + k) % 1000;
- }
- }
-
- checkArray(shorts, true, new Asserter()
- {
- public boolean assertArray(final Object original, final Object unwrapped)
- {
- return Arrays.equals((short[])original, (short[])unwrapped);
- }
- });
- checkArray(shorts, false, new Asserter()
- {
- public boolean assertArray(final Object original, final Object unwrapped)
- {
- return Arrays.equals((short[])original, (short[])unwrapped);
- }
- });
-
- checkArray(doubles, true, new Asserter()
- {
- public boolean assertArray(final Object original, final Object unwrapped)
- {
- return Arrays.equals((Double[])original, (Double[])unwrapped);
- }
- });
- checkArray(doubles, false, new Asserter()
- {
- public boolean assertArray(final Object original, final Object unwrapped)
- {
- return Arrays.equals((Double[])original, (Double[])unwrapped);
- }
- });
-
- Asserter objectsAsserter = new Asserter()
- {
- public boolean assertArray(final Object original, final Object unwrapped)
- {
- return Arrays.equals((Object[])original, (Object[])unwrapped);
- }
- };
-
- checkArray(enums, true, objectsAsserter);
- checkArray(enums, false, objectsAsserter);
-
- checkArray(generics, true, objectsAsserter);
- checkArray(generics, false, objectsAsserter);
-
- checkArray(composits, true, objectsAsserter);
- checkArray(composits, false, objectsAsserter);
-
- checkArray(recursiveComposites, true, objectsAsserter);
- checkArray(recursiveComposites, false, objectsAsserter);
-
- Asserter integersAsserter = new Asserter()
- {
- public boolean assertArray(final Object original, final Object unwrapped)
- {
- Integer[][] first = (Integer[][])original;
- Integer[][] second = (Integer[][])unwrapped;
- for (int i = 0; i < first.length; i++)
- for (int j = 0; j < first[0].length; j++)
- if (first[i][j].equals(second[i][j]) == false)
- return false;
- return true;
- }
- };
- checkArray(integers, true, integersAsserter);
- checkArray(integers, false, integersAsserter);
-
- Asserter tripleAsserter = new Asserter()
- {
- public boolean assertArray(final Object original, final Object unwrapped)
- {
- Integer[][][] first = (Integer[][][])original;
- Integer[][][] second = (Integer[][][])unwrapped;
- for (int i = 0; i < first.length; i++)
- for (int j = 0; j < first[0].length; j++)
- for (int k = 0; k < first[0][0].length; k++)
- if (first[i][j][k].equals(second[i][j][k]) == false)
- return false;
- return true;
- }
- };
- checkArray(triple, true, tripleAsserter);
- checkArray(triple, false, tripleAsserter);
- }
-
- public void testTableUnwrap() throws Exception
- {
- Method method = getClass().getMethod("compositeValueMap");
- Type mapType = method.getGenericReturnType();
-
- Map<Integer, String> map = new HashMap<Integer, String>();
- map.put(123, "123");
- checkSingle(map, mapType);
- }
-
- public void testIgnoreItemUnwrap()
- {
- TestIgnoredCompositeItem ignored = new TestIgnoredCompositeItem();
- ignored.setId("Id");
- ignored.setIgnored("Ignored?");
-
- MetaValue metaValue = createMetaValue(ignored);
- assertNotNull(metaValue);
- Object unwrapped = unwrapMetaValue(metaValue, TestIgnoredCompositeItem.class);
- TestIgnoredCompositeItem result = assertInstanceOf(unwrapped, TestIgnoredCompositeItem.class);
- assertEquals("Id", result.getId());
- assertNull(result.getIgnored());
- }
-
- public void testRenamedItemUnwrap()
- {
- TestRenamedCompositeItem renamedCompositeItem = new TestRenamedCompositeItem();
- renamedCompositeItem.setId("Id");
- renamedCompositeItem.setValue("Renamed");
-
- MetaValue metaValue = createMetaValue(renamedCompositeItem);
- assertNotNull(metaValue);
- Object unwrapped = unwrapMetaValue(metaValue, TestRenamedCompositeItem.class);
- TestRenamedCompositeItem result = assertInstanceOf(unwrapped, TestRenamedCompositeItem.class);
- assertEquals("Id", result.getId());
- assertEquals("Renamed", result.getValue());
- }
-
- public Map<Integer, String> compositeValueMap()
- {
- return null;
- }
-
- protected void checkSingle(Object object, boolean typeInfoFromObject)
- {
- MetaValue metaValue = createMetaValue(object);
- assertNotNull(metaValue);
- Object unwrapped;
- if (typeInfoFromObject)
- unwrapped = unwrapMetaValue(metaValue, object.getClass());
- else
- unwrapped = unwrapMetaValue(metaValue);
- assertEquals(object, unwrapped);
- }
-
- protected void checkSingle(Object object, Type type)
- {
- MetaValue metaValue = createMetaValue(object, type);
- assertNotNull(metaValue);
- Object unwrapped = unwrapMetaValue(metaValue, type);
- assertEquals(object, unwrapped);
- }
-
- protected <T> void checkCollection(Collection<T> collection, T... params) throws Exception
- {
- collection.addAll(Arrays.asList(params));
- checkSingle(collection, true);
- checkSingle(collection, false);
- }
-
- protected <T> void checkCollection(Collection<T> collection, Type type, T... params) throws Exception
- {
- collection.addAll(Arrays.asList(params));
- checkSingle(collection, type);
- }
-
- protected void checkArray(Object object, boolean typeInfoFromObject, Asserter asserter)
- {
- MetaValue metaValue = createMetaValue(object);
- assertNotNull(metaValue);
- Object unwrapped;
- if (typeInfoFromObject)
- unwrapped = unwrapMetaValue(metaValue, object.getClass());
- else
- unwrapped = unwrapMetaValue(metaValue);
- assertTrue("Different arrays.", asserter.assertArray(object, unwrapped));
- }
-
- private interface Asserter
- {
- boolean assertArray(final Object original, final Object unwrapped);
- }
-
- @SuppressWarnings("unchecked")
- protected Type getType(String type, Class<? extends Collection> clazz) throws Exception
- {
- Method method = getClass().getDeclaredMethod("get" + type + "s" + clazz.getSimpleName());
- return method.getGenericReturnType();
- }
-
- public List<Integer> getIntegersList()
- {
- return null;
- }
-
- public List<TestEnum> getEnumsList()
- {
- return null;
- }
-
- public List<TestGeneric> getGenericsList()
- {
- return null;
- }
-
- public List<TestSimpleComposite> getCompositesList()
- {
- return null;
- }
-
- public Set<Integer> getIntegersSet()
- {
- return null;
- }
-
- public Set<TestEnum> getEnumsSet()
- {
- return null;
- }
-
- public Set<TestGeneric> getGenericsSet()
- {
- return null;
- }
-
- public Set<TestSimpleComposite> getCompositesSet()
- {
- return null;
- }
-}
Copied: projects/jboss-man/tags/2.0.0.CR5/metatype/src/test/java/org/jboss/test/metatype/values/factory/test/UnwrapValueUnitTestCase.java (from rev 81328, projects/jboss-man/branches/Branch_2_0/metatype/src/test/java/org/jboss/test/metatype/values/factory/test/UnwrapValueUnitTestCase.java)
===================================================================
--- projects/jboss-man/tags/2.0.0.CR5/metatype/src/test/java/org/jboss/test/metatype/values/factory/test/UnwrapValueUnitTestCase.java (rev 0)
+++ projects/jboss-man/tags/2.0.0.CR5/metatype/src/test/java/org/jboss/test/metatype/values/factory/test/UnwrapValueUnitTestCase.java 2008-11-19 22:43:42 UTC (rev 81334)
@@ -0,0 +1,399 @@
+/*
+* 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.test.metatype.values.factory.test;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import junit.framework.Test;
+
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.test.metatype.values.factory.support.SimpleCompositeInterface;
+import org.jboss.test.metatype.values.factory.support.TestEnum;
+import org.jboss.test.metatype.values.factory.support.TestGeneric;
+import org.jboss.test.metatype.values.factory.support.TestIgnoredCompositeItem;
+import org.jboss.test.metatype.values.factory.support.TestRecursiveSimpleComposite;
+import org.jboss.test.metatype.values.factory.support.TestRenamedCompositeItem;
+import org.jboss.test.metatype.values.factory.support.TestSimpleComposite;
+import org.jboss.test.metatype.values.factory.support.TestSimpleCompositeInterface;
+
+/**
+ * UnwrapValueUnitTestCase.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class UnwrapValueUnitTestCase extends AbstractMetaValueFactoryTest
+{
+ /**
+ * Create a testsuite for this test
+ *
+ * @return the testsuite
+ */
+ public static Test suite()
+ {
+ return suite(UnwrapValueUnitTestCase.class);
+ }
+
+ /**
+ * Create a new UnwrapValueUnitTestCase
+ *
+ * @param name the test name
+ */
+ public UnwrapValueUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testSimpleUnwrap() throws Exception
+ {
+ checkSingle(123, true);
+ checkSingle(123, false);
+ checkSingle(new Date(), true);
+ checkSingle(new Date(), false);
+ }
+
+ public void testEnumUnwrap() throws Exception
+ {
+ checkSingle(TestEnum.ONE, true);
+ checkSingle(TestEnum.ONE, false);
+ }
+
+ public void testGenericUnwrap() throws Exception
+ {
+ checkSingle(new TestGeneric("123"), true);
+ checkSingle(new TestGeneric("123"), false);
+ }
+
+ public void testCompositeUnwrap() throws Exception
+ {
+ TestSimpleComposite composite = new TestSimpleComposite("something");
+ checkSingle(composite, true);
+ checkSingle(composite, false);
+
+ checkSingle(new TestRecursiveSimpleComposite("something", composite), true);
+ checkSingle(new TestRecursiveSimpleComposite("something", composite), false);
+
+ checkSingle(new TestSimpleCompositeInterface("something"), SimpleCompositeInterface.class);
+ }
+
+ public void testCollectionUnwrap() throws Exception
+ {
+ Integer i1 = 123;
+ Integer i2 = 123;
+ checkCollection(new ArrayList<Integer>(), i1, i2);
+ checkCollection(new ArrayList<Integer>(), List.class, i1, i2);
+ checkCollection(new ArrayList<Integer>(), getType("Integer", List.class), i1, i2);
+ checkCollection(new HashSet<Integer>(), i1, i2);
+ checkCollection(new HashSet<Integer>(), Set.class, i1, i2);
+ checkCollection(new HashSet<Integer>(), getType("Integer", Set.class), i1, i2);
+
+ TestEnum one = TestEnum.ONE;
+ TestEnum two = TestEnum.TWO;
+ TestEnum three = TestEnum.THREE;
+ checkCollection(new ArrayList<TestEnum>(), one, two, three, one);
+ checkCollection(new ArrayList<TestEnum>(), List.class, one, two, three, one);
+ checkCollection(new ArrayList<TestEnum>(), getType("Enum", List.class), one, two, three, one);
+ checkCollection(new HashSet<TestEnum>(), one, two, three, one);
+ checkCollection(new HashSet<TestEnum>(), Set.class, one, two, three, one);
+ checkCollection(new HashSet<TestEnum>(), getType("Enum", Set.class), one, two, three, one);
+
+ TestGeneric g1 = new TestGeneric("123");
+ TestGeneric g2 = new TestGeneric("123");
+ checkCollection(new ArrayList<TestGeneric>(), g1, g2);
+ checkCollection(new ArrayList<TestGeneric>(), List.class, g1, g2);
+ checkCollection(new ArrayList<TestGeneric>(), getType("Generic", List.class), g1, g2);
+ checkCollection(new HashSet<TestGeneric>(), g1, g2);
+ checkCollection(new HashSet<TestGeneric>(), Set.class, g1, g2);
+ checkCollection(new HashSet<TestGeneric>(), getType("Generic", Set.class), g1, g2);
+
+ TestSimpleComposite c1 = new TestSimpleComposite("123");
+ TestSimpleComposite c2 = new TestSimpleComposite("123");
+ checkCollection(new ArrayList<TestSimpleComposite>(), c1, c2);
+ checkCollection(new ArrayList<TestSimpleComposite>(), List.class, c1, c2);
+ checkCollection(new ArrayList<TestSimpleComposite>(), getType("Composite", List.class), c1, c2);
+ checkCollection(new HashSet<TestSimpleComposite>(), c1, c2);
+ checkCollection(new HashSet<TestSimpleComposite>(), Set.class, c1, c2);
+ checkCollection(new HashSet<TestSimpleComposite>(), getType("Composite", Set.class), c1, c2);
+ }
+
+ public void testArrayUnwrap() throws Exception
+ {
+ short[] shorts = new short[128];
+ Double[] doubles = new Double[128];
+ TestEnum[] enums = new TestEnum[128];
+ TestGeneric[] generics = new TestGeneric[128];
+ TestSimpleComposite[] composits = new TestSimpleComposite[128];
+ TestRecursiveSimpleComposite[] recursiveComposites = new TestRecursiveSimpleComposite[128];
+ Integer[][] integers = new Integer[128][128];
+ Integer[][][] triple = new Integer[10][10][10];
+ for(int i = 0; i < 128; i++)
+ {
+ shorts[i] = (short)i;
+ doubles[i] = i / Math.PI;
+ enums[i] = TestEnum.values()[i % 3];
+ generics[i] = new TestGeneric("#" + i);
+ composits[i] = new TestSimpleComposite("#" + i);
+ recursiveComposites[i] = new TestRecursiveSimpleComposite("#" + i, composits[i]);
+ for(int j = 0; j < 128; j++)
+ {
+ integers[i][j] = 128 * i + j;
+ for(int k = 0; k < 128; k++)
+ triple[i % 10][j % 10][k % 10] = (100 * i + 10 * j + k) % 1000;
+ }
+ }
+
+ checkArray(shorts, true, new Asserter()
+ {
+ public boolean assertArray(final Object original, final Object unwrapped)
+ {
+ return Arrays.equals((short[])original, (short[])unwrapped);
+ }
+ });
+ checkArray(shorts, false, new Asserter()
+ {
+ public boolean assertArray(final Object original, final Object unwrapped)
+ {
+ return Arrays.equals((short[])original, (short[])unwrapped);
+ }
+ });
+
+ checkArray(doubles, true, new Asserter()
+ {
+ public boolean assertArray(final Object original, final Object unwrapped)
+ {
+ return Arrays.equals((Double[])original, (Double[])unwrapped);
+ }
+ });
+ checkArray(doubles, false, new Asserter()
+ {
+ public boolean assertArray(final Object original, final Object unwrapped)
+ {
+ return Arrays.equals((Double[])original, (Double[])unwrapped);
+ }
+ });
+
+ Asserter objectsAsserter = new Asserter()
+ {
+ public boolean assertArray(final Object original, final Object unwrapped)
+ {
+ return Arrays.equals((Object[])original, (Object[])unwrapped);
+ }
+ };
+
+ checkArray(enums, true, objectsAsserter);
+ checkArray(enums, false, objectsAsserter);
+
+ checkArray(generics, true, objectsAsserter);
+ checkArray(generics, false, objectsAsserter);
+
+ checkArray(composits, true, objectsAsserter);
+ checkArray(composits, false, objectsAsserter);
+
+ checkArray(recursiveComposites, true, objectsAsserter);
+ checkArray(recursiveComposites, false, objectsAsserter);
+
+ Asserter integersAsserter = new Asserter()
+ {
+ public boolean assertArray(final Object original, final Object unwrapped)
+ {
+ Integer[][] first = (Integer[][])original;
+ Integer[][] second = (Integer[][])unwrapped;
+ for (int i = 0; i < first.length; i++)
+ for (int j = 0; j < first[0].length; j++)
+ if (first[i][j].equals(second[i][j]) == false)
+ return false;
+ return true;
+ }
+ };
+ checkArray(integers, true, integersAsserter);
+ checkArray(integers, false, integersAsserter);
+
+ Asserter tripleAsserter = new Asserter()
+ {
+ public boolean assertArray(final Object original, final Object unwrapped)
+ {
+ Integer[][][] first = (Integer[][][])original;
+ Integer[][][] second = (Integer[][][])unwrapped;
+ for (int i = 0; i < first.length; i++)
+ for (int j = 0; j < first[0].length; j++)
+ for (int k = 0; k < first[0][0].length; k++)
+ if (first[i][j][k].equals(second[i][j][k]) == false)
+ return false;
+ return true;
+ }
+ };
+ checkArray(triple, true, tripleAsserter);
+ checkArray(triple, false, tripleAsserter);
+ }
+
+ public void testTableUnwrap() throws Exception
+ {
+ Method method = getClass().getMethod("compositeValueMap");
+ Type mapType = method.getGenericReturnType();
+
+ Map<Integer, String> map = new HashMap<Integer, String>();
+ map.put(123, "123");
+ checkSingle(map, mapType);
+ }
+
+ public void testIgnoreItemUnwrap()
+ {
+ TestIgnoredCompositeItem ignored = new TestIgnoredCompositeItem();
+ ignored.setId("Id");
+ ignored.setIgnored("Ignored?");
+
+ MetaValue metaValue = createMetaValue(ignored);
+ assertNotNull(metaValue);
+ Object unwrapped = unwrapMetaValue(metaValue, TestIgnoredCompositeItem.class);
+ TestIgnoredCompositeItem result = assertInstanceOf(unwrapped, TestIgnoredCompositeItem.class);
+ assertEquals("Id", result.getId());
+ assertNull(result.getIgnored());
+ }
+
+ public void testRenamedItemUnwrap()
+ {
+ TestRenamedCompositeItem renamedCompositeItem = new TestRenamedCompositeItem();
+ renamedCompositeItem.setId("Id");
+ renamedCompositeItem.setValue("Renamed");
+
+ MetaValue metaValue = createMetaValue(renamedCompositeItem);
+ assertNotNull(metaValue);
+ Object unwrapped = unwrapMetaValue(metaValue, TestRenamedCompositeItem.class);
+ TestRenamedCompositeItem result = assertInstanceOf(unwrapped, TestRenamedCompositeItem.class);
+ assertEquals("Id", result.getId());
+ assertEquals("Renamed", result.getValue());
+ }
+
+ public Map<Integer, String> compositeValueMap()
+ {
+ return null;
+ }
+
+ protected void checkSingle(Object object, boolean typeInfoFromObject)
+ {
+ MetaValue metaValue = createMetaValue(object);
+ assertNotNull(metaValue);
+ Object unwrapped;
+ if (typeInfoFromObject)
+ unwrapped = unwrapMetaValue(metaValue, object.getClass());
+ else
+ unwrapped = unwrapMetaValue(metaValue);
+ assertEquals(object, unwrapped);
+ }
+
+ protected void checkSingle(Object object, Type type)
+ {
+ MetaValue metaValue = createMetaValue(object, type);
+ assertNotNull(metaValue);
+ Object unwrapped = unwrapMetaValue(metaValue, type);
+ assertEquals(object, unwrapped);
+ }
+
+ protected <T> void checkCollection(Collection<T> collection, T... params) throws Exception
+ {
+ collection.addAll(Arrays.asList(params));
+ checkSingle(collection, true);
+ checkSingle(collection, false);
+ }
+
+ protected <T> void checkCollection(Collection<T> collection, Type type, T... params) throws Exception
+ {
+ collection.addAll(Arrays.asList(params));
+ checkSingle(collection, type);
+ }
+
+ protected void checkArray(Object object, boolean typeInfoFromObject, Asserter asserter)
+ {
+ MetaValue metaValue = createMetaValue(object);
+ assertNotNull(metaValue);
+ Object unwrapped;
+ if (typeInfoFromObject)
+ unwrapped = unwrapMetaValue(metaValue, object.getClass());
+ else
+ unwrapped = unwrapMetaValue(metaValue);
+ assertTrue("Different arrays.", asserter.assertArray(object, unwrapped));
+ }
+
+ private interface Asserter
+ {
+ boolean assertArray(final Object original, final Object unwrapped);
+ }
+
+ @SuppressWarnings("unchecked")
+ protected Type getType(String type, Class<? extends Collection> clazz) throws Exception
+ {
+ String methodName = "get" + type + "s" + clazz.getSimpleName();
+ Method method = getClass().getDeclaredMethod(methodName);
+ Type gtype = method.getGenericReturnType();
+ getLog().debug("getType(type="+type+", clazz="+clazz+" : "+gtype);
+ return gtype;
+ }
+
+ public List<Integer> getIntegersList()
+ {
+ return null;
+ }
+
+ public List<TestEnum> getEnumsList()
+ {
+ return null;
+ }
+
+ public List<TestGeneric> getGenericsList()
+ {
+ return null;
+ }
+
+ public List<TestSimpleComposite> getCompositesList()
+ {
+ return null;
+ }
+
+ public Set<Integer> getIntegersSet()
+ {
+ return null;
+ }
+
+ public Set<TestEnum> getEnumsSet()
+ {
+ return null;
+ }
+
+ public Set<TestGeneric> getGenericsSet()
+ {
+ return null;
+ }
+
+ public Set<TestSimpleComposite> getCompositesSet()
+ {
+ return null;
+ }
+}
Deleted: projects/jboss-man/tags/2.0.0.CR5/pom.xml
===================================================================
--- projects/jboss-man/branches/Branch_2_0/pom.xml 2008-11-19 16:43:01 UTC (rev 81300)
+++ projects/jboss-man/tags/2.0.0.CR5/pom.xml 2008-11-19 22:43:42 UTC (rev 81334)
@@ -1,264 +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</artifactId>
- <version>2.0.0-SNAPSHOT</version>
- <packaging>pom</packaging>
- <name>JBoss Managed Parent POM</name>
- <url>http://www.jboss.com/products/jbossmc</url>
- <description>JBoss Managed Parent POM</description>
- <scm>
- <connection>scm:svn:https://svn.jboss.org/repos/jbossas/projects/jboss-man/tags/Branch_2_0</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/jbossas/projects/jboss-man/branches/Branch_2_0</developerConnection>
- <url>https://svn.jboss.org/repos/jbossas/projects/jboss-man/tags/Branch_2_0</url>
- </scm>
-
- <properties>
- <version.jboss.common.core>2.2.8.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.0.CR1</version.org.jboss.reflect>
- <version.org.jboss.mdr>2.0.0.GA</version.org.jboss.mdr>
- <version.org.jboss.test>1.1.1.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>
- <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>
- </execution>
- </executions>
- </plugin>
- <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.1</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.0.0.CR5/pom.xml (from rev 81333, projects/jboss-man/branches/Branch_2_0/pom.xml)
===================================================================
--- projects/jboss-man/tags/2.0.0.CR5/pom.xml (rev 0)
+++ projects/jboss-man/tags/2.0.0.CR5/pom.xml 2008-11-19 22:43:42 UTC (rev 81334)
@@ -0,0 +1,264 @@
+<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</artifactId>
+ <version>2.0.0.CR5</version>
+ <packaging>pom</packaging>
+ <name>JBoss Managed Parent POM</name>
+ <url>http://www.jboss.com/products/jbossmc</url>
+ <description>JBoss Managed Parent POM</description>
+ <scm>
+ <connection>scm:svn:https://svn.jboss.org/repos/jbossas/projects/jboss-man/tags/2.0.0.CR5</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/jbossas/projects/jboss-man/tags/2.0.0.CR5</developerConnection>
+ <url>scm:svn:https://svn.jboss.org/repos/jbossas/projects/jboss-man/tags/2.0.0.CR5</url>
+ </scm>
+
+ <properties>
+ <version.jboss.common.core>2.2.8.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.0.CR1</version.org.jboss.reflect>
+ <version.org.jboss.mdr>2.0.0.GA</version.org.jboss.mdr>
+ <version.org.jboss.test>1.1.1.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>
+ <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>
+ </execution>
+ </executions>
+ </plugin>
+ <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.1</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