[jboss-cvs] JBossAS SVN: r87526 - in projects/jboss-man/tags: 2.1.0.CR8 and 14 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sat Apr 18 22:32:29 EDT 2009
Author: scott.stark at jboss.org
Date: 2009-04-18 22:32:29 -0400 (Sat, 18 Apr 2009)
New Revision: 87526
Added:
projects/jboss-man/tags/2.1.0.CR8/
projects/jboss-man/tags/2.1.0.CR8/build/pom.xml
projects/jboss-man/tags/2.1.0.CR8/managed/pom.xml
projects/jboss-man/tags/2.1.0.CR8/managed/src/main/java/org/jboss/managed/api/Fields.java
projects/jboss-man/tags/2.1.0.CR8/managed/src/main/java/org/jboss/managed/api/ManagedProperty.java
projects/jboss-man/tags/2.1.0.CR8/managed/src/main/java/org/jboss/managed/api/annotation/DefaultValueBuilderFactory.java
projects/jboss-man/tags/2.1.0.CR8/managed/src/main/java/org/jboss/managed/api/annotation/ManagementProperty.java
projects/jboss-man/tags/2.1.0.CR8/managed/src/main/java/org/jboss/managed/plugins/ManagedPropertyImpl.java
projects/jboss-man/tags/2.1.0.CR8/managed/src/main/java/org/jboss/managed/plugins/factory/AbstractManagedObjectFactory.java
projects/jboss-man/tags/2.1.0.CR8/managed/src/test/java/org/jboss/test/managed/factory/support/ConstrainedBean.java
projects/jboss-man/tags/2.1.0.CR8/managed/src/test/java/org/jboss/test/managed/factory/support/defaults/
projects/jboss-man/tags/2.1.0.CR8/managed/src/test/java/org/jboss/test/managed/factory/test/PropertyDefaultsUnitTestCase.java
projects/jboss-man/tags/2.1.0.CR8/metatype/pom.xml
projects/jboss-man/tags/2.1.0.CR8/metatype/src/main/java/org/jboss/metatype/api/types/PropertiesMetaType.java
projects/jboss-man/tags/2.1.0.CR8/metatype/src/main/java/org/jboss/metatype/api/values/PropertiesMetaValue.java
projects/jboss-man/tags/2.1.0.CR8/metatype/src/main/java/org/jboss/metatype/api/values/SimpleValueSupport.java
projects/jboss-man/tags/2.1.0.CR8/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults/
projects/jboss-man/tags/2.1.0.CR8/metatype/src/main/java/org/jboss/metatype/plugins/values/mappers/PropertiesCompositeObjectNameMetaMapper.java
projects/jboss-man/tags/2.1.0.CR8/metatype/src/main/java/org/jboss/metatype/plugins/values/mappers/PropertiesMetaMapper.java
projects/jboss-man/tags/2.1.0.CR8/metatype/src/main/java/org/jboss/metatype/spi/values/DefaultValueBuilder.java
projects/jboss-man/tags/2.1.0.CR8/pom.xml
Removed:
projects/jboss-man/tags/2.1.0.CR8/build/pom.xml
projects/jboss-man/tags/2.1.0.CR8/managed/pom.xml
projects/jboss-man/tags/2.1.0.CR8/managed/src/main/java/org/jboss/managed/api/Fields.java
projects/jboss-man/tags/2.1.0.CR8/managed/src/main/java/org/jboss/managed/api/ManagedProperty.java
projects/jboss-man/tags/2.1.0.CR8/managed/src/main/java/org/jboss/managed/api/annotation/ManagementProperty.java
projects/jboss-man/tags/2.1.0.CR8/managed/src/main/java/org/jboss/managed/plugins/ManagedPropertyImpl.java
projects/jboss-man/tags/2.1.0.CR8/managed/src/main/java/org/jboss/managed/plugins/factory/AbstractManagedObjectFactory.java
projects/jboss-man/tags/2.1.0.CR8/managed/src/test/java/org/jboss/test/managed/factory/support/ConstrainedBean.java
projects/jboss-man/tags/2.1.0.CR8/metatype/pom.xml
projects/jboss-man/tags/2.1.0.CR8/metatype/src/main/java/org/jboss/metatype/api/types/PropertiesMetaType.java
projects/jboss-man/tags/2.1.0.CR8/metatype/src/main/java/org/jboss/metatype/api/values/PropertiesMetaValue.java
projects/jboss-man/tags/2.1.0.CR8/metatype/src/main/java/org/jboss/metatype/api/values/SimpleValueSupport.java
projects/jboss-man/tags/2.1.0.CR8/metatype/src/main/java/org/jboss/metatype/plugins/values/mappers/PropertiesCompositeObjectNameMetaMapper.java
projects/jboss-man/tags/2.1.0.CR8/pom.xml
Log:
[maven-release-plugin] copy for tag 2.1.0.CR8
Copied: projects/jboss-man/tags/2.1.0.CR8 (from rev 87523, projects/jboss-man/branches/Branch_2_1)
Deleted: projects/jboss-man/tags/2.1.0.CR8/build/pom.xml
===================================================================
--- projects/jboss-man/branches/Branch_2_1/build/pom.xml 2009-04-19 02:19:21 UTC (rev 87523)
+++ projects/jboss-man/tags/2.1.0.CR8/build/pom.xml 2009-04-19 02:32:29 UTC (rev 87526)
@@ -1,54 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>org.jboss.man</groupId>
- <artifactId>jboss-man-parent</artifactId>
- <version>2.1.0-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.jboss.man</groupId>
- <artifactId>jboss-man</artifactId>
- <version>2.1.0-SNAPSHOT</version>
- <packaging>pom</packaging>
- <name>JBoss Managed Distribution</name>
- <url>http://www.jboss.org/jbossmc</url>
- <description>JBoss Managed Distribution Build</description>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-assembly-plugin</artifactId>
- <version>2.2-beta-2</version>
- <executions>
- <execution>
- <id>make-assembly</id>
- <phase>package</phase>
- <goals>
- <goal>attached</goal>
- </goals>
- <configuration>
- <finalName>jboss-man-${project.version}</finalName>
- <descriptors>
- <descriptor>src/assembly/dist.xml</descriptor>
- <descriptor>src/assembly/dist-with-deps.xml</descriptor>
- <descriptor>src/assembly/src.xml</descriptor>
- </descriptors>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
- <dependency>
- <groupId>org.jboss.man</groupId>
- <artifactId>jboss-managed</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.man</groupId>
- <artifactId>jboss-metatype</artifactId>
- </dependency>
- </dependencies>
-
-</project>
Copied: projects/jboss-man/tags/2.1.0.CR8/build/pom.xml (from rev 87525, projects/jboss-man/branches/Branch_2_1/build/pom.xml)
===================================================================
--- projects/jboss-man/tags/2.1.0.CR8/build/pom.xml (rev 0)
+++ projects/jboss-man/tags/2.1.0.CR8/build/pom.xml 2009-04-19 02:32:29 UTC (rev 87526)
@@ -0,0 +1,54 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.jboss.man</groupId>
+ <artifactId>jboss-man-parent</artifactId>
+ <version>2.1.0.CR8</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.jboss.man</groupId>
+ <artifactId>jboss-man</artifactId>
+ <version>2.1.0.CR8</version>
+ <packaging>pom</packaging>
+ <name>JBoss Managed Distribution</name>
+ <url>http://www.jboss.org/jbossmc</url>
+ <description>JBoss Managed Distribution Build</description>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <version>2.2-beta-2</version>
+ <executions>
+ <execution>
+ <id>make-assembly</id>
+ <phase>package</phase>
+ <goals>
+ <goal>attached</goal>
+ </goals>
+ <configuration>
+ <finalName>jboss-man-${project.version}</finalName>
+ <descriptors>
+ <descriptor>src/assembly/dist.xml</descriptor>
+ <descriptor>src/assembly/dist-with-deps.xml</descriptor>
+ <descriptor>src/assembly/src.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.man</groupId>
+ <artifactId>jboss-managed</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.man</groupId>
+ <artifactId>jboss-metatype</artifactId>
+ </dependency>
+ </dependencies>
+
+</project>
Deleted: projects/jboss-man/tags/2.1.0.CR8/managed/pom.xml
===================================================================
--- projects/jboss-man/branches/Branch_2_1/managed/pom.xml 2009-04-19 02:19:21 UTC (rev 87523)
+++ projects/jboss-man/tags/2.1.0.CR8/managed/pom.xml 2009-04-19 02:32:29 UTC (rev 87526)
@@ -1,66 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>org.jboss.man</groupId>
- <artifactId>jboss-man-parent</artifactId>
- <version>2.1.0-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <artifactId>jboss-managed</artifactId>
- <packaging>jar</packaging>
- <name>JBoss Managed</name>
- <url>http://www.jboss.org/jbossmc</url>
- <description>JBoss Managed</description>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-assembly-plugin</artifactId>
- <configuration>
- <descriptors>
- <descriptor>src/assembly/api.xml</descriptor>
- <descriptor>src/assembly/plugins.xml</descriptor>
- </descriptors>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- <!-- Do not add version information here, use ../pom.xml instead -->
- <dependencies>
- <!-- Global dependencies -->
- <dependency>
- <groupId>org.jboss.man</groupId>
- <artifactId>jboss-metatype</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss</groupId>
- <artifactId>jboss-mdr</artifactId>
- </dependency>
- <!-- Test dependencies -->
- <dependency>
- <groupId>sun-jaxb</groupId>
- <artifactId>jaxb-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.logging</groupId>
- <artifactId>jboss-logging-log4j</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.test</groupId>
- <artifactId>jboss-test</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>javassist</groupId>
- <artifactId>javassist</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-</project>
\ No newline at end of file
Copied: projects/jboss-man/tags/2.1.0.CR8/managed/pom.xml (from rev 87525, projects/jboss-man/branches/Branch_2_1/managed/pom.xml)
===================================================================
--- projects/jboss-man/tags/2.1.0.CR8/managed/pom.xml (rev 0)
+++ projects/jboss-man/tags/2.1.0.CR8/managed/pom.xml 2009-04-19 02:32:29 UTC (rev 87526)
@@ -0,0 +1,66 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.jboss.man</groupId>
+ <artifactId>jboss-man-parent</artifactId>
+ <version>2.1.0.CR8</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>jboss-managed</artifactId>
+ <packaging>jar</packaging>
+ <name>JBoss Managed</name>
+ <url>http://www.jboss.org/jbossmc</url>
+ <description>JBoss Managed</description>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <configuration>
+ <descriptors>
+ <descriptor>src/assembly/api.xml</descriptor>
+ <descriptor>src/assembly/plugins.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <!-- Do not add version information here, use ../pom.xml instead -->
+ <dependencies>
+ <!-- Global dependencies -->
+ <dependency>
+ <groupId>org.jboss.man</groupId>
+ <artifactId>jboss-metatype</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-mdr</artifactId>
+ </dependency>
+ <!-- Test dependencies -->
+ <dependency>
+ <groupId>sun-jaxb</groupId>
+ <artifactId>jaxb-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-log4j</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.test</groupId>
+ <artifactId>jboss-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>javassist</groupId>
+ <artifactId>javassist</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
Deleted: projects/jboss-man/tags/2.1.0.CR8/managed/src/main/java/org/jboss/managed/api/Fields.java
===================================================================
--- projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/api/Fields.java 2009-04-19 02:19:21 UTC (rev 87523)
+++ projects/jboss-man/tags/2.1.0.CR8/managed/src/main/java/org/jboss/managed/api/Fields.java 2009-04-19 02:32:29 UTC (rev 87526)
@@ -1,111 +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>
- * @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";
-
- /** The removed flag */
- String REMOVED = "removed";
-
- /** The modified flag */
- String MODIFIED = "modified";
-
- /** The read-only flag */
- String READ_ONLY = "readOnly";
-
- /** The activation-policy flag */
- String ACTIVATION_POLICY = "activationPolicy";
-
- // 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);
-
- /**
- * Create a copy of the fields.
- * @return a copy of the fields.
- */
- Fields copy();
-}
Copied: projects/jboss-man/tags/2.1.0.CR8/managed/src/main/java/org/jboss/managed/api/Fields.java (from rev 87524, projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/api/Fields.java)
===================================================================
--- projects/jboss-man/tags/2.1.0.CR8/managed/src/main/java/org/jboss/managed/api/Fields.java (rev 0)
+++ projects/jboss-man/tags/2.1.0.CR8/managed/src/main/java/org/jboss/managed/api/Fields.java 2009-04-19 02:32:29 UTC (rev 87526)
@@ -0,0 +1,114 @@
+/*
+* 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 DEFAULT_VALUE = "defaultValue";
+
+ /** 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";
+
+ /** The removed flag */
+ String REMOVED = "removed";
+
+ /** The modified flag */
+ String MODIFIED = "modified";
+
+ /** The read-only flag */
+ String READ_ONLY = "readOnly";
+
+ /** The activation-policy flag */
+ String ACTIVATION_POLICY = "activationPolicy";
+
+ // 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);
+
+ /**
+ * Create a copy of the fields.
+ * @return a copy of the fields.
+ */
+ Fields copy();
+}
Deleted: projects/jboss-man/tags/2.1.0.CR8/managed/src/main/java/org/jboss/managed/api/ManagedProperty.java
===================================================================
--- projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/api/ManagedProperty.java 2009-04-19 02:19:21 UTC (rev 87523)
+++ projects/jboss-man/tags/2.1.0.CR8/managed/src/main/java/org/jboss/managed/api/ManagedProperty.java 2009-04-19 02:32:29 UTC (rev 87526)
@@ -1,233 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.managed.api;
-
-import java.io.Serializable;
-import java.lang.annotation.Annotation;
-import java.util.Map;
-import java.util.Set;
-
-import org.jboss.managed.api.annotation.ActivationPolicy;
-import org.jboss.managed.api.annotation.ManagementObjectRef;
-import org.jboss.managed.api.annotation.ViewUse;
-import org.jboss.metatype.api.types.MetaType;
-import org.jboss.metatype.api.values.MetaValue;
-
-/**
- * ManagedProperty.
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @author Scott.Stark at jboss.org
- * @version $Revision: 1.1 $
- */
-public interface ManagedProperty extends Serializable, TransientAttachments
-{
- /**
- * Get the managed object the property is associated with.
- *
- * @return the managed object
- */
- ManagedObject getManagedObject();
- void setManagedObject(ManagedObject managedObject);
-
- /**
- * Get the ManagedObject
- * @see {@linkplain ManagementObjectRef}
- * @return the ManagedObject the property references, null
- * if there is no reference or its unresolved.
- */
- ManagedObject getTargetManagedObject();
- void setTargetManagedObject(ManagedObject target);
-
- /**
- * Get the fields
- *
- * @return the fields
- */
- Fields getFields();
-
- /**
- * Create a copy of the managed property. This is a copy that whose fields
- * are copies of the original property. Changes to the copies fields have
- * not affect on the original.
- * @return a copy of the managed property.
- */
- ManagedProperty copy();
-
- /**
- * Get a field
- *
- * @param <T> the expected type
- * @param fieldName the field name
- * @param expected the expected type
- * @return the value
- */
- <T> T getField(String fieldName, Class<T> expected);
-
- /**
- * Set a field
- *
- * @param fieldName the field name
- * @param value the value
- */
- void setField(String fieldName, Serializable value);
-
- /**
- * Get the property's name
- *
- * @return the property's name
- */
- String getName();
-
- /**
- * Get the property's mapped name. This is an optional name
- * that allows for an external name to be mapped to an
- * internal one.
- *
- * @return the mapped name if it exists, null if there is no
- * mapped name.
- */
- String getMappedName();
-
- /**
- * Get the description
- *
- * @return the description
- */
- String getDescription();
-
- /**
- * Get the type
- *
- * @return the type
- */
- MetaType getMetaType();
-
- /**
- * Get the annotations associated with the property
- * @return the annotations associated with the property
- */
- Map<String, Annotation> getAnnotations();
-
- /**
- * Does the property have the annotation referenced by key.
- * @param key the key into {@link #getAnnotations()}
- * @return true if the annotation exists, false otherwise.
- */
- boolean hasAnnotation(String key);
-
- /**
- * See if the property has the indicated ViewUse among its
- * @ManagementProperty annotation uses.
- *
- * @param use - the ViewUse to check for
- * @return true if the ViewUse exists in the property uses, false otherwise
- */
- boolean hasViewUse(ViewUse use);
-
- /**
- * Get the activation policy for property value updates.
- * @return the property activation policy
- */
- ActivationPolicy getActivationPolicy();
-
- /**
- * Get the value
- *
- * @return the value
- */
- MetaValue getValue();
-
- /**
- * Set the value
- *
- * @param value the value
- */
- void setValue(MetaValue value);
-
- /**
- * Get the legal values
- *
- * @return the legal values
- */
- Set<MetaValue> getLegalValues();
-
- /**
- * Get the minimum value
- *
- * @return the minimum value, a MetaValue implementing Comparable
- */
- Comparable<? extends MetaValue> getMinimumValue();
-
- /**
- * Get the maximum value
- *
- * @return the maximum value, a MetaValue implementing Comparable
- */
- Comparable<? extends MetaValue> getMaximumValue();
-
- /**
- * Check whether this is a valid value
- *
- * @param value the value
- * @return null for a valid value, an error message otherwise
- */
- String checkValidValue(MetaValue value);
-
- /**
- * Whether the property is mandatory
- *
- * @return true when mandatory
- */
- boolean isMandatory();
-
- /**
- * Whether the property is read only
- * @return true when read only
- */
- boolean isReadOnly();
-
- /**
- * Whether the property has been edited/modified.
- *
- * @return true when modified
- */
- boolean isModified();
-
- /**
- * Set the modified state of the property value.
- * @param flag - whether the property has been modified
- */
- public void setModified(boolean flag);
-
- /**
- * Whether the property has been marked as removed from its ManagedObject.
- * @return true is the property has been removed.
- */
- boolean isRemoved();
- /**
- * Set whether a property has been marked as removed from its ManagedObject.
- * @param flag - true is the property has been removed, false if not.
- */
- void setRemoved(boolean flag);
-
-}
Copied: projects/jboss-man/tags/2.1.0.CR8/managed/src/main/java/org/jboss/managed/api/ManagedProperty.java (from rev 87524, projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/api/ManagedProperty.java)
===================================================================
--- projects/jboss-man/tags/2.1.0.CR8/managed/src/main/java/org/jboss/managed/api/ManagedProperty.java (rev 0)
+++ projects/jboss-man/tags/2.1.0.CR8/managed/src/main/java/org/jboss/managed/api/ManagedProperty.java 2009-04-19 02:32:29 UTC (rev 87526)
@@ -0,0 +1,239 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.managed.api;
+
+import java.io.Serializable;
+import java.lang.annotation.Annotation;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.managed.api.annotation.ActivationPolicy;
+import org.jboss.managed.api.annotation.ManagementObjectRef;
+import org.jboss.managed.api.annotation.ViewUse;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.values.MetaValue;
+
+/**
+ * ManagedProperty.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public interface ManagedProperty extends Serializable, TransientAttachments
+{
+ /**
+ * Get the managed object the property is associated with.
+ *
+ * @return the managed object
+ */
+ ManagedObject getManagedObject();
+ void setManagedObject(ManagedObject managedObject);
+
+ /**
+ * Get the ManagedObject
+ * @see {@linkplain ManagementObjectRef}
+ * @return the ManagedObject the property references, null
+ * if there is no reference or its unresolved.
+ */
+ ManagedObject getTargetManagedObject();
+ void setTargetManagedObject(ManagedObject target);
+
+ /**
+ * Get the fields
+ *
+ * @return the fields
+ */
+ Fields getFields();
+
+ /**
+ * Create a copy of the managed property. This is a copy that whose fields
+ * are copies of the original property. Changes to the copies fields have
+ * not affect on the original.
+ * @return a copy of the managed property.
+ */
+ ManagedProperty copy();
+
+ /**
+ * Get a field
+ *
+ * @param <T> the expected type
+ * @param fieldName the field name
+ * @param expected the expected type
+ * @return the value
+ */
+ <T> T getField(String fieldName, Class<T> expected);
+
+ /**
+ * Set a field
+ *
+ * @param fieldName the field name
+ * @param value the value
+ */
+ void setField(String fieldName, Serializable value);
+
+ /**
+ * Get the property's name
+ *
+ * @return the property's name
+ */
+ String getName();
+
+ /**
+ * Get the property's mapped name. This is an optional name
+ * that allows for an external name to be mapped to an
+ * internal one.
+ *
+ * @return the mapped name if it exists, null if there is no
+ * mapped name.
+ */
+ String getMappedName();
+
+ /**
+ * Get the description
+ *
+ * @return the description
+ */
+ String getDescription();
+
+ /**
+ * Get the type
+ *
+ * @return the type
+ */
+ MetaType getMetaType();
+
+ /**
+ * Get the annotations associated with the property
+ * @return the annotations associated with the property
+ */
+ Map<String, Annotation> getAnnotations();
+
+ /**
+ * Does the property have the annotation referenced by key.
+ * @param key the key into {@link #getAnnotations()}
+ * @return true if the annotation exists, false otherwise.
+ */
+ boolean hasAnnotation(String key);
+
+ /**
+ * See if the property has the indicated ViewUse among its
+ * @ManagementProperty annotation uses.
+ *
+ * @param use - the ViewUse to check for
+ * @return true if the ViewUse exists in the property uses, false otherwise
+ */
+ boolean hasViewUse(ViewUse use);
+
+ /**
+ * Get the activation policy for property value updates.
+ * @return the property activation policy
+ */
+ ActivationPolicy getActivationPolicy();
+
+ /**
+ * Get the value
+ *
+ * @return the value
+ */
+ MetaValue getValue();
+
+ /**
+ * Set the value
+ *
+ * @param value the value
+ */
+ void setValue(MetaValue value);
+
+ /**
+ * Get the legal values
+ *
+ * @return the legal values
+ */
+ Set<MetaValue> getLegalValues();
+
+ /**
+ * Get the property default value if one exists.
+ * @return the default value if one exists, null otherwise.
+ */
+ MetaValue getDefaultValue();
+
+ /**
+ * Get the minimum value
+ *
+ * @return the minimum value, a MetaValue implementing Comparable
+ */
+ Comparable<? extends MetaValue> getMinimumValue();
+
+ /**
+ * Get the maximum value
+ *
+ * @return the maximum value, a MetaValue implementing Comparable
+ */
+ Comparable<? extends MetaValue> getMaximumValue();
+
+ /**
+ * Check whether this is a valid value
+ *
+ * @param value the value
+ * @return null for a valid value, an error message otherwise
+ */
+ String checkValidValue(MetaValue value);
+
+ /**
+ * Whether the property is mandatory
+ *
+ * @return true when mandatory
+ */
+ boolean isMandatory();
+
+ /**
+ * Whether the property is read only
+ * @return true when read only
+ */
+ boolean isReadOnly();
+
+ /**
+ * Whether the property has been edited/modified.
+ *
+ * @return true when modified
+ */
+ boolean isModified();
+
+ /**
+ * Set the modified state of the property value.
+ * @param flag - whether the property has been modified
+ */
+ public void setModified(boolean flag);
+
+ /**
+ * Whether the property has been marked as removed from its ManagedObject.
+ * @return true is the property has been removed.
+ */
+ boolean isRemoved();
+ /**
+ * Set whether a property has been marked as removed from its ManagedObject.
+ * @param flag - true is the property has been removed, false if not.
+ */
+ void setRemoved(boolean flag);
+
+}
Copied: projects/jboss-man/tags/2.1.0.CR8/managed/src/main/java/org/jboss/managed/api/annotation/DefaultValueBuilderFactory.java (from rev 87524, projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/api/annotation/DefaultValueBuilderFactory.java)
===================================================================
--- projects/jboss-man/tags/2.1.0.CR8/managed/src/main/java/org/jboss/managed/api/annotation/DefaultValueBuilderFactory.java (rev 0)
+++ projects/jboss-man/tags/2.1.0.CR8/managed/src/main/java/org/jboss/managed/api/annotation/DefaultValueBuilderFactory.java 2009-04-19 02:32:29 UTC (rev 87526)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.managed.api.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import org.jboss.metatype.spi.values.DefaultValueBuilder;
+
+
+/**
+ * An annotation describing the DefaultValueBuilder implementation
+ * for a property.
+ * This can be used on fields, methods for an individual property
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+ at Target({ElementType.METHOD, ElementType.FIELD})
+ at Retention(RetentionPolicy.RUNTIME)
+public @interface DefaultValueBuilderFactory
+{
+ /** The constraints, allowed values populator factory */
+ Class<? extends DefaultValueBuilder> value();
+}
Deleted: projects/jboss-man/tags/2.1.0.CR8/managed/src/main/java/org/jboss/managed/api/annotation/ManagementProperty.java
===================================================================
--- projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/api/annotation/ManagementProperty.java 2009-04-19 02:19:21 UTC (rev 87523)
+++ projects/jboss-man/tags/2.1.0.CR8/managed/src/main/java/org/jboss/managed/api/annotation/ManagementProperty.java 2009-04-19 02:32:29 UTC (rev 87526)
@@ -1,76 +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.api.annotation;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * ManagementProperty annotation for describing a ManagedProperty
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
- at Target({ElementType.METHOD})
- at Retention(RetentionPolicy.RUNTIME)
- at Inherited
-public @interface ManagementProperty
-{
- /** The description */
- String description() default ManagementConstants.GENERATED;
-
- /** The external name of the property. If undefined its taken
- * from the property the annotation is on.
- */
- String name() default AnnotationDefaults.EMPTY_STRING;
-
- /** The internal name of the property as it relates to metadata */
- String mappedName() default AnnotationDefaults.EMPTY_STRING;
-
- /** Whether this property is mandatory */
- boolean mandatory() default false;
-
- /** Whether this property is read only */
- boolean readOnly() default false;
-
- /** Whether to create a managed object for the property */
- boolean managed() default false;
-
- /** Whether to ignore this property */
- boolean ignored() default false;
-
- /** Whether this property should be included in a deployment template */
- boolean includeInTemplate() default false;
-
- /** The views this property should be used in */
- ViewUse[] use() default {ViewUse.CONFIGURATION};
-
- /** The policy for updating property values */
- ActivationPolicy activationPolicy() default ActivationPolicy.IMMEDIATE;
-
- /** Strings describing free form association to admin views (Ports, Networks, ...} */
- String[] adminViews() default {};
-}
Copied: projects/jboss-man/tags/2.1.0.CR8/managed/src/main/java/org/jboss/managed/api/annotation/ManagementProperty.java (from rev 87524, projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/api/annotation/ManagementProperty.java)
===================================================================
--- projects/jboss-man/tags/2.1.0.CR8/managed/src/main/java/org/jboss/managed/api/annotation/ManagementProperty.java (rev 0)
+++ projects/jboss-man/tags/2.1.0.CR8/managed/src/main/java/org/jboss/managed/api/annotation/ManagementProperty.java 2009-04-19 02:32:29 UTC (rev 87526)
@@ -0,0 +1,86 @@
+/*
+* 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.api.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * ManagementProperty annotation for describing a ManagedProperty. Additional
+ * annotations that can be used on a property to control the behavior of the
+ * property include:
+ *
+ * {@linkplain ConstraintsPopulatorFactory}
+ * {@linkplain Masked}
+ * {@linkplain org.jboss.metatype.api.annotations.MetaMapping}
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+ at Target({ElementType.METHOD})
+ at Retention(RetentionPolicy.RUNTIME)
+ at Inherited
+public @interface ManagementProperty
+{
+ /** The description */
+ String description() default ManagementConstants.GENERATED;
+
+ /** The external name of the property. If undefined its taken
+ * from the property the annotation is on.
+ */
+ String name() default AnnotationDefaults.EMPTY_STRING;
+
+ /** The internal name of the property as it relates to metadata */
+ String mappedName() default AnnotationDefaults.EMPTY_STRING;
+
+ /** Whether this property is mandatory */
+ boolean mandatory() default false;
+
+ /** Whether this property is read only */
+ boolean readOnly() default false;
+
+ /** Whether to create a managed object for the property */
+ boolean managed() default false;
+
+ /** Whether to ignore this property */
+ boolean ignored() default false;
+
+ /** Whether this property should be included in a deployment template */
+ boolean includeInTemplate() default false;
+
+ /** A string representation of the property default value if not empty
+ */
+ String defaultValue() default AnnotationDefaults.EMPTY_STRING;
+
+ /** The views this property should be used in */
+ ViewUse[] use() default {ViewUse.CONFIGURATION};
+
+ /** The policy for updating property values */
+ ActivationPolicy activationPolicy() default ActivationPolicy.IMMEDIATE;
+
+ /** Strings describing free form association to admin views (Ports, Networks, ...} */
+ String[] adminViews() default {};
+}
Deleted: projects/jboss-man/tags/2.1.0.CR8/managed/src/main/java/org/jboss/managed/plugins/ManagedPropertyImpl.java
===================================================================
--- projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/plugins/ManagedPropertyImpl.java 2009-04-19 02:19:21 UTC (rev 87523)
+++ projects/jboss-man/tags/2.1.0.CR8/managed/src/main/java/org/jboss/managed/plugins/ManagedPropertyImpl.java 2009-04-19 02:32:29 UTC (rev 87526)
@@ -1,619 +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.HashMap;
-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.ActivationPolicy;
-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>
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-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;
- /** The transient attachments map */
- private transient Map<String, Object> transientAttachments;
-
- /**
- * Create a new ManagedProperty that is not associated to
- * a ManagedObject.
- *
- * @param name the managed property name
- * @throws IllegalArgumentException for null fields or
- * missing Fields.NAME
- */
- public 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);
- }
-
-
- public boolean hasAnnotation(String key)
- {
- boolean hasAnnotation = false;
- // Look to the ManagementProperty annotation
- Map<String, Annotation> annotations = getAnnotations();
- if(annotations != null)
- {
- hasAnnotation = annotations.containsKey(key);
- }
- return hasAnnotation;
- }
-
- /**
- * 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)
- {
- // Check for a change
- MetaValue oldValue = getValue();
- if(oldValue != value)
- {
- boolean isModified = true;
- if(value != null)
- isModified = ! value.equals(oldValue);
- setModified(isModified);
- }
- 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);
- }
-
- public ActivationPolicy getActivationPolicy()
- {
- ActivationPolicy activationPolicy = getField(Fields.ACTIVATION_POLICY, ActivationPolicy.class);
- return activationPolicy;
- }
- public void setActivationPolicy(ActivationPolicy policy)
- {
- setField(Fields.ACTIVATION_POLICY, policy);
- }
-
- @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<MetaValue> getMinimumValue()
- {
- return getField(Fields.MINIMUM_VALUE, Comparable.class);
- }
-
- /**
- * Set the minimum value
- *
- * @param value the value
- */
- public void setMinimumValue(Comparable<MetaValue> value)
- {
- setField(Fields.MINIMUM_VALUE, (Serializable)value);
- }
-
- public Comparable<MetaValue> getMaximumValue()
- {
- Comparable<MetaValue> field = getField(Fields.MAXIMUM_VALUE, Comparable.class);
- return field;
- }
-
- /**
- * Set the maximum value
- *
- * @param value the value
- */
- public void setMaximumValue(Comparable<MetaValue> value)
- {
- setField(Fields.MAXIMUM_VALUE, (Serializable)value);
- }
-
- public String checkValidValue(MetaValue value)
- {
- Comparable<MetaValue> min = getMinimumValue();
- if(min != null)
- {
- if(min.compareTo(value) > 0)
- return "min("+min+") > "+value;
- }
- Comparable<MetaValue> max = getMaximumValue();
- if(max != null)
- {
- if(max.compareTo(value) < 0)
- return "max("+max+") < "+value;
- }
- Set<MetaValue> legalValues = getLegalValues();
- if(legalValues != null && legalValues.size() > 0)
- {
- if(legalValues.contains(value) == false)
- return legalValues+" does not contain: "+value;
- }
- return null;
- }
-
- public boolean isMandatory()
- {
- Boolean result = getField(Fields.MANDATORY, Boolean.class);
- if (result == null)
- return false;
- return result;
- }
-
- public boolean isReadOnly()
- {
- Boolean result = getField(Fields.READ_ONLY, Boolean.class);
- if (result == null)
- return false;
- return result;
- }
- public void setReadOnly(boolean flag)
- {
- if (flag)
- setField(Fields.READ_ONLY, flag);
- else
- setField(Fields.READ_ONLY, null);
- }
-
- public boolean isModified()
- {
- Boolean result = getField(Fields.MODIFIED, Boolean.class);
- if (result == null)
- return false;
- return result;
- }
- public void setModified(boolean flag)
- {
- if (flag)
- setField(Fields.MODIFIED, flag);
- else
- setField(Fields.MODIFIED, null);
- }
-
- /**
- * 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);
- }
-
- public boolean isRemoved()
- {
- Boolean result = getField(Fields.REMOVED, Boolean.class);
- if (result == null)
- return false;
- return result;
- }
-
- /**
- * Set whether the property is removed
- *
- * @param flag true for removed
- */
- public void setRemoved(boolean flag)
- {
- if (flag)
- setField(Fields.REMOVED, flag);
- else
- setField(Fields.REMOVED, null);
- }
-
- public <T> T getTransientAttachment(Class<T> expectedType)
- {
- T tvalue = null;
- Object value = getTransientAttachment(expectedType.getName());
- if(value != null)
- tvalue = expectedType.cast(value);
- return tvalue;
- }
-
- public Object getTransientAttachment(String name)
- {
- Object value = null;
- if(transientAttachments != null)
- value = transientAttachments.get(name);
- return value;
- }
-
- public synchronized void setTransientAttachment(String name, Object attachment)
- {
- if(transientAttachments == null)
- transientAttachments = new HashMap<String, Object>();
- transientAttachments.put(name, attachment);
- }
-
- @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());
- }
-
- public ManagedProperty copy()
- {
- Fields fieldsCopy = fields.copy();
- ManagedProperty mp = new ManagedPropertyImpl(fieldsCopy);
- return mp;
- }
-
- /**
- * 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.1.0.CR8/managed/src/main/java/org/jboss/managed/plugins/ManagedPropertyImpl.java (from rev 87524, projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/plugins/ManagedPropertyImpl.java)
===================================================================
--- projects/jboss-man/tags/2.1.0.CR8/managed/src/main/java/org/jboss/managed/plugins/ManagedPropertyImpl.java (rev 0)
+++ projects/jboss-man/tags/2.1.0.CR8/managed/src/main/java/org/jboss/managed/plugins/ManagedPropertyImpl.java 2009-04-19 02:32:29 UTC (rev 87526)
@@ -0,0 +1,625 @@
+/*
+* 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.HashMap;
+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.ActivationPolicy;
+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>
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+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;
+ /** The transient attachments map */
+ private transient Map<String, Object> transientAttachments;
+
+ /**
+ * Create a new ManagedProperty that is not associated to
+ * a ManagedObject.
+ *
+ * @param name the managed property name
+ * @throws IllegalArgumentException for null fields or
+ * missing Fields.NAME
+ */
+ public 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);
+ }
+
+
+ public boolean hasAnnotation(String key)
+ {
+ boolean hasAnnotation = false;
+ // Look to the ManagementProperty annotation
+ Map<String, Annotation> annotations = getAnnotations();
+ if(annotations != null)
+ {
+ hasAnnotation = annotations.containsKey(key);
+ }
+ return hasAnnotation;
+ }
+
+ /**
+ * 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)
+ {
+ // Check for a change
+ MetaValue oldValue = getValue();
+ if(oldValue != value)
+ {
+ boolean isModified = true;
+ if(value != null)
+ isModified = ! value.equals(oldValue);
+ setModified(isModified);
+ }
+ 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);
+ }
+
+ public ActivationPolicy getActivationPolicy()
+ {
+ ActivationPolicy activationPolicy = getField(Fields.ACTIVATION_POLICY, ActivationPolicy.class);
+ return activationPolicy;
+ }
+ public void setActivationPolicy(ActivationPolicy policy)
+ {
+ setField(Fields.ACTIVATION_POLICY, policy);
+ }
+
+ @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 MetaValue getDefaultValue()
+ {
+ MetaValue field = getField(Fields.DEFAULT_VALUE, MetaValue.class);
+ return field;
+ }
+
+ public Comparable<MetaValue> getMinimumValue()
+ {
+ return getField(Fields.MINIMUM_VALUE, Comparable.class);
+ }
+
+ /**
+ * Set the minimum value
+ *
+ * @param value the value
+ */
+ public void setMinimumValue(Comparable<MetaValue> value)
+ {
+ setField(Fields.MINIMUM_VALUE, (Serializable)value);
+ }
+
+ public Comparable<MetaValue> getMaximumValue()
+ {
+ Comparable<MetaValue> field = getField(Fields.MAXIMUM_VALUE, Comparable.class);
+ return field;
+ }
+
+ /**
+ * Set the maximum value
+ *
+ * @param value the value
+ */
+ public void setMaximumValue(Comparable<MetaValue> value)
+ {
+ setField(Fields.MAXIMUM_VALUE, (Serializable)value);
+ }
+
+ public String checkValidValue(MetaValue value)
+ {
+ Comparable<MetaValue> min = getMinimumValue();
+ if(min != null)
+ {
+ if(min.compareTo(value) > 0)
+ return "min("+min+") > "+value;
+ }
+ Comparable<MetaValue> max = getMaximumValue();
+ if(max != null)
+ {
+ if(max.compareTo(value) < 0)
+ return "max("+max+") < "+value;
+ }
+ Set<MetaValue> legalValues = getLegalValues();
+ if(legalValues != null && legalValues.size() > 0)
+ {
+ if(legalValues.contains(value) == false)
+ return legalValues+" does not contain: "+value;
+ }
+ return null;
+ }
+
+ public boolean isMandatory()
+ {
+ Boolean result = getField(Fields.MANDATORY, Boolean.class);
+ if (result == null)
+ return false;
+ return result;
+ }
+
+ public boolean isReadOnly()
+ {
+ Boolean result = getField(Fields.READ_ONLY, Boolean.class);
+ if (result == null)
+ return false;
+ return result;
+ }
+ public void setReadOnly(boolean flag)
+ {
+ if (flag)
+ setField(Fields.READ_ONLY, flag);
+ else
+ setField(Fields.READ_ONLY, null);
+ }
+
+ public boolean isModified()
+ {
+ Boolean result = getField(Fields.MODIFIED, Boolean.class);
+ if (result == null)
+ return false;
+ return result;
+ }
+ public void setModified(boolean flag)
+ {
+ if (flag)
+ setField(Fields.MODIFIED, flag);
+ else
+ setField(Fields.MODIFIED, null);
+ }
+
+ /**
+ * 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);
+ }
+
+ public boolean isRemoved()
+ {
+ Boolean result = getField(Fields.REMOVED, Boolean.class);
+ if (result == null)
+ return false;
+ return result;
+ }
+
+ /**
+ * Set whether the property is removed
+ *
+ * @param flag true for removed
+ */
+ public void setRemoved(boolean flag)
+ {
+ if (flag)
+ setField(Fields.REMOVED, flag);
+ else
+ setField(Fields.REMOVED, null);
+ }
+
+ public <T> T getTransientAttachment(Class<T> expectedType)
+ {
+ T tvalue = null;
+ Object value = getTransientAttachment(expectedType.getName());
+ if(value != null)
+ tvalue = expectedType.cast(value);
+ return tvalue;
+ }
+
+ public Object getTransientAttachment(String name)
+ {
+ Object value = null;
+ if(transientAttachments != null)
+ value = transientAttachments.get(name);
+ return value;
+ }
+
+ public synchronized void setTransientAttachment(String name, Object attachment)
+ {
+ if(transientAttachments == null)
+ transientAttachments = new HashMap<String, Object>();
+ transientAttachments.put(name, attachment);
+ }
+
+ @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());
+ }
+
+ public ManagedProperty copy()
+ {
+ Fields fieldsCopy = fields.copy();
+ ManagedProperty mp = new ManagedPropertyImpl(fieldsCopy);
+ return mp;
+ }
+
+ /**
+ * 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.1.0.CR8/managed/src/main/java/org/jboss/managed/plugins/factory/AbstractManagedObjectFactory.java
===================================================================
--- projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/plugins/factory/AbstractManagedObjectFactory.java 2009-04-19 02:19:21 UTC (rev 87523)
+++ projects/jboss-man/tags/2.1.0.CR8/managed/src/main/java/org/jboss/managed/plugins/factory/AbstractManagedObjectFactory.java 2009-04-19 02:32:29 UTC (rev 87526)
@@ -1,1112 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2007, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.managed.plugins.factory;
-
-import java.io.Serializable;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Constructor;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.WeakHashMap;
-
-import org.jboss.beans.info.spi.BeanInfo;
-import org.jboss.beans.info.spi.PropertyInfo;
-import org.jboss.config.spi.Configuration;
-import org.jboss.logging.Logger;
-import org.jboss.managed.api.Fields;
-import org.jboss.managed.api.ManagedObject;
-import org.jboss.managed.api.ManagedOperation;
-import org.jboss.managed.api.ManagedParameter;
-import org.jboss.managed.api.ManagedProperty;
-import org.jboss.managed.api.MutableManagedObject;
-import org.jboss.managed.api.ManagedOperation.Impact;
-import org.jboss.managed.api.annotation.ActivationPolicy;
-import org.jboss.managed.api.annotation.AnnotationDefaults;
-import org.jboss.managed.api.annotation.ConstraintsPopulatorFactory;
-import org.jboss.managed.api.annotation.FieldsFactory;
-import org.jboss.managed.api.annotation.ManagementComponent;
-import org.jboss.managed.api.annotation.ManagementConstants;
-import org.jboss.managed.api.annotation.ManagementDeployment;
-import org.jboss.managed.api.annotation.ManagementObject;
-import org.jboss.managed.api.annotation.ManagementObjectID;
-import org.jboss.managed.api.annotation.ManagementObjectRef;
-import org.jboss.managed.api.annotation.ManagementOperation;
-import org.jboss.managed.api.annotation.ManagementParameter;
-import org.jboss.managed.api.annotation.ManagementProperties;
-import org.jboss.managed.api.annotation.ManagementProperty;
-import org.jboss.managed.api.annotation.ManagementPropertyFactory;
-import org.jboss.managed.api.annotation.ManagementRuntimeRef;
-import org.jboss.managed.api.annotation.Masked;
-import org.jboss.managed.api.annotation.RunStateProperty;
-import org.jboss.managed.api.annotation.ViewUse;
-import org.jboss.managed.api.factory.ManagedObjectFactory;
-import org.jboss.managed.api.factory.ManagedObjectDefinition;
-import org.jboss.managed.plugins.DefaultFieldsImpl;
-import org.jboss.managed.plugins.ManagedObjectImpl;
-import org.jboss.managed.plugins.ManagedOperationImpl;
-import org.jboss.managed.plugins.ManagedParameterImpl;
-import org.jboss.managed.plugins.WritethroughManagedPropertyImpl;
-import org.jboss.managed.spi.factory.InstanceClassFactory;
-import org.jboss.managed.spi.factory.ManagedObjectBuilder;
-import org.jboss.managed.spi.factory.ManagedObjectPopulator;
-import org.jboss.managed.spi.factory.ManagedParameterConstraintsPopulator;
-import org.jboss.managed.spi.factory.ManagedParameterConstraintsPopulatorFactory;
-import org.jboss.managed.spi.factory.ManagedPropertyConstraintsPopulator;
-import org.jboss.managed.spi.factory.ManagedPropertyConstraintsPopulatorFactory;
-import org.jboss.metadata.spi.MetaData;
-import org.jboss.metadata.spi.signature.FieldSignature;
-import org.jboss.metadata.spi.signature.MethodSignature;
-import org.jboss.metadata.spi.signature.Signature;
-import org.jboss.metatype.api.annotations.MetaMapping;
-import org.jboss.metatype.api.annotations.MetaMappingFactory;
-import org.jboss.metatype.api.types.ArrayMetaType;
-import org.jboss.metatype.api.types.CollectionMetaType;
-import org.jboss.metatype.api.types.GenericMetaType;
-import org.jboss.metatype.api.types.MetaType;
-import org.jboss.metatype.api.types.MetaTypeFactory;
-import org.jboss.metatype.api.values.MetaValueFactory;
-import org.jboss.metatype.spi.values.MetaMapper;
-import org.jboss.metatype.spi.values.MetaMapperFactory;
-import org.jboss.reflect.spi.AnnotatedInfo;
-import org.jboss.reflect.spi.ClassInfo;
-import org.jboss.reflect.spi.MethodInfo;
-import org.jboss.reflect.spi.ParameterInfo;
-import org.jboss.reflect.spi.TypeInfo;
-
-/**
- * The base ManagedObjectFactory implementation.
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public class AbstractManagedObjectFactory extends ManagedObjectFactory
- implements ManagedObjectBuilder
-{
- private static final Logger log = Logger.getLogger(AbstractManagedObjectFactory.class);
-
- /** The configuration */
- private static final Configuration configuration = PropertyConfigurationAccess.getConfiguration();
-
- /** The managed object meta type */
- public static final GenericMetaType MANAGED_OBJECT_META_TYPE = new GenericMetaType(ManagedObject.class.getName(), ManagedObject.class.getName());
-
- /** The meta type factory */
- private MetaTypeFactory metaTypeFactory = MetaTypeFactory.getInstance();
-
- /** The meta value factory */
- private MetaValueFactory metaValueFactory = MetaValueFactory.getInstance();
- /** A default InstanceClassFactory used when there is no explicit ICF for a given class */
- private InstanceClassFactory<?> defaultInstanceFactory;
- /** A default ManagedObjectPopulator used when there is no explicit ManagedObjectBuilder for a given class */
- private ManagedObjectPopulator<?> defaultManagedObjectPopulator;
-
- /** The managed object builders */
- private Map<Class<?>, ManagedObjectBuilder> builders = new WeakHashMap<Class<?>, ManagedObjectBuilder>();
-
- /** The instance to class factories */
- private Map<Class<?>, InstanceClassFactory<?>> instanceFactories = new WeakHashMap<Class<?>, InstanceClassFactory<?>>();
-
- /**
- * Create a ManagedProperty by looking to the factory for ctor(Fields)
- * @param factory - the ManagedProperty implementation class
- * @param fields - the fields to pass to the ctor
- * @return the managed property if successful, null otherwise
- */
- public static ManagedProperty createManagedProperty(Class<? extends ManagedProperty> factory, Fields fields)
- {
- ManagedProperty property = null;
- try
- {
- Class<?>[] sig = {Fields.class};
- Constructor<? extends ManagedProperty> ctor = factory.getConstructor(sig);
- Object[] args = {fields};
- property = ctor.newInstance(args);
- }
- catch(Exception e)
- {
- log.debug("Failed to create ManagedProperty", e);
- }
- return property;
- }
-
- /**
- * Create an AbstractManagedObjectFactory that uses an AbstractInstanceClassFactory
- * as the defaultInstanceFactory and AbstractManagedObjectPopulator as the
- * defaultManagedObjectPopulator. The MetaTypeFactory, MetaValueFactory are
- * obtained from the respective getInstance() factory methods.
- */
- public AbstractManagedObjectFactory()
- {
- // Create an AbstractInstanceClassFactory as the default ICF
- DefaultInstanceClassFactory icf = new DefaultInstanceClassFactory();
- icf.setMof(this);
- defaultInstanceFactory = icf;
- // Create an AbstractManagedObjectPopulator as the default
- defaultManagedObjectPopulator = new AbstractManagedObjectPopulator<Serializable>(configuration, icf, instanceFactories);
- }
- /**
- * Create an AbstractManagedObjectFactory the given factories, supporting
- * information.
- *
- * @param metaTypeFactory
- * @param metaValueFactory
- * @param defaultInstanceFactory
- * @param defaultManagedObjectPopulator
- * @param builders
- * @param instanceFactories
- */
- public AbstractManagedObjectFactory(MetaTypeFactory metaTypeFactory,
- MetaValueFactory metaValueFactory,
- InstanceClassFactory<?> defaultInstanceFactory,
- ManagedObjectPopulator<?> defaultManagedObjectPopulator,
- Map<Class<?>, ManagedObjectBuilder> builders,
- Map<Class<?>, InstanceClassFactory<?>> instanceFactories)
- {
- this.metaTypeFactory = metaTypeFactory;
- this.metaValueFactory = metaValueFactory;
- this.defaultInstanceFactory = defaultInstanceFactory;
- this.defaultManagedObjectPopulator = defaultManagedObjectPopulator;
- this.builders = builders;
- this.instanceFactories = instanceFactories;
- }
-
- /**
- * Add managed object definition.
- *
- * @param definition the MO definition
- */
- public void addManagedObjectDefinition(ManagedObjectDefinition definition)
- {
- if (definition == null || definition.isValid() == false)
- throw new IllegalArgumentException("Invalid MO definition: " + definition);
-
- setBuilder(definition.getType(), definition.getBuilder());
- }
-
- /**
- * Remove managed object definition.
- *
- * @param definition the MO definition
- */
- public void removeManagedObjectDefinition(ManagedObjectDefinition definition)
- {
- if (definition == null)
- return;
-
- setBuilder(definition.getType(), null);
- }
-
- /**
- * Get the configuration
- *
- * @return the configuration
- */
- public Configuration getConfiguration()
- {
- return configuration;
- }
-
-
- public MetaTypeFactory getMetaTypeFactory()
- {
- return metaTypeFactory;
- }
-
- public void setMetaTypeFactory(MetaTypeFactory metaTypeFactory)
- {
- this.metaTypeFactory = metaTypeFactory;
- }
-
- public MetaValueFactory getMetaValueFactory()
- {
- return metaValueFactory;
- }
-
- public void setMetaValueFactory(MetaValueFactory metaValueFactory)
- {
- this.metaValueFactory = metaValueFactory;
- }
-
- public Map<Class<?>, ManagedObjectBuilder> getBuilders()
- {
- return builders;
- }
-
- public void setBuilders(Map<Class<?>, ManagedObjectBuilder> builders)
- {
- this.builders = builders;
- }
-
- public Map<Class<?>, InstanceClassFactory<?>> getInstanceFactories()
- {
- return instanceFactories;
- }
-
- public void setInstanceFactories(
- Map<Class<?>, InstanceClassFactory<?>> instanceFactories)
- {
- this.instanceFactories = instanceFactories;
- }
-
- /**
- * Get the default InstanceClassFactory
- * @return the current default InstanceClassFactory
- */
- public InstanceClassFactory<?> getDefaultInstanceFactory()
- {
- return defaultInstanceFactory;
- }
- /**
- * Set the default InstanceClassFactory. This is used when there is not
- * match an exact match by the {@linkplain #getInstanceClassFactory(Class)}
- * factory method.
- *
- * @param defaultInstanceFactory the default InstanceClassFactory to fall
- * back to. It may be null if no default should be used.
- */
- public void setDefaultInstanceFactory(
- InstanceClassFactory<? extends Serializable> defaultInstanceFactory)
- {
- this.defaultInstanceFactory = defaultInstanceFactory;
- }
-
-
- public ManagedObjectPopulator<?> getDefaultManagedObjectPopulator()
- {
- return defaultManagedObjectPopulator;
- }
-
- /**
- * A default implementation of ManagedObjectPopulator that is used when
- * there is no ManagedObjectBuilder registered for a given type.
- * @see #getBuilder(Class)
- * @param defaultManagedObjectPopulator
- */
- public void setDefaultManagedObjectPopulator(
- ManagedObjectPopulator<? extends Serializable> defaultManagedObjectPopulator)
- {
- this.defaultManagedObjectPopulator = defaultManagedObjectPopulator;
- }
-
- @Override
- public <T> ManagedObject createManagedObject(Class<T> clazz, MetaData metaData)
- {
- if (clazz == null)
- throw new IllegalArgumentException("Null class");
-
- ManagedObject result = createSkeletonManagedObject(clazz, metaData);
- ManagedObjectPopulator<T> populator = getPopulator(clazz);
- populator.createObject(result, clazz, metaData);
-
- return result;
- }
-
- public ManagedObject initManagedObject(Object instance, Class<?> instanceType,
- MetaData metaData, String name, String nameType)
- {
- if (instance == null)
- throw new IllegalArgumentException("instance cannot be null");
-
- Class<?> clazz = instance.getClass();
- InstanceClassFactory icf = defaultInstanceFactory;
- if(instanceType != null && instanceType != clazz)
- icf = getInstanceClassFactory(instanceType, metaData);
- if(icf == defaultInstanceFactory)
- icf = getInstanceClassFactory(clazz, metaData);
-
- Class<Object> moClass;
- try
- {
- moClass = icf.getManagedObjectClass(instance);
- }
- catch(ClassNotFoundException e)
- {
- log.debug("Failed to load class for ManagedObject", e);
- return null;
- }
- if(moClass == null)
- {
- log.debug("ICF returned null class: "+instance);
- return null;
- }
-
- ManagedObject result = createSkeletonManagedObject(moClass, metaData);
- if (result == null)
- {
- log.debug("Null ManagedObject created for: "+moClass);
- return null;
- }
- log.debug("Created skeleton ManagedObject: "+result);
-
- if(result instanceof MutableManagedObject)
- {
- MutableManagedObject mmo = (MutableManagedObject) result;
- ManagedObjectPopulator<Object> populator = getPopulator(moClass);
- populator.populateManagedObject(mmo, instance, metaData);
- }
-
- return result;
- }
-
- @Override
- public void setBuilder(Class<?> clazz, ManagedObjectBuilder builder)
- {
- synchronized (builders)
- {
- if (builder == null)
- builders.remove(clazz);
- else
- builders.put(clazz, builder);
- }
- }
-
- @Override
- public <T> void setInstanceClassFactory(Class<T> clazz, InstanceClassFactory<T> factory)
- {
- synchronized (instanceFactories)
- {
- if (factory == null)
- {
- instanceFactories.remove(clazz);
- log.debug("Removed ICF for: "+clazz);
- }
- else
- {
- instanceFactories.put(clazz, factory);
- log.debug("Set ICF for: "+clazz+", to: "+factory);
- }
- }
- }
-
- /**
- * Create a skeleton managed object
- *
- * @param <T> the type
- * @param clazz the clazz
- * @return the skeleton managed object, null if clazz is not
- * marked as a ManagementObject.
- * {@linkplain ManagementObject}
- */
- protected <T> ManagedObject createSkeletonManagedObject(Class<T> clazz, MetaData metaData)
- {
- if (clazz == null)
- throw new IllegalArgumentException("Null class");
-
- ManagedObjectBuilder builder = getBuilder(clazz);
- return builder.buildManagedObject(clazz, metaData);
- }
-
- /**
- * The ManagedObjectBuilder.buildManagedObject implementation. This is based
- * on the org.jboss.managed.api.annotation.* package annotations.
- * @param clazz the attachment class
- * @param metaData - the optional metadata repository accessor used to query
- * for management annotation overrides/additions to the clazz
- * @return the ManagementObject if clazz is properly annotated, null if
- * it does not have a ManagementObject annotation on the class or metaData.
- * The BeanInfo used by this method is stored as a transient attachment
- * under the BeanInfo.class.getName() ket.
- */
- @SuppressWarnings("unchecked")
- public ManagedObject buildManagedObject(Class<?> clazz, MetaData metaData)
- {
- boolean trace = log.isTraceEnabled();
- BeanInfo beanInfo = configuration.getBeanInfo(clazz);
- ClassInfo classInfo = beanInfo.getClassInfo();
-
- ManagementObject managementObject = getAnnotation(ManagementObject.class, classInfo, metaData);
- if( managementObject == null )
- {
- if (trace)
- log.trace("No ManagementObject annotation, skipping ManagedObject for class: "+clazz);
- // Skip the ManagedObject creation
- return null;
- }
-
- // If a targetInterface exists, rebuild the BeanInfo from that
- Class<?> targetInterface = managementObject.targetInterface();
- if(targetInterface != Object.class)
- {
- beanInfo = getBeanInfo(targetInterface);
- classInfo = beanInfo.getClassInfo();
- }
- HashMap<String, Annotation> moAnnotations = new HashMap<String, Annotation>();
- moAnnotations.put(ManagementObject.class.getName(), managementObject);
- ManagementDeployment mnagementDeployment = getAnnotation(ManagementDeployment.class, classInfo, metaData);
- if(mnagementDeployment != null)
- moAnnotations.put(ManagementDeployment.class.getName(), mnagementDeployment);
- ManagementObjectID moID = getAnnotation(ManagementObjectID.class, classInfo, metaData);
- if (moID != null)
- moAnnotations.put(ManagementObjectID.class.getName(), moID);
-
- // Process the ManagementObject fields
- boolean isRuntime = managementObject.isRuntime();
- String name = classInfo.getName();
- String nameType = null;
- String attachmentName = classInfo.getName();
- Class<? extends Fields> moFieldsFactory = null;
- ConstraintsPopulatorFactory moCPF = null;
- Class<? extends ManagedPropertyConstraintsPopulatorFactory> moConstraintsFactory = null;
- Class<? extends ManagedProperty> moPropertyFactory = null;
- if (managementObject != null)
- {
- name = managementObject.name();
- if (name.length() == 0 || name.equals(ManagementConstants.GENERATED))
- name = classInfo.getName();
- nameType = managementObject.type();
- if (nameType.length() == 0)
- nameType = null;
- attachmentName = managementObject.attachmentName();
- if (attachmentName.length() == 0)
- attachmentName = classInfo.getName();
- // Check for a component specification
- ManagementComponent mc = managementObject.componentType();
- // Work around JBMDR-51 by checking type/subtype
- // if (mc.equals(AnnotationDefaults.COMP_TYPE) == false)
- if (mc.type().length() > 0 || mc.subtype().length() > 0)
- {
- log.debug("ManagedObject("+name+") is ManagedComponent type: "+mc);
- moAnnotations.put(ManagementComponent.class.getName(), mc);
- }
- // ManagementObject level default factory classes
- FieldsFactory ff = getAnnotation(FieldsFactory.class, classInfo, metaData);
- if(ff != null)
- moFieldsFactory = ff.value();
- moCPF = getAnnotation(ConstraintsPopulatorFactory.class, classInfo, metaData);
- if(moCPF != null)
- moConstraintsFactory = moCPF.value();
- ManagementPropertyFactory mpf = getAnnotation(ManagementPropertyFactory.class, classInfo, metaData);
- if(mpf != null)
- moPropertyFactory = mpf.value();
- }
-
- if (trace)
- {
- log.trace("Building MangedObject(name="+name+",nameType="+nameType
- +",attachmentName="+attachmentName+",isRuntime="+isRuntime+")");
- }
-
- ManagementProperties propertyType = ManagementProperties.ALL;
- Set<String> classProperties = null;
- if (managementObject != null)
- {
- propertyType = managementObject.properties();
- if(propertyType == ManagementProperties.CLASS || propertyType == ManagementProperties.CLASS_AND_EXPLICIT)
- {
- classProperties = new HashSet<String>();
- for(ManagementProperty mp : managementObject.classProperties())
- {
- if(mp.name().length() > 0)
- classProperties.add(mp.name());
- if(mp.mappedName().length() > 0)
- classProperties.add(mp.mappedName());
- }
- }
- }
-
- // Build the ManagedProperties
- Set<ManagedProperty> properties = new HashSet<ManagedProperty>();
-
- Set<PropertyInfo> propertyInfos = beanInfo.getProperties();
- if (propertyInfos != null && propertyInfos.isEmpty() == false)
- {
- for (PropertyInfo propertyInfo : propertyInfos)
- {
- // Ignore the "class" property
- if ("class".equals(propertyInfo.getName()))
- continue;
-
- ManagementProperty managementProperty = getAnnotation(ManagementProperty.class, propertyInfo, metaData);
- ManagementObjectID id = getAnnotation(ManagementObjectID.class, propertyInfo, metaData);
- ManagementObjectRef ref = getAnnotation(ManagementObjectRef.class, propertyInfo, metaData);
- ManagementRuntimeRef runtimeRef = getAnnotation(ManagementRuntimeRef.class, propertyInfo, metaData);
- RunStateProperty rsp = getAnnotation(RunStateProperty.class, propertyInfo, metaData);
- Masked masked = getAnnotation(Masked.class, propertyInfo, metaData);
- HashMap<String, Annotation> propAnnotations = new HashMap<String, Annotation>();
- if (managementProperty != null)
- propAnnotations.put(ManagementProperty.class.getName(), managementProperty);
- if (id != null)
- {
- propAnnotations.put(ManagementObjectID.class.getName(), id);
- // This overrides the MO nameType
- nameType = id.type();
- }
- if (ref != null)
- propAnnotations.put(ManagementObjectRef.class.getName(), ref);
- if (runtimeRef != null)
- propAnnotations.put(ManagementRuntimeRef.class.getName(), runtimeRef);
- if (rsp != null)
- propAnnotations.put(RunStateProperty.class.getName(), rsp);
- if (masked != null)
- propAnnotations.put(Masked.class.getName(), masked);
-
- // Check whether this property should be included
- boolean includeProperty = false;
- switch(propertyType)
- {
- // Only if the property as a ManagementProperty
- case EXPLICIT:
- includeProperty = managementProperty != null &&
- (managementProperty.ignored() == false);
- break;
- // Only if the property is listed in the classProperties
- case CLASS:
- includeProperty = classProperties.contains(propertyInfo.getName());
- break;
- // Only if the property is listed in the classProperties
- case CLASS_AND_EXPLICIT:
- includeProperty = classProperties.contains(propertyInfo.getName())
- || (managementProperty != null && managementProperty.ignored() == false);
- break;
- // Any property that is not ignored
- case ALL:
- includeProperty = managementProperty == null
- || managementProperty.ignored() == false;
- break;
- }
-
- if (includeProperty)
- {
- Fields fields = null;
- Class<? extends Fields> factory = moFieldsFactory;
- FieldsFactory ff = getAnnotation(FieldsFactory.class, propertyInfo, metaData);
- if(ff != null)
- factory = ff.value();
- if (factory != null)
- {
- try
- {
- fields = factory.newInstance();
- }
- catch (Exception e)
- {
- log.debug("Failed to created Fields", e);
- }
- }
- if (fields == null)
- fields = new DefaultFieldsImpl();
-
- if( propertyInfo instanceof Serializable )
- {
- Serializable info = Serializable.class.cast(propertyInfo);
- fields.setField(Fields.PROPERTY_INFO, info);
- }
-
- String propertyName = propertyInfo.getName();
- if (managementProperty != null)
- propertyName = managementProperty.name();
- if( propertyName.length() == 0 )
- propertyName = propertyInfo.getName();
- fields.setField(Fields.NAME, propertyName);
-
- // This should probably always the the propertyInfo name?
- String mappedName = propertyInfo.getName();
- if (managementProperty != null)
- mappedName = managementProperty.mappedName();
- if( mappedName.length() == 0 )
- mappedName = propertyInfo.getName();
- fields.setField(Fields.MAPPED_NAME, mappedName);
-
- String description = ManagementConstants.GENERATED;
- if (managementProperty != null)
- description = managementProperty.description();
- if (description.equals(ManagementConstants.GENERATED))
- description = propertyName;
- fields.setField(Fields.DESCRIPTION, description);
-
- if (trace)
- {
- log.trace("Building MangedProperty(name="+propertyName
- +",mappedName="+mappedName
- +") ,annotations="+propAnnotations);
- }
-
- boolean mandatory = false;
- if (managementProperty != null)
- mandatory = managementProperty.mandatory();
- if (mandatory)
- fields.setField(Fields.MANDATORY, Boolean.TRUE);
-
- boolean readOnly = propertyInfo.isWritable() == false;
- if (readOnly == false && managementProperty != null)
- readOnly = managementProperty.readOnly();
- if (readOnly)
- fields.setField(Fields.READ_ONLY, Boolean.TRUE);
-
- boolean managed = false;
- if (managementProperty != null)
- managed = managementProperty.managed();
- // View Use
- if (managementProperty != null)
- {
- ViewUse[] use = managementProperty.use();
- fields.setField(Fields.VIEW_USE, use);
- }
- // ActivationPolicy
- ActivationPolicy apolicy = ActivationPolicy.IMMEDIATE;
- if (managementProperty != null)
- {
- apolicy = managementProperty.activationPolicy();
- }
- fields.setField(Fields.ACTIVATION_POLICY, apolicy);
-
- // The managed property type
- MetaMapper[] mapperReturn = {null};
- MetaType metaType = this.getMetaType(propertyInfo, propertyInfo.getType(), metaData, false, mapperReturn);
-
- // Determine meta type based on property type
- if(metaType == null)
- {
- if (managed)
- {
- TypeInfo typeInfo = propertyInfo.getType();
- if(typeInfo.isArray())
- metaType = new ArrayMetaType(1, MANAGED_OBJECT_META_TYPE);
- else if (typeInfo.isCollection())
- metaType = new CollectionMetaType(typeInfo.getName(), MANAGED_OBJECT_META_TYPE);
- else
- metaType = MANAGED_OBJECT_META_TYPE;
- }
- else
- {
- metaType = metaTypeFactory.resolve(propertyInfo.getType());
- }
- }
- fields.setField(Fields.META_TYPE, metaType);
- // Property annotations
- if (propAnnotations.isEmpty() == false)
- fields.setField(Fields.ANNOTATIONS, propAnnotations);
-
- // Delegate others (legal values, min/max etc.) to the constraints factory
- try
- {
- Class<? extends ManagedPropertyConstraintsPopulatorFactory> factoryClass = moConstraintsFactory;
- ConstraintsPopulatorFactory cpf = getAnnotation(ConstraintsPopulatorFactory.class, propertyInfo, metaData);
- if(cpf != null)
- factoryClass = cpf.value();
- else
- cpf = moCPF;
- if(factoryClass != null)
- {
- ManagedPropertyConstraintsPopulatorFactory mpcpf = factoryClass.newInstance();
- ManagedPropertyConstraintsPopulator populator = mpcpf.newInstance(cpf.min(), cpf.max(), cpf.legalValues(), cpf.args());
- if (populator != null)
- populator.populateManagedProperty(clazz, propertyInfo, fields);
- }
- }
- catch(Exception e)
- {
- log.debug("Failed to populate constraints for: "+propertyInfo, e);
- }
-
- ManagedProperty property = null;
- Class<? extends ManagedProperty> mpClass = moPropertyFactory;
- ManagementPropertyFactory mpf = getAnnotation(ManagementPropertyFactory.class, propertyInfo, metaData);
- if (mpf != null)
- mpClass = mpf.value();
- if (mpClass != null)
- property = getManagedProperty(mpClass, fields);
- // we should have write-through by default
- // use factory to change this default behavior
- if (property == null)
- property = createDefaultManagedProperty(fields);
- // Pass the MetaMapper as an attachment
- if (mapperReturn[0] != null)
- property.setTransientAttachment(MetaMapper.class.getName(), mapperReturn[0]);
- properties.add(property);
- }
- else if (trace)
- log.trace("Ignoring property: " + propertyInfo);
- }
- }
-
- /* TODO: Operations. In general the bean metadata does not contain
- operation information.
- */
- Set<ManagedOperation> operations = new HashSet<ManagedOperation>();
-
- Set<MethodInfo> methodInfos = beanInfo.getMethods();
- if (methodInfos != null && methodInfos.isEmpty() == false)
- {
- for (MethodInfo methodInfo : methodInfos)
- {
- ManagementOperation managementOp = getAnnotation(ManagementOperation.class, methodInfo, metaData);
- if (managementOp == null)
- continue;
-
- ManagedOperation op = getManagedOperation(methodInfo, managementOp, metaData);
- operations.add(op);
- }
- }
-
- ManagedObjectImpl result = new ManagedObjectImpl(name, properties);
- result.setAnnotations(moAnnotations);
- // Set the component name to name if this is a runtime MO with a name specified
- if (isRuntime && name.equals(classInfo.getName()) == false)
- result.setComponentName(name);
- if (nameType != null)
- result.setNameType(nameType);
- if (attachmentName != null)
- result.setAttachmentName(attachmentName);
- if (operations.size() > 0 )
- result.setOperations(operations);
- for (ManagedProperty property : properties)
- property.setManagedObject(result);
- result.setTransientAttachment(BeanInfo.class.getName(), beanInfo);
- return result;
- }
-
- /**
- * Create default MangedProperty instance.
- * Override this method for different default.
- *
- * @param fields the fields
- * @return new ManagedProperty instance
- */
- protected ManagedProperty createDefaultManagedProperty(Fields fields)
- {
- return new WritethroughManagedPropertyImpl(fields, metaValueFactory, this);
- }
-
- /**
- * Get the property name.
- *
- * @param property managed property
- * @return property name
- */
- protected String getPropertyName(ManagedProperty property)
- {
- // First look to the mapped name
- String name = property.getMappedName();
- if (name == null)
- property.getName();
- return name;
- }
-
- /**
- *
- * @param methodInfo
- * @param opAnnotation
- * @return the managed operation
- */
- protected ManagedOperation getManagedOperation(MethodInfo methodInfo,
- ManagementOperation opAnnotation, MetaData metaData)
- {
- String name = methodInfo.getName();
- String description = opAnnotation.description();
- Impact impact = opAnnotation.impact();
- ManagementParameter[] params = opAnnotation.params();
- ParameterInfo[] paramInfo = methodInfo.getParameters();
- ArrayList<ManagedParameter> mparams = new ArrayList<ManagedParameter>();
- Class<? extends ManagedParameterConstraintsPopulatorFactory> opConstraintsFactor = opAnnotation.constraintsFactory();
-
- // The op return type
- MetaMapper[] returnTypeMapper = {null};
- MetaType returnType = getMetaType(methodInfo, methodInfo.getReturnType(), metaData, true, returnTypeMapper);
-
- // Process the op parameters
- if( paramInfo != null )
- {
- for(int i = 0; i < paramInfo.length; i ++)
- {
- ParameterInfo pinfo = paramInfo[i];
- String pname = pinfo.getName();
- String pdescription = null;
- ManagementParameter mpa = null;
- // Look to ManagementParameter for info
- if (i < params.length)
- {
- mpa = params[i];
- if (mpa.name().equals(AnnotationDefaults.EMPTY_STRING) == false)
- pname = mpa.name();
- if (mpa.description().equals(AnnotationDefaults.EMPTY_STRING) == false)
- pdescription = mpa.description();
- }
- // Generate a name if there is none
- if (pname == null)
- pname = "arg#" + i;
- Fields fields = new DefaultFieldsImpl(pname);
- if (pdescription != null)
- fields.setField(Fields.DESCRIPTION, pdescription);
- MetaMapper[] paramMapper = {null};
- MetaType metaType = getMetaType(pinfo, pinfo.getParameterType(), metaData, true, paramMapper);
- fields.setField(Fields.META_TYPE, metaType);
- // Delegate others (legal values, min/max etc.) to the constraints factory
- try
- {
- Class<? extends ManagedParameterConstraintsPopulatorFactory> factoryClass = opConstraintsFactor;
- if (factoryClass == ManagementParameter.NULL_CONSTRAINTS.class)
- {
- if (mpa != null)
- factoryClass = mpa.constraintsFactory();
- }
- ManagedParameterConstraintsPopulatorFactory factory = factoryClass.newInstance();
- ManagedParameterConstraintsPopulator populator = factory.newInstance();
- if (populator != null)
- populator.populateManagedParameter(name, pinfo, fields);
- }
- catch(Exception e)
- {
- log.debug("Failed to populate constraints for: "+pinfo, e);
- }
-
- ManagedParameterImpl mp = new ManagedParameterImpl(fields);
- if(paramMapper[0] != null)
- mp.setTransientAttachment(MetaMapper.class.getName(), paramMapper[0]);
- mparams.add(mp);
- }
- }
- ManagedParameter[] parameters = new ManagedParameter[mparams.size()];
- mparams.toArray(parameters);
-
- ManagedOperationImpl op = new ManagedOperationImpl(name, description, impact, parameters, returnType);
- if(returnTypeMapper[0] != null)
- op.setTransientAttachment(MetaMapper.class.getName(), returnTypeMapper[0]);
- return op;
- }
-
- /**
- * Get the MetaType for info by looking for MetaMapping/MetaMappingFactory
- * annotations in addition to the info type.
- *
- * @param methodInfo
- * @param metaData
- * @return the MetaType for info's type
- */
- protected MetaType getMetaType(AnnotatedInfo info, TypeInfo infoType, MetaData metaData,
- boolean useTypeFactory, MetaMapper[] mapperReturn)
- {
- MetaType returnType = null;
- // First look for meta mappings
- MetaMapper<?> metaMapper = null;
- MetaMapping metaMapping = getAnnotation(MetaMapping.class, info, metaData);
- MetaMappingFactory metaMappingFactory = getAnnotation(MetaMappingFactory.class, info, metaData);
- if(metaMappingFactory != null)
- {
- Class<? extends MetaMapperFactory<?>> mmfClass = metaMappingFactory.value();
- try
- {
- MetaMapperFactory<?> mmf = mmfClass.newInstance();
- String[] args = metaMappingFactory.args();
- if(args.length > 0)
- metaMapper = mmf.newInstance(args);
- else
- metaMapper = mmf.newInstance();
- }
- catch(Exception e)
- {
- log.debug("Failed to create MetaMapperFactory: "+metaMappingFactory, e);
- }
- }
- if(metaMapping != null)
- {
- // Use the mapping for the type
- Class<? extends MetaMapper<?>> mapperClass = metaMapping.value();
- try
- {
- metaMapper = mapperClass.newInstance();
- }
- catch(Exception e)
- {
- log.debug("Failed to create MetaMapper: "+metaMapping, e);
- }
- }
- if(metaMapper != null)
- {
- returnType = metaMapper.getMetaType();
- // Return the MetaMapper
- if(mapperReturn != null && mapperReturn.length > 0)
- mapperReturn[0] = metaMapper;
- }
-
- if(returnType == null && useTypeFactory)
- {
- // Use the type factory to convert the info type
- returnType = metaTypeFactory.resolve(infoType);
- }
- return returnType;
- }
-
- /**
- * Get the builder for a class
- *
- * @param clazz the class
- * @return the builder
- */
- protected ManagedObjectBuilder getBuilder(Class<?> clazz)
- {
- synchronized (builders)
- {
- ManagedObjectBuilder builder = builders.get(clazz);
- if (builder != null)
- return builder;
- }
- return this;
- }
-
- /**
- * Get the instance factory for a class
- *
- * @param clazz the class
- * @return the InstanceClassFactory
- */
- @SuppressWarnings("unchecked")
- public <X> InstanceClassFactory<X> getInstanceClassFactory(Class<X> clazz,
- MetaData metaData)
- {
- InstanceClassFactory defaultFactory = defaultInstanceFactory;
- if(metaData != null)
- {
- InstanceClassFactory mdrFactory = metaData.getMetaData(InstanceClassFactory.class);
- if(mdrFactory != null)
- defaultFactory = mdrFactory;
- }
- InstanceClassFactory<X> factory = (InstanceClassFactory<X>)
- Utility.getInstanceClassFactory(clazz, instanceFactories,
- defaultFactory);
- return factory;
- }
-
- /**
- * Get the populator for a class
- *
- * @param clazz the class
- * @return the populator
- */
- @SuppressWarnings("unchecked")
- protected <X> ManagedObjectPopulator<X> getPopulator(Class<X> clazz)
- {
- ManagedObjectBuilder builder = getBuilder(clazz);
- if (builder instanceof ManagedObjectPopulator)
- return (ManagedObjectPopulator) builder;
- ManagedObjectPopulator<X> mop = (ManagedObjectPopulator<X>) defaultManagedObjectPopulator;
- return mop;
- }
-
- protected Collection<?> getAsCollection(Object value)
- {
- if( value.getClass().isArray() )
- return Arrays.asList(value);
- else if (value instanceof Collection)
- return Collection.class.cast(value);
- return null;
- }
-
- /**
- * Look for ctor(Fields)
- * @param factory - the ManagedProperty implementation class
- * @param fields - the fields to pass to the ctor
- * @return the managed property
- */
- protected ManagedProperty getManagedProperty(Class<? extends ManagedProperty> factory, Fields fields)
- {
- return createManagedProperty(factory, fields);
- }
-
- protected <X extends Annotation> X getAnnotation(Class<X> annotationType,
- AnnotatedInfo info, MetaData metaData)
- {
- X annotation = null;
- if(metaData != null)
- {
- annotation = metaData.getAnnotation(annotationType);
- if(annotation == null && info instanceof MethodInfo)
- {
- MethodInfo mi = (MethodInfo) info;
- Signature mis = Signature.getSignature(mi);
- MetaData imetaData = metaData.getComponentMetaData(mis);
- if (imetaData != null)
- annotation = imetaData.getAnnotation(annotationType);
- }
- if (annotation == null && info instanceof PropertyInfo)
- {
- PropertyInfo pi = (PropertyInfo) info;
- if(pi.getGetter() != null)
- {
- Signature mis = new MethodSignature(pi.getGetter());
- MetaData imetaData = metaData.getComponentMetaData(mis);
- if (imetaData != null)
- annotation = imetaData.getAnnotation(annotationType);
- }
- if(annotation == null && pi.getSetter() != null)
- {
- Signature mis = new MethodSignature(pi.getSetter());
- MetaData imetaData = metaData.getComponentMetaData(mis);
- if (imetaData != null)
- annotation = imetaData.getAnnotation(annotationType);
- }
- if(annotation == null && pi.getFieldInfo() != null)
- {
- Signature fis = new FieldSignature(pi.getFieldInfo());
- MetaData imetaData = metaData.getComponentMetaData(fis);
- if (imetaData != null)
- annotation = imetaData.getAnnotation(annotationType);
- }
- }
- if(annotation != null)
- log.trace("Loaded "+annotationType+" from MetaData");
- }
- if(annotation == null)
- annotation = info.getUnderlyingAnnotation(annotationType);
- return annotation;
- }
-
- /**
- * Build up a BeanInfo from the interface class and all interfaces it
- * implements.
- *
- * @param iface - the interface for the managed object
- * @return the full BeanInfo for the iface
- */
- protected BeanInfo getBeanInfo(Class<?> iface)
- {
- BeanInfo ifaceBI = configuration.getBeanInfo(iface);
- Class<?>[] superIfaces = iface.getInterfaces();
- if(superIfaces != null && superIfaces.length > 0)
- {
- // Combine all properties
- Set<PropertyInfo> allProps = new HashSet<PropertyInfo>(ifaceBI.getProperties());
- // Combine all operations
- Set<MethodInfo> allMethods = new HashSet<MethodInfo>(ifaceBI.getMethods());
- for(Class<?> superIface : superIfaces)
- {
- BeanInfo cBI = configuration.getBeanInfo(superIface);
- Set<PropertyInfo> props = cBI.getProperties();
- if(props != null)
- allProps.addAll(props);
- Set<MethodInfo> methods = cBI.getMethods();
- if(methods != null)
- allMethods.addAll(methods);
- }
-
- ifaceBI.setProperties(allProps);
- ifaceBI.setMethods(allMethods);
- }
- return ifaceBI;
- }
-}
Copied: projects/jboss-man/tags/2.1.0.CR8/managed/src/main/java/org/jboss/managed/plugins/factory/AbstractManagedObjectFactory.java (from rev 87524, projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/plugins/factory/AbstractManagedObjectFactory.java)
===================================================================
--- projects/jboss-man/tags/2.1.0.CR8/managed/src/main/java/org/jboss/managed/plugins/factory/AbstractManagedObjectFactory.java (rev 0)
+++ projects/jboss-man/tags/2.1.0.CR8/managed/src/main/java/org/jboss/managed/plugins/factory/AbstractManagedObjectFactory.java 2009-04-19 02:32:29 UTC (rev 87526)
@@ -0,0 +1,1234 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2007, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.managed.plugins.factory;
+
+import java.io.Serializable;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.WeakHashMap;
+
+import org.jboss.beans.info.spi.BeanInfo;
+import org.jboss.beans.info.spi.PropertyInfo;
+import org.jboss.config.spi.Configuration;
+import org.jboss.logging.Logger;
+import org.jboss.managed.api.Fields;
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.api.ManagedOperation;
+import org.jboss.managed.api.ManagedParameter;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.managed.api.MutableManagedObject;
+import org.jboss.managed.api.ManagedOperation.Impact;
+import org.jboss.managed.api.annotation.ActivationPolicy;
+import org.jboss.managed.api.annotation.AnnotationDefaults;
+import org.jboss.managed.api.annotation.ConstraintsPopulatorFactory;
+import org.jboss.managed.api.annotation.DefaultValueBuilderFactory;
+import org.jboss.managed.api.annotation.FieldsFactory;
+import org.jboss.managed.api.annotation.ManagementComponent;
+import org.jboss.managed.api.annotation.ManagementConstants;
+import org.jboss.managed.api.annotation.ManagementDeployment;
+import org.jboss.managed.api.annotation.ManagementObject;
+import org.jboss.managed.api.annotation.ManagementObjectID;
+import org.jboss.managed.api.annotation.ManagementObjectRef;
+import org.jboss.managed.api.annotation.ManagementOperation;
+import org.jboss.managed.api.annotation.ManagementParameter;
+import org.jboss.managed.api.annotation.ManagementProperties;
+import org.jboss.managed.api.annotation.ManagementProperty;
+import org.jboss.managed.api.annotation.ManagementPropertyFactory;
+import org.jboss.managed.api.annotation.ManagementRuntimeRef;
+import org.jboss.managed.api.annotation.Masked;
+import org.jboss.managed.api.annotation.RunStateProperty;
+import org.jboss.managed.api.annotation.ViewUse;
+import org.jboss.managed.api.factory.ManagedObjectFactory;
+import org.jboss.managed.api.factory.ManagedObjectDefinition;
+import org.jboss.managed.plugins.DefaultFieldsImpl;
+import org.jboss.managed.plugins.ManagedObjectImpl;
+import org.jboss.managed.plugins.ManagedOperationImpl;
+import org.jboss.managed.plugins.ManagedParameterImpl;
+import org.jboss.managed.plugins.WritethroughManagedPropertyImpl;
+import org.jboss.managed.spi.factory.InstanceClassFactory;
+import org.jboss.managed.spi.factory.ManagedObjectBuilder;
+import org.jboss.managed.spi.factory.ManagedObjectPopulator;
+import org.jboss.managed.spi.factory.ManagedParameterConstraintsPopulator;
+import org.jboss.managed.spi.factory.ManagedParameterConstraintsPopulatorFactory;
+import org.jboss.managed.spi.factory.ManagedPropertyConstraintsPopulator;
+import org.jboss.managed.spi.factory.ManagedPropertyConstraintsPopulatorFactory;
+import org.jboss.metadata.spi.MetaData;
+import org.jboss.metadata.spi.signature.FieldSignature;
+import org.jboss.metadata.spi.signature.MethodSignature;
+import org.jboss.metadata.spi.signature.Signature;
+import org.jboss.metatype.api.annotations.MetaMapping;
+import org.jboss.metatype.api.annotations.MetaMappingFactory;
+import org.jboss.metatype.api.types.ArrayMetaType;
+import org.jboss.metatype.api.types.CollectionMetaType;
+import org.jboss.metatype.api.types.GenericMetaType;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.MetaTypeFactory;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.MetaValueFactory;
+import org.jboss.metatype.plugins.values.defaults.BigDecimalDefaultValueBuilder;
+import org.jboss.metatype.plugins.values.defaults.BigIntegerDefaultValueBuilder;
+import org.jboss.metatype.plugins.values.defaults.BooleanDefaultValueBuilder;
+import org.jboss.metatype.plugins.values.defaults.BooleanPrimitiveDefaultValueBuilder;
+import org.jboss.metatype.plugins.values.defaults.ByteDefaultValueBuilder;
+import org.jboss.metatype.plugins.values.defaults.BytePrimitiveDefaultValueBuilder;
+import org.jboss.metatype.plugins.values.defaults.CharDefaultValueBuilder;
+import org.jboss.metatype.plugins.values.defaults.CharPrimitiveDefaultValueBuilder;
+import org.jboss.metatype.plugins.values.defaults.DoubleDefaultValueBuilder;
+import org.jboss.metatype.plugins.values.defaults.DoublePrimitiveDefaultValueBuilder;
+import org.jboss.metatype.plugins.values.defaults.FloatDefaultValueBuilder;
+import org.jboss.metatype.plugins.values.defaults.FloatPrimitiveDefaultValueBuilder;
+import org.jboss.metatype.plugins.values.defaults.IntDefaultValueBuilder;
+import org.jboss.metatype.plugins.values.defaults.IntPrimitiveDefaultValueBuilder;
+import org.jboss.metatype.plugins.values.defaults.LongDefaultValueBuilder;
+import org.jboss.metatype.plugins.values.defaults.LongPrimitiveDefaultValueBuilder;
+import org.jboss.metatype.plugins.values.defaults.PropertiesDefaultValueBuilder;
+import org.jboss.metatype.plugins.values.defaults.ShortDefaultValueBuilder;
+import org.jboss.metatype.plugins.values.defaults.ShortPrimitiveDefaultValueBuilder;
+import org.jboss.metatype.plugins.values.defaults.StringDefaultValueBuilder;
+import org.jboss.metatype.plugins.values.defaults.StringObjectNameDefaultBuilder;
+import org.jboss.metatype.spi.values.DefaultValueBuilder;
+import org.jboss.metatype.spi.values.MetaMapper;
+import org.jboss.metatype.spi.values.MetaMapperFactory;
+import org.jboss.reflect.spi.AnnotatedInfo;
+import org.jboss.reflect.spi.ClassInfo;
+import org.jboss.reflect.spi.MethodInfo;
+import org.jboss.reflect.spi.ParameterInfo;
+import org.jboss.reflect.spi.TypeInfo;
+
+/**
+ * The base ManagedObjectFactory implementation.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class AbstractManagedObjectFactory extends ManagedObjectFactory
+ implements ManagedObjectBuilder
+{
+ private static final Logger log = Logger.getLogger(AbstractManagedObjectFactory.class);
+
+ /** The configuration */
+ private static final Configuration configuration = PropertyConfigurationAccess.getConfiguration();
+
+ /** The managed object meta type */
+ public static final GenericMetaType MANAGED_OBJECT_META_TYPE = new GenericMetaType(ManagedObject.class.getName(), ManagedObject.class.getName());
+
+ /** The meta type factory */
+ private MetaTypeFactory metaTypeFactory = MetaTypeFactory.getInstance();
+
+ /** The meta value factory */
+ private MetaValueFactory metaValueFactory = MetaValueFactory.getInstance();
+ /** A default InstanceClassFactory used when there is no explicit ICF for a given class */
+ private InstanceClassFactory<?> defaultInstanceFactory;
+ /** A default ManagedObjectPopulator used when there is no explicit ManagedObjectBuilder for a given class */
+ private ManagedObjectPopulator<?> defaultManagedObjectPopulator;
+
+ /** The managed object builders */
+ private Map<Class<?>, ManagedObjectBuilder> builders = new WeakHashMap<Class<?>, ManagedObjectBuilder>();
+
+ /** The instance to class factories */
+ private Map<Class<?>, InstanceClassFactory<?>> instanceFactories = new WeakHashMap<Class<?>, InstanceClassFactory<?>>();
+
+ /** The default value builders */
+ private Map<MetaType, DefaultValueBuilder> defaultBuilders = new HashMap<MetaType, DefaultValueBuilder>();
+
+ /**
+ * 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);
+ initDefaultValueBuilders();
+ }
+ /**
+ * 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;
+ initDefaultValueBuilders();
+ }
+
+ /**
+ * Add managed object definition.
+ *
+ * @param definition the MO definition
+ */
+ public void addManagedObjectDefinition(ManagedObjectDefinition definition)
+ {
+ if (definition == null || definition.isValid() == false)
+ throw new IllegalArgumentException("Invalid MO definition: " + definition);
+
+ setBuilder(definition.getType(), definition.getBuilder());
+ }
+
+ /**
+ * Remove managed object definition.
+ *
+ * @param definition the MO definition
+ */
+ public void removeManagedObjectDefinition(ManagedObjectDefinition definition)
+ {
+ if (definition == null)
+ return;
+
+ setBuilder(definition.getType(), null);
+ }
+
+ public void addDefaultValueBuilder(DefaultValueBuilder builder)
+ {
+ if(builder == null)
+ throw new IllegalArgumentException("Null DefaultValueBuilder");
+ setDefaultsBuilder(builder.getType(), builder);
+ }
+ public void setDefaultsBuilder(MetaType type, DefaultValueBuilder builder)
+ {
+ synchronized (defaultBuilders)
+ {
+ if (builder == null)
+ defaultBuilders.remove(type);
+ else
+ defaultBuilders.put(type, builder);
+ }
+ }
+ public void removeDefaltValueBuilder(DefaultValueBuilder builder)
+ {
+ if (builder == null)
+ return;
+ setDefaultsBuilder(builder.getType(), null);
+ }
+
+ /**
+ * Get the configuration
+ *
+ * @return the configuration
+ */
+ public Configuration getConfiguration()
+ {
+ return configuration;
+ }
+
+
+ public MetaTypeFactory getMetaTypeFactory()
+ {
+ return metaTypeFactory;
+ }
+
+ public void setMetaTypeFactory(MetaTypeFactory metaTypeFactory)
+ {
+ this.metaTypeFactory = metaTypeFactory;
+ }
+
+ public MetaValueFactory getMetaValueFactory()
+ {
+ return metaValueFactory;
+ }
+
+ public void setMetaValueFactory(MetaValueFactory metaValueFactory)
+ {
+ this.metaValueFactory = metaValueFactory;
+ }
+
+ public Map<Class<?>, ManagedObjectBuilder> getBuilders()
+ {
+ return builders;
+ }
+
+ public void setBuilders(Map<Class<?>, ManagedObjectBuilder> builders)
+ {
+ this.builders = builders;
+ }
+
+ public Map<Class<?>, InstanceClassFactory<?>> getInstanceFactories()
+ {
+ return instanceFactories;
+ }
+
+ public void setInstanceFactories(
+ Map<Class<?>, InstanceClassFactory<?>> instanceFactories)
+ {
+ this.instanceFactories = instanceFactories;
+ }
+
+ /**
+ * Get the default InstanceClassFactory
+ * @return the current default InstanceClassFactory
+ */
+ public InstanceClassFactory<?> getDefaultInstanceFactory()
+ {
+ return defaultInstanceFactory;
+ }
+ /**
+ * Set the default InstanceClassFactory. This is used when there is not
+ * match an exact match by the {@linkplain #getInstanceClassFactory(Class)}
+ * factory method.
+ *
+ * @param defaultInstanceFactory the default InstanceClassFactory to fall
+ * back to. It may be null if no default should be used.
+ */
+ public void setDefaultInstanceFactory(
+ InstanceClassFactory<? extends Serializable> defaultInstanceFactory)
+ {
+ this.defaultInstanceFactory = defaultInstanceFactory;
+ }
+
+
+ public ManagedObjectPopulator<?> getDefaultManagedObjectPopulator()
+ {
+ return defaultManagedObjectPopulator;
+ }
+
+ /**
+ * A default implementation of ManagedObjectPopulator that is used when
+ * there is no ManagedObjectBuilder registered for a given type.
+ * @see #getBuilder(Class)
+ * @param defaultManagedObjectPopulator
+ */
+ public void setDefaultManagedObjectPopulator(
+ ManagedObjectPopulator<? extends Serializable> defaultManagedObjectPopulator)
+ {
+ this.defaultManagedObjectPopulator = defaultManagedObjectPopulator;
+ }
+
+ @Override
+ public <T> ManagedObject createManagedObject(Class<T> clazz, MetaData metaData)
+ {
+ if (clazz == null)
+ throw new IllegalArgumentException("Null class");
+
+ ManagedObject result = createSkeletonManagedObject(clazz, metaData);
+ ManagedObjectPopulator<T> populator = getPopulator(clazz);
+ populator.createObject(result, clazz, metaData);
+
+ return result;
+ }
+
+ public ManagedObject initManagedObject(Object instance, Class<?> instanceType,
+ MetaData metaData, String name, String nameType)
+ {
+ if (instance == null)
+ throw new IllegalArgumentException("instance cannot be null");
+
+ Class<?> clazz = instance.getClass();
+ InstanceClassFactory icf = defaultInstanceFactory;
+ if(instanceType != null && instanceType != clazz)
+ icf = getInstanceClassFactory(instanceType, metaData);
+ if(icf == defaultInstanceFactory)
+ icf = getInstanceClassFactory(clazz, metaData);
+
+ Class<Object> moClass;
+ try
+ {
+ moClass = icf.getManagedObjectClass(instance);
+ }
+ catch(ClassNotFoundException e)
+ {
+ log.debug("Failed to load class for ManagedObject", e);
+ return null;
+ }
+ if(moClass == null)
+ {
+ log.debug("ICF returned null class: "+instance);
+ return null;
+ }
+
+ ManagedObject result = createSkeletonManagedObject(moClass, metaData);
+ if (result == null)
+ {
+ log.debug("Null ManagedObject created for: "+moClass);
+ return null;
+ }
+ log.debug("Created skeleton ManagedObject: "+result);
+
+ if(result instanceof MutableManagedObject)
+ {
+ MutableManagedObject mmo = (MutableManagedObject) result;
+ ManagedObjectPopulator<Object> populator = getPopulator(moClass);
+ populator.populateManagedObject(mmo, instance, metaData);
+ }
+
+ return result;
+ }
+
+ @Override
+ public void setBuilder(Class<?> clazz, ManagedObjectBuilder builder)
+ {
+ synchronized (builders)
+ {
+ if (builder == null)
+ builders.remove(clazz);
+ else
+ builders.put(clazz, builder);
+ }
+ }
+
+ @Override
+ public <T> void setInstanceClassFactory(Class<T> clazz, InstanceClassFactory<T> factory)
+ {
+ synchronized (instanceFactories)
+ {
+ if (factory == null)
+ {
+ instanceFactories.remove(clazz);
+ log.debug("Removed ICF for: "+clazz);
+ }
+ else
+ {
+ instanceFactories.put(clazz, factory);
+ log.debug("Set ICF for: "+clazz+", to: "+factory);
+ }
+ }
+ }
+
+ /**
+ * Create a skeleton managed object
+ *
+ * @param <T> the type
+ * @param clazz the clazz
+ * @return the skeleton managed object, null if clazz is not
+ * marked as a ManagementObject.
+ * {@linkplain ManagementObject}
+ */
+ protected <T> ManagedObject createSkeletonManagedObject(Class<T> clazz, MetaData metaData)
+ {
+ if (clazz == null)
+ throw new IllegalArgumentException("Null class");
+
+ ManagedObjectBuilder builder = getBuilder(clazz);
+ return builder.buildManagedObject(clazz, metaData);
+ }
+
+ /**
+ * The ManagedObjectBuilder.buildManagedObject implementation. This is based
+ * on the org.jboss.managed.api.annotation.* package annotations.
+ * @param clazz the attachment class
+ * @param metaData - the optional metadata repository accessor used to query
+ * for management annotation overrides/additions to the clazz
+ * @return the ManagementObject if clazz is properly annotated, null if
+ * it does not have a ManagementObject annotation on the class or metaData.
+ * The BeanInfo used by this method is stored as a transient attachment
+ * under the BeanInfo.class.getName() ket.
+ */
+ @SuppressWarnings("unchecked")
+ public ManagedObject buildManagedObject(Class<?> clazz, MetaData metaData)
+ {
+ boolean trace = log.isTraceEnabled();
+ BeanInfo beanInfo = configuration.getBeanInfo(clazz);
+ ClassInfo classInfo = beanInfo.getClassInfo();
+
+ ManagementObject managementObject = getAnnotation(ManagementObject.class, classInfo, metaData);
+ if( managementObject == null )
+ {
+ if (trace)
+ log.trace("No ManagementObject annotation, skipping ManagedObject for class: "+clazz);
+ // Skip the ManagedObject creation
+ return null;
+ }
+
+ // If a targetInterface exists, rebuild the BeanInfo from that
+ Class<?> targetInterface = managementObject.targetInterface();
+ if(targetInterface != Object.class)
+ {
+ beanInfo = getBeanInfo(targetInterface);
+ classInfo = beanInfo.getClassInfo();
+ }
+ HashMap<String, Annotation> moAnnotations = new HashMap<String, Annotation>();
+ moAnnotations.put(ManagementObject.class.getName(), managementObject);
+ ManagementDeployment mnagementDeployment = getAnnotation(ManagementDeployment.class, classInfo, metaData);
+ if(mnagementDeployment != null)
+ moAnnotations.put(ManagementDeployment.class.getName(), mnagementDeployment);
+ ManagementObjectID moID = getAnnotation(ManagementObjectID.class, classInfo, metaData);
+ if (moID != null)
+ moAnnotations.put(ManagementObjectID.class.getName(), moID);
+
+ // Process the ManagementObject fields
+ boolean isRuntime = managementObject.isRuntime();
+ String name = classInfo.getName();
+ String nameType = null;
+ String attachmentName = classInfo.getName();
+ Class<? extends Fields> moFieldsFactory = null;
+ ConstraintsPopulatorFactory moCPF = null;
+ Class<? extends ManagedPropertyConstraintsPopulatorFactory> moConstraintsFactory = null;
+ Class<? extends ManagedProperty> moPropertyFactory = null;
+ if (managementObject != null)
+ {
+ name = managementObject.name();
+ if (name.length() == 0 || name.equals(ManagementConstants.GENERATED))
+ name = classInfo.getName();
+ nameType = managementObject.type();
+ if (nameType.length() == 0)
+ nameType = null;
+ attachmentName = managementObject.attachmentName();
+ if (attachmentName.length() == 0)
+ attachmentName = classInfo.getName();
+ // Check for a component specification
+ ManagementComponent mc = null;
+ if (metaData != null )
+ mc = metaData.getAnnotation(ManagementComponent.class);
+ if (mc == null)
+ mc = managementObject.componentType();
+ // Work around JBMDR-51 by checking type/subtype
+ // if (mc.equals(AnnotationDefaults.COMP_TYPE) == false)
+ if (mc.type().length() > 0 || mc.subtype().length() > 0)
+ {
+ log.debug("ManagedObject("+name+") is ManagedComponent type: "+mc);
+ moAnnotations.put(ManagementComponent.class.getName(), mc);
+ }
+ // ManagementObject level default factory classes
+ FieldsFactory ff = getAnnotation(FieldsFactory.class, classInfo, metaData);
+ if(ff != null)
+ moFieldsFactory = ff.value();
+ moCPF = getAnnotation(ConstraintsPopulatorFactory.class, classInfo, metaData);
+ if(moCPF != null)
+ moConstraintsFactory = moCPF.value();
+ ManagementPropertyFactory mpf = getAnnotation(ManagementPropertyFactory.class, classInfo, metaData);
+ if(mpf != null)
+ moPropertyFactory = mpf.value();
+ }
+
+ if (trace)
+ {
+ log.trace("Building MangedObject(name="+name+",nameType="+nameType
+ +",attachmentName="+attachmentName+",isRuntime="+isRuntime+")");
+ }
+
+ ManagementProperties propertyType = ManagementProperties.ALL;
+ Set<String> classProperties = null;
+ if (managementObject != null)
+ {
+ propertyType = managementObject.properties();
+ if(propertyType == ManagementProperties.CLASS || propertyType == ManagementProperties.CLASS_AND_EXPLICIT)
+ {
+ classProperties = new HashSet<String>();
+ for(ManagementProperty mp : managementObject.classProperties())
+ {
+ if(mp.name().length() > 0)
+ classProperties.add(mp.name());
+ if(mp.mappedName().length() > 0)
+ classProperties.add(mp.mappedName());
+ }
+ }
+ }
+
+ // Build the ManagedProperties
+ Set<ManagedProperty> properties = new HashSet<ManagedProperty>();
+
+ Set<PropertyInfo> propertyInfos = beanInfo.getProperties();
+ if (propertyInfos != null && propertyInfos.isEmpty() == false)
+ {
+ for (PropertyInfo propertyInfo : propertyInfos)
+ {
+ // Ignore the "class" property
+ if ("class".equals(propertyInfo.getName()))
+ continue;
+
+ ManagementProperty managementProperty = getAnnotation(ManagementProperty.class, propertyInfo, metaData);
+ ManagementObjectID id = getAnnotation(ManagementObjectID.class, propertyInfo, metaData);
+ ManagementObjectRef ref = getAnnotation(ManagementObjectRef.class, propertyInfo, metaData);
+ ManagementRuntimeRef runtimeRef = getAnnotation(ManagementRuntimeRef.class, propertyInfo, metaData);
+ RunStateProperty rsp = getAnnotation(RunStateProperty.class, propertyInfo, metaData);
+ Masked masked = getAnnotation(Masked.class, propertyInfo, metaData);
+ DefaultValueBuilderFactory defaultsFactory = getAnnotation(DefaultValueBuilderFactory.class, propertyInfo, metaData);
+ HashMap<String, Annotation> propAnnotations = new HashMap<String, Annotation>();
+ if (managementProperty != null)
+ propAnnotations.put(ManagementProperty.class.getName(), managementProperty);
+ if (id != null)
+ {
+ propAnnotations.put(ManagementObjectID.class.getName(), id);
+ // This overrides the MO nameType
+ nameType = id.type();
+ }
+ if (ref != null)
+ propAnnotations.put(ManagementObjectRef.class.getName(), ref);
+ if (runtimeRef != null)
+ propAnnotations.put(ManagementRuntimeRef.class.getName(), runtimeRef);
+ if (rsp != null)
+ propAnnotations.put(RunStateProperty.class.getName(), rsp);
+ if (masked != null)
+ propAnnotations.put(Masked.class.getName(), masked);
+
+ // Check whether this property should be included
+ boolean includeProperty = false;
+ switch(propertyType)
+ {
+ // Only if the property as a ManagementProperty
+ case EXPLICIT:
+ includeProperty = managementProperty != null &&
+ (managementProperty.ignored() == false);
+ break;
+ // Only if the property is listed in the classProperties
+ case CLASS:
+ includeProperty = classProperties.contains(propertyInfo.getName());
+ break;
+ // Only if the property is listed in the classProperties
+ case CLASS_AND_EXPLICIT:
+ includeProperty = classProperties.contains(propertyInfo.getName())
+ || (managementProperty != null && managementProperty.ignored() == false);
+ break;
+ // Any property that is not ignored
+ case ALL:
+ includeProperty = managementProperty == null
+ || managementProperty.ignored() == false;
+ break;
+ }
+
+ if (includeProperty)
+ {
+ Fields fields = null;
+ Class<? extends Fields> factory = moFieldsFactory;
+ FieldsFactory ff = getAnnotation(FieldsFactory.class, propertyInfo, metaData);
+ if(ff != null)
+ factory = ff.value();
+ if (factory != null)
+ {
+ try
+ {
+ fields = factory.newInstance();
+ }
+ catch (Exception e)
+ {
+ log.debug("Failed to created Fields", e);
+ }
+ }
+ if (fields == null)
+ fields = new DefaultFieldsImpl();
+
+ if( propertyInfo instanceof Serializable )
+ {
+ Serializable info = Serializable.class.cast(propertyInfo);
+ fields.setField(Fields.PROPERTY_INFO, info);
+ }
+
+ String propertyName = propertyInfo.getName();
+ if (managementProperty != null)
+ propertyName = managementProperty.name();
+ if( propertyName.length() == 0 )
+ propertyName = propertyInfo.getName();
+ fields.setField(Fields.NAME, propertyName);
+
+ // This should probably always the the propertyInfo name?
+ String mappedName = propertyInfo.getName();
+ if (managementProperty != null)
+ mappedName = managementProperty.mappedName();
+ if( mappedName.length() == 0 )
+ mappedName = propertyInfo.getName();
+ fields.setField(Fields.MAPPED_NAME, mappedName);
+
+ String description = ManagementConstants.GENERATED;
+ if (managementProperty != null)
+ description = managementProperty.description();
+ if (description.equals(ManagementConstants.GENERATED))
+ description = propertyName;
+ fields.setField(Fields.DESCRIPTION, description);
+
+ if (trace)
+ {
+ log.trace("Building MangedProperty(name="+propertyName
+ +",mappedName="+mappedName
+ +") ,annotations="+propAnnotations);
+ }
+
+ boolean mandatory = false;
+ if (managementProperty != null)
+ mandatory = managementProperty.mandatory();
+ if (mandatory)
+ fields.setField(Fields.MANDATORY, Boolean.TRUE);
+
+ boolean readOnly = propertyInfo.isWritable() == false;
+ if (readOnly == false && managementProperty != null)
+ readOnly = managementProperty.readOnly();
+ if (readOnly)
+ fields.setField(Fields.READ_ONLY, Boolean.TRUE);
+
+ boolean managed = false;
+ if (managementProperty != null)
+ managed = managementProperty.managed();
+ // View Use
+ if (managementProperty != null)
+ {
+ ViewUse[] use = managementProperty.use();
+ fields.setField(Fields.VIEW_USE, use);
+ }
+ // ActivationPolicy
+ ActivationPolicy apolicy = ActivationPolicy.IMMEDIATE;
+ if (managementProperty != null)
+ {
+ apolicy = managementProperty.activationPolicy();
+ }
+ fields.setField(Fields.ACTIVATION_POLICY, apolicy);
+ // The managed property type
+ MetaMapper[] mapperReturn = {null};
+ MetaType metaType = this.getMetaType(propertyInfo, propertyInfo.getType(), metaData, false, mapperReturn);
+
+ // Determine meta type based on property type
+ if(metaType == null)
+ {
+ if (managed)
+ {
+ TypeInfo typeInfo = propertyInfo.getType();
+ if(typeInfo.isArray())
+ metaType = new ArrayMetaType(1, MANAGED_OBJECT_META_TYPE);
+ else if (typeInfo.isCollection())
+ metaType = new CollectionMetaType(typeInfo.getName(), MANAGED_OBJECT_META_TYPE);
+ else
+ metaType = MANAGED_OBJECT_META_TYPE;
+ }
+ else
+ {
+ metaType = metaTypeFactory.resolve(propertyInfo.getType());
+ }
+ }
+ fields.setField(Fields.META_TYPE, metaType);
+
+ // Default value
+ if(managementProperty != null)
+ {
+ String defaultValue = managementProperty.defaultValue();
+ if(defaultValue.length() > 0)
+ {
+ try
+ {
+ // Check for a DefaultValueBuilderFactory
+ DefaultValueBuilder builder = null;
+ if(defaultsFactory != null)
+ {
+ Class<? extends DefaultValueBuilder> factoryClass = defaultsFactory.value();
+ builder = factoryClass.newInstance();
+ }
+ // Lookup the builder by metaType
+ if(builder == null)
+ {
+ builder = defaultBuilders.get(metaType);
+ }
+ if(builder != null)
+ {
+ MetaValue defaultMV = builder.buildMetaValue(defaultValue);
+ if(defaultMV != null)
+ fields.setField(Fields.DEFAULT_VALUE, defaultMV);
+ }
+ else
+ {
+ log.warn("Failed to find DefaultValueBuilder for type: "+metaType);
+ }
+ }
+ catch(Exception e)
+ {
+ log.warn("Failed to create default value for: "+propertyInfo, e);
+ }
+ }
+ }
+
+ // Property annotations
+ if (propAnnotations.isEmpty() == false)
+ fields.setField(Fields.ANNOTATIONS, propAnnotations);
+
+ // Delegate others (legal values, min/max etc.) to the constraints factory
+ try
+ {
+ Class<? extends ManagedPropertyConstraintsPopulatorFactory> factoryClass = moConstraintsFactory;
+ ConstraintsPopulatorFactory cpf = getAnnotation(ConstraintsPopulatorFactory.class, propertyInfo, metaData);
+ if(cpf != null)
+ factoryClass = cpf.value();
+ else
+ cpf = moCPF;
+ if(factoryClass != null)
+ {
+ ManagedPropertyConstraintsPopulatorFactory mpcpf = factoryClass.newInstance();
+ ManagedPropertyConstraintsPopulator populator = mpcpf.newInstance(cpf.min(), cpf.max(), cpf.legalValues(), cpf.args());
+ if (populator != null)
+ populator.populateManagedProperty(clazz, propertyInfo, fields);
+ }
+ }
+ catch(Exception e)
+ {
+ log.debug("Failed to populate constraints for: "+propertyInfo, e);
+ }
+
+ ManagedProperty property = null;
+ Class<? extends ManagedProperty> mpClass = moPropertyFactory;
+ ManagementPropertyFactory mpf = getAnnotation(ManagementPropertyFactory.class, propertyInfo, metaData);
+ if (mpf != null)
+ mpClass = mpf.value();
+ if (mpClass != null)
+ property = getManagedProperty(mpClass, fields);
+ // we should have write-through by default
+ // use factory to change this default behavior
+ if (property == null)
+ property = createDefaultManagedProperty(fields);
+ // Pass the MetaMapper as an attachment
+ if (mapperReturn[0] != null)
+ property.setTransientAttachment(MetaMapper.class.getName(), mapperReturn[0]);
+ properties.add(property);
+ }
+ else if (trace)
+ log.trace("Ignoring property: " + propertyInfo);
+ }
+ }
+
+ /* TODO: Operations. In general the bean metadata does not contain
+ operation information.
+ */
+ Set<ManagedOperation> operations = new HashSet<ManagedOperation>();
+
+ Set<MethodInfo> methodInfos = beanInfo.getMethods();
+ if (methodInfos != null && methodInfos.isEmpty() == false)
+ {
+ for (MethodInfo methodInfo : methodInfos)
+ {
+ ManagementOperation managementOp = getAnnotation(ManagementOperation.class, methodInfo, metaData);
+ if (managementOp == null)
+ continue;
+
+ ManagedOperation op = getManagedOperation(methodInfo, managementOp, metaData);
+ operations.add(op);
+ }
+ }
+
+ ManagedObjectImpl result = new ManagedObjectImpl(name, properties);
+ result.setAnnotations(moAnnotations);
+ // Set the component name to name if this is a runtime MO with a name specified
+ if (isRuntime && name.equals(classInfo.getName()) == false)
+ result.setComponentName(name);
+ if (nameType != null)
+ result.setNameType(nameType);
+ if (attachmentName != null)
+ result.setAttachmentName(attachmentName);
+ if (operations.size() > 0 )
+ result.setOperations(operations);
+ for (ManagedProperty property : properties)
+ property.setManagedObject(result);
+ result.setTransientAttachment(BeanInfo.class.getName(), beanInfo);
+ return result;
+ }
+
+ /**
+ * Create default MangedProperty instance.
+ * Override this method for different default.
+ *
+ * @param fields the fields
+ * @return new ManagedProperty instance
+ */
+ protected ManagedProperty createDefaultManagedProperty(Fields fields)
+ {
+ return new WritethroughManagedPropertyImpl(fields, metaValueFactory, this);
+ }
+
+ /**
+ * Get the property name.
+ *
+ * @param property managed property
+ * @return property name
+ */
+ protected String getPropertyName(ManagedProperty property)
+ {
+ // First look to the mapped name
+ String name = property.getMappedName();
+ if (name == null)
+ property.getName();
+ return name;
+ }
+
+ /**
+ *
+ * @param methodInfo
+ * @param opAnnotation
+ * @return the managed operation
+ */
+ protected ManagedOperation getManagedOperation(MethodInfo methodInfo,
+ ManagementOperation opAnnotation, MetaData metaData)
+ {
+ String name = methodInfo.getName();
+ String description = opAnnotation.description();
+ Impact impact = opAnnotation.impact();
+ ManagementParameter[] params = opAnnotation.params();
+ ParameterInfo[] paramInfo = methodInfo.getParameters();
+ ArrayList<ManagedParameter> mparams = new ArrayList<ManagedParameter>();
+ Class<? extends ManagedParameterConstraintsPopulatorFactory> opConstraintsFactor = opAnnotation.constraintsFactory();
+
+ // The op return type
+ MetaMapper[] returnTypeMapper = {null};
+ MetaType returnType = getMetaType(methodInfo, methodInfo.getReturnType(), metaData, true, returnTypeMapper);
+
+ // Process the op parameters
+ if( paramInfo != null )
+ {
+ for(int i = 0; i < paramInfo.length; i ++)
+ {
+ ParameterInfo pinfo = paramInfo[i];
+ String pname = pinfo.getName();
+ String pdescription = null;
+ ManagementParameter mpa = null;
+ // Look to ManagementParameter for info
+ if (i < params.length)
+ {
+ mpa = params[i];
+ if (mpa.name().equals(AnnotationDefaults.EMPTY_STRING) == false)
+ pname = mpa.name();
+ if (mpa.description().equals(AnnotationDefaults.EMPTY_STRING) == false)
+ pdescription = mpa.description();
+ }
+ // Generate a name if there is none
+ if (pname == null)
+ pname = "arg#" + i;
+ Fields fields = new DefaultFieldsImpl(pname);
+ if (pdescription != null)
+ fields.setField(Fields.DESCRIPTION, pdescription);
+ MetaMapper[] paramMapper = {null};
+ MetaType metaType = getMetaType(pinfo, pinfo.getParameterType(), metaData, true, paramMapper);
+ fields.setField(Fields.META_TYPE, metaType);
+ // Delegate others (legal values, min/max etc.) to the constraints factory
+ try
+ {
+ Class<? extends ManagedParameterConstraintsPopulatorFactory> factoryClass = opConstraintsFactor;
+ if (factoryClass == ManagementParameter.NULL_CONSTRAINTS.class)
+ {
+ if (mpa != null)
+ factoryClass = mpa.constraintsFactory();
+ }
+ ManagedParameterConstraintsPopulatorFactory factory = factoryClass.newInstance();
+ ManagedParameterConstraintsPopulator populator = factory.newInstance();
+ if (populator != null)
+ populator.populateManagedParameter(name, pinfo, fields);
+ }
+ catch(Exception e)
+ {
+ log.debug("Failed to populate constraints for: "+pinfo, e);
+ }
+
+ ManagedParameterImpl mp = new ManagedParameterImpl(fields);
+ if(paramMapper[0] != null)
+ mp.setTransientAttachment(MetaMapper.class.getName(), paramMapper[0]);
+ mparams.add(mp);
+ }
+ }
+ ManagedParameter[] parameters = new ManagedParameter[mparams.size()];
+ mparams.toArray(parameters);
+
+ ManagedOperationImpl op = new ManagedOperationImpl(name, description, impact, parameters, returnType);
+ if(returnTypeMapper[0] != null)
+ op.setTransientAttachment(MetaMapper.class.getName(), returnTypeMapper[0]);
+ return op;
+ }
+
+ /**
+ * Get the MetaType for info by looking for MetaMapping/MetaMappingFactory
+ * annotations in addition to the info type.
+ *
+ * @param methodInfo
+ * @param metaData
+ * @return the MetaType for info's type
+ */
+ protected MetaType getMetaType(AnnotatedInfo info, TypeInfo infoType, MetaData metaData,
+ boolean useTypeFactory, MetaMapper[] mapperReturn)
+ {
+ MetaType returnType = null;
+ // First look for meta mappings
+ MetaMapper<?> metaMapper = null;
+ MetaMapping metaMapping = getAnnotation(MetaMapping.class, info, metaData);
+ MetaMappingFactory metaMappingFactory = getAnnotation(MetaMappingFactory.class, info, metaData);
+ if(metaMappingFactory != null)
+ {
+ Class<? extends MetaMapperFactory<?>> mmfClass = metaMappingFactory.value();
+ try
+ {
+ MetaMapperFactory<?> mmf = mmfClass.newInstance();
+ String[] args = metaMappingFactory.args();
+ if(args.length > 0)
+ metaMapper = mmf.newInstance(args);
+ else
+ metaMapper = mmf.newInstance();
+ }
+ catch(Exception e)
+ {
+ log.debug("Failed to create MetaMapperFactory: "+metaMappingFactory, e);
+ }
+ }
+ if(metaMapping != null)
+ {
+ // Use the mapping for the type
+ Class<? extends MetaMapper<?>> mapperClass = metaMapping.value();
+ try
+ {
+ metaMapper = mapperClass.newInstance();
+ }
+ catch(Exception e)
+ {
+ log.debug("Failed to create MetaMapper: "+metaMapping, e);
+ }
+ }
+ if(metaMapper != null)
+ {
+ returnType = metaMapper.getMetaType();
+ // Return the MetaMapper
+ if(mapperReturn != null && mapperReturn.length > 0)
+ mapperReturn[0] = metaMapper;
+ }
+
+ if(returnType == null && useTypeFactory)
+ {
+ // Use the type factory to convert the info type
+ returnType = metaTypeFactory.resolve(infoType);
+ }
+ return returnType;
+ }
+
+ /**
+ * Get the builder for a class
+ *
+ * @param clazz the class
+ * @return the builder
+ */
+ protected ManagedObjectBuilder getBuilder(Class<?> clazz)
+ {
+ synchronized (builders)
+ {
+ ManagedObjectBuilder builder = builders.get(clazz);
+ if (builder != null)
+ return builder;
+ }
+ return this;
+ }
+
+ /**
+ * Get the instance factory for a class
+ *
+ * @param clazz the class
+ * @return the InstanceClassFactory
+ */
+ @SuppressWarnings("unchecked")
+ public <X> InstanceClassFactory<X> getInstanceClassFactory(Class<X> clazz,
+ MetaData metaData)
+ {
+ InstanceClassFactory defaultFactory = defaultInstanceFactory;
+ if(metaData != null)
+ {
+ InstanceClassFactory mdrFactory = metaData.getMetaData(InstanceClassFactory.class);
+ if(mdrFactory != null)
+ defaultFactory = mdrFactory;
+ }
+ InstanceClassFactory<X> factory = (InstanceClassFactory<X>)
+ Utility.getInstanceClassFactory(clazz, instanceFactories,
+ defaultFactory);
+ return factory;
+ }
+
+ /**
+ * Initialize the DefaultValueBuilder map with known implementations
+ */
+ protected void initDefaultValueBuilders()
+ {
+ addDefaultValueBuilder(new BigDecimalDefaultValueBuilder());
+ addDefaultValueBuilder(new BigIntegerDefaultValueBuilder());
+ addDefaultValueBuilder(new DoubleDefaultValueBuilder());
+ addDefaultValueBuilder(new DoublePrimitiveDefaultValueBuilder());
+ addDefaultValueBuilder(new FloatDefaultValueBuilder());
+ addDefaultValueBuilder(new FloatPrimitiveDefaultValueBuilder());
+ addDefaultValueBuilder(new CharDefaultValueBuilder());
+ addDefaultValueBuilder(new CharPrimitiveDefaultValueBuilder());
+ addDefaultValueBuilder(new IntDefaultValueBuilder());
+ addDefaultValueBuilder(new IntPrimitiveDefaultValueBuilder());
+ addDefaultValueBuilder(new ShortDefaultValueBuilder());
+ addDefaultValueBuilder(new ShortPrimitiveDefaultValueBuilder());
+ addDefaultValueBuilder(new LongDefaultValueBuilder());
+ addDefaultValueBuilder(new LongPrimitiveDefaultValueBuilder());
+ addDefaultValueBuilder(new ByteDefaultValueBuilder());
+ addDefaultValueBuilder(new BytePrimitiveDefaultValueBuilder());
+ addDefaultValueBuilder(new BooleanDefaultValueBuilder());
+ addDefaultValueBuilder(new BooleanPrimitiveDefaultValueBuilder());
+ addDefaultValueBuilder(new PropertiesDefaultValueBuilder());
+ addDefaultValueBuilder(new StringDefaultValueBuilder());
+ }
+
+ /**
+ * Get the populator for a class
+ *
+ * @param clazz the class
+ * @return the populator
+ */
+ @SuppressWarnings("unchecked")
+ protected <X> ManagedObjectPopulator<X> getPopulator(Class<X> clazz)
+ {
+ ManagedObjectBuilder builder = getBuilder(clazz);
+ if (builder instanceof ManagedObjectPopulator)
+ return (ManagedObjectPopulator) builder;
+ ManagedObjectPopulator<X> mop = (ManagedObjectPopulator<X>) defaultManagedObjectPopulator;
+ return mop;
+ }
+
+ protected Collection<?> getAsCollection(Object value)
+ {
+ if( value.getClass().isArray() )
+ return Arrays.asList(value);
+ else if (value instanceof Collection)
+ return Collection.class.cast(value);
+ return null;
+ }
+
+ /**
+ * Look for ctor(Fields)
+ * @param factory - the ManagedProperty implementation class
+ * @param fields - the fields to pass to the ctor
+ * @return the managed property
+ */
+ protected ManagedProperty getManagedProperty(Class<? extends ManagedProperty> factory, Fields fields)
+ {
+ return createManagedProperty(factory, fields);
+ }
+
+ protected <X extends Annotation> X getAnnotation(Class<X> annotationType,
+ AnnotatedInfo info, MetaData metaData)
+ {
+ X annotation = null;
+ if(metaData != null)
+ {
+ annotation = metaData.getAnnotation(annotationType);
+ if(annotation == null && info instanceof MethodInfo)
+ {
+ MethodInfo mi = (MethodInfo) info;
+ Signature mis = Signature.getSignature(mi);
+ MetaData imetaData = metaData.getComponentMetaData(mis);
+ if (imetaData != null)
+ annotation = imetaData.getAnnotation(annotationType);
+ }
+ if (annotation == null && info instanceof PropertyInfo)
+ {
+ PropertyInfo pi = (PropertyInfo) info;
+ if(pi.getGetter() != null)
+ {
+ Signature mis = new MethodSignature(pi.getGetter());
+ MetaData imetaData = metaData.getComponentMetaData(mis);
+ if (imetaData != null)
+ annotation = imetaData.getAnnotation(annotationType);
+ }
+ if(annotation == null && pi.getSetter() != null)
+ {
+ Signature mis = new MethodSignature(pi.getSetter());
+ MetaData imetaData = metaData.getComponentMetaData(mis);
+ if (imetaData != null)
+ annotation = imetaData.getAnnotation(annotationType);
+ }
+ if(annotation == null && pi.getFieldInfo() != null)
+ {
+ Signature fis = new FieldSignature(pi.getFieldInfo());
+ MetaData imetaData = metaData.getComponentMetaData(fis);
+ if (imetaData != null)
+ annotation = imetaData.getAnnotation(annotationType);
+ }
+ }
+ if(annotation != null)
+ log.trace("Loaded "+annotationType+" from MetaData");
+ }
+ if(annotation == null)
+ annotation = info.getUnderlyingAnnotation(annotationType);
+ return annotation;
+ }
+
+ /**
+ * Build up a BeanInfo from the interface class and all interfaces it
+ * implements.
+ *
+ * @param iface - the interface for the managed object
+ * @return the full BeanInfo for the iface
+ */
+ protected BeanInfo getBeanInfo(Class<?> iface)
+ {
+ BeanInfo ifaceBI = configuration.getBeanInfo(iface);
+ Class<?>[] superIfaces = iface.getInterfaces();
+ if(superIfaces != null && superIfaces.length > 0)
+ {
+ // Combine all properties
+ Set<PropertyInfo> allProps = new HashSet<PropertyInfo>(ifaceBI.getProperties());
+ // Combine all operations
+ Set<MethodInfo> allMethods = new HashSet<MethodInfo>(ifaceBI.getMethods());
+ for(Class<?> superIface : superIfaces)
+ {
+ BeanInfo cBI = configuration.getBeanInfo(superIface);
+ Set<PropertyInfo> props = cBI.getProperties();
+ if(props != null)
+ allProps.addAll(props);
+ Set<MethodInfo> methods = cBI.getMethods();
+ if(methods != null)
+ allMethods.addAll(methods);
+ }
+
+ ifaceBI.setProperties(allProps);
+ ifaceBI.setMethods(allMethods);
+ }
+ return ifaceBI;
+ }
+}
Deleted: projects/jboss-man/tags/2.1.0.CR8/managed/src/test/java/org/jboss/test/managed/factory/support/ConstrainedBean.java
===================================================================
--- projects/jboss-man/branches/Branch_2_1/managed/src/test/java/org/jboss/test/managed/factory/support/ConstrainedBean.java 2009-04-19 02:19:21 UTC (rev 87523)
+++ projects/jboss-man/tags/2.1.0.CR8/managed/src/test/java/org/jboss/test/managed/factory/support/ConstrainedBean.java 2009-04-19 02:32:29 UTC (rev 87526)
@@ -1,99 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.managed.factory.support;
-
-import org.jboss.managed.api.annotation.ConstraintsPopulatorFactory;
-import org.jboss.managed.api.annotation.ManagementObject;
-import org.jboss.managed.api.annotation.ManagementProperty;
-import org.jboss.managed.plugins.constraints.NumberConstraintsPopulatorFactory;
-import org.jboss.managed.plugins.constraints.StringLegalValuesPopulatorFactory;
-
-/**
- * Test bean for validating ConstraintsPopulatorFactory on managed properties
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
- at ManagementObject
-public class ConstrainedBean
-{
- private float temperature;
- private Float pi;
- private Short dayOfYear;
- private int day;
- private String month;
-
- @ManagementProperty()
- @ConstraintsPopulatorFactory(value=NumberConstraintsPopulatorFactory.class,
- min="0",max="100")
- public float getTemperature()
- {
- return temperature;
- }
- public void setTemperature(float temperature)
- {
- this.temperature = temperature;
- }
- @ManagementProperty()
- @ConstraintsPopulatorFactory(value=NumberConstraintsPopulatorFactory.class,
- min="3",max="3.14159")
- public Float getPi()
- {
- return pi;
- }
- public void setPi(Float pi)
- {
- this.pi = pi;
- }
- @ManagementProperty()
- @ConstraintsPopulatorFactory(value=NumberConstraintsPopulatorFactory.class,
- min="1",max="365")
- public Short getDayOfYear()
- {
- return dayOfYear;
- }
- public void setDayOfYear(Short dayOfYear)
- {
- this.dayOfYear = dayOfYear;
- }
- @ManagementProperty()
- @ConstraintsPopulatorFactory(value=StringLegalValuesPopulatorFactory.class,
- legalValues={"JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"})
- public String getMonth()
- {
- return month;
- }
- public void setMonth(String month)
- {
- this.month = month;
- }
- @ManagementProperty()
- @ConstraintsPopulatorFactory(value=NumberConstraintsPopulatorFactory.class,
- min="1",max="31")
- public int getDay()
- {
- return day;
- }
- public void setDay(int day)
- {
- this.day = day;
- }
-}
Copied: projects/jboss-man/tags/2.1.0.CR8/managed/src/test/java/org/jboss/test/managed/factory/support/ConstrainedBean.java (from rev 87524, projects/jboss-man/branches/Branch_2_1/managed/src/test/java/org/jboss/test/managed/factory/support/ConstrainedBean.java)
===================================================================
--- projects/jboss-man/tags/2.1.0.CR8/managed/src/test/java/org/jboss/test/managed/factory/support/ConstrainedBean.java (rev 0)
+++ projects/jboss-man/tags/2.1.0.CR8/managed/src/test/java/org/jboss/test/managed/factory/support/ConstrainedBean.java 2009-04-19 02:32:29 UTC (rev 87526)
@@ -0,0 +1,103 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.managed.factory.support;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
+import org.jboss.managed.api.annotation.ConstraintsPopulatorFactory;
+import org.jboss.managed.api.annotation.ManagementObject;
+import org.jboss.managed.api.annotation.ManagementProperty;
+import org.jboss.managed.plugins.constraints.NumberConstraintsPopulatorFactory;
+import org.jboss.managed.plugins.constraints.StringLegalValuesPopulatorFactory;
+
+/**
+ * Test bean for validating ConstraintsPopulatorFactory on managed properties
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+ at ManagementObject
+public class ConstrainedBean
+{
+ private float temperature;
+ private Float pi;
+ private Short dayOfYear;
+ private int day;
+ private String month;
+
+ @ManagementProperty()
+ @ConstraintsPopulatorFactory(value=NumberConstraintsPopulatorFactory.class,
+ min="0",max="100")
+ public float getTemperature()
+ {
+ return temperature;
+ }
+ public void setTemperature(float temperature)
+ {
+ this.temperature = temperature;
+ }
+ @ManagementProperty()
+ @ConstraintsPopulatorFactory(value=NumberConstraintsPopulatorFactory.class,
+ min="3",max="3.14159")
+ public Float getPi()
+ {
+ return pi;
+ }
+ public void setPi(Float pi)
+ {
+ this.pi = pi;
+ }
+ @ManagementProperty()
+ @ConstraintsPopulatorFactory(value=NumberConstraintsPopulatorFactory.class,
+ min="1",max="365")
+ public Short getDayOfYear()
+ {
+ return dayOfYear;
+ }
+ public void setDayOfYear(Short dayOfYear)
+ {
+ this.dayOfYear = dayOfYear;
+ }
+ @ManagementProperty()
+ @ConstraintsPopulatorFactory(value=StringLegalValuesPopulatorFactory.class,
+ legalValues={"JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"})
+ public String getMonth()
+ {
+ return month;
+ }
+ public void setMonth(String month)
+ {
+ this.month = month;
+ }
+ @ManagementProperty()
+ @ConstraintsPopulatorFactory(value=NumberConstraintsPopulatorFactory.class,
+ min="1",max="31")
+ public int getDay()
+ {
+ return day;
+ }
+ public void setDay(int day)
+ {
+ this.day = day;
+ }
+
+}
Copied: projects/jboss-man/tags/2.1.0.CR8/managed/src/test/java/org/jboss/test/managed/factory/support/defaults (from rev 87524, projects/jboss-man/branches/Branch_2_1/managed/src/test/java/org/jboss/test/managed/factory/support/defaults)
Copied: projects/jboss-man/tags/2.1.0.CR8/managed/src/test/java/org/jboss/test/managed/factory/test/PropertyDefaultsUnitTestCase.java (from rev 87524, projects/jboss-man/branches/Branch_2_1/managed/src/test/java/org/jboss/test/managed/factory/test/PropertyDefaultsUnitTestCase.java)
===================================================================
--- projects/jboss-man/tags/2.1.0.CR8/managed/src/test/java/org/jboss/test/managed/factory/test/PropertyDefaultsUnitTestCase.java (rev 0)
+++ projects/jboss-man/tags/2.1.0.CR8/managed/src/test/java/org/jboss/test/managed/factory/test/PropertyDefaultsUnitTestCase.java 2009-04-19 02:32:29 UTC (rev 87526)
@@ -0,0 +1,368 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.managed.factory.test;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.Properties;
+
+import javax.management.ObjectName;
+
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.managed.api.annotation.DefaultValueBuilderFactory;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.PropertiesMetaValue;
+import org.jboss.metatype.api.values.SimpleValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.metatype.plugins.types.ObjectNameTypeBuilder;
+import org.jboss.metatype.plugins.values.mappers.PropertiesCompositeObjectNameMetaMapper;
+import org.jboss.test.managed.factory.AbstractManagedObjectFactoryTest;
+import org.jboss.test.managed.factory.support.defaults.DefaultsBean;
+
+/**
+ * Tests of specifying defaults on managed properties
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class PropertyDefaultsUnitTestCase extends AbstractManagedObjectFactoryTest
+{
+
+ public PropertyDefaultsUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testFloatDefaults()
+ throws Exception
+ {
+ DefaultsBean bean = new DefaultsBean();
+ ManagedObject managedObject = super.initManagedObject(bean);
+
+ // Test the temperature constraints
+ ManagedProperty temperature = managedObject.getProperty("temperature");
+ SimpleValue defaultValue = (SimpleValue) temperature.getDefaultValue();
+ assertNotNull(defaultValue);
+ getLog().debug("temperature default: "+defaultValue);
+ int compare = defaultValue.compareTo(SimpleValueSupport.wrap(60f));
+ assertTrue("temperature == 60; "+compare, compare == 0);
+
+ ManagedProperty pi = managedObject.getProperty("pi");
+ defaultValue = (SimpleValue) pi.getDefaultValue();
+ assertNotNull(defaultValue);
+ getLog().debug("pi default: "+defaultValue);
+ compare = defaultValue.compareTo(SimpleValueSupport.wrap(3.14f));
+ assertTrue("pi == 3.14; "+compare, compare == 0);
+ }
+ /**
+ * Test default value for Double property types
+ */
+ public void testDoubleDefaults()
+ throws Exception
+ {
+ DefaultsBean bean = new DefaultsBean();
+ ManagedObject managedObject = super.initManagedObject(bean);
+
+ // Test the temperature constraints
+ ManagedProperty temperature = managedObject.getProperty("temperatureD");
+ SimpleValue defaultValue = (SimpleValue) temperature.getDefaultValue();
+ assertNotNull(defaultValue);
+ getLog().debug("temperature default: "+defaultValue);
+ int compare = defaultValue.compareTo(SimpleValueSupport.wrap(60.5));
+ assertTrue("temperature == 60; "+compare, compare == 0);
+
+ ManagedProperty pi = managedObject.getProperty("piD");
+ defaultValue = (SimpleValue) pi.getDefaultValue();
+ assertNotNull(defaultValue);
+ getLog().debug("pi default: "+defaultValue);
+ compare = defaultValue.compareTo(SimpleValueSupport.wrap(3.14159265358979));
+ assertTrue("pi == 3.14159265358979 "+compare, compare == 0);
+ }
+ /**
+ * Test default value for Long property types
+ */
+ public void testLongDefaults()
+ throws Exception
+ {
+ DefaultsBean bean = new DefaultsBean();
+ ManagedObject managedObject = super.initManagedObject(bean);
+
+ // Test the temperature constraints
+ ManagedProperty temperature = managedObject.getProperty("propLong");
+ SimpleValue defaultValue = (SimpleValue) temperature.getDefaultValue();
+ assertNotNull(defaultValue);
+ getLog().debug("propLong default: "+defaultValue);
+ int compare = defaultValue.compareTo(SimpleValueSupport.wrap(123456789l));
+ assertTrue("propLong == 123456789; "+compare, compare == 0);
+
+ ManagedProperty pi = managedObject.getProperty("propLongPrimitive");
+ defaultValue = (SimpleValue) pi.getDefaultValue();
+ assertNotNull(defaultValue);
+ getLog().debug("propLongPrimitive default: "+defaultValue);
+ compare = defaultValue.compareTo(SimpleValueSupport.wrap(123456789l));
+ assertTrue("propLongPrimitive == 123456789 "+compare, compare == 0);
+ }
+ /**
+ * Test default value for String property types
+ */
+ public void testStringDefaults()
+ {
+ DefaultsBean bean = new DefaultsBean();
+ ManagedObject managedObject = super.initManagedObject(bean);
+ ManagedProperty month = managedObject.getProperty("month");
+ SimpleValue defaultValue = (SimpleValue) month.getDefaultValue();
+ assertNotNull(defaultValue);
+ getLog().debug("month default: "+defaultValue);
+ int compare = defaultValue.compareTo(SimpleValueSupport.wrap("JAN"));
+ assertTrue("month == JAN; "+compare, compare == 0);
+ }
+ /**
+ * Test default value for BigDecimal property types
+ */
+ public void testBigDecimalDefaults()
+ {
+ DefaultsBean bean = new DefaultsBean();
+ ManagedObject managedObject = super.initManagedObject(bean);
+ ManagedProperty month = managedObject.getProperty("propBD");
+ SimpleValue defaultValue = (SimpleValue) month.getDefaultValue();
+ assertNotNull(defaultValue);
+ getLog().debug("propBD default: "+defaultValue);
+ BigDecimal bd = new BigDecimal("123456789.987654321");
+ int compare = defaultValue.compareTo(SimpleValueSupport.wrap(bd));
+ assertTrue("propBD == 123456789.987654321; "+compare, compare == 0);
+ }
+ /**
+ * Test default value for BigInteger property types
+ */
+ public void testBigIntegerDefaults()
+ {
+ DefaultsBean bean = new DefaultsBean();
+ ManagedObject managedObject = super.initManagedObject(bean);
+ ManagedProperty propBI = managedObject.getProperty("propBI");
+ SimpleValue defaultValue = (SimpleValue) propBI.getDefaultValue();
+ assertEquals(SimpleMetaType.BIGINTEGER, defaultValue.getMetaType());
+ assertNotNull(defaultValue);
+ getLog().debug("propBI default: "+defaultValue);
+ BigInteger bd = new BigInteger("123456789987654321");
+ int compare = defaultValue.compareTo(SimpleValueSupport.wrap(bd));
+ assertEquals("propBI == 123456789987654321; "+compare, 0, compare);
+ }
+
+ /**
+ * Test default value for Char property types
+ */
+ public void testCharDefaults()
+ {
+ DefaultsBean bean = new DefaultsBean();
+ ManagedObject managedObject = super.initManagedObject(bean);
+ ManagedProperty propCharPrimitive = managedObject.getProperty("propCharPrimitive");
+ SimpleValue defaultValue = (SimpleValue) propCharPrimitive.getDefaultValue();
+ assertNotNull(defaultValue);
+ assertEquals(SimpleMetaType.CHARACTER_PRIMITIVE, defaultValue.getMetaType());
+ getLog().debug("propCharPrimitive default: "+defaultValue);
+ int compare = defaultValue.compareTo(SimpleValueSupport.wrap('c'));
+ assertEquals("propCharPrimitive == c; ", 0, compare);
+
+ ManagedProperty propChar = managedObject.getProperty("propChar");
+ defaultValue = (SimpleValue) propChar.getDefaultValue();
+ assertNotNull(defaultValue);
+ assertEquals(SimpleMetaType.CHARACTER, defaultValue.getMetaType());
+ getLog().debug("propChar default: "+defaultValue);
+ compare = defaultValue.compareTo(SimpleValueSupport.wrap(new Character('C')));
+ assertTrue("propChar == c; "+compare, compare == 0);
+ }
+
+ /**
+ * Test default value for Integer property types
+ */
+ public void testIntDefaults()
+ {
+ DefaultsBean bean = new DefaultsBean();
+ ManagedObject managedObject = super.initManagedObject(bean);
+ ManagedProperty day = managedObject.getProperty("day");
+ SimpleValue defaultValue = (SimpleValue) day.getDefaultValue();
+ assertNotNull(defaultValue);
+ getLog().debug("day default: "+defaultValue);
+ int compare = defaultValue.compareTo(SimpleValueSupport.wrap(1));
+ assertTrue("day == 1; "+compare, compare == 0);
+
+ ManagedProperty century = managedObject.getProperty("century");
+ defaultValue = (SimpleValue) century.getDefaultValue();
+ assertNotNull(defaultValue);
+ getLog().debug("century default: "+defaultValue);
+ compare = defaultValue.compareTo(SimpleValueSupport.wrap(2000));
+ assertTrue("century == 2000; "+compare, compare == 0);
+ }
+ /**
+ * Test default value for Byte property types
+ */
+ public void testByteDefaults()
+ {
+ DefaultsBean bean = new DefaultsBean();
+ ManagedObject managedObject = super.initManagedObject(bean);
+ ManagedProperty propByte = managedObject.getProperty("propByte");
+ SimpleValue defaultValue = (SimpleValue) propByte.getDefaultValue();
+ assertNotNull(defaultValue);
+ assertEquals(SimpleMetaType.BYTE, defaultValue.getMetaType());
+ getLog().debug("propByte default: "+defaultValue);
+ int compare = defaultValue.compareTo(SimpleValueSupport.wrap(10));
+ assertTrue("propByte == 1; "+compare, compare == 0);
+
+ ManagedProperty propBytePrimitive = managedObject.getProperty("propBytePrimitive");
+ defaultValue = (SimpleValue) propBytePrimitive.getDefaultValue();
+ assertNotNull(defaultValue);
+ assertEquals(SimpleMetaType.BYTE_PRIMITIVE, defaultValue.getMetaType());
+ getLog().debug("propBytePrimitive default: "+defaultValue);
+ compare = defaultValue.compareTo(SimpleValueSupport.wrap(10));
+ assertEquals("propBytePrimitive == 10; ", 0, compare);
+ }
+ /**
+ * Test default value for Short property types
+ */
+ public void testShortDefaults()
+ {
+ DefaultsBean bean = new DefaultsBean();
+ ManagedObject managedObject = super.initManagedObject(bean);
+ ManagedProperty dayOfYear = managedObject.getProperty("dayOfYear");
+ SimpleValue defaultValue = (SimpleValue) dayOfYear.getDefaultValue();
+ assertNotNull(defaultValue);
+ getLog().debug("dayOfYear default: "+defaultValue);
+ int compare = defaultValue.compareTo(SimpleValueSupport.wrap(1));
+ assertTrue("dayOfYear == 1; "+compare, compare == 0);
+
+ ManagedProperty propShortPrimitive = managedObject.getProperty("propShortPrimitive");
+ defaultValue = (SimpleValue) propShortPrimitive.getDefaultValue();
+ assertNotNull(defaultValue);
+ assertEquals(SimpleMetaType.SHORT_PRIMITIVE, defaultValue.getMetaType());
+ getLog().debug("propShortPrimitive default: "+defaultValue);
+ compare = defaultValue.compareTo(SimpleValueSupport.wrap(1234));
+ assertTrue("propShortPrimitive == 1234; "+compare, compare == 0);
+ }
+ /**
+ * Test default value for Boolean property types
+ */
+ public void testBooleanDefaults()
+ {
+ DefaultsBean bean = new DefaultsBean();
+ ManagedObject managedObject = super.initManagedObject(bean);
+ ManagedProperty propBoolean = managedObject.getProperty("propBoolean");
+ SimpleValue defaultValue = (SimpleValue) propBoolean.getDefaultValue();
+ assertNotNull(defaultValue);
+ assertEquals(SimpleMetaType.BOOLEAN, defaultValue.getMetaType());
+ getLog().debug("propBoolean default: "+defaultValue);
+ int compare = defaultValue.compareTo(SimpleValueSupport.wrap(Boolean.TRUE));
+ assertTrue("propBoolean == true; "+compare, compare == 0);
+
+ ManagedProperty propBooleanPrimitive = managedObject.getProperty("propBooleanPrimitive");
+ defaultValue = (SimpleValue) propBooleanPrimitive.getDefaultValue();
+ assertNotNull(defaultValue);
+ assertEquals(SimpleMetaType.BOOLEAN_PRIMITIVE, defaultValue.getMetaType());
+ getLog().debug("propBooleanPrimitive default: "+defaultValue);
+ compare = defaultValue.compareTo(SimpleValueSupport.wrap(true));
+ assertEquals("propBooleanPrimitive == true; ", 0, compare);
+ }
+ /**
+ * Test default value for a Properties type
+ */
+ public void testPropertiesDefault()
+ throws Exception
+ {
+ DefaultsBean bean = new DefaultsBean();
+ ManagedObject managedObject = super.initManagedObject(bean);
+ ManagedProperty props = managedObject.getProperty("props");
+ MetaValue defaultValue = props.getDefaultValue();
+ assertNotNull(defaultValue);
+ getLog().debug("props default: "+defaultValue);
+ Properties expected = new Properties();
+ expected.put("key1", "value1");
+ expected.put("key2", "value2");
+ assertEquals(expected, defaultValue);
+ }
+ /**
+ * Test default value for a Properties type with a DefaultValueBuilderFactory
+ */
+ public void testOverridenPropertiesDefault()
+ {
+ DefaultsBean bean = new DefaultsBean();
+ ManagedObject managedObject = super.initManagedObject(bean);
+ ManagedProperty props = managedObject.getProperty("props2");
+ MetaValue defaultValue = props.getDefaultValue();
+ assertNotNull(defaultValue);
+ getLog().debug("props default: "+defaultValue);
+ Properties expected = new Properties();
+ expected.put("key1", "props2-value1");
+ expected.put("key2", "props2-value2");
+ assertEquals(expected, defaultValue);
+ }
+ /**
+ * Test default value for a ObjectName type with SimpleMetaType.STRING type
+ */
+ public void testStringObjectNameDefault()
+ throws Exception
+ {
+ DefaultsBean bean = new DefaultsBean();
+ ManagedObject managedObject = super.initManagedObject(bean);
+ ManagedProperty nameAsString = managedObject.getProperty("nameAsString");
+ MetaValue defaultValue = nameAsString.getDefaultValue();
+ assertNotNull(defaultValue);
+ getLog().debug("nameAsString default: "+defaultValue);
+ MetaValue expected = SimpleValueSupport.wrap("domain1:key1=value1,key2=value2");
+ assertEquals(expected, defaultValue);
+ }
+ /**
+ * Test default value for a ObjectName type with PropertiesMetaType
+ */
+ public void testPropertiesObjectNameDefault()
+ throws Exception
+ {
+ DefaultsBean bean = new DefaultsBean();
+ ManagedObject managedObject = super.initManagedObject(bean);
+ ManagedProperty nameAsProperties = managedObject.getProperty("nameAsProperties");
+ MetaValue defaultValue = nameAsProperties.getDefaultValue();
+ assertNotNull(defaultValue);
+ getLog().debug("nameAsProperties default: "+defaultValue);
+ Properties p = new Properties();
+ p.setProperty("domain", "domain1");
+ p.setProperty("key1", "value1");
+ p.setProperty("key2", "value2");
+ PropertiesMetaValue expected = new PropertiesMetaValue(p);
+ assertEquals(expected, defaultValue);
+ }
+ /**
+ * Test default value for a ObjectName type with default meta type
+ */
+ public void testDefaultObjectNameDefault()
+ throws Exception
+ {
+ DefaultsBean bean = new DefaultsBean();
+ ManagedObject managedObject = super.initManagedObject(bean);
+ ManagedProperty nameAsProperties = managedObject.getProperty("nameAsDefault");
+ MetaValue defaultValue = nameAsProperties.getDefaultValue();
+ assertNotNull(defaultValue);
+ getLog().debug("nameAsProperties default: "+defaultValue);
+ assertEquals(ObjectNameTypeBuilder.META_TYPE, defaultValue.getMetaType());
+ PropertiesCompositeObjectNameMetaMapper mapper = new PropertiesCompositeObjectNameMetaMapper();
+ MetaValue expected = mapper.createMetaValue(null, new ObjectName("domain1:key1=value1,key2=value2"));
+ assertEquals(expected, defaultValue);
+ }
+}
Deleted: projects/jboss-man/tags/2.1.0.CR8/metatype/pom.xml
===================================================================
--- projects/jboss-man/branches/Branch_2_1/metatype/pom.xml 2009-04-19 02:19:21 UTC (rev 87523)
+++ projects/jboss-man/tags/2.1.0.CR8/metatype/pom.xml 2009-04-19 02:32:29 UTC (rev 87526)
@@ -1,74 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>org.jboss.man</groupId>
- <artifactId>jboss-man-parent</artifactId>
- <version>2.1.0-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <artifactId>jboss-metatype</artifactId>
- <packaging>jar</packaging>
- <name>JBoss Metatype</name>
- <url>http://www.jboss.org/jbossmc</url>
- <description>JBoss Metatype</description>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <testFailureIgnore>false</testFailureIgnore>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- <!-- Do not add version information here, use ../pom.xml instead -->
- <dependencies>
- <!-- Global dependencies -->
- <dependency>
- <groupId>org.jboss</groupId>
- <artifactId>jboss-reflect</artifactId>
- <exclusions>
- <exclusion>
- <groupId>org.jboss</groupId>
- <artifactId>jboss-common-core</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.jboss.logging</groupId>
- <artifactId>jboss-logging-spi</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.jboss.logging</groupId>
- <artifactId>jboss-logging-spi</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss</groupId>
- <artifactId>jboss-common-core</artifactId>
- </dependency>
- <!-- Test dependencies -->
- <dependency>
- <groupId>org.jboss.logging</groupId>
- <artifactId>jboss-logging-log4j</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.test</groupId>
- <artifactId>jboss-test</artifactId>
- <scope>test</scope>
- <exclusions>
- <exclusion>
- <groupId>org.jboss.man</groupId>
- <artifactId>jboss-managed</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-</project>
Copied: projects/jboss-man/tags/2.1.0.CR8/metatype/pom.xml (from rev 87525, projects/jboss-man/branches/Branch_2_1/metatype/pom.xml)
===================================================================
--- projects/jboss-man/tags/2.1.0.CR8/metatype/pom.xml (rev 0)
+++ projects/jboss-man/tags/2.1.0.CR8/metatype/pom.xml 2009-04-19 02:32:29 UTC (rev 87526)
@@ -0,0 +1,74 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.jboss.man</groupId>
+ <artifactId>jboss-man-parent</artifactId>
+ <version>2.1.0.CR8</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>jboss-metatype</artifactId>
+ <packaging>jar</packaging>
+ <name>JBoss Metatype</name>
+ <url>http://www.jboss.org/jbossmc</url>
+ <description>JBoss Metatype</description>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <testFailureIgnore>false</testFailureIgnore>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <!-- Do not add version information here, use ../pom.xml instead -->
+ <dependencies>
+ <!-- Global dependencies -->
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-reflect</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-common-core</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-spi</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-spi</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-common-core</artifactId>
+ </dependency>
+ <!-- Test dependencies -->
+ <dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-log4j</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.test</groupId>
+ <artifactId>jboss-test</artifactId>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.jboss.man</groupId>
+ <artifactId>jboss-managed</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
Deleted: projects/jboss-man/tags/2.1.0.CR8/metatype/src/main/java/org/jboss/metatype/api/types/PropertiesMetaType.java
===================================================================
--- projects/jboss-man/branches/Branch_2_1/metatype/src/main/java/org/jboss/metatype/api/types/PropertiesMetaType.java 2009-04-19 02:19:21 UTC (rev 87523)
+++ projects/jboss-man/tags/2.1.0.CR8/metatype/src/main/java/org/jboss/metatype/api/types/PropertiesMetaType.java 2009-04-19 02:32:29 UTC (rev 87526)
@@ -1,85 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.metatype.api.types;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
-import org.jboss.metatype.api.values.PropertiesMetaValue;
-
-
-/**
- * A MetaType for java.util.Properties
- *
- * @author Scott.Stark at jboss.org
- * @version $Revision:$
- */
-public class PropertiesMetaType extends AbstractMetaType
-{
- private static final long serialVersionUID = 1;
- public static final PropertiesMetaType INSTANCE = new PropertiesMetaType();
- /** A mapping from known property names to description */
- private Map<String, String> propertyNameDescriptions = Collections.emptyMap();
-
- public PropertiesMetaType()
- {
- this(Properties.class.getName());
- }
- public PropertiesMetaType(String description)
- {
- super(Properties.class.getName(), description);
- }
- public PropertiesMetaType(String description, Map<String, String> propertyNameDescriptions)
- {
- super(Properties.class.getName(), description);
- this.propertyNameDescriptions = propertyNameDescriptions;
- }
-
- public void addProperty(String name, String description)
- {
- if(propertyNameDescriptions.size() == 0)
- propertyNameDescriptions = new HashMap<String,String>();
- propertyNameDescriptions.put(name, description);
- }
-
- public boolean isProperty(String name)
- {
- return propertyNameDescriptions.containsKey(name);
- }
- public String getDescription(String name)
- {
- return propertyNameDescriptions.get(name);
- }
-
- @Override
- public boolean isProperties()
- {
- return true;
- }
- @Override
- public boolean isValue(Object obj)
- {
- return obj instanceof PropertiesMetaValue;
- }
-}
Copied: projects/jboss-man/tags/2.1.0.CR8/metatype/src/main/java/org/jboss/metatype/api/types/PropertiesMetaType.java (from rev 87524, projects/jboss-man/branches/Branch_2_1/metatype/src/main/java/org/jboss/metatype/api/types/PropertiesMetaType.java)
===================================================================
--- projects/jboss-man/tags/2.1.0.CR8/metatype/src/main/java/org/jboss/metatype/api/types/PropertiesMetaType.java (rev 0)
+++ projects/jboss-man/tags/2.1.0.CR8/metatype/src/main/java/org/jboss/metatype/api/types/PropertiesMetaType.java 2009-04-19 02:32:29 UTC (rev 87526)
@@ -0,0 +1,100 @@
+/*
+ * 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.metatype.api.types;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import org.jboss.metatype.api.values.PropertiesMetaValue;
+
+
+/**
+ * A MetaType for java.util.Properties
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class PropertiesMetaType extends AbstractMetaType
+{
+ private static final long serialVersionUID = 1;
+ public static final PropertiesMetaType INSTANCE = new PropertiesMetaType();
+ /** A mapping from known property names to description */
+ private Map<String, String> propertyNameDescriptions = Collections.emptyMap();
+
+ public PropertiesMetaType()
+ {
+ this(Properties.class.getName());
+ }
+ public PropertiesMetaType(String description)
+ {
+ super(Properties.class.getName(), description);
+ }
+ public PropertiesMetaType(String description, Map<String, String> propertyNameDescriptions)
+ {
+ super(Properties.class.getName(), description);
+ this.propertyNameDescriptions = propertyNameDescriptions;
+ }
+
+ public void addProperty(String name, String description)
+ {
+ if(propertyNameDescriptions.size() == 0)
+ propertyNameDescriptions = new HashMap<String,String>();
+ propertyNameDescriptions.put(name, description);
+ }
+
+ public boolean isProperty(String name)
+ {
+ return propertyNameDescriptions.containsKey(name);
+ }
+ public String getDescription(String name)
+ {
+ return propertyNameDescriptions.get(name);
+ }
+
+ @Override
+ public boolean isProperties()
+ {
+ return true;
+ }
+ @Override
+ public boolean isValue(Object obj)
+ {
+ return obj instanceof PropertiesMetaValue;
+ }
+
+ /**
+ * Equality of PropertiesMetaType is just based on the class
+ */
+ @Override
+ public boolean equals(Object obj)
+ {
+ return obj instanceof PropertiesMetaType;
+ }
+ @Override
+ public int hashCode()
+ {
+ return getClass().hashCode();
+ }
+
+}
Deleted: projects/jboss-man/tags/2.1.0.CR8/metatype/src/main/java/org/jboss/metatype/api/values/PropertiesMetaValue.java
===================================================================
--- projects/jboss-man/branches/Branch_2_1/metatype/src/main/java/org/jboss/metatype/api/values/PropertiesMetaValue.java 2009-04-19 02:19:21 UTC (rev 87523)
+++ projects/jboss-man/tags/2.1.0.CR8/metatype/src/main/java/org/jboss/metatype/api/values/PropertiesMetaValue.java 2009-04-19 02:32:29 UTC (rev 87526)
@@ -1,98 +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.metatype.api.values;
-
-import java.util.Map;
-import java.util.Properties;
-
-import org.jboss.metatype.api.types.PropertiesMetaType;
-
-/**
- * A mapping from the jdk Properties to a MetaValue
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public class PropertiesMetaValue extends Properties
- implements MetaValue
-{
- private static final long serialVersionUID = 1;
- private PropertiesMetaType type = PropertiesMetaType.INSTANCE;
-
- /**
- * Build a PropertiesMetaValue from a Properties by copying all key/value
- * pairs from props into the new PropertiesMetaValue.
- *
- * @param props - the Properties to copy
- * @return PropertiesMetaValue
- */
- public static PropertiesMetaValue wrap(Map<String,String> props)
- {
- PropertiesMetaValue value = new PropertiesMetaValue();
- value.putAll(props);
- return value;
- }
-
- /**
- * Creates an empty PropertiesMetaValue
- */
- public PropertiesMetaValue()
- {
- }
- /**
- * Create a PropertiesMetaValue with props as the defaults. If you want to
- * create a PropertiesMetaValue with only the key/value pairs of props use
- * {@link #wrap(Properties)}.
- *
- * @param props - default properties
- */
- public PropertiesMetaValue(Properties props)
- {
- this(props, PropertiesMetaType.INSTANCE);
- }
- /**
- * Create a PropertiesMetaValue with props as the defaults. If you want to
- * create a PropertiesMetaValue with only the key/value pairs of props use
- * {@link #wrap(Properties)}.
- *
- * @param props - default properties
- * @param type - the properties
- */
- public PropertiesMetaValue(Properties props, PropertiesMetaType type)
- {
- super.putAll(props);
- this.type = type;
- }
-
- public PropertiesMetaType getMetaType()
- {
- return type;
- }
-
- @Override
- public MetaValue clone()
- {
- PropertiesMetaValue clone = new PropertiesMetaValue();
- clone.putAll(this);
- return clone;
- }
-
-}
Copied: projects/jboss-man/tags/2.1.0.CR8/metatype/src/main/java/org/jboss/metatype/api/values/PropertiesMetaValue.java (from rev 87524, projects/jboss-man/branches/Branch_2_1/metatype/src/main/java/org/jboss/metatype/api/values/PropertiesMetaValue.java)
===================================================================
--- projects/jboss-man/tags/2.1.0.CR8/metatype/src/main/java/org/jboss/metatype/api/values/PropertiesMetaValue.java (rev 0)
+++ projects/jboss-man/tags/2.1.0.CR8/metatype/src/main/java/org/jboss/metatype/api/values/PropertiesMetaValue.java 2009-04-19 02:32:29 UTC (rev 87526)
@@ -0,0 +1,99 @@
+/*
+ * 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.metatype.api.values;
+
+import java.util.Map;
+import java.util.Properties;
+
+import org.jboss.metatype.api.types.PropertiesMetaType;
+
+/**
+ * A mapping from the jdk Properties to a MetaValue
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class PropertiesMetaValue extends Properties
+ implements MetaValue
+{
+ private static final long serialVersionUID = 1;
+ private PropertiesMetaType type = PropertiesMetaType.INSTANCE;
+
+ /**
+ * Build a PropertiesMetaValue from a Properties by copying all key/value
+ * pairs from props into the new PropertiesMetaValue.
+ *
+ * @param props - the Properties to copy
+ * @return PropertiesMetaValue
+ */
+ public static PropertiesMetaValue wrap(Map<String,String> props)
+ {
+ PropertiesMetaValue value = new PropertiesMetaValue();
+ value.putAll(props);
+ return value;
+ }
+
+ /**
+ * Creates an empty PropertiesMetaValue
+ */
+ public PropertiesMetaValue()
+ {
+ }
+ /**
+ * Create a PropertiesMetaValue with props as the defaults. If you want to
+ * create a PropertiesMetaValue with only the key/value pairs of props use
+ * {@link #wrap(Properties)}.
+ *
+ * @param props - default properties
+ */
+ public PropertiesMetaValue(Properties props)
+ {
+ this(props, PropertiesMetaType.INSTANCE);
+ }
+ /**
+ * Create a PropertiesMetaValue with props as the defaults. If you want to
+ * create a PropertiesMetaValue with only the key/value pairs of props use
+ * {@link #wrap(Properties)}.
+ *
+ * @param props - default properties
+ * @param type - the properties
+ */
+ public PropertiesMetaValue(Properties props, PropertiesMetaType type)
+ {
+ if(props != null)
+ super.putAll(props);
+ this.type = type;
+ }
+
+ public PropertiesMetaType getMetaType()
+ {
+ return type;
+ }
+
+ @Override
+ public MetaValue clone()
+ {
+ PropertiesMetaValue clone = new PropertiesMetaValue();
+ clone.putAll(this);
+ return clone;
+ }
+
+}
Deleted: projects/jboss-man/tags/2.1.0.CR8/metatype/src/main/java/org/jboss/metatype/api/values/SimpleValueSupport.java
===================================================================
--- projects/jboss-man/branches/Branch_2_1/metatype/src/main/java/org/jboss/metatype/api/values/SimpleValueSupport.java 2009-04-19 02:19:21 UTC (rev 87523)
+++ projects/jboss-man/tags/2.1.0.CR8/metatype/src/main/java/org/jboss/metatype/api/values/SimpleValueSupport.java 2009-04-19 02:32:29 UTC (rev 87526)
@@ -1,304 +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.api.values;
-
-import java.io.Serializable;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.util.Date;
-
-import org.jboss.metatype.api.types.Name;
-import org.jboss.metatype.api.types.SimpleMetaType;
-
-/**
- * SimpleValue.
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
-public class SimpleValueSupport extends AbstractMetaValue implements SimpleValue
-{
- /** The serialVersionUID */
- private static final long serialVersionUID = 8473043036261557127L;
-
- /** The simple meta type */
- private SimpleMetaType metaType;
-
- /** The value */
- private Serializable value;
-
- /**
- * Wrap a simple object in simple value
- *
- * @param object the simple object
- * @return the simple value
- */
- public static SimpleValue wrap(Serializable object)
- {
- if (object == null)
- return null;
- String className = object.getClass().getName();
- return wrap(object, className);
- }
- private static SimpleValue wrap(Serializable object, String className)
- {
- SimpleMetaType metaType = SimpleMetaType.resolve(className);
- return new SimpleValueSupport(metaType, object);
- }
- public static SimpleValue wrap(boolean value)
- {
- return wrap(value, boolean.class.getName());
- }
- public static SimpleValue wrap(byte value)
- {
- return wrap(value, byte.class.getName());
- }
- public static SimpleValue wrap(char value)
- {
- return wrap(value, char.class.getName());
- }
- public static SimpleValue wrap(short value)
- {
- return wrap(value, short.class.getName());
- }
- public static SimpleValue wrap(int value)
- {
- return wrap(value, int.class.getName());
- }
- public static SimpleValue wrap(long value)
- {
- return wrap(value, long.class.getName());
- }
- public static SimpleValue wrap(float value)
- {
- return wrap(value, float.class.getName());
- }
- public static SimpleValue wrap(double value)
- {
- return wrap(value, double.class.getName());
- }
-
- /**
- * Create a new SimpleValueSupport.
- *
- * @param metaType the simple meta type
- * @param value the value
- * @throws IllegalArgumentException for a null simpleMetaType
- */
- public SimpleValueSupport(SimpleMetaType metaType, Serializable value)
- {
- if (metaType == null)
- throw new IllegalArgumentException("Null simple meta type");
- this.metaType = metaType;
- setValue(value);
- }
-
- public SimpleMetaType getMetaType()
- {
- return metaType;
- }
-
- /**
- * Get the value.
- *
- * @return the value.
- */
- public Serializable getValue()
- {
- return value;
- }
-
- /**
- * Set the value.
- *
- * @param value the value.
- */
- public void setValue(Serializable value)
- {
- this.value = value;
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj == this)
- return true;
-
- if (obj == null || obj instanceof SimpleValue == false)
- return false;
-
- SimpleValue other = (SimpleValue) obj;
- if (metaType.equals(other.getMetaType()) == false)
- {
- // Check equivalent types
- if (metaType.equalsIgnorePrimitive(other.getMetaType()) == false)
- return false;
- }
-
- Object otherValue = other.getValue();
- if (value == null && otherValue == null)
- return true;
- if (value == null && otherValue != null)
- return false;
- return value.equals(otherValue);
- }
-
- @Override
- public int hashCode()
- {
- if (value == null)
- return 0;
- return value.hashCode();
- }
-
- @Override
- public String toString()
- {
- return metaType + ":" + value;
- }
-
- public int compareTo(SimpleValue sv)
- {
- int compare = -1;
- if(getMetaType() == SimpleMetaType.BIGINTEGER && sv.getMetaType() == SimpleMetaType.BIGINTEGER)
- {
- BigInteger v1 = BigInteger.class.cast(value);
- BigInteger v2 = BigInteger.class.cast(sv.getValue());
- compare = v1.compareTo(v2);
- }
- else if(getMetaType() == SimpleMetaType.BIGDECIMAL && sv.getMetaType() == SimpleMetaType.BIGDECIMAL)
- {
- BigDecimal v1 = BigDecimal.class.cast(value);
- BigDecimal v2 = BigDecimal.class.cast(sv.getValue());
- compare = v1.compareTo(v2);
- }
- else if(getMetaType() == SimpleMetaType.BOOLEAN && sv.getMetaType() == SimpleMetaType.BOOLEAN)
- {
- Boolean v1 = Boolean.class.cast(value);
- Boolean v2 = Boolean.class.cast(sv.getValue());
- compare = v1.compareTo(v2);
- }
- else if(getMetaType() == SimpleMetaType.BYTE && sv.getMetaType() == SimpleMetaType.BYTE)
- {
- Byte v1 = Byte.class.cast(value);
- Byte v2 = Byte.class.cast(sv.getValue());
- compare = v1.compareTo(v2);
- }
- else if(getMetaType() == SimpleMetaType.CHARACTER && sv.getMetaType() == SimpleMetaType.CHARACTER)
- {
- Character v1 = Character.class.cast(value);
- Character v2 = Character.class.cast(sv.getValue());
- compare = v1.compareTo(v2);
- }
- else if(getMetaType() == SimpleMetaType.DATE && sv.getMetaType() == SimpleMetaType.DATE)
- {
- Date v1 = Date.class.cast(value);
- Date v2 = Date.class.cast(sv.getValue());
- compare = v1.compareTo(v2);
- }
- else if(getMetaType() == SimpleMetaType.DOUBLE && sv.getMetaType() == SimpleMetaType.DOUBLE)
- {
- Double v1 = Double.class.cast(value);
- Double v2 = Double.class.cast(sv.getValue());
- compare = v1.compareTo(v2);
- }
- else if(getMetaType() == SimpleMetaType.FLOAT && sv.getMetaType() == SimpleMetaType.FLOAT)
- {
- Float v1 = Float.class.cast(value);
- Float v2 = Float.class.cast(sv.getValue());
- compare = v1.compareTo(v2);
- }
- else if(getMetaType() == SimpleMetaType.INTEGER && sv.getMetaType() == SimpleMetaType.INTEGER)
- {
- Integer v1 = Integer.class.cast(value);
- Integer v2 = Integer.class.cast(sv.getValue());
- compare = v1.compareTo(v2);
- }
- else if(getMetaType() == SimpleMetaType.LONG && sv.getMetaType() == SimpleMetaType.LONG)
- {
- Long v1 = Long.class.cast(value);
- Long v2 = Long.class.cast(sv.getValue());
- compare = v1.compareTo(v2);
- }
- else if(getMetaType() == SimpleMetaType.SHORT && sv.getMetaType() == SimpleMetaType.SHORT)
- {
- Short v1 = Short.class.cast(value);
- Short v2 = Short.class.cast(sv.getValue());
- compare = v1.compareTo(v2);
- }
- else if(getMetaType() == SimpleMetaType.STRING && sv.getMetaType() == SimpleMetaType.STRING)
- {
- String v1 = String.class.cast(value);
- String v2 = String.class.cast(sv.getValue());
- compare = v1.compareTo(v2);
- }
- else if(getMetaType() == SimpleMetaType.NAMEDOBJECT && sv.getMetaType() == SimpleMetaType.NAMEDOBJECT)
- {
- Name v1 = Name.class.cast(value);
- Name v2 = Name.class.cast(sv.getValue());
- compare = v1.compareTo(v2);
- }
- else if(getMetaType() == SimpleMetaType.VOID && sv.getMetaType() == SimpleMetaType.VOID)
- {
- compare = 0;
- }
- else if(value instanceof Number && sv.getValue() instanceof Number)
- {
- // Compare two Numbers using the most precise type
- Number n0 = (Number) value;
- Number n1 = (Number) sv.getValue();
- if(n0 instanceof BigDecimal)
- {
- BigDecimal db0 = (BigDecimal) n0;
- BigDecimal db1 = new BigDecimal(n1.doubleValue());
- compare = db0.compareTo(db1);
- }
- else if(n1 instanceof BigDecimal)
- {
- BigDecimal db1 = (BigDecimal) n1;
- BigDecimal db0 = new BigDecimal(n0.doubleValue());
- compare = db0.compareTo(db1);
- }
- else if(n0 instanceof Float || n0 instanceof Double
- || n1 instanceof Float || n1 instanceof Double)
- {
- double d0 = n0.doubleValue();
- double d1 = n1.doubleValue();
- compare = Double.compare(d0, d1);
- }
- else
- {
- long l0 = n0.longValue();
- long l1 = n1.longValue();
- if(l0 < l1)
- compare = -1;
- else if(l0 > l1)
- compare = 1;
- else
- compare = 0;
- }
- }
-
- return compare;
- }
-
-}
Copied: projects/jboss-man/tags/2.1.0.CR8/metatype/src/main/java/org/jboss/metatype/api/values/SimpleValueSupport.java (from rev 87524, projects/jboss-man/branches/Branch_2_1/metatype/src/main/java/org/jboss/metatype/api/values/SimpleValueSupport.java)
===================================================================
--- projects/jboss-man/tags/2.1.0.CR8/metatype/src/main/java/org/jboss/metatype/api/values/SimpleValueSupport.java (rev 0)
+++ projects/jboss-man/tags/2.1.0.CR8/metatype/src/main/java/org/jboss/metatype/api/values/SimpleValueSupport.java 2009-04-19 02:32:29 UTC (rev 87526)
@@ -0,0 +1,316 @@
+/*
+* 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.api.values;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.Date;
+
+import org.jboss.metatype.api.types.Name;
+import org.jboss.metatype.api.types.SimpleMetaType;
+
+/**
+ * SimpleValue.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class SimpleValueSupport extends AbstractMetaValue implements SimpleValue
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 8473043036261557127L;
+
+ /** The simple meta type */
+ private SimpleMetaType metaType;
+
+ /** The value */
+ private Serializable value;
+
+ /**
+ * Wrap a simple object in simple value
+ *
+ * @param object the simple object
+ * @return the simple value
+ */
+ public static SimpleValue wrap(Serializable object)
+ {
+ if (object == null)
+ return null;
+ String className = object.getClass().getName();
+ return wrap(object, className);
+ }
+ private static SimpleValue wrap(Serializable object, String className)
+ {
+ SimpleMetaType metaType = SimpleMetaType.resolve(className);
+ return new SimpleValueSupport(metaType, object);
+ }
+ public static SimpleValue wrap(boolean value)
+ {
+ return wrap(value, boolean.class.getName());
+ }
+ public static SimpleValue wrap(byte value)
+ {
+ return wrap(value, byte.class.getName());
+ }
+ public static SimpleValue wrap(char value)
+ {
+ return wrap(value, char.class.getName());
+ }
+ public static SimpleValue wrap(short value)
+ {
+ return wrap(value, short.class.getName());
+ }
+ public static SimpleValue wrap(int value)
+ {
+ return wrap(value, int.class.getName());
+ }
+ public static SimpleValue wrap(long value)
+ {
+ return wrap(value, long.class.getName());
+ }
+ public static SimpleValue wrap(float value)
+ {
+ return wrap(value, float.class.getName());
+ }
+ public static SimpleValue wrap(double value)
+ {
+ return wrap(value, double.class.getName());
+ }
+
+ /**
+ * Create a new SimpleValueSupport.
+ *
+ * @param metaType the simple meta type
+ * @param value the value
+ * @throws IllegalArgumentException for a null simpleMetaType
+ */
+ public SimpleValueSupport(SimpleMetaType metaType, Serializable value)
+ {
+ if (metaType == null)
+ throw new IllegalArgumentException("Null simple meta type");
+ this.metaType = metaType;
+ setValue(value);
+ }
+
+ public SimpleMetaType getMetaType()
+ {
+ return metaType;
+ }
+
+ /**
+ * Get the value.
+ *
+ * @return the value.
+ */
+ public Serializable getValue()
+ {
+ return value;
+ }
+
+ /**
+ * Set the value.
+ *
+ * @param value the value.
+ */
+ public void setValue(Serializable value)
+ {
+ this.value = value;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ return true;
+
+ if (obj == null || obj instanceof SimpleValue == false)
+ return false;
+
+ SimpleValue other = (SimpleValue) obj;
+ if (metaType.equals(other.getMetaType()) == false)
+ {
+ // Check equivalent types
+ if (metaType.equalsIgnorePrimitive(other.getMetaType()) == false)
+ return false;
+ }
+
+ Object otherValue = other.getValue();
+ if (value == null && otherValue == null)
+ return true;
+ if (value == null && otherValue != null)
+ return false;
+ return value.equals(otherValue);
+ }
+
+ @Override
+ public int hashCode()
+ {
+ if (value == null)
+ return 0;
+ return value.hashCode();
+ }
+
+ @Override
+ public String toString()
+ {
+ return metaType + ":" + value;
+ }
+
+ public int compareTo(SimpleValue sv)
+ {
+ int compare = -1;
+ if(getMetaType() == SimpleMetaType.BIGINTEGER && sv.getMetaType() == SimpleMetaType.BIGINTEGER)
+ {
+ BigInteger v1 = BigInteger.class.cast(value);
+ BigInteger v2 = BigInteger.class.cast(sv.getValue());
+ compare = v1.compareTo(v2);
+ }
+ else if(getMetaType() == SimpleMetaType.BIGDECIMAL && sv.getMetaType() == SimpleMetaType.BIGDECIMAL)
+ {
+ BigDecimal v1 = BigDecimal.class.cast(value);
+ BigDecimal v2 = BigDecimal.class.cast(sv.getValue());
+ compare = v1.compareTo(v2);
+ }
+ else if(getMetaType() == SimpleMetaType.BOOLEAN && sv.getMetaType() == SimpleMetaType.BOOLEAN)
+ {
+ Boolean v1 = Boolean.class.cast(value);
+ Boolean v2 = Boolean.class.cast(sv.getValue());
+ compare = v1.compareTo(v2);
+ }
+ else if(getMetaType() == SimpleMetaType.BOOLEAN_PRIMITIVE && sv.getMetaType() == SimpleMetaType.BOOLEAN_PRIMITIVE)
+ {
+ Boolean v1 = Boolean.class.cast(value);
+ Boolean v2 = Boolean.class.cast(sv.getValue());
+ compare = v1.compareTo(v2);
+ }
+ else if(getMetaType() == SimpleMetaType.BYTE && sv.getMetaType() == SimpleMetaType.BYTE)
+ {
+ Byte v1 = Byte.class.cast(value);
+ Byte v2 = Byte.class.cast(sv.getValue());
+ compare = v1.compareTo(v2);
+ }
+ else if(getMetaType() == SimpleMetaType.CHARACTER && sv.getMetaType() == SimpleMetaType.CHARACTER)
+ {
+ Character v1 = Character.class.cast(value);
+ Character v2 = Character.class.cast(sv.getValue());
+ compare = v1.compareTo(v2);
+ }
+ else if(getMetaType() == SimpleMetaType.CHARACTER_PRIMITIVE && sv.getMetaType() == SimpleMetaType.CHARACTER_PRIMITIVE)
+ {
+ Character v1 = Character.class.cast(value);
+ Character v2 = Character.class.cast(sv.getValue());
+ compare = v1.compareTo(v2);
+ }
+ else if(getMetaType() == SimpleMetaType.DATE && sv.getMetaType() == SimpleMetaType.DATE)
+ {
+ Date v1 = Date.class.cast(value);
+ Date v2 = Date.class.cast(sv.getValue());
+ compare = v1.compareTo(v2);
+ }
+ else if(getMetaType() == SimpleMetaType.DOUBLE && sv.getMetaType() == SimpleMetaType.DOUBLE)
+ {
+ Double v1 = Double.class.cast(value);
+ Double v2 = Double.class.cast(sv.getValue());
+ compare = v1.compareTo(v2);
+ }
+ else if(getMetaType() == SimpleMetaType.FLOAT && sv.getMetaType() == SimpleMetaType.FLOAT)
+ {
+ Float v1 = Float.class.cast(value);
+ Float v2 = Float.class.cast(sv.getValue());
+ compare = v1.compareTo(v2);
+ }
+ else if(getMetaType() == SimpleMetaType.INTEGER && sv.getMetaType() == SimpleMetaType.INTEGER)
+ {
+ Integer v1 = Integer.class.cast(value);
+ Integer v2 = Integer.class.cast(sv.getValue());
+ compare = v1.compareTo(v2);
+ }
+ else if(getMetaType() == SimpleMetaType.LONG && sv.getMetaType() == SimpleMetaType.LONG)
+ {
+ Long v1 = Long.class.cast(value);
+ Long v2 = Long.class.cast(sv.getValue());
+ compare = v1.compareTo(v2);
+ }
+ else if(getMetaType() == SimpleMetaType.SHORT && sv.getMetaType() == SimpleMetaType.SHORT)
+ {
+ Short v1 = Short.class.cast(value);
+ Short v2 = Short.class.cast(sv.getValue());
+ compare = v1.compareTo(v2);
+ }
+ else if(getMetaType() == SimpleMetaType.STRING && sv.getMetaType() == SimpleMetaType.STRING)
+ {
+ String v1 = String.class.cast(value);
+ String v2 = String.class.cast(sv.getValue());
+ compare = v1.compareTo(v2);
+ }
+ else if(getMetaType() == SimpleMetaType.NAMEDOBJECT && sv.getMetaType() == SimpleMetaType.NAMEDOBJECT)
+ {
+ Name v1 = Name.class.cast(value);
+ Name v2 = Name.class.cast(sv.getValue());
+ compare = v1.compareTo(v2);
+ }
+ else if(getMetaType() == SimpleMetaType.VOID && sv.getMetaType() == SimpleMetaType.VOID)
+ {
+ compare = 0;
+ }
+ else if(value instanceof Number && sv.getValue() instanceof Number)
+ {
+ // Compare two Numbers using the most precise type
+ Number n0 = (Number) value;
+ Number n1 = (Number) sv.getValue();
+ if(n0 instanceof BigDecimal)
+ {
+ BigDecimal db0 = (BigDecimal) n0;
+ BigDecimal db1 = new BigDecimal(n1.doubleValue());
+ compare = db0.compareTo(db1);
+ }
+ else if(n1 instanceof BigDecimal)
+ {
+ BigDecimal db1 = (BigDecimal) n1;
+ BigDecimal db0 = new BigDecimal(n0.doubleValue());
+ compare = db0.compareTo(db1);
+ }
+ else if(n0 instanceof Float || n0 instanceof Double
+ || n1 instanceof Float || n1 instanceof Double)
+ {
+ double d0 = n0.doubleValue();
+ double d1 = n1.doubleValue();
+ compare = Double.compare(d0, d1);
+ }
+ else
+ {
+ long l0 = n0.longValue();
+ long l1 = n1.longValue();
+ if(l0 < l1)
+ compare = -1;
+ else if(l0 > l1)
+ compare = 1;
+ else
+ compare = 0;
+ }
+ }
+
+ return compare;
+ }
+
+}
Copied: projects/jboss-man/tags/2.1.0.CR8/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults (from rev 87524, projects/jboss-man/branches/Branch_2_1/metatype/src/main/java/org/jboss/metatype/plugins/values/defaults)
Deleted: projects/jboss-man/tags/2.1.0.CR8/metatype/src/main/java/org/jboss/metatype/plugins/values/mappers/PropertiesCompositeObjectNameMetaMapper.java
===================================================================
--- projects/jboss-man/branches/Branch_2_1/metatype/src/main/java/org/jboss/metatype/plugins/values/mappers/PropertiesCompositeObjectNameMetaMapper.java 2009-04-19 02:19:21 UTC (rev 87523)
+++ projects/jboss-man/tags/2.1.0.CR8/metatype/src/main/java/org/jboss/metatype/plugins/values/mappers/PropertiesCompositeObjectNameMetaMapper.java 2009-04-19 02:32:29 UTC (rev 87526)
@@ -1,95 +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.metatype.plugins.values.mappers;
-
-import java.lang.reflect.Type;
-import java.util.Hashtable;
-
-import javax.management.ObjectName;
-
-import org.jboss.metatype.api.types.MetaType;
-import org.jboss.metatype.api.values.CompositeValue;
-import org.jboss.metatype.api.values.CompositeValueSupport;
-import org.jboss.metatype.api.values.MetaValue;
-import org.jboss.metatype.api.values.PropertiesMetaValue;
-import org.jboss.metatype.api.values.SimpleValue;
-import org.jboss.metatype.api.values.SimpleValueSupport;
-import org.jboss.metatype.plugins.types.ObjectNameTypeBuilder;
-import org.jboss.metatype.spi.values.MetaMapper;
-
-/**
- * A MetaMapper for ObjectName to CompositeValue using domain, keyPropertyList
- * @author Scott.Stark at jboss.org
- * @version $Revision:$
- */
-public class PropertiesCompositeObjectNameMetaMapper extends MetaMapper<ObjectName>
-{
-
- @Override
- public MetaType getMetaType()
- {
- return ObjectNameTypeBuilder.META_TYPE;
- }
- @Override
- public Type mapToType()
- {
- return ObjectName.class;
- }
-
- @Override
- public MetaValue createMetaValue(MetaType metaType, ObjectName object)
- {
- String[] itemNames = {"domain", "keyPropertyList"};
- PropertiesMetaValue keyValues = new PropertiesMetaValue();
- for(Object key : object.getKeyPropertyList().keySet())
- {
- Object value = object.getKeyProperty((String)key);
- keyValues.put(key, value);
- }
- MetaValue[] itemValues = {SimpleValueSupport.wrap(object.getDomain()), };
- CompositeValueSupport mv = new CompositeValueSupport(ObjectNameTypeBuilder.META_TYPE,
- itemNames, itemValues);
- return mv;
- }
-
- @Override
- public ObjectName unwrapMetaValue(MetaValue metaValue)
- {
- CompositeValue compositeValue = (CompositeValue) metaValue;
- SimpleValue domain = (SimpleValue) compositeValue.get("domain");
- String domainUnwrap = domain.toString();
- MetaValue keys = compositeValue.get("keyPropertyList");
- Hashtable keysUnwrap = null;
- if(keys instanceof PropertiesMetaValue)
- keysUnwrap = (PropertiesMetaValue) keys;
- try
- {
- ObjectName name = new ObjectName(domainUnwrap, keysUnwrap);
- return name;
- }
- catch(Exception e)
- {
- throw new IllegalArgumentException(e);
- }
- }
-
-}
Copied: projects/jboss-man/tags/2.1.0.CR8/metatype/src/main/java/org/jboss/metatype/plugins/values/mappers/PropertiesCompositeObjectNameMetaMapper.java (from rev 87524, projects/jboss-man/branches/Branch_2_1/metatype/src/main/java/org/jboss/metatype/plugins/values/mappers/PropertiesCompositeObjectNameMetaMapper.java)
===================================================================
--- projects/jboss-man/tags/2.1.0.CR8/metatype/src/main/java/org/jboss/metatype/plugins/values/mappers/PropertiesCompositeObjectNameMetaMapper.java (rev 0)
+++ projects/jboss-man/tags/2.1.0.CR8/metatype/src/main/java/org/jboss/metatype/plugins/values/mappers/PropertiesCompositeObjectNameMetaMapper.java 2009-04-19 02:32:29 UTC (rev 87526)
@@ -0,0 +1,95 @@
+/*
+ * 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.metatype.plugins.values.mappers;
+
+import java.lang.reflect.Type;
+import java.util.Hashtable;
+
+import javax.management.ObjectName;
+
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.values.CompositeValue;
+import org.jboss.metatype.api.values.CompositeValueSupport;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.PropertiesMetaValue;
+import org.jboss.metatype.api.values.SimpleValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.metatype.plugins.types.ObjectNameTypeBuilder;
+import org.jboss.metatype.spi.values.MetaMapper;
+
+/**
+ * A MetaMapper for ObjectName to CompositeValue using domain, keyPropertyList
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class PropertiesCompositeObjectNameMetaMapper extends MetaMapper<ObjectName>
+{
+
+ @Override
+ public MetaType getMetaType()
+ {
+ return ObjectNameTypeBuilder.META_TYPE;
+ }
+ @Override
+ public Type mapToType()
+ {
+ return ObjectName.class;
+ }
+
+ @Override
+ public MetaValue createMetaValue(MetaType metaType, ObjectName object)
+ {
+ String[] itemNames = {"domain", "keyPropertyList"};
+ PropertiesMetaValue keyValues = new PropertiesMetaValue();
+ for(Object key : object.getKeyPropertyList().keySet())
+ {
+ Object value = object.getKeyProperty((String)key);
+ keyValues.put(key, value);
+ }
+ MetaValue[] itemValues = {SimpleValueSupport.wrap(object.getDomain()), keyValues};
+ CompositeValueSupport mv = new CompositeValueSupport(ObjectNameTypeBuilder.META_TYPE,
+ itemNames, itemValues);
+ return mv;
+ }
+
+ @Override
+ public ObjectName unwrapMetaValue(MetaValue metaValue)
+ {
+ CompositeValue compositeValue = (CompositeValue) metaValue;
+ SimpleValue domain = (SimpleValue) compositeValue.get("domain");
+ String domainUnwrap = domain.toString();
+ MetaValue keys = compositeValue.get("keyPropertyList");
+ Hashtable keysUnwrap = null;
+ if(keys instanceof PropertiesMetaValue)
+ keysUnwrap = (PropertiesMetaValue) keys;
+ try
+ {
+ ObjectName name = new ObjectName(domainUnwrap, keysUnwrap);
+ return name;
+ }
+ catch(Exception e)
+ {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+}
Copied: projects/jboss-man/tags/2.1.0.CR8/metatype/src/main/java/org/jboss/metatype/plugins/values/mappers/PropertiesMetaMapper.java (from rev 87524, projects/jboss-man/branches/Branch_2_1/metatype/src/main/java/org/jboss/metatype/plugins/values/mappers/PropertiesMetaMapper.java)
===================================================================
--- projects/jboss-man/tags/2.1.0.CR8/metatype/src/main/java/org/jboss/metatype/plugins/values/mappers/PropertiesMetaMapper.java (rev 0)
+++ projects/jboss-man/tags/2.1.0.CR8/metatype/src/main/java/org/jboss/metatype/plugins/values/mappers/PropertiesMetaMapper.java 2009-04-19 02:32:29 UTC (rev 87526)
@@ -0,0 +1,96 @@
+/*
+ * 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.metatype.plugins.values.mappers;
+
+import java.lang.reflect.Type;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.management.ObjectName;
+
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.PropertiesMetaType;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.PropertiesMetaValue;
+import org.jboss.metatype.spi.values.MetaMapper;
+
+/**
+ * An Properties MetaMapper that maps to a PropertiesMetaType/PropertiesMetaValue
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 81575 $
+ */
+public class PropertiesMetaMapper extends MetaMapper<Properties>
+{
+ PropertiesMetaType type;
+
+ public PropertiesMetaMapper()
+ {
+ this((String[])null);
+ }
+ public PropertiesMetaMapper(String... args)
+ {
+ Map<String, String> propertyNameDescriptions = Collections.emptyMap();
+ if(args != null)
+ {
+ if(((args.length %2) == 0) == false)
+ throw new IllegalStateException("args counts must be 2*n for n key,key-description pairs");
+ propertyNameDescriptions = new HashMap<String,String>();
+ for(int n = 0; n < args.length; n += 2)
+ {
+ String key = args[n];
+ String description = args[n+1];
+ propertyNameDescriptions.put(key, description);
+ }
+ }
+
+ type = new PropertiesMetaType("java.util.Properties", propertyNameDescriptions);
+ }
+
+ @Override
+ public MetaType getMetaType()
+ {
+ return type;
+ }
+
+ @Override
+ public Type mapToType()
+ {
+ return ObjectName.class;
+ }
+
+ @Override
+ public MetaValue createMetaValue(MetaType metaType, Properties object)
+ {
+ PropertiesMetaValue map = new PropertiesMetaValue(object);
+ return map;
+ }
+
+ @Override
+ public Properties unwrapMetaValue(MetaValue metaValue)
+ {
+ PropertiesMetaValue map = (PropertiesMetaValue) metaValue;
+ return map;
+ }
+
+}
Copied: projects/jboss-man/tags/2.1.0.CR8/metatype/src/main/java/org/jboss/metatype/spi/values/DefaultValueBuilder.java (from rev 87524, projects/jboss-man/branches/Branch_2_1/metatype/src/main/java/org/jboss/metatype/spi/values/DefaultValueBuilder.java)
===================================================================
--- projects/jboss-man/tags/2.1.0.CR8/metatype/src/main/java/org/jboss/metatype/spi/values/DefaultValueBuilder.java (rev 0)
+++ projects/jboss-man/tags/2.1.0.CR8/metatype/src/main/java/org/jboss/metatype/spi/values/DefaultValueBuilder.java 2009-04-19 02:32:29 UTC (rev 87526)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.metatype.spi.values;
+
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.values.MetaValue;
+
+/**
+ * Convert a string representation of a default value into a MetaValue
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public interface DefaultValueBuilder
+{
+ public MetaType getType();
+ public MetaValue buildMetaValue(String value)
+ throws Exception;
+}
Deleted: projects/jboss-man/tags/2.1.0.CR8/pom.xml
===================================================================
--- projects/jboss-man/branches/Branch_2_1/pom.xml 2009-04-19 02:19:21 UTC (rev 87523)
+++ projects/jboss-man/tags/2.1.0.CR8/pom.xml 2009-04-19 02:32:29 UTC (rev 87526)
@@ -1,250 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.jboss</groupId>
- <artifactId>jboss-parent</artifactId>
- <version>4</version>
- </parent>
- <groupId>org.jboss.man</groupId>
- <artifactId>jboss-man-parent</artifactId>
- <version>2.1.0-SNAPSHOT</version>
- <packaging>pom</packaging>
- <name>JBoss Managed Parent POM</name>
- <url>http://www.jboss.org/jbossmc</url>
- <description>JBoss Managed Parent POM</description>
- <scm>
- <connection>scm:svn:http://anonsvn.jboss.org/repos/jbossas/projects/jboss-man/branches/</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/jbossas/projects/jboss-man/branches/</developerConnection>
- <url>http://viewvc.jboss.org/cgi-bin/viewvc.cgi/jbossas/projects/jboss-man/trunk/</url>
- </scm>
-
- <properties>
- <version.jboss.common.core>2.2.10.GA</version.jboss.common.core>
- <version.jboss.common.logging.spi>2.0.5.GA</version.jboss.common.logging.spi>
- <version.jboss.common.logging.log4j>2.0.5.GA</version.jboss.common.logging.log4j>
- <version.org.jboss.reflect>2.0.2.GA</version.org.jboss.reflect>
- <version.org.jboss.mdr>2.0.1.GA</version.org.jboss.mdr>
- <version.org.jboss.test>1.1.3.GA</version.org.jboss.test>
- <version.junit>4.4</version.junit>
- <version.sun.jaxb>2.1.4</version.sun.jaxb>
- <version.javassist>3.9.0.GA</version.javassist>
- </properties>
-
- <modules>
- <module>metatype</module>
- <module>managed</module>
- <module>build</module>
- </modules>
-
- <build>
- <outputDirectory>${microcontainer.outputDirectory}</outputDirectory>
- <testOutputDirectory>${microcontainer.testOutputDirectory}</testOutputDirectory>
- <finalName>${artifactId}</finalName>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>2.0.2</version>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- <showDeprecation>true</showDeprecation>
- <showWarnings>true</showWarnings>
- <optimize>true</optimize>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-release-plugin</artifactId>
- <version>2.0-beta-7</version>
- <configuration>
- <tagBase>https://svn.jboss.org/repos/jbossas/projects/jboss-man/tags</tagBase>
- <autoVersionSubmodules>true</autoVersionSubmodules>
- </configuration>
- </plugin>
- </plugins>
-
- <pluginManagement>
- <plugins>
- <plugin>
- <artifactId>maven-idea-plugin</artifactId>
- <configuration>
- <downloadSources>true</downloadSources>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <version>2.2</version>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <version>2.4.2</version>
- <configuration>
- <redirectTestOutputToFile>true</redirectTestOutputToFile>
- <includes>
- <include>org/jboss/test/**/*TestCase.java</include>
- </includes>
- </configuration>
- </plugin>
- </plugins>
- </pluginManagement>
- </build>
-
- <reporting>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-project-info-reports-plugin</artifactId>
- <reportSets>
- <reportSet>
- <reports>
- <report>dependencies</report>
- <report>issue-tracking</report>
- <report>license</report>
- <report>scm</report>
- </reports>
- </reportSet>
- </reportSets>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>findbugs-maven-plugin</artifactId>
- <version>1.0.0</version>
- </plugin>
- </plugins>
- </reporting>
- <dependencyManagement>
- <!-- The parent pom manages the inter-dependencies of the modules. -->
- <dependencies>
- <dependency>
- <groupId>org.jboss.man</groupId>
- <artifactId>jboss-managed</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.jboss.man</groupId>
- <artifactId>jboss-metatype</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.jboss</groupId>
- <artifactId>jboss-common-core</artifactId>
- <version>${version.jboss.common.core}</version>
- </dependency>
- <dependency>
- <groupId>org.jboss.logging</groupId>
- <artifactId>jboss-logging-spi</artifactId>
- <version>${version.jboss.common.logging.spi}</version>
- </dependency>
- <dependency>
- <groupId>org.jboss.logging</groupId>
- <artifactId>jboss-logging-log4j</artifactId>
- <version>${version.jboss.common.logging.log4j}</version>
- </dependency>
- <dependency>
- <groupId>org.jboss</groupId>
- <artifactId>jboss-reflect</artifactId>
- <version>${version.org.jboss.reflect}</version>
- </dependency>
- <dependency>
- <groupId>org.jboss</groupId>
- <artifactId>jboss-mdr</artifactId>
- <version>${version.org.jboss.mdr}</version>
- </dependency>
- <!-- test dependencies -->
- <dependency>
- <groupId>org.jboss.test</groupId>
- <artifactId>jboss-test</artifactId>
- <version>${version.org.jboss.test}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>${version.junit}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>sun-jaxb</groupId>
- <artifactId>jaxb-api</artifactId>
- <version>${version.sun.jaxb}</version>
- </dependency>
- <dependency>
- <groupId>javassist</groupId>
- <artifactId>javassist</artifactId>
- <version>${version.javassist}</version>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
- <repositories>
- <repository>
- <id>repository.jboss.org</id>
- <name>JBoss Repository</name>
- <layout>default</layout>
- <url>http://repository.jboss.org/maven2/</url>
- <releases>
- <enabled>true</enabled>
- </releases>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- </repository>
- <repository>
- <id>snapshots.jboss.org</id>
- <name>JBoss Snapshots Repository</name>
- <layout>default</layout>
- <url>http://snapshots.jboss.org/maven2/</url>
- <snapshots>
- <enabled>true</enabled>
- </snapshots>
- <releases>
- <enabled>false</enabled>
- </releases>
- </repository>
- </repositories>
-
- <profiles>
- <profile>
- <id>default</id>
- <activation>
- <activeByDefault>true</activeByDefault>
- </activation>
- <properties>
- <microcontainer.outputDirectory>target/classes</microcontainer.outputDirectory>
- <microcontainer.testOutputDirectory>target/tests-classes</microcontainer.testOutputDirectory>
- </properties>
- </profile>
- <profile>
- <id>eclipse</id>
- <build>
- <defaultGoal>process-test-resources</defaultGoal>
- <plugins>
- <plugin>
- <artifactId>maven-eclipse-plugin</artifactId>
- <executions>
- <execution>
- <id>eclipse</id>
- <phase>process-test-resources</phase>
- <goals>
- <goal>eclipse</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <downloadSources>true</downloadSources>
- <buildOutputDirectory>${microcontainer.outputDirectory}</buildOutputDirectory>
- </configuration>
- </plugin>
- </plugins>
- </build>
- <properties>
- <microcontainer.outputDirectory>eclipse-target/classes</microcontainer.outputDirectory>
- <microcontainer.testOutputDirectory>eclipse-target/tests-classes</microcontainer.testOutputDirectory>
- </properties>
- </profile>
- </profiles>
-
-</project>
Copied: projects/jboss-man/tags/2.1.0.CR8/pom.xml (from rev 87525, projects/jboss-man/branches/Branch_2_1/pom.xml)
===================================================================
--- projects/jboss-man/tags/2.1.0.CR8/pom.xml (rev 0)
+++ projects/jboss-man/tags/2.1.0.CR8/pom.xml 2009-04-19 02:32:29 UTC (rev 87526)
@@ -0,0 +1,250 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-parent</artifactId>
+ <version>4</version>
+ </parent>
+ <groupId>org.jboss.man</groupId>
+ <artifactId>jboss-man-parent</artifactId>
+ <version>2.1.0.CR8</version>
+ <packaging>pom</packaging>
+ <name>JBoss Managed Parent POM</name>
+ <url>http://www.jboss.org/jbossmc</url>
+ <description>JBoss Managed Parent POM</description>
+ <scm>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/jbossas/projects/jboss-man/tags/2.1.0.CR8</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/jbossas/projects/jboss-man/tags/2.1.0.CR8</developerConnection>
+ <url>scm:svn:https://svn.jboss.org/repos/jbossas/projects/jboss-man/tags/2.1.0.CR8</url>
+ </scm>
+
+ <properties>
+ <version.jboss.common.core>2.2.10.GA</version.jboss.common.core>
+ <version.jboss.common.logging.spi>2.0.5.GA</version.jboss.common.logging.spi>
+ <version.jboss.common.logging.log4j>2.0.5.GA</version.jboss.common.logging.log4j>
+ <version.org.jboss.reflect>2.0.2.GA</version.org.jboss.reflect>
+ <version.org.jboss.mdr>2.0.1.GA</version.org.jboss.mdr>
+ <version.org.jboss.test>1.1.3.GA</version.org.jboss.test>
+ <version.junit>4.4</version.junit>
+ <version.sun.jaxb>2.1.4</version.sun.jaxb>
+ <version.javassist>3.9.0.GA</version.javassist>
+ </properties>
+
+ <modules>
+ <module>metatype</module>
+ <module>managed</module>
+ <module>build</module>
+ </modules>
+
+ <build>
+ <outputDirectory>${microcontainer.outputDirectory}</outputDirectory>
+ <testOutputDirectory>${microcontainer.testOutputDirectory}</testOutputDirectory>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.0.2</version>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ <showDeprecation>true</showDeprecation>
+ <showWarnings>true</showWarnings>
+ <optimize>true</optimize>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-release-plugin</artifactId>
+ <version>2.0-beta-7</version>
+ <configuration>
+ <tagBase>https://svn.jboss.org/repos/jbossas/projects/jboss-man/tags</tagBase>
+ <autoVersionSubmodules>true</autoVersionSubmodules>
+ </configuration>
+ </plugin>
+ </plugins>
+
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <artifactId>maven-idea-plugin</artifactId>
+ <configuration>
+ <downloadSources>true</downloadSources>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>2.2</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.4.2</version>
+ <configuration>
+ <redirectTestOutputToFile>true</redirectTestOutputToFile>
+ <includes>
+ <include>org/jboss/test/**/*TestCase.java</include>
+ </includes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-project-info-reports-plugin</artifactId>
+ <reportSets>
+ <reportSet>
+ <reports>
+ <report>dependencies</report>
+ <report>issue-tracking</report>
+ <report>license</report>
+ <report>scm</report>
+ </reports>
+ </reportSet>
+ </reportSets>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>findbugs-maven-plugin</artifactId>
+ <version>1.0.0</version>
+ </plugin>
+ </plugins>
+ </reporting>
+ <dependencyManagement>
+ <!-- The parent pom manages the inter-dependencies of the modules. -->
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.man</groupId>
+ <artifactId>jboss-managed</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.man</groupId>
+ <artifactId>jboss-metatype</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-common-core</artifactId>
+ <version>${version.jboss.common.core}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-spi</artifactId>
+ <version>${version.jboss.common.logging.spi}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-log4j</artifactId>
+ <version>${version.jboss.common.logging.log4j}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-reflect</artifactId>
+ <version>${version.org.jboss.reflect}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-mdr</artifactId>
+ <version>${version.org.jboss.mdr}</version>
+ </dependency>
+ <!-- test dependencies -->
+ <dependency>
+ <groupId>org.jboss.test</groupId>
+ <artifactId>jboss-test</artifactId>
+ <version>${version.org.jboss.test}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${version.junit}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>sun-jaxb</groupId>
+ <artifactId>jaxb-api</artifactId>
+ <version>${version.sun.jaxb}</version>
+ </dependency>
+ <dependency>
+ <groupId>javassist</groupId>
+ <artifactId>javassist</artifactId>
+ <version>${version.javassist}</version>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <repositories>
+ <repository>
+ <id>repository.jboss.org</id>
+ <name>JBoss Repository</name>
+ <layout>default</layout>
+ <url>http://repository.jboss.org/maven2/</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ <repository>
+ <id>snapshots.jboss.org</id>
+ <name>JBoss Snapshots Repository</name>
+ <layout>default</layout>
+ <url>http://snapshots.jboss.org/maven2/</url>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ </repository>
+ </repositories>
+
+ <profiles>
+ <profile>
+ <id>default</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <properties>
+ <microcontainer.outputDirectory>target/classes</microcontainer.outputDirectory>
+ <microcontainer.testOutputDirectory>target/tests-classes</microcontainer.testOutputDirectory>
+ </properties>
+ </profile>
+ <profile>
+ <id>eclipse</id>
+ <build>
+ <defaultGoal>process-test-resources</defaultGoal>
+ <plugins>
+ <plugin>
+ <artifactId>maven-eclipse-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>eclipse</id>
+ <phase>process-test-resources</phase>
+ <goals>
+ <goal>eclipse</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <downloadSources>true</downloadSources>
+ <buildOutputDirectory>${microcontainer.outputDirectory}</buildOutputDirectory>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <properties>
+ <microcontainer.outputDirectory>eclipse-target/classes</microcontainer.outputDirectory>
+ <microcontainer.testOutputDirectory>eclipse-target/tests-classes</microcontainer.testOutputDirectory>
+ </properties>
+ </profile>
+ </profiles>
+
+</project>
More information about the jboss-cvs-commits
mailing list