libjboss-managed-java-2.0.0.CR4.orig/0000755000175000017500000000000011105402544017111 5ustar twernertwernerlibjboss-managed-java-2.0.0.CR4.orig/build/0000755000175000017500000000000011105402542020206 5ustar twernertwernerlibjboss-managed-java-2.0.0.CR4.orig/build/src/0000755000175000017500000000000011105402542020775 5ustar twernertwernerlibjboss-managed-java-2.0.0.CR4.orig/build/src/assembly/0000755000175000017500000000000011105402542022614 5ustar twernertwernerlibjboss-managed-java-2.0.0.CR4.orig/build/src/assembly/dist.xml0000644000175000017500000000060411060005461024300 0ustar twernertwerner zip ../metatype/target/classes ../managed/target/classes libjboss-managed-java-2.0.0.CR4.orig/build/src/assembly/src.xml0000644000175000017500000000063111060005461024124 0ustar twernertwerner src zip .. */target/ libjboss-managed-java-2.0.0.CR4.orig/build/.project0000644000175000017500000000030610764772170021675 0ustar twernertwerner build libjboss-managed-java-2.0.0.CR4.orig/build/JBossORG-EULA.txt0000644000175000017500000001764610764772170023122 0ustar twernertwernerLICENSE AGREEMENT JBOSS(r) This License Agreement governs the use of the Software Packages and any updates to the Software Packages, regardless of the delivery mechanism. Each Software Package is a collective work under U.S. Copyright Law. Subject to the following terms, Red Hat, Inc. ("Red Hat") grants to the user ("Client") a license to the applicable collective work(s) pursuant to the GNU Lesser General Public License v. 2.1 except for the following Software Packages: (a) JBoss Portal Forums and JBoss Transactions JTS, each of which is licensed pursuant to the GNU General Public License v.2; (b) JBoss Rules, which is licensed pursuant to the Apache License v.2.0; (c) an optional download for JBoss Cache for the Berkeley DB for Java database, which is licensed under the (open source) Sleepycat License (if Client does not wish to use the open source version of this database, it may purchase a license from Sleepycat Software); and (d) the BPEL extension for JBoss jBPM, which is licensed under the Common Public License v.1, and, pursuant to the OASIS BPEL4WS standard, requires parties wishing to redistribute to enter various royalty-free patent licenses. Each of the foregoing licenses is available at http://www.opensource.org/licenses/index.php. 1. The Software. "Software Packages" refer to the various software modules that are created and made available for distribution by the JBoss.org open source community at http://www.jboss.org. Each of the Software Packages may be comprised of hundreds of software components. The end user license agreement for each component is located in the component's source code. With the exception of certain image files identified in Section 2 below, the license terms for the components permit Client to copy, modify, and redistribute the component, in both source code and binary code forms. This agreement does not limit Client's rights under, or grant Client rights that supersede, the license terms of any particular component. 2. Intellectual Property Rights. The Software Packages are owned by Red Hat and others and are protected under copyright and other laws. Title to the Software Packages and any component, or to any copy, modification, or merged portion shall remain with the aforementioned, subject to the applicable license. The "JBoss" trademark, "Red Hat" trademark, the individual Software Package trademarks, and the "Shadowman" logo are registered trademarks of Red Hat and its affiliates in the U.S. and other countries. This agreement permits Client to distribute unmodified copies of the Software Packages using the Red Hat trademarks that Red Hat has inserted in the Software Packages on the condition that Client follows Red Hat's trademark guidelines for those trademarks located at http://www.redhat.com/about/corporate/trademark/. Client must abide by these trademark guidelines when distributing the Software Packages, regardless of whether the Software Packages have been modified. If Client modifies the Software Packages, then Client must replace all Red Hat trademarks and logos identified at http://www.jboss.com/company/logos, unless a separate agreement with Red Hat is executed or other permission granted. Merely deleting the files containing the Red Hat trademarks may corrupt the Software Packages. 3. Limited Warranty. Except as specifically stated in this Paragraph 3 or a license for a particular component, to the maximum extent permitted under applicable law, the Software Packages and the components are provided and licensed "as is" without warranty of any kind, expressed or implied, including the implied warranties of merchantability, non-infringement or fitness for a particular purpose. Red Hat warrants that the media on which Software Packages may be furnished will be free from defects in materials and manufacture under normal use for a period of 30 days from the date of delivery to Client. Red Hat does not warrant that the functions contained in the Software Packages will meet Client's requirements or that the operation of the Software Packages will be entirely error free or appear precisely as described in the accompanying documentation. This warranty extends only to the party that purchases the Services pertaining to the Software Packages from Red Hat or a Red Hat authorized distributor. 4. Limitation of Remedies and Liability. To the maximum extent permitted by applicable law, the remedies described below are accepted by Client as its only remedies. Red Hat's entire liability, and Client's exclusive remedies, shall be: If the Software media is defective, Client may return it within 30 days of delivery along with a copy of Client's payment receipt and Red Hat, at its option, will replace it or refund the money paid by Client for the Software. To the maximum extent permitted by applicable law, Red Hat or any Red Hat authorized dealer will not be liable to Client for any incidental or consequential damages, including lost profits or lost savings arising out of the use or inability to use the Software, even if Red Hat or such dealer has been advised of the possibility of such damages. In no event shall Red Hat's liability under this agreement exceed the amount that Client paid to Red Hat under this Agreement during the twelve months preceding the action. 5. Export Control. As required by U.S. law, Client represents and warrants that it: (a) understands that the Software Packages are subject to export controls under the U.S. Commerce Department's Export Administration Regulations ("EAR"); (b) is not located in a prohibited destination country under the EAR or U.S. sanctions regulations (currently Cuba, Iran, Iraq, Libya, North Korea, Sudan and Syria); (c) will not export, re-export, or transfer the Software Packages to any prohibited destination, entity, or individual without the necessary export license(s) or authorizations(s) from the U.S. Government; (d) will not use or transfer the Software Packages for use in any sensitive nuclear, chemical or biological weapons, or missile technology end-uses unless authorized by the U.S. Government by regulation or specific license; (e) understands and agrees that if it is in the United States and exports or transfers the Software Packages to eligible end users, it will, as required by EAR Section 740.17(e), submit semi-annual reports to the Commerce Department's Bureau of Industry & Security (BIS), which include the name and address (including country) of each transferee; and (f) understands that countries other than the United States may restrict the import, use, or export of encryption products and that it shall be solely responsible for compliance with any such import, use, or export restrictions. 6. Third Party Programs. Red Hat may distribute third party software programs with the Software Packages that are not part of the Software Packages and which Client must install separately. These third party programs are subject to their own license terms. The license terms either accompany the programs or can be viewed at http://www.redhat.com/licenses/. If Client does not agree to abide by the applicable license terms for such programs, then Client may not install them. If Client wishes to install the programs on more than one system or transfer the programs to another party, then Client must contact the licensor of the programs. 7. General. If any provision of this agreement is held to be unenforceable, that shall not affect the enforceability of the remaining provisions. This License Agreement shall be governed by the laws of the State of North Carolina and of the United States, without regard to any conflict of laws provisions, except that the United Nations Convention on the International Sale of Goods shall not apply. Copyright 2006 Red Hat, Inc. All rights reserved. "JBoss" and the JBoss logo are registered trademarks of Red Hat, Inc. All other trademarks are the property of their respective owners. Page 1 of 1 18 October 2006 libjboss-managed-java-2.0.0.CR4.orig/build/pom.xml0000644000175000017500000000207611104141463021531 0ustar twernertwerner org.jboss.man jboss-man 2.0.0.CR4 4.0.0 org.jboss.man jboss-man-dist 2.0.0.CR4 pom JBoss Managed Distribution Build http://www.jboss.com/products/jbossmc JBoss Managed Distribution Build org.apache.maven.plugins maven-assembly-plugin src/assembly/dist.xml src/assembly/src.xml libjboss-managed-java-2.0.0.CR4.orig/metatype/0000755000175000017500000000000011105402544020741 5ustar twernertwernerlibjboss-managed-java-2.0.0.CR4.orig/metatype/pom-jdk14.xml0000644000175000017500000001344010764372266023214 0ustar twernertwerner org.jboss.microcontainer-jdk14 jboss-microcontainer-jdk14 2.0.0-SNAPSHOT ../build/pom-jdk14.xml 4.0.0 jboss-metatype-jdk14 jar JBoss Microcontainer Metatype JDK 1.4 http://www.jboss.com/products/jbossmc JBoss Microcontainer Metatype org.jboss.maven.plugins maven-jboss-retro-plugin 1.0-beta-1 weave-classes weave ${project.build.directory}/classes-jdk14 weave-test-classes weave-tests ${project.build.directory}/test-classes-jdk14 org.jboss.weaver.retro.WeaverRetroJdk14 org.apache.maven.plugins maven-jar-plugin 2.1 ${project.build.directory}/classes-jdk14 org.apache.maven.plugins maven-surefire-plugin true run-jdk14-tests target/classes-jdk14 target/test-classes-jdk14 org.apache.maven.plugins maven-enforcer-plugin 1.0-alpha-3 enforce-jdk14-property enforce-once java14_home The property java14_home should be set to a valid installation of jdk1.4. The jdk14 tests cannot be run without this property. org.apache.maven.plugins maven-surefire-plugin ${java14_home}/bin/java always false true true true ${project.build.directory}/surefire-reports-jdk14 **/*TestCase.java org.jboss jboss-reflect-jdk14 org.jboss jboss-common-core-jdk14 org.jboss jboss-test-jdk14 test junit junit test libjboss-managed-java-2.0.0.CR4.orig/metatype/.classpath0000644000175000017500000000440611061231504022725 0ustar twernertwerner libjboss-managed-java-2.0.0.CR4.orig/metatype/.project0000644000175000017500000000050010770625662022422 0ustar twernertwerner jboss-metatype JBoss Metatype org.eclipse.jdt.core.javabuilder org.eclipse.jdt.core.javanature libjboss-managed-java-2.0.0.CR4.orig/metatype/src/0000755000175000017500000000000011105402543021527 5ustar twernertwernerlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/0000755000175000017500000000000011105402542022505 5ustar twernertwernerlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/0000755000175000017500000000000011105402542023426 5ustar twernertwernerlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/0000755000175000017500000000000011105402542024215 5ustar twernertwernerlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/0000755000175000017500000000000011105402542025335 5ustar twernertwernerlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/0000755000175000017500000000000011105402542026314 5ustar twernertwernerlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/0000755000175000017500000000000011105402543030145 5ustar twernertwernerlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/0000755000175000017500000000000011105402543031444 5ustar twernertwernerlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/test/0000755000175000017500000000000011105402543032423 5ustar twernertwerner././@LongLink0000000000000000000000000000020700000000000011564 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/test/CompositeValueSupportUnitTestCase.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/test/Comp0000644000175000017500000004752610761511660033272 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.values.test; import java.util.Collection; import java.util.HashMap; import java.util.Map; import junit.framework.Test; import org.jboss.metatype.api.types.CompositeMetaType; 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.SimpleValue; import org.jboss.test.metatype.AbstractMetaTypeTest; /** * CompositeValueSupportUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class CompositeValueSupportUnitTestCase extends AbstractMetaTypeTest { /** * Create a testsuite for this test * * @return the testsuite */ public static Test suite() { return suite(CompositeValueSupportUnitTestCase.class); } /** * Create a new CompositeValueSupportUnitTestCase. * * @param name the test name */ public CompositeValueSupportUnitTestCase(String name) { super(name); } /** * Test the composite value * * @throws Exception for any problem */ public void testCompositeValueSupport() throws Exception { CompositeMetaType compositeMetaType = initCompositeMetaType(); Map map = initMapValues(); String[] keys = initKeys(); MetaValue[] values = initValues(); new CompositeValueSupport(compositeMetaType, map); new CompositeValueSupport(compositeMetaType, keys, values); } /** * Test the meta type for a composite value * * @throws Exception for any problem */ public void testGetCompositeMetaType() throws Exception { CompositeMetaType compositeMetaType = initCompositeMetaType(); Map map = initMapValues(); CompositeValue v = new CompositeValueSupport(compositeMetaType, map); assertEquals(compositeMetaType, v.getMetaType()); } /** * Test the get for a composite value * * @throws Exception for any problem */ public void testGet()throws Exception { CompositeMetaType compositeMetaType = initCompositeMetaType(); Map map = initMapValues(); CompositeValue v = new CompositeValueSupport(compositeMetaType, map); assertEquals(initStringValue1(), v.get("name1")); assertEquals(initInteger2(), v.get("name2")); } /** * Test the getAll for a composite value * * @throws Exception for any problem */ public void testGetAll() throws Exception { SimpleValue value1 = initStringValue1(); SimpleValue integer2 = initInteger2(); CompositeMetaType compositeMetaType = initCompositeMetaType(); Map map = initMapValues(); CompositeValue v = new CompositeValueSupport(compositeMetaType, map); MetaValue[] result = v.getAll(new String[] { "name1", "name2" }); assertEquals(value1, result[0]); assertEquals(integer2, result[1]); result = v.getAll(new String[] { "name2", "name1" }); assertEquals(value1, result[1]); assertEquals(integer2, result[0]); result = v.getAll(new String[] { "name1" }); assertEquals(value1, result[0]); result = v.getAll(new String[] { "name2" }); assertEquals(integer2, result[0]); } /** * Test the containsKey for a composite value * * @throws Exception for any problem */ public void testContainsKey() throws Exception { CompositeMetaType compositeMetaType = initCompositeMetaType(); Map map = initMapValues(); CompositeValue v = new CompositeValueSupport(compositeMetaType, map); assertTrue("data should contain key name1", v.containsKey("name1")); assertTrue("data should contain key name2", v.containsKey("name2")); assertFalse("data should not contain key nameX", v.containsKey("nameX")); assertFalse("data should not contain key null", v.containsKey(null)); assertFalse("data should not contain key ", v.containsKey("")); } /** * Test the containsValue for a composite value * * @throws Exception for any problem */ public void testContainsValue() throws Exception { SimpleValue value1 = initStringValue1(); SimpleValue integer2 = initInteger2(); SimpleValue name1 = initStringName1(); SimpleValue nullString = initStringNull(); SimpleValue emptyString = initStringEmpty(); SimpleValue nullInteger = initIntegerNull(); CompositeMetaType compositeMetaType = initCompositeMetaType(); Map map = initMapValues(); CompositeValue v = new CompositeValueSupport(compositeMetaType, map); assertTrue("data should contain value value1", v.containsValue(value1)); assertTrue("data should contain value 2", v.containsValue(integer2)); assertFalse("data should not contain value name1", v.containsValue(name1)); assertFalse("data should not contain key null", v.containsValue(null)); assertFalse("data should not contain key null", v.containsValue(nullString)); assertFalse("data should not contain key ", v.containsValue(emptyString)); map.clear(); map.put("name1", value1); map.put("name2", null); v = new CompositeValueSupport(compositeMetaType, map); assertTrue("data should contain value null", v.containsValue(null)); assertFalse("data should not contain key null", v.containsValue(nullString)); map.clear(); map.put("name1", value1); map.put("name2", nullInteger); v = new CompositeValueSupport(compositeMetaType, map); assertTrue("data should contain value null", v.containsValue(nullInteger)); assertFalse("data should not contain key null", v.containsValue(null)); } /** * Test the values for a composite value * * @throws Exception for any problem */ public void testValues() throws Exception { SimpleValue value1 = initStringValue1(); SimpleValue integer2 = initInteger2(); SimpleValue name1 = initStringName1(); SimpleValue nullString = initStringNull(); SimpleValue emptyString = initStringEmpty(); SimpleValue nullInteger = initIntegerNull(); CompositeMetaType compositeMetaType = initCompositeMetaType(); Map map = initMapValues(); CompositeValue v = new CompositeValueSupport(compositeMetaType, map); Collection values = v.values(); assertTrue("data values contain 2 elements", values.size() == 2); assertTrue("data values should have value1", values.contains(value1)); assertTrue("data values should have 2", values.contains(integer2)); assertFalse("data values should not have name1", values.contains(name1)); assertFalse("data values should not have null", values.contains(null)); assertFalse("data values should not have null", values.contains(nullString)); assertFalse("data values should not have ", values.contains(emptyString)); map.clear(); map.put("name1", value1); map.put("name2", null); v = new CompositeValueSupport(compositeMetaType, map); values = v.values(); assertTrue("data values should contain value null", values.contains(null)); assertFalse("data values should not have null", values.contains(nullString)); map.clear(); map.put("name1", value1); map.put("name2", nullInteger); v = new CompositeValueSupport(compositeMetaType, map); values = v.values(); assertTrue("data values should contain value null", values.contains(nullInteger)); assertFalse("data values should not have null", values.contains(null)); } /** * Test the equals for a composite value * * @throws Exception for any problem */ public void testEquals() throws Exception { CompositeMetaType compositeMetaType = initCompositeMetaType(); Map map = initMapValues(); CompositeValue v = new CompositeValueSupport(compositeMetaType, map); assertEquals("data should equal itself", v, v); assertNotSame("data should not equal null", v, null); assertNotSame("data should not equal non CompositeData", v, new Object()); CompositeValue v2 = new CompositeValueSupport(compositeMetaType, map); assertEquals("data should equal with data2 with different instance of the same composite type", v, v2); assertEquals("data should equal with data2 with different instance of the same composite type", v2, v); CompositeMetaType compositeMetaType2 = initCompositeMetaType2(); v2 = new CompositeValueSupport(compositeMetaType2, map); assertNotSame("data should not be equal with data2 with different composite type", v, v2); assertNotSame("data2 should not be equal with data with different composite type", v2, v); Map map2 = initMapValues2(); v2 = new CompositeValueSupport(compositeMetaType, map2); assertNotSame("data should not be equal with data2 with different values", v, v2); assertNotSame("data2 should not be equal with data with different value", v2, v); } /** * Test the hashCode for a composite value * * @throws Exception for any problem */ public void testHashCode() throws Exception { CompositeMetaType compositeMetaType = initCompositeMetaType(); Map map = initMapValues(); CompositeValue v = new CompositeValueSupport(compositeMetaType, map); int myHashCode = compositeMetaType.hashCode() + "value1".hashCode() + new Integer(2).hashCode(); assertEquals("Wrong hash code generated", myHashCode, v.hashCode()); } /** * Test the toString for a composite value * * @throws Exception for any problem */ public void testToString() throws Exception { CompositeMetaType compositeMetaType = initCompositeMetaType(); Map map = initMapValues(); CompositeValue v = new CompositeValueSupport(compositeMetaType, map); String toString = v.toString(); assertTrue("toString() should contain the composite type", toString.indexOf(compositeMetaType.toString()) != -1); assertTrue("toString() should contain name1", toString.indexOf("name1") != -1); assertTrue("toString() should contain value1", toString.indexOf("value1") != -1); assertTrue("toString() should contain name2=", toString.indexOf("name2") != -1); assertTrue(toString + " should contain " + new Integer(2), toString.indexOf(new Integer(2).toString()) != -1); } /** * Test the serialization for a composite value * * @throws Exception for any problem */ public void testSerialization() throws Exception { CompositeMetaType compositeMetaType = initCompositeMetaType(); Map map = initMapValues(); CompositeValue v = new CompositeValueSupport(compositeMetaType, map); byte[] bytes = serialize(v); Object result = deserialize(bytes); assertEquals(v, result); } /** * Test the errors for a composite value * * @throws Exception for any problem */ public void testErrorsArray() throws Exception { CompositeMetaType compositeMetaType = initCompositeMetaType(); String[] itemNames = initKeys(); MetaValue[] itemValues = initValues(); try { new CompositeValueSupport(null, itemNames, itemValues); fail("Excepted IllegalArgumentException for null composite type"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } try { new CompositeValueSupport(compositeMetaType, null, itemValues); fail("Excepted IllegalArgumentException for null item names"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } try { new CompositeValueSupport(compositeMetaType, new String[0], itemValues); fail("Excepted IllegalArgumentException for empty item names"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } try { new CompositeValueSupport(compositeMetaType, itemNames, null); fail("Excepted IllegalArgumentException for null item values"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } try { new CompositeValueSupport(compositeMetaType, itemNames, new MetaValue[0]); fail("Excepted IllegalArgumentException for empty item values"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } try { new CompositeValueSupport(compositeMetaType, new String[] { "name1", null }, itemValues); fail("Excepted IllegalArgumentException for a null item name"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } try { new CompositeValueSupport(compositeMetaType, new String[] { "name1", "" }, itemValues); fail("Excepted IllegalArgumentException for an empty item name"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } try { new CompositeValueSupport(compositeMetaType, itemNames, new MetaValue[] { initStringWrong() }); fail("Excepted IllegalArgumentException for mismatch in number of itemNames/itemValues"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } try { new CompositeValueSupport(compositeMetaType, new String[] { "name1", "wrongName" }, itemValues); fail("Excepted IllegalArgumentException for an item name not in the composite type"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } try { new CompositeValueSupport(compositeMetaType, itemNames, new MetaValue[] { initStringValue1(), initStringWrong() }); fail("Excepted IllegalArgumentException for an item value of the wrong type"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } new CompositeValueSupport(compositeMetaType, itemNames, new MetaValue[] { initStringValue1(), null }); new CompositeValueSupport(compositeMetaType, itemNames, new MetaValue[] { initStringValue1(), initIntegerNull() }); } /** * Test the errors for a composite value * * @throws Exception for any problem */ public void testErrorsMap() throws Exception { CompositeMetaType compositeMetaType = initCompositeMetaType(); Map map = initMapValues(); try { new CompositeValueSupport(null, map); fail("Excepted IllegalArgumentException for null composite type"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } try { HashMap map2 = new HashMap(); map2.put("name1", initStringValue1()); map2.put(null, initInteger2()); new CompositeValueSupport(compositeMetaType, map2); fail("Excepted IllegalArgumentException for a null key in map"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } try { HashMap map2 = new HashMap(); map2.put("name1", initStringValue1()); map2.put("", initInteger2()); new CompositeValueSupport(compositeMetaType, map2); fail("Excepted IllegalArgumentException for an empty key in map"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } try { HashMap map2 = new HashMap(); map2.put("name1", initStringValue1()); map2.put("wrongName", initInteger2()); new CompositeValueSupport(compositeMetaType, map2); fail("Excepted IllegalArgumentException for an item name not in the composite type"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } try { HashMap map2 = new HashMap(); map2.put("name1", initStringValue1()); map2.put("name2", initStringWrong()); new CompositeValueSupport(compositeMetaType, map2); fail("Excepted IllegalArgumentException for an item value of the wrong type"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } HashMap map2 = new HashMap(); map2.put("name1", initStringValue1()); map2.put("name2", null); new CompositeValueSupport(compositeMetaType, map2); map2 = new HashMap(); map2.put("name1", initStringValue1()); map2.put("name2", initIntegerNull()); new CompositeValueSupport(compositeMetaType, map2); } /** * Test the errors for a composite value * * @throws Exception for any problem */ public void testErrors() throws Exception { CompositeMetaType compositeMetaType = initCompositeMetaType(); Map map = initMapValues(); CompositeValue data = new CompositeValueSupport(compositeMetaType, map); try { data.get(null); fail("Excepted IllegalArgumentException for get and a null key"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } try { data.get(""); fail("Excepted IllegalArgumentException for get and an empty key"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } try { data.get("wrong"); fail("Excepted IllegalArgumentException for get and a wrong key"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } try { data.getAll(new String[] { "name1", null }); fail("Excepted IllegalArgumentException for getAll and a null key"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } try { data.getAll(new String[] { "name1", "" }); fail("Excepted IllegalArgumentException for getAll and an empty key"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } try { data.getAll(new String[] { "name1", "wrong" }); fail("Excepted IllegalArgumentException for getAll and an invalid key"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } } } ././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/test/SimpleValueSupportUnitTestCase.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/test/Simp0000644000175000017500000001311310761511660033265 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.values.test; import junit.framework.Test; import org.jboss.metatype.api.types.SimpleMetaType; import org.jboss.metatype.api.values.SimpleValue; import org.jboss.metatype.api.values.SimpleValueSupport; import org.jboss.test.metatype.AbstractMetaTypeTest; /** * SimpleValueSupportUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class SimpleValueSupportUnitTestCase extends AbstractMetaTypeTest { /** * Create a testsuite for this test * * @return the testsuite */ public static Test suite() { return suite(SimpleValueSupportUnitTestCase.class); } /** * Create a new SimpleValueSupportUnitTestCase. * * @param name the test name */ public SimpleValueSupportUnitTestCase(String name) { super(name); } /** * Test the simple value * * @throws Exception for any problem */ public void testSimpleValueSupport() throws Exception { initStringValue1(); } /** * Test the meta type for a simple value * * @throws Exception for any problem */ public void testGetSimpleMetaType() throws Exception { SimpleValue value = initStringValue1(); assertEquals(SimpleMetaType.STRING, value.getMetaType()); } /** * Test the getValue for a simple value * * @throws Exception for any problem */ public void testGetValue()throws Exception { SimpleValue value = initStringValue1(); assertEquals("value1", value.getValue()); } /** * Test the setValue for a simple value * * @throws Exception for any problem */ public void testSetValue()throws Exception { SimpleValueSupport value = (SimpleValueSupport) initStringValue1(); value.setValue("value2"); assertEquals("value2", value.getValue()); } /** * Test the equals for a simple value * * @throws Exception for any problem */ public void testEquals() throws Exception { SimpleValue v = initStringValue1(); assertEquals("data should equal itself", v, v); assertNotSame("data should not equal null", v, null); assertNotSame("data should not equal null value", v, initStringNull()); assertNotSame("data should not equal empty value", v, initStringEmpty()); assertNotSame("data should not equal non SimpleValue", v, new Object()); SimpleValue v2 = initStringValue1(); assertEquals("data should equal with data2 with different instance of the same simple type", v, v2); assertEquals("data should equal with data2 with different instance of the same simple type", v2, v); v2 = initInteger2(); assertNotSame("data should not be equal with data2 with different simple type", v, v2); assertNotSame("data2 should not be equal with data with different simple type", v2, v); v2 = initStringName1(); assertNotSame("data should not be equal with data2 with different values", v, v2); assertNotSame("data2 should not be equal with data with different value", v2, v); } /** * Test the hashCode for a simple value * * @throws Exception for any problem */ public void testHashCode() throws Exception { SimpleValue v = initStringValue1(); int myHashCode = "value1".hashCode(); assertEquals("Wrong hash code generated", myHashCode, v.hashCode()); } /** * Test the toString for a simple value * * @throws Exception for any problem */ public void testToString() throws Exception { SimpleValue v = initStringValue1(); String toString = v.toString(); assertTrue("toString() should contain the simple type", toString.indexOf(SimpleMetaType.STRING.toString()) != -1); assertTrue("toString() should contain value1", toString.indexOf("value1") != -1); } /** * Test the serialization for a simple value * * @throws Exception for any problem */ public void testSerialization() throws Exception { SimpleValue v = initStringValue1(); byte[] bytes = serialize(v); Object result = deserialize(bytes); assertEquals(v, result); } /** * Test the errors for a simple value * * @throws Exception for any problem */ public void testErrors() throws Exception { try { new SimpleValueSupport(null, "value1"); fail("Excepted IllegalArgumentException for null simple type"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } new SimpleValueSupport(SimpleMetaType.STRING, null); } } ././@LongLink0000000000000000000000000000020300000000000011560 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/test/ArrayValueSupportUnitTestCase.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/test/Arra0000644000175000017500000001152710761511660033251 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.values.test; import java.lang.reflect.Array; import junit.framework.Test; import org.jboss.metatype.api.types.ArrayMetaType; import org.jboss.metatype.api.types.SimpleMetaType; import org.jboss.metatype.api.values.ArrayValueSupport; import org.jboss.test.metatype.AbstractMetaTypeTest; /** * Tests of the ArrayValueSupport class. * * @author Scott.Stark@jboss.org * @version $Revision: 70207 $ */ public class ArrayValueSupportUnitTestCase extends AbstractMetaTypeTest { /** * Create a testsuite for this test * * @return the testsuite */ public static Test suite() { return suite(ArrayValueSupportUnitTestCase.class); } /** * Create a new ArrayValueSupportUnitTestCase. * * @param name the test name */ public ArrayValueSupportUnitTestCase(String name) { super(name); } @SuppressWarnings("unchecked") static T[] convert(Object array, T[] t) { int length = Array.getLength(array); Class c = t.getClass().getComponentType(); T[] result = (T[]) Array.newInstance(c, length); for(int n = 0; n < length; n ++) { result[n] = (T) Array.get(array, n); } return result; } public void testCharArray() throws Exception { ArrayMetaType type = new ArrayMetaType(1, SimpleMetaType.CHARACTER); char[] value = {'h', 'e', 'l', 'l', 'o'}; ArrayValueSupport avs = new ArrayValueSupport(type, value); // Use getValue(int) accessor for(int n = 0; n < avs.getLength(); n ++) { Object element = avs.getValue(n); assertEquals(value[n], element); } // Use typesafe foreach Iterable int i = 0; for(Object c : avs) { assertEquals("["+i+"]", value[i++], c); } // Validate the primative array char[] raw = (char[]) avs.getValue(); for(int n = 0; n < value.length; n ++) { assertEquals(value[n], raw[n]); } } @SuppressWarnings("unchecked") public void testCharacterArray() throws Exception { ArrayMetaType type = new ArrayMetaType(1, SimpleMetaType.CHARACTER); Character[] value = {'h', 'e', 'l', 'l', 'o'}; ArrayValueSupport avs = new ArrayValueSupport(type, value); for(int n = 0; n < avs.getLength(); n ++) { Object element = avs.getValue(n); assertEquals(value[n], element); } // Validate the raw array Character[] raw = (Character[]) avs.getValue(); for(int n = 0; n < value.length; n ++) { assertEquals(value[n], raw[n]); } } public void test2DCharArray() throws Exception { ArrayMetaType type = new ArrayMetaType(2, SimpleMetaType.CHARACTER, true); char[][] value = {{'h', 'e'}, {'l', 'l', 'o'}}; ArrayValueSupport avs = new ArrayValueSupport(type, value); assertEquals(value.length, avs.getLength()); for(int m = 0; m < value.length; m ++) { Object arraym = avs.getValue(m); for(int n = 0; n < value[m].length; n ++) { // Have to use the java.lang.reflect.Array to access nested elements Object valuenm = Array.get(arraym, n); assertEquals("["+m+"]["+n+"]", value[m][n], valuenm); } } /* FIXME: Use typesafe foreach Iterable: current broken with CCE on [C int i = 0, j = 0; for(Character[] carray : avs) { for(Character c : carray) { Character cij = value[i ++][j ++]; assertEquals("["+i+"], ["+j+"]", cij , c); } } */ // Validate the primitive 2d array char[][] raw = (char[][]) avs.getValue(); for(int m = 0; m < value.length; m ++) { for(int n = 0; n < value[m].length; n ++) { assertEquals("["+m+"]["+n+"]", value[m][n], raw[m][n]); } } } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/test/ValuesTestSuite.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/test/Valu0000644000175000017500000000363610657001651033273 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2005, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.values.test; import junit.framework.Test; import junit.framework.TestSuite; import junit.textui.TestRunner; /** * Values Test Suite. * * @author Adrian Brock * @version $Revision: 55115 $ */ public class ValuesTestSuite extends TestSuite { /** * For running the testsuite from the command line * * @param args the command line args */ public static void main(String[] args) { TestRunner.run(suite()); } /** * Create the testsuite * * @return the testsuite */ public static Test suite() { TestSuite suite = new TestSuite("Values Tests"); suite.addTest(ArrayValueSupportUnitTestCase.suite()); suite.addTest(SimpleValueSupportUnitTestCase.suite()); suite.addTest(CompositeValueSupportUnitTestCase.suite()); suite.addTest(TableValueSupportUnitTestCase.suite()); return suite; } } ././@LongLink0000000000000000000000000000020300000000000011560 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/test/TableValueSupportUnitTestCase.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/test/Tabl0000644000175000017500000006712610645072106033252 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.values.test; import java.util.Arrays; import java.util.Collection; import java.util.List; import java.util.Map; import java.util.Set; import junit.framework.Test; import org.jboss.metatype.api.types.CompositeMetaType; import org.jboss.metatype.api.types.ImmutableTableMetaType; import org.jboss.metatype.api.types.TableMetaType; 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.TableValue; import org.jboss.metatype.api.values.TableValueSupport; import org.jboss.test.metatype.AbstractMetaTypeTest; /** * TableValueSupportUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class TableValueSupportUnitTestCase extends AbstractMetaTypeTest { /** * Create a testsuite for this test * * @return the testsuite */ public static Test suite() { return suite(TableValueSupportUnitTestCase.class); } /** * Create a new TableValueSupportUnitTestCase. * * @param name the test name */ public TableValueSupportUnitTestCase(String name) { super(name); } /** * Test the table value support * * @throws Exception for any problem */ public void testTableValueSupport() throws Exception { TableMetaType tableType = initTableType(); new TableValueSupport(tableType); new TableValueSupport(tableType, 100, .5f); } /** * Test the table type for a table value * * @throws Exception for any problem */ public void testGetTableType() throws Exception { TableMetaType tableType = initTableType(); TableValueSupport data = new TableValueSupport(tableType); assertTrue("Expected the same table type", data.getMetaType().equals(tableType)); } /** * Test the calculate index for a table value * * @throws Exception for any problem */ public void testCalculateIndex() throws Exception { TableMetaType tableType = initTableType(); TableValueSupport data = new TableValueSupport(tableType); CompositeValue compData = initCompositeValue(data); Object[] index = data.calculateIndex(compData); assertEquals("Expected index element 0 to be value1", index[0], initStringValue1()); assertEquals("Expected index element 1 to be 2", index[1], initInteger2()); compData = initCompositeValue3(data); index = data.calculateIndex(compData); assertEquals("Expected index element 0 to be value2", index[0], initStringValue2()); assertEquals("Expected index element 1 to be 3", index[1], initInteger3()); } /** * Test the contains key for a table value * * @throws Exception for any problem */ public void testContainsKey() throws Exception { TableMetaType tableType = initTableType(); TableValueSupport data = new TableValueSupport(tableType); assertFalse("Didn't expect containsKey null", data.containsKey(null)); MetaValue[] index = new MetaValue[] { initStringValue1(), initInteger2() }; assertFalse("Didn't expect containsKey on empty data", data.containsKey(index)); CompositeValue compData = initCompositeValue2(data); assertFalse("Didn't expect containsKey on index not present", data.containsKey(index)); compData = initCompositeValue(data); data.put(compData); assertTrue("Expected containsKey", data.containsKey(index)); compData = initCompositeValue2(data); assertFalse("Didn't expect containsKey on index still not present", data.containsKey(data.calculateIndex(compData))); data.remove(index); assertFalse("Didn't expect removed data in containsKey", data.containsKey(index)); } /** * Test the contains value for a table value * * @throws Exception for any problem */ public void testContainsValue() throws Exception { TableMetaType tableType = initTableType(); TableValueSupport data = new TableValueSupport(tableType); assertFalse("Didn't expect containsValue null", data.containsValue(null)); CompositeMetaType rowType2 = initCompositeMetaType2(); CompositeValue compData2 = initCompositeValue(rowType2); assertFalse("Didn't expect containsValue wrong composite type", data.containsValue(compData2)); CompositeValue compData = initCompositeValue(data); assertFalse("Didn't expect containsValue on data not present", data.containsValue(compData)); data.put(compData); assertTrue("Expected containsValue", data.containsValue(compData)); compData = initCompositeValue2(data); assertFalse("Didn't expect containsValue on value still not present", data.containsValue(compData)); assertFalse("Didn't expect containsValue still wrong composite type", data.containsValue(compData2)); data.remove(data.calculateIndex(compData)); assertFalse("Didn't expect removed data in containsValue", data.containsValue(compData)); } /** * Test the get for a table value * * @throws Exception for any problem */ public void testGet() throws Exception { TableMetaType tableType = initTableType(); TableValueSupport data = new TableValueSupport(tableType); MetaValue[] index = initValues2(); assertNull("Expected null for get on data not present", data.get(index)); CompositeValue compData = initCompositeValue(data); index = initValues(); data.put(compData); assertEquals("Expected get to return the same value", compData, data.get(index)); index = initValues2(); assertNull("Didn't expect get on value still not present", data.get(index)); index = initValues(); data.remove(index); assertNull("Didn't expect removed data in get", data.get(index)); } /** * Test the put for a table value * * @throws Exception for any problem */ public void testPut() throws Exception { TableMetaType tableType = initTableType(); TableValueSupport data = new TableValueSupport(tableType); CompositeValue compData = initCompositeValue(data); MetaValue[] index = initValues(); data.put(compData); assertEquals("The data should be present after put", compData, data.get(index)); CompositeValue compData2 = initCompositeValue2(data); index = initValues2(); data.put(compData2); assertEquals("Another data should be present after put", compData2, data.get(index)); index = initValues(); assertEquals("The previous data should be present after put", compData, data.get(index)); data.remove(index); data.put(compData); assertEquals("Data should be present after remove/put", compData, data.get(index)); } /** * Test the remove for a table value * * @throws Exception for any problem */ public void testRemove() throws Exception { TableMetaType tableType = initTableType(); TableValueSupport data = new TableValueSupport(tableType); CompositeValue compData = initCompositeValue(data); MetaValue[] index = initValues(); assertNull("Remove on data not present returns null", data.remove(index)); data.put(compData); assertEquals("Remove on data present returns the data", compData, data.remove(index)); } /** * Test the put all for a table value * * @throws Exception for any problem */ public void testPutAll() throws Exception { TableMetaType tableType = initTableType(); TableValueSupport data = new TableValueSupport(tableType); data.putAll((CompositeValue[]) null); assertTrue("Put all null is ok", data.isEmpty()); CompositeValue compData = initCompositeValue(data); CompositeValue[] toPut = new CompositeValue[] { compData }; data.putAll(toPut); assertEquals("Put all added one", 1, data.size()); assertTrue("Put all added the correct data", data.containsValue(compData)); CompositeValue compData2 = initCompositeValue2(data); CompositeValue compData3 = initCompositeValue4(data); toPut = new CompositeValue[] { compData2, compData3 }; data.putAll(toPut); assertEquals("Put all added two", 3, data.size()); assertTrue("Put all added the correct data", data.containsValue(compData2)); assertTrue("Put all added the correct data", data.containsValue(compData3)); assertTrue("Put all original data still present", data.containsValue(compData)); } /** * Test the clear for a table value * * @throws Exception for any problem */ public void testClear() throws Exception { TableMetaType tableType = initTableType(); TableValueSupport data = new TableValueSupport(tableType); data.putAll((CompositeValue[]) null); assertTrue("Put all null is ok", data.isEmpty()); CompositeValue compData = initCompositeValue(data); CompositeValue compData2 = initCompositeValue2(data); CompositeValue compData3 = initCompositeValue4(data); data.putAll(new CompositeValue[] { compData, compData2, compData3 }); data.clear(); assertTrue("Clear should clear the data", data.isEmpty()); } /** * Test the size for a table value * * @throws Exception for any problem */ public void testSize() throws Exception { TableMetaType tableType = initTableType(); TableValueSupport data = new TableValueSupport(tableType); assertEquals("Initial size is zero", 0, data.size()); CompositeValue compData = initCompositeValue(data); data.putAll(new CompositeValue[] { compData }); assertEquals("Expected one element", 1, data.size()); CompositeValue compData2 = initCompositeValue2(data); CompositeValue compData3 = initCompositeValue4(data); data.putAll(new CompositeValue[] { compData2, compData3 }); assertEquals("Expected three elements", 3, data.size()); data.remove(initValues4()); assertEquals("Expected two elements", 2, data.size()); data.clear(); assertEquals("Expected no elements", 0, data.size()); } /** * Test the isEmpty for a table value * * @throws Exception for any problem */ public void testIsEmpty() throws Exception { TableMetaType tableType = initTableType(); TableValueSupport data = new TableValueSupport(tableType); assertTrue("Initially empty", data.isEmpty()); CompositeValue compData = initCompositeValue(data); data.putAll(new CompositeValue[] { compData }); assertFalse("Not empty after a put", data.isEmpty()); data.clear(); assertTrue("Expected no elements", data.isEmpty()); } /** * Test the keySet for a table value * * @throws Exception for any problem */ public void testKeySet() throws Exception { TableMetaType tableType = initTableType(); TableValueSupport data = new TableValueSupport(tableType); CompositeValue compData = initCompositeValue(data); CompositeValue compData2 = initCompositeValue2(data); CompositeValue compData3 = initCompositeValue4(data); data.putAll(new CompositeValue[] { compData, compData2, compData3 }); Set> keySet = data.keySet(); assertEquals("Key set should contain 3 elements", 3, keySet.size()); assertTrue("Key set should contain index [value1, 2]", keySet.contains(Arrays.asList(initValues()))); assertTrue("Key set should contain index [value1, 3]", keySet.contains(Arrays.asList(initValues2()))); assertTrue("Key set should contain index [value1, 4]", keySet.contains(Arrays.asList(initValues4()))); } /** * Test the values for a table value * * @throws Exception for any problem */ public void testValues() throws Exception { TableMetaType tableType = initTableType(); TableValueSupport data = new TableValueSupport(tableType); CompositeValue compData = initCompositeValue(data); CompositeValue compData2 = initCompositeValue2(data); CompositeValue compData3 = initCompositeValue4(data); data.putAll(new CompositeValue[] { compData, compData2, compData3 }); Collection values = data.values(); assertEquals("Values should contain 3 elements", 3, values.size()); assertTrue("Values should contain index compData", values.contains(compData)); assertTrue("Values should contain index compData2", values.contains(compData2)); assertTrue("Values should contain index compData3", values.contains(compData3)); } /** * Test the clone for a table value * * @throws Exception for any problem */ public void testClone() throws Exception { TableMetaType tableType = initTableType(); TableValueSupport data = new TableValueSupport(tableType); CompositeValue compData = initCompositeValue(data); CompositeValue compData2 = initCompositeValue2(data); CompositeValue compData3 = initCompositeValue4(data); data.putAll(new CompositeValue[] { compData, compData2, compData3 }); TableValue clone = data.clone(); assertEquals("Clone should have the same tabular type", data.getMetaType(), clone.getMetaType()); assertEquals("Clone should have the same number of elements", data.size(), clone.size()); CompositeValue compDataClone = clone.get(initValues()); assertTrue("Should be a shallow clone", compData == compDataClone); } /** * Test the equals for a table value * * @throws Exception for any problem */ public void testEquals() throws Exception { TableMetaType tableType = initTableType(); TableValueSupport data = new TableValueSupport(tableType); assertNotSame("Null should not be equal", data, null); assertNotSame("Only TableValues should be equal", data, new Object()); assertEquals("An instance should equal itself", data, data); TableValueSupport data2 = new TableValueSupport(tableType); assertEquals("Two different instances with the same table type are equal", data, data2); assertEquals("Two different instances with the same table type are equal", data2, data); TableMetaType tableType2 = initTableType2(); data2 = new TableValueSupport(tableType2); assertNotSame("Instances with different table type are not equal", data, data2); assertNotSame("Instances with different table type are not equal", data2, data); CompositeValue compData = initCompositeValue(data); CompositeValue compData2 = initCompositeValue2(data); CompositeValue compData3 = initCompositeValue4(data); data.putAll(new CompositeValue[] { compData, compData2, compData3 }); data2 = new TableValueSupport(tableType); data2.putAll(new CompositeValue[] { compData, compData2, compData3 }); assertEquals("Instances with the same composite values are equal", data, data2); assertEquals("Instances with the same composite values are equal", data2, data); data2 = new TableValueSupport(tableType); data2.putAll(new CompositeValue[] { compData, compData2}); assertNotSame("Instances with different composite values are not equal", data, data2); assertNotSame("Instances with different composite values are not equal", data2, data); } /** * Test the hashCode for a table value * * @throws Exception for any problem */ public void testHashCode() throws Exception { TableMetaType tableType = initTableType(); TableValueSupport data = new TableValueSupport(tableType); CompositeValue compData = initCompositeValue(data); CompositeValue compData2 = initCompositeValue2(data); CompositeValue compData3 = initCompositeValue4(data); data.putAll(new CompositeValue[] { compData, compData2, compData3 }); int myHashCode = tableType.hashCode() + compData.hashCode() + compData2.hashCode() + compData3.hashCode(); assertEquals("Wrong hash code generated", myHashCode, data.hashCode()); } /** * Test the toString for a table value * * @throws Exception for any problem */ public void testToString() throws Exception { TableMetaType tableType = initTableType(); TableValueSupport data = new TableValueSupport(tableType); CompositeValue compData = initCompositeValue(data); CompositeValue compData2 = initCompositeValue2(data); CompositeValue compData3 = initCompositeValue4(data); data.putAll(new CompositeValue[] { compData, compData2, compData3 }); String toString = data.toString(); assertTrue("toString() should contain the tabular type", toString.indexOf(tableType.toString()) != -1); assertTrue("toString() should contain index=compositeValue for compData", toString.indexOf(Arrays.asList(data.calculateIndex(compData)) + "=" + compData) != -1); assertTrue("toString() should contain index=compositeValue for compData2", toString.indexOf(Arrays.asList(data.calculateIndex(compData2)) + "=" + compData2) != -1); assertTrue("toString() should contain index=compositeValue for compData3", toString.indexOf(Arrays.asList(data.calculateIndex(compData3)) + "=" + compData3) != -1); } /** * Test the serialization for a table value * * @throws Exception for any problem */ public void testSerialization() throws Exception { TableMetaType tableType = initTableType(); TableValueSupport data = new TableValueSupport(tableType); CompositeValue compData = initCompositeValue(data); CompositeValue compData2 = initCompositeValue2(data); CompositeValue compData3 = initCompositeValue4(data); data.putAll(new CompositeValue[] { compData, compData2, compData3 }); byte[] bytes = serialize(data); Object result = deserialize(bytes); assertEquals(data, result); } /** * Test the errors for a table value * * @throws Exception for any problem */ public void testErrors() throws Exception { TableMetaType tableType = initTableType(); CompositeValue compData = initCompositeValue(tableType.getRowType()); CompositeValue compData2 = initCompositeValue2(initCompositeMetaType2()); try { new TableValueSupport(null); fail("Expected IllegalArgumentException for null tabular type"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } try { new TableValueSupport(null, 10, .5f); fail("Expected IllegalArgumentException for null tabular type"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } try { new TableValueSupport(tableType, -1, .5f); fail("Expected IllegalArgumentException for negative initial capacity"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } try { new TableValueSupport(tableType, 10, 0f); fail("Expected IllegalArgumentException for zero load factor"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } try { new TableValueSupport(tableType, 10, -0.5f); fail("Expected IllegalArgumentException for negative load factor"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } try { TableValueSupport data = new TableValueSupport(tableType); data.calculateIndex(null); fail("Expected IllegalArgumentException for calculate index on null object"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } try { TableValueSupport data = new TableValueSupport(tableType); data.calculateIndex(compData2); fail("Expected IllegalArgumentException for calculate index on wrong composite type"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } try { TableValueSupport data = new TableValueSupport(tableType); data.get((MetaValue[]) null); fail("Expected IllegalArgumentException for get(null)"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } try { TableValueSupport data = new TableValueSupport(tableType); data.get(new MetaValue[] { initStringWrong() }); fail("Expected IllegalArgumentException for get(wrong)"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } try { TableValueSupport data = new TableValueSupport(tableType); data.put(null); fail("Expected IllegalArgumentException for put(CompositeValue) with null value"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } try { TableValueSupport data = new TableValueSupport(tableType); data.put(compData2); fail("Expected IllegalArgumentException for put(CompositeValue) with wrong CompositeType"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } try { TableValueSupport data = new TableValueSupport(tableType); data.put(compData); data.put(compData); fail("Expected IllegalArgumentException for put(CompositeValue)"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } try { TableValueSupport data = new TableValueSupport(tableType); data.remove((MetaValue[]) null); fail("Expected IllegalArgumentException for remove(null)"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } try { TableValueSupport data = new TableValueSupport(tableType); data.remove(new MetaValue[] { initStringWrong() }); fail("Expected IllegalArgumentException for remove(wrong)"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } try { TableValueSupport data = new TableValueSupport(tableType); CompositeValue[] toPut = new CompositeValue[] { compData, null }; data.putAll(toPut); fail("Expected IllegalArgumentException for putAll(CompositeValue[]) null"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } try { TableValueSupport data = new TableValueSupport(tableType); CompositeValue[] toPut = new CompositeValue[] { compData, compData2 }; data.putAll(toPut); fail("Expected IllegalArgumentException for putAll(CompositeValue[]) wrong composite type"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } try { TableValueSupport data = new TableValueSupport(tableType); CompositeValue[] toPut = new CompositeValue[] { compData, compData }; data.putAll(toPut); fail("Expected IllegalArgumentException for putAll(CompositeValue[]) with duplicate data"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } try { TableValueSupport data = new TableValueSupport(tableType); CompositeValue[] toPut = new CompositeValue[] { compData }; data.putAll(toPut); data.putAll(toPut); fail("Expected IllegalArgumentException for putAll(CompositeValue[]) adding a duplicate"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } } /** * Initialize a test table type * * @return the type */ protected TableMetaType initTableType() { CompositeMetaType rowType = initCompositeMetaType(); String[] indexNames = new String[] { "name1", "name2" }; TableMetaType tableType = new ImmutableTableMetaType("typeName", "description", rowType, indexNames); return tableType; } /** * Initialize a test table type 2 * * @return the type */ protected TableMetaType initTableType2() { CompositeMetaType rowType = initCompositeMetaType(); String[] indexNames = new String[] { "name1", "name2" }; TableMetaType tableType = new ImmutableTableMetaType("typeName2", "description", rowType, indexNames); return tableType; } /** * Initialize a test composite value * * @param tableValue the table value * @return the type */ protected CompositeValue initCompositeValue(TableValue tableValue) { return initCompositeValue(tableValue.getMetaType().getRowType()); } /** * Initialize a test composite value * * @param rowType the row type * @return the type */ protected CompositeValue initCompositeValue(CompositeMetaType rowType) { Map map = initMapValues(); CompositeValue compData = new CompositeValueSupport(rowType, map); return compData; } /** * Initialize a test composite value 2 * * @param tableValue the table value * @return the type */ protected CompositeValue initCompositeValue2(TableValue tableValue) { return initCompositeValue2(tableValue.getMetaType().getRowType()); } /** * Initialize a test composite value 2 * * @param rowType the row type * @return the type */ protected CompositeValue initCompositeValue2(CompositeMetaType rowType) { Map map = initMapValues2(); CompositeValue compData = new CompositeValueSupport(rowType, map); return compData; } /** * Initialize a test composite value 3 * * @param tableValue the table value * @return the type */ protected CompositeValue initCompositeValue3(TableValue tableValue) { Map map = initMapValues3(); CompositeValue compData = new CompositeValueSupport(tableValue.getMetaType().getRowType(), map); return compData; } /** * Initialize a test composite value 4 * * @param tableValue the table value * @return the type */ protected CompositeValue initCompositeValue4(TableValue tableValue) { Map map = initMapValues4(); CompositeValue compData = new CompositeValueSupport(tableValue.getMetaType().getRowType(), map); return compData; } } libjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/factory/0000755000175000017500000000000011105402543033113 5ustar twernertwerner././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/factory/test/libjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/factory/t0000755000175000017500000000000011105402543033277 5ustar twernertwerner././@LongLink0000000000000000000000000000021700000000000011565 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/factory/test/CompositeValueFactoryUnitTestCase.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/factory/t0000644000175000017500000002056110764347532033325 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.values.factory.test; import java.lang.reflect.Field; import java.lang.reflect.Type; import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.Properties; import java.util.Set; import junit.framework.Test; import org.jboss.metatype.api.types.SimpleMetaType; import org.jboss.metatype.api.values.CompositeValue; import org.jboss.metatype.api.values.CompositeValueSupport; import org.jboss.metatype.api.values.MapCompositeValueSupport; import org.jboss.metatype.api.values.MetaValue; import org.jboss.metatype.api.values.SimpleValueSupport; import org.jboss.metatype.plugins.types.MutableCompositeMetaType; import org.jboss.test.metatype.values.factory.support.TestIgnoredCompositeItem; import org.jboss.test.metatype.values.factory.support.TestRecursiveComposite; import org.jboss.test.metatype.values.factory.support.TestRenamedCompositeItem; import org.jboss.test.metatype.values.factory.support.TestSimpleComposite; /** * CompositeValueFactoryUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class CompositeValueFactoryUnitTestCase extends AbstractMetaValueFactoryTest { /** * Create a testsuite for this test * * @return the testsuite */ public static Test suite() { return suite(CompositeValueFactoryUnitTestCase.class); } /** * Create a new CompositeValueFactoryUnitTestCase. * * @param name the test name */ public CompositeValueFactoryUnitTestCase(String name) { super(name); } /** * Test the correct value is generated for a simple composite * * @throws Exception for any problem */ public void testSimpleComposite() throws Exception { MutableCompositeMetaType compositeType = new MutableCompositeMetaType(TestSimpleComposite.class.getName(), TestSimpleComposite.class.getName()); compositeType.addItem("something", "something", SimpleMetaType.STRING); compositeType.freeze(); String[] compositeNames = { "something" }; CompositeValue expected = new CompositeValueSupport(compositeType, compositeNames, new MetaValue[] { SimpleValueSupport.wrap("Hello") }); MetaValue result = createMetaValue(new TestSimpleComposite("Hello")); CompositeValue actual = assertInstanceOf(result, CompositeValue.class); getLog().debug("Composite Value: " + actual); assertEquals(expected, actual); } /** * Test the correct value is generated for a recursive composite * * @throws Exception for any problem */ public void testRecursiveComposite() throws Exception { MutableCompositeMetaType compositeType = new MutableCompositeMetaType(TestRecursiveComposite.class.getName(), TestRecursiveComposite.class.getName()); compositeType.addItem("id", "id", SimpleMetaType.STRING); compositeType.addItem("other", "other", compositeType); Set keys = Collections.singleton("id"); compositeType.setKeys(keys); compositeType.freeze(); CompositeValueSupport expected = new CompositeValueSupport(compositeType); expected.set("id", SimpleValueSupport.wrap("Hello")); expected.set("other", expected); TestRecursiveComposite object = new TestRecursiveComposite("Hello"); object.setOther(object); MetaValue result = createMetaValue(object); CompositeValue actual = assertInstanceOf(result, CompositeValue.class); getLog().debug("Composite Value: " + actual); assertEquals(expected, actual); } public void testIgnoreItem() throws Exception { MutableCompositeMetaType compositeType = new MutableCompositeMetaType(TestIgnoredCompositeItem.class.getName(), TestIgnoredCompositeItem.class.getName()); compositeType.addItem("id", "id", SimpleMetaType.STRING); Set keys = Collections.singleton("id"); compositeType.setKeys(keys); compositeType.freeze(); CompositeValueSupport expected = new CompositeValueSupport(compositeType); expected.set("id", SimpleValueSupport.wrap("Hello")); TestIgnoredCompositeItem object = new TestIgnoredCompositeItem(); object.setId("Hello"); object.setIgnored("Ignored?"); MetaValue result = createMetaValue(object); CompositeValue actual = assertInstanceOf(result, CompositeValue.class); getLog().debug("Composite Value: " + actual); assertEquals(expected, actual); } public void testRenameItem() throws Exception { MutableCompositeMetaType compositeType = new MutableCompositeMetaType(TestRenamedCompositeItem.class.getName(), TestRenamedCompositeItem.class.getName()); compositeType.addItem("id", "id", SimpleMetaType.STRING); compositeType.addItem("renamed", "renamed", SimpleMetaType.STRING); Set keys = Collections.singleton("id"); compositeType.setKeys(keys); compositeType.freeze(); CompositeValueSupport expected = new CompositeValueSupport(compositeType); expected.set("id", SimpleValueSupport.wrap("Hello")); expected.set("renamed", SimpleValueSupport.wrap("Renamed")); TestRenamedCompositeItem object = new TestRenamedCompositeItem(); object.setId("Hello"); object.setValue("Renamed"); MetaValue result = createMetaValue(object); CompositeValue actual = assertInstanceOf(result, CompositeValue.class); getLog().debug("Composite Value: " + actual); assertEquals(expected, actual); } public HashMap compositeSignature; /** * JBMICROCONT-238, Map should map to a MapCompositeValueSupport(MetaValue) * @throws Exception */ public void testMapWithStringKeyComposite() throws Exception { Field field = getClass().getField("compositeSignature"); Type mapSignature = field.getGenericType(); Map values = new HashMap(); values.put("key1", "value1"); values.put("key2", "value2"); values.put("key3", "value3"); MapCompositeValueSupport expected = new MapCompositeValueSupport(SimpleMetaType.STRING); expected.put("key1", SimpleValueSupport.wrap("value1")); expected.put("key2", SimpleValueSupport.wrap("value2")); expected.put("key3", SimpleValueSupport.wrap("value3")); MetaValue result = createMetaValue(values, mapSignature); CompositeValue actual = assertInstanceOf(result, CompositeValue.class); getLog().debug("Composite Value: " + actual); assertEquals(expected, actual); } /** * JBMICROCONT-238, java.util.Properties should map to a MapCompositeValueSupport(MetaValue) * @throws Exception */ public void testPropertiesComposite() throws Exception { Type propertiesType = Properties.class; Properties values = new Properties(); values.put("key1", "value1"); values.put("key2", "value2"); values.put("key3", "value3"); MapCompositeValueSupport expected = new MapCompositeValueSupport(SimpleMetaType.STRING); expected.put("key1", SimpleValueSupport.wrap("value1")); expected.put("key2", SimpleValueSupport.wrap("value2")); expected.put("key3", SimpleValueSupport.wrap("value3")); MetaValue result = createMetaValue(values, propertiesType); CompositeValue actual = assertInstanceOf(result, CompositeValue.class); getLog().debug("Composite Value: " + actual); assertEquals(expected, actual); } } ././@LongLink0000000000000000000000000000021200000000000011560 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/factory/test/AbstractMetaValueFactoryTest.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/factory/t0000644000175000017500000000674110761511660033321 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.values.factory.test; import java.lang.reflect.Type; 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.spi.types.MetaTypeBuilder; import org.jboss.metatype.spi.values.MetaValueBuilder; import org.jboss.test.metatype.AbstractMetaTypeTest; /** * AbstractMetaValueFactoryTest. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public abstract class AbstractMetaValueFactoryTest extends AbstractMetaTypeTest { /** The metatype factory */ private static final MetaTypeFactory metaTypeFactory = MetaTypeFactory.getInstance(); /** The meta value factory */ private static final MetaValueFactory metaValueFactory = MetaValueFactory.getInstance(); /** * Create a new AbstractMetaValueFactoryTest. * * @param name the test name */ public AbstractMetaValueFactoryTest(String name) { super(name); } /** * Set a builder * * @param clazz the clazz * @param builder the builder */ protected void setBuilder(Class clazz, MetaValueBuilder builder) { metaTypeFactory.setBuilder(clazz, (MetaTypeBuilder) builder); metaValueFactory.setBuilder(clazz, builder); } /** * Resolve a meta type * * @param type the type * @return the meta type */ protected MetaType resolve(Type type) { return metaTypeFactory.resolve(type); } /** * Create a meta value * * @param value the value * @return the meta value */ protected MetaValue createMetaValue(Object value) { return metaValueFactory.create(value); } /** * Create a meta value * * @param value the value * @param type the type * @return the meta value */ protected MetaValue createMetaValue(Object value, Type type) { return metaValueFactory.create(value, type); } /** * Unwrap meta value. * * @param value the meta value * @return unwrapped */ protected Object unwrapMetaValue(MetaValue value) { return metaValueFactory.unwrap(value); } /** * Unwrap meta value. * * @param value the meta value * @param type expecyed type * @return unwrapped */ protected Object unwrapMetaValue(MetaValue value, Type type) { return metaValueFactory.unwrap(value, type); } } ././@LongLink0000000000000000000000000000021300000000000011561 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/factory/test/ArrayValueFactoryUnitTestCase.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/factory/t0000644000175000017500000001532610761511660033320 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.values.factory.test; import org.jboss.metatype.api.types.ArrayMetaType; import org.jboss.metatype.api.types.CompositeMetaType; import org.jboss.metatype.api.values.ArrayValue; import org.jboss.metatype.api.values.ArrayValueSupport; 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.SimpleValueSupport; import org.jboss.test.metatype.values.factory.support.TestSimpleComposite; import junit.framework.Test; /** * ArrayValueFactoryUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class ArrayValueFactoryUnitTestCase extends AbstractMetaValueFactoryTest { /** * Create a testsuite for this test * * @return the testsuite */ public static Test suite() { return suite(ArrayValueFactoryUnitTestCase.class); } /** * Create a new ArrayValueFactoryUnitTestCase. * * @param name the test name */ public ArrayValueFactoryUnitTestCase(String name) { super(name); } /** * Test the correct value is generated for a simple array * * @throws Exception for any problem */ @SuppressWarnings("unchecked") public void testSimpleArray() throws Exception { String[] array = { "Hello", "Goodbye" }; ArrayMetaType arrayType = assertInstanceOf(resolve(array.getClass()), ArrayMetaType.class); MetaValue[] metaArray = { SimpleValueSupport.wrap("Hello"), SimpleValueSupport.wrap("Goodbye") }; ArrayValueSupport expected = new ArrayValueSupport(arrayType, metaArray); MetaValue result = createMetaValue(array); ArrayValue actual = assertInstanceOf(result, ArrayValue.class); getLog().debug("Array Value: " + actual); assertEquals(expected, actual); } @SuppressWarnings("unchecked") public void testCharArray() throws Exception { char[] array = "Hello".toCharArray(); ArrayMetaType arrayType = assertInstanceOf(resolve(array.getClass()), ArrayMetaType.class); MetaValue[] metaArray = { SimpleValueSupport.wrap('H'), SimpleValueSupport.wrap('e'), SimpleValueSupport.wrap('l'), SimpleValueSupport.wrap('l'), SimpleValueSupport.wrap('o') }; ArrayValueSupport expected = new ArrayValueSupport(arrayType, metaArray); MetaValue result = createMetaValue(array); ArrayValue actual = assertInstanceOf(result, ArrayValue.class); getLog().debug("Array Value: " + actual); assertEquals(expected, actual); } @SuppressWarnings("unchecked") public void test2DCharArray() { char[][] array = {"Hello".toCharArray(), "World".toCharArray()}; ArrayMetaType arrayType = assertInstanceOf(resolve(array.getClass()), ArrayMetaType.class); MetaValue[][] metaArray = { {SimpleValueSupport.wrap('H'), SimpleValueSupport.wrap('e'), SimpleValueSupport.wrap('l'), SimpleValueSupport.wrap('l'), SimpleValueSupport.wrap('o')}, {SimpleValueSupport.wrap('W'), SimpleValueSupport.wrap('o'), SimpleValueSupport.wrap('r'), SimpleValueSupport.wrap('l'), SimpleValueSupport.wrap('d')} }; ArrayValueSupport expected = new ArrayValueSupport(arrayType, metaArray); MetaValue result = createMetaValue(array); ArrayValue actual = assertInstanceOf(result, ArrayValue.class); getLog().debug("Array Value: " + actual); assertEquals(expected, actual); } /** * Test the correct value is generated for a composite array * * @throws Exception for any problem */ @SuppressWarnings("unchecked") public void testCompositeArray() throws Exception { TestSimpleComposite hello = new TestSimpleComposite("Hello"); TestSimpleComposite goodbye = new TestSimpleComposite("Goodbye"); TestSimpleComposite[] array = { hello, goodbye }; ArrayMetaType arrayType = assertInstanceOf(resolve(array.getClass()), ArrayMetaType.class); CompositeMetaType compositeType = assertInstanceOf(resolve(TestSimpleComposite.class), CompositeMetaType.class); String[] itemNames = { "something" }; MetaValue[] itemValues = { SimpleValueSupport.wrap("Hello") }; CompositeValue helloValue = new CompositeValueSupport(compositeType, itemNames, itemValues); itemValues = new MetaValue[] { SimpleValueSupport.wrap("Goodbye") }; CompositeValue goodbyeValue = new CompositeValueSupport(compositeType, itemNames, itemValues); MetaValue[] metaArray = { helloValue, goodbyeValue }; ArrayValueSupport expected = new ArrayValueSupport(arrayType, metaArray); MetaValue result = createMetaValue(array); ArrayValue actual = assertInstanceOf(result, ArrayValue.class); getLog().debug("Array Value: " + actual); assertEquals(expected, actual); } /** * Test the correct value is generated for a mutlidimensional array * * @throws Exception for any problem */ @SuppressWarnings("unchecked") public void testMultipleArray() throws Exception { String[][] array = { { "Hello" }, { "Goodbye" } }; ArrayMetaType arrayType = assertInstanceOf(resolve(array.getClass()), ArrayMetaType.class); Object[][] metaArray = { { SimpleValueSupport.wrap("Hello") }, { SimpleValueSupport.wrap("Goodbye") } }; ArrayValueSupport expected = new ArrayValueSupport(arrayType, metaArray); MetaValue result = createMetaValue(array); ArrayValue actual = assertInstanceOf(result, ArrayValue.class); getLog().debug("Array Value: " + actual); assertEquals(expected, actual); } } ././@LongLink0000000000000000000000000000021500000000000011563 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/factory/test/SpecialValueFactoryUnitTestCase.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/factory/t0000644000175000017500000001425410761511660033317 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.values.factory.test; import junit.framework.Test; import org.jboss.metatype.api.types.CompositeMetaType; import org.jboss.metatype.api.types.GenericMetaType; 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.GenericValue; import org.jboss.metatype.api.values.GenericValueSupport; import org.jboss.metatype.api.values.MetaValue; import org.jboss.metatype.api.values.SimpleValueSupport; import org.jboss.metatype.plugins.types.MutableCompositeMetaType; import org.jboss.test.metatype.values.factory.support.TestGeneric; import org.jboss.test.metatype.values.factory.support.TestGenericComposite; import org.jboss.test.metatype.values.factory.support.TestOverrideComposite; import org.jboss.test.metatype.values.factory.support.TestOverrideCompositeBuilder; /** * SpecialValueFactoryUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class SpecialValueFactoryUnitTestCase extends AbstractMetaValueFactoryTest { /** * Create a testsuite for this test * * @return the testsuite */ public static Test suite() { return suite(SpecialValueFactoryUnitTestCase.class); } /** * Create a new SpecialValueFactoryUnitTestCase. * * @param name the test name */ public SpecialValueFactoryUnitTestCase(String name) { super(name); } /** * Test the value generated for a class * * @throws Exception for any problem */ public void testClass() throws Exception { CompositeMetaType metaType = assertInstanceOf(resolve(Class.class), CompositeMetaType.class); String[] itemNames = { "name" }; MetaValue[] itemValues = { SimpleValueSupport.wrap(Class.class.getName()) }; CompositeValue expected = new CompositeValueSupport(metaType, itemNames, itemValues); MetaValue result = createMetaValue(Class.class); CompositeValue actual = assertInstanceOf(result, CompositeValue.class); getLog().debug("Class.class: " + actual); assertEquals(expected, actual); } /** * Test the value generated for an object * * @throws Exception for any problem */ public void testObject() throws Exception { CompositeMetaType metaType = assertInstanceOf(resolve(Object.class), CompositeMetaType.class); CompositeValue expected = new CompositeValueSupport(metaType, new String[0], new MetaValue[0]); MetaValue result = createMetaValue(new Object()); CompositeValue actual = assertInstanceOf(result, CompositeValue.class); getLog().debug("new Object(): " + actual); assertEquals(expected, actual); } /** * Test the value generated for a generic * * @throws Exception for any problem */ public void testGeneric() throws Exception { TestGeneric test = new TestGeneric("Hello"); GenericMetaType generic = new GenericMetaType(TestGeneric.class.getName(), TestGeneric.class.getName()); GenericValue expected = new GenericValueSupport(generic, test); MetaValue result = createMetaValue(test); GenericValue actual = assertInstanceOf(result, GenericValue.class); getLog().debug("Generic: " + actual); assertEquals(expected, actual); } /** * Test the value generated for a generic composite * * @throws Exception for any problem */ public void testGenericComposite() throws Exception { TestGeneric test = new TestGeneric("Hello"); TestGenericComposite composite = new TestGenericComposite(); composite.setGeneric(test); GenericMetaType generic = new GenericMetaType(TestGeneric.class.getName(), TestGeneric.class.getName()); GenericValue genericValue = new GenericValueSupport(generic, test); MutableCompositeMetaType compositeType = new MutableCompositeMetaType(TestGenericComposite.class.getName(), TestGenericComposite.class.getName()); compositeType.addItem("generic", "generic", generic); compositeType.freeze(); CompositeValueSupport expected = new CompositeValueSupport(compositeType); expected.set("generic", genericValue); MetaValue result = createMetaValue(composite); CompositeValue actual = assertInstanceOf(result, CompositeValue.class); getLog().debug("GenericComposite: " + actual); assertEquals(expected, actual); } /** * Test the value generated with a builder * * @throws Exception for any problem */ public void testBuilder() throws Exception { TestOverrideCompositeBuilder builder = new TestOverrideCompositeBuilder(); setBuilder(TestOverrideComposite.class, builder); try { TestOverrideComposite value = new TestOverrideComposite("Hello"); MetaType metaType = builder.buildMetaType(); MetaValue expected = builder.buildMetaValue(metaType, value); MetaValue actual = createMetaValue(value); getLog().debug("Builder: " + actual); assertEquals(expected, actual); } finally { setBuilder(TestOverrideComposite.class, null); } } } ././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/factory/test/ValuesFactoryTestSuite.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/factory/t0000644000175000017500000000443310757514543033325 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2005, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.values.factory.test; import junit.framework.Test; import junit.framework.TestSuite; import junit.textui.TestRunner; /** * Values Factory Test Suite. * * @author Adrian Brock * @version $Revision: 55115 $ */ public class ValuesFactoryTestSuite extends TestSuite { /** * For running the testsuite from the command line * * @param args the command line args */ public static void main(String[] args) { TestRunner.run(suite()); } /** * Create the testsuite * * @return the testsuite */ public static Test suite() { TestSuite suite = new TestSuite("Values Factory Tests"); suite.addTest(SimpleValueFactoryUnitTestCase.suite()); suite.addTest(SpecialValueFactoryUnitTestCase.suite()); suite.addTest(EnumValueFactoryUnitTestCase.suite()); suite.addTest(ArrayValueFactoryUnitTestCase.suite()); suite.addTest(CollectionValueFactoryUnitTestCase.suite()); suite.addTest(MapValueFactoryUnitTestCase.suite()); suite.addTest(CompositeValueFactoryUnitTestCase.suite()); suite.addTest(AnnotationValueFactoryUnitTestCase.suite()); suite.addTest(UnwrapValueUnitTestCase.suite()); suite.addTest(MetaMapperUnitTestCase.suite()); return suite; } } ././@LongLink0000000000000000000000000000022000000000000011557 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/factory/test/AnnotationValueFactoryUnitTestCase.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/factory/t0000644000175000017500000000601110645072106033305 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.values.factory.test; import junit.framework.Test; import org.jboss.metatype.api.types.SimpleMetaType; 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.SimpleValueSupport; import org.jboss.metatype.plugins.types.MutableCompositeMetaType; import org.jboss.test.metatype.values.factory.support.TestAnnotation; /** * AnnotationValueFactoryUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ @TestAnnotation(something="Hello") public class AnnotationValueFactoryUnitTestCase extends AbstractMetaValueFactoryTest { /** * Create a testsuite for this test * * @return the testsuite */ public static Test suite() { return suite(AnnotationValueFactoryUnitTestCase.class); } /** * Create a new AnnotationValueFactoryUnitTestCase. * * @param name the test name */ public AnnotationValueFactoryUnitTestCase(String name) { super(name); } /** * Test the correct value is generated for a simple annotation * * @throws Exception for any problem */ public void testSimpleAnnotation() throws Exception { MutableCompositeMetaType compositeType = new MutableCompositeMetaType(TestAnnotation.class.getName(), TestAnnotation.class.getName()); compositeType.addItem("something", "something", SimpleMetaType.STRING); compositeType.freeze(); String[] compositeNames = { "something" }; CompositeValue expected = new CompositeValueSupport(compositeType, compositeNames, new MetaValue[] { SimpleValueSupport.wrap("Hello") }); TestAnnotation annotation = getClass().getAnnotation(TestAnnotation.class); MetaValue result = createMetaValue(annotation); CompositeValue actual = assertInstanceOf(result, CompositeValue.class); getLog().debug("Annotation Value: " + actual); assertEquals(expected, actual); } } ././@LongLink0000000000000000000000000000021200000000000011560 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/factory/test/EnumValueFactoryUnitTestCase.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/factory/t0000644000175000017500000000556310665650720033326 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.values.factory.test; import junit.framework.Test; import org.jboss.metatype.api.types.EnumMetaType; import org.jboss.metatype.api.values.EnumValue; import org.jboss.metatype.api.values.EnumValueSupport; import org.jboss.metatype.api.values.MetaValue; import org.jboss.test.metatype.values.factory.support.TestEnum; /** * EnumValueFactoryUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class EnumValueFactoryUnitTestCase extends AbstractMetaValueFactoryTest { /** * Create a testsuite for this test * * @return the testsuite */ public static Test suite() { return suite(EnumValueFactoryUnitTestCase.class); } /** * Create a new EnumValueFactoryUnitTestCase. * * @param name the test name */ public EnumValueFactoryUnitTestCase(String name) { super(name); } /** * Test the correct value is generate for an enum * * @throws Exception for any problem */ public void testEnumFromString() throws Exception { EnumMetaType enumType = assertInstanceOf(resolve(TestEnum.class), EnumMetaType.class); EnumValue expected = new EnumValueSupport(enumType, TestEnum.ONE.name()); MetaValue result = createMetaValue(TestEnum.ONE); EnumValue actual = assertInstanceOf(result, EnumValue.class); getLog().debug("Enum Value: " + actual); assertEquals(expected, actual); } public void testEnum() throws Exception { EnumMetaType enumType = assertInstanceOf(resolve(TestEnum.class), EnumMetaType.class); EnumValue expected = new EnumValueSupport(enumType, TestEnum.ONE); MetaValue result = createMetaValue(TestEnum.ONE); EnumValue actual = assertInstanceOf(result, EnumValue.class); getLog().debug("Enum Value: " + actual); assertEquals(expected, actual); } } ././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/factory/test/UnwrapValueUnitTestCase.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/factory/t0000644000175000017500000003404010757514543033322 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.values.factory.test; import java.lang.reflect.Method; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Date; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import junit.framework.Test; import org.jboss.metatype.api.values.MetaValue; import org.jboss.test.metatype.values.factory.support.SimpleCompositeInterface; import org.jboss.test.metatype.values.factory.support.TestEnum; import org.jboss.test.metatype.values.factory.support.TestGeneric; import org.jboss.test.metatype.values.factory.support.TestIgnoredCompositeItem; import org.jboss.test.metatype.values.factory.support.TestRecursiveSimpleComposite; import org.jboss.test.metatype.values.factory.support.TestRenamedCompositeItem; import org.jboss.test.metatype.values.factory.support.TestSimpleComposite; import org.jboss.test.metatype.values.factory.support.TestSimpleCompositeInterface; /** * UnwrapValueUnitTestCase. * * @author Ales Justin */ public class UnwrapValueUnitTestCase extends AbstractMetaValueFactoryTest { /** * Create a testsuite for this test * * @return the testsuite */ public static Test suite() { return suite(UnwrapValueUnitTestCase.class); } /** * Create a new UnwrapValueUnitTestCase * * @param name the test name */ public UnwrapValueUnitTestCase(String name) { super(name); } public void testSimpleUnwrap() throws Exception { checkSingle(123, true); checkSingle(123, false); checkSingle(new Date(), true); checkSingle(new Date(), false); } public void testEnumUnwrap() throws Exception { checkSingle(TestEnum.ONE, true); checkSingle(TestEnum.ONE, false); } public void testGenericUnwrap() throws Exception { checkSingle(new TestGeneric("123"), true); checkSingle(new TestGeneric("123"), false); } public void testCompositeUnwrap() throws Exception { TestSimpleComposite composite = new TestSimpleComposite("something"); checkSingle(composite, true); checkSingle(composite, false); checkSingle(new TestRecursiveSimpleComposite("something", composite), true); checkSingle(new TestRecursiveSimpleComposite("something", composite), false); checkSingle(new TestSimpleCompositeInterface("something"), SimpleCompositeInterface.class); } public void testCollectionUnwrap() throws Exception { Integer i1 = 123; Integer i2 = 123; checkCollection(new ArrayList(), i1, i2); checkCollection(new ArrayList(), List.class, i1, i2); checkCollection(new ArrayList(), getType("Integer", List.class), i1, i2); checkCollection(new HashSet(), i1, i2); checkCollection(new HashSet(), Set.class, i1, i2); checkCollection(new HashSet(), getType("Integer", Set.class), i1, i2); TestEnum one = TestEnum.ONE; TestEnum two = TestEnum.TWO; TestEnum three = TestEnum.THREE; checkCollection(new ArrayList(), one, two, three, one); checkCollection(new ArrayList(), List.class, one, two, three, one); checkCollection(new ArrayList(), getType("Enum", List.class), one, two, three, one); checkCollection(new HashSet(), one, two, three, one); checkCollection(new HashSet(), Set.class, one, two, three, one); checkCollection(new HashSet(), getType("Enum", Set.class), one, two, three, one); TestGeneric g1 = new TestGeneric("123"); TestGeneric g2 = new TestGeneric("123"); checkCollection(new ArrayList(), g1, g2); checkCollection(new ArrayList(), List.class, g1, g2); checkCollection(new ArrayList(), getType("Generic", List.class), g1, g2); checkCollection(new HashSet(), g1, g2); checkCollection(new HashSet(), Set.class, g1, g2); checkCollection(new HashSet(), getType("Generic", Set.class), g1, g2); TestSimpleComposite c1 = new TestSimpleComposite("123"); TestSimpleComposite c2 = new TestSimpleComposite("123"); checkCollection(new ArrayList(), c1, c2); checkCollection(new ArrayList(), List.class, c1, c2); checkCollection(new ArrayList(), getType("Composite", List.class), c1, c2); checkCollection(new HashSet(), c1, c2); checkCollection(new HashSet(), Set.class, c1, c2); checkCollection(new HashSet(), getType("Composite", Set.class), c1, c2); } public void testArrayUnwrap() throws Exception { short[] shorts = new short[128]; Double[] doubles = new Double[128]; TestEnum[] enums = new TestEnum[128]; TestGeneric[] generics = new TestGeneric[128]; TestSimpleComposite[] composits = new TestSimpleComposite[128]; TestRecursiveSimpleComposite[] recursiveComposites = new TestRecursiveSimpleComposite[128]; Integer[][] integers = new Integer[128][128]; Integer[][][] triple = new Integer[10][10][10]; for(int i = 0; i < 128; i++) { shorts[i] = (short)i; doubles[i] = i / Math.PI; enums[i] = TestEnum.values()[i % 3]; generics[i] = new TestGeneric("#" + i); composits[i] = new TestSimpleComposite("#" + i); recursiveComposites[i] = new TestRecursiveSimpleComposite("#" + i, composits[i]); for(int j = 0; j < 128; j++) { integers[i][j] = 128 * i + j; for(int k = 0; k < 128; k++) triple[i % 10][j % 10][k % 10] = (100 * i + 10 * j + k) % 1000; } } checkArray(shorts, true, new Asserter() { public boolean assertArray(final Object original, final Object unwrapped) { return Arrays.equals((short[])original, (short[])unwrapped); } }); checkArray(shorts, false, new Asserter() { public boolean assertArray(final Object original, final Object unwrapped) { return Arrays.equals((short[])original, (short[])unwrapped); } }); checkArray(doubles, true, new Asserter() { public boolean assertArray(final Object original, final Object unwrapped) { return Arrays.equals((Double[])original, (Double[])unwrapped); } }); checkArray(doubles, false, new Asserter() { public boolean assertArray(final Object original, final Object unwrapped) { return Arrays.equals((Double[])original, (Double[])unwrapped); } }); Asserter objectsAsserter = new Asserter() { public boolean assertArray(final Object original, final Object unwrapped) { return Arrays.equals((Object[])original, (Object[])unwrapped); } }; checkArray(enums, true, objectsAsserter); checkArray(enums, false, objectsAsserter); checkArray(generics, true, objectsAsserter); checkArray(generics, false, objectsAsserter); checkArray(composits, true, objectsAsserter); checkArray(composits, false, objectsAsserter); checkArray(recursiveComposites, true, objectsAsserter); checkArray(recursiveComposites, false, objectsAsserter); Asserter integersAsserter = new Asserter() { public boolean assertArray(final Object original, final Object unwrapped) { Integer[][] first = (Integer[][])original; Integer[][] second = (Integer[][])unwrapped; for (int i = 0; i < first.length; i++) for (int j = 0; j < first[0].length; j++) if (first[i][j].equals(second[i][j]) == false) return false; return true; } }; checkArray(integers, true, integersAsserter); checkArray(integers, false, integersAsserter); Asserter tripleAsserter = new Asserter() { public boolean assertArray(final Object original, final Object unwrapped) { Integer[][][] first = (Integer[][][])original; Integer[][][] second = (Integer[][][])unwrapped; for (int i = 0; i < first.length; i++) for (int j = 0; j < first[0].length; j++) for (int k = 0; k < first[0][0].length; k++) if (first[i][j][k].equals(second[i][j][k]) == false) return false; return true; } }; checkArray(triple, true, tripleAsserter); checkArray(triple, false, tripleAsserter); } public void testTableUnwrap() throws Exception { Method method = getClass().getMethod("compositeValueMap"); Type mapType = method.getGenericReturnType(); Map map = new HashMap(); map.put(123, "123"); checkSingle(map, mapType); } public void testIgnoreItemUnwrap() { TestIgnoredCompositeItem ignored = new TestIgnoredCompositeItem(); ignored.setId("Id"); ignored.setIgnored("Ignored?"); MetaValue metaValue = createMetaValue(ignored); assertNotNull(metaValue); Object unwrapped = unwrapMetaValue(metaValue, TestIgnoredCompositeItem.class); TestIgnoredCompositeItem result = assertInstanceOf(unwrapped, TestIgnoredCompositeItem.class); assertEquals("Id", result.getId()); assertNull(result.getIgnored()); } public void testRenamedItemUnwrap() { TestRenamedCompositeItem renamedCompositeItem = new TestRenamedCompositeItem(); renamedCompositeItem.setId("Id"); renamedCompositeItem.setValue("Renamed"); MetaValue metaValue = createMetaValue(renamedCompositeItem); assertNotNull(metaValue); Object unwrapped = unwrapMetaValue(metaValue, TestRenamedCompositeItem.class); TestRenamedCompositeItem result = assertInstanceOf(unwrapped, TestRenamedCompositeItem.class); assertEquals("Id", result.getId()); assertEquals("Renamed", result.getValue()); } public Map compositeValueMap() { return null; } protected void checkSingle(Object object, boolean typeInfoFromObject) { MetaValue metaValue = createMetaValue(object); assertNotNull(metaValue); Object unwrapped; if (typeInfoFromObject) unwrapped = unwrapMetaValue(metaValue, object.getClass()); else unwrapped = unwrapMetaValue(metaValue); assertEquals(object, unwrapped); } protected void checkSingle(Object object, Type type) { MetaValue metaValue = createMetaValue(object, type); assertNotNull(metaValue); Object unwrapped = unwrapMetaValue(metaValue, type); assertEquals(object, unwrapped); } protected void checkCollection(Collection collection, T... params) throws Exception { collection.addAll(Arrays.asList(params)); checkSingle(collection, true); checkSingle(collection, false); } protected void checkCollection(Collection collection, Type type, T... params) throws Exception { collection.addAll(Arrays.asList(params)); checkSingle(collection, type); } protected void checkArray(Object object, boolean typeInfoFromObject, Asserter asserter) { MetaValue metaValue = createMetaValue(object); assertNotNull(metaValue); Object unwrapped; if (typeInfoFromObject) unwrapped = unwrapMetaValue(metaValue, object.getClass()); else unwrapped = unwrapMetaValue(metaValue); assertTrue("Different arrays.", asserter.assertArray(object, unwrapped)); } private interface Asserter { boolean assertArray(final Object original, final Object unwrapped); } @SuppressWarnings("unchecked") protected Type getType(String type, Class clazz) throws Exception { Method method = getClass().getDeclaredMethod("get" + type + "s" + clazz.getSimpleName()); return method.getGenericReturnType(); } public List getIntegersList() { return null; } public List getEnumsList() { return null; } public List getGenericsList() { return null; } public List getCompositesList() { return null; } public Set getIntegersSet() { return null; } public Set getEnumsSet() { return null; } public Set getGenericsSet() { return null; } public Set getCompositesSet() { return null; } } ././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/factory/test/MetaMapperUnitTestCase.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/factory/t0000644000175000017500000000431010761511660033307 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.values.factory.test; import junit.framework.Test; import org.jboss.metatype.api.types.MetaType; import org.jboss.metatype.api.types.SimpleMetaType; import org.jboss.metatype.api.values.MetaValue; import org.jboss.test.metatype.values.factory.support.TestMetaMapped; /** * MetaMapperUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class MetaMapperUnitTestCase extends AbstractMetaValueFactoryTest { public static Test suite() { return suite(MetaMapperUnitTestCase.class); } public MetaMapperUnitTestCase(String name) { super(name); } public void testMetaMapper() throws Exception { MetaType metaType = resolve(TestMetaMapped.class); assertEquals(SimpleMetaType.STRING, metaType); TestMetaMapped test = new TestMetaMapped("Hello"); MetaValue value = createMetaValue(test); MetaValue stringHello = createMetaValue("Hello"); assertEquals(stringHello, value); Object unwrapped = unwrapMetaValue(value, TestMetaMapped.class); TestMetaMapped result = assertInstanceOf(unwrapped, TestMetaMapped.class); assertEquals("Hello", result.getValue()); } } ././@LongLink0000000000000000000000000000021400000000000011562 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/factory/test/SimpleValueFactoryUnitTestCase.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/factory/t0000644000175000017500000000773410761511660033324 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.values.factory.test; import java.math.BigDecimal; import java.math.BigInteger; import java.util.Date; import org.jboss.metatype.api.types.SimpleMetaType; import org.jboss.metatype.api.values.MetaValue; import org.jboss.metatype.api.values.SimpleValue; import org.jboss.metatype.api.values.SimpleValueSupport; import junit.framework.Test; /** * SimpleValueFactoryUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class SimpleValueFactoryUnitTestCase extends AbstractMetaValueFactoryTest { /** * Create a testsuite for this test * * @return the testsuite */ public static Test suite() { return suite(SimpleValueFactoryUnitTestCase.class); } /** * Create a new SimpleValueFactoryUnitTestCase. * * @param name the test name */ public SimpleValueFactoryUnitTestCase(String name) { super(name); } BigDecimal BIG_DECIMAL = new BigDecimal(1); BigInteger BIG_INTEGER = BigInteger.ONE; Boolean BOOLEAN = new Boolean(false); Byte BYTE = Byte.MAX_VALUE; Character CHARACTER = new Character('a'); Date DATE = new Date(System.currentTimeMillis()); Double DOUBLE = new Double(1); Float FLOAT = new Float(1); Integer INTEGER = new Integer(1); Long LONG = new Long(1); Short SHORT = new Short(Short.MAX_VALUE); String STRING = new String("hello"); Object[] values = new Object[] { BIG_DECIMAL, BIG_INTEGER, BOOLEAN, BYTE, CHARACTER, DATE, DOUBLE, FLOAT, INTEGER, LONG, SHORT, STRING, }; @SuppressWarnings("unchecked") SimpleValue[] metaValues = new SimpleValue[] { new SimpleValueSupport(SimpleMetaType.BIGDECIMAL, BIG_DECIMAL), new SimpleValueSupport(SimpleMetaType.BIGINTEGER, BIG_INTEGER), new SimpleValueSupport(SimpleMetaType.BOOLEAN, BOOLEAN), new SimpleValueSupport(SimpleMetaType.BYTE, BYTE), new SimpleValueSupport(SimpleMetaType.CHARACTER, CHARACTER), new SimpleValueSupport(SimpleMetaType.DATE, DATE), new SimpleValueSupport(SimpleMetaType.DOUBLE, DOUBLE), new SimpleValueSupport(SimpleMetaType.FLOAT, FLOAT), new SimpleValueSupport(SimpleMetaType.INTEGER, INTEGER), new SimpleValueSupport(SimpleMetaType.LONG, LONG), new SimpleValueSupport(SimpleMetaType.SHORT, SHORT), new SimpleValueSupport(SimpleMetaType.STRING, STRING), }; /** * Test the generated simple values * * @throws Exception for any problem */ public void testSimpleValues() throws Exception { for (int i = 0; i < values.length; i++) { Object value = values[i]; MetaValue result = createMetaValue(value); SimpleValue actual = assertInstanceOf(result, SimpleValue.class); SimpleValue expected = metaValues[i]; getLog().debug("Simple Value: expected=" + expected + " actual=" + actual); assertEquals(expected, actual); } } } ././@LongLink0000000000000000000000000000022000000000000011557 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/factory/test/CollectionValueFactoryUnitTestCase.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/factory/t0000644000175000017500000001764610761511660033327 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.values.factory.test; import java.lang.reflect.Method; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.Collection; import java.util.LinkedHashSet; import java.util.List; import java.util.Set; import junit.framework.Test; import org.jboss.metatype.api.types.CollectionMetaType; import org.jboss.metatype.api.types.CompositeMetaType; import org.jboss.metatype.api.values.CollectionValue; import org.jboss.metatype.api.values.CollectionValueSupport; import org.jboss.metatype.api.values.CompositeValue; import org.jboss.metatype.api.values.CompositeValueSupport; import org.jboss.metatype.api.values.MetaValue; import org.jboss.metatype.api.values.SimpleValueSupport; import org.jboss.test.metatype.values.factory.support.TestSimpleComposite; /** * CollectionValueFactoryUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class CollectionValueFactoryUnitTestCase extends AbstractMetaValueFactoryTest { /** * Create a testsuite for this test * * @return the testsuite */ public static Test suite() { return suite(CollectionValueFactoryUnitTestCase.class); } /** * Create a new CollectionValueFactoryUnitTestCase. * * @param name the test name */ public CollectionValueFactoryUnitTestCase(String name) { super(name); } /** * Create a test simple collection * * @return the test value */ public Collection simpleCollection() { Collection result = new ArrayList(); result.add("Hello"); result.add("Goodbye"); return result; } /** * Create a test composite collection * * @return the test value */ public Collection compositeCollection() { Collection result = new ArrayList(); result.add(new TestSimpleComposite("Hello")); result.add(new TestSimpleComposite("Goodbye")); return result; } /** * Create a test simple list * * @return the test value */ public List simpleList() { List result = new ArrayList(); result.add("Hello"); result.add("Goodbye"); return result; } /** * Create a test composite list * * @return the test value */ public List compositeList() { List result = new ArrayList(); result.add(new TestSimpleComposite("Hello")); result.add(new TestSimpleComposite("Goodbye")); return result; } /** * Create a test simple set * * @return the test value */ public Set simpleSet() { Set result = new LinkedHashSet(); result.add("Hello"); result.add("Goodbye"); return result; } /** * Create a test composite set * * @return the test value */ public Set compositeSet() { Set result = new LinkedHashSet(); result.add(new TestSimpleComposite("Hello")); result.add(new TestSimpleComposite("Goodbye")); return result; } /** * Test the correct value is generated for a simple collection * * @throws Exception for any problem */ public void testSimpleCollection() throws Exception { testSimple("simpleCollection", simpleCollection()); } /** * Test the correct value is generated for a composite collection * * @throws Exception for any problem */ public void testCompositeCollection() throws Exception { testComposite("compositeCollection", compositeCollection()); } /** * Test the correct value is generated for a simple list * * @throws Exception for any problem */ public void testSimpleList() throws Exception { testSimple("simpleList", simpleList()); } /** * Test the correct value is generated for a composite list * * @throws Exception for any problem */ public void testCompositeList() throws Exception { testComposite("compositeList", compositeList()); } /** * Test the correct value is generated for a simple set * * @throws Exception for any problem */ public void testSimpleSet() throws Exception { testSimple("simpleSet", simpleSet()); } /** * Test the correct value is generated for a composite set * * @throws Exception for any problem */ public void testCompositeSet() throws Exception { testComposite("compositeSet", compositeSet()); } /** * Test a simple collection * * @param methodName that gives the collection * @param collection the collection value * @throws Exception for any problem */ public void testSimple(String methodName, Collection collection) throws Exception { Method method = getClass().getMethod(methodName); Type type = method.getGenericReturnType(); CollectionMetaType arrayType = assertInstanceOf(resolve(type), CollectionMetaType.class); MetaValue[] metaArray = { SimpleValueSupport.wrap("Hello"), SimpleValueSupport.wrap("Goodbye") }; CollectionValueSupport expected = new CollectionValueSupport(arrayType, metaArray); MetaValue result = createMetaValue(collection, type); CollectionValue actual = assertInstanceOf(result, CollectionValue.class); getLog().debug("Collection Value: " + actual); assertEquals(expected, actual); } /** * Test a composite collection * * @param methodName that gives the collection * @param collection the collection value * @throws Exception for any problem */ public void testComposite(String methodName, Collection collection) throws Exception { Method method = getClass().getMethod(methodName); Type type = method.getGenericReturnType(); CollectionMetaType arrayType = assertInstanceOf(resolve(type), CollectionMetaType.class); CompositeMetaType compositeType = assertInstanceOf(resolve(TestSimpleComposite.class), CompositeMetaType.class); String[] itemNames = { "something" }; MetaValue[] itemValues = { SimpleValueSupport.wrap("Hello") }; CompositeValue helloValue = new CompositeValueSupport(compositeType, itemNames, itemValues); itemValues = new MetaValue[] { SimpleValueSupport.wrap("Goodbye") }; CompositeValue goodbyeValue = new CompositeValueSupport(compositeType, itemNames, itemValues); MetaValue[] metaArray = { helloValue, goodbyeValue }; CollectionValueSupport expected = new CollectionValueSupport(arrayType, metaArray); MetaValue result = createMetaValue(collection, type); CollectionValue actual = assertInstanceOf(result, CollectionValue.class); getLog().debug("Collection Value: " + actual); assertEquals(expected, actual); } } ././@LongLink0000000000000000000000000000021100000000000011557 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/factory/test/MapValueFactoryUnitTestCase.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/factory/t0000644000175000017500000002521010770514540033311 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.values.factory.test; import java.lang.reflect.Method; import java.lang.reflect.Type; import java.util.LinkedHashMap; import java.util.Map; import junit.framework.Test; import org.jboss.metatype.api.types.CompositeMetaType; import org.jboss.metatype.api.types.ImmutableCompositeMetaType; import org.jboss.metatype.api.types.ImmutableTableMetaType; import org.jboss.metatype.api.types.MetaType; import org.jboss.metatype.api.types.SimpleMetaType; import org.jboss.metatype.api.types.TableMetaType; 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.SimpleValueSupport; import org.jboss.metatype.api.values.TableValue; import org.jboss.metatype.api.values.TableValueSupport; import org.jboss.metatype.plugins.types.DefaultMetaTypeFactory; import org.jboss.metatype.plugins.types.MutableCompositeMetaType; import org.jboss.test.metatype.values.factory.support.StringKey; import org.jboss.test.metatype.values.factory.support.TestSimpleComposite; /** * Test of Maps with non-String keys as TableMetaType/TableMetaValue. * Map uses MapCompositeMetaType(MetaValue). * * @author Adrian Brock * @author Scott.Stark@jboss.org * @version $Revision: 1.1 $ */ public class MapValueFactoryUnitTestCase extends AbstractMetaValueFactoryTest { /** * Create a testsuite for this test * * @return the testsuite */ public static Test suite() { return suite(MapValueFactoryUnitTestCase.class); } /** * Create a new MapValueFactoryUnitTestCase. * * @param name the test name */ public MapValueFactoryUnitTestCase(String name) { super(name); } /** * The signature and value to test a simple map * * @return the value */ public Map simpleMap() { Map result = new LinkedHashMap(); result.put(new StringKey("Hello"), new Integer(1)); result.put(new StringKey("Goodbye"), new Integer(2)); return result; } /** * The signature and value to test a map with a composite key * * @return the value */ public Map compositeKeyMap() { Map result = new LinkedHashMap(); result.put(new TestSimpleComposite("Hello"), new Integer(1)); result.put(new TestSimpleComposite("Goodbye"), new Integer(2)); return result; } /** * The signature and value to test a map with a composite value * * @return the value */ public Map compositeValueMap() { Map result = new LinkedHashMap(); result.put(new StringKey("Hello"), new TestSimpleComposite("Hello")); result.put(new StringKey("Goodbye"), new TestSimpleComposite("Goodbye")); return result; } /** * Test a simple map * * @throws Exception for any problem */ public void testSimpleMap() throws Exception { Method method = getClass().getMethod("simpleMap", (Class[]) null); Type collectionType = method.getGenericReturnType(); Map map = simpleMap(); CompositeMetaType keyType = (CompositeMetaType) resolve(StringKey.class); MetaType valueType = resolve(Integer.class); MetaType[] itemTypes = { keyType, valueType }; String entryName = Map.Entry.class.getName(); CompositeMetaType entryType = new ImmutableCompositeMetaType(entryName, entryName, DefaultMetaTypeFactory.MAP_ITEM_NAMES, DefaultMetaTypeFactory.MAP_ITEM_NAMES, itemTypes); TableMetaType tableType = new ImmutableTableMetaType(Map.class.getName(), Map.class.getName(), entryType, DefaultMetaTypeFactory.MAP_INDEX_NAMES); TableValue expected = new TableValueSupport(tableType); String[] itemNames = DefaultMetaTypeFactory.MAP_ITEM_NAMES; MetaValue[] keyValues1 = {SimpleValueSupport.wrap("Hello")}; CompositeValueSupport key1 = new CompositeValueSupport(keyType, new String[]{"key"}, keyValues1); MetaValue[] itemValues = new MetaValue[] {key1, SimpleValueSupport.wrap(new Integer(1)) }; expected.put(new CompositeValueSupport(entryType, itemNames, itemValues)); MetaValue[] keyValues2 = {SimpleValueSupport.wrap("Goodbye")}; CompositeValueSupport key2 = new CompositeValueSupport(keyType, new String[]{"key"}, keyValues2); itemValues = new MetaValue[] { key2, SimpleValueSupport.wrap(new Integer(2)) }; expected.put(new CompositeValueSupport(entryType, itemNames, itemValues)); MetaValue result = createMetaValue(map, collectionType); TableValue actual = assertInstanceOf(result, TableValue.class); getLog().debug("Map Value: " + actual); assertEquals(expected, actual); } /** * Test a composite key map * * @throws Exception for any problem */ public void testCompositeKeyMap() throws Exception { Method method = getClass().getMethod("compositeKeyMap", (Class[]) null); Type collectionType = method.getGenericReturnType(); Map map = compositeKeyMap(); MetaType keyType = resolve(TestSimpleComposite.class); MetaType valueType = resolve(Integer.class); MetaType[] itemTypes = { keyType, valueType }; String entryName = Map.Entry.class.getName(); CompositeMetaType entryType = new ImmutableCompositeMetaType(entryName, entryName, DefaultMetaTypeFactory.MAP_ITEM_NAMES, DefaultMetaTypeFactory.MAP_ITEM_NAMES, itemTypes); TableMetaType tableType = new ImmutableTableMetaType(Map.class.getName(), Map.class.getName(), entryType, DefaultMetaTypeFactory.MAP_INDEX_NAMES); TableValue expected = new TableValueSupport(tableType); String[] itemNames = DefaultMetaTypeFactory.MAP_ITEM_NAMES; MutableCompositeMetaType compositeType = new MutableCompositeMetaType(TestSimpleComposite.class.getName(), TestSimpleComposite.class.getName()); compositeType.addItem("something", "something", SimpleMetaType.STRING); compositeType.freeze(); String[] compositeNames = { "something" }; CompositeValue compositeValue = new CompositeValueSupport(compositeType, compositeNames, new MetaValue[] { SimpleValueSupport.wrap("Hello") }); MetaValue[] itemValues = new MetaValue[] { compositeValue, SimpleValueSupport.wrap(new Integer(1)) }; expected.put(new CompositeValueSupport(entryType, itemNames, itemValues)); compositeValue = new CompositeValueSupport(compositeType, compositeNames, new MetaValue[] { SimpleValueSupport.wrap("Goodbye") }); itemValues = new MetaValue[] { compositeValue, SimpleValueSupport.wrap(new Integer(2)) }; expected.put(new CompositeValueSupport(entryType, itemNames, itemValues)); MetaValue result = createMetaValue(map, collectionType); TableValue actual = assertInstanceOf(result, TableValue.class); getLog().debug("Map Value: " + actual); assertEquals(expected, actual); } /** * Test a composite value map * * @throws Exception for any problem */ public void testCompositeValueMap() throws Exception { Method method = getClass().getMethod("compositeValueMap", (Class[]) null); Type collectionType = method.getGenericReturnType(); Map map = compositeValueMap(); CompositeMetaType keyType = (CompositeMetaType) resolve(StringKey.class); MetaType valueType = resolve(TestSimpleComposite.class); MetaType[] itemTypes = { keyType, valueType }; String entryName = Map.Entry.class.getName(); CompositeMetaType entryType = new ImmutableCompositeMetaType(entryName, entryName, DefaultMetaTypeFactory.MAP_ITEM_NAMES, DefaultMetaTypeFactory.MAP_ITEM_NAMES, itemTypes); TableMetaType tableType = new ImmutableTableMetaType(Map.class.getName(), Map.class.getName(), entryType, DefaultMetaTypeFactory.MAP_INDEX_NAMES); TableValue expected = new TableValueSupport(tableType); String[] itemNames = DefaultMetaTypeFactory.MAP_ITEM_NAMES; MutableCompositeMetaType compositeType = new MutableCompositeMetaType(TestSimpleComposite.class.getName(), TestSimpleComposite.class.getName()); compositeType.addItem("something", "something", SimpleMetaType.STRING); compositeType.freeze(); String[] compositeNames = { "something" }; CompositeValue compositeValue = new CompositeValueSupport(compositeType, compositeNames, new MetaValue[] { SimpleValueSupport.wrap("Hello") }); MetaValue[] keyValues1 = {SimpleValueSupport.wrap("Hello")}; CompositeValueSupport key1 = new CompositeValueSupport(keyType, new String[]{"key"}, keyValues1); MetaValue[] itemValues = new MetaValue[] { key1, compositeValue }; expected.put(new CompositeValueSupport(entryType, itemNames, itemValues)); MetaValue[] keyValues2 = {SimpleValueSupport.wrap("Goodbye")}; CompositeValueSupport key2 = new CompositeValueSupport(keyType, new String[]{"key"}, keyValues2); compositeValue = new CompositeValueSupport(compositeType, compositeNames, new MetaValue[] { SimpleValueSupport.wrap("Goodbye") }); itemValues = new MetaValue[] { key2, compositeValue }; expected.put(new CompositeValueSupport(entryType, itemNames, itemValues)); MetaValue result = createMetaValue(map, collectionType); TableValue actual = assertInstanceOf(result, TableValue.class); getLog().debug("Map Value: " + actual); assertEquals(expected, actual); } } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/factory/support/libjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/factory/s0000755000175000017500000000000011105402543033276 5ustar twernertwerner././@LongLink0000000000000000000000000000021100000000000011557 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/factory/support/TestRenamedCompositeItem.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/factory/s0000644000175000017500000000416310757514543033324 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.values.factory.support; import org.jboss.metatype.api.annotations.CompositeKey; import org.jboss.metatype.api.annotations.CompositeValue; /** * TestRenamedCompositeItem. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class TestRenamedCompositeItem { /** The id */ private String id; /** The renamed */ private String value; /** * Get the id * * @return the id */ @CompositeKey public String getId() { return id; } /** * Set the id * * @param id the id */ public void setId(String id) { this.id = id; } /** * Get the value. * * @return the value. */ public String getValue() { return value; } /** * Set the value. * * @param value the value. */ @CompositeValue(name="renamed") public void setValue(String value) { this.value = value; } public String getRenamed() { return value; } @CompositeValue(ignore=true) public void setRenamed(String value) { this.value = value; } } ././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/factory/support/TestGenericComposite.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/factory/s0000644000175000017500000000301310645072106033303 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.values.factory.support; /** * TestGenericComposite. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class TestGenericComposite { private TestGeneric generic; /** * Get the generic. * * @return the generic. */ public TestGeneric getGeneric() { return generic; } /** * Set the generic. * * @param generic the generic. */ public void setGeneric(TestGeneric generic) { this.generic = generic; } } ././@LongLink0000000000000000000000000000020600000000000011563 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/factory/support/TestOverrideComposite.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/factory/s0000644000175000017500000000333410645072106033311 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.values.factory.support; /** * TestOverrideComposite. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class TestOverrideComposite { private String something; /** * Create a new TestOverrideComposite. * * @param something the something */ public TestOverrideComposite(String something) { this.something = something; } /** * Get the something. * * @return the something. */ public String getSomething() { return something; } /** * Set the something. * * @param something the something. */ public void setSomething(String something) { this.something = something; } } ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/factory/support/TestEnum.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/factory/s0000644000175000017500000000234710645072106033314 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.values.factory.support; /** * TestEnum. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public enum TestEnum { /** ONE */ ONE, /** TWO */ TWO, /** THREE */ THREE } ././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/factory/support/TestGeneric.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/factory/s0000644000175000017500000000416610645072106033315 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.values.factory.support; import java.io.Serializable; import org.jboss.metatype.api.annotations.Generic; /** * TestGeneric. * * @author Adrian Brock * @version $Revision: 1.1 $ */ @Generic public class TestGeneric implements Serializable { /** The serialVersionUID */ private static final long serialVersionUID = -1L; /** The id */ String id; /** * Create a new TestGeneric. * * @param id the id */ public TestGeneric(String id) { this.id = id; } @Override public boolean equals(Object obj) { if (obj == this) return true; if (obj == null || obj instanceof TestGeneric == false) return false; TestGeneric other = (TestGeneric) obj; return id.equals(other.id); } @Override public int hashCode() { return id.hashCode(); } /** * Get the id. * * @return the id. */ public String getId() { return id; } /** * Set the id. * * @param id the id. */ public void setId(String id) { this.id = id; } } ././@LongLink0000000000000000000000000000021500000000000011563 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/factory/support/TestRecursiveSimpleComposite.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/factory/s0000644000175000017500000000553010706114625033312 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.values.factory.support; /** * TestSimpleComposite. * * @author Ales Justin */ public class TestRecursiveSimpleComposite { private String something; private TestSimpleComposite composite; /** * Default constructor. * Needed with unwrap. */ public TestRecursiveSimpleComposite() { } /** * Create a new TestSimpleComposite. * * @param something the something * @param composite the composite */ public TestRecursiveSimpleComposite(String something, TestSimpleComposite composite) { this.something = something; this.composite = composite; } /** * Get the something. * * @return the something. */ public String getSomething() { return something; } /** * Set the something. * * @param something the something. */ public void setSomething(String something) { this.something = something; } /** * Get the composite. * * @return the composite */ public TestSimpleComposite getComposite() { return composite; } /** * Set the composite. * * @param composite the composite */ public void setComposite(TestSimpleComposite composite) { this.composite = composite; } public boolean equals(Object obj) { if (obj == this) return true; if (obj == null || obj instanceof TestRecursiveSimpleComposite == false) return false; TestRecursiveSimpleComposite other = (TestRecursiveSimpleComposite) obj; return something.equals(other.something) && composite.equals(other.composite); } public int hashCode() { return something.hashCode() + 11 * composite.hashCode(); } } ././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/factory/support/TestAnnotation.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/factory/s0000644000175000017500000000262310645072106033311 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.values.factory.support; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; /** * TestAnnotation. * * @author Adrian Brock * @version $Revision: 1.1 $ */ @Retention(RetentionPolicy.RUNTIME) public @interface TestAnnotation { /** * The something * * @return the something */ String something() default ""; } ././@LongLink0000000000000000000000000000021500000000000011563 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/factory/support/TestOverrideCompositeBuilder.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/factory/s0000644000175000017500000000462310761511660033315 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.values.factory.support; import org.jboss.metatype.api.types.CompositeMetaType; import org.jboss.metatype.api.types.MetaType; import org.jboss.metatype.api.types.SimpleMetaType; import org.jboss.metatype.api.values.CompositeValueSupport; import org.jboss.metatype.api.values.MetaValue; import org.jboss.metatype.api.values.SimpleValueSupport; import org.jboss.metatype.plugins.types.MutableCompositeMetaType; import org.jboss.metatype.spi.types.MetaTypeBuilder; import org.jboss.metatype.spi.values.MetaValueBuilder; /** * TestOverrideCompositeBuilder. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class TestOverrideCompositeBuilder implements MetaTypeBuilder, MetaValueBuilder { public MetaType buildMetaType() { MutableCompositeMetaType result = new MutableCompositeMetaType(TestOverrideComposite.class.getName(), TestOverrideComposite.class.getName()); result.addItem("somethingElse", "somethingElse", SimpleMetaType.STRING); result.freeze(); return result; } public MetaValue buildMetaValue(MetaType metaType, TestOverrideComposite object) { CompositeMetaType compositeType = (CompositeMetaType) metaType; CompositeValueSupport result = new CompositeValueSupport(compositeType); result.set("somethingElse", SimpleValueSupport.wrap(object.getSomething())); return result; } } ././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/factory/support/TestSimpleComposite.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/factory/s0000644000175000017500000000427210706114625033314 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.values.factory.support; /** * TestSimpleComposite. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class TestSimpleComposite { private String something; /** * Default constructor. * Needed with unwrap. */ public TestSimpleComposite() { } /** * Create a new TestSimpleComposite. * * @param something the something */ public TestSimpleComposite(String something) { this.something = something; } /** * Get the something. * * @return the something. */ public String getSomething() { return something; } /** * Set the something. * * @param something the something. */ public void setSomething(String something) { this.something = something; } public boolean equals(Object obj) { if (obj == this) return true; if (obj == null || obj instanceof TestSimpleComposite == false) return false; TestSimpleComposite other = (TestSimpleComposite) obj; return something.equals(other.something); } public int hashCode() { return something.hashCode(); } } ././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/factory/support/TestMetaMapped.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/factory/s0000644000175000017500000000265710757514543033332 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.values.factory.support; import org.jboss.metatype.api.annotations.MetaMapping; /** * TestMetaMapped. * * @author Adrian Brock * @version $Revision: 1.1 $ */ @MetaMapping(TestMetaMapper.class) public class TestMetaMapped { private String value; public TestMetaMapped(String value) { this.value = value; } public String getValue() { return value; } } ././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/factory/support/TestMetaMapper.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/factory/s0000644000175000017500000000416110761511660033312 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.values.factory.support; import java.lang.reflect.Type; import org.jboss.metatype.api.types.MetaType; import org.jboss.metatype.api.types.SimpleMetaType; import org.jboss.metatype.api.values.MetaValue; import org.jboss.metatype.api.values.SimpleValue; import org.jboss.metatype.api.values.SimpleValueSupport; import org.jboss.metatype.spi.values.MetaMapper; /** * TestMetaMapper. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class TestMetaMapper extends MetaMapper { @Override public Type mapToType() { return String.class; } public MetaValue createMetaValue(MetaType metaType, TestMetaMapped object) { return SimpleValueSupport.wrap(object.getValue()); } public TestMetaMapped unwrapMetaValue(MetaValue metaValue) { if (SimpleMetaType.STRING.equals(metaValue.getMetaType()) == false) throw new IllegalArgumentException("Not a string: " + metaValue); SimpleValue simple = (SimpleValue) metaValue; String value = (String) simple.getValue(); return new TestMetaMapped(value); } } ././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/factory/support/StringKey.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/factory/s0000644000175000017500000000400510764061563033314 0ustar twernertwerner/* * 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.metatype.values.factory.support; /** * A string like key used in the MapValueFactoryUnitTestCase, * MapMetaTypeFactoryUnitTestCase. * * @author Scott.Stark@jboss.org * @version $Revision: 70518 $ */ public class StringKey { private String key; public StringKey(String key) { super(); this.key = key; } public String getKey() { return key; } @Override public int hashCode() { final int PRIME = 31; int result = 1; result = PRIME * result + ((key == null) ? 0 : key.hashCode()); return result; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; final StringKey other = (StringKey) obj; if (key == null) { if (other.key != null) return false; } else if (!key.equals(other.key)) return false; return true; } } ././@LongLink0000000000000000000000000000021500000000000011563 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/factory/support/TestSimpleCompositeInterface.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/factory/s0000644000175000017500000000423410730037304033305 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.values.factory.support; /** * TestSimpleCompositeInterface. * * @author Ales Justin */ public class TestSimpleCompositeInterface implements SimpleCompositeInterface { private String something; /** * Default constructor. * Needed with unwrap. */ public TestSimpleCompositeInterface() { } /** * Create a new TestSimpleComposite. * * @param something the something */ public TestSimpleCompositeInterface(String something) { this.something = something; } public String getSomething() { return something; } public void setSomething(String something) { this.something = something; } public boolean equals(Object obj) { if (obj == this) return true; if (obj == null || obj instanceof SimpleCompositeInterface == false) return false; SimpleCompositeInterface other = (SimpleCompositeInterface) obj; return something.equals(other.getSomething()); } public int hashCode() { return something.hashCode(); } } ././@LongLink0000000000000000000000000000021100000000000011557 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/factory/support/TestIgnoredCompositeItem.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/factory/s0000644000175000017500000000373010757514543033323 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.values.factory.support; import org.jboss.metatype.api.annotations.CompositeKey; import org.jboss.metatype.api.annotations.CompositeValue; /** * TestIgnoredCompositeItem. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class TestIgnoredCompositeItem { /** The id */ private String id; /** The ignored */ private Object ignored; /** * Get the id * * @return the id */ @CompositeKey public String getId() { return id; } /** * Set the id * * @param id the id */ public void setId(String id) { this.id = id; } /** * Get the ignored. * * @return the ignored. */ public Object getIgnored() { return ignored; } /** * Set the ignored. * * @param ignored the ignored. */ @CompositeValue(ignore=true) public void setIgnored(Object ignored) { this.ignored = ignored; } } ././@LongLink0000000000000000000000000000020700000000000011564 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/factory/support/TestRecursiveComposite.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/factory/s0000644000175000017500000000400710645072106033307 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.values.factory.support; import org.jboss.metatype.api.annotations.CompositeKey; /** * TestRecursiveComposite. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class TestRecursiveComposite { private String id; private TestRecursiveComposite other; /** * Create a new TestRecursiveComposite. * * @param id */ public TestRecursiveComposite(String id) { this.id = id; } /** * Get the id. * * @return the id. */ @CompositeKey public String getId() { return id; } /** * Set the id. * * @param id the id. */ public void setId(String id) { this.id = id; } /** * Get the other. * * @return the other. */ public TestRecursiveComposite getOther() { return other; } /** * Set the other. * * @param other the other. */ public void setOther(TestRecursiveComposite other) { this.other = other; } } ././@LongLink0000000000000000000000000000021100000000000011557 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/factory/support/SimpleCompositeInterface.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/values/factory/s0000644000175000017500000000267010730037304033307 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.values.factory.support; /** * SimpleCompositeInterface. * * @author Ales Justin */ public interface SimpleCompositeInterface { /** * Get the something. * * @return the something. */ String getSomething(); /** * Set the something. * * @param something the something. */ void setSomething(String something); } libjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/0000755000175000017500000000000011105402543031311 5ustar twernertwernerlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/test/0000755000175000017500000000000011105402543032270 5ustar twernertwerner././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/test/ArrayMetaTypeUnitTestCase.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/test/Array0000644000175000017500000002721710761511660033312 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.types.test; import junit.framework.Test; import org.jboss.metatype.api.types.ArrayMetaType; import org.jboss.metatype.api.types.CompositeMetaType; import org.jboss.metatype.api.types.ImmutableCompositeMetaType; import org.jboss.metatype.api.types.ImmutableTableMetaType; import org.jboss.metatype.api.types.MetaType; import org.jboss.metatype.api.types.SimpleMetaType; import org.jboss.metatype.api.types.TableMetaType; import org.jboss.metatype.api.values.TableValue; import org.jboss.test.metatype.AbstractMetaTypeTest; import org.jboss.test.metatype.types.support.MockCompositeValue; import org.jboss.test.metatype.types.support.MockSimpleValue; import org.jboss.test.metatype.types.support.MockTableValue; /** * ArrayMetaTypeUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class ArrayMetaTypeUnitTestCase extends AbstractMetaTypeTest { /** * Create a testsuite for this test * * @return the testsuite */ public static Test suite() { return suite(ArrayMetaTypeUnitTestCase.class); } /** * Create a new ArrayMetaTypeUnitTestCase. * * @param name the test name */ public ArrayMetaTypeUnitTestCase(String name) { super(name); } /** * Test the meta type for an array meta type * * @throws Exception for any problem */ @SuppressWarnings("unchecked") public void testArrayTypeMetaType() throws Exception { ArrayMetaType arrayType = new ArrayMetaType(3, SimpleMetaType.STRING); assertEquals("[[[Ljava.lang.String;", arrayType.getClassName()); assertEquals("3-dimension array of java.lang.String", arrayType.getDescription()); assertEquals("[[[Ljava.lang.String;", arrayType.getTypeName()); assertTrue("Type should be an array", arrayType.isArray()); } @SuppressWarnings("unchecked") public void testCharArrayType() { ArrayMetaType arrayType = ArrayMetaType.getPrimitiveArrayType(char[].class); assertEquals("[C", arrayType.getClassName()); assertEquals("1-dimension array of char", arrayType.getDescription()); assertEquals("[C", arrayType.getTypeName()); assertTrue("Type should be an array", arrayType.isArray()); assertEquals(SimpleMetaType.CHARACTER, arrayType.getElementType()); } /** * Test the the dimension for an array meta type * * @throws Exception for any problem */ @SuppressWarnings("unchecked") public void testGetDimension() throws Exception { ArrayMetaType arrayType = new ArrayMetaType(3, SimpleMetaType.STRING); assertEquals("Dimension should be 3", 3, arrayType.getDimension()); } /** * Test the element type * * @throws Exception for any problem */ @SuppressWarnings("unchecked") public void testElementType() throws Exception { ArrayMetaType arrayType = new ArrayMetaType(3, SimpleMetaType.STRING); assertEquals("Element MetaType should be " + SimpleMetaType.STRING, SimpleMetaType.STRING, arrayType.getElementType()); } /** * Test the isValue for an array meta type * * @throws Exception for any problem */ public void testIsValueSimpleValue() throws Exception { SimpleMetaType simpleType = SimpleMetaType.STRING; MockSimpleValue sv = new MockSimpleValue(simpleType); MockSimpleValue[][] compData1 = new MockSimpleValue[][] { { sv, null }, { sv, sv } }; ArrayMetaType compArrayType1 = new ArrayMetaType(2, SimpleMetaType.STRING); assertTrue("compData1 should be a value of array type", compArrayType1.isValue(compData1)); ArrayMetaType compArrayType2 = new ArrayMetaType(1, SimpleMetaType.STRING); assertFalse("compData1 should not be a value of array type, wrong dimension", compArrayType2.isValue(compData1)); SimpleMetaType simpleType2 = SimpleMetaType.INTEGER; ArrayMetaType compArrayType3 = new ArrayMetaType(2, simpleType2); assertFalse("compData1 should not be a value of array type, wrong element type", compArrayType3.isValue(compData1)); } /** * Test the isValue for an array meta type * * @throws Exception for any problem */ @SuppressWarnings("unchecked") public void testIsValueComposite() throws Exception { String[] itemNames = new String[] { "name1", "name2" }; String[] itemDescriptions = new String[] { "desc1", "desc2" }; MetaType[] itemTypes = new MetaType[] { SimpleMetaType.STRING, SimpleMetaType.INTEGER }; CompositeMetaType compositeType = new ImmutableCompositeMetaType("typeName", "description", itemNames, itemDescriptions, itemTypes); MockCompositeValue cv = new MockCompositeValue(compositeType); MockCompositeValue[][] compData1 = new MockCompositeValue[][] { { cv, null }, { cv, cv } }; ArrayMetaType compArrayType1 = new ArrayMetaType(2, compositeType); assertTrue("compData1 should be a value of array type", compArrayType1.isValue(compData1)); ArrayMetaType compArrayType2 = new ArrayMetaType(1, compositeType); assertFalse("compData1 should not be a value of array type, wrong dimension", compArrayType2.isValue(compData1)); CompositeMetaType compositeType2 = new ImmutableCompositeMetaType("typeName2", "description", itemNames, itemDescriptions, itemTypes); ArrayMetaType compArrayType3 = new ArrayMetaType(2, compositeType2); assertFalse("compData1 should not be a value of array type, wrong element type", compArrayType3.isValue(compData1)); } /** * Test the isValue for an array meta type * * @throws Exception for any problem */ @SuppressWarnings("unchecked") public void testIsValueTable() throws Exception { String[] itemNames = new String[] { "name1", "name2" }; String[] itemDescriptions = new String[] { "desc1", "desc2" }; MetaType[] itemTypes = new MetaType[] { SimpleMetaType.STRING, SimpleMetaType.INTEGER }; CompositeMetaType compositeType = new ImmutableCompositeMetaType("typeName", "description", itemNames, itemDescriptions, itemTypes); TableMetaType tableType = new ImmutableTableMetaType("typeName", "description", compositeType, new String[] { "name1" }); TableValue tv = new MockTableValue(tableType); TableValue[][] tabData1 = new TableValue[][] { { tv, null }, { tv, tv } }; ArrayMetaType tabArrayType1 = new ArrayMetaType(2, tableType); assertTrue("tabData1 should be a value of array type", tabArrayType1.isValue(tabData1)); ArrayMetaType tabArrayType2 = new ArrayMetaType(1, tableType); assertFalse("tabData1 should not be a value of array type, wrong number of dimensions", tabArrayType2.isValue(tabData1)); TableMetaType tableType2 = new ImmutableTableMetaType("typeName2", "description", compositeType, new String[] { "name1" }); ArrayMetaType tabArrayType3 = new ArrayMetaType(2, tableType2); assertFalse("tabData1 should not be a value of array type, wrong element type", tabArrayType3.isValue(tabData1)); } /** * Test the equals for an array meta type * * @throws Exception for any problem */ @SuppressWarnings("unchecked") public void testEquals() throws Exception { ArrayMetaType arrayType = new ArrayMetaType(3, SimpleMetaType.STRING); assertNotSame("null is not an array type", null, arrayType); assertNotSame("object is not an array type", new Object(), arrayType); assertEquals("should be equal to itself", arrayType, arrayType); ArrayMetaType arrayType2 = new ArrayMetaType(3, SimpleMetaType.STRING); assertEquals("should be equal, even though different instances", arrayType, arrayType2); assertEquals("should be equal, even though different instances", arrayType2, arrayType); arrayType2 = new ArrayMetaType(2, SimpleMetaType.STRING); assertNotSame("should not be equal, wrong number of dimensions", arrayType, arrayType2); assertNotSame("should not be equal, wrong number of dimensions", arrayType2, arrayType); arrayType2 = new ArrayMetaType(3, SimpleMetaType.INTEGER); assertNotSame("should not be equal, wrong element type", arrayType, arrayType2); assertNotSame("should not be equal, wrong element type", arrayType2, arrayType); } /** * Test the hashCode for an array meta type * * @throws Exception for any problem */ @SuppressWarnings("unchecked") public void testHashCode() throws Exception { ArrayMetaType arrayType = new ArrayMetaType(3, SimpleMetaType.STRING); int myHashCode = 3 + SimpleMetaType.STRING.hashCode(); assertTrue("Wrong hash code generated", myHashCode == arrayType.hashCode()); } /** * Test the toString for an array meta type * * @throws Exception for any problem */ @SuppressWarnings("unchecked") public void testToString() throws Exception { ArrayMetaType arrayType = new ArrayMetaType(3, SimpleMetaType.STRING); String toString = arrayType.toString(); assertTrue("toString() should contain the array type class name", toString.indexOf(ArrayMetaType.class.getSimpleName()) != -1); assertTrue("toString() should contain the dimension", toString.indexOf("3") != -1); assertTrue("toString() should contain the element type", toString.indexOf(SimpleMetaType.STRING.toString()) != -1); } /** * Test the serialization for an array meta type * * @throws Exception for any problem */ @SuppressWarnings("unchecked") public void testSerialization() throws Exception { ArrayMetaType arrayType = new ArrayMetaType(3, SimpleMetaType.STRING); byte[] bytes = serialize(arrayType); Object result = deserialize(bytes); assertEquals(arrayType, result); } /** * Test the errors for an array meta type * * @throws Exception for any problem */ @SuppressWarnings("unchecked") public void testErrors() throws Exception { try { new ArrayMetaType(-1, SimpleMetaType.STRING); fail("Excepted IllegalArgumentException for negative dimension"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } try { new ArrayMetaType(1, new ArrayMetaType(2, SimpleMetaType.STRING)); fail("Excepted IllegalArgumentException for ArrayMetaType element type"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } try { new ArrayMetaType(1, null); fail("Excepted IllegalArgumentException for null element type"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } } } ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/test/MetaTypeUnitTestCase.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/test/MetaT0000644000175000017500000002053110761511660033236 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.types.test; import java.math.BigDecimal; import java.math.BigInteger; import java.util.Date; import java.util.List; import junit.framework.Test; import org.jboss.metatype.api.types.MetaType; import org.jboss.metatype.api.types.Name; import org.jboss.metatype.api.values.ArrayValue; import org.jboss.metatype.api.values.CompositeValue; import org.jboss.metatype.api.values.EnumValue; import org.jboss.metatype.api.values.GenericValue; import org.jboss.metatype.api.values.SimpleValue; import org.jboss.metatype.api.values.TableValue; import org.jboss.test.metatype.AbstractMetaTypeTest; import org.jboss.test.metatype.types.support.MockMetaType; /** * MetaTypeUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class MetaTypeUnitTestCase extends AbstractMetaTypeTest { /** * Create a testsuite for this test * * @return the testsuite */ public static Test suite() { return suite(MetaTypeUnitTestCase.class); } /** * Create a new MetaTypeUnitTestCase. * * @param name the test name */ public MetaTypeUnitTestCase(String name) { super(name); } /** * Test the allowed classes * * @throws Exception for any problem */ public void testAllowedClasses() throws Exception { List allowedClassNames = MetaType.ALLOWED_CLASSNAMES; assertEquals(20, allowedClassNames.size()); checkMetaType(allowedClassNames, Void.class); checkMetaType(allowedClassNames, Boolean.class); checkMetaType(allowedClassNames, Character.class); checkMetaType(allowedClassNames, Byte.class); checkMetaType(allowedClassNames, Short.class); checkMetaType(allowedClassNames, Integer.class); checkMetaType(allowedClassNames, Long.class); checkMetaType(allowedClassNames, Float.class); checkMetaType(allowedClassNames, Double.class); checkMetaType(allowedClassNames, String.class); checkMetaType(allowedClassNames, Date.class); checkMetaType(allowedClassNames, BigDecimal.class); checkMetaType(allowedClassNames, BigInteger.class); checkMetaType(allowedClassNames, Name.class); checkMetaType(allowedClassNames, SimpleValue.class); checkMetaType(allowedClassNames, EnumValue.class); checkMetaType(allowedClassNames, GenericValue.class); checkMetaType(allowedClassNames, ArrayValue.class); checkMetaType(allowedClassNames, CompositeValue.class); checkMetaType(allowedClassNames, TableValue.class); } /** * Test the simple constructor * * @throws Exception for any problem */ @SuppressWarnings("unchecked") public void testConstructorSimple() throws Exception { MetaType test = new MockMetaType("java.lang.Void", "type", "description"); assertEquals("java.lang.Void", test.getClassName()); assertEquals("type", test.getTypeName()); assertEquals("description", test.getDescription()); assertEquals(false, test.isArray()); } /** * Test the array constructor * * @throws Exception for any problem */ @SuppressWarnings("unchecked") public void testConstructorArray() throws Exception { MetaType test = new MockMetaType("[[Ljava.lang.Void;", "type", "description"); assertEquals("[[Ljava.lang.Void;", test.getClassName()); assertEquals("type", test.getTypeName()); assertEquals("description", test.getDescription()); assertEquals(true, test.isArray()); } /** * Test the simple serialization * * @throws Exception for any problem */ public void testSerializationSimple() throws Exception { testSerialization("java.lang.Void", "type", "description"); } /** * Test the array serialization * * @throws Exception for any problem */ public void testSerializationArray() throws Exception { testSerialization("[[Ljava.lang.Void;", "type", "description"); } /** * Test the errors * * @throws Exception for any problem */ @SuppressWarnings("unchecked") public void testErrors() throws Exception { try { new MockMetaType(null, "dummy", "dummy"); fail("className cannot be null"); } catch (Throwable e) { checkThrowable(IllegalArgumentException.class, e); } try { new MockMetaType("", "dummy", "dummy"); fail("className cannot be empty"); } catch (Throwable e) { checkThrowable(IllegalArgumentException.class, e); } try { new MockMetaType("java.lang.Void", null, "dummy"); fail("typeName cannot be null"); } catch (Throwable e) { checkThrowable(IllegalArgumentException.class, e); } try { new MockMetaType("java.lang.Void", null, "dummy"); fail("typeName cannot be empty"); } catch (Throwable e) { checkThrowable(IllegalArgumentException.class, e); } try { new MockMetaType("java.lang.Void", "dummy", null); fail("description cannot be null"); } catch (Throwable e) { checkThrowable(IllegalArgumentException.class, e); } try { new MockMetaType("java.lang.Void", "dummy", ""); fail("description cannot be empty"); } catch (Throwable e) { checkThrowable(IllegalArgumentException.class, e); } try { new MockMetaType("java.lang.Class", "dummy", "dummy"); fail("className must be a MetaType"); } catch (Throwable e) { checkThrowable(IllegalArgumentException.class, e); } try { new MockMetaType("[Ljava.lang.Void", "dummy", "dummy"); fail("[Ljava.lang.Void is not a valid array"); } catch (Throwable e) { checkThrowable(IllegalArgumentException.class, e); } try { new MockMetaType("[L", "dummy", "dummy"); fail("[L is not a valid array"); } catch (Throwable e) { checkThrowable(IllegalArgumentException.class, e); } try { new MockMetaType("[Xjava.lang.Void;", "dummy", "dummy"); fail("FAILS IN RI: [Xjava.lang.Void; is not a valid array"); } catch (Throwable e) { checkThrowable(IllegalArgumentException.class, e); } } @SuppressWarnings("unchecked") private void testSerialization(String className, String type, String description) throws Exception { MetaType original = new MockMetaType(className, type, description); byte[] bytes = serialize(original); MetaType result = (MetaType) deserialize(bytes); assertEquals(original.getClassName(), result.getClassName()); assertEquals(original.getTypeName(), result.getTypeName()); assertEquals(original.getDescription(), result.getDescription()); assertEquals(original.isArray(), result.isArray()); } @SuppressWarnings("unchecked") private void checkMetaType(List names, Class clazz) throws Exception { String name = clazz.getName(); assertTrue(name + " is a MetaType", names.contains(name)); new MockMetaType(name, "dummy", "dummy"); new MockMetaType("[L"+name+";", "dummy", "dummy"); new MockMetaType("[[[[[L"+name+";", "dummy", "dummy"); } } ././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/test/SimpleMetaTypeUnitTestCase.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/test/Simpl0000644000175000017500000002274310761511660033317 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.types.test; import java.math.BigDecimal; import java.math.BigInteger; import java.util.Date; import junit.framework.Test; import org.jboss.metatype.api.types.Name; import org.jboss.metatype.api.types.SimpleMetaType; import org.jboss.metatype.api.values.SimpleValue; import org.jboss.metatype.api.values.SimpleValueSupport; import org.jboss.metatype.plugins.types.StringName; import org.jboss.test.metatype.AbstractMetaTypeTest; /** * SimpleMetaTypeUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class SimpleMetaTypeUnitTestCase extends AbstractMetaTypeTest { /** * Create a testsuite for this test * * @return the testsuite */ public static Test suite() { return suite(SimpleMetaTypeUnitTestCase.class); } /** * Create a new SimpleMetaTypeUnitTestCase. * * @param name the test name */ public SimpleMetaTypeUnitTestCase(String name) { super(name); } SimpleMetaType[] types = new SimpleMetaType[] { SimpleMetaType.BIGDECIMAL, SimpleMetaType.BIGINTEGER, SimpleMetaType.BOOLEAN, SimpleMetaType.BYTE, SimpleMetaType.CHARACTER, SimpleMetaType.DATE, SimpleMetaType.DOUBLE, SimpleMetaType.FLOAT, SimpleMetaType.INTEGER, SimpleMetaType.LONG, SimpleMetaType.SHORT, SimpleMetaType.STRING, SimpleMetaType.VOID, SimpleMetaType.NAMEDOBJECT }; Class[] classes = new Class[] { BigDecimal.class, BigInteger.class, Boolean.class, Byte.class, Character.class, Date.class, Double.class, Float.class, Integer.class, Long.class, Short.class, String.class, Void.class, Name.class }; @SuppressWarnings("unchecked") SimpleValue[] values = new SimpleValue[] { new SimpleValueSupport(SimpleMetaType.BIGDECIMAL, new BigDecimal(1)), new SimpleValueSupport(SimpleMetaType.BIGINTEGER, BigInteger.ONE), new SimpleValueSupport(SimpleMetaType.BOOLEAN, new Boolean(false)), new SimpleValueSupport(SimpleMetaType.BYTE, new Byte(Byte.MAX_VALUE)), new SimpleValueSupport(SimpleMetaType.CHARACTER, new Character('a')), new SimpleValueSupport(SimpleMetaType.DATE, new Date(System.currentTimeMillis())), new SimpleValueSupport(SimpleMetaType.DOUBLE, new Double(1)), new SimpleValueSupport(SimpleMetaType.FLOAT, new Float(1)), new SimpleValueSupport(SimpleMetaType.INTEGER, new Integer(1)), new SimpleValueSupport(SimpleMetaType.LONG, new Long(1)), new SimpleValueSupport(SimpleMetaType.SHORT, new Short(Short.MAX_VALUE)), new SimpleValueSupport(SimpleMetaType.STRING, new String("hello")), new SimpleValueSupport(SimpleMetaType.VOID, null), new SimpleValueSupport(SimpleMetaType.NAMEDOBJECT, new StringName("objectref")) }; @SuppressWarnings("unchecked") SimpleValue[] nullValues = new SimpleValue[] { new SimpleValueSupport(SimpleMetaType.BIGDECIMAL, null), new SimpleValueSupport(SimpleMetaType.BIGINTEGER, null), new SimpleValueSupport(SimpleMetaType.BOOLEAN, null), new SimpleValueSupport(SimpleMetaType.BYTE, null), new SimpleValueSupport(SimpleMetaType.CHARACTER, null), new SimpleValueSupport(SimpleMetaType.DATE, null), new SimpleValueSupport(SimpleMetaType.DOUBLE, null), new SimpleValueSupport(SimpleMetaType.FLOAT, null), new SimpleValueSupport(SimpleMetaType.INTEGER, null), new SimpleValueSupport(SimpleMetaType.LONG, null), new SimpleValueSupport(SimpleMetaType.SHORT, null), new SimpleValueSupport(SimpleMetaType.STRING, null), new SimpleValueSupport(SimpleMetaType.VOID, null), new SimpleValueSupport(SimpleMetaType.NAMEDOBJECT, null) }; /** * Test the simple types * * @throws Exception for any problem */ public void testSimpleTypes() throws Exception { for (int i = 0; i < types.length; i++) { String className = classes[i].getName(); getLog().debug("SimpleMetaType: " + className + " className=" + types[i].getClassName() + " typeName=" + types[i].getTypeName() + " description=" + types[i].getDescription()); assertEquals(className, types[i].getClassName()); assertEquals(className, types[i].getTypeName()); assertEquals(className, types[i].getDescription()); } } /** * Test the equals * * @throws Exception for any problem */ public void testEquals() throws Exception { for (int i = 0; i < types.length; i++) { for (int j = 0; j < types.length; j++) { boolean resultEquals = types[i].equals(types[j]); boolean resultReference = types[i] != types[j]; getLog().debug("equals : " + types[i].getClassName() + " " + types[j] + " result=" + resultEquals); getLog().debug("equality: " + types[i].getClassName() + " " + types[j] + " result=" + resultReference); if (i == j) assertEquals("SimpleMetaTypes should be equal to itself " + classes[i], types[i], types[j]); else { assertNotSame("SimpleMetaTypes should be different under equality " + classes[i], types[i], types[j]); assertTrue("SimpleMetaTypes should be different under reference " + classes[i], types[i] != types[j]); } } } } /** * Test the isValue * * @throws Exception for any problem */ public void testIsValue() throws Exception { for (int i = 0; i < types.length; ++i) { for (int j = 0; j < types.length; ++j) { // isValue makes no sense for Void if (values[i].getValue() == null) continue; boolean result = types[j].isValue(values[i]); getLog().debug("isValue: " + types[j].getClassName() + " value=" + values[i] + " result=" + result); if (i == j) { assertTrue(classes[i] + " should be a simple value of " + types[j], result); result = types[i].isValue(nullValues[j]); getLog().debug("isValue: " + types[i].getClassName() + " value=null value result=" + result); assertTrue(nullValues[j] + " should be a simple value of " + types[i], result); } else { assertFalse(classes[i] + " should NOT be a simple value of " + types[j], result); result = types[i].isValue(nullValues[j]); getLog().debug("isValue: " + types[i].getClassName() + " value=null value result=" + result); assertFalse(nullValues[j] + " should NOT be a simple value of " + types[i], result); } } } } /** * Test the hashCode * * @throws Exception for any problem */ public void testHashCode() throws Exception { for (int i = 0; i < types.length; i++) { int classHashCode = classes[i].getName().hashCode(); int typeHashCode = types[i].hashCode(); getLog().debug("hashCode: " + types[i].getClassName() + " expected=" + classHashCode + " actual=" + typeHashCode); assertEquals(classHashCode, typeHashCode); } } /** * Test the toString * * @throws Exception for any problem */ public void testToString() throws Exception { String smt = SimpleMetaType.class.getSimpleName(); for (int i = 0; i < types.length; i++) { String className = classes[i].getName(); String toString = types[i].toString(); getLog().debug("toString: " + types[i].getClassName() + " value=" + toString); assertTrue("SimpleMetaType " + className + " should contain " + smt, toString.indexOf(smt) != -1); assertTrue("SimpleMetaType " + className + " should contain " + className, toString.indexOf(className) != -1); } } /** * Test the serialization * * @throws Exception for any problem */ public void testSerialization() throws Exception { for (int i = 0; i < types.length; i++) { getLog().debug("serialization: " + types[i].getClassName() + " original=" + types[i]); byte[] bytes = serialize(types[i]); SimpleMetaType result = (SimpleMetaType) deserialize(bytes); getLog().debug("serialization: " + types[i].getClassName() + " result =" + types[i]); assertTrue("Should resolve to same object after serialization " + types[i], types[i] == result); } } } ././@LongLink0000000000000000000000000000021300000000000011561 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/test/ImmutableCompositeMetaTypeUnitTestCase.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/test/Immut0000644000175000017500000004040410761511660033320 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.types.test; import java.util.Set; import junit.framework.Test; import org.jboss.metatype.api.types.CompositeMetaType; import org.jboss.metatype.api.types.ImmutableCompositeMetaType; import org.jboss.metatype.api.types.MetaType; import org.jboss.metatype.api.types.SimpleMetaType; import org.jboss.metatype.api.values.CompositeValue; import org.jboss.test.metatype.AbstractMetaTypeTest; /** * CompositeMetaTypeUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class ImmutableCompositeMetaTypeUnitTestCase extends AbstractMetaTypeTest { /** * Create a testsuite for this test * * @return the testsuite */ public static Test suite() { return suite(ImmutableCompositeMetaTypeUnitTestCase.class); } /** * Create a new ImmutableCompositeMetaTypeUnitTestCase. * * @param name the test name */ public ImmutableCompositeMetaTypeUnitTestCase(String name) { super(name); } /** * Test the metatype for a composite type * * @throws Exception for any problem */ public void testCompositeMetaTypeMetaType() throws Exception { CompositeMetaType compositeType = initCompositeMetaType(); assertEquals(CompositeValue.class.getName(), compositeType.getClassName()); assertEquals("description", compositeType.getDescription()); assertEquals("typeName", compositeType.getTypeName()); assertTrue("Composite meta type should not be an array", compositeType.isArray() == false); } /** * Test the containsItem for a composite type * * @throws Exception for any problem */ public void testContainsItem() throws Exception { CompositeMetaType compositeType = initCompositeMetaType(); assertTrue("Composite type should contain key name1", compositeType.containsItem("name1") == true); assertTrue("Composite type should contain key name2", compositeType.containsItem("name2") == true); assertTrue("Composite type should not contain key nameX", compositeType.containsItem("nameX") == false); assertTrue("Composite type should not contain key null", compositeType.containsItem(null) == false); assertTrue("Composite type should not contain key ", compositeType.containsItem("") == false); } /** * Test the description for a composite type item * * @throws Exception for any problem */ public void testGetDescriptionForItemName() throws Exception { CompositeMetaType compositeType = initCompositeMetaType(); assertEquals("desc1", compositeType.getDescription("name1")); assertEquals("desc2", compositeType.getDescription("name2")); } /** * Test the type for a composite type item * * @throws Exception for any problem */ public void testGetTypeForItemName() throws Exception { CompositeMetaType compositeType = initCompositeMetaType(); assertEquals(SimpleMetaType.STRING, compositeType.getType("name1")); assertEquals(SimpleMetaType.INTEGER, compositeType.getType("name2")); } /** * Test the key set for a composite type * * @throws Exception for any problem */ public void testKeySet() throws Exception { CompositeMetaType compositeType = initCompositeMetaType(); Set keys = compositeType.keySet(); assertTrue("Should be 2 items", keys.size() == 2); assertTrue("Should contain name1", keys.contains("name1")); assertTrue("Should contain name2", keys.contains("name2")); } /** * Test the isValue for a composite type * * @throws Exception for any problem */ public void testIsValue() throws Exception { // TODO testIsValue } /** * Test the equals for a composite type * * @throws Exception for any problem */ public void testEquals() throws Exception { CompositeMetaType compositeType = initCompositeMetaType();; assertTrue("null is not equal composite type", compositeType.equals(null) == false); assertTrue("object is not equal composite type", compositeType.equals(new Object()) == false); CompositeMetaType compositeType2 = initCompositeMetaType(); assertTrue("compositeType2 should be equal composite type, even though not the same object instance", compositeType.equals(compositeType2)); assertTrue("compositeType2 should be equal composite type, even though not the same object instance", compositeType2.equals(compositeType)); compositeType2 = initCompositeMetaTypeDifferentItemTypes(); assertTrue("compositeType2 should not be equal composite type, it has different types", compositeType.equals(compositeType2) == false); assertTrue("compositeType2 should not be equal composite type, it has different types", compositeType2.equals(compositeType) == false); compositeType2 = initCompositeMetaTypeDifferentTypeName(); assertTrue("compositeType2 should not be equal composite type, it has a different type name", compositeType.equals(compositeType2) == false); assertTrue("compositeType2 should not be equal composite type, it has a different type name", compositeType2.equals(compositeType) == false); compositeType2 = initCompositeMetaTypeDifferentItemNames(); assertTrue("compositeType2 should not be equal composite type, it has different item names", compositeType.equals(compositeType2) == false); assertTrue("compositeType2 should not be equal composite type, it has different item names", compositeType2.equals(compositeType) == false); } /** * Test the hashCode for a composite type * * @throws Exception for any problem */ public void testHashCode() throws Exception { CompositeMetaType compositeType = initCompositeMetaType(); int myHashCode = "typeName".hashCode(); myHashCode += SimpleMetaType.STRING.hashCode(); myHashCode += SimpleMetaType.INTEGER.hashCode(); myHashCode += "name1".hashCode(); myHashCode += "name2".hashCode(); assertTrue("Wrong hash code generated", myHashCode == compositeType.hashCode()); } /** * Test the toString for a composite type * * @throws Exception for any problem */ public void testToString() throws Exception { CompositeMetaType compositeType = initCompositeMetaType(); String toString = compositeType.toString(); assertTrue("toString() should contain the composite type class name", toString.indexOf(compositeType.getClass().getSimpleName()) != -1); assertTrue("toString() should contain the item name name1", toString.indexOf("name1") != -1); assertTrue("toString() should contain the item name name2", toString.indexOf("name2") != -1); assertTrue("toString() should contain " + SimpleMetaType.STRING.getTypeName(), toString.indexOf(SimpleMetaType.STRING.getTypeName()) != -1); assertTrue("toString() should contain " + SimpleMetaType.INTEGER.getTypeName(), toString.indexOf(SimpleMetaType.INTEGER.getTypeName()) != -1); } /** * Test the serialization for a composite type * * @throws Exception for any problem */ public void testSerialization() throws Exception { CompositeMetaType compositeType = initCompositeMetaType(); byte[] bytes = serialize(compositeType); Object result = deserialize(bytes); assertEquals(compositeType, result); } /** * Test the errors for a composite type * * @throws Exception for any problem */ public void testErrors() throws Exception { String[] itemNames = new String[] { "name1", "name2" }; String[] itemDescriptions = new String[] { "desc1", "desc2" }; MetaType[] itemTypes = new MetaType[] { SimpleMetaType.STRING, SimpleMetaType.INTEGER }; try { new ImmutableCompositeMetaType(null, "description", itemNames, itemDescriptions, itemTypes); fail("Excepted IllegalArgumentException for null typeName"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } try { new ImmutableCompositeMetaType("", "description", itemNames, itemDescriptions, itemTypes); fail("Excepted IllegalArgumentException for empty typeName"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } try { new ImmutableCompositeMetaType("typeName", null, itemNames, itemDescriptions, itemTypes); fail("Excepted IllegalArgumentException for null description"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } try { new ImmutableCompositeMetaType("typeName", "", itemNames, itemDescriptions, itemTypes); fail("Excepted IllegalArgumentException for empty description"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } try { new ImmutableCompositeMetaType("typeName", "description", null, itemDescriptions, itemTypes); fail("Excepted IllegalArgumentException for null item names"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } try { new ImmutableCompositeMetaType("typeName", "description", itemNames, null, itemTypes); fail("Excepted IllegalArgumentException for null item descriptions"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } try { new ImmutableCompositeMetaType("typeName", "description", itemNames, itemDescriptions, null); fail("Excepted IllegalArgumentException for null item types"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } String[] nullItemNames = new String[] { "name1", null }; try { new ImmutableCompositeMetaType("typeName", "description", nullItemNames, itemDescriptions, itemTypes); fail("Excepted IllegalArgumentException for null element of item names"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } String[] nullItemDescriptions = new String[] { "desc1", null }; try { new ImmutableCompositeMetaType("typeName", "description", itemNames, nullItemDescriptions, itemTypes); fail("Excepted IllegalArgumentException for null element of item descriptions"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } MetaType[] nullItemTypes = new MetaType[] { SimpleMetaType.STRING, null }; try { new ImmutableCompositeMetaType("typeName", "description", itemNames, itemDescriptions, nullItemTypes); fail("Excepted IllegalArgumentException for null element of item types"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } String[] wrongItemNames = new String[] { "name1" }; try { new ImmutableCompositeMetaType("typeName", "description", wrongItemNames, itemDescriptions, itemTypes); fail("Excepted IllegalArgumentException for wrong number of elements for item names"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } String[] wrongItemDescriptions = new String[] { "desc1"}; try { new ImmutableCompositeMetaType("typeName", "description", itemNames, wrongItemDescriptions, itemTypes); fail("Excepted IllegalArgumentException for wrong number of elements for item descriptions"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } MetaType[] wrongItemTypes = new MetaType[] { SimpleMetaType.STRING }; try { new ImmutableCompositeMetaType("typeName", "description", itemNames, itemDescriptions, wrongItemTypes); fail("Excepted IllegalArgumentException for wrong number of elements for item types"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } String[] duplicateItemNames = new String[] { "desc1", "desc1" }; try { new ImmutableCompositeMetaType("typeName", "description", duplicateItemNames, itemDescriptions, itemTypes); fail("Excepted OpenDataException for duplicate item names"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } duplicateItemNames = new String[] { "desc1", " desc1 " }; try { new ImmutableCompositeMetaType("typeName", "description", duplicateItemNames, itemDescriptions, itemTypes); fail("Excepted OpenDataException for duplicate item names"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } } /** * Initialise a test composite metatype * * @return the meta type */ protected CompositeMetaType initCompositeMetaType() { String[] itemNames = new String[] { "name1", "name2" }; String[] itemDescriptions = new String[] { "desc1", "desc2" }; MetaType[] itemTypes = new MetaType[] { SimpleMetaType.STRING, SimpleMetaType.INTEGER }; CompositeMetaType compositeType = new ImmutableCompositeMetaType("typeName", "description", itemNames, itemDescriptions, itemTypes); return compositeType; } /** * Initialise a test composite metatype with different item types * * @return the meta type */ protected CompositeMetaType initCompositeMetaTypeDifferentItemTypes() { String[] itemNames = new String[] { "name1", "name2" }; String[] itemDescriptions = new String[] { "desc1", "desc2" }; MetaType[] itemTypes = new MetaType[] { SimpleMetaType.STRING, SimpleMetaType.LONG }; CompositeMetaType compositeType = new ImmutableCompositeMetaType("typeName", "description", itemNames, itemDescriptions, itemTypes); return compositeType; } /** * Initialise a test composite metatype with a different type name * * @return the meta type */ protected CompositeMetaType initCompositeMetaTypeDifferentTypeName() { String[] itemNames = new String[] { "name1", "name2" }; String[] itemDescriptions = new String[] { "desc1", "desc2" }; MetaType[] itemTypes = new MetaType[] { SimpleMetaType.STRING, SimpleMetaType.INTEGER }; CompositeMetaType compositeType = new ImmutableCompositeMetaType("typeName2", "description", itemNames, itemDescriptions, itemTypes); return compositeType; } /** * Initialise a test composite metatype with different item names * * @return the meta type */ protected CompositeMetaType initCompositeMetaTypeDifferentItemNames() { String[] itemNames = new String[] { "nameX", "name2" }; String[] itemDescriptions = new String[] { "desc1", "desc2" }; MetaType[] itemTypes = new MetaType[] { SimpleMetaType.STRING, SimpleMetaType.INTEGER }; CompositeMetaType compositeType = new ImmutableCompositeMetaType("typeName", "description", itemNames, itemDescriptions, itemTypes); return compositeType; } } ././@LongLink0000000000000000000000000000020700000000000011564 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/test/ImmutableTableMetaTypeUnitTestCase.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/test/Immut0000644000175000017500000003143110761511660033320 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.types.test; import java.util.Iterator; import java.util.List; import junit.framework.Test; import org.jboss.metatype.api.types.CompositeMetaType; import org.jboss.metatype.api.types.ImmutableCompositeMetaType; import org.jboss.metatype.api.types.ImmutableTableMetaType; import org.jboss.metatype.api.types.MetaType; import org.jboss.metatype.api.types.SimpleMetaType; import org.jboss.metatype.api.types.TableMetaType; import org.jboss.metatype.api.values.TableValue; import org.jboss.test.metatype.AbstractMetaTypeTest; /** * ImmutableMetaTypeUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class ImmutableTableMetaTypeUnitTestCase extends AbstractMetaTypeTest { /** * Create a testsuite for this test * * @return the testsuite */ public static Test suite() { return suite(ImmutableTableMetaTypeUnitTestCase.class); } /** * Create a new ImmutableTableMetaTypeUnitTestCase. * * @param name the test name */ public ImmutableTableMetaTypeUnitTestCase(String name) { super(name); } /** * Test the metatype for a table type * * @throws Exception for any problem */ public void testTableMetaType() throws Exception { TableMetaType tableType = initTableMetaType(); assertEquals(TableValue.class.getName(), tableType.getClassName()); assertEquals("description", tableType.getDescription()); assertEquals("typeName", tableType.getTypeName()); assertTrue("Tabular type should not be an array", tableType.isArray() == false); } /** * Test the getRow for a table type * * @throws Exception for any problem */ public void testGetRowType() throws Exception { CompositeMetaType rowType = initRowType(); TableMetaType tableType = initTableMetaType(); assertEquals(rowType, tableType.getRowType()); } /** * Test the getIndexNames for a table type * * @throws Exception for any problem */ public void testIndexNames() throws Exception { TableMetaType tableType = initTableMetaType(); List indexList = tableType.getIndexNames(); assertTrue("wrong number of index names", indexList.size() == 2); assertTrue("index list should contain name1", indexList.contains("name1")); assertTrue("index list should contain name2", indexList.contains("name2")); Iterator i = indexList.iterator(); assertTrue("first index is name1", i.next().equals("name1")); assertTrue("second index is name2", i.next().equals("name2")); } /** * Test the isValue for a table type * * @throws Exception for any problem */ public void testIsValue() throws Exception { // TODO testIsValue } /** * Test the equals for a table type * * @throws Exception for any problem */ public void testEquals() throws Exception { TableMetaType tableType = initTableMetaType(); assertNotSame("null is not equal to table type", tableType, null); assertNotSame("object is not a equal to table type", tableType, new Object()); TableMetaType tableType2 = initTableMetaType(); assertEquals("Should be equal, even though the table type is a different instance", tableType, tableType2); assertEquals("Should be equal, even though the table type is a different instance", tableType2, tableType); tableType2 = initTableMetaTypeDifferentTypeName(); assertNotSame("should not be equal, they have different type names", tableType, tableType2); assertNotSame("should not be equal, they have different type names", tableType2, tableType); tableType2 = initTableMetaTypeDifferentRowTypes(); assertNotSame("should not be equal, they have different row types", tableType, tableType2); assertNotSame("should not be equal, they have different row types", tableType2, tableType); tableType2 = initTableMetaTypeDifferentIndexNames(); assertNotSame("should not be equal, they have different index names", tableType, tableType2); assertNotSame("should not be equal, they have different index names", tableType2, tableType); } /** * Test the hashCdoe for a table type * * @throws Exception for any problem */ public void testHashCode() throws Exception { CompositeMetaType rowType = initRowType(); TableMetaType tableType = initTableMetaType(); int myHashCode = "typeName".hashCode() + rowType.hashCode() + "name1".hashCode() + "name2".hashCode(); assertTrue("Wrong hash code generated", myHashCode == tableType.hashCode()); } /** * Test the toString for a table type * * @throws Exception for any problem */ public void testToString() throws Exception { CompositeMetaType rowType = initRowType(); TableMetaType tableType = initTableMetaType(); String toString = tableType.toString(); assertTrue("toString() should contain the tabular type class name", toString.indexOf(TableMetaType.class.getSimpleName()) != -1); assertTrue("toString() should contain the type name", toString.indexOf("typeName") != -1); assertTrue("toString() should contain the row type " + rowType, toString.indexOf(rowType.toString()) != -1); assertTrue("toString() should contain the index name1", toString.indexOf("name1") != -1); assertTrue("toString() should contain the index name2", toString.indexOf("name2") != -1); } /** * Test the serialization for a table type * * @throws Exception for any problem */ public void testSerialization() throws Exception { TableMetaType tableType = initTableMetaType(); byte[] bytes = serialize(tableType); Object result = deserialize(bytes); assertEquals(tableType, result); } /** * Test the errors for a table type * * @throws Exception for any problem */ public void testErrors() throws Exception { CompositeMetaType rowType = initRowType(); String[] indexNames = new String[] { "name1", "name2" }; try { new ImmutableTableMetaType(null, "description", rowType, indexNames); fail("Expected IllegalArgumentException for null type name"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } try { new ImmutableTableMetaType("", "description", rowType, indexNames); fail("Expected IllegalArgumentException for empty type name"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } try { new ImmutableTableMetaType("typeName", null, rowType, indexNames); fail("Expected IllegalArgumentException for null description"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } try { new ImmutableTableMetaType("typeName", "", rowType, indexNames); fail("Expected IllegalArgumentException for empty description"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } try { new ImmutableTableMetaType("typeName", "description", null, indexNames); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } try { new ImmutableTableMetaType("typeName", "description", rowType, null); fail("Expected IllegalArgumentException for null row type"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } try { new ImmutableTableMetaType("typeName", "description", rowType, new String[0]); fail("Expected IllegalArgumentException for empty index names"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } try { new ImmutableTableMetaType("typeName", "description", rowType, new String[] { "name1", null }); fail("Expected IllegalArgumentException for null index name element"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } try { new ImmutableTableMetaType("typeName", "description", rowType, new String[] { "name1", "" }); fail("Expected IllegalArgumentException for empty index name element"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } try { new ImmutableTableMetaType("typeName", "description", rowType, new String[] { "name1", "nameX" }); fail("Expected IllegalArgumentException for invalid index name"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } } /** * Initialise a test row type * * @return the test row type * @throws Exception for any problem */ protected CompositeMetaType initRowType() throws Exception { String[] itemNames = new String[] { "name1", "name2" }; String[] itemDescriptions = new String[] { "desc1", "desc2" }; MetaType[] itemTypes = new MetaType[] { SimpleMetaType.STRING, SimpleMetaType.INTEGER }; CompositeMetaType rowType = new ImmutableCompositeMetaType("rowTypeName", "rowDescription", itemNames, itemDescriptions, itemTypes); return rowType; } /** * Initialise a test table type * * @return the type * @throws Exception for any problem */ protected TableMetaType initTableMetaType() throws Exception { CompositeMetaType rowType = initRowType(); String[] indexNames = new String[] { "name1", "name2" }; TableMetaType tableType = new ImmutableTableMetaType("typeName", "description", rowType, indexNames); return tableType; } /** * Initialise a test table type with a different type name * * @return the type * @throws Exception for any problem */ protected TableMetaType initTableMetaTypeDifferentTypeName() throws Exception { CompositeMetaType rowType = initRowType(); String[] indexNames = new String[] { "name1", "name2" }; TableMetaType tableType = new ImmutableTableMetaType("typeName2", "description", rowType, indexNames); return tableType; } /** * Initialise a test row type 2 * * @return the type * @throws Exception for any problem */ protected CompositeMetaType initRowType2() throws Exception { String[] itemNames = new String[] { "name1", "name2" }; String[] itemDescriptions = new String[] { "desc1", "desc2" }; MetaType[] itemTypes = new MetaType[] { SimpleMetaType.STRING, SimpleMetaType.INTEGER }; CompositeMetaType rowType = new ImmutableCompositeMetaType("rowTypeName2", "rowDescription", itemNames, itemDescriptions, itemTypes); return rowType; } /** * Initialise a test table type with different row types * * @return the type * @throws Exception for any problem */ protected TableMetaType initTableMetaTypeDifferentRowTypes() throws Exception { CompositeMetaType rowType = initRowType2(); String[] indexNames = new String[] { "name1", "name2" }; TableMetaType tableType = new ImmutableTableMetaType("typeName", "description", rowType, indexNames); return tableType; } /** * Initialise a test table type with different index names * * @return the type * @throws Exception for any problem */ protected TableMetaType initTableMetaTypeDifferentIndexNames() throws Exception { CompositeMetaType rowType = initRowType(); String[] indexNames = new String[] { "name2", "name1" }; TableMetaType tableType = new ImmutableTableMetaType("typeName", "description", rowType, indexNames); return tableType; } } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/test/TypesTestSuite.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/test/Types0000644000175000017500000000371710645072106033335 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2005, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.types.test; import junit.framework.Test; import junit.framework.TestSuite; import junit.textui.TestRunner; /** * Types Test Suite. * * @author Adrian Brock * @version $Revision: 55115 $ */ public class TypesTestSuite extends TestSuite { /** * For running the testsuite from the command line * * @param args the command line args */ public static void main(String[] args) { TestRunner.run(suite()); } /** * Create the testsuite * * @return the testsuite */ public static Test suite() { TestSuite suite = new TestSuite("Types Tests"); suite.addTest(MetaTypeUnitTestCase.suite()); suite.addTest(SimpleMetaTypeUnitTestCase.suite()); suite.addTest(ArrayMetaTypeUnitTestCase.suite()); suite.addTest(ImmutableCompositeMetaTypeUnitTestCase.suite()); suite.addTest(ImmutableTableMetaTypeUnitTestCase.suite()); return suite; } } libjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/factory/0000755000175000017500000000000011105402543032760 5ustar twernertwerner././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/factory/test/libjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/factory/te0000755000175000017500000000000011105402543033311 5ustar twernertwerner././@LongLink0000000000000000000000000000022100000000000011560 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/factory/test/CompositeMetaTypeFactoryUnitTestCase.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/factory/te0000644000175000017500000001656610764347532033351 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.types.factory.test; import java.lang.reflect.Field; import java.lang.reflect.Type; import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.Properties; import java.util.Set; import junit.framework.Test; import org.jboss.metatype.api.types.CompositeMetaType; import org.jboss.metatype.api.types.ImmutableCompositeMetaType; import org.jboss.metatype.api.types.ImmutableTableMetaType; import org.jboss.metatype.api.types.MapCompositeMetaType; import org.jboss.metatype.api.types.MetaType; import org.jboss.metatype.api.types.SimpleMetaType; import org.jboss.metatype.api.types.TableMetaType; import org.jboss.metatype.plugins.types.DefaultMetaTypeFactory; import org.jboss.metatype.plugins.types.MutableCompositeMetaType; import org.jboss.test.metatype.types.factory.support.TestIgnoredCompositeItem; import org.jboss.test.metatype.types.factory.support.TestRecursiveComposite; import org.jboss.test.metatype.types.factory.support.TestRenamedCompositeItem; import org.jboss.test.metatype.types.factory.support.TestSimpleComposite; /** * CompositeMetaTypeFactoryUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class CompositeMetaTypeFactoryUnitTestCase extends AbstractMetaTypeFactoryTest { /** * Create a testsuite for this test * * @return the testsuite */ public static Test suite() { return suite(CompositeMetaTypeFactoryUnitTestCase.class); } /** * Create a new CompositeMetaTypeFactoryUnitTestCase. * * @param name the test name */ public CompositeMetaTypeFactoryUnitTestCase(String name) { super(name); } /** * Test the correct metatype is generated for a simple composite * * @throws Exception for any problem */ public void testSimpleComposite() throws Exception { MetaType result = resolve(TestSimpleComposite.class); CompositeMetaType actual = assertInstanceOf(result, CompositeMetaType.class); MutableCompositeMetaType expected = new MutableCompositeMetaType(TestSimpleComposite.class.getName(), TestSimpleComposite.class.getName()); expected.addItem("something", "something", SimpleMetaType.STRING); expected.freeze(); testComposite(expected, actual); } /** * Test the correct metatype is generated for a recursive composite * * @throws Exception for any problem */ public void testRecursiveComposite() throws Exception { MetaType result = resolve(TestRecursiveComposite.class); CompositeMetaType actual = assertInstanceOf(result, CompositeMetaType.class); MutableCompositeMetaType expected = new MutableCompositeMetaType(TestRecursiveComposite.class.getName(), TestRecursiveComposite.class.getName()); expected.addItem("id", "id", SimpleMetaType.STRING); expected.addItem("other", "other", expected); Set keys = Collections.singleton("id"); expected.setKeys(keys); expected.freeze(); testComposite(expected, actual); } public void testIgnoredItem() throws Exception { MetaType result = resolve(TestIgnoredCompositeItem.class); CompositeMetaType actual = assertInstanceOf(result, CompositeMetaType.class); MutableCompositeMetaType expected = new MutableCompositeMetaType(TestIgnoredCompositeItem.class.getName(), TestIgnoredCompositeItem.class.getName()); expected.addItem("id", "id", SimpleMetaType.STRING); Set keys = Collections.singleton("id"); expected.setKeys(keys); expected.freeze(); testComposite(expected, actual); } public void testRenamedItem() throws Exception { MetaType result = resolve(TestRenamedCompositeItem.class); CompositeMetaType actual = assertInstanceOf(result, CompositeMetaType.class); MutableCompositeMetaType expected = new MutableCompositeMetaType(TestRenamedCompositeItem.class.getName(), TestRenamedCompositeItem.class.getName()); expected.addItem("id", "id", SimpleMetaType.STRING); expected.addItem("renamed", "renamed", SimpleMetaType.STRING); Set keys = Collections.singleton("id"); expected.setKeys(keys); expected.freeze(); testComposite(expected, actual); } public HashMap compositeSignature; /** * JBMICROCONT-238, Map should map to a MapCompositeMetaType(MetaValue) * @throws Exception */ public void testMapWithStringKeyComposite() throws Exception { //Map map = new HashMap(); Field field = getClass().getField("compositeSignature"); Type mapSignature = field.getGenericType(); CompositeMetaType result = assertInstanceOf(resolve(mapSignature), CompositeMetaType.class); MapCompositeMetaType expected = new MapCompositeMetaType(SimpleMetaType.STRING); testComposite(expected, result); } /** * JBMICROCONT-238, java.util.Properties should map to a MapCompositeMetaType(MetaValue) * @throws Exception */ public void testPropertiesComposite() throws Exception { Type propertiesType = Properties.class; CompositeMetaType result = assertInstanceOf(resolve(propertiesType), CompositeMetaType.class); MapCompositeMetaType expected = new MapCompositeMetaType(SimpleMetaType.STRING); testComposite(expected, result); } /** * Illustrate the expected type when type does not contain the * generic parameter type information. * * @throws Exception for any error */ public void testMapWithStringKeyErasure() throws Exception { Map map = new HashMap(); Type mapSignature = map.getClass(); TableMetaType result = assertInstanceOf(resolve(mapSignature), TableMetaType.class); MetaType keyType = resolve(Object.class); MetaType valueType = resolve(Object.class); MetaType[] itemTypes = { keyType, valueType }; String entryName = Map.Entry.class.getName(); CompositeMetaType entryType = new ImmutableCompositeMetaType(entryName, entryName, DefaultMetaTypeFactory.MAP_ITEM_NAMES, DefaultMetaTypeFactory.MAP_ITEM_NAMES, itemTypes); TableMetaType expected = new ImmutableTableMetaType(Map.class.getName(), Map.class.getName(), entryType, DefaultMetaTypeFactory.MAP_INDEX_NAMES); assertEquals(expected, result); } } ././@LongLink0000000000000000000000000000021400000000000011562 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/factory/test/EnumMetaTypeFactoryUnitTestCase.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/factory/te0000644000175000017500000000513610761511660033330 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.types.factory.test; import java.util.ArrayList; import junit.framework.Test; import org.jboss.metatype.api.types.EnumMetaType; import org.jboss.metatype.api.types.MetaType; import org.jboss.test.metatype.types.factory.support.TestEnum; /** * EnumMetaTypeFactoryUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class EnumMetaTypeFactoryUnitTestCase extends AbstractMetaTypeFactoryTest { /** * Create a testsuite for this test * * @return the testsuite */ public static Test suite() { return suite(EnumMetaTypeFactoryUnitTestCase.class); } /** * Create a new EnumMetaTypeFactoryUnitTestCase. * * @param name the test name */ public EnumMetaTypeFactoryUnitTestCase(String name) { super(name); } /** * Test the correct metatype is generated for an enum * * @throws Exception for any problem */ public void testEnumType() throws Exception { MetaType result = resolve(TestEnum.class); EnumMetaType actual = assertInstanceOf(result, EnumMetaType.class); ArrayList expectedValues = new ArrayList(3); expectedValues.add("ONE"); expectedValues.add("TWO"); expectedValues.add("THREE"); EnumMetaType expected = new EnumMetaType(TestEnum.class.getName(), expectedValues); getLog().debug("Enum MetaType: className=" + actual.getClassName() + " typeName=" + actual.getTypeName() + " description=" + actual.getDescription() + " values=" + actual.getValidValues()); assertEquals(expected, actual); } } ././@LongLink0000000000000000000000000000021000000000000011556 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/factory/test/AbstractMetaTypeFactoryTest.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/factory/te0000644000175000017500000000427310761511660033331 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.types.factory.test; import java.lang.reflect.Type; import org.jboss.metatype.api.types.MetaType; import org.jboss.metatype.api.types.MetaTypeFactory; import org.jboss.metatype.spi.types.MetaTypeBuilder; import org.jboss.test.metatype.AbstractMetaTypeTest; /** * AbstractMetaTypeFactoryTest. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public abstract class AbstractMetaTypeFactoryTest extends AbstractMetaTypeTest { /** The metatype factory */ private static final MetaTypeFactory metaTypeFactory = MetaTypeFactory.getInstance(); /** * Create a new AbstractMetaTypeFactoryTest. * * @param name the test name */ public AbstractMetaTypeFactoryTest(String name) { super(name); } /** * Set a builder * * @param clazz the clazz * @param builder the builder */ protected void setBuilder(Class clazz, MetaTypeBuilder builder) { metaTypeFactory.setBuilder(clazz, builder); } /** * Resolve a metatype * * @param type the type * @return the meta type */ protected MetaType resolve(Type type) { return metaTypeFactory.resolve(type); } } ././@LongLink0000000000000000000000000000021600000000000011564 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/factory/test/SimpleMetaTypeFactoryUnitTestCase.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/factory/te0000644000175000017500000000675710761511660033342 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.types.factory.test; import java.math.BigDecimal; import java.math.BigInteger; import java.util.Date; import junit.framework.Test; import org.jboss.metatype.api.types.MetaType; import org.jboss.metatype.api.types.SimpleMetaType; /** * SimpleMetaTypeFactoryUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class SimpleMetaTypeFactoryUnitTestCase extends AbstractMetaTypeFactoryTest { /** * Create a testsuite for this test * * @return the testsuite */ public static Test suite() { return suite(SimpleMetaTypeFactoryUnitTestCase.class); } /** * Create a new SimpleMetaTypeFactoryUnitTestCase. * * @param name the test name */ public SimpleMetaTypeFactoryUnitTestCase(String name) { super(name); } SimpleMetaType[] expected = new SimpleMetaType[] { SimpleMetaType.BIGDECIMAL, SimpleMetaType.BIGINTEGER, SimpleMetaType.BOOLEAN, SimpleMetaType.BOOLEAN, SimpleMetaType.BYTE, SimpleMetaType.BYTE, SimpleMetaType.CHARACTER, SimpleMetaType.CHARACTER, SimpleMetaType.DATE, SimpleMetaType.DOUBLE, SimpleMetaType.DOUBLE, SimpleMetaType.FLOAT, SimpleMetaType.FLOAT, SimpleMetaType.INTEGER, SimpleMetaType.INTEGER, SimpleMetaType.LONG, SimpleMetaType.LONG, SimpleMetaType.SHORT, SimpleMetaType.SHORT, SimpleMetaType.STRING, SimpleMetaType.VOID }; Class[] classes = new Class[] { BigDecimal.class, BigInteger.class, Boolean.class, Boolean.TYPE, Byte.class, Byte.TYPE, Character.class, Character.TYPE, Date.class, Double.class, Double.TYPE, Float.class, Float.TYPE, Integer.class, Integer.TYPE, Long.class, Long.TYPE, Short.class, Short.TYPE, String.class, Void.class }; /** * Test the simple meta types are generated correctly * * @throws Exception for any problem */ public void testSimpleTypes() throws Exception { for (int i = 0; i < expected.length; ++i) { String className = classes[i].getName(); MetaType actual = resolve(classes[i]); getLog().debug("SimpleMetaType: " + className + " className=" + actual.getClassName() + " typeName=" + actual.getTypeName() + " description=" + actual.getDescription()); assertEquals(expected[i], actual); } } } ././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/factory/test/TypesFactoryTestSuite.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/factory/te0000644000175000017500000000431210645072106033321 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2005, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.types.factory.test; import junit.framework.Test; import junit.framework.TestSuite; import junit.textui.TestRunner; /** * Types Factory Test Suite. * * @author Adrian Brock * @version $Revision: 55115 $ */ public class TypesFactoryTestSuite extends TestSuite { /** * For running the testsuite from the command line * * @param args the command line args */ public static void main(String[] args) { TestRunner.run(suite()); } /** * Create the testsuite * * @return the testsuite */ public static Test suite() { TestSuite suite = new TestSuite("Types Factory Tests"); suite.addTest(SimpleMetaTypeFactoryUnitTestCase.suite()); suite.addTest(SpecialMetaTypeFactoryUnitTestCase.suite()); suite.addTest(EnumMetaTypeFactoryUnitTestCase.suite()); suite.addTest(ArrayMetaTypeFactoryUnitTestCase.suite()); suite.addTest(CollectionMetaTypeFactoryUnitTestCase.suite()); suite.addTest(MapMetaTypeFactoryUnitTestCase.suite()); suite.addTest(CompositeMetaTypeFactoryUnitTestCase.suite()); suite.addTest(AnnotationMetaTypeFactoryUnitTestCase.suite()); return suite; } } ././@LongLink0000000000000000000000000000022200000000000011561 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/factory/test/AnnotationMetaTypeFactoryUnitTestCase.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/factory/te0000644000175000017500000000511610761511660033326 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.types.factory.test; import junit.framework.Test; import org.jboss.metatype.api.types.CompositeMetaType; import org.jboss.metatype.api.types.MetaType; import org.jboss.metatype.api.types.SimpleMetaType; import org.jboss.metatype.plugins.types.MutableCompositeMetaType; import org.jboss.test.metatype.types.factory.support.TestSimpleAnnotation; /** * AnnotationMetaTypeFactoryUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class AnnotationMetaTypeFactoryUnitTestCase extends AbstractMetaTypeFactoryTest { /** * Create a new testsuite for this test * * @return the testsuite */ public static Test suite() { return suite(AnnotationMetaTypeFactoryUnitTestCase.class); } /** * Create a new AnnotationMetaTypeFactoryUnitTestCase. * * @param name the test name */ public AnnotationMetaTypeFactoryUnitTestCase(String name) { super(name); } /** * Test the composite type generated for a simple annotation * * @throws Exception for any problem */ public void testSimpleAnnotation() throws Exception { MetaType result = resolve(TestSimpleAnnotation.class); CompositeMetaType actual = assertInstanceOf(result, CompositeMetaType.class); MutableCompositeMetaType expected = new MutableCompositeMetaType(TestSimpleAnnotation.class.getName(), TestSimpleAnnotation.class.getName()); expected.addItem("something", "something", SimpleMetaType.STRING); expected.freeze(); testComposite(expected, actual); } } ././@LongLink0000000000000000000000000000022200000000000011561 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/factory/test/CollectionMetaTypeFactoryUnitTestCase.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/factory/te0000644000175000017500000001300410726633514033325 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.types.factory.test; import java.lang.reflect.Method; import java.lang.reflect.Type; import java.util.Collection; import java.util.List; import java.util.Set; import junit.framework.Test; import org.jboss.metatype.api.types.CollectionMetaType; import org.jboss.metatype.api.types.MetaType; import org.jboss.test.metatype.types.factory.support.TestSimpleComposite; /** * CollectionMetaTypeFactoryUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class CollectionMetaTypeFactoryUnitTestCase extends AbstractMetaTypeFactoryTest { /** * Create a testsuite for this test * * @return the testsuite */ public static Test suite() { return suite(CollectionMetaTypeFactoryUnitTestCase.class); } /** * Create a new CollectionMetaTypeFactoryUnitTestCase. * * @param name the test name */ public CollectionMetaTypeFactoryUnitTestCase(String name) { super(name); } /** * Signature method for a simple collection * * @return the signature */ public Collection simpleCollection() { return null; } /** * Signature method for a composite collection * * @return the signature */ public static Collection simpleCompositeCollection() { return null; } /** * Signature method for a list * * @return the signature */ public List simpleList() { return null; } /** * Signature method for a composite list * * @return the signature */ public static List simpleCompositeList() { return null; } /** * Signature method for a composite set * * @return the signature */ public Set simpleSet() { return null; } /** * Signature method for a composite set * * @return the signature */ public static Set simpleCompositeSet() { return null; } /** * Test the correct meta type is generated for a simple collection * * @throws Exception for any problem */ public void testSimpleCollection() throws Exception { testCollection("simpleCollection", String.class, Collection.class); } /** * Test the correct meta type is generated for a composite collection * * @throws Exception for any problem */ public void testSimpleCompositeCollection() throws Exception { testCollection("simpleCompositeCollection", TestSimpleComposite.class, Collection.class); } /** * Test the correct meta type is generated for a simple list * * @throws Exception for any problem */ public void testSimpleList() throws Exception { testCollection("simpleList", String.class, List.class); } /** * Test the correct meta type is generated for a composite list * * @throws Exception for any problem */ public void testSimpleCompositeList() throws Exception { testCollection("simpleCompositeList", TestSimpleComposite.class, List.class); } /** * Test the correct meta type is generated for a simple set * * @throws Exception for any problem */ public void testSimpleSet() throws Exception { testCollection("simpleSet", String.class, Set.class); } /** * Test the correct meta type is generated for a composite set * * @throws Exception for any problem */ public void testSimpleCompositeSet() throws Exception { testCollection("simpleCompositeSet", TestSimpleComposite.class, Set.class); } /** * Test the correct meta type is generated for a collection * * @param methodName the method name to lookup the connection signature * @param elementClass the expected element type of the collection * @param collectionClass the expected type of the collection * @throws Exception for any problem */ @SuppressWarnings("unchecked") protected void testCollection(String methodName, Type elementClass, Class collectionClass) throws Exception { Method method = getClass().getMethod(methodName); Type collectionType = method.getGenericReturnType(); MetaType result = resolve(collectionType); CollectionMetaType actual = assertInstanceOf(result, CollectionMetaType.class); MetaType elementType = resolve(elementClass); CollectionMetaType expected = new CollectionMetaType(collectionClass.getName(), elementType); testCollection(expected, actual); } } ././@LongLink0000000000000000000000000000021500000000000011563 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/factory/test/ArrayMetaTypeFactoryUnitTestCase.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/factory/te0000644000175000017500000001145210761511660033326 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.types.factory.test; import org.jboss.metatype.api.types.ArrayMetaType; import org.jboss.metatype.api.types.MetaType; import org.jboss.metatype.api.types.SimpleMetaType; import org.jboss.test.metatype.types.factory.support.TestSimpleComposite; import junit.framework.Test; /** * ArrayMetaTypeFactoryUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class ArrayMetaTypeFactoryUnitTestCase extends AbstractMetaTypeFactoryTest { /** * Create a testsuite for this test * * @return the testsuite */ public static Test suite() { return suite(ArrayMetaTypeFactoryUnitTestCase.class); } /** * Create a new ArrayMetaTypeFactoryUnitTestCase. * * @param name the test name */ public ArrayMetaTypeFactoryUnitTestCase(String name) { super(name); } /** * Test the correct meta type is generated for a simple array * * @throws Exception for any problem */ @SuppressWarnings("unchecked") public void testSimpleArray() throws Exception { String[] array = new String[0]; MetaType result = resolve(array.getClass()); ArrayMetaType actual = assertInstanceOf(result, ArrayMetaType.class); ArrayMetaType expected = new ArrayMetaType(1, SimpleMetaType.STRING); testArray(expected, actual); } @SuppressWarnings("unchecked") public void testCharArray() throws Exception { char[] array = {'H', 'e', 'l', 'l', 'o'}; MetaType result = resolve(array.getClass()); ArrayMetaType actual = assertInstanceOf(result, ArrayMetaType.class); ArrayMetaType expected = new ArrayMetaType(1, SimpleMetaType.CHARACTER); testArray(expected, actual); } @SuppressWarnings("unchecked") public void testChar2DArray() throws Exception { char[][] array = {{'H', 'e', 'l', 'l', 'o'}}; MetaType result = resolve(array.getClass()); ArrayMetaType actual = assertInstanceOf(result, ArrayMetaType.class); ArrayMetaType expected = new ArrayMetaType(2, SimpleMetaType.CHARACTER); testArray(expected, actual); } /** * Test the correct meta type is generated for a composite array * * @throws Exception for any problem */ @SuppressWarnings("unchecked") public void testSimpleCompositeArray() throws Exception { TestSimpleComposite[] array = new TestSimpleComposite[0]; MetaType result = resolve(array.getClass()); MetaType composite = resolve(TestSimpleComposite.class); ArrayMetaType actual = assertInstanceOf(result, ArrayMetaType.class); ArrayMetaType expected = new ArrayMetaType(1, composite); testArray(expected, actual); } /** * Test the correct meta type is generated for a multidimensional simple array * * @throws Exception for any problem */ @SuppressWarnings("unchecked") public void testMultiSimpleArray() throws Exception { String[][] array = new String[0][0]; MetaType result = resolve(array.getClass()); ArrayMetaType actual = assertInstanceOf(result, ArrayMetaType.class); ArrayMetaType expected = new ArrayMetaType(2, SimpleMetaType.STRING); testArray(expected, actual); } /** * Test the correct meta type is generated for a mutli dimensional composite array * * @throws Exception for any problem */ @SuppressWarnings("unchecked") public void testMultiSimpleCompositeArray() throws Exception { TestSimpleComposite[][] array = new TestSimpleComposite[0][0]; MetaType result = resolve(array.getClass()); MetaType composite = resolve(TestSimpleComposite.class); ArrayMetaType actual = assertInstanceOf(result, ArrayMetaType.class); ArrayMetaType expected = new ArrayMetaType(2, composite); testArray(expected, actual); } } ././@LongLink0000000000000000000000000000021300000000000011561 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/factory/test/MapMetaTypeFactoryUnitTestCase.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/factory/te0000644000175000017500000001152110770514540033323 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.types.factory.test; import java.lang.reflect.Method; import java.lang.reflect.Type; import java.util.Map; import junit.framework.Test; import org.jboss.metatype.api.types.CompositeMetaType; import org.jboss.metatype.api.types.ImmutableCompositeMetaType; import org.jboss.metatype.api.types.ImmutableTableMetaType; import org.jboss.metatype.api.types.MetaType; import org.jboss.metatype.api.types.TableMetaType; import org.jboss.metatype.plugins.types.DefaultMetaTypeFactory; import org.jboss.test.metatype.types.factory.support.TestSimpleComposite; import org.jboss.test.metatype.values.factory.support.StringKey; /** * Test of Maps with non-String keys as TableMetaType/TableMetaValue. * Map uses MapCompositeMetaType(MetaValue). * * @author Adrian Brock * @author Scott.Stark@jboss.org * @version $Revision: 71085 $ */ public class MapMetaTypeFactoryUnitTestCase extends AbstractMetaTypeFactoryTest { /** * Create a testsuite for this test * * @return the testsuite */ public static Test suite() { return suite(MapMetaTypeFactoryUnitTestCase.class); } /** * Create a new MapMetaTypeFactoryUnitTestCase. * * @param name the test name */ public MapMetaTypeFactoryUnitTestCase(String name) { super(name); } /** * Signature method for a simple map * * @return the signature */ public Map simpleMap() { return null; } /** * Signature method for a map with a composite key * * @return the signature */ public Map compositeKeyMap() { return null; } /** * Signature method for a map with a composite value * * @return the signature */ public Map compositeValueMap() { return null; } /** * Test the correct meta type is generated for a simple map * * @throws Exception for any problem */ public void testSimpleMap() throws Exception { testMap("simpleMap", StringKey.class, Integer.class); } /** * Test the correct meta type is generated for a map with a composite key * * @throws Exception for any problem */ public void testCompositeKeyMap() throws Exception { testMap("compositeKeyMap", TestSimpleComposite.class, Integer.class); } /** * Test the correct meta type is generated for a map with a composite value * * @throws Exception for any problem */ public void testCompositeValueMap() throws Exception { testMap("compositeValueMap", StringKey.class, TestSimpleComposite.class); } /** * Test the correct meta type is generated for a map * * @param methodName the method name to lookup the connection signature * @param keyClass the expected key type * @param valueClass the expected value type * @throws Exception for any problem */ protected void testMap(String methodName, Type keyClass, Type valueClass) throws Exception { Method method = getClass().getMethod(methodName, (Class[]) null); Type collectionType = method.getGenericReturnType(); MetaType result = resolve(collectionType); TableMetaType actual = assertInstanceOf(result, TableMetaType.class); MetaType keyType = resolve(keyClass); MetaType valueType = resolve(valueClass); MetaType[] itemTypes = { keyType, valueType }; String entryName = Map.Entry.class.getName(); CompositeMetaType entryType = new ImmutableCompositeMetaType(entryName, entryName, DefaultMetaTypeFactory.MAP_ITEM_NAMES, DefaultMetaTypeFactory.MAP_ITEM_NAMES, itemTypes); TableMetaType expected = new ImmutableTableMetaType(Map.class.getName(), Map.class.getName(), entryType, DefaultMetaTypeFactory.MAP_INDEX_NAMES); testTable(expected, actual); } } ././@LongLink0000000000000000000000000000021700000000000011565 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/factory/test/SpecialMetaTypeFactoryUnitTestCase.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/factory/te0000644000175000017500000001107110761511660033323 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.types.factory.test; import junit.framework.Test; import org.jboss.metatype.api.types.CompositeMetaType; import org.jboss.metatype.api.types.GenericMetaType; import org.jboss.metatype.api.types.MetaType; import org.jboss.metatype.plugins.types.ClassMetaTypeBuilder; import org.jboss.metatype.plugins.types.MutableCompositeMetaType; import org.jboss.test.metatype.types.factory.support.TestGeneric; import org.jboss.test.metatype.types.factory.support.TestGenericComposite; import org.jboss.test.metatype.types.factory.support.TestOverrideComposite; import org.jboss.test.metatype.types.factory.support.TestOverrideCompositeBuilder; /** * SpecialMetaTypeFactoryUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class SpecialMetaTypeFactoryUnitTestCase extends AbstractMetaTypeFactoryTest { /** * Create a testsuite for this test * * @return the testsuite */ public static Test suite() { return suite(SpecialMetaTypeFactoryUnitTestCase.class); } /** * Create a new SpecialMetaTypeFactoryUnitTestCase. * * @param name the test name */ public SpecialMetaTypeFactoryUnitTestCase(String name) { super(name); } /** * Test the meta type is generated correctly for java.lang.Class * * @throws Exception for any problem */ public void testClass() throws Exception { MetaType actual = resolve(Class.class); getLog().debug("Class MetaType: " + " className=" + actual.getClassName() + " typeName=" + actual.getTypeName() + " description=" + actual.getDescription()); assertEquals(ClassMetaTypeBuilder.CLASS_META_TYPE, actual); } /** * Test the meta type is generated correctly for a generic type * * @throws Exception for any problem */ public void testGeneric() throws Exception { MetaType actual = resolve(TestGeneric.class); getLog().debug("Generic MetaType: " + " className=" + actual.getClassName() + " typeName=" + actual.getTypeName() + " description=" + actual.getDescription()); GenericMetaType expected = new GenericMetaType(TestGeneric.class.getName(), TestGeneric.class.getName()); assertEquals(expected, actual); } /** * Test the meta type is generated correctly for a generic composite * * @throws Exception for any problem */ public void testGenericComposite() throws Exception { MetaType actual = resolve(TestGenericComposite.class); printComposite("GenericComposite MetaType: ", assertInstanceOf(actual, CompositeMetaType.class)); MutableCompositeMetaType expected = new MutableCompositeMetaType(TestGenericComposite.class.getName(), TestGenericComposite.class.getName()); GenericMetaType generic = new GenericMetaType(TestGeneric.class.getName(), TestGeneric.class.getName()); expected.addItem("generic", "generic", generic); expected.freeze(); assertEquals(expected, actual); } /** * Test the meta type is generated correctly for a builder * * @throws Exception for any problem */ public void testBuilder() throws Exception { TestOverrideCompositeBuilder builder = new TestOverrideCompositeBuilder(); setBuilder(TestOverrideComposite.class, builder); try { MetaType expected = builder.buildMetaType(); MetaType actual = resolve(TestOverrideComposite.class); getLog().debug("Builder: " + actual); assertEquals(expected, actual); } finally { setBuilder(TestOverrideComposite.class, null); } } } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/factory/support/libjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/factory/su0000755000175000017500000000000011105402543033330 5ustar twernertwerner././@LongLink0000000000000000000000000000021000000000000011556 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/factory/support/TestIgnoredCompositeItem.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/factory/su0000644000175000017500000000372710757514543033363 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.types.factory.support; import org.jboss.metatype.api.annotations.CompositeKey; import org.jboss.metatype.api.annotations.CompositeValue; /** * TestIgnoredCompositeItem. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class TestIgnoredCompositeItem { /** The id */ private String id; /** The ignored */ private Object ignored; /** * Get the id * * @return the id */ @CompositeKey public String getId() { return id; } /** * Set the id * * @param id the id */ public void setId(String id) { this.id = id; } /** * Get the ignored. * * @return the ignored. */ public Object getIgnored() { return ignored; } /** * Set the ignored. * * @param ignored the ignored. */ @CompositeValue(ignore=true) public void setIgnored(Object ignored) { this.ignored = ignored; } } ././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/factory/support/TestGenericComposite.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/factory/su0000644000175000017500000000307510645072106033345 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.types.factory.support; /** * TestGenericComposite. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class TestGenericComposite { /** Generic property */ private TestGeneric generic; /** * Get the generic property * * @return the property */ public TestGeneric getGeneric() { return generic; } /** * Set the generic property * * @param generic the generic property */ public void setGeneric(TestGeneric generic) { this.generic = generic; } } ././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/factory/support/TestOverrideComposite.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/factory/su0000644000175000017500000000307210645072106033342 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.types.factory.support; /** * TestOverrideComposite. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class TestOverrideComposite { /** The something property */ private String something; /** * Get the something. * * @return the something. */ public String getSomething() { return something; } /** * Set the something. * * @param something the something. */ public void setSomething(String something) { this.something = something; } } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/factory/support/TestEnum.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/factory/su0000644000175000017500000000234710645072106033346 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.types.factory.support; /** * TestEnum. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public enum TestEnum { /** ONE */ ONE, /** TWO */ TWO, /** THREE */ THREE } ././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/factory/support/TestSimpleAnnotation.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/factory/su0000644000175000017500000000244510645072106033345 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.types.factory.support; /** * TestSimpleAnnotation. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public @interface TestSimpleAnnotation { /** * The something * * @return the something */ String something() default ""; } ././@LongLink0000000000000000000000000000021400000000000011562 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/factory/support/TestOverrideCompositeBuilder.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/factory/su0000644000175000017500000000337210761511660033347 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.types.factory.support; import org.jboss.metatype.api.types.MetaType; import org.jboss.metatype.api.types.SimpleMetaType; import org.jboss.metatype.plugins.types.MutableCompositeMetaType; import org.jboss.metatype.spi.types.MetaTypeBuilder; /** * TestOverrideCompositeBuilder. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class TestOverrideCompositeBuilder implements MetaTypeBuilder { public MetaType buildMetaType() { MutableCompositeMetaType result = new MutableCompositeMetaType(TestOverrideComposite.class.getName(), TestOverrideComposite.class.getName()); result.addItem("somethingElse", "somethingElse", SimpleMetaType.STRING); result.freeze(); return result; } } ././@LongLink0000000000000000000000000000020600000000000011563 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/factory/support/TestRecursiveComposite.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/factory/su0000644000175000017500000000406410645072106033344 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.types.factory.support; import org.jboss.metatype.api.annotations.CompositeKey; /** * TestRecursiveComposite. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class TestRecursiveComposite { /** The id */ private String id; /** The other */ private TestRecursiveComposite other; /** * Create a new TestRecursiveComposite. * * @param id the id */ public TestRecursiveComposite(String id) { this.id = id; } /** * Get the id * * @return the id */ @CompositeKey public String getId() { return id; } /** * Set the id * * @param id the id */ public void setId(String id) { this.id = id; } /** * Get the other. * * @return the other. */ public TestRecursiveComposite getOther() { return other; } /** * Set the other. * * @param other the other. */ public void setOther(TestRecursiveComposite other) { this.other = other; } } ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/factory/support/TestGeneric.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/factory/su0000644000175000017500000000234410645072106033343 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.types.factory.support; import org.jboss.metatype.api.annotations.Generic; /** * TestGeneric. * * @author Adrian Brock * @version $Revision: 1.1 $ */ @Generic public class TestGeneric { } ././@LongLink0000000000000000000000000000020300000000000011560 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/factory/support/TestSimpleComposite.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/factory/su0000644000175000017500000000305110645072106033337 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.types.factory.support; /** * TestSimpleComposite. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class TestSimpleComposite { /** The something */ private String something; /** * Get the something. * * @return the something. */ public String getSomething() { return something; } /** * Set the something. * * @param something the something. */ public void setSomething(String something) { this.something = something; } } ././@LongLink0000000000000000000000000000021000000000000011556 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/factory/support/TestRenamedCompositeItem.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/factory/su0000644000175000017500000000370210757514543033354 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.types.factory.support; import org.jboss.metatype.api.annotations.CompositeKey; import org.jboss.metatype.api.annotations.CompositeValue; /** * TestRenamedCompositeItem. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class TestRenamedCompositeItem { /** The id */ private String id; /** The renamed */ private String value; /** * Get the id * * @return the id */ @CompositeKey public String getId() { return id; } /** * Set the id * * @param id the id */ public void setId(String id) { this.id = id; } /** * Get the value. * * @return the value. */ public String getValue() { return value; } /** * Set the value. * * @param value the value. */ @CompositeValue(name="renamed") public void setValue(String value) { this.value = value; } } libjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/support/0000755000175000017500000000000011105402543033025 5ustar twernertwerner././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/support/MockCompositeValue.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/support/Mo0000644000175000017500000000456210645072106033340 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.types.support; import java.util.Collection; import org.jboss.metatype.api.types.CompositeMetaType; import org.jboss.metatype.api.values.CompositeValue; import org.jboss.metatype.api.values.MetaValue; /** * MockCompositeValue. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class MockCompositeValue extends MockMetaValue implements CompositeValue { /** The serialVersionUID */ private static final long serialVersionUID = 1L; /** * Create a new MockCompositeValue. * * @param metaType the meta type */ public MockCompositeValue(CompositeMetaType metaType) { super(metaType); } public CompositeMetaType getMetaType() { return (CompositeMetaType) super.getMetaType(); } public boolean containsKey(String key) { throw new org.jboss.util.NotImplementedException("containsKey"); } public boolean containsValue(MetaValue value) { throw new org.jboss.util.NotImplementedException("containsValue"); } public MetaValue get(String key) { throw new org.jboss.util.NotImplementedException("get"); } public MetaValue[] getAll(String[] keys) { throw new org.jboss.util.NotImplementedException("getAll"); } public Collection values() { throw new org.jboss.util.NotImplementedException("values"); } } ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/support/MockSimpleValue.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/support/Mo0000644000175000017500000000352610761511660033341 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.types.support; import java.io.Serializable; import org.jboss.metatype.api.types.SimpleMetaType; import org.jboss.metatype.api.values.SimpleValue; /** * MockSimpleValue. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class MockSimpleValue extends MockMetaValue implements SimpleValue { /** The serialVersionUID */ private static final long serialVersionUID = 1L; /** * Create a new MockSimpleValue. * * @param metaType the meta type */ public MockSimpleValue(SimpleMetaType metaType) { super(metaType); } @SuppressWarnings("unchecked") public SimpleMetaType getMetaType() { return (SimpleMetaType) super.getMetaType(); } public Serializable getValue() { throw new org.jboss.util.NotImplementedException("getValue"); } } ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/support/MockMetaType.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/support/Mo0000644000175000017500000000410410761511660033332 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.types.support; import org.jboss.metatype.api.types.AbstractMetaType; /** * MockMetaType. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class MockMetaType extends AbstractMetaType { private static final long serialVersionUID = -1; /** * Create a new MockMetaType. * * @param className the class name * @param typeName the type name * @param description the description */ public MockMetaType(String className, String typeName, String description) { super(className, typeName, description); } @Override public boolean equals(Object obj) { throw new org.jboss.util.NotImplementedException("equals"); } @Override public int hashCode() { throw new org.jboss.util.NotImplementedException("hashCode"); } @Override public boolean isValue(Object obj) { throw new org.jboss.util.NotImplementedException("isValue"); } @Override public String toString() { throw new org.jboss.util.NotImplementedException("toString"); } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/support/MockMetaValue.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/support/Mo0000644000175000017500000000354110761511660033336 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.types.support; import org.jboss.metatype.api.types.MetaType; import org.jboss.metatype.api.values.MetaValue; /** * MockMetaValue. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class MockMetaValue implements MetaValue { /** The serialVersionUID */ private static final long serialVersionUID = 1L; private MetaType metaType; /** * Create a new MockMetaValue. * * @param metaType the meta type */ public MockMetaValue(MetaType metaType) { this.metaType = metaType; } public MetaType getMetaType() { return metaType; } public MetaValue clone() { try { return (MockMetaValue) super.clone(); } catch (CloneNotSupportedException e) { throw new Error("unexpected", e); } } } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/support/MockTableValue.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/types/support/Mo0000644000175000017500000000635110645072106033336 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype.types.support; import java.util.Collection; import java.util.List; import java.util.Set; import org.jboss.metatype.api.types.TableMetaType; import org.jboss.metatype.api.values.CompositeValue; import org.jboss.metatype.api.values.MetaValue; import org.jboss.metatype.api.values.TableValue; /** * MockTableValue. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class MockTableValue extends MockMetaValue implements TableValue { /** The serialVersionUID */ private static final long serialVersionUID = 1L; /** * Create a new MockTableValue. * * @param metaType the meta type */ public MockTableValue(TableMetaType metaType) { super(metaType); } public TableMetaType getMetaType() { return (TableMetaType) super.getMetaType(); } public MetaValue[] calculateIndex(CompositeValue value) { throw new org.jboss.util.NotImplementedException("calculateIndex"); } public void clear() { throw new org.jboss.util.NotImplementedException("clear"); } public boolean containsKey(MetaValue[] key) { throw new org.jboss.util.NotImplementedException("containsKey"); } public boolean containsValue(CompositeValue value) { throw new org.jboss.util.NotImplementedException("containsValue"); } public CompositeValue get(MetaValue[] key) { throw new org.jboss.util.NotImplementedException("get"); } public boolean isEmpty() { throw new org.jboss.util.NotImplementedException("isEmpty"); } public Set> keySet() { throw new org.jboss.util.NotImplementedException("keySet"); } public void put(CompositeValue value) { throw new org.jboss.util.NotImplementedException("put"); } public void putAll(CompositeValue[] values) { throw new org.jboss.util.NotImplementedException("putAll"); } public CompositeValue remove(MetaValue[] key) { throw new org.jboss.util.NotImplementedException("remove"); } public int size() { throw new org.jboss.util.NotImplementedException("size"); } public Collection values() { throw new org.jboss.util.NotImplementedException("values"); } } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/MetaTypeAllTestSuite.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/MetaTypeAllTestS0000644000175000017500000000416710645072106033252 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2005, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype; import org.jboss.test.metatype.types.factory.test.TypesFactoryTestSuite; import org.jboss.test.metatype.types.test.TypesTestSuite; import org.jboss.test.metatype.values.factory.test.ValuesFactoryTestSuite; import org.jboss.test.metatype.values.test.ValuesTestSuite; import junit.framework.Test; import junit.framework.TestSuite; import junit.textui.TestRunner; /** * MetaType All Test Suite. * * @author Adrian Brock * @version $Revision: 37459 $ */ public class MetaTypeAllTestSuite extends TestSuite { /** * For running the testsuite from the command line * * @param args the command line args */ public static void main(String[] args) { TestRunner.run(suite()); } /** * Create the testsuite * * @return the testsuite */ public static Test suite() { TestSuite suite = new TestSuite("MetaType All Tests"); suite.addTest(TypesTestSuite.suite()); suite.addTest(TypesFactoryTestSuite.suite()); suite.addTest(ValuesTestSuite.suite()); suite.addTest(ValuesFactoryTestSuite.suite()); return suite; } } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/AbstractMetaTypeTest.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/test/java/org/jboss/test/metatype/AbstractMetaType0000644000175000017500000002171610761511660033323 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metatype; import java.util.HashMap; import java.util.Map; import org.jboss.metatype.api.types.ArrayMetaType; import org.jboss.metatype.api.types.CompositeMetaType; import org.jboss.metatype.api.types.ImmutableCompositeMetaType; import org.jboss.metatype.api.types.MetaType; import org.jboss.metatype.api.types.SimpleMetaType; import org.jboss.metatype.api.types.TableMetaType; import org.jboss.metatype.api.types.CollectionMetaType; import org.jboss.metatype.api.values.MetaValue; import org.jboss.metatype.api.values.SimpleValue; import org.jboss.metatype.api.values.SimpleValueSupport; import org.jboss.test.BaseTestCase; /** * AbstractMetaTypeTest. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public abstract class AbstractMetaTypeTest extends BaseTestCase { /** * Create a new AbstractMetaTypeTest. * * @param name the test name */ public AbstractMetaTypeTest(String name) { super(name); } /** * Initialise string value 1 * * @return the value */ protected SimpleValue initStringValue1() { return SimpleValueSupport.wrap("value1"); } /** * Initialise string value 2 * * @return the value */ protected SimpleValue initStringValue2() { return SimpleValueSupport.wrap("value2"); } /** * Initialise string name 1 * * @return the name */ protected SimpleValue initStringName1() { return SimpleValueSupport.wrap("name1"); } /** * Initialise the empty string * * @return the empty string */ protected SimpleValue initStringEmpty() { return SimpleValueSupport.wrap(""); } /** * Initialise the null string * * @return the null string */ protected SimpleValue initStringNull() { return new SimpleValueSupport(SimpleMetaType.STRING, null); } /** * Initialise the wrong string * * @return the wrong string */ protected SimpleValue initStringWrong() { return SimpleValueSupport.wrap("wrong"); } /** * Initialise the integer 2 * * @return the value */ protected SimpleValue initInteger2() { return SimpleValueSupport.wrap(new Integer(2)); } /** * Initialise the integer 3 * * @return the value */ protected SimpleValue initInteger3() { return SimpleValueSupport.wrap(new Integer(3)); } /** * Initialise the integer 4 * * @return the value */ protected SimpleValue initInteger4() { return SimpleValueSupport.wrap(new Integer(4)); } /** * Initialise the null integer * * @return the value */ protected SimpleValue initIntegerNull() { return new SimpleValueSupport(SimpleMetaType.INTEGER, null); } /** * Initialise map values * * @return the value */ protected Map initMapValues() { Map map = new HashMap(); map.put("name1", initStringValue1()); map.put("name2", initInteger2()); return map; } /** * Initialise map values 2 * * @return the value */ protected Map initMapValues2() { Map map = new HashMap(); map.put("name1", initStringValue1()); map.put("name2", initInteger3()); return map; } /** * Initialise map values 3 * * @return the value */ protected Map initMapValues3() { Map map = new HashMap(); map.put("name1", initStringValue2()); map.put("name2", initInteger3()); return map; } /** * Initialise map values 4 * * @return the value */ protected Map initMapValues4() { Map map = new HashMap(); map.put("name1", initStringValue1()); map.put("name2", initInteger4()); return map; } /** * Initialise map keys * * @return the keys */ protected String[] initKeys() { return new String[] { "name1", "name2" }; } /** * Initialise map values * * @return the values */ protected MetaValue[] initValues() { return new MetaValue[] { initStringValue1(), initInteger2() }; } /** * Initialise map values 2 * * @return the values */ protected MetaValue[] initValues2() { return new MetaValue[] { initStringValue1(), initInteger3() }; } /** * Initialise map values 4 * * @return the values */ protected MetaValue[] initValues4() { return new MetaValue[] { initStringValue1(), initInteger4() }; } /** * Initialise a composite meta type * * @return the type */ protected CompositeMetaType initCompositeMetaType() { String[] itemNames = new String[] { "name1", "name2" }; String[] itemDescriptions = new String[] { "desc1", "desc2" }; MetaType[] itemTypes = new MetaType[] { SimpleMetaType.STRING, SimpleMetaType.INTEGER }; CompositeMetaType compositeMetaType = new ImmutableCompositeMetaType("typeName", "description", itemNames, itemDescriptions, itemTypes); return compositeMetaType; } /** * Initialise a composite meta type 2 * * @return the type */ protected CompositeMetaType initCompositeMetaType2() { String[] itemNames = new String[] { "name1", "name2" }; String[] itemDescriptions = new String[] { "desc1", "desc2" }; MetaType[] itemTypes = new MetaType[] { SimpleMetaType.STRING, SimpleMetaType.INTEGER }; CompositeMetaType compositeMetaType = new ImmutableCompositeMetaType("typeName2", "description", itemNames, itemDescriptions, itemTypes); return compositeMetaType; } /** * Print a composite type * * @param context the context * @param type the type */ protected void printComposite(String context, CompositeMetaType type) { getLog().debug(context + " className=" + type.getClassName() + " typeName=" + type.getTypeName() + " description=" + type.getDescription() + " keys=" + type.keySet() + " items=" + type.itemSet()); } /** * Test an array type * * @param expected the expected * @param actual the actual * @throws Exception for any problem */ protected void testArray(ArrayMetaType expected, ArrayMetaType actual) throws Exception { getLog().debug("Array MetaType: className=" + actual.getClassName() + " typeName=" + actual.getTypeName() + " description=" + actual.getDescription() + " dim=" + actual.getDimension()); assertEquals(expected, actual); } /** * Test an array type * * @param expected the expected * @param actual the actual * @throws Exception for any problem */ protected void testCollection(CollectionMetaType expected, CollectionMetaType actual) throws Exception { getLog().debug("Collection MetaType: className=" + actual.getClassName() + " typeName=" + actual.getTypeName() + " description=" + actual.getDescription()); assertEquals(expected, actual); } /** * Test a table type * * @param expected the expected * @param actual the actual * @throws Exception for any problem */ protected void testTable(TableMetaType expected, TableMetaType actual) throws Exception { getLog().debug("Table MetaType: className=" + actual.getClassName() + " typeName=" + actual.getTypeName() + " description=" + actual.getDescription() + " index=" + actual.getIndexNames() + " row=" + actual.getRowType()); assertEquals(expected, actual); } /** * Test a composite type * * @param expected the expected * @param actual the actual * @throws Exception for any problem */ protected void testComposite(CompositeMetaType expected, CompositeMetaType actual) throws Exception { printComposite("Composite MetaType", actual); assertEquals(expected, actual); } } libjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/0000755000175000017500000000000011105402543022453 5ustar twernertwernerlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/0000755000175000017500000000000011105402543023374 5ustar twernertwernerlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/0000755000175000017500000000000011105402543024163 5ustar twernertwernerlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/0000755000175000017500000000000011105402543025303 5ustar twernertwernerlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/0000755000175000017500000000000011105402544027134 5ustar twernertwernerlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/plugins/0000755000175000017500000000000011105402543030614 5ustar twernertwernerlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/plugins/values/0000755000175000017500000000000011105402543032113 5ustar twernertwerner././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/plugins/values/SortedSetInstanceFactory.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/plugins/values/Sorted0000644000175000017500000000324310756363227033320 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.metatype.plugins.values; import java.util.SortedSet; import java.util.TreeSet; import org.jboss.beans.info.spi.BeanInfo; import org.jboss.metatype.api.values.InstanceFactory; /** * Sorted set instance factory. * * @author Ales Justin */ @SuppressWarnings("unchecked") public class SortedSetInstanceFactory implements InstanceFactory { public static SortedSetInstanceFactory INSTANCE = new SortedSetInstanceFactory(); private SortedSetInstanceFactory() { } public SortedSet instantiate(BeanInfo beanInfo) throws Throwable { return new TreeSet(); } } ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/plugins/values/DefaultMetaValueFactory.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/plugins/values/Defaul0000644000175000017500000010272311060015302033234 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.metatype.plugins.values; import java.io.Serializable; import java.lang.ref.WeakReference; import java.lang.reflect.Array; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Proxy; import java.lang.reflect.Type; import java.lang.reflect.UndeclaredThrowableException; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.Collection; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; import java.util.SortedSet; import java.util.Stack; import java.util.WeakHashMap; import java.util.Map.Entry; import org.jboss.beans.info.spi.BeanInfo; import org.jboss.beans.info.spi.PropertyInfo; import org.jboss.config.plugins.property.PropertyConfiguration; import org.jboss.config.spi.Configuration; import org.jboss.metatype.api.types.ArrayMetaType; import org.jboss.metatype.api.types.CollectionMetaType; import org.jboss.metatype.api.types.CompositeMetaType; import org.jboss.metatype.api.types.EnumMetaType; import org.jboss.metatype.api.types.GenericMetaType; import org.jboss.metatype.api.types.MapCompositeMetaType; import org.jboss.metatype.api.types.MetaType; import org.jboss.metatype.api.types.MetaTypeFactory; import org.jboss.metatype.api.types.SimpleMetaType; import org.jboss.metatype.api.types.TableMetaType; import org.jboss.metatype.api.values.ArrayValue; import org.jboss.metatype.api.values.ArrayValueSupport; import org.jboss.metatype.api.values.CollectionValue; import org.jboss.metatype.api.values.CollectionValueSupport; import org.jboss.metatype.api.values.CompositeValue; import org.jboss.metatype.api.values.CompositeValueSupport; import org.jboss.metatype.api.values.EnumValue; import org.jboss.metatype.api.values.EnumValueSupport; import org.jboss.metatype.api.values.GenericValue; import org.jboss.metatype.api.values.GenericValueSupport; import org.jboss.metatype.api.values.InstanceFactory; import org.jboss.metatype.api.values.MapCompositeValueSupport; import org.jboss.metatype.api.values.MetaValue; import org.jboss.metatype.api.values.MetaValueFactory; import org.jboss.metatype.api.values.SimpleValue; import org.jboss.metatype.api.values.SimpleValueSupport; import org.jboss.metatype.api.values.TableValue; import org.jboss.metatype.api.values.TableValueSupport; import org.jboss.metatype.plugins.types.DefaultMetaTypeFactory; import org.jboss.metatype.spi.values.MetaMapper; import org.jboss.metatype.spi.values.MetaValueBuilder; import org.jboss.reflect.plugins.introspection.ParameterizedClassInfo; import org.jboss.reflect.spi.ArrayInfo; import org.jboss.reflect.spi.ClassInfo; import org.jboss.reflect.spi.TypeInfo; import org.jboss.reflect.spi.TypeInfoFactory; /** * DefaultMetaValueFactory. * * @author Ales Justin * @author Adrian Brock * @version $Revision: 1.1 $ */ public class DefaultMetaValueFactory extends MetaValueFactory { /** The metatype factory */ private MetaTypeFactory metaTypeFactory = MetaTypeFactory.getInstance(); /** The configuration */ private static Configuration configuration; static { configuration = AccessController.doPrivileged(new PrivilegedAction() { public Configuration run() { return new PropertyConfiguration(); } }); } /** The thread local stack of objects mapped to meta values */ private ThreadLocal>> mappingStack = new ThreadLocal>>() { protected Stack> initialValue() { return new Stack>(); } }; /** The builders */ private Map, WeakReference>> builders = new WeakHashMap, WeakReference>>(); /** The Object type info */ private static final TypeInfo OBJECT_TYPE_INFO = configuration.getTypeInfo(Object.class); /** The instance factory builders */ private Map, InstanceFactory> instanceFactoryMap = new WeakHashMap, InstanceFactory>(); public DefaultMetaValueFactory() { // set default collection instance factories setInstanceFactory(List.class, ListInstanceFactory.INSTANCE); setInstanceFactory(Set.class, SetInstanceFactory.INSTANCE); setInstanceFactory(SortedSet.class, SortedSetInstanceFactory.INSTANCE); } public void setBuilder(Class clazz, MetaValueBuilder builder) { synchronized (builders) { if (builder == null) builders.remove(clazz); builders.put(clazz, new WeakReference>(builder)); } } public void setInstanceFactory(Class clazz, InstanceFactory factory) { synchronized(instanceFactoryMap) { if (factory == null) instanceFactoryMap.remove(clazz); else instanceFactoryMap.put(clazz, factory); } } /** * Create a simple value * * @param type the type * @param value the value * @return the simple value */ public static SimpleValue createSimpleValue(SimpleMetaType type, Serializable value) { if (value == null) return null; return new SimpleValueSupport(type, value); } /** * Create an enum value * * @param the enum type * @param type the type * @param value the value * @return the enum value */ public static > EnumValue createEnumValue(EnumMetaType type, T value) { if (value == null) return null; return new EnumValueSupport(type, value.name()); } /** * Create a generic value * * @param type the type * @param value the value * @param mapping the mapping * @return the generic value */ public static GenericValue createGenericValue(GenericMetaType type, Object value, Map mapping) { if (value == null) return null; if (value instanceof Serializable == false) throw new IllegalArgumentException("Not serializable: " + value.getClass().getName()); GenericValue result = new GenericValueSupport(type, (Serializable) value); mapping.put(value, result); return result; } /** * Create a collection value * * @param type the type * @param value the value * @param mapping the mapping * @return the generic value */ public CollectionValue createCollectionValue(CollectionMetaType type, Object value, Map mapping) { if (value == null) return null; Collection collection = (Collection)value; MetaValue[] elements = new MetaValue[collection.size()]; int i = 0; for(Object ce : collection) { // recalculate element info, since usually more deterministic TypeInfo typeInfo = configuration.getTypeInfo(ce.getClass()); MetaType metaType = metaTypeFactory.resolve(typeInfo); elements[i++] = internalCreate(ce, typeInfo, metaType); } CollectionValue result = new CollectionValueSupport(type, elements); mapping.put(value, result); return result; } /** * Transform a primitive array into an Object[]. Converts * a primitive array like char[] to Object[]. * * @param type - the primitive array class type info. * @param value - the primitive array instance. * @return object array */ public static Object[] convertPrimativeArray(TypeInfo type, Object value) { if (value == null) return null; Object[] oa; if( type instanceof ArrayInfo ) { // Get the Object form of the element ArrayInfo arrayInfo = ArrayInfo.class.cast(type); TypeInfo etype = arrayInfo.getComponentType(); int size = Array.getLength(value); oa = new Object[size]; for(int n = 0; n < size; n ++) { Object nvalue = Array.get(value, n); // Recursively convert nested array elements if (etype.isArray()) { oa[n] = convertPrimativeArray(etype, nvalue); } oa[n] = nvalue; } } else { oa = (Object[]) value; } return oa; } /** * Transform a primitive array into an Object[]. Converts * a primitive array like char[] to Object[]. * * @param value - the primitive array instance. * @return object array */ public static Object[] convertPrimativeArray(Object value) { if (value == null) return null; return convertPrimativeArray(configuration.getTypeInfo(value.getClass()), value); } /** * Create an array value * * @param type the type * @param value the value * @param mapping the mapping * @return the composite value */ @SuppressWarnings("unchecked") public ArrayValue createArrayValue(ArrayMetaType type, Object value, Map mapping) { if (value == null) return null; ArrayValueSupport result = new ArrayValueSupport(type); mapping.put(value, result); Object[] array; MetaType elementType = type.getElementType(); int dimension = type.getDimension(); Object[] oldArray; Class componentType; try { componentType = Class.forName(type.getClassName()); } catch (Exception e) { throw new RuntimeException("Unable to determine component type for " + type, e); } ClassInfo classInfo = configuration.getClassInfo(value.getClass()); if (classInfo.isArray()) { // See if this is a primitive array ArrayInfo arrayInfo = ArrayInfo.class.cast(classInfo); TypeInfo compInfo = arrayInfo.getComponentType(); while(compInfo instanceof ArrayInfo) { arrayInfo = ArrayInfo.class.cast(compInfo); compInfo = arrayInfo.getComponentType(); } // Translate if (compInfo.isPrimitive()) oldArray = convertPrimativeArray(classInfo, value); else oldArray = (Object[]) value; } else throw new UnsupportedOperationException("Cannot construct array for " + value.getClass()); array = createArray(elementType, componentType.getComponentType(), dimension, oldArray); result.setValue(array); return result; } /** * Create an array * * @param elementType the element type * @param componentType the component type * @param dimension the dimension * @param oldArray the old array * @return the array */ protected Object[] createArray(MetaType elementType, Class componentType, int dimension, Object[] oldArray) { if (oldArray == null) return null; Object[] newArray = new Object[oldArray.length]; if (dimension > 1) { Object[] nestedOld; for (int i = 0; i < oldArray.length; ++i) { if ( !(oldArray[i] instanceof Object[]) ) nestedOld = convertPrimativeArray(oldArray[i]); else nestedOld = (Object[]) oldArray[i]; Object[] result = createArray(elementType, componentType.getComponentType(), dimension-1, nestedOld); newArray[i] = result; } } else { for (int i = 0; i < oldArray.length; ++i) newArray[i] = internalCreate(oldArray[i], null, elementType); } return newArray; } /** * Create a composite value * * @param type the type * @param value the value * @param mapping the mapping * @return the composite value */ @SuppressWarnings("unchecked") public CompositeValue createCompositeValue(CompositeMetaType type, Object value, Map mapping) { if (value == null) return null; // See if this is a Map type if(type instanceof MapCompositeMetaType) { if((value instanceof Map) == false) throw new RuntimeException("Expected Map value for: " + type+", was: "+(value != null ? value.getClass() : "null")); Map map = (Map) value; MapCompositeMetaType mapType = (MapCompositeMetaType) type; MetaType mapValueType = mapType.getValueType(); MapCompositeValueSupport result = new MapCompositeValueSupport(mapValueType); for(Entry entry : map.entrySet()) { Object entryValue = entry.getValue(); MetaValue entryMetaValue = internalCreate(entryValue, null, mapValueType); result.put(entry.getKey(), entryMetaValue); } mapping.put(value, result); return result; } CompositeValueSupport result = new CompositeValueSupport(type); mapping.put(value, result); BeanInfo beanInfo; try { ClassLoader cl = value.getClass().getClassLoader(); if (cl == null) beanInfo = configuration.getBeanInfo(value.getClass()); else beanInfo = configuration.getBeanInfo(type.getTypeName(), cl); } catch (Exception e) { throw new RuntimeException("Error retrieving BeanInfo for " + type, e); } for (String name : type.itemSet()) { MetaType itemType = type.getType(name); Object itemValue; try { itemValue = beanInfo.getProperty(value, name); } catch (RuntimeException e) { throw e; } catch (Error e) { throw e; } catch (Throwable t) { throw new RuntimeException("Error getting property: " + name + " for " + value.getClass(), t); } MetaValue item = internalCreate(itemValue, null, itemType); result.set(name, item); } return result; } /** * Create a table value * * @param type the type * @param value the value * @param mapping the mapping * @return the table value */ @SuppressWarnings("unchecked") public TableValue createTableValue(TableMetaType type, Map value, Map mapping) { if (value == null) return null; TableValueSupport table = new TableValueSupport(type); mapping.put(value, table); CompositeMetaType entryType = type.getRowType(); MetaType keyType = entryType.getType(DefaultMetaTypeFactory.MAP_KEY); MetaType valType = entryType.getType(DefaultMetaTypeFactory.MAP_VALUE); for (Iterator i = value.entrySet().iterator(); i.hasNext();) { Map.Entry entry = i.next(); MetaValue key = internalCreate(entry.getKey(), null, keyType); MetaValue val = internalCreate(entry.getValue(), null, valType); CompositeValueSupport data = new CompositeValueSupport(entryType, DefaultMetaTypeFactory.MAP_ITEM_NAMES, new MetaValue[] { key, val }); table.put(data); } return table; } @Override public MetaValue create(Object value) { return internalCreate(value, null, null); } @Override public MetaValue create(Object value, Type type) { TypeInfo typeInfo = configuration.getTypeInfo(type); return internalCreate(value, typeInfo, null); } @Override public MetaValue create(Object value, TypeInfo type) { return internalCreate(value, type, null); } @Override public Object unwrap(MetaValue metaValue) { return internalUnwrap(metaValue, null); } @Override public Object unwrap(MetaValue metaValue, Type type) { TypeInfo typeInfo = configuration.getTypeInfo(type); return internalUnwrap(metaValue, typeInfo); } @Override public Object unwrap(MetaValue metaValue, TypeInfo type) { return internalUnwrap(metaValue, type); } /** * Unwrap value from meta value. * * @param metaValue the meta value * @param type expected type info * @return unwrapped value */ protected Object internalUnwrap(MetaValue metaValue, TypeInfo type) { if (metaValue == null) return null; MetaMapper mapper = MetaMapper.getMetaMapper(type); if (mapper != null) return mapper.unwrapMetaValue(metaValue); MetaType metaType = metaValue.getMetaType(); if (metaType.isSimple()) { Serializable value = ((SimpleValue)metaValue).getValue(); return getValue(metaType, type, value); } else if (metaType.isEnum()) { String value = ((EnumValue)metaValue).getValue(); return getValue(metaType, type, value); } else if (metaType.isGeneric()) { Serializable value = ((GenericValue)metaValue).getValue(); return getValue(metaType, type, value); } else if (metaType.isArray()) { ArrayValue arrayValue = (ArrayValue)metaValue; if (type == null) type= getTypeInfo(metaType, arrayValue.getValue()); Object array = newArrayInstance(type, arrayValue.getLength()); for (int i = 0; i < Array.getLength(array); i++) { Object element = arrayValue.getValue(i); if (element instanceof MetaValue) element = unwrapMetaValue((MetaValue)element, type, array); else if (element != null && element.getClass().isArray()) element = unwrapArray(array, element); Array.set(array, i, element); } return array; } else if (metaType.isComposite()) { CompositeValue compositeValue = (CompositeValue)metaValue; return unwrapComposite(compositeValue, type); } else if (metaType.isCollection()) { CollectionValue collectionValue = (CollectionValue)metaValue; return unwrapCollection(collectionValue, type); } else if (metaType.isTable()) { TableValue tableValue = (TableValue)metaValue; return unwrapTable(tableValue, type); } throw new IllegalArgumentException("Unsupported meta value: " + metaValue); } /** * Do a simple check. * If current type param is null, * try getting type info from meta type * and value's classloader. * * @param type the type info * @param value tester value * @param metaType the meta type * @return type info */ protected TypeInfo checkTypeInfo(TypeInfo type, Object value, MetaType metaType) { if (type == null && value != null) type = getTypeInfo(metaType, value); return type; } /** * Get the value. * Join type check and value conversion. * * @param metaType the meta type * @param typeInfo the type info * @param value the value * @return the converted value */ protected Object getValue(MetaType metaType, TypeInfo typeInfo, Object value) { typeInfo = checkTypeInfo(typeInfo, value, metaType); return convertValue(value, typeInfo); } /** * Unwrap MetaValue. * * @param element the meta value * @param type parent type * @param array parent array * @return unwrapped value */ protected Object unwrapMetaValue(MetaValue element, TypeInfo type, Object array) { TypeInfo elementType; if (type instanceof ClassInfo) elementType = ((ClassInfo)type).getComponentType(); else elementType = getTypeInfo(element.getMetaType(), array); return unwrap(element, elementType); } /** * Unwrap array. * @param array parent array * @param element current array element * @return unwrapped array element */ protected Object unwrapArray(Object array, Object element) { TypeInfo elementType = configuration.getTypeInfo(array.getClass().getComponentType()); int subSize = Array.getLength(element); Object newElement = newArrayInstance(elementType, subSize); for(int i = 0; i < subSize; i++) { Object subElement = Array.get(element, i); if (subElement instanceof MetaValue) subElement = unwrapMetaValue((MetaValue)subElement, elementType, newElement); if (subElement != null && subElement.getClass().isArray()) subElement = unwrapArray(newElement, subElement); Array.set(newElement, i, subElement); } return newElement; } /** * Unwrap composite. * * @param compositeValue the composite value * @param typeInfo expected type info * @return unwrapped value */ @SuppressWarnings("deprecation") protected Object unwrapComposite(CompositeValue compositeValue, TypeInfo typeInfo) { CompositeMetaType compositeMetaType = compositeValue.getMetaType(); String typeName = compositeMetaType.getTypeName(); ClassLoader cl; if (typeInfo != null) cl = typeInfo.getType().getClassLoader(); else cl = Thread.currentThread().getContextClassLoader(); try { BeanInfo beanInfo = configuration.getBeanInfo(typeName, cl); ClassInfo classInfo = beanInfo.getClassInfo(); if (classInfo.isInterface()) { InvocationHandler handler = createCompositeValueInvocationHandler(compositeValue); Class clazz = classInfo.getType(); Class[] interfaces = new Class[]{clazz}; return Proxy.newProxyInstance(clazz.getClassLoader(), interfaces, handler); } Object bean = createNewInstance(beanInfo); for (String name : compositeMetaType.itemSet()) { MetaValue itemValue = compositeValue.get(name); PropertyInfo propertyInfo = beanInfo.getProperty(name); Object value = unwrap(itemValue, propertyInfo.getType()); propertyInfo.set(bean, value); } return bean; } catch (Throwable t) { throw new UndeclaredThrowableException(t); } } /** * Create composite invocation handler. * * @param compositeValue the composite value * @return composite invocation handler */ protected InvocationHandler createCompositeValueInvocationHandler(CompositeValue compositeValue) { return new CompositeValueInvocationHandler(compositeValue); } /** * Unwrap collection meta value. * * @param collectionValue the collection value * @param type the type info * @return unwrapped collection */ @SuppressWarnings("unchecked") protected Object unwrapCollection(CollectionValue collectionValue, TypeInfo type) { try { BeanInfo collectionInfo; // null is not instance of if (type instanceof ClassInfo) { collectionInfo = configuration.getBeanInfo(type); } else { MetaType metaType = collectionValue.getMetaType(); collectionInfo = configuration.getBeanInfo(metaType.getTypeName(), Thread.currentThread().getContextClassLoader()); } ClassInfo classInfo = collectionInfo.getClassInfo(); Collection collection = (Collection)createNewInstance(collectionInfo); Iterator iter = collectionValue.iterator(); while (iter.hasNext()) { MetaValue metaValue = iter.next(); TypeInfo componentType = classInfo.getComponentType(); // try better if (OBJECT_TYPE_INFO.equals(componentType)) componentType = getTypeInfo(metaValue.getMetaType(), null); collection.add(unwrap(metaValue, componentType)); } return collection; } catch (Throwable t) { throw new UndeclaredThrowableException(t); } } /** * Unwrap table meta value. * * @param tableValue the table value * @param type the type info * @return unwrapped table (map) */ @SuppressWarnings("deprecation") protected Object unwrapTable(TableValue tableValue, TypeInfo type) { if (type instanceof ParameterizedClassInfo) { ParameterizedClassInfo parameterizedType = (ParameterizedClassInfo)type; ClassInfo rawType = parameterizedType.getRawType(); if (Map.class.isAssignableFrom(rawType.getType())) { TypeInfo keyType = parameterizedType.getActualTypeArguments()[0]; TypeInfo valueType = parameterizedType.getActualTypeArguments()[1]; return createMap(tableValue, keyType, valueType); } } throw new UnsupportedOperationException("Insufficient information to unwrap table: " + tableValue + ", " + type); } /** * Create a map * * @param tableValue the table value * @param keyType the key type * @param valueType the value type * @return the map */ protected Map createMap(TableValue tableValue, TypeInfo keyType, TypeInfo valueType) { if (tableValue == null) return null; Map result = new HashMap(); Collection values = tableValue.values(); for (CompositeValue entry : values) { Object key = unwrap(entry.get(DefaultMetaTypeFactory.MAP_KEY), keyType); Object val = unwrap(entry.get(DefaultMetaTypeFactory.MAP_VALUE), valueType); result.put(key, val); } return result; } /** * Create new instance. * * @param beanInfo the bean info * @return new instance * @throws Throwable for any error */ @SuppressWarnings("deprecation") protected Object createNewInstance(BeanInfo beanInfo) throws Throwable { ClassInfo classInfo = beanInfo.getClassInfo(); if (classInfo.isInterface()) { InstanceFactory instanceFactory = instanceFactoryMap.get(classInfo.getType()); if (instanceFactory == null) throw new IllegalArgumentException("Cannot instantiate interface BeanInfo, missing InstanceFactory: " + classInfo); return instanceFactory.instantiate(beanInfo); } return beanInfo.newInstance(); } /** * Get new array instance. * * @param typeInfo the type info * @param size the size * @return new array instance */ protected Object newArrayInstance(TypeInfo typeInfo, int size) { if (typeInfo == null) throw new IllegalArgumentException("Null type info."); try { return typeInfo.newArrayInstance(size); } catch (Throwable t) { throw new UndeclaredThrowableException(t); } } /** * Get the class info from meta type. * * @param metaType the meta type * @param value the value which can provide classloader * @return type info */ protected TypeInfo getTypeInfo(MetaType metaType, Object value) { if (metaType == null) throw new IllegalArgumentException("Null meta type, cannot determine class name."); if (value == null) throw new IllegalArgumentException("Null value, cannot determine classloader."); // get the classloader from the array we plan to fill ClassLoader cl = value.getClass().getClassLoader(); return getTypeInfo(metaType, cl); } /** * Get the class info from meta type. * * @param metaType the meta type * @param cl the classloader * @return class info */ protected TypeInfo getTypeInfo(MetaType metaType, ClassLoader cl) { if (cl == null) cl = Thread.currentThread().getContextClassLoader(); try { TypeInfoFactory tif = configuration.getTypeInfoFactory(); if (metaType.isArray()) { ArrayMetaType arrayMetaType = (ArrayMetaType)metaType; MetaType elementMetaType = arrayMetaType.getElementType(); String elementTypeName = elementMetaType.getTypeName(); if (arrayMetaType.isPrimitiveArray()) elementTypeName = ArrayMetaType.getPrimitiveName(elementTypeName); TypeInfo elementTypeInfo = tif.getTypeInfo(elementTypeName, cl); int dimension = arrayMetaType.getDimension() - 1; // minus 1, since we already use first in next line TypeInfo typeInfo = elementTypeInfo.getArrayType(); while(dimension > 0) { typeInfo = typeInfo.getArrayType(); dimension--; } return typeInfo; } return tif.getTypeInfo(metaType.getTypeName(), cl); } catch (ClassNotFoundException e) { throw new UndeclaredThrowableException(e); } } /** * Create a meta value from the object * * @param value the value * @param type the type * @param metaType the metaType * @return the meta value */ @SuppressWarnings("unchecked") protected MetaValue internalCreate(Object value, TypeInfo type, MetaType metaType) { if (value == null) return null; if (type == null) type = configuration.getTypeInfo(value.getClass()); value = convertValue(value, type); boolean start = false; if (metaType == null) { start = true; metaType = metaTypeFactory.resolve(type); } // For more complicated values we need to keep a mapping of objects to meta values // this avoids duplicate meta value construction and recursion Map mapping; if (start) { // This is the start of the mapping mapping = new HashMap(); mappingStack.get().push(mapping); } else { // Check the existing mapping mapping = mappingStack.get().peek(); MetaValue result = mapping.get(value); // Seen this before if (result != null) return result; } try { MetaValue result = isBuilder(metaType, type, value, mapping); if (result == null) { MetaMapper mapper = (MetaMapper) MetaMapper.getMetaMapper(type); if (mapper != null) result = mapper.createMetaValue(metaType, value); } if (result == null) { if (metaType.isSimple()) result = createSimpleValue((SimpleMetaType) metaType, (Serializable) value); else if (metaType.isEnum()) result = createEnumValue((EnumMetaType) metaType, (Enum) value); else if (metaType.isArray()) result = createArrayValue((ArrayMetaType) metaType, value, mapping); else if (metaType.isComposite()) result = createCompositeValue((CompositeMetaType) metaType, value, mapping); else if (metaType.isTable()) result = createTableValue((TableMetaType) metaType, (Map) value, mapping); else if (metaType.isGeneric()) result = createGenericValue((GenericMetaType) metaType, value, mapping); else if (metaType.isCollection()) result = createCollectionValue((CollectionMetaType) metaType, value, mapping); else throw new IllegalStateException("Unknown metaType: " + metaType); } return result; } finally { // Remove the mapping from the stack if (start) mappingStack.get().pop(); } } /** * Convert the value. * * @param value the value * @param typeInfo type info * @return converted value if type info not null * @throws UndeclaredThrowableException for any error */ protected Object convertValue(Object value, TypeInfo typeInfo) { try { return typeInfo != null ? typeInfo.convertValue(value) : value; } catch (Throwable t) { throw new UndeclaredThrowableException(t); } } /** * Check for a builder * * @param metaType the meta type * @param type the type * @param value the value * @param mapping the mappings * @return the meta value */ @SuppressWarnings({"unchecked", "deprecation"}) protected MetaValue isBuilder(MetaType metaType, TypeInfo type, Object value, Map mapping) { MetaValueBuilder builder = null; synchronized (builders) { WeakReference> weak = builders.get(type.getType()); if (weak != null) builder = weak.get(); } if (builder == null) return null; MetaValue result = builder.buildMetaValue(metaType, value); if (result != null) mapping.put(value, result); return result; } } ././@LongLink0000000000000000000000000000020300000000000011560 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/plugins/values/CompositeValueInvocationHandler.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/plugins/values/Compos0000644000175000017500000001250010756363227033314 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.metatype.plugins.values; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflect.Type; import java.lang.reflect.Proxy; import java.util.Map; import java.util.Collections; import java.util.WeakHashMap; import org.jboss.util.UnreachableStatementException; import org.jboss.metatype.api.values.CompositeValue; import org.jboss.metatype.api.values.MetaValueFactory; import org.jboss.metatype.api.values.MetaValue; /** * CompositeValueInvocationHandler. * * @author Ales Justin * @author Adrian Brock */ public class CompositeValueInvocationHandler implements InvocationHandler { /** The MetaValueFactory */ private static MetaValueFactory factory = MetaValueFactory.getInstance(); /** A cache of methods to keys */ private static final Map compositeDataKeyCache = Collections.synchronizedMap(new WeakHashMap()); /** The composite value */ private CompositeValue compositeValue; /** * Create a new CompositeValueInvocationHandler. * * @param compositeValue the composite value */ public CompositeValueInvocationHandler(CompositeValue compositeValue) { if (compositeValue == null) throw new IllegalArgumentException("Null compositeValue"); this.compositeValue = compositeValue; } /** * Get the compositeData. * * @return the compositeData. */ public CompositeValue getCompositeValue() { return compositeValue; } public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if (Object.class.equals(method.getDeclaringClass())) return handleObjectInvocation(method.getName(), args); MetaValue value = compositeValue.get(getCompositeDataKey(method)); Type returnType = method.getGenericReturnType(); return factory.unwrap(value, returnType); } private Object handleObjectInvocation(String name, Object[] args) throws Throwable { if ("equals".equals(name)) { Object object = args[0]; if (object == null || object instanceof Proxy == false) return false; InvocationHandler handler = Proxy.getInvocationHandler(object); if (handler == this) return true; if (handler == null || handler instanceof CompositeValueInvocationHandler == false) return false; CompositeValueInvocationHandler other = (CompositeValueInvocationHandler) handler; return getCompositeValue().equals(other.getCompositeValue()); } else if ("hashCode".equals(name)) return getCompositeValue().hashCode(); else if ("toString".equals(name)) return getCompositeValue().toString(); throw new UnreachableStatementException(); } /** * Get the key for a composite data getter method * * @param method the method * @return the key */ public static String getCompositeDataKey(Method method) { String key = compositeDataKeyCache.get(method); if (key != null) return key; StringBuilder fieldName = null; Class returnType = method.getReturnType(); Class[] paramTypes = method.getParameterTypes(); if (Void.TYPE.equals(returnType) == false && paramTypes.length == 0) { String name = method.getName(); if (name.startsWith("is") && name.length() > 2) { if (Boolean.TYPE.equals(returnType)) { fieldName = new StringBuilder(); fieldName.append(Character.toLowerCase(name.charAt(2))); if (name.length() > 3) fieldName.append(name.substring(3)); } } else if (name.startsWith("get") && name.length() > 3) { fieldName = new StringBuilder(); fieldName.append(Character.toLowerCase(name.charAt(3))); if (name.length() > 4) fieldName.append(name.substring(4)); } } if (fieldName == null) return null; String result = fieldName.toString(); compositeDataKeyCache.put(method, result); return result; } } ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/plugins/values/MetaValueFactoryBuilder.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/plugins/values/MetaVa0000644000175000017500000000634111044242074033222 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.metatype.plugins.values; import java.security.AccessController; import java.security.PrivilegedAction; import org.jboss.metatype.api.values.MetaValueFactory; /** * MetaValueFactoryBuilder. * * TODO this class only creates a singleton implementation for now, configurable * via the org.jboss.metatype.api.values.MetaValueFactory system property. * @author Adrian Brock * @author Scott.Stark@jboss.org * @version $Revision: 76501 $ */ public class MetaValueFactoryBuilder { /** The singleton */ private static final MetaValueFactory singleton; static { singleton = AccessController.doPrivileged(new PrivilegedAction() { public MetaValueFactory run() { MetaValueFactory mvf = null; String defaultMVF = DefaultMetaValueFactory.class.getName(); // The system property for the MetaValueFactory class to use String className = System.getProperty(MetaValueFactory.class.getName(), defaultMVF); try { Class clazz; try { clazz = Thread.currentThread().getContextClassLoader().loadClass(className); } catch (ClassNotFoundException e) { try { clazz = getClass().getClassLoader().loadClass(className); } catch (ClassNotFoundException ignored) { throw e; } } Object result = clazz.newInstance(); mvf = MetaValueFactory.class.cast(result); } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new Error("Unexpected error loading MetaValueFactory " + className, e); } return mvf; } }); } /** * Create the factory * * @return the factory */ public static MetaValueFactory create() { return singleton; } } ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/plugins/values/ListInstanceFactory.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/plugins/values/ListIn0000644000175000017500000000317710756363227033270 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.metatype.plugins.values; import java.util.List; import java.util.ArrayList; import org.jboss.metatype.api.values.InstanceFactory; import org.jboss.beans.info.spi.BeanInfo; /** * List instance factory. * * @author Ales Justin */ @SuppressWarnings("unchecked") public class ListInstanceFactory implements InstanceFactory { public static ListInstanceFactory INSTANCE = new ListInstanceFactory(); private ListInstanceFactory() { } public List instantiate(BeanInfo beanInfo) throws Throwable { return new ArrayList(); } } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/plugins/values/SetInstanceFactory.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/plugins/values/SetIns0000644000175000017500000000316210756363227033265 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.metatype.plugins.values; import java.util.HashSet; import java.util.Set; import org.jboss.beans.info.spi.BeanInfo; import org.jboss.metatype.api.values.InstanceFactory; /** * Set instance factory. * * @author Ales Justin */ @SuppressWarnings("unchecked") public class SetInstanceFactory implements InstanceFactory { public static SetInstanceFactory INSTANCE = new SetInstanceFactory(); private SetInstanceFactory() { } public Set instantiate(BeanInfo beanInfo) throws Throwable { return new HashSet(); } } libjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/plugins/types/0000755000175000017500000000000011105402544031761 5ustar twernertwerner././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/plugins/types/AbstractCompositeMetaType.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/plugins/types/Abstrac0000644000175000017500000002407110761511660033276 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.metatype.plugins.types; import java.util.Collections; import java.util.Iterator; import java.util.Set; import java.util.TreeMap; import org.jboss.metatype.api.types.AbstractMetaType; import org.jboss.metatype.api.types.CompositeMetaType; import org.jboss.metatype.api.types.MetaType; import org.jboss.metatype.api.values.CompositeValue; /** * ImmutableCompositeMetaType. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public abstract class AbstractCompositeMetaType extends AbstractMetaType implements CompositeMetaType { /** The serialVersionUID */ private static final long serialVersionUID = -7421421680257307598L; /** Item names to descriptions */ private TreeMap nameToDescription; /** Item names to meta types */ private TreeMap nameToType; /** The keys */ private Set keys; /** * Construct a composite meta type. The parameters are checked for validity.

* * The three arrays are internally copied. Future changes to these * arrays do not alter the composite type.

* * getClassName() returns {@link CompositeValue} * * @param typeName the name of the composite type, cannot be null or empty * @param description the human readable description of the composite type, cannot be null or empty * @param itemNames the names of the items described by this type. Cannot * be null, must contain at least one element, the elements cannot * be null or empty. The order of the items is unimportant when * determining equality. * @param itemDescriptions the human readable descriptions of the items * in the same order as the itemNames, cannot be null must have the * same number of elements as the itemNames. The elements cannot * be null or empty. * @param itemTypes the MetaTypes of the items in the same order as the * item names, cannot be null must have the * same number of elements as the itemNames. The elements cannot * be null. * @param ignoreItems whether to ignore items * @exception IllegalArgumentException when a parameter does not match * what is described above or when itemNames contains a duplicate name. * The names are case sensitive, leading and trailing whitespace * is ignored. */ protected AbstractCompositeMetaType(String typeName, String description, String[] itemNames, String[] itemDescriptions, MetaType[] itemTypes, boolean ignoreItems) { super(CompositeValue.class.getName(), typeName, description); if (ignoreItems) { nameToDescription = new TreeMap(); nameToType = new TreeMap(); return; } if (itemNames == null || itemNames.length == 0) throw new IllegalArgumentException("null or empty itemNames"); if (itemDescriptions == null || itemDescriptions.length == 0) throw new IllegalArgumentException("null or empty itemDescriptions"); if (itemTypes == null || itemTypes.length == 0) throw new IllegalArgumentException("null or empty itemTypes"); if (itemNames.length != itemDescriptions.length) throw new IllegalArgumentException("wrong number of itemDescriptions"); if (itemNames.length != itemTypes.length) throw new IllegalArgumentException("wrong number of itemTypes"); nameToDescription = new TreeMap(); nameToType = new TreeMap(); for (int i = 0; i < itemNames.length; ++i) { try { addItem(itemNames[i], itemDescriptions[i], itemTypes[i]); } catch (IllegalArgumentException e) { IllegalArgumentException e1 = new IllegalArgumentException(e.getMessage() + " for item " + i); e1.setStackTrace(e.getStackTrace()); throw e1; } } } /** * Construct a composite meta type with no items. * * @param typeName the name of the composite type, cannot be null or empty * @param description the human readable description of the composite type, cannot be null or empty * @throws IllegalArgumentException when a parameter does not match what is described above. */ protected AbstractCompositeMetaType(String typeName, String description) { this(typeName, description, null, null, null, true); } /** * Set the keys * * @param keySet the key set */ protected void setKeys(Set keySet) { if (keySet != null) { for (String key : keySet) { if (containsItem(key) == false) throw new IllegalArgumentException("Key " + key + " is not an item " + itemSet()); } } keys = keySet; } /** * Add an item * * @param itemName the item name * @param itemDescription the item description * @param itemType the item type * @throws IllegalArgumentException for a null or empty item name, description or type or duplicate item */ protected void addItem(String itemName, String itemDescription, MetaType itemType) { if (itemName == null) throw new IllegalArgumentException("null item name"); itemName = itemName.trim(); if (itemName.length() == 0) throw new IllegalArgumentException("empty item name"); if (nameToDescription.containsKey(itemName)) throw new IllegalArgumentException("duplicate item name " + itemName); if (itemDescription == null) throw new IllegalArgumentException("null item description"); itemDescription = itemDescription.trim(); if (itemDescription.length() == 0) throw new IllegalArgumentException("empty item description"); if (itemType == null) throw new IllegalArgumentException("null item type"); nameToDescription.put(itemName, itemDescription); nameToType.put(itemName, itemType); } public boolean containsItem(String itemName) { if (itemName == null) return false; return nameToDescription.containsKey(itemName); } public String getDescription(String itemName) { if (itemName == null) return null; return nameToDescription.get(itemName); } @Override public boolean isComposite() { return true; } public MetaType getType(String itemName) { if (itemName == null) return null; return nameToType.get(itemName); } public Set itemSet() { return Collections.unmodifiableSet(nameToDescription.keySet()); } public Set keySet() { if (keys == null) return itemSet(); return Collections.unmodifiableSet(keys); } @Override public boolean isValue(Object obj) { if (obj == null || obj instanceof CompositeValue == false) return false; return equalsImpl(((CompositeValue) obj).getMetaType()); } /** * Implementation of equals * * @param obj the object to check * @return true when equals false otherwise */ protected boolean equalsImpl(Object obj) { if (this == obj) return true; if (obj == null || obj instanceof CompositeMetaType == false) return false; CompositeMetaType other = (CompositeMetaType) obj; if (this.getTypeName().equals(other.getTypeName()) == false) return false; Iterator thisNames = this.keySet().iterator(); Iterator otherNames = other.keySet().iterator(); while(thisNames.hasNext() && otherNames.hasNext()) { String thisName = thisNames.next(); String otherName = otherNames.next(); if (thisName.equals(otherName) == false) return false; if (this.getType(thisName).equals(other.getType(otherName)) == false) return false; } if (thisNames.hasNext() || otherNames.hasNext()) return false; return true; } /** * Hashcode implementation * * @return the hash code */ protected int hashCodeImpl() { int hashCode = getTypeName().hashCode(); for (Object o : nameToType.values()) hashCode += o.hashCode(); for (Object o : keySet()) hashCode += o.hashCode(); return hashCode; } @Override public String toString() { StringBuilder buffer = new StringBuilder(getClass().getSimpleName()); buffer.append('{').append(getTypeName()); Iterator thisNames = itemSet().iterator(); if (thisNames.hasNext()) { buffer.append(" items="); while(thisNames.hasNext()) { String thisName = thisNames.next(); buffer.append("["); buffer.append("name="); buffer.append(thisName); buffer.append(" type="); buffer.append(getType(thisName).getTypeName()); buffer.append("]"); if (thisNames.hasNext()) buffer.append(", "); } } buffer.append('}'); return buffer.toString(); } } ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/plugins/types/ClassMetaTypeBuilder.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/plugins/types/ClassMe0000644000175000017500000000362510761511660033250 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.metatype.plugins.types; import org.jboss.metatype.api.types.ImmutableCompositeMetaType; import org.jboss.metatype.api.types.MetaType; import org.jboss.metatype.api.types.SimpleMetaType; import org.jboss.metatype.spi.types.MetaTypeBuilder; /** * ClassMetaTypeBuilder. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class ClassMetaTypeBuilder implements MetaTypeBuilder { /** The singleton instance */ public static final ClassMetaTypeBuilder INSTANCE = new ClassMetaTypeBuilder(); /** The MetaType for Class */ public static final MetaType CLASS_META_TYPE = new ImmutableCompositeMetaType( Class.class.getName(), Class.class.getName(), new String[] { "name" }, new String[] { "The class name" }, new MetaType[] { SimpleMetaType.STRING } ); public MetaType buildMetaType() { return CLASS_META_TYPE; } } ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/plugins/types/MutableCompositeMetaType.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/plugins/types/Mutable0000644000175000017500000000712310761511660033307 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.metatype.plugins.types; import java.io.IOException; import java.io.ObjectInputStream; import java.util.Set; import org.jboss.metatype.api.types.MetaType; /** * MutableCompositeMetaType. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class MutableCompositeMetaType extends AbstractCompositeMetaType { /** The serialVersionUID */ private static final long serialVersionUID = -8580367706705513814L; /** Whether the composite type is frozen */ private transient boolean frozen = false; /** Cached hash code */ private transient int cachedHashCode = Integer.MIN_VALUE; /** Cached string representation */ private transient String cachedToString = null; /** * Construct a composite meta type with no items. * * @param typeName the name of the composite type, cannot be null or empty * @param description the human readable description of the composite type, cannot be null or empty * @throws IllegalArgumentException when a parameter does not match what is described above. */ public MutableCompositeMetaType(String typeName, String description) { super(typeName, description); } @Override public void addItem(String itemName, String itemDescription, MetaType itemType) { if (frozen) throw new IllegalStateException("The type is frozen"); super.addItem(itemName, itemDescription, itemType); } @Override public void setKeys(Set keySet) { if (frozen) throw new IllegalStateException("The type is frozen"); super.setKeys(keySet); } /** * Freeze the metatype */ public void freeze() { frozen = true; } @Override public boolean equals(Object obj) { // If we aren't frozen yet, use identity if (frozen == false) return super.equals(obj); return equalsImpl(obj); } @Override public int hashCode() { // If we aren't frozen yet, use identity if (frozen == false) return super.hashCode(); if (cachedHashCode != Integer.MIN_VALUE) return cachedHashCode; cachedHashCode = hashCodeImpl(); return cachedHashCode; } @Override public String toString() { // If we aren't frozen yet, don't cache if (frozen == false) return super.toString(); if (cachedToString == null) cachedToString = super.toString(); return cachedToString; } private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); freeze(); } } ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/plugins/types/DefaultMetaTypeFactory.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/plugins/types/Default0000644000175000017500000003317310770514540033306 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.metatype.plugins.types; import java.lang.ref.WeakReference; import java.lang.reflect.Type; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.ArrayList; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Properties; 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.plugins.property.PropertyConfiguration; import org.jboss.config.spi.Configuration; import org.jboss.metatype.api.annotations.CompositeKey; import org.jboss.metatype.api.annotations.CompositeValue; import org.jboss.metatype.api.annotations.Generic; import org.jboss.metatype.api.annotations.MetaTypeConstants; import org.jboss.metatype.api.types.ArrayMetaType; import org.jboss.metatype.api.types.CollectionMetaType; import org.jboss.metatype.api.types.CompositeMetaType; import org.jboss.metatype.api.types.EnumMetaType; import org.jboss.metatype.api.types.GenericMetaType; import org.jboss.metatype.api.types.ImmutableCompositeMetaType; import org.jboss.metatype.api.types.ImmutableTableMetaType; import org.jboss.metatype.api.types.MapCompositeMetaType; import org.jboss.metatype.api.types.MetaType; import org.jboss.metatype.api.types.MetaTypeFactory; import org.jboss.metatype.api.types.SimpleMetaType; import org.jboss.metatype.api.types.TableMetaType; import org.jboss.metatype.spi.types.MetaTypeBuilder; import org.jboss.metatype.spi.values.MetaMapper; import org.jboss.reflect.spi.ArrayInfo; import org.jboss.reflect.spi.ClassInfo; import org.jboss.reflect.spi.EnumConstantInfo; import org.jboss.reflect.spi.EnumInfo; import org.jboss.reflect.spi.InterfaceInfo; import org.jboss.reflect.spi.TypeInfo; /** * DefaultMetaTypeFactory. * * @author Adrian Brock * @author Scott.Stark@jboss.org * @version $Revision: 71085 $ */ public class DefaultMetaTypeFactory extends MetaTypeFactory { /** The map key */ public static final String MAP_KEY = "key"; /** The map value */ public static final String MAP_VALUE = "value"; /** Map index names */ public static final String[] MAP_INDEX_NAMES = { MAP_KEY }; /** Map item names */ public static final String[] MAP_ITEM_NAMES = { MAP_KEY, MAP_VALUE }; /** The configuration */ private static Configuration configuration; static { configuration = AccessController.doPrivileged(new PrivilegedAction() { public Configuration run() { return new PropertyConfiguration(); } }); } /** The object type info */ private TypeInfo objectTypeInfo = configuration.getTypeInfo(Object.class); /** The builders */ private Map, WeakReference> builders = new WeakHashMap, WeakReference>(); /** * Create a new DefaultMetaTypeFactory. */ public DefaultMetaTypeFactory() { // Special types setBuilder(Class.class, ClassMetaTypeBuilder.INSTANCE); } @Override public MetaType resolve(Type type) { TypeInfo typeInfo = configuration.getTypeInfo(type); return resolve(typeInfo); } /** * Resolve the meta type * * @param typeInfo the type * @return the meta type */ public MetaType resolve(TypeInfo typeInfo) { // Look for a cached value MetaType result = typeInfo.getAttachment(MetaType.class); if (result == null) { // Generate it result = generate(typeInfo); // Cache it typeInfo.setAttachment(MetaType.class.getName(), result); } // Return the result return result; } public void setBuilder(Class clazz, MetaTypeBuilder builder) { synchronized (builders) { if (builder == null) builders.remove(clazz); builders.put(clazz, new WeakReference(builder)); } } /** * Generate the metatype * * @param typeInfo the type info * @return the metatype */ public MetaType generate(TypeInfo typeInfo) { MetaType result = isBuilder(typeInfo); if (result != null) return result; MetaMapper mapper = MetaMapper.getMetaMapper(typeInfo); if (mapper != null) return mapper.getMetaType(); result = isGeneric(typeInfo); if (result != null) return result; if (typeInfo.isEnum()) return generateEnum((EnumInfo) typeInfo); ClassInfo annotationType = isAnnotation(typeInfo); if (annotationType != null) return generateAnnotation(annotationType); if (typeInfo.isArray()) return generateArray((ArrayInfo) typeInfo); if (typeInfo.isCollection()) return generateCollection((ClassInfo) typeInfo); if (typeInfo.isMap()) { // See if this is a Map type ClassInfo classInfo = (ClassInfo) typeInfo; TypeInfo[] types = classInfo.getActualTypeArguments(); if (types != null) { TypeInfo keyType = types[0]; TypeInfo valueType = types[1]; if(keyType.getName().equals(String.class.getName())) { // Use MapCompositeMetaType MetaType valueMetaType = resolve(valueType); return new MapCompositeMetaType(valueMetaType); } } // Map java.util.Properties to MapCompositeMetaType(SimpleMetaType.STRING) else if(typeInfo.getName().equals(Properties.class.getName())) { return new MapCompositeMetaType(SimpleMetaType.STRING); } // No, return the general map type return generateMap(classInfo); } result = SimpleMetaType.isSimpleType(typeInfo.getName()); if (result != null) return result; return generateBean((ClassInfo) typeInfo); } /** * Generate an enum metatype * * @param typeInfo the type info * @return the metatype */ public EnumMetaType generateEnum(EnumInfo typeInfo) { EnumConstantInfo[] constants = typeInfo.getEnumConstants(); List validValues = new ArrayList(constants.length); for (EnumConstantInfo constant : constants) validValues.add(constant.getName()); return new EnumMetaType(typeInfo.getName(), validValues); } /** * Whether this type is an annotation * * @param typeInfo the type info * @return the annotation type info */ public ClassInfo isAnnotation(TypeInfo typeInfo) { if (typeInfo.isAnnotation()) return (ClassInfo) typeInfo; if (typeInfo instanceof ClassInfo) { ClassInfo classInfo = (ClassInfo) typeInfo; InterfaceInfo[] interfaces = classInfo.getInterfaces(); if (interfaces != null) { for (int i = 0; i < interfaces.length; ++i) { if (interfaces[i].isAnnotation()) return interfaces[i]; } } } // Doesn't look like an annotation return null; } /** * Generate an annotation metatype * * @param typeInfo the type info * @return the metatype */ public CompositeMetaType generateAnnotation(ClassInfo typeInfo) { return generateBean(typeInfo); } /** * Generate an array metatype * * @param typeInfo the type info * @return the metatype */ @SuppressWarnings("unchecked") public ArrayMetaType generateArray(ArrayInfo typeInfo) { int dimension = 1; TypeInfo componentType = typeInfo.getComponentType(); while (componentType.isArray()) { ++dimension; componentType = ((ArrayInfo) componentType).getComponentType(); } MetaType componentMetaType = resolve(componentType); return new ArrayMetaType(dimension, componentMetaType, componentType.isPrimitive()); } /** * Generate a collection metatype * * @param typeInfo the type info * @return the metatype */ @SuppressWarnings("unchecked") public CollectionMetaType generateCollection(ClassInfo typeInfo) { TypeInfo elementType = objectTypeInfo; TypeInfo[] types = typeInfo.getActualTypeArguments(); if (types != null) elementType = types[0]; MetaType elementMetaType = resolve(elementType); return new CollectionMetaType(typeInfo.getName(), elementMetaType); } /** * Generate a map metatype * * @param typeInfo the type info * @return the metatype */ public TableMetaType generateMap(ClassInfo typeInfo) { TypeInfo keyType = objectTypeInfo; TypeInfo valueType = objectTypeInfo; TypeInfo[] types = typeInfo.getActualTypeArguments(); if (types != null) { keyType = types[0]; valueType = types[1]; } return createMapType(keyType, valueType); } /** * Create a map type * * @param keyType the key type * @param valueType the value type * @return the map type */ public TableMetaType createMapType(TypeInfo keyType, TypeInfo valueType) { String name = Map.class.getName(); MetaType[] itemTypes = { resolve(keyType), resolve(valueType) }; CompositeMetaType entryType = createMapEntryType(itemTypes); return new ImmutableTableMetaType(name, name, entryType, MAP_INDEX_NAMES); } /** * Create a map entry type * * @param itemTypes the item types * @return the map entry type */ public static CompositeMetaType createMapEntryType(MetaType[] itemTypes) { String entryName = Map.Entry.class.getName(); return new ImmutableCompositeMetaType(entryName, entryName, MAP_ITEM_NAMES, MAP_ITEM_NAMES, itemTypes); } /** * Generate a bean metatype * * @param typeInfo the type info * @return the metatype */ public CompositeMetaType generateBean(ClassInfo typeInfo) { BeanInfo beanInfo = configuration.getBeanInfo(typeInfo); MutableCompositeMetaType result = new MutableCompositeMetaType(typeInfo.getName(), typeInfo.getName()); typeInfo.setAttachment(MetaType.class.getName(), result); Set keys = null; Set properties = beanInfo.getProperties(); if (properties != null && properties.size() > 0) { for (PropertyInfo property : properties) { // Do we ignore this property? CompositeValue compositeValue = property.getUnderlyingAnnotation(CompositeValue.class); if (compositeValue != null && compositeValue.ignore()) continue; String name = property.getName(); if ("class".equals(name) == false) { if (compositeValue != null) { String compositeValueName = compositeValue.name(); if (MetaTypeConstants.DEFAULT.equals(compositeValueName) == false) name = compositeValueName; } TypeInfo itemTypeInfo = property.getType(); MetaType metaType = resolve(itemTypeInfo); result.addItem(name, name, metaType); if (property.isAnnotationPresent(CompositeKey.class)) { if (keys == null) keys = new LinkedHashSet(); keys.add(name); } } } } if (keys != null) result.setKeys(keys); result.freeze(); return result; } /** * Check for builders * * @param typeInfo the type info * @return the meta type when it is special */ @SuppressWarnings("deprecation") public MetaType isBuilder(TypeInfo typeInfo) { MetaTypeBuilder builder = null; synchronized (builders) { WeakReference weak = builders.get(typeInfo.getType()); if (weak != null) builder = weak.get(); } if (builder == null) return null; return builder.buildMetaType(); } /** * Check for generic * * @param typeInfo the type info * @return the meta type when it is generic */ public GenericMetaType isGeneric(TypeInfo typeInfo) { if (typeInfo instanceof ClassInfo == false) return null; ClassInfo classInfo = (ClassInfo) typeInfo; Generic generic = classInfo.getUnderlyingAnnotation(Generic.class); if (generic != null) return new GenericMetaType(typeInfo.getName(), typeInfo.getName()); return null; } } ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/plugins/types/MetaTypeFactoryBuilder.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/plugins/types/MetaTyp0000644000175000017500000000306110645072106033274 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.metatype.plugins.types; import org.jboss.metatype.api.types.MetaTypeFactory; /** * MetaTypeFactoryBuilder. * * TODO this class only creates a singleton fixed implementation for now * @author Adrian Brock * @version $Revision: 1.1 $ */ public class MetaTypeFactoryBuilder { /** The singleton */ private static final MetaTypeFactory singleton = new DefaultMetaTypeFactory(); /** * Create the factory * * @return the factory */ public static MetaTypeFactory create() { return singleton; } } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/plugins/types/StringName.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/plugins/types/StringN0000644000175000017500000000331610654162370033303 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, Red Hat Middleware LLC, and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.metatype.plugins.types; import org.jboss.metatype.api.types.Name; /** * A simple string based Name implementation. * * @author Scott.Stark@jboss.org * @version $Revision: 64409 $ */ public class StringName implements Name { private static final long serialVersionUID = 1; private String name; /** * * @param name */ public StringName(String name) { if( name == null ) throw new IllegalArgumentException("Name cannot be null"); this.name = name; } public int hashCode() { return name.hashCode(); } public boolean equals(Object obj) { return name.equals(obj); } public String toString() { return name; } } libjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/0000755000175000017500000000000011105402544027705 5ustar twernertwernerlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/values/0000755000175000017500000000000011105402544031204 5ustar twernertwerner././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/values/GenericValueSupport.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/values/GenericVal0000644000175000017500000000607410645072106033162 0ustar twernertwerner/* * 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 org.jboss.metatype.api.types.GenericMetaType; /** * GenericValue. * * TODO tests * @author Adrian Brock * @version $Revision: 1.1 $ */ public class GenericValueSupport extends AbstractMetaValue implements GenericValue { /** The serialVersionUID */ private static final long serialVersionUID = 5552880928848272037L; /** The generic meta type */ private GenericMetaType metaType; /** The value */ private Serializable value; /** * Create a new GenericValueSupport. * * @param metaType the generic meta type * @param value the value * @throws IllegalArgumentException for a null generic MetaType */ public GenericValueSupport(GenericMetaType metaType, Serializable value) { if (metaType == null) throw new IllegalArgumentException("Null generic meta type"); this.metaType = metaType; this.value = value; } public GenericMetaType 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 GenericValue == false) return false; GenericValue other = (GenericValue) obj; if (metaType.equals(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; } } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/values/CompositeValue.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/values/CompositeV0000644000175000017500000000665610541761230033237 0ustar twernertwerner/* * 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.util.Collection; import org.jboss.metatype.api.types.CompositeMetaType; /** * CompositeValue. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public interface CompositeValue extends MetaValue { CompositeMetaType getMetaType(); /** * Retrieve the value for the item with the passed key * * @param key the key to the item * @return the value * @throws IllegalArgumentException when the key is null or the empty string or when the key does not exist */ MetaValue get(String key); /** * Retrieve the array of values for the item with the passed keys * * @param keys an array of key values * @return the array of values * @throws IllegalArgumentException when a key is null or the empty * string or the array is null or when a key does not exist */ MetaValue[] getAll(String[] keys); /** * Tests whether a key is part of this composite value * * @param key the key to test * @return true when the key exists, false otherwise */ boolean containsKey(String key); /** * Tests whether a item exists with the passed value * * @param value the value to test * @return true when the value exists, false otherwise */ boolean containsValue(MetaValue value); /** * The values of this composite value

* * An iterator over the returned collection returns result in ascending * lexicographic order * * @return an unmodifiable Collection of the values of this CompositeMetaType. */ Collection values(); /** * Tests whether two composite value objects are equal

* * The object is non-null
* The object implements this interface
* The composite meta types are equal
* The values are equal * * @param obj the object to test * @return true when the above conditions are satisfied, false otherwise. */ boolean equals(Object obj); /** * Generates a hashcode for the implementation.

* * The sum of the hashCodes for the elements mentioned in the equals method * * @return the calculated hashcode */ int hashCode(); /** * A string representation of the open mbean operation info.

* * It is made up of implementation class and the values mentioned * in the equals method * * @return the string */ String toString(); } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/values/EnumValue.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/values/EnumValue.0000644000175000017500000000256310645072106033121 0ustar twernertwerner/* * 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 org.jboss.metatype.api.types.EnumMetaType; /** * EnumValue. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public interface EnumValue extends MetaValue { EnumMetaType getMetaType(); /** * Get the underlying value * * @return the underlying value */ public String getValue(); } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/values/CollectionValueSupport.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/values/Collection0000644000175000017500000001145610761511660033240 0ustar twernertwerner/* * 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.util.Arrays; import java.util.Iterator; import org.jboss.metatype.api.types.CollectionMetaType; /** * CollectionValueSupport. * * @author Ales Justin */ public class CollectionValueSupport extends AbstractMetaValue implements CollectionValue { /** The serialVersionUID */ private static final long serialVersionUID = 1131827130033538066L; /** The collection meta type */ private CollectionMetaType metaType; /** The elements */ private MetaValue[] elements; /** * Create a new CollectionValueSupport. * * @param metaType the collection meta type * @throws IllegalArgumentException for a null array MetaType */ public CollectionValueSupport(CollectionMetaType metaType) { if (metaType == null) throw new IllegalArgumentException("Null collection meta type"); this.metaType = metaType; } /** * Create a new ArrayValueSupport. * * @param metaType the collection meta type * @param elements the elements * @throws IllegalArgumentException for a null array MetaType */ public CollectionValueSupport(CollectionMetaType metaType, MetaValue[] elements) { this(metaType); this.elements = elements; } public CollectionMetaType getMetaType() { return metaType; } /** * Get the value. * * @return the value. */ public MetaValue[] getElements() { return elements; } /** * Get the size of the collection. * @return size of the collection. */ public int getSize() { return elements != null ? elements.length : 0; } public Iterator iterator() { return new ElementsIterator(elements); } /** * Set the value. * * @param elements the elements. */ public void setElements(MetaValue[] elements) { this.elements = elements; } @Override @SuppressWarnings("unchecked") public boolean equals(Object obj) { if (obj == this) return true; if (obj == null || obj instanceof CollectionValue == false) return false; CollectionValue other = (CollectionValue) obj; if (metaType.equals(other.getMetaType()) == false) return false; Object[] otherElements = other.getElements(); if (elements == null) return otherElements == null; return otherElements != null && Arrays.equals(elements, otherElements); } @Override public int hashCode() { if (elements == null) return 0; return elements.hashCode(); } @Override public String toString() { return metaType + ": " + elements; } @Override @SuppressWarnings("unchecked") public MetaValue clone() { CollectionValueSupport result = (CollectionValueSupport) super.clone(); int size = getSize(); if (size > 0) { result.elements = new MetaValue[size]; System.arraycopy(elements, 0, result.elements, 0, size); } return result; } private static class ElementsIterator implements Iterator { private int index; private int length; private MetaValue[] elements; ElementsIterator(MetaValue[] elements) { this.elements = elements; this.index = 0; this.length = elements != null ? elements.length : 0; } public boolean hasNext() { return index < length; } public MetaValue next() { return elements[index++]; } public void remove() { throw new UnsupportedOperationException(); } } } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/values/AbstractMetaValue.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/values/AbstractMe0000644000175000017500000000303710541761230033162 0ustar twernertwerner/* * 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; /** * AbstractMetaValue. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public abstract class AbstractMetaValue implements MetaValue { /** The serialVersionUID */ private static final long serialVersionUID = -2213622770885293629L; @Override public MetaValue clone() { try { return (AbstractMetaValue) super.clone(); } catch (CloneNotSupportedException e) { throw new Error("Unexpected error in clone: ", e); } } } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/values/ArrayValueSupport.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/values/ArrayValue0000644000175000017500000001615310761511660033217 0ustar twernertwerner/* * 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.lang.reflect.Array; import java.util.Arrays; import java.util.Iterator; import org.jboss.metatype.api.types.ArrayMetaType; /** * ArrayValue. * * TODO tests * @author Adrian Brock * @version $Revision: 1.1 $ */ public class ArrayValueSupport extends AbstractMetaValue implements ArrayValue { /** The serialVersionUID */ private static final long serialVersionUID = 1131827130033538066L; /** The array meta type */ private ArrayMetaType metaType; /** The value */ private Object value; /** * Create a new ArrayValueSupport. * * @param metaType the array meta type * @throws IllegalArgumentException for a null array MetaType */ public ArrayValueSupport(ArrayMetaType metaType) { if (metaType == null) throw new IllegalArgumentException("Null array meta type"); this.metaType = metaType; } /** * Create a new ArrayValueSupport. * * @param metaType the array meta type * @param value the value * @throws IllegalArgumentException for a null array MetaType */ public ArrayValueSupport(ArrayMetaType metaType, Object value) { this(metaType); this.value = value; } public ArrayMetaType getMetaType() { return metaType; } /** * Get the value. * * @return the value. */ public Object getValue() { return value; } /** * Get the length of the array. * @return length of the array. */ public int getLength() { return Array.getLength(value); } public Object getValue(int index) { return Array.get(value, index); } public Iterator iterator() { return new ArrayValueIterator(value); } /** * Set the value. * * @param value the value. */ public void setValue(Object value) { this.value = value; } @Override public boolean equals(Object obj) { if (obj == this) return true; if (obj == null || obj instanceof ArrayValue == false) return false; ArrayValue other = (ArrayValue) obj; if (metaType.equals(other.getMetaType()) == false) return false; Object otherValue = other.getValue(); if (value == null && otherValue == null) return true; if (value == null && otherValue != null) return false; // Deep equals check boolean equals = false; if (value instanceof Object[] && otherValue instanceof Object[]) equals = Arrays.deepEquals((Object[]) value, (Object[]) otherValue); else if (value instanceof byte[] && otherValue instanceof byte[]) equals = Arrays.equals((byte[]) value, (byte[]) otherValue); else if (value instanceof short[] && otherValue instanceof short[]) equals = Arrays.equals((short[]) value, (short[]) otherValue); else if (value instanceof int[] && otherValue instanceof int[]) equals = Arrays.equals((int[]) value, (int[]) otherValue); else if (value instanceof long[] && otherValue instanceof long[]) equals = Arrays.equals((long[]) value, (long[]) otherValue); else if (value instanceof char[] && otherValue instanceof char[]) equals = Arrays.equals((char[]) value, (char[]) otherValue); else if (value instanceof float[] && otherValue instanceof float[]) equals = Arrays.equals((float[]) value, (float[]) otherValue); else if (value instanceof double[] && otherValue instanceof double[]) equals = Arrays.equals((double[]) value, (double[]) otherValue); else if (value instanceof boolean[] && otherValue instanceof boolean[]) equals = Arrays.equals((boolean[]) value, (boolean[]) otherValue); else equals = value.equals(otherValue); return equals; } @Override public int hashCode() { if (value == null) return 0; return value.hashCode(); } @Override public String toString() { return metaType + ":" + deepToString(); } @Override public MetaValue clone() { ArrayValueSupport result = (ArrayValueSupport) super.clone(); int length = getLength(); if (value != null && length > 0) { // TODO: This is wrong as value is not an Object[] in general result.value = new Object[length]; System.arraycopy(value, 0, result.value, 0, length); } return result; } /** * * @return the deep string */ protected String deepToString() { String deepToString; if (value == null) deepToString = "null"; else if (value instanceof byte[]) deepToString = Arrays.toString((byte[]) value); else if (value instanceof short[]) deepToString = Arrays.toString((short[]) value); else if (value instanceof int[]) deepToString = Arrays.toString((int[]) value); else if (value instanceof long[]) deepToString = Arrays.toString((long[]) value); else if (value instanceof char[]) deepToString = Arrays.toString((char[]) value); else if (value instanceof float[]) deepToString = Arrays.toString((float[]) value); else if (value instanceof double[]) deepToString = Arrays.toString((double[]) value); else if (value instanceof boolean[]) deepToString = Arrays.toString((boolean[]) value); else if (value instanceof Object[]) deepToString = Arrays.deepToString((Object[]) value); else deepToString = value.toString(); return deepToString; } private static class ArrayValueIterator implements Iterator { private int index; private int length; private Object array; ArrayValueIterator(Object array) { this.array = array; this.index = 0; this.length = Array.getLength(array); } public boolean hasNext() { return index < length; } public Object next() { return Array.get(array, index ++); } public void remove() { throw new UnsupportedOperationException(); } } } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/values/GenericValue.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/values/GenericVal0000644000175000017500000000264310645072106033160 0ustar twernertwerner/* * 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 org.jboss.metatype.api.types.GenericMetaType; /** * GenericValue. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public interface GenericValue extends MetaValue { GenericMetaType getMetaType(); /** * Get the underlying value * * @return the underlying value */ public Serializable getValue(); } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/values/MetaValueFactory.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/values/MetaValueF0000644000175000017500000000651710756363227033150 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.metatype.api.values; import java.lang.reflect.Type; import org.jboss.metatype.plugins.values.MetaValueFactoryBuilder; import org.jboss.metatype.spi.values.MetaValueBuilder; import org.jboss.reflect.spi.TypeInfo; /** * MetaValueFactory. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public abstract class MetaValueFactory { /** The singleton builder */ private static final MetaValueFactoryBuilder builder = new MetaValueFactoryBuilder(); /** * Get the metatype factory * * @return the instance */ public static final MetaValueFactory getInstance() { return builder.create(); } /** * Create a meta value * * @param value the value * @return the meta value */ public abstract MetaValue create(Object value); /** * Create a meta value * * @param value the value * @param type the type * @return the meta value */ public abstract MetaValue create(Object value, Type type); /** * Create a meta value * * @param value the value * @param type the type * @return the meta value */ public abstract MetaValue create(Object value, TypeInfo type); /** * Set a meta value builder. * * @param clazz the class * @param builder the builder */ public abstract void setBuilder(Class clazz, MetaValueBuilder builder); /** * Set an instance factory. * * @param exact instance type * @param clazz the class * @param factory the factory */ public abstract void setInstanceFactory(Class clazz, InstanceFactory factory); /** * Unwrap meta value. * Supports simple and generic meta value. * * @param metaValue meta value * @return meta value's value */ public abstract Object unwrap(MetaValue metaValue); /** * Unwrap meta value. * Supports simple and generic meta value. * * @param metaValue meta value * @param type the type * @return meta value's value */ public abstract Object unwrap(MetaValue metaValue, Type type); /** * Unwrap meta value. * Supports simple and generic meta value. * * @param metaValue meta value * @param type the type * @return meta value's value */ public abstract Object unwrap(MetaValue metaValue, TypeInfo type); } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/values/ArrayValue.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/values/ArrayValue0000644000175000017500000000342010761511660033210 0ustar twernertwerner/* * 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 org.jboss.metatype.api.types.ArrayMetaType; /** * ArrayValue. * * @author Adrian Brock * @author Scott.Stark@jboss.org * @version $Revision: 1.1 $ */ public interface ArrayValue extends MetaValue, Iterable { ArrayMetaType getMetaType(); /** * Get the underlying array value. This will not be an * Object[] in general. * @see #getValue(int) * * @return the underlying value */ public Object getValue(); /** * Get the length of the array. * @return length of the array. */ public int getLength(); /** * Get the array element at index. * @param index - index into the array. * @return element at index. */ public Object getValue(int index); } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/values/TableValueSupport.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/values/TableValue0000644000175000017500000002333710761511660033172 0ustar twernertwerner/* * 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.IOException; import java.io.ObjectInputStream; import java.io.ObjectStreamField; import java.util.Arrays; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Set; import java.util.Map.Entry; import org.jboss.metatype.api.types.MetaType; import org.jboss.metatype.api.types.TableMetaType; /** * TableValueSupport. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class TableValueSupport extends AbstractMetaValue implements TableValue { /** The serialVersionUID */ private static final long serialVersionUID = -6862672408820383430L; /** The serialized form */ private static final ObjectStreamField[] serialPersistentFields = new ObjectStreamField[] { new ObjectStreamField("dataMap", HashMap.class), new ObjectStreamField("tableType", TableMetaType.class), }; /** The data map of this tabular data */ private HashMap, CompositeValue> dataMap; /** The table meta data type */ private TableMetaType tableType; /** The index names */ private transient String[] indexNames; /** * Construct Table Value with an initial capacity of 101 and a load * factor of 0.75 * * @param tableType the table type of the data * @exception IllegalArgumentException for a null argument */ public TableValueSupport(TableMetaType tableType) { this(tableType, 101, 0.75f); } /** * Construct Table value * * @param tableType the table type * @param initialCapacity the initial capacity of the map * @param loadFactor the load factory of the map * @exception IllegalArgumentException for a null argument */ public TableValueSupport(TableMetaType tableType, int initialCapacity, float loadFactor) { init(new HashMap, CompositeValue>(initialCapacity, loadFactor), tableType); } public TableMetaType getMetaType() { return tableType; } public MetaValue[] calculateIndex(CompositeValue value) { validateCompositeValue(value); return value.getAll(indexNames); } public void clear() { dataMap.clear(); } public boolean containsKey(MetaValue[] key) { if (key == null) return false; return dataMap.containsKey(Arrays.asList(key)); } public boolean containsValue(CompositeValue value) { return dataMap.containsValue(value); } public CompositeValue get(MetaValue[] key) { validateKey(key); return dataMap.get(Arrays.asList(key)); } public boolean isEmpty() { return dataMap.isEmpty(); } public Set> keySet() { return dataMap.keySet(); } public void put(CompositeValue value) { List index = Arrays.asList(calculateIndex(value)); if (dataMap.containsKey(index)) throw new IllegalArgumentException("The index is already used " + index); dataMap.put(index, value); } public void putAll(CompositeValue[] values) { if (values == null) return; HashSet> keys = new HashSet>(); for (int i = 0; i < values.length; ++i) { List index = Arrays.asList(calculateIndex(values[i])); if (keys.contains(index)) throw new IllegalArgumentException("Duplicate index in values " + index + " for value " + values[i]); keys.add(index); if (dataMap.containsKey(index)) throw new IllegalArgumentException("Index already used " + index + " for value " + values[i]); } for (int i = 0; i < values.length; i++) put(values[i]); } public CompositeValue remove(MetaValue[] key) { validateKey(key); return dataMap.remove(Arrays.asList(key)); } public int size() { return dataMap.size(); } public Collection values() { return dataMap.values(); } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null || (obj instanceof TableValue) == false) return false; TableValue other = (TableValue) obj; if (tableType.equals(other.getMetaType()) == false) return false; if (size() != other.size()) return false; for (Entry, CompositeValue> entry : dataMap.entrySet()) { List list = entry.getKey(); MetaValue[] indexes = list.toArray(new MetaValue[list.size()]); CompositeValue thisValue = entry.getValue(); CompositeValue otherValue = other.get(indexes); if (thisValue == null && otherValue == null) return true; if (thisValue == null && otherValue != null) return false; if (thisValue.equals(otherValue) == false) return false; } return true; } @Override public int hashCode() { int hash = tableType.hashCode(); for (CompositeValue value : dataMap.values()) hash += value.hashCode(); return hash; } @Override public String toString() { StringBuilder buffer = new StringBuilder(getClass().getSimpleName()); buffer.append(": tableType=["); buffer.append(getMetaType()); buffer.append("] mappings=["); Iterator, CompositeValue>> entries = dataMap.entrySet().iterator(); while(entries.hasNext()) { Entry, CompositeValue> entry = entries.next(); buffer.append(entry.getKey()); buffer.append("="); buffer.append(entry.getValue()); if (entries.hasNext()) buffer.append(","); } buffer.append("]"); return buffer.toString(); } @Override @SuppressWarnings("unchecked") public TableValueSupport clone() { TableValueSupport result = (TableValueSupport) super.clone(); result.dataMap = (HashMap, CompositeValue>) dataMap.clone(); return result; } /** * Initialise the table value * * @param dataMap the data * @param tableType the table type * @exception IllegalArgumentException for a null */ private void init(HashMap, CompositeValue> dataMap, TableMetaType tableType) { if (dataMap == null) throw new IllegalArgumentException("null dataMap"); if (tableType == null) throw new IllegalArgumentException("null table type"); this.dataMap = dataMap; this.tableType = tableType; List indexNameList = tableType.getIndexNames(); this.indexNames = indexNameList.toArray(new String[indexNameList.size()]); } /** * Validate the composite type against the row type * * @param value the composite value * @throws IllegalArgumentException for a null value or if the value is not valid for the table value's row type */ private void validateCompositeValue(CompositeValue value) { if (value == null) throw new IllegalArgumentException("null value"); if (value.getMetaType().equals(tableType.getRowType()) == false) throw new IllegalArgumentException("value has composite type " + value.getMetaType() + " expected row type " + tableType.getRowType()); } /** * Validate the key against the row type * * @param key the key to check * @throws IllegalArgumentException for a null key or if the key is not valid for the table value's row type */ private void validateKey(MetaValue[] key) { if (key == null || key.length == 0) throw new IllegalArgumentException("null or empty key"); if (key.length != indexNames.length) throw new IllegalArgumentException("key has " + key.length + " elements, " + "should be " + indexNames.length); for (int i = 0; i < key.length; i++) { MetaType metaType = tableType.getRowType().getType(indexNames[i]); if (key[i] != null && metaType.isValue(key[i]) == false) throw new IllegalArgumentException("key element " + i + " " + key + " is not a value for " + metaType); } } @SuppressWarnings("unchecked") private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { ObjectInputStream.GetField getField = in.readFields(); HashMap, CompositeValue> dataMap = (HashMap, CompositeValue>) getField.get("dataMap", null); TableMetaType tableType = (TableMetaType) getField.get("tableType", null); try { init(dataMap, tableType); } catch (Exception e) { throw new RuntimeException("Unexpected error during deserialization", e); } } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/values/MetaValue.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/values/MetaValue.0000644000175000017500000000274310761511660033105 0ustar twernertwerner/* * 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 org.jboss.metatype.api.types.MetaType; /** * MetaValue. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public interface MetaValue extends Serializable, Cloneable { /** * Get the metatype for this value * * @return the metatype */ MetaType getMetaType(); /** * Clone the meta value * * @return the cloned meta value */ MetaValue clone(); } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/values/SimpleValueSupport.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/values/SimpleValu0000644000175000017500000000670310761511660033225 0ustar twernertwerner/* * 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 org.jboss.metatype.api.types.SimpleMetaType; /** * SimpleValue. * * @author Adrian Brock * @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(); SimpleMetaType metaType = SimpleMetaType.resolve(className); return new SimpleValueSupport(metaType, object); } /** * 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) 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; } } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/values/TableValue.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/values/TableValue0000644000175000017500000001136710645072106033170 0ustar twernertwerner/* * 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.util.Collection; import java.util.List; import java.util.Set; import org.jboss.metatype.api.types.TableMetaType; /** * TableValue. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public interface TableValue extends MetaValue { TableMetaType getMetaType(); /** * Calculate the index for the value passed if it were added to the * table value. The validity of the passed value is checked. But the * table value isn't checked to see whether the index is already used. * * @param value the value for which the index is calculated. * @return the calculated index * @throws IllegalArgumentException for a null value or when the passed value is not valid for the table value's row type. */ MetaValue[] calculateIndex(CompositeValue value); /** * Retrieve the number of rows in the table value. * * @return the number of rows. */ int size(); /** * Determine whether the table value is empty. * * @return true when there are no rows, false otherwise */ boolean isEmpty(); /** * Determine whether the table value contains the passed value as a row. * If the passed value is null or invalid, false is returned. * * @param key the value to check * @return true when the value is a row index, false otherwise */ boolean containsKey(MetaValue[] key); /** * Determine whether the table value contains the passed value. * If the passed value is null or invalid, false is returned. * * @param value the value to check * @return true when the value is a row index, false otherwise */ boolean containsValue(CompositeValue value); /** * Retrieve the composite value for the passed index. * * @param key the index to retrieve * @return the composite value * @throws IllegalArgumentException when the passed key is null or when the passed key does match the row type of the table value. */ CompositeValue get(MetaValue[] key); /** * Add a value to the table value. The value must have the same * CompositeMetaType has the table value and there is no value already * occupying the index for the value. * * @param value the value to add * @throws IllegalArgumentException when the passed value is null or when the value is not valid for * the row type of the tabular data or when the index for the value is already occupied. */ void put(CompositeValue value); /** * Removes the value for the passed and returns the removed value, or * null if the key was not present. * * @param key the index of the value to remove * @return the removed value * @throws IllegalArgumentException when the passed key is null or when the key is not valid for the table value */ CompositeValue remove(MetaValue[] key); /** * Add all the passed values. All the values are checked before * addition including any duplicates that might be added. Either all * or no value is added. * * @param values the values to add * @throws IllegalArgumentException when the passed values is null or an element of the values is null * or when one of value is not valid for the row type of the table value or when * the index for one of the values is already occupied. */ void putAll(CompositeValue[] values); /** * Removes all CompositeValues from the Table value */ void clear(); /** * Returns a set view of the index values. * * @return the set of index values. */ Set> keySet(); /** * Returns a set view of the row values. * * @return the set of row values. */ Collection values(); } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/values/CollectionValue.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/values/Collection0000644000175000017500000000306410761511660033234 0ustar twernertwerner/* * 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 org.jboss.metatype.api.types.CollectionMetaType; /** * CollectionValue. * * @author Ales Justin */ public interface CollectionValue extends MetaValue, Iterable { CollectionMetaType getMetaType(); /** * Get the underlying elements. * * @return the underlying elements */ public MetaValue[] getElements(); /** * Get the size of the collection. * @return size of the colelction. */ public int getSize(); } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/values/SimpleValue.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/values/SimpleValu0000644000175000017500000000263010761511660033220 0ustar twernertwerner/* * 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 org.jboss.metatype.api.types.SimpleMetaType; /** * SimpleValue. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public interface SimpleValue extends MetaValue { SimpleMetaType getMetaType(); /** * Get the underlying value * * @return the underlying value */ Serializable getValue(); } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/values/EnumValueSupport.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/values/EnumValueS0000644000175000017500000000643210756363227033177 0ustar twernertwerner/* * 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 org.jboss.metatype.api.types.EnumMetaType; /** * EnumValue. * * TODO tests * @author Adrian Brock * @version $Revision: 1.1 $ */ public class EnumValueSupport extends AbstractMetaValue implements EnumValue { /** The serialVersionUID */ private static final long serialVersionUID = -6472212391813711803L; /** The enum meta type */ private EnumMetaType metaType; /** The value */ private String value; /** * Create a new EnumValueSupport. * * @param metaType the enum meta type * @param value the value * @throws IllegalArgumentException for a null enum MetaType */ public EnumValueSupport(EnumMetaType metaType, String value) { if (metaType == null) throw new IllegalArgumentException("Null enum meta type"); this.metaType = metaType; this.value = value; } /** * Create a new EnumValueSupport from an Enum value. * @param metaType the enum meta type * @param value the enum instance * @throws IllegalArgumentException for a null enum MetaType */ public EnumValueSupport(EnumMetaType metaType, Enum value) { this(metaType, value.name()); } public EnumMetaType getMetaType() { return metaType; } /** * Get the value. * * @return the value. */ public String getValue() { return value; } /** * Set the value. * * @param value the value. */ public void setValue(String value) { this.value = value; } @Override public boolean equals(Object obj) { if (obj == this) return true; if (obj == null || obj instanceof EnumValue == false) return false; EnumValue other = (EnumValue) obj; if (metaType.equals(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; } } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/values/InstanceFactory.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/values/InstanceFa0000644000175000017500000000274710730037304033155 0ustar twernertwerner/* * 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 org.jboss.beans.info.spi.BeanInfo; /** * The recreate instance factory. * * @param the actual instance type * @author Ales Justin */ public interface InstanceFactory { /** * Create new instance. * * @param beanInfo the bean info * @return new instance * @throws Throwable for any error */ T instantiate(BeanInfo beanInfo) throws Throwable; } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/values/MapCompositeValueSupport.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/values/MapComposi0000644000175000017500000000766110763570354033226 0ustar twernertwerner/* * 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.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; import org.jboss.metatype.api.types.CompositeMetaType; import org.jboss.metatype.api.types.MapCompositeMetaType; import org.jboss.metatype.api.types.MetaType; /** * A CompositeValue for Map * * @author Scott.Stark@jboss.org * @version $Revision: 70446 $ */ public class MapCompositeValueSupport extends AbstractMetaValue implements CompositeValue { private static final long serialVersionUID = 1; private Map map; private MapCompositeMetaType mapType; public MapCompositeValueSupport(MetaType valueType) { this(null, valueType); } public MapCompositeValueSupport(Map map, MetaType valueType) { this.map = createMap(); this.mapType = new MapCompositeMetaType(valueType); if(map != null) { for(Map.Entry entry : map.entrySet()) this.put(entry.getKey(), entry.getValue()); } } /** * Create map instance. * Default is hash map. * * @return the map */ protected Map createMap() { return new HashMap(); } public boolean containsKey(String key) { return map.containsKey(key); } public boolean containsValue(MetaValue value) { return map.containsValue(value); } public MetaValue get(String key) { return map.get(key); } public void put(String key, MetaValue value) { if(mapType.containsItem(key) == false) mapType.addItem(key); map.put(key, value); } public MetaValue[] getAll(String[] keys) { List values = new ArrayList(); if(keys != null) { for(String key : keys) { MetaValue value = map.get(key); values.add(value); } } MetaValue[] mvs = new MetaValue[values.size()]; return values.toArray(mvs); } public CompositeMetaType getMetaType() { return mapType; } public Collection values() { return map.values(); } @Override public boolean equals(Object obj) { if (obj == this) return true; if (obj == null || obj instanceof MapCompositeValueSupport == false) return false; MapCompositeValueSupport other = (MapCompositeValueSupport) obj; if (mapType.equals(other.getMetaType()) == false) return false; Map otherMap = other.map; if (map == null && otherMap == null) return true; if (map == null && otherMap != null) return false; return map.equals(otherMap); } @Override public int hashCode() { return map.hashCode(); } @Override public String toString() { return mapType + ":" + map; } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/values/CompositeValueSupport.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/values/CompositeV0000644000175000017500000002573510761511660033242 0ustar twernertwerner/* * 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.IOException; import java.io.ObjectInputStream; import java.io.ObjectStreamField; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; import java.util.SortedMap; import java.util.TreeMap; import java.util.Map.Entry; import org.jboss.metatype.api.types.CompositeMetaType; import org.jboss.metatype.api.types.MetaType; /** * CompositeValueSupport. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class CompositeValueSupport extends AbstractMetaValue implements CompositeValue { /** The serialVersionUID */ private static final long serialVersionUID = 6262188760975631870L; /** The serialized form */ private static final ObjectStreamField[] serialPersistentFields = new ObjectStreamField[] { new ObjectStreamField("contents", SortedMap.class), new ObjectStreamField("metaType", CompositeMetaType.class), }; /** The contents */ private SortedMap contents; /** The composite type */ private CompositeMetaType metaType; /** cached hashCode */ private transient int cachedHashCode = Integer.MIN_VALUE; /** * Construct Composite Value * * @param metaType the composite meta type of the data * @param itemNames the names of the values * @param itemValues the values * @throws IllegalArgumentException for a null metaType */ public CompositeValueSupport(CompositeMetaType metaType, String[] itemNames, MetaValue[] itemValues) { if (metaType == null) throw new IllegalArgumentException("null meta type"); if (itemNames == null) itemNames = new String[0]; if (itemValues == null) itemValues = new MetaValue[0]; if (itemNames.length != itemValues.length) throw new IllegalArgumentException("itemNames has size " + itemNames.length + " but itemValues has size " + itemValues.length); Set compositeNames = metaType.itemSet(); int compositeNameSize = compositeNames.size(); if (itemNames.length > compositeNameSize) throw new IllegalArgumentException("itemNames has size " + itemNames.length + " but composite type has size " + compositeNameSize); this.metaType = metaType; contents = new TreeMap(); for (int i = 0; i < itemNames.length; i++) { if (itemNames[i] == null || itemNames[i].length() == 0) throw new IllegalArgumentException("Item name " + i + " is null or empty"); if (contents.get(itemNames[i]) != null) throw new IllegalArgumentException("duplicate item name " + itemNames[i]); MetaType itemType = metaType.getType(itemNames[i]); if (itemType == null) throw new IllegalArgumentException("item name not in composite type: " + itemNames[i]); if (itemValues[i] != null && itemType.isValue(itemValues[i]) == false) throw new IllegalArgumentException("item value " + itemValues[i] + " for item name " + itemNames[i] + " is not a " + itemType); contents.put(itemNames[i], itemValues[i]); } if (itemNames.length < compositeNameSize) { List itemList = Arrays.asList(itemNames); for (String name : compositeNames) { if (itemList.contains(name) == false) contents.put(name, null); } } } /** * Construct Composite Value * * @param metaType the composite meta type of the data * @throws IllegalArgumentException for a null metaType */ public CompositeValueSupport(CompositeMetaType metaType) { this(metaType, null, null); } /** * Construct Composite Value * * @param compositeMetaType the composite type of the data * @param items map of strings to values * @throws IllegalArgumentException for a null metaType */ public CompositeValueSupport(CompositeMetaType compositeMetaType, Map items) { init(compositeMetaType, items); } public CompositeMetaType getMetaType() { return metaType; } public MetaValue get(String key) { validateKey(key); return contents.get(key); } /** * Set an item value * * @param key the key * @param value the value */ public void set(String key, MetaValue value) { MetaType itemType = validateKey(key); if (value != null && itemType.isValue(value) == false) throw new IllegalArgumentException("item value " + value + " for item name " + key + " is not a " + itemType); contents.put(key, value); } public MetaValue[] getAll(String[] keys) { if (keys == null) throw new IllegalArgumentException("Null keys"); MetaValue[] result = new MetaValue[keys.length]; for (int i = 0; i < keys.length; i++) { validateKey(keys[i]); result[i] = contents.get(keys[i]); } return result; } public boolean containsKey(String key) { if (key == null || key.length() == 0) return false; return contents.containsKey(key); } public boolean containsValue(MetaValue value) { return contents.containsValue(value); } public Collection values() { return Collections.unmodifiableCollection(contents.values()); } @Override public boolean equals(Object obj) { if (obj == this) return true; if (obj == null || obj instanceof CompositeValue == false) return false; CompositeValue other = (CompositeValue) obj; if (getMetaType().equals(other.getMetaType()) == false) return false; for (String key : getMetaType().keySet()) { Object thisValue = this.get(key); Object otherValue = other.get(key); if ((thisValue == null && otherValue == null || thisValue != null && thisValue.equals(otherValue)) == false) return false; } return true; } @Override public int hashCode() { if (cachedHashCode != Integer.MIN_VALUE) return cachedHashCode; cachedHashCode = getMetaType().hashCode(); for (String key : getMetaType().keySet()) { Object value = contents.get(key); if (value != null) cachedHashCode += value.hashCode(); } return cachedHashCode; } @Override public String toString() { CompositeMetaType metaType = getMetaType(); StringBuilder buffer = new StringBuilder(getClass().getSimpleName()); buffer.append(": metaType=["); buffer.append(metaType); buffer.append("] items=["); Iterator keys = metaType.keySet().iterator(); while(keys.hasNext()) { Object key = keys.next(); buffer.append(key).append("="); Object value = contents.get(key); buffer.append(value); if (keys.hasNext()) buffer.append(","); } buffer.append("]"); return buffer.toString(); } /** * Validates the key against the composite type * * @param key the key to check * @return the meta type * @throws IllegalArgumentException for a null or empty key or when * the key not a valid item name for the composite type */ private MetaType validateKey(String key) { if (key == null || key.length() == 0) throw new IllegalArgumentException("null or empty key"); CompositeMetaType metaType = getMetaType(); MetaType result = metaType.getType(key); if (result == null) throw new IllegalArgumentException("no such item name " + key + " for composite type " + metaType); return result; } /** * Construct Composite Value * * @param metaType the composite type of the data * @param items map of strings to values * @throws IllegalArgumentException for a metaType */ private void init(CompositeMetaType metaType, Map items) { if (metaType == null) throw new IllegalArgumentException("null meta type"); if (items == null) items = Collections.emptyMap(); Set compositeNames = metaType.itemSet(); int compositeNameSize = compositeNames.size(); if (items.size() > compositeNameSize) throw new IllegalArgumentException("items has size " + items.size() + " but composite type has size " + compositeNameSize); this.metaType = metaType; contents = new TreeMap(); for (Entry entry : items.entrySet()) { String key = entry.getKey(); if (key == null || key.length() == 0) throw new IllegalArgumentException("Key is null or empty"); MetaType itemType = metaType.getType(key); if (itemType == null) throw new IllegalArgumentException("item name not in composite type " + key); MetaValue value = items.get(key); if (value != null && itemType.isValue(value) == false) throw new IllegalArgumentException("item value " + value + " for item name " + key + " is not a " + itemType); contents.put(key, value); } if (items.size() < compositeNameSize) { for (String name : compositeNames) { if (items.containsKey(name) == false) contents.put(name, null); } } } @SuppressWarnings("unchecked") private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { ObjectInputStream.GetField getField = in.readFields(); SortedMap contents = (SortedMap) getField.get("contents", null); CompositeMetaType compositeType = (CompositeMetaType) getField.get("metaType", null); try { init(compositeType, contents); } catch (Exception e) { throw new RuntimeException("Error deserializing composite value", e); } } } libjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/types/0000755000175000017500000000000011105402544031051 5ustar twernertwerner././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/types/ImmutableCompositeMetaType.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/types/ImmutableCo0000644000175000017500000000733710761511660033216 0ustar twernertwerner/* * 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.types; import org.jboss.metatype.api.values.CompositeValue; import org.jboss.metatype.plugins.types.AbstractCompositeMetaType; /** * ImmutableCompositeMetaType. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class ImmutableCompositeMetaType extends AbstractCompositeMetaType { /** The serialVersionUID */ private static final long serialVersionUID = 1133171306971861455L; /** Cached hash code */ private transient int cachedHashCode = Integer.MIN_VALUE; /** Cached string representation */ private transient String cachedToString = null; /** * Construct a composite meta type. The parameters are checked for validity.

* * The three arrays are internally copied. Future changes to these * arrays do not alter the composite type.

* * getClassName() returns {@link CompositeValue} * * @param typeName the name of the composite type, cannot be null or empty * @param description the human readable description of the composite type, cannot be null or empty * @param itemNames the names of the items described by this type. Cannot * be null, must contain at least one element, the elements cannot * be null or empty. The order of the items is unimportant when * determining equality. * @param itemDescriptions the human readable descriptions of the items * in the same order as the itemNames, cannot be null must have the * same number of elements as the itemNames. The elements cannot * be null or empty. * @param itemTypes the MetaTypes of the items in the same order as the * item names, cannot be null must have the * same number of elements as the itemNames. The elements cannot * be null. * @exception IllegalArgumentException when a parameter does not match * what is described above or when itemNames contains a duplicate name. * The names are case sensitive, leading and trailing whitespace * is ignored. */ public ImmutableCompositeMetaType(String typeName, String description, String[] itemNames, String[] itemDescriptions, MetaType[] itemTypes) { super(typeName, description, itemNames, itemDescriptions, itemTypes, false); } @Override public boolean equals(Object obj) { return equalsImpl(obj); } @Override public int hashCode() { if (cachedHashCode != Integer.MIN_VALUE) return cachedHashCode; cachedHashCode = hashCodeImpl(); return cachedHashCode; } @Override public String toString() { if (cachedToString == null) cachedToString = super.toString(); return cachedToString; } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/types/ImmutableTableMetaType.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/types/ImmutableTa0000644000175000017500000001416710761511660033220 0ustar twernertwerner/* * 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.types; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; import org.jboss.metatype.api.values.TableValue; /** * ImmutableTableMetaType. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class ImmutableTableMetaType extends AbstractMetaType implements TableMetaType { /** The serialVersionUID */ private static final long serialVersionUID = 5791103660662775558L; /** The open type of the rows */ private CompositeMetaType rowType; /** Index names */ private List indexNames; /** Cached hash code */ private transient int cachedHashCode = Integer.MIN_VALUE; /** Cached string representation */ private transient String cachedToString = null; /** * Construct a tabe type. The parameters are checked for validity. * * @param typeName the name of the tabular type, cannot be null or empty * @param description the human readable description of the tabular type, cannot be null or empty * @param rowType the type of the row elements in the tabular data, cannot be null * @param indexNames the names of the item values that uniquely index each * row element in the tabular data, cannot be null or empty. Each * element must be an item name in the rowType, nul or empty is not * allowed. The order of the item names in this parameter is used * by {@link TableValue#get} and {@link TableValue#remove} the * TabularValue to match the array of values to items. * @throws IllegalArgumentException when a parameter does not match * what is described above or when an element of indexNames is not defined * in rowType. */ public ImmutableTableMetaType(String typeName, String description, CompositeMetaType rowType, String[] indexNames) { super(TableValue.class.getName(), typeName, description); if (rowType == null) throw new IllegalArgumentException("null rowType"); if (indexNames == null || indexNames.length == 0) throw new IllegalArgumentException("null or empty indexNames"); this.rowType = rowType; this.indexNames = new ArrayList(); for (int i = 0; i < indexNames.length; i++) { if (indexNames[i] == null) throw new IllegalArgumentException("null index name " + i); String indexName = indexNames[i].trim(); if (indexName.length() == 0) throw new IllegalArgumentException("empty index name " + i); if (rowType.containsItem(indexName) == false) throw new IllegalArgumentException("no item name " + indexName); this.indexNames.add(indexName); } } public CompositeMetaType getRowType() { return rowType; } public List getIndexNames() { return Collections.unmodifiableList(indexNames); } @Override public boolean isTable() { return true; } @Override public boolean isValue(Object obj) { if (obj == null || obj instanceof TableValue == false) return false; TableMetaType other = ((TableValue) obj).getMetaType(); return equals(other); } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null || obj instanceof TableMetaType == false) return false; TableMetaType other = (TableMetaType) obj; if (this.getTypeName().equals(other.getTypeName()) == false) return false; if (this.getRowType().equals(other.getRowType()) == false) return false; Iterator thisNames = this.getIndexNames().iterator(); Iterator otherNames = other.getIndexNames().iterator(); while (thisNames.hasNext() && otherNames.hasNext()) { String thisName = thisNames.next(); String otherName = otherNames.next(); if (thisName.equals(otherName) == false) return false; } if (thisNames.hasNext() || otherNames.hasNext()) return false; return true; } @Override public int hashCode() { if (cachedHashCode != Integer.MIN_VALUE) return cachedHashCode; cachedHashCode = getTypeName().hashCode(); cachedHashCode += getRowType().hashCode(); for (Iterator i = indexNames.iterator(); i.hasNext();) cachedHashCode += i.next().hashCode(); return cachedHashCode; } @Override public String toString() { if (cachedToString != null) return cachedToString; StringBuilder buffer = new StringBuilder(getClass().getSimpleName()); buffer.append(": typeName=["); buffer.append(getTypeName()); buffer.append("] rowType=["); buffer.append(getRowType()); buffer.append("] indexNames=["); Iterator thisNames = getIndexNames().iterator(); while(thisNames.hasNext()) { buffer.append(thisNames.next()); if (thisNames.hasNext()) buffer.append(", "); } buffer.append("]"); cachedToString = buffer.toString(); return cachedToString; } } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/types/MetaTypeFactory.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/types/MetaTypeFac0000644000175000017500000000564110761511660033153 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.metatype.api.types; import java.lang.reflect.Type; import org.jboss.metatype.plugins.types.MetaTypeFactoryBuilder; import org.jboss.metatype.spi.types.MetaTypeBuilder; import org.jboss.reflect.spi.TypeInfo; /** * MetaTypeFactory. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public abstract class MetaTypeFactory { /** The singleton builder */ private static final MetaTypeFactoryBuilder builder = new MetaTypeFactoryBuilder(); /** * Get the metatype factory * * @return the instance */ public static final MetaTypeFactory getInstance() { return builder.create(); } /** * Resolve a metatype * * @param type the type * @return the metatype * @throws IllegalArgumentException for a null type */ public abstract MetaType resolve(Type type); /** * Resolve a metatype * * @param type the type * @return the metatype * @throws IllegalArgumentException for a null type */ public abstract MetaType resolve(TypeInfo type); /** * Resolve a metatype * * @param className the class name * @param classLoader the classloader * @return the metatype * @throws IllegalArgumentException for a null className or classloader * @throws ClassNotFoundException when the class is not found */ public MetaType resolve(String className, ClassLoader classLoader) throws ClassNotFoundException { if (className == null) throw new IllegalArgumentException("Null className"); if (classLoader == null) throw new IllegalArgumentException("Null classLoader"); Class clazz = Class.forName(className, false, classLoader); return resolve(clazz); } /** * Set a meta type builder * * @param clazz the class * @param builder the builder */ public abstract void setBuilder(Class clazz, MetaTypeBuilder builder); } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/types/MetaType.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/types/MetaType.ja0000644000175000017500000001147310761511660033132 0ustar twernertwerner/* * 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.types; import java.io.Serializable; import java.math.BigDecimal; import java.math.BigInteger; import java.util.Arrays; import java.util.Collections; import java.util.Date; import java.util.List; import org.jboss.metatype.api.values.ArrayValue; import org.jboss.metatype.api.values.CompositeValue; import org.jboss.metatype.api.values.EnumValue; import org.jboss.metatype.api.values.GenericValue; import org.jboss.metatype.api.values.SimpleValue; import org.jboss.metatype.api.values.TableValue; /** * MetaType. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public interface MetaType extends Serializable { /** * The allowed classnames.

* * One of
* java.lang.Void
* java.lang.Boolean
* java.lang.Character
* java.lang.Byte
* java.lang.Short
* java.lang.Integer
* java.lang.Long
* java.lang.Float
* java.lang.Double
* java.lang.String
* java.lang.Date
* java.math.BigDecimal
* java.math.BigInteger
* {@link Name}
* {@link SimpleValue}
* {@link EnumValue}
* {@link GenericValue}
* {@link ArrayValue}
* {@link CompositeValue}
* {@link TableValue} */ List ALLOWED_CLASSNAMES = Collections.unmodifiableList(Arrays.asList(new String[] { Void.class.getName(), Boolean.class.getName(), Character.class.getName(), Byte.class.getName(), Short.class.getName(), Integer.class.getName(), Long.class.getName(), Float.class.getName(), Double.class.getName(), String.class.getName(), Date.class.getName(), BigDecimal.class.getName(), BigInteger.class.getName(), Name.class.getName(), SimpleValue.class.getName(), EnumValue.class.getName(), GenericValue.class.getName(), ArrayValue.class.getName(), CompositeValue.class.getName(), TableValue.class.getName() })); /** * Retrieve the class name of the values of this meta * type. It is one of those listed in ALLOWED_CLASSNAMES or * a (multi-dimensional) array of one of those classes. * * @return the class name */ String getClassName(); /** * Retrieve the name of the meta type * * @return the type name */ String getTypeName(); /** * Retrieve the description of the type * * @return the description */ String getDescription(); /** * Retrieve whether the class name of the type is an array * * @return true when it is an array or false otherwise */ boolean isArray(); /** * Retrieve whether the class name of the type is a collection * * @return true when it is a collection or false otherwise */ boolean isCollection(); /** * Retrieve whether the class name of the type is an enum * * @return true when it is an enum or false otherwise */ boolean isEnum(); /** * Retrieve whether the class name of the type is simple * * @return true when it is simple or false otherwise */ boolean isSimple(); /** * Retrieve whether the class name of the type is generic * * @return true when it is generic or false otherwise */ boolean isGeneric(); /** * Retrieve whether the class name of the type is composite * * @return true when it is composite or false otherwise */ boolean isComposite(); /** * Retrieve whether the class name of the type is a table * * @return true when it is a table or false otherwise */ boolean isTable(); /** * Whether the passed value is one of those described by this meta type. * * @param obj the object to test * @return true when it is value for this meta type, false otherwise */ boolean isValue(Object obj); } libjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/types/Name.java0000644000175000017500000000243010654162370032603 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, Red Hat Middleware LLC, and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.metatype.api.types; import java.io.Serializable; /** * A name is a typed string representing a reference to * an object. * * @author Scott.Stark@jboss.org * @version $Revision: 64409 $ */ public interface Name extends Serializable { public String toString(); } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/types/TableMetaType.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/types/TableMetaTy0000644000175000017500000000276210761511660033165 0ustar twernertwerner/* * 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.types; import java.util.List; /** * TableMetaType. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public interface TableMetaType extends MetaType { /** * Retrieve the row type * * @return the row type */ CompositeMetaType getRowType(); /** * Retrieve an unmodifiable list of index names in the same order as * passed to the constructor. * * @return the index names */ List getIndexNames(); } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/types/SimpleMetaType.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/types/SimpleMetaT0000644000175000017500000001705310761511660033175 0ustar twernertwerner/* * 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.types; import java.io.ObjectStreamException; import java.math.BigDecimal; import java.math.BigInteger; import java.util.Date; import org.jboss.metatype.api.values.SimpleValue; /** * SimpleMetaType. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class SimpleMetaType extends AbstractMetaType { /** The serialVersionUID */ private static final long serialVersionUID = 6786422588217893696L; /** Cached hash code */ private transient int cachedHashCode; /** Cached string representation */ private transient String cachedToString; /** The simple type for java.math.BigDecimal */ public static final SimpleMetaType BIGDECIMAL; /** The simple type for java.math.BigInteger */ public static final SimpleMetaType BIGINTEGER; /** The simple type for java.lang.Boolean */ public static final SimpleMetaType BOOLEAN; /** The simple type for java.lang.Byte */ public static final SimpleMetaType BYTE; /** The simple type for java.lang.Character */ public static final SimpleMetaType CHARACTER; /** The simple type for java.lang.Date */ public static final SimpleMetaType DATE; /** The simple type for java.lang.Double */ public static final SimpleMetaType DOUBLE; /** The simple type for java.lang.Float */ public static final SimpleMetaType FLOAT; /** The simple type for java.lang.Integer */ public static final SimpleMetaType INTEGER; /** The simple type for java.lang.Long */ public static final SimpleMetaType LONG; /** The simple type for java.lang.Short */ public static final SimpleMetaType SHORT; /** The simple type for java.lang.String */ public static final SimpleMetaType STRING; /** The simple type for an object name */ public static final SimpleMetaType NAMEDOBJECT; /** The simple type for java.lang.Void */ public static final SimpleMetaType VOID; static { BIGDECIMAL = new SimpleMetaType(BigDecimal.class.getName()); BIGINTEGER = new SimpleMetaType(BigInteger.class.getName()); BOOLEAN = new SimpleMetaType(Boolean.class.getName()); BYTE = new SimpleMetaType(Byte.class.getName()); CHARACTER = new SimpleMetaType(Character.class.getName()); DATE = new SimpleMetaType(Date.class.getName()); DOUBLE = new SimpleMetaType(Double.class.getName()); FLOAT = new SimpleMetaType(Float.class.getName()); INTEGER = new SimpleMetaType(Integer.class.getName()); LONG = new SimpleMetaType(Long.class.getName()); SHORT = new SimpleMetaType(Short.class.getName()); STRING = new SimpleMetaType(String.class.getName()); NAMEDOBJECT = new SimpleMetaType(Name.class.getName()); VOID = new SimpleMetaType(Void.class.getName()); } /** * Resolve a simple type * * @param className the class name of the simple type * @return the simple type * @throws IllegalArgumentException for a null className or if it is not a simple type */ public static SimpleMetaType resolve(String className) { SimpleMetaType result = isSimpleType(className); if (result != null) return result; throw new IllegalArgumentException("Class is not a simple type: " + className); } /** * Return the simple type if the class name is a simple type * otherwise null. * * @param className the class name of the simple type * @return the simple type * @throws IllegalArgumentException for a null className */ public static SimpleMetaType isSimpleType(String className) { if (className == null) throw new IllegalArgumentException("Null class name"); if (className.equals(STRING.getClassName())) return STRING; if (className.equals(INTEGER.getClassName()) || className.equals(Integer.TYPE.getName())) return INTEGER; if (className.equals(BOOLEAN.getClassName()) || className.equals(Boolean.TYPE.getName())) return BOOLEAN; if (className.equals(LONG.getClassName()) || className.equals(Long.TYPE.getName())) return LONG; if (className.equals(BYTE.getClassName()) || className.equals(Byte.TYPE.getName())) return BYTE; if (className.equals(CHARACTER.getClassName()) || className.equals(Character.TYPE.getName())) return CHARACTER; if (className.equals(DOUBLE.getClassName()) || className.equals(Double.TYPE.getName())) return DOUBLE; if (className.equals(FLOAT.getClassName()) || className.equals(Float.TYPE.getName())) return FLOAT; if (className.equals(SHORT.getClassName()) || className.equals(Short.TYPE.getName())) return SHORT; if (className.equals(BIGDECIMAL.getClassName())) return BIGDECIMAL; if (className.equals(BIGINTEGER.getClassName())) return BIGINTEGER; if (className.equals(VOID.getClassName()) || className.equals(Void.TYPE.getName())) return VOID; if (className.equals(DATE.getClassName())) return DATE; if (className.equals(NAMEDOBJECT.getClassName())) return NAMEDOBJECT; return null; } /** * Construct an SimpleMetaType.

* * This constructor is used to construct the static simple meta types. * * @param className the name of the class implementing the type */ private SimpleMetaType(String className) { super(className); cachedHashCode = getClassName().hashCode(); StringBuilder buffer = new StringBuilder(SimpleMetaType.class.getSimpleName()); buffer.append(":"); buffer.append(getClassName()); cachedToString = buffer.toString(); } @Override public boolean isSimple() { return true; } @Override public boolean isValue(Object obj) { if (obj == null || obj instanceof SimpleValue == false) return false; SimpleValue value = (SimpleValue) obj; return equals(value.getMetaType()); } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null || obj instanceof SimpleMetaType == false) return false; SimpleMetaType other = (SimpleMetaType) obj; return getClassName().equals(other.getClassName()); } @Override public int hashCode() { return cachedHashCode; } @Override public String toString() { return cachedToString; } /** * Resolve to the singletons * @return the singletons * @throws ObjectStreamException for a corrupted stream */ private Object readResolve() throws ObjectStreamException { return resolve(getClassName()); } } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/types/CollectionMetaType.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/types/CollectionM0000644000175000017500000001141210761511660033212 0ustar twernertwerner/* * 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.types; import java.util.Collection; import org.jboss.metatype.api.values.CollectionValue; /** * CollectionMetaType. * * @author Ales Justin * @author Adrian Brock */ public class CollectionMetaType extends AbstractMetaType { /** The serialVersionUID */ private static final long serialVersionUID = -2062790692152055156L; /** The element type for the array */ private MetaType elementType; /** Cached hash code */ private transient int cachedHashCode = Integer.MIN_VALUE; /** Cached string representation */ private transient String cachedToString = null; public CollectionMetaType(String className, MetaType elementType) { super(className); if (elementType == null) throw new IllegalArgumentException("Null element type"); this.elementType = elementType; } public CollectionMetaType(String className, String description, MetaType elementType) { super(className, description); if (elementType == null) throw new IllegalArgumentException("Null element type"); this.elementType = elementType; } public CollectionMetaType(String className, String typeName, String description, MetaType elementType) { super(className, typeName, description); if (elementType == null) throw new IllegalArgumentException("Null element type"); this.elementType = elementType; } public boolean isCollection() { return true; } /** * Get collection meta type. * * @param collectionType the element meta type * @param elementType the element meta type * @return collection meta type */ public static CollectionMetaType getCollectionType(String collectionType, MetaType elementType) { return new CollectionMetaType(collectionType, elementType); } /** * Get the meta type of the array elements * * @return the element type */ public MetaType getElementType() { return elementType; } @Override @SuppressWarnings("unchecked") public boolean isValue(Object obj) { if (obj == null) return false; if (obj instanceof Collection == false && (obj instanceof CollectionValue) == false) return false; if (obj instanceof CollectionValue) { CollectionValue cv = (CollectionValue)obj; return equals(cv.getMetaType()); } Collection collection = (Collection)obj; for(Object element : collection) { if (elementType.isValue(element) == false) return false; } return true; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null || obj instanceof CollectionMetaType == false) return false; CollectionMetaType other = (CollectionMetaType) obj; return getTypeName().equals(other.getTypeName()) && getElementType().equals(other.getElementType()); } @Override public int hashCode() { if (cachedHashCode != Integer.MIN_VALUE) return cachedHashCode; cachedHashCode = getTypeName().hashCode() + getElementType().hashCode(); return cachedHashCode; } @Override public String toString() { if (cachedToString != null) return cachedToString; StringBuilder buffer = new StringBuilder(CollectionMetaType.class.getSimpleName()); buffer.append("{type="); buffer.append(getTypeName()); buffer.append(" elementType="); buffer.append(elementType); cachedToString = buffer.toString(); return cachedToString; } } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/types/GenericMetaType.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/types/GenericMeta0000644000175000017500000000471410761511660033174 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.metatype.api.types; import org.jboss.metatype.api.values.GenericValue; /** * GenericMetaType.

* * This type allows objects that otherwise wouldn't otherwise be metatypes * to be passed as is inside the type system. Assuming that both * sides understand the value. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class GenericMetaType extends AbstractMetaType { /** The serialVersionUID */ private static final long serialVersionUID = 6783554622082477064L; /** * Create a new GenericMetaType. * * @param typeName the type name * @param description the description */ public GenericMetaType(String typeName, String description) { super(GenericValue.class.getName(), typeName, description); } @Override public boolean isGeneric() { return true; } @Override public boolean isValue(Object obj) { if (obj == null || obj instanceof GenericValue == false) return false; // TODO some other check, e.g. typeName? return true; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null || obj instanceof GenericMetaType == false) return false; GenericMetaType other = (GenericMetaType) obj; return getTypeName().equals(other.getTypeName()); } @Override public String toString() { return "GenericMetaType:" + getTypeName(); } } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/types/ArrayMetaType.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/types/ArrayMetaTy0000644000175000017500000003323610761511660033214 0ustar twernertwerner/* * 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.types; import org.jboss.metatype.api.values.ArrayValue; /** * ArrayMetaType. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class ArrayMetaType extends AbstractMetaType { /** The serialVersionUID */ private static final long serialVersionUID = -2062790692152055156L; /** The number of dimensions in the array */ private int dimension = 0; /** The element type for the array */ private MetaType elementType; /** Is elementType a primative array */ private boolean primitiveArray; /** Cached hash code */ private transient int cachedHashCode = Integer.MIN_VALUE; /** Cached string representation */ private transient String cachedToString = null; private static final int PRIMITIVE_WRAPPER_NAME_INDEX = 0; private static final int PRIMITIVE_TYPE_NAME_INDEX = 1; private static final int PRIMITIVE_TYPE_ENCODING_INDEX = 2; private static final int PRIMITIVE_OPEN_TYPE_INDEX = 3; private static final Object[][] PRIMITIVE_ARRAY_TYPES = { { Boolean.class.getName(), boolean.class.getName(), "Z", SimpleMetaType.BOOLEAN }, { Character.class.getName(), char.class.getName(), "C", SimpleMetaType.CHARACTER }, { Byte.class.getName(), byte.class.getName(), "B", SimpleMetaType.BYTE }, { Short.class.getName(), short.class.getName(), "S", SimpleMetaType.SHORT }, { Integer.class.getName(), int.class.getName(), "I", SimpleMetaType.INTEGER }, { Long.class.getName(), long.class.getName(), "J", SimpleMetaType.LONG }, { Float.class.getName(), float.class.getName(), "F", SimpleMetaType.FLOAT }, { Double.class.getName(), double.class.getName(), "D", SimpleMetaType.DOUBLE } }; /** * Is primitive key. * * @param primitiveKey the key to check * @return true if key is primitive */ public static boolean isPrimitiveEncoding(final String primitiveKey) { for (Object[] typeDescr : PRIMITIVE_ARRAY_TYPES) { if (typeDescr[PRIMITIVE_TYPE_ENCODING_INDEX].equals(primitiveKey)) { return true; } } return false; } /** * Get primitive meta type. * * @param primitiveTypeName primitive type name * @return primitive meta type or null if param is not primitive */ public static SimpleMetaType getPrimitiveMetaType(String primitiveTypeName) { for (Object[] typeDescr : PRIMITIVE_ARRAY_TYPES) { if (primitiveTypeName.equals(typeDescr[PRIMITIVE_TYPE_NAME_INDEX])) return (SimpleMetaType) typeDescr[PRIMITIVE_OPEN_TYPE_INDEX]; } return null; } /** * Get the char encoding string for the type name. * * @param typeName - the primitive wrapper type name * @return char encoding string. */ public static String getPrimitiveEncoding(String typeName) { for (Object[] typeDescr : PRIMITIVE_ARRAY_TYPES) { if (typeName.equals(typeDescr[PRIMITIVE_WRAPPER_NAME_INDEX])) return (String) typeDescr[PRIMITIVE_TYPE_ENCODING_INDEX]; } return null; } /** * Get the char encoding string for the type name. * * @param typeName - the primitive wrapper type name * @return primitive type name string. */ public static String getPrimitiveName(String typeName) { for (Object[] typeDescr : PRIMITIVE_ARRAY_TYPES) { if (typeName.equals(typeDescr[PRIMITIVE_WRAPPER_NAME_INDEX])) return (String) typeDescr[PRIMITIVE_TYPE_NAME_INDEX]; } return null; } /** * Get array meta type. * * @param elementType the element meta type * @return array meta type */ public static ArrayMetaType getArrayType(MetaType elementType) { return new ArrayMetaType(1, elementType); } /** * Get primitive array meta type. * * @param arrayClass array class * @return array meta type */ @SuppressWarnings("unchecked") public static ArrayMetaType getPrimitiveArrayType(Class arrayClass) { if (!arrayClass.isArray()) { throw new IllegalArgumentException("arrayClass must be an array"); } int n = 1; Class componentType = arrayClass.getComponentType(); while (componentType.isArray()) { n++; componentType = componentType.getComponentType(); } String componentTypeName = componentType.getName(); if (!componentType.isPrimitive()) { throw new IllegalArgumentException( "component type of the array must be a primitive type"); } SimpleMetaType simpleType = getPrimitiveMetaType(componentTypeName); // Build primitive array // ArrayMetaType at = new ArrayMetaType(simpleType, true); if (n > 1) at = new ArrayMetaType(n - 1, at); return at; } /** * Generate the class name * * @param dimension the dimension * @param elementType the element type * @param isPrimitive is this a primitive type * @return the class name */ private static String genName(int dimension, MetaType elementType, boolean isPrimitive) { if (dimension < 1) throw new IllegalArgumentException("negative dimension"); if (elementType == null) throw new IllegalArgumentException("null element type"); if (elementType instanceof ArrayMetaType) throw new IllegalArgumentException("array type cannot be an element of an array type"); StringBuilder buffer = new StringBuilder(); for (int i=0; i < dimension; i++) buffer.append('['); if (isPrimitive) { buffer.append(getPrimitiveEncoding(elementType.getClassName())); } else { buffer.append('L'); buffer.append(elementType.getClassName()); buffer.append(';'); } return buffer.toString(); } /** * Generate the type name * * @param dimension the dimension * @param elementType the element type * @param isPrimitive is this a primitive type * @return the type name */ private static String genType(int dimension, MetaType elementType, boolean isPrimitive) { if (dimension < 1) throw new IllegalArgumentException("negative dimension"); if (elementType == null) throw new IllegalArgumentException("null element type"); if (elementType instanceof ArrayMetaType) throw new IllegalArgumentException("array type cannot be an element of an array type"); StringBuilder buffer = new StringBuilder(); for (int i=0; i < dimension; i++) buffer.append('['); if (isPrimitive) { buffer.append(getPrimitiveEncoding(elementType.getClassName())); } else { buffer.append('L'); buffer.append(elementType.getClassName()); buffer.append(';'); } return buffer.toString(); } /** * Generate the description * * @param dimension the dimension * @param elementType the element type * @param isPrimitive is this a primitive type * @return the description */ private static String genDesc(int dimension, MetaType elementType, boolean isPrimitive) { StringBuilder buffer = new StringBuilder(); buffer.append(new Integer(dimension)); buffer.append("-dimension array of "); if (isPrimitive) buffer.append(getPrimitiveName(elementType.getTypeName())); else buffer.append(elementType.getTypeName()); return buffer.toString(); } /** * Construct an ArrayMetaType. * * @param dimension the number of dimensions in the array * @param elementType the open type of the array elements * @throws IllegalArgumentException for a null argument or non-negative dimension or when meta type is an ArrayMetaType */ public ArrayMetaType(int dimension, MetaType elementType) { super(genName(dimension, elementType, false), genType(dimension, elementType, false), genDesc(dimension, elementType, false)); this.dimension = dimension; this.elementType = elementType; this.primitiveArray = false; } /** * Construct an ArrayMetaType. * * @param elementType the element type * @param primitiveArray is primitive array */ public ArrayMetaType(SimpleMetaType elementType, boolean primitiveArray) { this(1, elementType, primitiveArray); } /** * Construct an ArrayMetaType. * * @param dimension the number of dimensions in the array * @param elementType the open type of the array elements * @param primitiveArray is primitive array * @throws IllegalArgumentException for a null argument or non-negative dimension or when meta type is an ArrayMetaType */ public ArrayMetaType(int dimension, MetaType elementType, boolean primitiveArray) { super(genName(dimension, elementType, primitiveArray), genType(dimension, elementType, primitiveArray), genDesc(dimension, elementType, primitiveArray)); this.dimension = dimension; this.elementType = elementType; this.primitiveArray = primitiveArray; } /** * Get the dimension of the array * * @return the dimension */ public int getDimension() { return dimension; } /** * Get the meta type of the array elements * * @return the element type */ public MetaType getElementType() { return elementType; } /** * Is primitive array. * * @return true for primitive array */ public boolean isPrimitiveArray() { return primitiveArray; } @Override @SuppressWarnings("unchecked") public boolean isValue(Object obj) { if (obj == null) return false; Class clazz = obj.getClass(); if (clazz.isArray() == false && (obj instanceof ArrayValue) == false) return false; if (elementType instanceof SimpleMetaType) return recursiveCheck((Object[]) obj, dimension); if (elementType instanceof TableMetaType || elementType instanceof CompositeMetaType) { // If this is an ArrayValue check its MetaType if (obj instanceof ArrayValue) { ArrayValue av = (ArrayValue) obj; return this.equals(av.getMetaType()); } // Check the element classes Class thisClass; try { ClassLoader loader = Thread.currentThread().getContextClassLoader(); thisClass = Class.forName(getClassName(), false, loader); } catch (ClassNotFoundException e) { return false; } if (thisClass.isAssignableFrom(clazz) == false) return false; return recursiveCheck((Object[]) obj, dimension); } return false; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null || obj instanceof ArrayMetaType == false) return false; ArrayMetaType other = (ArrayMetaType) obj; return getDimension() == other.getDimension() && getElementType().equals(other.getElementType()); } @Override public int hashCode() { if (cachedHashCode != Integer.MIN_VALUE) return cachedHashCode; cachedHashCode = getDimension() + getElementType().hashCode(); return cachedHashCode; } @Override public String toString() { if (cachedToString != null) return cachedToString; StringBuilder buffer = new StringBuilder(ArrayMetaType.class.getSimpleName()); buffer.append("{type="); buffer.append(getTypeName()); buffer.append(" dims="); buffer.append(dimension); buffer.append(" elementType="); buffer.append(elementType); cachedToString = buffer.toString(); return cachedToString; } /** * Recursively check array elements * * @param elements the elements * @param dimension the dimension * @return true if elements match, false otherwise */ private boolean recursiveCheck(Object[] elements, int dimension) { // Reached the end if (dimension == 1) { // Check each element is the correct type for (int i = 0; i < elements.length; i++) { if (elements[i] != null && elementType.isValue(elements[i]) == false) return false; } } else { // Check the array element in this array element for (int i = 0; i < elements.length; i++) { if (recursiveCheck((Object[]) elements[i], dimension-1) == false) return false; } } return true; } } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/types/CompositeMetaType.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/types/CompositeMe0000644000175000017500000000417510761511660033236 0ustar twernertwerner/* * 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.types; import java.util.Set; /** * CompositeMetaType. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public interface CompositeMetaType extends MetaType { /** * Determine whether this CompositeMetaType contains the itemName * * @param itemName the item name * @return true when it does, false otherwise */ boolean containsItem(String itemName); /** * Retrieve the description for an item name * * @param itemName the item name * @return the description or null when there is no such item name */ String getDescription(String itemName); /** * Retrieve the meta type for an item name * * @param itemName the item name * @return the open type or null when there is no such item name */ MetaType getType(String itemName); /** * Retrieve an unmodifiable Set view of all the item names in ascending order. * * @return the Set */ Set itemSet(); /** * Retrieve an unmodifiable Set view of all the key names in ascending order. * * @return the Set */ Set keySet(); } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/types/MapCompositeMetaType.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/types/MapComposit0000644000175000017500000000504410764061563033246 0ustar twernertwerner/* * 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 org.jboss.metatype.plugins.types.AbstractCompositeMetaType; /** * A CompositeMetaType for Map * * @author Scott.Stark@jboss.org * @version $Revision: 70518 $ */ public class MapCompositeMetaType extends AbstractCompositeMetaType { private static final long serialVersionUID = 1; private MetaType valueType; /** Cached hash code */ private transient int cachedHashCode = Integer.MIN_VALUE; /** Cached string representation */ private transient String cachedToString = null; /** * Create a MapCompositeMetaType with the given value metatype. * @param valueType the value meta type */ public MapCompositeMetaType(MetaType valueType) { super("java.util.Map", "Map"); this.valueType = valueType; } /** * Access the map value type. * @return the map value type. */ public MetaType getValueType() { return valueType; } /** * * @param itemName */ public void addItem(String itemName) { super.addItem(itemName, itemName, valueType); } @Override public boolean equals(Object obj) { return equalsImpl(obj); } @Override public int hashCode() { if (cachedHashCode != Integer.MIN_VALUE) return cachedHashCode; cachedHashCode = hashCodeImpl(); return cachedHashCode; } @Override public String toString() { if (cachedToString == null) cachedToString = super.toString(); return cachedToString; } } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/types/AbstractMetaType.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/types/AbstractMet0000644000175000017500000002110610761511660033214 0ustar twernertwerner/* * 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.types; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectStreamField; /** * AbstractMetaType. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public abstract class AbstractMetaType implements MetaType { /** The serialVersionUID */ private static final long serialVersionUID = 5786422588217893696L; /** The peristent fields */ private static final ObjectStreamField[] serialPersistentFields = new ObjectStreamField[] { new ObjectStreamField("className", String.class), new ObjectStreamField("description", String.class), new ObjectStreamField("typeName", String.class) }; /** The type's class name */ private String className; // TODO internationalization /** The type's description */ private String description; /** The type's name */ private String typeName; /** Whether the class is an array */ private transient boolean array = false; /** * Construct a new MetaType.

* * The class name must be in {@link #ALLOWED_CLASSNAMES} or an * array of those classes. * * @param className the name of the class implementing the meta type, * cannot be null * @param typeName the name of the meta type, cannot be null * @param description the human readable description of the type, cannot * be null * @throws IllegalArgumentException for a null argument or a class is not an allowed class */ protected AbstractMetaType(String className, String typeName, String description) { init(className, typeName, description); } /** * Construct a new MetaType.

* * The class name must be in {@link #ALLOWED_CLASSNAMES} or an * array of those classes. * * @param className the name of the class implementing the meta type, * cannot be null * @param description the human readable description of the type, cannot * be null * @throws IllegalArgumentException for a null argument or a class is not an allowed class */ protected AbstractMetaType(String className, String description) { init(className, className, description); } /** * Construct a new MetaType. * * The class name must be in {@link #ALLOWED_CLASSNAMES} or an * array of those classes. * * @param className the name of the class implementing the meta type, * cannot be null * @throws IllegalArgumentException for a null argument or a class is not an allowed class */ protected AbstractMetaType(String className) { init(className, className, className); } public String getClassName() { return className; } public String getTypeName() { return typeName; } public String getDescription() { return description; } public boolean isEnum() { return false; } public boolean isComposite() { return false; } public boolean isSimple() { return false; } public boolean isGeneric() { return false; } public boolean isTable() { return false; } public boolean isArray() { return array; } public boolean isCollection() { return false; } public abstract boolean isValue(Object obj); /** * Initialise the object * * @param className the name of the class implementing the meta type, * cannot be null or an empty * @param typeName the name of the meta type, cannot be null or an empty * string * @param description the human readable description of the type, cannot * be null or an empty string * @exception IllegalArgumentException for a null or empty argument or when class name is not allowed class */ private void init(String className, String typeName, String description) { if (className == null || className.trim().equals("")) throw new IllegalArgumentException("null or empty class name"); if (typeName == null || typeName.trim().equals("")) throw new IllegalArgumentException("null or empty type name"); if (description == null || description.trim().equals("")) throw new IllegalArgumentException("null or empty description"); if (isCollection() == false) { // Calculate the underlying class and whether this is an array String testClassName = getBaseClassName(className); if (testClassName == null) throw new IllegalArgumentException("Invalid array declaration (see the javadocs for java.lang.Class): " + className); if (testClassName.equals(className) == false) array = true; // Check the underlying class boolean ok = false; for (int i = 0; i < ALLOWED_CLASSNAMES.size(); i++) { if (testClassName.equals(ALLOWED_CLASSNAMES.get(i))) { ok = true; break; } } if (ok == false) { // Check for a primative array type int index = className.lastIndexOf('['); if (index == className.length()-2) ok = ArrayMetaType.isPrimitiveEncoding(className.substring(index+1)); if (ok == false) throw new IllegalArgumentException("Not a MetaType allowed class name: " + className); } } // Looks ok this.className = className; this.typeName = typeName; this.description = description; } /** * Gets the base class name, either the passed class name * or the underlying class name if it is an array.

* * NOTE: The class is not check for validity.

* * Null is returned when the array declaration is invalid. * * @param className the string to test * @return the underlying class name or null */ private static String getBaseClassName(String className) { final int length = className.length(); final int last = length - 1; int i = 0; // Eat the array dimensions while (i < length && className.charAt(i) == '[') ++i; // It looks like an array if (i > 0) { // But is it valid char type = className.charAt(i); // Primitive array if (type == 'B' || type == 'C' || type == 'D' || type == 'F' || type == 'I' || type == 'J' || type == 'S' || type == 'Z' || type == 'V') { if (i != last) return null; return className.substring(last, length); } // Object Array else if (className.charAt(i) != 'L' || i >= last-1 || className.charAt(last) != ';') return null; // Potentially valid array, class name might be rubbish return className.substring(i+1, last); } // Not an array return className; } /** * Read the object from a stream * * @param in the stream * @throws IOException * @throws ClassNotFoundException */ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { ObjectInputStream.GetField getField = in.readFields(); String className = (String) getField.get("className", null); String typeName = (String) getField.get("typeName", null); String description = (String) getField.get("description", null); try { init(className, typeName, description); } catch (Exception e) { throw new RuntimeException("Unexpected error deserializing MetaType: " + className, e); } } } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/types/EnumMetaType.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/types/EnumMetaTyp0000644000175000017500000000742110761511660033217 0ustar twernertwerner/* * 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.types; import java.util.ArrayList; import java.util.Collections; import java.util.List; import org.jboss.metatype.api.values.SimpleValue; /** * EnumMetaType. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class EnumMetaType extends AbstractMetaType { /** The serialVersionUID */ private static final long serialVersionUID = 6786422588217893696L; /** The valid values */ private List validValues; /** * Create a new EnumMetaType. * * @param className the class name * @param validValues the valid values */ public EnumMetaType(String className, List validValues) { super(String.class.getName(), className, className); if (validValues == null) throw new IllegalArgumentException("Null valid values"); this.validValues = validValues; } /** * Create a new EnumMetaType from the Enum values. * * @param validValues the valid Enum values */ public EnumMetaType(Enum[] validValues) { super( String.class.getName(), isValid(validValues) ? validValues[0].getClass().getName() : null, isValid(validValues) ? validValues[0].getClass().getName() : null ); if (isValid(validValues) == false) throw new IllegalArgumentException("Null or empty valid values"); ArrayList values = new ArrayList(); for (Enum e : validValues) values.add(e.name()); this.validValues = values; } /** * Are enums valid. * * @param values the enums * @return true if not null and not empty */ protected static boolean isValid(Enum[] values) { return values != null && values.length > 0; } /** * Get the valid values * * @return the valid values */ public List getValidValues() { return Collections.unmodifiableList(validValues); } @Override public boolean isEnum() { return true; } @Override public boolean isValue(Object obj) { if (obj == null || obj instanceof SimpleValue == false) return false; SimpleValue value = (SimpleValue) obj; if (SimpleMetaType.STRING == value.getMetaType() == false) return false; return validValues.contains(value.getValue()); } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null || obj instanceof EnumMetaType == false) return false; EnumMetaType other = (EnumMetaType) obj; return getTypeName().equals(other.getTypeName()) && getValidValues().equals(other.getValidValues()); } @Override public String toString() { return getTypeName() + "{" + validValues + "}"; } } libjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/annotations/0000755000175000017500000000000011105402544032242 5ustar twernertwerner././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/annotations/MetaTypeConstants.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/annotations/MetaT0000644000175000017500000000237310757514543033223 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.metatype.api.annotations; /** * MetaTypeConstants. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public interface MetaTypeConstants { /** A default value */ public static final String DEFAULT = "##DEFAULT"; } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/annotations/CompositeValue.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/annotations/Compo0000644000175000017500000000303710757514543033264 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.metatype.api.annotations; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** * CompositeKey. * * @author Adrian Brock * @version $Revision: 1.1 $ */ @Target({ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) public @interface CompositeValue { /** The item name */ String name() default MetaTypeConstants.DEFAULT; /** Whether to ignore this item */ boolean ignore() default false; } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/annotations/MetaMapping.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/annotations/MetaM0000644000175000017500000000304410757641060033203 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.metatype.api.annotations; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import org.jboss.metatype.spi.values.MetaMapper; /** * MetaMapper. * * @author Adrian Brock * @version $Revision: 1.1 $ */ @Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) public @interface MetaMapping { /** * The meta mapper * * @return mapper class */ Class> value(); } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/annotations/CompositeKey.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/annotations/Compo0000644000175000017500000000260710757514543033266 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.metatype.api.annotations; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** * CompositeKey. * * @author Adrian Brock * @version $Revision: 1.1 $ */ @Target({ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) public @interface CompositeKey { } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/annotations/Generic.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/api/annotations/Gener0000644000175000017500000000260410645072106033234 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.metatype.api.annotations; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; /** * Generic. * * @author Adrian Brock * @version $Revision: 1.1 $ */ @Retention(RetentionPolicy.RUNTIME) public @interface Generic { /** * The generic type name * * @return the generic type name */ String type() default ""; } libjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/spi/0000755000175000017500000000000011105402544027727 5ustar twernertwernerlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/spi/values/0000755000175000017500000000000011105402544031226 5ustar twernertwerner././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/spi/values/MetaValueBuilder.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/spi/values/MetaValueB0000644000175000017500000000275710761511660033160 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.metatype.spi.values; import org.jboss.metatype.api.types.MetaType; import org.jboss.metatype.api.values.MetaValue; /** * MetaValueBuilder. * * @param the object type * @author Adrian Brock * @version $Revision: 1.1 $ */ public interface MetaValueBuilder { /** * Build the meta value * * @param metaType the meta type * @param object the object * @return the meta value */ MetaValue buildMetaValue(MetaType metaType, T object); } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/spi/values/MetaMapper.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/spi/values/MetaMapper0000644000175000017500000000756210761511660033225 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.metatype.spi.values; import java.lang.reflect.Type; import org.jboss.metatype.api.annotations.MetaMapping; import org.jboss.metatype.api.types.MetaType; import org.jboss.metatype.api.types.MetaTypeFactory; import org.jboss.metatype.api.values.MetaValue; import org.jboss.reflect.spi.ClassInfo; import org.jboss.reflect.spi.ConstructorInfo; import org.jboss.reflect.spi.TypeInfo; import org.jboss.reflect.spi.TypeInfoFactory; /** * MetaMapper. * * @param the mapped type * @author Adrian Brock * @version $Revision: 1.1 $ */ public abstract class MetaMapper { /** The metatype factory */ private static final MetaTypeFactory metaTypeFactory = MetaTypeFactory.getInstance(); /** * Get a metamapper for a type info * * @param typeInfo the type info * @return the metamapper or null if there isn't one */ public static final MetaMapper getMetaMapper(TypeInfo typeInfo) { if (typeInfo instanceof ClassInfo == false) return null; ClassInfo classInfo = (ClassInfo) typeInfo; MetaMapper mapper = typeInfo.getAttachment(MetaMapper.class); if (mapper != null) return mapper; MetaMapping mapping = classInfo.getUnderlyingAnnotation(MetaMapping.class); if (mapping == null) return null; try { TypeInfoFactory factory = classInfo.getTypeInfoFactory(); ClassInfo mapperClass = (ClassInfo) factory.getTypeInfo(mapping.value()); ConstructorInfo constructor = mapperClass.getDeclaredConstructor(null); mapper = (MetaMapper) constructor.newInstance(null); typeInfo.setAttachment(MetaMapper.class.getName(), mapper); return mapper; } catch (Error e) { throw e; } catch (RuntimeException e) { throw e; } catch (Throwable t) { throw new RuntimeException("Error creating MetaMapper " + mapping + " for " + typeInfo.getName()); } } /** * Override this method to map to a specific type * * @return the type */ public Type mapToType() { return null; } /** * Override this method to create your own metatype * * @return the metatype */ public MetaType getMetaType() { Type type = mapToType(); if (type == null) throw new IllegalStateException("You haven't overridden getMetaType() or mapToType()"); return metaTypeFactory.resolve(type); } /** * Create the meta value * * @param metaType the metatype * @param object the object * @return the meta value */ public abstract MetaValue createMetaValue(MetaType metaType, T object); /** * Unwrap the metavalue * * @param metaValue the meta value * @return the object */ public abstract T unwrapMetaValue(MetaValue metaValue); } libjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/spi/types/0000755000175000017500000000000011105402544031073 5ustar twernertwerner././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/spi/types/MetaTypeBuilder.javalibjboss-managed-java-2.0.0.CR4.orig/metatype/src/main/java/org/jboss/metatype/spi/types/MetaTypeBui0000644000175000017500000000247110761511660033221 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.metatype.spi.types; import org.jboss.metatype.api.types.MetaType; /** * MetaTypeBuilder. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public interface MetaTypeBuilder { /** * Build the meta type * * @return the meta type */ MetaType buildMetaType(); } libjboss-managed-java-2.0.0.CR4.orig/metatype/.settings/0000755000175000017500000000000011105402544022657 5ustar twernertwernerlibjboss-managed-java-2.0.0.CR4.orig/metatype/.settings/org.eclipse.jdt.core.prefs0000644000175000017500000000032010674774740027660 0ustar twernertwerner#Fri Sep 21 17:48:56 BST 2007 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.source=1.5 org.eclipse.jdt.core.compiler.compliance=1.5 libjboss-managed-java-2.0.0.CR4.orig/metatype/pom.xml0000644000175000017500000000415011104141463022255 0ustar twernertwerner org.jboss.man jboss-man 2.0.0.CR4 4.0.0 jboss-metatype jar JBoss Metatype http://www.jboss.com/products/jbossmc JBoss Metatype org.apache.maven.plugins maven-surefire-plugin true org.jboss jboss-reflect org.jboss jboss-common-core org.jboss.logging jboss-logging-spi org.jboss.logging jboss-logging-spi org.jboss jboss-common-core org.jboss.logging jboss-logging-log4j test org.jboss.test jboss-test test junit junit test libjboss-managed-java-2.0.0.CR4.orig/managed/0000755000175000017500000000000011105402551020503 5ustar twernertwernerlibjboss-managed-java-2.0.0.CR4.orig/managed/pom-jdk14.xml0000644000175000017500000001401510764372266022757 0ustar twernertwerner org.jboss.microcontainer-jdk14 jboss-microcontainer-jdk14 2.0.0-SNAPSHOT ../build/pom-jdk14.xml 4.0.0 jboss-managed-jdk14 jar JBoss Microcontainer Managed JDK 1.4 http://www.jboss.com/products/jbossmc JBoss Microcontainer Managed org.jboss.maven.plugins maven-jboss-retro-plugin 1.0-beta-1 weave-classes weave ${project.build.directory}/classes-jdk14 weave-test-classes weave-tests ${project.build.directory}/test-classes-jdk14 org.jboss.weaver.retro.WeaverRetroJdk14 org.apache.maven.plugins maven-jar-plugin 2.1 ${project.build.directory}/classes-jdk14 org.apache.maven.plugins maven-surefire-plugin true run-jdk14-tests target/classes-jdk14 target/test-classes-jdk14 org.apache.maven.plugins maven-enforcer-plugin 1.0-alpha-3 enforce-jdk14-property enforce-once java14_home The property java14_home should be set to a valid installation of jdk1.4. The jdk14 tests cannot be run without this property. org.apache.maven.plugins maven-surefire-plugin ${java14_home}/bin/java always false true true true ${project.build.directory}/surefire-reports-jdk14 **/*TestCase.java org.jboss.aop-jdk14 jboss-aop-jdk14 org.jboss.reflect jboss-reflect-jdk14 org.jboss.microcontainer-jdk14 jboss-metatype-jdk14 org.jboss jboss-common-logging-spi-jdk14 org.jboss jboss-test-jdk14 junit junit libjboss-managed-java-2.0.0.CR4.orig/managed/.classpath0000644000175000017500000000557511104137625022510 0ustar twernertwerner libjboss-managed-java-2.0.0.CR4.orig/managed/.project0000644000175000017500000000056110770625662022175 0ustar twernertwerner jboss-managed JBoss Managed jboss-metatype org.eclipse.jdt.core.javabuilder org.eclipse.jdt.core.javanature libjboss-managed-java-2.0.0.CR4.orig/managed/src/0000755000175000017500000000000011105402547021277 5ustar twernertwernerlibjboss-managed-java-2.0.0.CR4.orig/managed/src/assembly/0000755000175000017500000000000011105402544023113 5ustar twernertwernerlibjboss-managed-java-2.0.0.CR4.orig/managed/src/assembly/plugins.xml0000644000175000017500000000057710761571174025344 0ustar twernertwerner plugins jar false target/classes org/jboss/managed/plugins/** libjboss-managed-java-2.0.0.CR4.orig/managed/src/assembly/api.xml0000644000175000017500000000056710600557226024425 0ustar twernertwerner api jar false target/classes org/jboss/managed/api/** libjboss-managed-java-2.0.0.CR4.orig/managed/src/test/0000755000175000017500000000000011105402545022254 5ustar twernertwernerlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/0000755000175000017500000000000011105402544023174 5ustar twernertwernerlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/0000755000175000017500000000000011105402544023763 5ustar twernertwernerlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/0000755000175000017500000000000011105402544025103 5ustar twernertwernerlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/0000755000175000017500000000000011105402544026062 5ustar twernertwernerlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/0000755000175000017500000000000011105402545027457 5ustar twernertwernerlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/0000755000175000017500000000000011105402544031125 5ustar twernertwernerlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/test/0000755000175000017500000000000011105402544032104 5ustar twernertwerner././@LongLink0000000000000000000000000000020700000000000011564 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/test/DeploymentTemplateInfoUnitTestCase.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/test/Deplo0000644000175000017500000000636010763656725033124 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.managed.factory.test; import junit.framework.Test; import org.jboss.managed.api.DeploymentTemplateInfo; import org.jboss.managed.api.ManagedObject; import org.jboss.managed.plugins.factory.DeploymentTemplateInfoFactory; import org.jboss.test.managed.factory.AbstractManagedObjectFactoryTest; import org.jboss.test.managed.factory.support.template.ManagementObjectExplicit; /** * DeploymentTemplateInfo factory tests. * * @author Scott.Stark@jboss.org * @version $Revision: 70458 $ */ public class DeploymentTemplateInfoUnitTestCase extends AbstractManagedObjectFactoryTest { /** * Create a testsuite for this test * * @return the testsuite */ public static Test suite() { return suite(DeploymentTemplateInfoUnitTestCase.class); } /** * Create a new DeploymentTemplateInfoUnitTestCase. * * @param name the test name */ public DeploymentTemplateInfoUnitTestCase(String name) { super(name); } /** * Test Explicit properties included */ public void testExplicit() { ManagedObject managedObject = createManagedObject(ManagementObjectExplicit.class); checkManagedObjectDefaults(ManagementObjectExplicit.class, managedObject); checkManagedProperties(managedObject, "property1"); DeploymentTemplateInfoFactory factory = new DeploymentTemplateInfoFactory(); DeploymentTemplateInfo info = factory.createTemplateInfo(managedObject, "testExplicit", "testExplicit"); log.info(info); assertEquals("testExplicit", info.getName()); assertEquals("testExplicit", info.getDescription()); assertTrue("property1 is in template info", info.getProperties().containsKey("property1")); } public void testReflectionOfExplicit() throws Exception { DeploymentTemplateInfoFactory factory = new DeploymentTemplateInfoFactory(); DeploymentTemplateInfo info = factory.createTemplateInfo(ManagementObjectExplicit.class, "testReflectionOfExplicit", "testReflectionOfExplicit"); log.info(info); assertEquals("testReflectionOfExplicit", info.getName()); assertEquals("testReflectionOfExplicit", info.getDescription()); assertTrue("property1 is in template info", info.getProperties().containsKey("property1")); } }././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/test/ManagementObjectUnitTestCase.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/test/Manag0000644000175000017500000000410710645072106033061 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.managed.factory.test; import junit.framework.Test; import org.jboss.managed.api.ManagedObject; import org.jboss.test.managed.factory.AbstractManagedObjectFactoryTest; import org.jboss.test.managed.factory.support.ManagementObjectChangedName; /** * ManagementObjectUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class ManagementObjectUnitTestCase extends AbstractManagedObjectFactoryTest { /** * Create a testsuite for this test * * @return the testsuite */ public static Test suite() { return suite(ManagementObjectUnitTestCase.class); } /** * Create a new ManagementObjectUnitTestCase. * * @param name the test name */ public ManagementObjectUnitTestCase(String name) { super(name); } /** * Test the changed name */ public void testChangedName() { ManagedObject managedObject = createManagedObject(ManagementObjectChangedName.class); checkManagedObject(ManagementObjectChangedName.class, managedObject, "changed", null); } }././@LongLink0000000000000000000000000000021500000000000011563 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/test/AbstractManagedObjectFactoryUnitTestCase.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/test/Abstr0000644000175000017500000004710511104137625033115 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.managed.factory.test; import java.lang.annotation.Annotation; import java.math.BigDecimal; import java.net.URL; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Map; import junit.framework.Test; import junit.framework.TestSuite; import org.jboss.annotation.factory.AnnotationCreator; import org.jboss.managed.api.ManagedObject; import org.jboss.managed.api.ManagedProperty; import org.jboss.managed.api.annotation.ManagementComponent; import org.jboss.managed.api.annotation.ManagementObject; import org.jboss.managed.api.factory.ManagedObjectFactory; import org.jboss.managed.plugins.factory.AbstractInstanceClassFactory; import org.jboss.managed.plugins.factory.AbstractManagedObjectFactory; import org.jboss.managed.plugins.factory.DefaultInstanceClassFactory; import org.jboss.managed.spi.factory.InstanceClassFactory; import org.jboss.metadata.plugins.loader.memory.MemoryMetaDataLoader; import org.jboss.metadata.spi.MetaData; import org.jboss.metadata.spi.retrieval.MetaDataRetrievalToMetaDataBridge; import org.jboss.metatype.api.values.CollectionValue; import org.jboss.metatype.api.values.GenericValue; import org.jboss.metatype.api.values.MetaValue; import org.jboss.metatype.api.values.SimpleValueSupport; import org.jboss.test.managed.factory.AbstractManagedObjectFactoryTest; import org.jboss.test.managed.factory.support.ManagementObjectChangedName; import org.jboss.test.managed.factory.support.ManagementPropertySimpleManaged; import org.jboss.test.managed.factory.support.Simple; import org.jboss.test.managed.factory.support.SimpleUnannotated; import org.jboss.test.managed.factory.support.amof.CustomName; import org.jboss.test.managed.factory.support.amof.ManagementObjectWithRuntimeRef; import org.jboss.test.managed.factory.support.amof.ManagementObjectWithRuntimeRefICF; import org.jboss.test.managed.factory.support.amof.TestICF; import org.jboss.test.managed.factory.support.amof.TestMOP; import org.jboss.test.managed.factory.support.amof.TestSimpleICF; import org.jboss.test.managed.factory.support.beans.ABeanMetaData; import org.jboss.test.managed.factory.support.beans.AKernelDeployment; import org.jboss.test.managed.factory.support.beans.BeanMetaDataICF; import org.jboss.test.managed.factory.support.beans.IBeanMetaData; import org.jboss.test.managed.factory.support.beans.IBeanMetaDataFactory; import org.jboss.test.managed.factory.support.deployment.JmsDestination; import org.jboss.test.managed.factory.support.deployment.JmsDestinationICF; import org.jboss.test.managed.factory.support.deployment.JmsDestinations; import org.jboss.test.managed.factory.support.deployment.QueueDestination; import org.jboss.test.managed.factory.support.deployment.SecurityDomain; import org.jboss.test.managed.factory.support.mcf.DBMSMetaData; import org.jboss.test.managed.factory.support.mcf.DataSourceConnectionPropertyMetaData; import org.jboss.test.managed.factory.support.mcf.LocalDSInstanceClassFactory; import org.jboss.test.managed.factory.support.mcf.LocalDataSourceDeploymentMetaData; import org.jboss.test.managed.factory.support.mcf.ManagedConnectionFactoryDeploymentGroup; import org.jboss.test.managed.factory.support.mcf.ManagedConnectionFactoryDeploymentMetaData; import org.jboss.test.managed.factory.support.mcf.NoTxConnectionFactoryDeploymentMetaData; import org.jboss.test.managed.factory.support.mcf.NoTxICF; import org.jboss.test.managed.factory.support.mcf.SecurityMetaData; /** * Test of behavior of the AbstractManagedObjectFactory * * @author Scott.Stark@jboss.org * @version $Revision: 80522 $ */ public class AbstractManagedObjectFactoryUnitTestCase extends AbstractManagedObjectFactoryTest { private ManagedObjectFactory testMOF; public static Test suite() { return new TestSuite(AbstractManagedObjectFactoryUnitTestCase.class); } public AbstractManagedObjectFactoryUnitTestCase(String name) { super(name); } /** * Test overriding the AbstractManagedObjectFactory.defaultInstanceFactory */ public void testDefaultInstanceFactory() { AbstractManagedObjectFactory mof = new AbstractManagedObjectFactory(); mof.setDefaultInstanceFactory(new TestICF()); TestSimpleICF icf = new TestSimpleICF(); mof.setInstanceClassFactory(Simple.class, icf); testMOF = mof; BigDecimal bigDecimal = new BigDecimal(10); Simple simple = new Simple(); simple.setBigDecimalValue(bigDecimal); ManagedObject managedObject = initManagedObject(simple); checkManagedObjectDefaults(Simple.class, managedObject); checkDefaultManagedProperties(managedObject, Simple.class); checkPropertyDefaults(managedObject, "bigDecimalValue", BigDecimal.class, bigDecimal); assertTrue("TestBigDecimalICF.isGetValueCalled", icf.isGetValueCalled()); // managedObject = super.createManagedObject(ManagementPropertySimpleManaged.class); checkManagedObjectDefaults(ManagementPropertySimpleManaged.class, managedObject); checkDefaultManagedProperties(managedObject, ManagementPropertySimpleManaged.class); } /** * Test that the setDefaultManagedObjectPopulator overrides the MOF * default ManagedObjectPopulator */ public void testDefaultManagedObjectPopulator() { AbstractManagedObjectFactory mof = new AbstractManagedObjectFactory(); TestMOP mop = new TestMOP(mof.getConfiguration(), new TestSimpleICF(), mof.getInstanceFactories()); mof.setDefaultManagedObjectPopulator(mop); testMOF = mof; BigDecimal bigDecimal = new BigDecimal(10); Simple simple = new Simple(); simple.setBigDecimalValue(bigDecimal); ManagedObject managedObject = initManagedObject(simple); checkManagedObjectDefaults(Simple.class, managedObject); checkDefaultManagedProperties(managedObject, Simple.class); checkPropertyDefaults(managedObject, "bigDecimalValue", BigDecimal.class, bigDecimal); assertTrue("isPopulateManagedObjectCalled", mop.isPopulateManagedObjectCalled()); // managedObject = createManagedObject(ManagementPropertySimpleManaged.class); checkManagedObjectDefaults(ManagementPropertySimpleManaged.class, managedObject); checkDefaultManagedProperties(managedObject, ManagementPropertySimpleManaged.class); assertTrue("isCreateObjectCalled", mop.isCreateObjectCalled()); } public void testInstanceClassFactoryAddition() { AbstractManagedObjectFactory mof = new AbstractManagedObjectFactory(); testMOF = mof; BeanMetaDataICF bicf = new BeanMetaDataICF(); mof.addInstanceClassFactory(bicf); LocalDSInstanceClassFactory dsicf = new LocalDSInstanceClassFactory(); mof.addInstanceClassFactory(dsicf); NoTxICF nticf = new NoTxICF(); mof.addInstanceClassFactory(nticf); InstanceClassFactory icf = mof.getInstanceClassFactory(IBeanMetaData.class); assertEquals("IBeanMetaData ICF", bicf, icf); icf = mof.getInstanceClassFactory(LocalDataSourceDeploymentMetaData.class); assertEquals("LocalDataSourceDeploymentMetaData ICF", dsicf, icf); icf = mof.getInstanceClassFactory(NoTxConnectionFactoryDeploymentMetaData.class); assertEquals("NoTxConnectionFactoryDeploymentMetaData ICF", nticf, icf); } /** * Test that the MetaData repository annotations override/augment the class * annotations. */ public void testMetaDataRepositoryOverride() throws Exception { MemoryMetaDataLoader memory = new MemoryMetaDataLoader(); String annotationExpr = "@org.jboss.managed.api.annotation.ManagementObject(name=\"testMetaDataRepositoryOverride\",componentType=@org.jboss.managed.api.annotation.ManagementComponent(type=\"MCBean\", subtype=\"MetaDataTest\"))"; ManagementObject override = (ManagementObject) AnnotationCreator.createAnnotation(annotationExpr, ManagementObject.class); memory.addAnnotation(override); MetaData metaData = new MetaDataRetrievalToMetaDataBridge(memory); BigDecimal bigDecimal = new BigDecimal(10); SimpleUnannotated simple = new SimpleUnannotated(); simple.setBigDecimalValue(bigDecimal); ManagedObjectFactory mof = getMOF(); ManagedObject managedObject = mof.initManagedObject(simple, metaData); assertEquals("testMetaDataRepositoryOverride", managedObject.getName()); Map moAnnotations = managedObject.getAnnotations(); assertEquals("MO annotations == 2;", 2, moAnnotations.size()); ManagementObject moAnn = (ManagementObject) moAnnotations.get(ManagementObject.class.getName()); ManagementComponent componentType = moAnn.componentType(); assertEquals("componentType.type", "MCBean", componentType.type()); assertEquals("componentType.subtype", "MetaDataTest", componentType.subtype()); checkPropertyDefaults(managedObject, "bigDecimalValue", BigDecimal.class, bigDecimal); checkDefaultManagedProperties(managedObject, SimpleUnannotated.class); } @SuppressWarnings("unchecked") public void testGenericValueUpdate() { super.enableTrace("org.jboss.managed"); AbstractManagedObjectFactory mof = new AbstractManagedObjectFactory(); mof.setInstanceClassFactory(JmsDestination.class, new JmsDestinationICF(mof)); testMOF = mof; JmsDestinations destinations = new JmsDestinations(); List queues = new ArrayList(); QueueDestination q1 = new QueueDestination(); q1.setJndiName("queues/Q1"); q1.setDomain(new SecurityDomain("java:/jaas/JMS")); queues.add(q1); destinations.setDestinations(queues); ManagedObject managedObject = initManagedObject(destinations); checkManagedObjectDefaults(JmsDestinations.class, managedObject); ManagedProperty destinationsMP = managedObject.getProperty("destinations"); assertNotNull(destinationsMP); CollectionValue destinationsValue = (CollectionValue) destinationsMP.getValue(); assertNotNull(destinationsValue); assertEquals(1, destinationsValue.getSize()); GenericValue q1GV = (GenericValue) destinationsValue.getElements()[0]; assertNotNull(q1GV); ManagedObject q1MO = (ManagedObject) q1GV.getValue(); assertNotNull(q1MO); ManagedProperty domain = q1MO.getProperty("domain"); getLog().info(domain); GenericValue domainGV = (GenericValue) domain.getValue(); assertNotNull(domainGV); ManagedObject domainMO = (ManagedObject) domainGV.getValue(); assertNotNull(domainMO); ManagedProperty domainName = domainMO.getProperty("domain"); assertEquals(SimpleValueSupport.wrap("java:/jaas/JMS"), domainName.getValue()); ManagedObject domainUpdateMO = initManagedObject(new SecurityDomain("java:/jaas/JMS2")); DefaultInstanceClassFactory icf = new DefaultInstanceClassFactory(mof); GenericValue domainUpdateGV = icf.getManagedObjectValue(domain, domainUpdateMO); assertNotNull(domainUpdateGV.getValue()); domain.setValue(domainUpdateGV); // Validate this has been written through assertEquals("java:/jaas/JMS2", q1.getDomain().getDomain()); } /** * Test the transformer value of the ManagementRuntimeRef annotation when * there is a custom ICF */ public void testTransformer() { AbstractManagedObjectFactory mof = new AbstractManagedObjectFactory(); mof.setInstanceClassFactory(ManagementObjectWithRuntimeRef.class, new ManagementObjectWithRuntimeRefICF()); testMOF = mof; ManagementObjectWithRuntimeRef mowref = new ManagementObjectWithRuntimeRef(); mowref.setRefName(new CustomName("jboss:test=testTransformer")); ManagedObject managedObject = initManagedObject(mowref); createManagedObject(ManagementObjectChangedName.class); assertEquals("jboss:test=testTransformer", managedObject.getComponentName()); } public void testMCFHierarchy() throws Exception { ManagedConnectionFactoryDeploymentGroup mcf = initMCFDG(); ManagedObjectFactory mof = getMOF(); ManagedObject mcfMO = mof.initManagedObject(mcf, "ManagedConnectionFactoryDeploymentGroup", null); ManagedProperty deployments = mcfMO.getProperty("deployments"); Object dvalue = deployments.getValue(); assertTrue(dvalue.getClass()+"", dvalue instanceof CollectionValue); CollectionValue cv = (CollectionValue) dvalue; assertEquals(1, cv.getSize()); Object cv0 = cv.iterator().next(); assertTrue(cv0 instanceof GenericValue); GenericValue gv0 = (GenericValue) cv0; assertTrue(gv0.getValue() instanceof ManagedObject); ManagedObject mo = (ManagedObject) gv0.getValue(); assertEquals(LocalDataSourceDeploymentMetaData.class.getName(), mo.getAttachmentName()); assertEquals(mcfMO, mo.getParent()); // Validate the security-domain ManagedProperty secDomain = mo.getProperty("security-domain"); assertNotNull("security-domain", secDomain); GenericValue sdGV = (GenericValue) secDomain.getValue(); assertNotNull("security-domain.GV", sdGV); ManagedObject secDomainMO = (ManagedObject) sdGV.getValue(); assertNotNull("security-domain.MO", secDomainMO); assertEquals(mo, secDomainMO.getParent()); ManagedProperty domainName = secDomainMO.getProperty("domain"); assertNotNull("security-domain.MO.domain", domainName); assertEquals(SimpleValueSupport.wrap("java:/jaas/SomeDomain"), domainName.getValue()); } public void testKernelDeployment() { AbstractManagedObjectFactory mof = new AbstractManagedObjectFactory(); mof.setInstanceClassFactory(IBeanMetaData.class, new BeanMetaDataICF()); testMOF = mof; AKernelDeployment ad = new AKernelDeployment(); ABeanMetaData bean1 = new ABeanMetaData(); bean1.setBean(Simple.class.getName()); bean1.setName("SimpleBean#1"); ABeanMetaData bean2 = new ABeanMetaData(); bean2.setBean(Simple.class.getName()); bean2.setName("SimpleBean#2"); Simple simple1 = new Simple(); simple1.setBigDecimalValue(new BigDecimal(123456)); Simple simple2 = new Simple(); simple2.setBigDecimalValue(new BigDecimal(222222)); BeanMetaDataICF.setBean("SimpleBean#1", simple1); BeanMetaDataICF.setBean("SimpleBean#2", simple2); List beanFactories = new ArrayList(); beanFactories.add(bean1); beanFactories.add(bean2); ad.setBeanFactories(beanFactories); ManagedObject mo = mof.initManagedObject(ad, "KernelDeployment", null); ManagedProperty beanFactoriesMP = mo.getProperty("beanFactories"); assertNotNull("beanFactories MP", beanFactoriesMP); Object beanFactoriesMPValue = beanFactoriesMP.getValue(); getLog().debug("beanFactories MP value: "+beanFactoriesMPValue); assertTrue(beanFactoriesMPValue instanceof CollectionValue); CollectionValue cv = CollectionValue.class.cast(beanFactoriesMPValue); MetaValue[] cvs = cv.getElements(); assertEquals(2, cv.getSize()); MetaValue mv0 = cvs[0]; assertTrue(mv0 instanceof GenericValue); GenericValue gv0 = GenericValue.class.cast(mv0); Object gv0Value = gv0.getValue(); assertTrue(gv0Value instanceof ManagedObject); ManagedObject mo0 = ManagedObject.class.cast(gv0Value); ManagedProperty bigDecimalValueMP = mo0.getProperty("bigDecimalValue"); assertNotNull(bigDecimalValueMP); assertEquals(SimpleValueSupport.wrap(new BigDecimal(123456)), bigDecimalValueMP.getValue()); bigDecimalValueMP.setValue(SimpleValueSupport.wrap(new BigDecimal(987654))); assertEquals(new BigDecimal(987654), simple1.getBigDecimalValue()); MetaValue mv1 = cvs[1]; assertTrue(mv1 instanceof GenericValue); GenericValue gv1 = GenericValue.class.cast(mv1); Object gv1Value = gv1.getValue(); assertTrue(gv1Value instanceof ManagedObject); ManagedObject mo1 = ManagedObject.class.cast(gv1Value); ManagedProperty bigDecimalValueMP2 = mo1.getProperty("bigDecimalValue"); assertNotNull(bigDecimalValueMP2); assertEquals(SimpleValueSupport.wrap(new BigDecimal(222222)), bigDecimalValueMP2.getValue()); bigDecimalValueMP2.setValue(SimpleValueSupport.wrap(new BigDecimal(12222221))); assertEquals(new BigDecimal(12222221), simple2.getBigDecimalValue()); } /** * Override to allow test specific ManagedObjectFactory */ @Override protected ManagedObjectFactory getMOF() { ManagedObjectFactory mof = testMOF; if (mof == null) mof = super.getMOF(); return mof; } protected ManagedConnectionFactoryDeploymentGroup initMCFDG() throws Exception { ManagedConnectionFactoryDeploymentGroup mcfs = new ManagedConnectionFactoryDeploymentGroup(); LocalDataSourceDeploymentMetaData lds = new LocalDataSourceDeploymentMetaData(); lds.setBackgroundValidation(true); lds.setBackgroundValidationMillis(5000); lds.setBlockingTimeoutMilliSeconds(5000); lds.setCheckValidConnectionSQL("select something from somewhere"); lds.setConnectionDefinition("conn def"); lds.setConnectionUrl("jdbc:xyz:a=b"); DataSourceConnectionPropertyMetaData cp1 = new DataSourceConnectionPropertyMetaData(); cp1.setName("cp1-name"); cp1.setValue("cp1-value"); DataSourceConnectionPropertyMetaData cp2 = new DataSourceConnectionPropertyMetaData(); cp2.setName("cp2-name"); cp2.setValue("cp2-value"); DataSourceConnectionPropertyMetaData[] cps = { cp1, cp2 }; lds.setDataSourceConnectionProperties(Arrays.asList(cps)); lds.setDriverClass("org.jboss.jdbc.SomeDriver"); lds.setExceptionSorterClassName("org.jboss.jdbc.SomeExceptionSorter"); String[] depends = {"jboss:service=Naming", "jboss:service=Hypersonic,database=localDB"}; lds.setDependsNames(Arrays.asList(depends)); lds.setIdleTimeoutMinutes(15); lds.setInterleaving(false); lds.setMaxSize(100); lds.setMinSize(1); DBMSMetaData md = new DBMSMetaData(); md.setTypeMapping("Hypersonic SQL"); lds.setDBMSMetaData(md); lds.setNewConnectionSQL("run this on a new conn"); lds.setPassWord("password"); lds.setPrefill(true); lds.setPreparedStatementCacheSize(50); lds.setQueryTimeout(30000); lds.setUserName("user"); // Set a SecurityMetaData to validate its MO SecurityMetaData smd = new SecurityMetaData(); smd.setDomain("java:/jaas/SomeDomain"); lds.setSecurityMetaData(smd); ManagedConnectionFactoryDeploymentMetaData[] mds = {lds}; mcfs.setDeployments(Arrays.asList(mds)); mcfs.setUrl(new URL("file:/deploy/some-ds.xml")); return mcfs; } } ././@LongLink0000000000000000000000000000021300000000000011561 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/test/SimpleManagedObjectFactoryUnitTestCase.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/test/Simpl0000644000175000017500000001567710645072106033140 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.managed.factory.test; import java.math.BigDecimal; import java.math.BigInteger; import java.util.Date; import junit.framework.Test; import org.jboss.managed.api.ManagedObject; import org.jboss.test.managed.factory.AbstractManagedObjectFactoryTest; import org.jboss.test.managed.factory.support.Simple; /** * SimpleManagedObjectFactoryUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class SimpleManagedObjectFactoryUnitTestCase extends AbstractManagedObjectFactoryTest { /** * Create a testsuite for this test * * @return the testsuite */ public static Test suite() { return suite(SimpleManagedObjectFactoryUnitTestCase.class); } /** * Create a new SimpleManagedObjectFactoryUnitTestCase. * * @param name the test name */ public SimpleManagedObjectFactoryUnitTestCase(String name) { super(name); } /** * Test the correct managed object is generated for a simple type * * @throws Exception for any problem */ public void testSimpleSkeleton() throws Exception { ManagedObject managedObject = createManagedObject(Simple.class); checkManagedObjectDefaults(Simple.class, managedObject); checkDefaultManagedProperties(managedObject, Simple.class); checkPropertyDefaults(managedObject, "bigDecimalValue", BigDecimal.class); checkPropertyDefaults(managedObject, "bigIntegerValue", BigInteger.class); checkPropertyDefaults(managedObject, "booleanvalue", Boolean.TYPE, Boolean.FALSE); checkPropertyDefaults(managedObject, "booleanValue", Boolean.class); checkPropertyDefaults(managedObject, "bytevalue", Byte.TYPE, new Byte((byte) 0)); checkPropertyDefaults(managedObject, "byteValue", Byte.class); checkPropertyDefaults(managedObject, "charactervalue", Character.TYPE, new Character('\0')); checkPropertyDefaults(managedObject, "characterValue", Character.class); checkPropertyDefaults(managedObject, "dateValue", Date.class); checkPropertyDefaults(managedObject, "doublevalue", Double.TYPE, new Double(0)); checkPropertyDefaults(managedObject, "doubleValue", Double.class); checkPropertyDefaults(managedObject, "floatvalue", Float.TYPE, new Float(0)); checkPropertyDefaults(managedObject, "floatValue", Float.class); checkPropertyDefaults(managedObject, "integervalue", Integer.TYPE, new Integer(0)); checkPropertyDefaults(managedObject, "integerValue", Integer.class); checkPropertyDefaults(managedObject, "longvalue", Long.TYPE, new Long(0)); checkPropertyDefaults(managedObject, "longValue", Long.class); checkPropertyDefaults(managedObject, "shortvalue", Short.TYPE, new Short((short) 0)); checkPropertyDefaults(managedObject, "shortValue", Short.class); checkPropertyDefaults(managedObject, "stringValue", String.class); } /** * Test the correct managed object is generated for a simple value * * @throws Exception for any problem */ public void testSimple() throws Exception { BigDecimal bigDecimal = new BigDecimal(10); BigInteger bigInteger = BigInteger.ONE; Date date = new Date(System.currentTimeMillis()); Simple simple = new Simple(); simple.setBigDecimalValue(bigDecimal); simple.setBigIntegerValue(bigInteger); simple.setBooleanvalue(true); simple.setBooleanValue(Boolean.FALSE); simple.setBytevalue((byte) 1); simple.setByteValue(new Byte((byte) 2)); simple.setCharactervalue('a'); simple.setCharacterValue(new Character('b')); simple.setDateValue(date); simple.setDoublevalue(1); simple.setDoubleValue(new Double(2)); simple.setFloatvalue(1); simple.setFloatValue(new Float(2)); simple.setIntegervalue(1); simple.setIntegerValue(new Integer(2)); simple.setLongvalue(1); simple.setLongValue(new Long(2)); simple.setShortvalue((short) 1); simple.setShortValue(new Short((short) 2)); simple.setStringValue("Hello"); ManagedObject managedObject = initManagedObject(simple); checkManagedObjectDefaults(Simple.class, managedObject, simple); checkDefaultManagedProperties(managedObject, Simple.class); checkPropertyDefaults(managedObject, "bigDecimalValue", BigDecimal.class, bigDecimal); checkPropertyDefaults(managedObject, "bigIntegerValue", BigInteger.class, bigInteger); checkPropertyDefaults(managedObject, "booleanvalue", Boolean.TYPE, Boolean.TRUE); checkPropertyDefaults(managedObject, "booleanValue", Boolean.class, Boolean.FALSE); checkPropertyDefaults(managedObject, "bytevalue", Byte.TYPE, new Byte((byte) 1)); checkPropertyDefaults(managedObject, "byteValue", Byte.class, new Byte((byte) 2)); checkPropertyDefaults(managedObject, "charactervalue", Character.TYPE, new Character('a')); checkPropertyDefaults(managedObject, "characterValue", Character.class, new Character('b')); checkPropertyDefaults(managedObject, "dateValue", Date.class, date); checkPropertyDefaults(managedObject, "doublevalue", Double.TYPE, new Double(1)); checkPropertyDefaults(managedObject, "doubleValue", Double.class, new Double(2)); checkPropertyDefaults(managedObject, "floatvalue", Float.TYPE, new Float(1)); checkPropertyDefaults(managedObject, "floatValue", Float.class, new Float(2)); checkPropertyDefaults(managedObject, "integervalue", Integer.TYPE, new Integer(1)); checkPropertyDefaults(managedObject, "integerValue", Integer.class, new Integer(2)); checkPropertyDefaults(managedObject, "longvalue", Long.TYPE, new Long(1)); checkPropertyDefaults(managedObject, "longValue", Long.class, new Long(2)); checkPropertyDefaults(managedObject, "shortvalue", Short.TYPE, new Short((short) 1)); checkPropertyDefaults(managedObject, "shortValue", Short.class, new Short((short) 2)); checkPropertyDefaults(managedObject, "stringValue", String.class, "Hello"); } } ././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/test/ManagementDeploymentUnitTestCase.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/test/Manag0000644000175000017500000000510711013572634033063 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2008, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.managed.factory.test; import java.lang.annotation.Annotation; import java.util.Map; import org.jboss.managed.api.ManagedObject; import org.jboss.managed.api.ManagedDeployment.DeploymentPhase; import org.jboss.managed.api.annotation.ManagementDeployment; import org.jboss.test.managed.factory.AbstractManagedObjectFactoryTest; import org.jboss.test.managed.factory.support.deployment.JmsDestinations; /** * ManagementDeployment tests * * @author Scott.Stark@jboss.org * @version $Revision: 1.1 $ */ public class ManagementDeploymentUnitTestCase extends AbstractManagedObjectFactoryTest { public ManagementDeploymentUnitTestCase(String name) { super(name); } /** * Test that the ManagementDeployment annotation shows up on the root * ManagedObject */ public void testManagementDeploymentonMO() { getLog().info("JmsDestinations.CS: "+JmsDestinations.class.getProtectionDomain().getCodeSource()); Annotation[] reflectAnnotations = JmsDestinations.class.getAnnotations(); assertEquals(2, reflectAnnotations.length); JmsDestinations destinations = new JmsDestinations(); ManagedObject mo = initManagedObject(destinations); assertNotNull(mo); Map annotations = mo.getAnnotations(); getLog().info(annotations); ManagementDeployment mda = (ManagementDeployment) annotations.get(ManagementDeployment.class.getName()); assertNotNull(mda); assertEquals(DeploymentPhase.APPLICATION, mda.phase()); assertEquals(1, mda.types().length); assertEquals("jms", mda.types()[0]); } } ././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/test/ManagementRuntimeRefUnitTestCase.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/test/Manag0000644000175000017500000000465111061306612033060 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.managed.factory.test; import junit.framework.Test; import org.jboss.managed.api.ManagedObject; import org.jboss.test.managed.factory.AbstractManagedObjectFactoryTest; import org.jboss.test.managed.factory.support.ManagementObjectChangedName; import org.jboss.test.managed.factory.support.amof.CustomName; import org.jboss.test.managed.factory.support.amof.ManagementObjectWithRuntimeRef; /** * Tests of the ManagementRuntimeRef annotation * * @author Scott.Stark@jboss.org * @version $Revision: 1.1 $ */ public class ManagementRuntimeRefUnitTestCase extends AbstractManagedObjectFactoryTest { /** * Create a testsuite for this test * * @return the testsuite */ public static Test suite() { return suite(ManagementRuntimeRefUnitTestCase.class); } /** * Create a new ManagementObjectUnitTestCase. * * @param name the test name */ public ManagementRuntimeRefUnitTestCase(String name) { super(name); } /** * Test the transformer value of the annotation */ public void testTransformer() { ManagementObjectWithRuntimeRef mowref = new ManagementObjectWithRuntimeRef(); mowref.setRefName(new CustomName("jboss:test=testTransformer")); ManagedObject managedObject = initManagedObject(mowref); createManagedObject(ManagementObjectChangedName.class); assertEquals("jboss:test=testTransformer", managedObject.getComponentName()); } }././@LongLink0000000000000000000000000000021300000000000011561 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/test/ManagementObjectPropertiesUnitTestCase.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/test/Manag0000644000175000017500000001121011104137625033051 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.managed.factory.test; import junit.framework.Test; import org.jboss.managed.api.ManagedObject; import org.jboss.managed.api.ManagedProperty; import org.jboss.test.managed.factory.AbstractManagedObjectFactoryTest; import org.jboss.test.managed.factory.support.ManagementObjectAll; import org.jboss.test.managed.factory.support.ManagementObjectExplicit; import org.jboss.test.managed.factory.support.ManagementObjectIgnored; import org.jboss.test.managed.factory.support.ManagementObjectNone; import org.jboss.test.managed.factory.support.ManagementPropertyClass; import org.jboss.test.managed.factory.support.ManagementPropertyClassAndExplicit; import org.jboss.test.managed.factory.support.WriteOnlyPropertyObject; /** * ManagementObjectPropertiesUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class ManagementObjectPropertiesUnitTestCase extends AbstractManagedObjectFactoryTest { /** * Create a testsuite for this test * * @return the testsuite */ public static Test suite() { return suite(ManagementObjectPropertiesUnitTestCase.class); } /** * Create a new ManagementObjectPropertiesUnitTestCase. * * @param name the test name */ public ManagementObjectPropertiesUnitTestCase(String name) { super(name); } /** * Test all properties included */ public void testAll() { ManagedObject managedObject = createManagedObject(ManagementObjectAll.class); checkManagedObjectDefaults(ManagementObjectAll.class, managedObject); checkManagedProperties(managedObject, "property1", "property2"); } /** * Test some properties ignored */ public void testIgnored() { ManagedObject managedObject = createManagedObject(ManagementObjectIgnored.class); checkManagedObjectDefaults(ManagementObjectIgnored.class, managedObject); checkManagedProperties(managedObject, "property2"); } /** * Test no properties included */ public void testNone() { ManagedObject managedObject = createManagedObject(ManagementObjectNone.class); checkManagedObjectDefaults(ManagementObjectNone.class, managedObject); checkManagedProperties(managedObject, new String[0]); } /** * Test explicit properties included */ public void testExplicit() { ManagedObject managedObject = createManagedObject(ManagementObjectExplicit.class); checkManagedObjectDefaults(ManagementObjectExplicit.class, managedObject); checkManagedProperties(managedObject, "property1"); } /** * Test CLASS properties included */ public void testClass() { ManagedObject managedObject = createManagedObject(ManagementPropertyClass.class); checkManagedObjectDefaults(ManagementPropertyClass.class, managedObject); checkManagedProperties(managedObject, "property2"); } /** * Test CLASS_AND_EXPLICIT properties included */ public void testClassAndExplicit() { ManagedObject managedObject = createManagedObject(ManagementPropertyClassAndExplicit.class); checkManagedObjectDefaults(ManagementPropertyClassAndExplicit.class, managedObject); checkManagedProperties(managedObject, "property1", "property2"); } /** * Validate that a write-only property does not fail the creation of * a ManagedObject/ManagedProperty. */ public void testWriteOnlyProperty() { ManagedObject managedObject = createManagedObject(WriteOnlyPropertyObject.class); ManagedProperty serverProperty = managedObject.getProperty("serverProperty"); assertNotNull(serverProperty); log.info(serverProperty); } } ././@LongLink0000000000000000000000000000020300000000000011560 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/test/ManagementPropertyUnitTestCase.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/test/Manag0000644000175000017500000001124510763706473033076 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.managed.factory.test; import java.lang.annotation.Annotation; import java.util.Map; import junit.framework.Test; import org.jboss.managed.api.ManagedObject; import org.jboss.managed.api.ManagedProperty; import org.jboss.managed.api.annotation.ManagementObjectID; import org.jboss.managed.api.annotation.ManagementProperty; import org.jboss.managed.api.annotation.ViewUse; import org.jboss.test.managed.factory.AbstractManagedObjectFactoryTest; import org.jboss.test.managed.factory.support.ManagementPropertyAnnotations; import org.jboss.test.managed.factory.support.ManagementPropertyDescription; import org.jboss.test.managed.factory.support.ManagementPropertyMandatory; import org.jboss.test.managed.factory.support.ManagementPropertySimpleManaged; /** * ManagementPropertyUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class ManagementPropertyUnitTestCase extends AbstractManagedObjectFactoryTest { /** * Create a testsuite for this test * * @return the testsuite */ public static Test suite() { return suite(ManagementPropertyUnitTestCase.class); } /** * Create a new ManagementPropertyUnitTestCase. * * @param name the test name */ public ManagementPropertyUnitTestCase(String name) { super(name); } /** * Test the overridden description */ public void testDescription() { ManagedObject managedObject = createAndCheckDefaultManagedObject(ManagementPropertyDescription.class); checkProperty(managedObject, "property", String.class, "changed", false, null); } /** * Test the overridden mandatory */ public void testMandatory() { ManagedObject managedObject = createAndCheckDefaultManagedObject(ManagementPropertyMandatory.class); checkProperty(managedObject, "property", String.class, "property", true, null); } /** * Test the overidden property to managed object */ public void testSimpleManaged() { ManagementPropertySimpleManaged test = new ManagementPropertySimpleManaged(); ManagedObject managedObject = checkManagedObject(test); checkPropertyIsManagedObject(managedObject, "property", "property", false, test.getProperty()); } /** * Test property annotations */ public void testAnnotations() { ManagedObject managedObject = createAndCheckDefaultManagedObject(ManagementPropertyAnnotations.class); ManagedProperty managedProperty = managedObject.getProperty("runtime"); assertNotNull(managedProperty); Map annotations = managedProperty.getAnnotations(); assertEquals(2, annotations.size()); assertTrue(annotations.containsKey(ManagementProperty.class.getName())); assertTrue(annotations.containsKey(ManagementObjectID.class.getName())); } /** * Test property ViewUse */ public void testViewUse() { ManagedObject managedObject = createAndCheckDefaultManagedObject(ManagementPropertyAnnotations.class); ManagedProperty runtime = managedObject.getProperty("runtime"); assertNotNull(runtime); assertTrue("has ViewUse.RUNTIME", runtime.hasViewUse(ViewUse.RUNTIME)); assertTrue("!has ViewUse.CONFIGURATION", !runtime.hasViewUse(ViewUse.CONFIGURATION)); assertTrue("!has ViewUse.STATISTIC", !runtime.hasViewUse(ViewUse.STATISTIC)); ManagedProperty configuration = managedObject.getProperty("configuration"); assertTrue("has ViewUse.CONFIGURATION", configuration.hasViewUse(ViewUse.CONFIGURATION)); ManagedProperty stat = managedObject.getProperty("stat"); assertTrue("has ViewUse.STATISTIC", stat.hasViewUse(ViewUse.STATISTIC)); } }libjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/0000755000175000017500000000000011105402545032642 5ustar twernertwerner././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/libjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/de0000755000175000017500000000000011105402545033153 5ustar twernertwerner././@LongLink0000000000000000000000000000020300000000000011560 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/QueueDestination.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/de0000644000175000017500000000275611013572634033174 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.managed.factory.support.deployment; import java.io.Serializable; import org.jboss.managed.api.annotation.ManagementComponent; import org.jboss.managed.api.annotation.ManagementObject; /** * @author Scott.Stark@jboss.org * @version $Revision:$ */ @ManagementObject(componentType=@ManagementComponent(type="JMSDestination", subtype="Queue")) public class QueueDestination extends JmsDestination implements Serializable { private static final long serialVersionUID = 1; } ././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/SecurityDomain.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/de0000644000175000017500000000276711060100301033152 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.managed.factory.support.deployment; import org.jboss.managed.api.annotation.ManagementObject; /** * @author Scott.Stark@jboss.org * @version $Revision:$ */ @ManagementObject public class SecurityDomain extends SecDomainMD { private static final long serialVersionUID = 1; public SecurityDomain() { super(SecurityDeploymentType.DOMAIN); } public SecurityDomain(String domain) { super(SecurityDeploymentType.DOMAIN); super.setDomain(domain); } } ././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/SecDomainMD.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/de0000644000175000017500000000430311060100301033136 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.managed.factory.support.deployment; import java.io.Serializable; import org.jboss.managed.api.annotation.ManagementObject; import org.jboss.managed.api.annotation.ManagementProperty; /** * * @author Scott.Stark@jboss.org * @version $Revision:$ */ @ManagementObject(description="The security domain, type information") public class SecDomainMD implements Serializable { /** The serialVersionUID */ private static final long serialVersionUID = 1; private String domain; private SecurityDeploymentType type; public SecDomainMD() { this(SecurityDeploymentType.NONE); } protected SecDomainMD(SecurityDeploymentType type) { this.type = type; } public boolean requiresDomain() { return (getSecurityDeploymentType().equals(SecurityDeploymentType.DOMAIN) || getSecurityDeploymentType().equals(SecurityDeploymentType.DOMAIN_AND_APPLICATION)); } @ManagementProperty public String getDomain() { return domain; } public void setDomain(String domain) { this.domain = domain; } @ManagementProperty public SecurityDeploymentType getSecurityDeploymentType() { return type; } } ././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/SecDomainICF.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/de0000644000175000017500000000253511104137625033165 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.managed.factory.support.deployment; import org.jboss.managed.plugins.factory.AbstractInstanceClassFactory; /** * @author Scott.Stark@jboss.org * @version $Revision:$ */ public class SecDomainICF extends AbstractInstanceClassFactory { public Class getType() { return SecDomainMD.class; } } ././@LongLink0000000000000000000000000000023300000000000011563 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/SecurityDomainApplicationManagedMetaData.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/de0000644000175000017500000000254711060100301033146 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.managed.factory.support.deployment; /** * @author Scott.Stark@jboss.org * @version $Revision:$ */ public class SecurityDomainApplicationManagedMetaData extends SecDomainMD { private static final long serialVersionUID = 1; public SecurityDomainApplicationManagedMetaData() { super(SecurityDeploymentType.APPLICATION); } } ././@LongLink0000000000000000000000000000021100000000000011557 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/SecurityDeploymentType.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/de0000644000175000017500000000231711060100301033141 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.managed.factory.support.deployment; /** * @author Scott.Stark@jboss.org * @version $Revision:$ */ public enum SecurityDeploymentType { NONE, APPLICATION, DOMAIN, DOMAIN_AND_APPLICATION; } ././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/JmsDestination.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/de0000644000175000017500000000412111060100301033134 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.managed.factory.support.deployment; import java.io.Serializable; import org.jboss.managed.api.annotation.ManagementObject; import org.jboss.managed.api.annotation.ManagementProperty; import org.jboss.managed.api.annotation.ViewUse; /** * @author Scott.Stark@jboss.org * @version $Revision:$ */ @ManagementObject public class JmsDestination implements Serializable { private static final long serialVersionUID = 1; private String jndiName; private SecDomainMD domain; @ManagementProperty(description="JNDI binding location of destination", includeInTemplate=true) public String getJndiName() { return jndiName; } public void setJndiName(String jndiName) { this.jndiName = jndiName; } @ManagementProperty(use={ViewUse.STATISTIC}, includeInTemplate=false) public int getMsgCount() { return 0; } @ManagementProperty(description="Security domain information", managed=true) public SecDomainMD getDomain() { return domain; } public void setDomain(SecDomainMD domain) { this.domain = domain; } } ././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/JmsDestinationICF.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/de0000644000175000017500000000616311104137625033166 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.managed.factory.support.deployment; import org.jboss.beans.info.spi.BeanInfo; import org.jboss.managed.api.ManagedObject; import org.jboss.managed.api.ManagedProperty; import org.jboss.managed.api.factory.ManagedObjectFactory; import org.jboss.managed.plugins.factory.AbstractInstanceClassFactory; import org.jboss.metatype.api.values.EnumValue; import org.jboss.metatype.api.values.GenericValue; import org.jboss.metatype.api.values.MetaValue; import org.jboss.metatype.api.values.SimpleValue; /** * @author Scott.Stark@jboss.org * @version $Revision:$ */ public class JmsDestinationICF extends AbstractInstanceClassFactory { public JmsDestinationICF() { super(); } public JmsDestinationICF(ManagedObjectFactory mof) { super(mof); } public Class getType() { return JmsDestination.class; } @Override public void setValue(BeanInfo beanInfo, ManagedProperty property, JmsDestination object, MetaValue value) { if(property.getName().equals("domain")) { GenericValue gv = (GenericValue) value; ManagedObject mo = (ManagedObject) gv.getValue(); // Create the correct type of ManagedProperty type = mo.getProperty("securityDeploymentType"); ManagedProperty domain = mo.getProperty("domain"); String domainName = ((SimpleValue) domain.getValue()).getValue().toString(); EnumValue typeValue = (EnumValue) type.getValue(); String typeString = typeValue.getValue(); SecurityDeploymentType stype = SecurityDeploymentType.valueOf(typeString); SecDomainMD domainMD = null; switch(stype) { case APPLICATION: domainMD = new SecurityDomainApplicationManagedMetaData(); break; case DOMAIN: domainMD = new SecurityDomain(); break; default: case NONE: break; } domainMD.setDomain(domainName); object.setDomain(domainMD); } else { super.setValue(beanInfo, property, object, value); } } } ././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/JmsDestinations.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/de0000644000175000017500000000373111060100301033142 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.managed.factory.support.deployment; import java.io.Serializable; import java.util.List; import org.jboss.managed.api.ManagedDeployment.DeploymentPhase; import org.jboss.managed.api.annotation.ManagementDeployment; import org.jboss.managed.api.annotation.ManagementObject; import org.jboss.managed.api.annotation.ManagementProperty; /** * test jms pojo deployment * * @author Scott.Stark@jboss.org * @version $Revision:$ */ @ManagementObject(description="prototype jms destinations deployment") @ManagementDeployment(phase=DeploymentPhase.APPLICATION, types={"jms"}) public class JmsDestinations implements Serializable { private static final long serialVersionUID = 1; private List destinations; @ManagementProperty(managed=true) public List getDestinations() { return destinations; } public void setDestinations(List destinations) { this.destinations = destinations; } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/amof/libjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/am0000755000175000017500000000000011105402545033160 5ustar twernertwerner././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/amof/CustomName.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/am0000644000175000017500000000301411061306612033157 0ustar twernertwerner/* * 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.amof; import java.io.Serializable; import org.jboss.metatype.api.annotations.Generic; /** * Custom runtime component name. * * @author Ales.Justin@jboss.org * @author Scott.Stark@jboss.org * @version $Revision:$ */ @Generic public class CustomName implements Serializable { private static final long serialVersionUID = 1; private String name; public CustomName(String name) { this.name = name; } public String getName() { return name; } } ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/amof/TestICF.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/am0000644000175000017500000000257511104137625033176 0ustar twernertwerner/* * 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.amof; import java.io.Serializable; import org.jboss.managed.plugins.factory.AbstractInstanceClassFactory; /** * @author Scott.Stark@jboss.org * @version $Revision: 80522 $ */ public class TestICF extends AbstractInstanceClassFactory { public Class getType() { return Serializable.class; } } ././@LongLink0000000000000000000000000000021300000000000011561 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/amof/ManagementObjectWithRuntimeRef.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/am0000644000175000017500000000355511061306612033171 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.managed.factory.support.amof; import java.io.Serializable; import org.jboss.managed.api.annotation.ManagementObject; import org.jboss.managed.api.annotation.ManagementProperty; import org.jboss.managed.api.annotation.ManagementRuntimeRef; /** * A ManagementObject with a ManagementRuntimeRef * * @author Scott.Stark@jboss.org * @version $Revision: 1.1 $ */ @ManagementObject public class ManagementObjectWithRuntimeRef implements Serializable { /** The serialVersionUID */ private static final long serialVersionUID = -1L; private CustomName refName; @ManagementRuntimeRef(transformer=CustomRuntimeComponentNameTransformer.class) @ManagementProperty(description="A property referencing a runtime object") public CustomName getRefName() { return refName; } public void setRefName(CustomName refName) { this.refName = refName; } } ././@LongLink0000000000000000000000000000022200000000000011561 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/amof/CustomRuntimeComponentNameTransformer.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/am0000644000175000017500000000305411061306612033163 0ustar twernertwerner/* * 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.amof; import org.jboss.managed.plugins.factory.AbstractComponentNameTransformer; /** * Custom runtime component name transformer. * * @author Ales.Justin@jboss.org * @author Scott.Stark@jboss.org * @version $Revision:$ */ public class CustomRuntimeComponentNameTransformer extends AbstractComponentNameTransformer { public CustomRuntimeComponentNameTransformer() { super(CustomName.class); } protected Object doTransform(CustomName value) { return value.getName(); } } ././@LongLink0000000000000000000000000000021600000000000011564 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/amof/ManagementObjectWithRuntimeRefICF.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/am0000644000175000017500000000660711104137625033176 0ustar twernertwerner/* * 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.amof; import org.jboss.beans.info.spi.BeanInfo; import org.jboss.beans.info.spi.PropertyInfo; import org.jboss.managed.api.ManagedProperty; import org.jboss.managed.spi.factory.InstanceClassFactory; import org.jboss.metadata.spi.MetaData; import org.jboss.metatype.api.values.MetaValue; import org.jboss.metatype.api.values.MetaValueFactory; /** * @author Scott.Stark@jboss.org * @version $Revision:$ */ public class ManagementObjectWithRuntimeRefICF implements InstanceClassFactory { /** The meta value factory */ private MetaValueFactory metaValueFactory = MetaValueFactory.getInstance(); public Class getType() { return ManagementObjectWithRuntimeRef.class; } @SuppressWarnings("unchecked") public Class getManagedObjectClass(ManagementObjectWithRuntimeRef instance) throws ClassNotFoundException { return instance.getClass(); } protected String getPropertyName(ManagedProperty property) { // First look to the mapped name String name = property.getMappedName(); if (name == null) property.getName(); return name; } public MetaValue getValue(BeanInfo beanInfo, ManagedProperty property, MetaData metaData, ManagementObjectWithRuntimeRef instance) { String name = getPropertyName(property); PropertyInfo propertyInfo = beanInfo.getProperty(name); Object value = null; try { value = propertyInfo.get(instance); } catch(Throwable e) { throw new RuntimeException("Failed to get property: "+name, e); } return metaValueFactory.create(value, propertyInfo.getType()); } public void setValue(BeanInfo beanInfo, ManagedProperty property, ManagementObjectWithRuntimeRef object, MetaValue value) { String name = getPropertyName(property); PropertyInfo propertyInfo = beanInfo.getProperty(name); Object ovalue = metaValueFactory.unwrap(value, propertyInfo.getType()); try { propertyInfo.set(object, ovalue); } catch(Throwable e) { throw new RuntimeException("Failed to set property: "+name, e); } } public Object getComponentName(BeanInfo beanInfo, ManagedProperty property, ManagementObjectWithRuntimeRef object, MetaValue value) { return null; } } ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/amof/TestMOP.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/am0000644000175000017500000000621211104137625033166 0ustar twernertwerner/* * 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.amof; import java.io.Serializable; import java.util.Map; import org.jboss.config.spi.Configuration; import org.jboss.managed.api.ManagedObject; import org.jboss.managed.api.MutableManagedObject; import org.jboss.managed.plugins.factory.AbstractManagedObjectPopulator; import org.jboss.managed.spi.factory.InstanceClassFactory; import org.jboss.managed.spi.factory.ManagedObjectPopulator; import org.jboss.metadata.spi.MetaData; /** * @author Scott.Stark@jboss.org * @version $Revision: 80522 $ */ public class TestMOP extends AbstractManagedObjectPopulator implements ManagedObjectPopulator { private boolean createObjectCalled; private boolean populateManagedObjectCalled; public TestMOP(Configuration configuration, InstanceClassFactory defaultInstanceFactory, Map, InstanceClassFactory> instanceFactories) { super(configuration, defaultInstanceFactory, instanceFactories); } public TestMOP(Configuration configuration) { super(configuration); } @Override public void createObject(ManagedObject managedObject, Class clazz) { createObjectCalled = true; super.createObject(managedObject, clazz); } @Override public void createObject(ManagedObject managedObject, Class clazz, MetaData metaData) { createObjectCalled = true; super.createObject(managedObject, clazz, metaData); } @Override public void populateManagedObject(MutableManagedObject managedObject, Serializable object) { populateManagedObjectCalled = true; super.populateManagedObject(managedObject, object); } @Override public void populateManagedObject(MutableManagedObject managedObject, Serializable object, MetaData metaData) { populateManagedObjectCalled = true; super.populateManagedObject(managedObject, object, metaData); } public boolean isCreateObjectCalled() { return createObjectCalled; } public boolean isPopulateManagedObjectCalled() { return populateManagedObjectCalled; } } ././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/amof/BigDecimalSimpleValue.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/am0000644000175000017500000000337611060022631033165 0ustar twernertwerner/* * 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.amof; import java.io.Serializable; import java.math.BigDecimal; import org.jboss.metatype.api.types.SimpleMetaType; import org.jboss.metatype.api.values.AbstractMetaValue; import org.jboss.metatype.api.values.SimpleValue; /** * @author Scott.Stark@jboss.org * @version $Revision: 77998 $ */ public class BigDecimalSimpleValue extends AbstractMetaValue implements SimpleValue { private static final long serialVersionUID = 1L; /** The value */ private BigDecimal value; public BigDecimalSimpleValue(BigDecimal value) { this.value = value; } public SimpleMetaType getMetaType() { return SimpleMetaType.BIGDECIMAL; } public Serializable getValue() { return value; } } ././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/amof/TestSimpleICF.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/am0000644000175000017500000000434011104137625033166 0ustar twernertwerner/* * 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.amof; import org.jboss.beans.info.spi.BeanInfo; import org.jboss.managed.api.ManagedProperty; import org.jboss.managed.plugins.factory.AbstractInstanceClassFactory; import org.jboss.metadata.spi.MetaData; import org.jboss.metatype.api.values.MetaValue; import org.jboss.test.managed.factory.support.Simple; /** * @author Scott.Stark@jboss.org * @version $Revision: 80522 $ */ public class TestSimpleICF extends AbstractInstanceClassFactory { private boolean getValueCalled; private boolean setValueCalled; @Override public MetaValue getValue(BeanInfo beanInfo, ManagedProperty property, MetaData metaData, Simple object) { getValueCalled = true; return super.getValue(beanInfo, property, metaData, object); } public boolean isGetValueCalled() { return getValueCalled; } public Class getType() { return Simple.class; } @Override public void setValue(BeanInfo beanInfo, ManagedProperty property, Simple object, MetaValue value) { setValueCalled = true; super.setValue(beanInfo, property, object, value); } public boolean isSetValueCalled() { return setValueCalled; } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/mcf/libjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/mc0000755000175000017500000000000011105402545033162 5ustar twernertwerner././@LongLink0000000000000000000000000000022300000000000011562 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/mcf/NoTxConnectionFactoryDeploymentMetaData.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/mc0000644000175000017500000000141011077652533033174 0ustar twernertwernerpackage org.jboss.test.managed.factory.support.mcf; import javax.xml.bind.annotation.XmlType; import org.jboss.managed.api.annotation.ManagementObject; /** * A NoTxConnectionFactoryDeploymentMetaData. * * @author Weston Price * @version $Revision: 1.1 $ */ @XmlType(name="no-tx-connection-factory") @ManagementObject public class NoTxConnectionFactoryDeploymentMetaData extends ManagedConnectionFactoryDeploymentMetaData { /** The serialVersionUID */ private static final long serialVersionUID = -8637168894246737692L; @Override public ManagedConnectionFactoryTransactionSupportMetaData getTransactionSupportMetaData() { return ManagedConnectionFactoryTransactionSupportMetaData.NONE; } }././@LongLink0000000000000000000000000000021500000000000011563 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/mcf/NonXADataSourceDeploymentMetaData.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/mc0000644000175000017500000000612311077652533033202 0ustar twernertwernerpackage org.jboss.test.managed.factory.support.mcf; import java.util.ArrayList; import java.util.List; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.adapters.CollapsedStringAdapter; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import org.jboss.managed.api.annotation.ManagementObject; @XmlAccessorType(XmlAccessType.FIELD) @ManagementObject public abstract class NonXADataSourceDeploymentMetaData extends DataSourceDeploymentMetaData { @XmlElement(name="driver-class", required=true) @XmlJavaTypeAdapter(CollapsedStringAdapter.class) private String driverClass; @XmlElement(name="connection-url", required=true) @XmlJavaTypeAdapter(CollapsedStringAdapter.class) private String connectionUrl; @XmlElement(name="connection-property") private List connectionProperties = new ArrayList(); public String getConnectionUrl() { return connectionUrl; } public void setConnectionUrl(String connectionUrl) { this.connectionUrl = connectionUrl; } public String getDriverClass() { return driverClass; } public void setDriverClass(String driverClass) { this.driverClass = driverClass; } public List getDataSourceConnectionProperties() { return this.connectionProperties; } public void setDataSourceConnectionProperties(List connectionProperties) { this.connectionProperties = connectionProperties; } @Override public List getManagedConnectionFactoryProperties() { List properties = super.getManagedConnectionFactoryProperties(); ManagedConnectionFactoryPropertyMetaData property = null; if(getConnectionUrl() != null) { property = new ManagedConnectionFactoryPropertyMetaData(); property.setName("ConnectionURL"); property.setValue(getConnectionUrl()); properties.add(property); } if(getDriverClass() != null) { property = new ManagedConnectionFactoryPropertyMetaData(); property.setName("DriverClass"); property.setValue(getDriverClass()); properties.add(property); } StringBuffer propBuff = new StringBuffer(); List dsProps = getDataSourceConnectionProperties(); if (dsProps != null) { for (DataSourceConnectionPropertyMetaData prop : dsProps) { propBuff.append(prop.getName() + "=" + prop.getValue() + "\n"); } } property = new ManagedConnectionFactoryPropertyMetaData(); property.setName("ConnectionProperties"); property.setValue(propBuff.toString()); properties.add(property); return properties; } } ././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/mcf/SecurityDomainMetaData.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/mc0000644000175000017500000000334111077652533033201 0ustar twernertwerner/* * 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.mcf; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlType; import org.jboss.test.managed.factory.support.deployment.SecurityDeploymentType; /** * A SecurityDomainMetaData. * * @author Weston Price * @version $Revision: 1.1 $ */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name="security-domain") public class SecurityDomainMetaData extends SecurityMetaData { /** The serialVersionUID */ private static final long serialVersionUID = 7651471441356573122L; public SecurityDomainMetaData() { type = SecurityDeploymentType.DOMAIN; } } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/mcf/NoTxICF.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/mc0000644000175000017500000000313511104137625033171 0ustar twernertwerner/* * 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.mcf; import org.jboss.managed.api.factory.ManagedObjectFactory; import org.jboss.managed.plugins.factory.AbstractInstanceClassFactory; /** * @author Scott.Stark@jboss.org * @version $Revision:$ */ public class NoTxICF extends AbstractInstanceClassFactory { public NoTxICF() { super(); } public NoTxICF(ManagedObjectFactory mof) { super(mof); } public Class getType() { return NoTxConnectionFactoryDeploymentMetaData.class; } } ././@LongLink0000000000000000000000000000022400000000000011563 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/mcf/SecurityDomainApplicationManagedMetaData.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/mc0000644000175000017500000000302711077652533033202 0ustar twernertwerner/* * 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.mcf; import javax.xml.bind.annotation.XmlType; import org.jboss.test.managed.factory.support.deployment.SecurityDeploymentType; @XmlType(name="security-domain-and-application") public class SecurityDomainApplicationManagedMetaData extends SecurityMetaData { /** The serialVersionUID */ private static final long serialVersionUID = -6069372122256391426L; public SecurityDomainApplicationManagedMetaData() { type = SecurityDeploymentType.DOMAIN_AND_APPLICATION; } } ././@LongLink0000000000000000000000000000021400000000000011562 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/mcf/NoTxDataSourceDeploymentMetaData.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/mc0000644000175000017500000000101611077652533033176 0ustar twernertwernerpackage org.jboss.test.managed.factory.support.mcf; import org.jboss.managed.api.annotation.ManagementObject; @ManagementObject public class NoTxDataSourceDeploymentMetaData extends NonXADataSourceDeploymentMetaData { /** The serialVersionUID */ private static final long serialVersionUID = -5354506847562754007L; @Override public ManagedConnectionFactoryTransactionSupportMetaData getTransactionSupportMetaData() { return ManagedConnectionFactoryTransactionSupportMetaData.NONE; } } ././@LongLink0000000000000000000000000000022600000000000011565 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/mcf/ManagedConnectionFactoryDeploymentMetaData.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/mc0000644000175000017500000003321311077652533033202 0ustar twernertwernerpackage org.jboss.test.managed.factory.support.mcf; /* * JBoss, Home of Professional Open Source. * Copyright 2006, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file 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. */ import java.io.Serializable; import java.util.ArrayList; import java.util.List; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElements; import javax.xml.bind.annotation.XmlTransient; import javax.xml.bind.annotation.adapters.CollapsedStringAdapter; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import org.jboss.managed.api.annotation.ManagementObject; import org.jboss.managed.api.annotation.ManagementProperty; /** * A ManagedConnectionFactoryDeployment. * * @author Weston Price * @version $Revision: 1.1 $ */ @XmlAccessorType(XmlAccessType.FIELD) @ManagementObject public class ManagedConnectionFactoryDeploymentMetaData implements Serializable { /** The serialVersionUID */ private static final long serialVersionUID = -4591557831734316580L; /** The jndiName */ @XmlElement(name="jndi-name") @XmlJavaTypeAdapter(CollapsedStringAdapter.class) private String jndiName; /** The rarName */ @XmlElement(name="rar-name") @XmlJavaTypeAdapter(CollapsedStringAdapter.class) private String rarName; /** The useJavaContext */ @XmlElement(name="use-java-context") private boolean useJavaContext = true; /** The connectionDefinition */ @XmlElement(name="connection-definition") @XmlJavaTypeAdapter(CollapsedStringAdapter.class) protected String connectionDefinition; /** The jmxInvokerName */ @XmlElement(name="jmx-invoker-name") @XmlJavaTypeAdapter(CollapsedStringAdapter.class) private String jmxInvokerName = "jboss:service=invoker,type=jrmp"; @XmlElement(name="min-pool-size") private int minSize = 0; @XmlElement(name="max-pool-size") private int maxPoolSize = 10; @XmlElement(name="blocking-timeout-millis") private long blockingTimeout = 30000; @XmlElement(name="idle-timeout-minutes") private int idleTimeout = 30; @XmlElement(name="prefill") private Boolean prefill = Boolean.FALSE; @XmlElement(name="background-validation") private boolean backgroundValidation; @XmlElement(name="background-validation-millis") private long backgroundValidationMillis; @XmlElement(name="validate-on-match") private boolean validateOnMatch = true; @XmlJavaTypeAdapter(ManagedConnectionEmptyContentAdapter.class) @XmlElement(name="use-strict-min") private Boolean useStrictMin = Boolean.FALSE; @XmlJavaTypeAdapter(ManagedConnectionEmptyContentAdapter.class) @XmlElement(name="no-tx-separate-pools") private Boolean noTxSeparatePools = Boolean.FALSE; @XmlElement(name="statistics-formatter") @XmlJavaTypeAdapter(CollapsedStringAdapter.class) private String statisticsFormatter = "org.jboss.resource.statistic.pool.JBossDefaultSubPoolStatisticFormatter"; @XmlElement(name="isSameRM-override-value") private Boolean isSameRMOverrideValue = Boolean.FALSE; // is always true now and left here for the xml binding @Deprecated @XmlJavaTypeAdapter(ManagedConnectionEmptyContentAdapter.class) @XmlElement(name="track-connection-by-tx") private Boolean trackConnectionByTransaction; @XmlJavaTypeAdapter(ManagedConnectionEmptyContentAdapter.class) @XmlElement(name="interleaving") private Boolean interleaving; /** The transactionSupportMetaData */ @XmlTransient private ManagedConnectionFactoryTransactionSupportMetaData transactionSupportMetaData = ManagedConnectionFactoryTransactionSupportMetaData.NONE; /** The managedConnectionFactoryProperties */ @XmlElement(name="config-property") private List managedConnectionFactoryProperties = new ArrayList(); @XmlElement(name="depends") private List dependsNames = new ArrayList(); // todo: this should be wrapped into element @XmlElement(name="type-mapping") String typeMapping; @XmlElement(name="metadata") private DBMSMetaData dbmsMetaData; /** The localTransactions */ @XmlJavaTypeAdapter(ManagedConnectionEmptyContentAdapter.class) @XmlElement(name="local-transaction") private Boolean localTransactions = Boolean.FALSE; /** The securityMetaData */ @XmlElements({@XmlElement(name="security-domain", type=SecurityDomainMetaData.class), @XmlElement(name="security-domain-and-application",type=SecurityDomainApplicationManagedMetaData.class), @XmlElement(name="application-managed-security",type=ApplicationManagedSecurityMetaData.class)}) private SecurityMetaData securityMetaData; public ManagedConnectionFactoryDeploymentMetaData() { this.interleaving = Boolean.FALSE; } /** * Get the securityMetaData. * * @return the securityMetaData. */ @ManagementProperty(name="security-domain", managed=true, includeInTemplate=true) public SecurityMetaData getSecurityMetaData() { return securityMetaData; } /** * Set the securityMetaData. * * @param securityMetaData The securityMetaData to set. */ public void setSecurityMetaData(SecurityMetaData securityMetaData) { this.securityMetaData = securityMetaData; } /** * Get the connectionDefinition. * * @return the connectionDefinition. */ public String getConnectionDefinition() { return connectionDefinition; } /** * Set the connectionDefinition. * * @param connectionDefinition The connectionDefinition to set. */ public void setConnectionDefinition(String connectionDefinition) { this.connectionDefinition = connectionDefinition; } /** * Get the jndiName. This is the id for the DataSource ManagedObject. * * @return the jndiName. */ public String getJndiName() { return jndiName; } /** * Set the jndiName. * * @param jndiName The jndiName to set. */ public void setJndiName(String jndiName) { this.jndiName = jndiName; } /** * Get the transactionSupportMetaData. * * @return the transactionSupportMetaData. */ public ManagedConnectionFactoryTransactionSupportMetaData getTransactionSupportMetaData() { return transactionSupportMetaData; } /** * Set the transactionSupportMetaData. * * @param transactionSupportMetaData The transactionSupportMetaData to set. */ public void setTransactionSupportMetaData(ManagedConnectionFactoryTransactionSupportMetaData transactionSupportMetaData) { this.transactionSupportMetaData = transactionSupportMetaData; } /** * Get the useJavaContext. * * @return the useJavaContext. */ public boolean isUseJavaContext() { return useJavaContext; } /** * Set the useJavaContext. * * @param useJavaContext The useJavaContext to set. */ public void setUseJavaContext(boolean useJavaContext) { this.useJavaContext = useJavaContext; } /** * Get the managedConnectionFactoryProperties. * * @return the managedConnectionFactoryProperties. */ public List getManagedConnectionFactoryProperties() { return managedConnectionFactoryProperties; } /** * Set the managedConnectionFactoryProperties. * * @param managedConnectionFactoryProperties The managedConnectionFactoryProperties to set. */ public void setManagedConnectionFactoryProperties( List managedConnectionFactoryProperties) { this.managedConnectionFactoryProperties = managedConnectionFactoryProperties; } /** * Get the rarName. * * @return the rarName. */ public String getRarName() { return rarName; } /** * Set the rarName. * * @param rarName The rarName to set. */ public void setRarName(String rarName) { this.rarName = rarName; } /** * Get the typeMapping. * * @return the typeMapping. */ public String getTypeMapping() { return typeMapping; } /** * Set the typeMapping. * * @param typeMapping The typeMapping to set. */ public void setTypeMapping(String typeMapping) { this.typeMapping = typeMapping; } /** * Get the jmxInvokerName. * * @return the jmxInvokerName. */ public String getJmxInvokerName() { return jmxInvokerName; } /** * Set the jmxInvokerName. * * @param jmxInvokerName The jmxInvokerName to set. */ public void setJmxInvokerName(String jmxInvokerName) { this.jmxInvokerName = jmxInvokerName; } /** * Get the dependsNames. * * @return the dependsNames. */ public List getDependsNames() { return dependsNames; } /** * Set the dependsNames. * * @param dependsNames The dependsNames to set. */ public void setDependsNames(List dependsNames) { this.dependsNames = dependsNames; } public void setMinSize(int minSize) { this.minSize = minSize; } public int getMinSize() { return this.minSize; } public void setMaxSize(int maxSize) { this.maxPoolSize = maxSize; } public int getMaxSize() { if (this.maxPoolSize >= this.minSize) { return this.maxPoolSize; } else { return this.minSize; } } public void setBlockingTimeoutMilliSeconds(long blockTimeout) { this.blockingTimeout = blockTimeout; } public long getBlockingTimeoutMilliSeconds() { return this.blockingTimeout; } public void setIdleTimeoutMinutes(int idleTimeout) { this.idleTimeout = idleTimeout; } public int getIdleTimeoutMinutes() { return this.idleTimeout; } public void setPrefill(Boolean prefill) { this.prefill = prefill; } public Boolean getPrefill() { return this.prefill; } public boolean isBackgroundValidation() { return backgroundValidation; } public void setBackgroundValidation(boolean backgroundValidation) { this.backgroundValidation = backgroundValidation; } public void setBackgroundValidationMillis(long interval) { this.backgroundValidationMillis = interval; } public long getBackgroundValidationMillis() { return this.backgroundValidationMillis; } public void setValidateOnMatch(boolean validateOnMatch) { this.validateOnMatch = validateOnMatch; } public boolean isValidateOnMatch() { return this.validateOnMatch; } public Boolean getIsSameRMOverrideValue() { return isSameRMOverrideValue; } public void setIsSameRMOverrideValue(Boolean isSameRMOverrideValue) { this.isSameRMOverrideValue = isSameRMOverrideValue; } @Deprecated public Boolean getTrackConnectionByTransaction() { return !isInterleaving(); } @Deprecated public void setTrackConnectionByTransaction(Boolean trackConnectionByTransaction) { if(Boolean.TRUE == getLocalTransactions() && !Boolean.TRUE.equals(trackConnectionByTransaction)) throw new IllegalStateException("In case of local transactions track-connection-by-tx must always be true"); setInterleaving(!Boolean.TRUE.equals(trackConnectionByTransaction)); } public Boolean isInterleaving() { return interleaving == Boolean.TRUE && !Boolean.TRUE.equals(getLocalTransactions()); } public void setInterleaving(Boolean interleaving) { this.interleaving = interleaving; } public Boolean getLocalTransactions() { return localTransactions; } public void setLocalTransactions(Boolean localTransactions) { this.localTransactions = localTransactions; } public Boolean getUseStrictMin() { return useStrictMin; } public void setUseStrictMin(Boolean useStrictMin) { this.useStrictMin = useStrictMin; } public String getStatisticsFormatter() { return statisticsFormatter; } public void setStatisticsFormatter(String statisticsFormatter) { this.statisticsFormatter = statisticsFormatter; } public Boolean getNoTxSeparatePools() { return this.noTxSeparatePools; } public void setNoTxSeparatePools(Boolean notxpool) { this.noTxSeparatePools = notxpool; } public DBMSMetaData getDBMSMetaData() { return dbmsMetaData; } public void setDBMSMetaData(DBMSMetaData dbmsMetaData) { this.dbmsMetaData = dbmsMetaData; } } ././@LongLink0000000000000000000000000000021500000000000011563 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/mcf/LocalDataSourceDeploymentMetaData.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/mc0000644000175000017500000000211011077652533033172 0ustar twernertwernerpackage org.jboss.test.managed.factory.support.mcf; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlType; import org.jboss.managed.api.annotation.ManagementComponent; import org.jboss.managed.api.annotation.ManagementObject; /** * A LocalDataSourceDeploymentMetaData. * * @author Weston Price * @version $Revision: 1.1 $ */ @XmlType(name="local-tx-datasource") @XmlAccessorType(XmlAccessType.FIELD) @ManagementObject(componentType=@ManagementComponent(type="DataSource",subtype="LocalTx")) public class LocalDataSourceDeploymentMetaData extends NonXADataSourceDeploymentMetaData { /** The serialVersionUID */ private static final long serialVersionUID = -1513179292986405426L; public LocalDataSourceDeploymentMetaData() { setLocalTransactions(true); setTransactionSupportMetaData(ManagedConnectionFactoryTransactionSupportMetaData.LOCAL); } @Override public Boolean getLocalTransactions() { return Boolean.TRUE; } } ././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/mcf/SecurityMetaData.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/mc0000644000175000017500000000453711077652533033211 0ustar twernertwerner/* * 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.mcf; import java.io.Serializable; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlValue; import org.jboss.managed.api.annotation.ManagementObject; import org.jboss.managed.api.annotation.ManagementProperty; import org.jboss.test.managed.factory.support.deployment.SecurityDeploymentType; @XmlAccessorType(XmlAccessType.NONE) @ManagementObject(description="The security domain, type information") public class SecurityMetaData implements Serializable { /** The serialVersionUID */ private static final long serialVersionUID = 8939054836116025885L; @XmlValue private String domain; protected SecurityDeploymentType type; public SecurityMetaData() { type = SecurityDeploymentType.NONE; } public boolean requiresDomain() { return (getSecurityDeploymentType().equals(SecurityDeploymentType.DOMAIN) || getSecurityDeploymentType().equals(SecurityDeploymentType.DOMAIN_AND_APPLICATION)); } @ManagementProperty public String getDomain() { return domain; } public void setDomain(String domain) { this.domain = domain; } @ManagementProperty public SecurityDeploymentType getSecurityDeploymentType() { return type; } } ././@LongLink0000000000000000000000000000023600000000000011566 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/mcf/ManagedConnectionFactoryTransactionSupportMetaData.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/mc0000644000175000017500000000021411077652533033175 0ustar twernertwernerpackage org.jboss.test.managed.factory.support.mcf; public enum ManagedConnectionFactoryTransactionSupportMetaData { NONE, LOCAL, XA; }././@LongLink0000000000000000000000000000021600000000000011564 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/mcf/ApplicationManagedSecurityMetaData.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/mc0000644000175000017500000000321411077652533033200 0ustar twernertwerner/* * 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.mcf; import javax.xml.bind.annotation.XmlType; import org.jboss.test.managed.factory.support.deployment.SecurityDeploymentType; /** * A ApplicationManagedSecurityMetaData. * * @author Weston Price * @version $Revision: 1.1 $ */ @XmlType(name="application-managed-security") public class ApplicationManagedSecurityMetaData extends SecurityMetaData { /** The serialVersionUID */ private static final long serialVersionUID = 7685268791262205126L; public ApplicationManagedSecurityMetaData() { type = SecurityDeploymentType.APPLICATION; } } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/mcf/DBMSMetaData.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/mc0000644000175000017500000000207311077652533033202 0ustar twernertwernerpackage org.jboss.test.managed.factory.support.mcf; import java.io.Serializable; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.adapters.CollapsedStringAdapter; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import org.jboss.managed.api.annotation.ManagementObject; /** * A DBMSMetaData. * * @author Weston M. Price * @version $Revision: 1.1 $ */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name="metadata") @ManagementObject() public class DBMSMetaData implements Serializable { private static final long serialVersionUID = -5511233258559770711L; @XmlElement(name="type-mapping") @XmlJavaTypeAdapter(CollapsedStringAdapter.class) private String typeMapping; public String getTypeMapping() { return typeMapping; } public void setTypeMapping(String typeMapping) { this.typeMapping = typeMapping; } } ././@LongLink0000000000000000000000000000022400000000000011563 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/mcf/ManagedConnectionFactoryPropertyMetaData.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/mc0000644000175000017500000000430311077652533033200 0ustar twernertwernerpackage org.jboss.test.managed.factory.support.mcf; import java.io.Serializable; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlValue; import org.jboss.managed.api.annotation.ManagementObject; @XmlAccessorType(XmlAccessType.FIELD) @ManagementObject public class ManagedConnectionFactoryPropertyMetaData implements Serializable { /** The serialVersionUID */ private static final long serialVersionUID = 4978655092571661074L; /** The name */ @XmlAttribute(name="name") private String name; /** The type */ @XmlAttribute(name="type") private String type = "java.lang.String"; @XmlValue private String value; /** * Get the name. * * @return the name. */ public String getName() { return name; } /** * Set the name. * * @param name The name to set. */ public void setName(String name) { this.name = name; } /** * Get the type. * * @return the type. */ public String getType() { return type; } /** * Set the type. * * @param type The type to set. */ public void setType(String type) { this.type = type; } /** * Get the value. * * @return the value. */ public String getValue() { return value; } /** * Set the value. * * @param value The value to set. */ public void setValue(String value) { this.value = value; } @Override public boolean equals(Object obj) { if(this == obj) return true; if(!(obj instanceof ManagedConnectionFactoryPropertyMetaData)) { return false; } ManagedConnectionFactoryPropertyMetaData other = (ManagedConnectionFactoryPropertyMetaData)obj; if(getName() == null) return false; else { return getName().equals(other.getName()); } } @Override public int hashCode() { if (getName() == null) { return 42; } return getName().hashCode(); } } ././@LongLink0000000000000000000000000000022000000000000011557 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/mcf/DataSourceConnectionPropertyMetaData.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/mc0000644000175000017500000000146311077652533033204 0ustar twernertwernerpackage org.jboss.test.managed.factory.support.mcf; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlValue; @XmlAccessorType(XmlAccessType.FIELD) public class DataSourceConnectionPropertyMetaData implements java.io.Serializable { @XmlAttribute(name="name") protected String name; @XmlValue protected String value; public String getName() { return name; } public void setName(String name) { this.name = name; } public String getValue() { return value; } public void setValue(String value) { this.value = value; } public String toString() { return "[" + name + "=" + value + "]"; } } ././@LongLink0000000000000000000000000000022300000000000011562 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/mcf/ManagedConnectionFactoryDeploymentGroup.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/mc0000644000175000017500000000712311077652533033203 0ustar twernertwernerpackage org.jboss.test.managed.factory.support.mcf; /* * JBoss, Home of Professional Open Source. * Copyright 2006, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file 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. */ import java.io.Serializable; import java.net.URL; import java.util.ArrayList; import java.util.Collections; import java.util.List; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElements; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import org.jboss.managed.api.annotation.ManagementDeployment; import org.jboss.managed.api.annotation.ManagementObject; import org.jboss.managed.api.annotation.ManagementProperty; /** * A ManagedConnectionFactoryDeploymentGroup. * * @author Weston Price * @author Scott.Stark@jboss.org * @version $Revision: 1.1 $ */ @XmlAccessorType(XmlAccessType.NONE) @ManagementObject() @ManagementDeployment() public class ManagedConnectionFactoryDeploymentGroup implements Serializable { /** The serialVersionUID */ private static final long serialVersionUID = -7650097438654698297L; /** The fileUrl */ private URL fileUrl; /** The deployments */ @XmlElements({@XmlElement(name="local-tx-datasource", type=LocalDataSourceDeploymentMetaData.class), @XmlElement(name="no-tx-datasource", type=NoTxDataSourceDeploymentMetaData.class), @XmlElement(name="no-tx-connection-factory", type=NoTxConnectionFactoryDeploymentMetaData.class) }) private List deployments = new ArrayList(); public void addManagedConnectionFactoryDeployment(ManagedConnectionFactoryDeploymentMetaData deployment) { this.deployments.add(deployment); } @ManagementProperty(description="The connection factories", managed=true) public List getDeployments() { return Collections.unmodifiableList(deployments); } /** * Get the fileUrl. * * @return the fileUrl. */ @ManagementProperty(description="The ds.xml url", ignored=true) public URL getUrl() { return fileUrl; } /** * Set the fileUrl. * * @param fileUrl The fileUrl to set. */ public void setUrl(URL fileUrl) { this.fileUrl = fileUrl; } /** * Set the deployments. * * @param deployments The deployments to set. */ public void setDeployments(List deployments) { this.deployments = deployments; } } ././@LongLink0000000000000000000000000000020700000000000011564 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/mcf/LocalDSInstanceClassFactory.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/mc0000644000175000017500000001036611104137625033175 0ustar twernertwerner/* * 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.mcf; import java.io.Serializable; import java.util.ArrayList; import java.util.List; import org.jboss.beans.info.spi.BeanInfo; import org.jboss.managed.api.ManagedProperty; import org.jboss.managed.api.factory.ManagedObjectFactory; import org.jboss.managed.plugins.factory.AbstractInstanceClassFactory; import org.jboss.metadata.spi.MetaData; import org.jboss.metatype.api.types.SimpleMetaType; import org.jboss.metatype.api.values.MapCompositeValueSupport; import org.jboss.metatype.api.values.MetaValue; import org.jboss.metatype.api.values.SimpleValueSupport; /** * An InstanceClassFactory for LocalDataSourceDeploymentMetaData that handles * connection-properties property as a MapCompositeValueSupport. * * @author Scott.Stark@jboss.org * @version $Revision: 78217 $ */ public class LocalDSInstanceClassFactory extends AbstractInstanceClassFactory { public LocalDSInstanceClassFactory() { super(); } public LocalDSInstanceClassFactory(ManagedObjectFactory mof) { super(mof); } public Class getType() { return LocalDataSourceDeploymentMetaData.class; } public Class getManagedObjectClass( LocalDataSourceDeploymentMetaData attachment) throws ClassNotFoundException { return attachment.getClass(); } public MetaValue getValue(BeanInfo beanInfo, ManagedProperty property, MetaData metaData, LocalDataSourceDeploymentMetaData attachment) { MetaValue value = null; if("connection-properties".equals(property.getName())) { MapCompositeValueSupport mapValue = new MapCompositeValueSupport(SimpleMetaType.STRING); List list = attachment.getDataSourceConnectionProperties(); if(list != null) { for(DataSourceConnectionPropertyMetaData prop : list) { MetaValue wrapped = SimpleValueSupport.wrap(prop.getValue()); mapValue.put(prop.getName(), wrapped); } } value = mapValue; } else { value = super.getValue(beanInfo, property, metaData, attachment); } return value; } @Override protected Object unwrapValue(BeanInfo beanInfo, ManagedProperty property, MetaValue value) { if((value instanceof MapCompositeValueSupport) == false) { return super.unwrapValue(beanInfo, property, value); } MapCompositeValueSupport mapValue = (MapCompositeValueSupport) value; Object unwrapValue = null; if("connection-properties".equals(property.getName())) { List list = new ArrayList(); for(String name : mapValue.getMetaType().keySet()) { DataSourceConnectionPropertyMetaData prop = new DataSourceConnectionPropertyMetaData(); prop.setName(name); String svalue = (String) getMetaValueFactory().unwrap(mapValue.get(name)); prop.setValue(svalue); list.add(prop); } unwrapValue = list; } return unwrapValue; } } ././@LongLink0000000000000000000000000000022000000000000011557 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/mcf/ManagedConnectionEmptyContentAdapter.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/mc0000644000175000017500000000204211077652533033176 0ustar twernertwernerpackage org.jboss.test.managed.factory.support.mcf; import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.adapters.XmlAdapter; /** * A ManagedConnectionEmptyContentAdapter. * * @author Weston Price * @author Alexey Loubyansky * @version $Revision: 1.1 $ */ public class ManagedConnectionEmptyContentAdapter extends XmlAdapter { @XmlType(factoryMethod="instance") public static class EmptyElement { public static EmptyElement INSTANCE = new EmptyElement(); public static EmptyElement instance() { return INSTANCE; } private EmptyElement(){} } @Override public EmptyElement marshal(Boolean v) throws Exception { return Boolean.TRUE.equals(v) ? EmptyElement.INSTANCE : null; } @Override public Boolean unmarshal(EmptyElement v) throws Exception { return v == null ? Boolean.FALSE : Boolean.TRUE; } } ././@LongLink0000000000000000000000000000021000000000000011556 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/mcf/DataSourceDeploymentMetaData.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/mc0000644000175000017500000002617311077652533033211 0ustar twernertwernerpackage org.jboss.test.managed.factory.support.mcf; import java.util.ArrayList; import java.util.List; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.adapters.CollapsedStringAdapter; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; public class DataSourceDeploymentMetaData extends ManagedConnectionFactoryDeploymentMetaData { /** The serialVersionUID */ private static final long serialVersionUID = 1440129014410015366L; private static final String CONNECTION_DEFINITION = "javax.sql.DataSource"; private static final String RAR_NAME = "jboss-local-jdbc.rar"; @XmlElement(name="transaction-isolation") @XmlJavaTypeAdapter(CollapsedStringAdapter.class) private String transactionIsolation; @XmlElement(name="user-name") @XmlJavaTypeAdapter(CollapsedStringAdapter.class) private String userName; @XmlElement(name="password") @XmlJavaTypeAdapter(CollapsedStringAdapter.class) private String passWord; @XmlElement(name="new-connection-sql") @XmlJavaTypeAdapter(CollapsedStringAdapter.class) private String newConnectionSQL; @XmlElement(name="check-valid-connection-sql") @XmlJavaTypeAdapter(CollapsedStringAdapter.class) private String checkValidConnectionSQL; @XmlElement(name="valid-connection-checker-class-name") @XmlJavaTypeAdapter(CollapsedStringAdapter.class) private String validConnectionCheckerClassName; @XmlElement(name="exception-sorter-class-name") @XmlJavaTypeAdapter(CollapsedStringAdapter.class) private String exceptionSorterClassName; @XmlElement(name="stale-connection-checker-class-name") @XmlJavaTypeAdapter(CollapsedStringAdapter.class) private String staleConnectionCheckerClassName; @XmlElement(name="track-statements") @XmlJavaTypeAdapter(CollapsedStringAdapter.class) private String trackStatements; @XmlElement(name="prepared-statement-cache-size") private int preparedStatementCacheSize = 0; @XmlElement(name="share-prepared-statements") private boolean sharePreparedStatements; @XmlElement(name="set-tx-query-timeout") private boolean useQueryTimeout; @XmlElement(name="query-timeout") private int queryTimeout; @XmlElement(name="use-try-lock") private long useTryLock; @XmlElement(name="url-delimiter") @XmlJavaTypeAdapter(CollapsedStringAdapter.class) private String urlDelimiter; @XmlElement(name="url-selector-strategy-class-name") @XmlJavaTypeAdapter(CollapsedStringAdapter.class) private String urlSelectorStrategyClassName; public DataSourceDeploymentMetaData() { setConnectionDefinition(CONNECTION_DEFINITION); setRarName(RAR_NAME); } public String getTransactionIsolation() { return transactionIsolation; } public void setTransactionIsolation(String transactionIsolation) { this.transactionIsolation = transactionIsolation; } public String getPassWord() { return passWord; } public void setPassWord(String passWord) { this.passWord = passWord; } public String getUserName() { return userName; } public void setUserName(String userName) { this.userName = userName; } public String getCheckValidConnectionSQL() { return checkValidConnectionSQL; } public void setCheckValidConnectionSQL(String checkValidConnectionSQL) { this.checkValidConnectionSQL = checkValidConnectionSQL; } public String getExceptionSorterClassName() { return exceptionSorterClassName; } public void setExceptionSorterClassName(String exceptionSorterClassName) { this.exceptionSorterClassName = exceptionSorterClassName; } public String getNewConnectionSQL() { return newConnectionSQL; } public void setNewConnectionSQL(String newConnectionSQL) { this.newConnectionSQL = newConnectionSQL; } public String getValidConnectionCheckerClassName() { return validConnectionCheckerClassName; } public void setValidConnectionCheckerClassName(String validConnectionCheckerClassName) { this.validConnectionCheckerClassName = validConnectionCheckerClassName; } public String getStaleConnectionCheckerClassName() { return staleConnectionCheckerClassName; } public void setStaleConnectionCheckerClassName(String staleConnectionCheckerClassName) { this.staleConnectionCheckerClassName = staleConnectionCheckerClassName; } public String getURLDelimiter() { return urlDelimiter; } public void setURLDelimiter(String urlDelimiter) { this.urlDelimiter = urlDelimiter; } public String getURLSelectorStrategyClassName() { return urlSelectorStrategyClassName; } public void setURLSelectorStrategyClassName(String urlSelectorStrategyClassName) { this.urlSelectorStrategyClassName = urlSelectorStrategyClassName; } public int getPreparedStatementCacheSize() { return preparedStatementCacheSize; } public void setPreparedStatementCacheSize(int preparedStatementCacheSize) { this.preparedStatementCacheSize = preparedStatementCacheSize; } public int getQueryTimeout() { return queryTimeout; } public void setQueryTimeout(int queryTimeout) { this.queryTimeout = queryTimeout; } public long getUseTryLock() { return useTryLock; } public void setUseTryLock(long useTryLock) { this.useTryLock = useTryLock; } public boolean isSharePreparedStatements() { return sharePreparedStatements; } public void setSharePreparedStatements(boolean sharePreparedStatements) { this.sharePreparedStatements = sharePreparedStatements; } public String getTrackStatements() { return trackStatements; } public void setTrackStatements(String trackStatements) { this.trackStatements = trackStatements; } public boolean isUseQueryTimeout() { return useQueryTimeout; } public void setUseQueryTimeout(boolean useQueryTimeout) { this.useQueryTimeout = useQueryTimeout; } @Override public List getManagedConnectionFactoryProperties() { List properties = new ArrayList(); ManagedConnectionFactoryPropertyMetaData property = null; if(getUserName() != null) { property = new ManagedConnectionFactoryPropertyMetaData(); property.setName("UserName"); property.setValue(getUserName()); properties.add(property); } if(getPassWord() != null) { property = new ManagedConnectionFactoryPropertyMetaData(); property.setName("Password"); property.setValue(getPassWord()); properties.add(property); } if(getTransactionIsolation() != null) { property = new ManagedConnectionFactoryPropertyMetaData(); property.setName("TransactionIsolation"); property.setValue(getTransactionIsolation()); properties.add(property); } if(getNewConnectionSQL() != null) { property = new ManagedConnectionFactoryPropertyMetaData(); property.setName("NewConnectionSQL"); property.setValue(getNewConnectionSQL()); properties.add(property); } if(getCheckValidConnectionSQL() != null) { property = new ManagedConnectionFactoryPropertyMetaData(); property.setName("CheckValidConnectionSQL"); property.setValue(getCheckValidConnectionSQL()); properties.add(property); } if(getValidConnectionCheckerClassName() != null) { property = new ManagedConnectionFactoryPropertyMetaData(); property.setName("ValidConnectionCheckerClassName"); property.setValue(getValidConnectionCheckerClassName()); properties.add(property); } if(getExceptionSorterClassName() != null) { property = new ManagedConnectionFactoryPropertyMetaData(); property.setName("ExceptionSorterClassName"); property.setValue(getExceptionSorterClassName()); properties.add(property); } if(getStaleConnectionCheckerClassName() != null) { property = new ManagedConnectionFactoryPropertyMetaData(); property.setName("StaleConnectionCheckerClassName"); property.setValue(getStaleConnectionCheckerClassName()); properties.add(property); } if(getURLSelectorStrategyClassName() != null) { property = new ManagedConnectionFactoryPropertyMetaData(); property.setName("URLSelectorStrategyClassName"); property.setValue(getURLSelectorStrategyClassName()); properties.add(property); } if(getURLDelimiter() != null) { property = new ManagedConnectionFactoryPropertyMetaData(); property.setName("URLDelimiter"); property.setValue(getURLDelimiter()); properties.add(property); } property = new ManagedConnectionFactoryPropertyMetaData(); property.setName("PreparedStatementCacheSize"); property.setType("int"); property.setValue(String.valueOf(getPreparedStatementCacheSize())); properties.add(property); property = new ManagedConnectionFactoryPropertyMetaData(); property.setName("SharePreparedStatements"); property.setType("boolean"); property.setValue(String.valueOf(isSharePreparedStatements())); properties.add(property); property = new ManagedConnectionFactoryPropertyMetaData(); property.setName("QueryTimeout"); property.setType("int"); property.setValue(String.valueOf(getQueryTimeout())); properties.add(property); property = new ManagedConnectionFactoryPropertyMetaData(); property.setName("UseTryLock"); property.setType("long"); property.setValue(String.valueOf(getUseTryLock())); properties.add(property); property = new ManagedConnectionFactoryPropertyMetaData(); property.setName("TransactionQueryTimeout"); property.setType("boolean"); property.setValue(String.valueOf(isUseQueryTimeout())); properties.add(property); property = new ManagedConnectionFactoryPropertyMetaData(); property.setName("ValidateOnMatch"); property.setType("boolean"); property.setValue(String.valueOf(isValidateOnMatch())); properties.add(property); if (getTrackStatements() != null) { property = new ManagedConnectionFactoryPropertyMetaData(); property.setName("TrackStatements"); property.setType("java.lang.String"); property.setValue(String.valueOf(getTrackStatements())); properties.add(property); } return properties; } }././@LongLink0000000000000000000000000000020300000000000011560 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/ManagementPropertyMandatory.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/Ma0000644000175000017500000000316310655621033033131 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.managed.factory.support; import java.io.Serializable; import org.jboss.managed.api.annotation.ManagementObject; import org.jboss.managed.api.annotation.ManagementProperty; /** * ManagementPropertyMandatory. * * @author Adrian Brock * @version $Revision: 1.1 $ */ @ManagementObject public class ManagementPropertyMandatory implements Serializable { /** The serialVersionUID */ private static final long serialVersionUID = -1L; /** * Get property * * @return null */ @ManagementProperty(mandatory=true) public String getProperty() { return null; } } ././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/ManagementPropertyAnnotations.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/Ma0000644000175000017500000000431310763706473033143 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.managed.factory.support; import java.io.Serializable; import org.jboss.managed.api.annotation.ManagementObject; import org.jboss.managed.api.annotation.ManagementObjectID; import org.jboss.managed.api.annotation.ManagementProperty; import org.jboss.managed.api.annotation.ViewUse; /** * Test property annotations * * @author Scott.Stark@jboss.org * @version $Revision: 70462 $ */ @ManagementObject public class ManagementPropertyAnnotations implements Serializable { /** The serialVersionUID */ private static final long serialVersionUID = -1L; /** * Get property * * @return null */ @ManagementProperty(description="Property with extra annotations", use={ViewUse.RUNTIME}) @ManagementObjectID(name="SomeObject", type="SomeType") public String getRuntime() { return null; } @ManagementProperty(description="Property with CONFIGURATION use", use={ViewUse.CONFIGURATION}) public String getConfiguration() { return null; } public void setConfiguration(String config) { } @ManagementProperty(description="Property with STATISTIC use", use={ViewUse.STATISTIC}) public String getStat() { return null; } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/beans/libjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/be0000755000175000017500000000000011105402545033151 5ustar twernertwerner././@LongLink0000000000000000000000000000020600000000000011563 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/beans/DirectAnnotationMetaData.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/be0000644000175000017500000000501211101241666033152 0ustar twernertwerner/* * 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.beans; import java.io.Serializable; import java.lang.annotation.Annotation; import org.jboss.util.JBossObject; import org.jboss.util.JBossStringBuilder; /** * Metadata for an annotation. * * @author Ales Justin */ public class DirectAnnotationMetaData extends JBossObject implements IAnnotationMetaData, Serializable { private static final long serialVersionUID = 1L; private Annotation annotation; public DirectAnnotationMetaData(Annotation annotation) { if (annotation == null) throw new IllegalArgumentException("Null annotation"); this.annotation = annotation; } public Annotation getAnnotationInstance() { return annotation; } public Annotation getAnnotationInstance(ClassLoader cl) { return annotation; } public void toString(JBossStringBuilder buffer) { buffer.append("annotationr=").append(annotation); } public void toShortString(JBossStringBuilder buffer) { buffer.append(annotation); } protected int getHashCode() { return annotation.hashCode(); } public boolean equals(Object object) { if (object == null || object instanceof DirectAnnotationMetaData == false) return false; DirectAnnotationMetaData damd = (DirectAnnotationMetaData)object; return annotation.equals(damd.annotation); } public DirectAnnotationMetaData clone() { return (DirectAnnotationMetaData)super.clone(); } }././@LongLink0000000000000000000000000000020300000000000011560 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/beans/AbstractValueMetaData.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/be0000644000175000017500000000553611101241666033165 0ustar twernertwerner/* * 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.beans; import java.io.Serializable; import javax.xml.bind.annotation.XmlType; import org.jboss.reflect.spi.TypeInfo; import org.jboss.util.JBossObject; import org.jboss.util.JBossStringBuilder; /** * Plain value. * * @author Ales Justin * @author Adrian Brock * @version $Revision: 76863 $ */ @XmlType public class AbstractValueMetaData extends JBossObject implements IValueMetaData, Serializable { private static final long serialVersionUID = 2L; /** * The value */ private Object value; /** * Create a new plain value */ public AbstractValueMetaData() { } /** * Create a new plain value * * @param value the value */ public AbstractValueMetaData(Object value) { setValue(value); } public Object getValue() { return value; } public void setValue(Object value) { Object jmxHack = null; if (jmxHack != null) this.value = jmxHack; else this.value = value; flushJBossObjectCache(); } public Object getUnderlyingValue() { return value; } /** * Do we use jmx object name fix. * * @return do we use jmx object name fix */ protected boolean isUseJMXObjectNameFix() { return true; } public Object getValue(TypeInfo info, ClassLoader cl) throws Throwable { return info != null ? info.convertValue(value) : value; } public void toString(JBossStringBuilder buffer) { buffer.append("value=").append(value); } public void toShortString(JBossStringBuilder buffer) { buffer.append(value); } public AbstractValueMetaData clone() { AbstractValueMetaData clone = (AbstractValueMetaData)super.clone(); return clone; } } ././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/beans/StringValueMetaData.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/be0000644000175000017500000000666611101241666033172 0ustar twernertwerner/* * 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.beans; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlValue; import org.jboss.logging.Logger; import org.jboss.reflect.spi.TypeInfo; /** * @author Scott.Stark@jboss.org * @version $Revision:$ */ public class StringValueMetaData implements IValueMetaData { private static final long serialVersionUID = 2L; /** The log */ private static final Logger log = Logger.getLogger(StringValueMetaData.class); /** * The value */ private Object value; /** * The type */ protected String type; /** * The property name */ protected String propertyName; /** * The bean name */ protected String beanName; /** * Do we replace String with System property, * by default it is true. */ private boolean replace = true; /** * Do we trim string value before usage, * by default is true. */ private boolean trim = true; /** * Create a new string value */ public StringValueMetaData() { } /** * Create a new string value * * @param value the value */ public StringValueMetaData(String value) { this.value = value; } public String getValue() { return value.toString(); } /** * Set the value * * @param value the value */ @XmlValue public void setValue(String value) { this.value = value; } public void setValue(Object value) { if (value != null && value instanceof String == false) throw new ClassCastException("value is not a String: " + value); this.value = (String) value; } protected Object getDefaultInstance() { return null; } public boolean isReplace() { return replace; } @XmlAttribute(name="replace") public void setReplace(boolean replace) { this.replace = replace; } public boolean isTrim() { return trim; } public void setTrim(boolean trim) { this.trim = trim; } public Object getUnderlyingValue() { return value; } public Object getValue(TypeInfo info, ClassLoader cl) throws Throwable { // TODO Auto-generated method stub return null; } public StringValueMetaData clone() throws CloneNotSupportedException { return (StringValueMetaData)super.clone(); } public void setType(String type) { this.type = type; } } ././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/beans/AbstractTypeMetaData.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/be0000644000175000017500000001534711101241666033166 0ustar twernertwerner/* * 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.beans; import java.io.Serializable; import java.util.Stack; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlTransient; import org.jboss.beans.info.spi.BeanInfo; import org.jboss.beans.info.spi.PropertyInfo; import org.jboss.reflect.spi.ClassInfo; import org.jboss.reflect.spi.TypeInfo; import org.jboss.util.JBossStringBuilder; import org.jboss.joinpoint.spi.Joinpoint; /** * A typed value. * * @author Adrian Brock * @author Ales Justin * @version $Revision: 76173 $ */ public abstract class AbstractTypeMetaData extends AbstractValueMetaData implements Serializable { private static final long serialVersionUID = 3L; /** * The type */ protected String type; /** * The property name */ protected String propertyName; /** * The bean name */ protected String beanName; /** * Create a new typed value */ public AbstractTypeMetaData() { } /** * Create a new typed value * * @param value the value */ public AbstractTypeMetaData(String value) { super(value); } /** * Set the type * * @param type the type */ @XmlAttribute(name="class") public void setType(String type) { this.type = type; } public String getType() { return type; } /** * Check result for class compatibility. * * @param the expected type * @param result the result * @param expected expected class * @return casted result * @throws ClassCastException if result cannot be casted into expected parameter */ protected T checkResult(Object result, Class expected) { if (result != null && expected.isAssignableFrom(result.getClass()) == false) throw new ClassCastException(result.getClass() + " is not a " + expected.getName()); return expected.cast(result); } /** * Create new instance from type field. * Fall back to info parameter if no type field is set. * * @param expected type * @param info the type of reference we are about to set * @param cl the classloader to use * @param expected the expected class * @param explicit is type explicit * @return class instance or null if type is too broad * @throws Throwable on any error */ protected T createInstance(TypeInfo info, ClassLoader cl, Class expected, boolean explicit) throws Throwable { if (info == null || Object.class.getName().equals(info.getName())) return null; if (info instanceof ClassInfo == false) { if (explicit) throw new IllegalArgumentException(info.getName() + " is not a class"); else return null; } if (((ClassInfo) info).isInterface()) { if (explicit) throw new IllegalArgumentException(info.getName() + " is an interface"); else return null; } Object result = null; if (expected.isAssignableFrom(result.getClass()) == false) throw new ClassCastException(result.getClass() + " is not a " + expected.getName()); return expected.cast(result); } /** * Create the class instance * * @param expected type * @param info the request type * @param cl the classloader * @param expected the expected class * @return the class instance * @throws Throwable for any error */ protected T getTypeInstance(TypeInfo info, ClassLoader cl, Class expected) throws Throwable { return getTypeInstance(info, cl, expected, true); } /** * Create the class instance * * @param expected type * @param info the request type * @param cl the classloader * @param expected the expected class * @param preInstantiatedLookup whether to do the preinstantiated lookup * @return the class instance * @throws Throwable for any error */ protected T getTypeInstance(TypeInfo info, ClassLoader cl, Class expected, boolean preInstantiatedLookup) throws Throwable { T result = null; TypeInfo typeInfo = getClassInfo(cl); // we have explicitly set type if (typeInfo != null) result = createInstance(typeInfo, cl, expected, true); if (result == null) { // try info param if (result == null) { result = createInstance(info, cl, expected, false); // get default if (result == null) result = expected.cast(getDefaultInstance()); } } return result; } /** * Get the default instance. * * @return the default instance */ protected abstract Object getDefaultInstance(); public void toString(JBossStringBuilder buffer) { super.toString(buffer); if (type != null) buffer.append(" type=").append(type); } /** * Get the class info for this type * * @param cl classloader * @return the class info * @throws Throwable for any error */ protected ClassInfo getClassInfo(ClassLoader cl) throws Throwable { return getClassInfo(type, cl); } protected ClassInfo getClassInfo(String classType, ClassLoader cl) throws Throwable { return null; } /** * Get the type info for this type * * @param cl classloader * @return the type info * @throws Throwable for any error */ protected TypeInfo getTypeInfo(ClassLoader cl) throws Throwable { return getTypeInfo(type, cl); } protected TypeInfo getTypeInfo(String classType, ClassLoader cl) throws Throwable { if (classType == null) return null; return null; } } ././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/beans/IBeanMetaDataFactory.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/be0000644000175000017500000000233111101241666033153 0ustar twernertwerner/* * 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.beans; import java.util.List; /** * @author Scott.Stark@jboss.org * @version $Revision:$ */ public interface IBeanMetaDataFactory { public List getBeans(); } ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/beans/ABeanMetaData.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/be0000644000175000017500000000727411101241666033166 0ustar twernertwerner/* * 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.beans; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; import org.jboss.managed.api.annotation.ManagementObject; import org.jboss.managed.api.annotation.ManagementProperties; import org.jboss.managed.api.annotation.ManagementProperty; /** * @author Scott.Stark@jboss.org * @version $Revision:$ */ @ManagementObject(properties = ManagementProperties.EXPLICIT) @XmlRootElement(name="bean") @XmlType(name="beanType", propOrder={"aliasMetaData", "related", "annotations", "classLoader", "constructor", "properties", "create", "start", "stop", "destroy", "depends", "demands", "supplies", "installs", "uninstalls", "installCallbacks", "uninstallCallbacks"}) public class ABeanMetaData extends AFeatureMetaData implements IBeanMetaData, IBeanMetaDataFactory { private static final long serialVersionUID = 1; private String bean; private String name; /** The properties configuration Set */ private Set properties; public String getBean() { return bean; } public void setBean(String bean) { this.bean = bean; } public String getName() { return name; } public void setName(String name) { this.name = name; } /** * Get a property * * @param name the name * @return the property name */ public IPropertyMetaData getProperty(String name) { if (name == null) throw new IllegalArgumentException("Null name"); if (properties != null && properties.size() > 0) { for (IPropertyMetaData prop : properties) { if (name.equals(prop.getName())) return prop; } } return null; } /** * Add a property * * @param property the property */ public void addProperty(IPropertyMetaData property) { if (property == null) throw new IllegalArgumentException("Null property"); if (properties == null) properties = new HashSet(); properties.add(property); } /** * Set the propertiess. * * @param properties Set */ @ManagementProperty(managed=true) @XmlElement(name="property", type=APropertyMetaData.class) public void setProperties(Set properties) { this.properties = properties; } public List getBeans() { ArrayList beans = new ArrayList(); beans.add(this); return beans; } } ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/beans/IBeanMetaData.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/be0000644000175000017500000000260511101241666033157 0ustar twernertwerner/* * 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.beans; import java.util.Set; /** * @author Scott.Stark@jboss.org * @version $Revision:$ */ public interface IBeanMetaData { /** * Get the bean. * * @return the bean. */ String getBean(); /** * Get the name * * @return the name */ String getName(); Set getAnnotations(); } ././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/beans/AKernelDeployment.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/be0000644000175000017500000001022011101241666033147 0ustar twernertwerner/* * 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.beans; import java.io.IOException; import java.io.Serializable; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.concurrent.CopyOnWriteArrayList; import javax.xml.bind.annotation.XmlAnyElement; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElements; import javax.xml.bind.annotation.XmlNsForm; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; import org.jboss.managed.api.annotation.ManagementObject; import org.jboss.managed.api.annotation.ManagementProperties; import org.jboss.managed.api.annotation.ManagementProperty; import org.jboss.util.JBossObject; import org.jboss.util.JBossStringBuilder; /** * An abstract kernel deployment. * * @author Ales Justin * @author Adrian Brock * @version $Revision: 71557 $ */ @ManagementObject(properties = ManagementProperties.EXPLICIT) // TODO - explicitly add props we want to manage @XmlRootElement(name="deployment") @XmlType(name="deploymentType", propOrder={"annotations", "classLoader", "beanFactories", "create", "start", "stop", "destroy", "aliases"}) public class AKernelDeployment extends JBossObject implements IKernelDeployment, Serializable { private static final long serialVersionUID = 3l; /** The name of the deployment */ protected String name; /** Whether it is installed */ protected boolean installed; /** Is deployment scoped */ protected Boolean scoped; /** The beans List */ protected List beanFactories; /** * Create a new kernel deployment */ public AKernelDeployment() { } /** * Set the bean factories. * * @deprecated use setBeanFactories * @param beans a List. */ @SuppressWarnings("unchecked") public void setBeans(List beans) { this.beanFactories = beans; flushJBossObjectCache(); } public List getBeanFactories() { return beanFactories; } /** * Set the bean factories. * * @param beanFactories a List. */ @ManagementProperty(managed=true) @XmlElements ({ @XmlElement(name="bean", type=ABeanMetaData.class) }) @XmlAnyElement public void setBeanFactories(List beanFactories) { this.beanFactories = beanFactories; flushJBossObjectCache(); } public String getName() { return name; } @XmlAttribute public void setName(String name) { this.name = name; flushJBossObjectCache(); } public boolean isInstalled() { return installed; } public void toString(JBossStringBuilder buffer) { buffer.append("name=").append(name); buffer.append(" installed=").append(installed); if (beanFactories != null) buffer.append(" beanFactories=").append(beanFactories); } public void toShortString(JBossStringBuilder buffer) { buffer.append(name); } }././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/beans/IAnnotationMetaData.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/be0000644000175000017500000000315211101241666033155 0ustar twernertwerner/* * 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.beans; import java.lang.annotation.Annotation; import javax.xml.bind.annotation.XmlTransient; /** * @author Scott.Stark@jboss.org * @version $Revision:$ */ public interface IAnnotationMetaData { /** * Get the annotation using passed in classloader * @param classloader The classloader * @return The annotation instance */ Annotation getAnnotationInstance(ClassLoader classloader); /** * Get the annotation using the thread context classloader * @return The annotation instance */ @XmlTransient Annotation getAnnotationInstance(); } ././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/beans/IValueMetaData.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/be0000644000175000017500000000305011101241666033152 0ustar twernertwerner/* * 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.beans; import org.jboss.reflect.spi.TypeInfo; /** * @author Scott.Stark@jboss.org * @version $Revision:$ */ public interface IValueMetaData { /** * Get the underlying value * * @return the underlying value */ public Object getUnderlyingValue(); /** * Get the value. * * @param info the type info * @param cl the classloader * @return the value. * @throws Throwable for any error */ Object getValue(TypeInfo info, ClassLoader cl) throws Throwable; } ././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/beans/APropertyMetaData.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/be0000644000175000017500000001355111101241666033161 0ustar twernertwerner/* * 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.beans; import java.io.Serializable; import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlAnyElement; import javax.xml.bind.annotation.XmlValue; import org.jboss.util.JBossStringBuilder; import org.jboss.managed.api.annotation.ManagementProperty; /** * Metadata for a property. * * @author Ales Justin * @author Adrian Brock * @version $Revision: 76911 $ */ @XmlType(name="propertyType", propOrder={"annotations", "value"}) public class APropertyMetaData extends AFeatureMetaData implements IPropertyMetaData, Serializable { private static final long serialVersionUID = 3L; /** The property name */ protected String name; /** The preinstantiate */ protected boolean preInstantiate = true; /** The property value */ protected IValueMetaData value; /** The property type */ protected String type; /** The property replace */ private Boolean replace; /** Whether to trim */ private Boolean trim; /** * Create a new property meta data */ public APropertyMetaData() { } /** * Create a new property meta data * * @param name the name * @param value the value */ public APropertyMetaData(String name, Object value) { this.name = name; this.value = new AbstractValueMetaData(value); } /** * Create a new property meta data * * @param name the name * @param value the string value */ public APropertyMetaData(String name, String value) { this.name = name; this.value = new StringValueMetaData(value); } /** * Create a new attribute meta data * * @param name the name * @param value the value meta data */ public APropertyMetaData(String name, IValueMetaData value) { this.name = name; this.value = value; } /** * Create a new property meta data * * @param name the name * @param value the string value * @param type the type */ public APropertyMetaData(String name, String value, String type) { this.name = name; StringValueMetaData svmd = new StringValueMetaData(value); svmd.setType(type); this.value = svmd; } public String getName() { return name; } /** * Set the name * * @param name the name */ @XmlAttribute public void setName(String name) { this.name = name; } public String getType() { if (value instanceof AbstractTypeMetaData) { return ((AbstractTypeMetaData)value).getType(); } return null; } public boolean isPreInstantiate() { return preInstantiate; } @XmlAttribute(name="preinstantiate") public void setPreInstantiate(boolean preInstantiate) { this.preInstantiate = preInstantiate; } public IValueMetaData getValue() { return value; } public void setValue(IValueMetaData value) { this.value = value; } @XmlAnyElement @ManagementProperty(ignored = true) public void setValueObject(Object value) { if (value == null) setValue(null); else if (value instanceof IValueMetaData) setValue((IValueMetaData) value); else setValue(new AbstractValueMetaData(value)); } @XmlValue @ManagementProperty(ignored = true) public void setValueString(String value) { if (value == null) setValue(null); else { IValueMetaData valueMetaData = getValue(); if (valueMetaData instanceof StringValueMetaData) { ((StringValueMetaData) valueMetaData).setValue(value); } else { StringValueMetaData stringValue = new StringValueMetaData(value); stringValue.setType(getType()); setValue(stringValue); } } } public String getPropertyType() { return type; } @XmlAttribute(name="class") @ManagementProperty(ignored = true) public void setPropertyType(String type) { this.type = type; } @XmlAttribute(name="replace") @ManagementProperty(ignored = true) public void setPropertyReplace(boolean replace) { this.replace = replace; } @XmlAttribute(name="trim") @ManagementProperty(ignored = true) public void setPropertyTrim(boolean trim) { this.trim = trim; } public void toString(JBossStringBuilder buffer) { buffer.append("name=").append(name); if (value != null) buffer.append(" value=").append(value); } public void toShortString(JBossStringBuilder buffer) { buffer.append(name); } public APropertyMetaData clone() { APropertyMetaData clone = (APropertyMetaData)super.clone(); return clone; } } ././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/beans/SecurityActions.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/be0000644000175000017500000001133011101241666033152 0ustar twernertwerner/* * 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.beans; import java.security.AccessController; import java.security.PrivilegedAction; /** * Package privileged actions * * @author Scott.Stark@jboss.org * @version $Revision: 71039 $ */ class SecurityActions { interface TCLAction { class UTIL { static TCLAction getTCLAction() { return System.getSecurityManager() == null ? NON_PRIVILEGED : PRIVILEGED; } static ClassLoader getContextClassLoader() { return getTCLAction().getContextClassLoader(); } static ClassLoader getContextClassLoader(Thread thread) { return getTCLAction().getContextClassLoader(thread); } static void setContextClassLoader(ClassLoader cl) { getTCLAction().setContextClassLoader(cl); } static void setContextClassLoader(Thread thread, ClassLoader cl) { getTCLAction().setContextClassLoader(thread, cl); } } TCLAction NON_PRIVILEGED = new TCLAction() { public ClassLoader getContextClassLoader() { return Thread.currentThread().getContextClassLoader(); } public ClassLoader getContextClassLoader(Thread thread) { return thread.getContextClassLoader(); } public void setContextClassLoader(ClassLoader cl) { Thread.currentThread().setContextClassLoader(cl); } public void setContextClassLoader(Thread thread, ClassLoader cl) { thread.setContextClassLoader(cl); } }; TCLAction PRIVILEGED = new TCLAction() { private final PrivilegedAction getTCLPrivilegedAction = new PrivilegedAction() { public ClassLoader run() { return Thread.currentThread().getContextClassLoader(); } }; public ClassLoader getContextClassLoader() { return AccessController.doPrivileged(getTCLPrivilegedAction); } public ClassLoader getContextClassLoader(final Thread thread) { return AccessController.doPrivileged(new PrivilegedAction() { public ClassLoader run() { return thread.getContextClassLoader(); } }); } public void setContextClassLoader(final ClassLoader cl) { AccessController.doPrivileged( new PrivilegedAction() { public ClassLoader run() { Thread.currentThread().setContextClassLoader(cl); return null; } } ); } public void setContextClassLoader(final Thread thread, final ClassLoader cl) { AccessController.doPrivileged( new PrivilegedAction() { public ClassLoader run() { thread.setContextClassLoader(cl); return null; } } ); } }; ClassLoader getContextClassLoader(); ClassLoader getContextClassLoader(Thread thread); void setContextClassLoader(ClassLoader cl); void setContextClassLoader(Thread thread, ClassLoader cl); } static ClassLoader getContextClassLoader() { return TCLAction.UTIL.getContextClassLoader(); } static void setContextClassLoader(ClassLoader loader) { TCLAction.UTIL.setContextClassLoader(loader); } } ././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/beans/BeanMetaDataICF.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/be0000644000175000017500000001543611104137625033167 0ustar twernertwerner/* * 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.beans; import java.lang.annotation.Annotation; import java.util.HashMap; import java.util.Map; import java.util.Set; import org.jboss.beans.info.spi.BeanInfo; import org.jboss.beans.info.spi.PropertyInfo; import org.jboss.logging.Logger; import org.jboss.managed.api.ManagedProperty; import org.jboss.managed.api.annotation.ManagementObjectClass; import org.jboss.managed.api.annotation.ManagementProperty; import org.jboss.managed.api.annotation.ViewUse; import org.jboss.managed.spi.factory.InstanceClassFactory; import org.jboss.metadata.spi.MetaData; import org.jboss.metatype.api.values.MetaValue; import org.jboss.metatype.api.values.MetaValueFactory; /** * An InstanceClassFactory for BeanMetaData * * @author Scott.Stark@jboss.org * @version $Revision:$ */ public class BeanMetaDataICF implements InstanceClassFactory { private static final Logger log = Logger.getLogger(BeanMetaDataICF.class); /** The meta value factory */ private MetaValueFactory metaValueFactory = MetaValueFactory.getInstance(); private static HashMap beanMap = new HashMap(); public MetaValueFactory getMetaValueFactory() { return metaValueFactory; } public void setMetaValueFactory(MetaValueFactory metaValueFactory) { this.metaValueFactory = metaValueFactory; } public static Object getBean(String name) { return beanMap.get(name); } public static void setBean(String name, Object bean) { beanMap.put(name, bean); } public Object locateBean(String beanName) { return beanMap.get(beanName); } public Class getType() { return IBeanMetaData.class; } public Object getComponentName(BeanInfo beanInfo, ManagedProperty property, IBeanMetaData attachment, MetaValue value) { return attachment.getName(); } public Class getManagedObjectClass(IBeanMetaData attachment) throws ClassNotFoundException { Class mocClass = null; // Look for a ManagementObjectClass annotation Set annotations = attachment.getAnnotations(); if(annotations != null) { for(IAnnotationMetaData amd : annotations) { Annotation ann = amd.getAnnotationInstance(); if(ann instanceof ManagementObjectClass) { ManagementObjectClass moc = (ManagementObjectClass) ann; mocClass = moc.code(); } } } // Use the bean from the metadata if(mocClass == null) { String beanClassName = attachment.getBean(); if(beanClassName != null && beanClassName.length() > 0) { // TODO: TCL may not be correct ClassLoader loader = getClassLoader(attachment); mocClass = loader.loadClass(beanClassName); } } return mocClass; } public MetaValue getValue(BeanInfo beanInfo, ManagedProperty property, MetaData metaData, IBeanMetaData attachment) { // Get the property from the bean // First look to the mapped name String name = property.getMappedName(); if (name == null) property.getName(); PropertyInfo propertyInfo = beanInfo.getProperty(name); Object bean = locateBean(attachment.getName()); Object value = null; MetaValue mvalue = null; try { value = propertyInfo.get(bean); mvalue = metaValueFactory.create(value, propertyInfo.getType()); } catch(Throwable e) { log.debug("Failed to get property value for bean: "+beanInfo.getName() +", property: "+propertyInfo.getName(), e); mvalue = metaValueFactory.create(null, propertyInfo.getType()); return mvalue; } return mvalue; } public void setValue(BeanInfo beanInfo, ManagedProperty property, IBeanMetaData attachment, MetaValue value) { ClassLoader prevLoader = SecurityActions.getContextClassLoader(); String beanName = attachment.getName(); // First look to the mapped name String name = property.getMappedName(); if (name == null) property.getName(); // See if this is a RUNTIME property Map annotations = property.getAnnotations(); boolean isRuntime = false; if(annotations != null) { ManagementProperty annotation = (ManagementProperty) annotations.get(ManagementProperty.class); if(annotation != null) { ViewUse[] uses = annotation.use(); for(ViewUse use : uses) { if(use == ViewUse.RUNTIME) isRuntime = true; } } } try { ClassLoader loader = getClassLoader(attachment); // Set the mbean class loader as the TCL SecurityActions.setContextClassLoader(loader); PropertyInfo propertyInfo = beanInfo.getProperty(name); if(propertyInfo == null) throw new IllegalArgumentException("No matching property found: " + name + "/" + beanName); Object plainValue = metaValueFactory.unwrap(value, propertyInfo.getType()); Object bean = locateBean(beanName); propertyInfo.set(bean, plainValue); } catch(Throwable e) { throw new IllegalStateException("Failed to set property value: "+name + "/" + beanName, e); } finally { SecurityActions.setContextClassLoader(prevLoader); } } protected ClassLoader getClassLoader(IBeanMetaData deployment) { ClassLoader loader = null; // TODO... // Fallback to TCL if there is no if(loader == null) loader = SecurityActions.getContextClassLoader(); return loader; } } ././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/beans/IKernelDeployment.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/be0000644000175000017500000000222511101241666033155 0ustar twernertwerner/* * 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.beans; /** * @author Scott.Stark@jboss.org * @version $Revision:$ */ public interface IKernelDeployment { } ././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/beans/AFeatureMetaData.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/be0000644000175000017500000000664111101241666033163 0ustar twernertwerner/* * 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.beans; import java.io.Serializable; import java.util.Set; import javax.xml.bind.annotation.XmlElement; import org.jboss.reflect.spi.ClassInfo; import org.jboss.reflect.spi.TypeInfo; import org.jboss.util.JBossObject; import org.jboss.util.JBossStringBuilder; /** * General metadata. * * @author Adrian Brock * @version $Revision: 71794 $ */ public abstract class AFeatureMetaData extends JBossObject implements Serializable { private static final long serialVersionUID = 2L; /** The description */ private String description; /** The annotations */ private Set annotations; /** * Create a new meta data */ public AFeatureMetaData() { } /** * Set the description. * * @param description the description. */ public void setDescription(String description) { this.description = description; flushJBossObjectCache(); } /** * Set the annotations. * * @param annotations Set */ @XmlElement(name="annotation", type=DirectAnnotationMetaData.class) public void setAnnotations(Set annotations) { this.annotations = annotations; flushJBossObjectCache(); } public String getDescription() { return description; } public Set getAnnotations() { return annotations; } protected TypeInfo applyCollectionOrMapCheck(TypeInfo typeInfo) throws Throwable { // cannot determine on map, since we don't know if we are key or value if (typeInfo instanceof ClassInfo) { ClassInfo classInfo = (ClassInfo)typeInfo; TypeInfo componentType = classInfo.getComponentType(); if (componentType != null) return componentType; } if (typeInfo.isCollection() || typeInfo.isMap()) { throw new IllegalArgumentException("Should not be here - set element/value class type in collection/map: " + this); } return typeInfo; } public void toString(JBossStringBuilder buffer) { if (description != null) buffer.append("description=").append(description); if (annotations != null) buffer.append(" annotations=").append(annotations); } public void toShortString(JBossStringBuilder buffer) { buffer.append(description); } } ././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/beans/IPropertyMetaData.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/be0000644000175000017500000000311011101241666033147 0ustar twernertwerner/* * 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.beans; /** * @author Scott.Stark@jboss.org * @version $Revision:$ */ public interface IPropertyMetaData { /** * Get the name. * * @return the name. */ String getName(); /** * Get property type if possible. * * @return class type if set, otherwise null */ String getType(); /** * Get the preinstantiate flag. * * @return the preinstantiate flag */ boolean isPreInstantiate(); /** * Get the value. * * @return the value. */ IValueMetaData getValue(); } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/template/libjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/te0000755000175000017500000000000011105402545033173 5ustar twernertwerner././@LongLink0000000000000000000000000000021100000000000011557 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/template/ManagementObjectExplicit.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/te0000644000175000017500000000352110763516020033201 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.managed.factory.support.template; import java.io.Serializable; import org.jboss.managed.api.annotation.ManagementObject; import org.jboss.managed.api.annotation.ManagementProperties; import org.jboss.managed.api.annotation.ManagementProperty; /** * Test explicit properties. * * @author Scott.Stark@jboss.org * @version $Revision: 70420 $ */ @ManagementObject(properties=ManagementProperties.EXPLICIT) public class ManagementObjectExplicit implements Serializable { /** The serialVersionUID */ private static final long serialVersionUID = -1L; /** * Get property 1 * * @return null */ @ManagementProperty(includeInTemplate=true) public String getProperty1() { return null; } /** * Get property 2 * * @return null */ public String getProperty2() { return null; } } ././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/template/ManagementObjectAll.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/te0000644000175000017500000000335510763516020033206 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.managed.factory.support.template; import java.io.Serializable; import org.jboss.managed.api.annotation.ManagementObject; import org.jboss.managed.api.annotation.ManagementProperties; /** * ManagementObjectAll. * * @author Adrian Brock * @version $Revision: 70420 $ */ @ManagementObject(properties=ManagementProperties.ALL) public class ManagementObjectAll implements Serializable { /** The serialVersionUID */ private static final long serialVersionUID = -1L; /** * Get property 1 * * @return null */ public String getProperty1() { return null; } /** * Get property 2 * * @return null */ public String getProperty2() { return null; } } ././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/ManagementObjectExplicit.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/Ma0000644000175000017500000000350410645072106033130 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.managed.factory.support; import java.io.Serializable; import org.jboss.managed.api.annotation.ManagementObject; import org.jboss.managed.api.annotation.ManagementProperties; import org.jboss.managed.api.annotation.ManagementProperty; /** * ManagementObjectExplicit. * * @author Adrian Brock * @version $Revision: 1.1 $ */ @ManagementObject(properties=ManagementProperties.EXPLICIT) public class ManagementObjectExplicit implements Serializable { /** The serialVersionUID */ private static final long serialVersionUID = -1L; /** * Get property 1 * * @return null */ @ManagementProperty public String getProperty1() { return null; } /** * Get property 2 * * @return null */ public String getProperty2() { return null; } } ././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/ManagementPropertyClass.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/Ma0000644000175000017500000000363211104137625033131 0ustar twernertwerner/* * 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.io.Serializable; import org.jboss.managed.api.annotation.ManagementObject; import org.jboss.managed.api.annotation.ManagementProperties; import org.jboss.managed.api.annotation.ManagementProperty; /** * Test that only properties specified at the class level ManagementObject * are seen. * * @author Scott.Stark@jboss.org * @version $Revision:$ */ @ManagementObject(properties=ManagementProperties.CLASS, classProperties={ @ManagementProperty(name="property2") } ) public class ManagementPropertyClass implements Serializable { private static final long serialVersionUID = 1; /** * Get property 1 * * @return null */ @ManagementProperty public String getProperty1() { return null; } /** * Get property 2 * * @return null */ public String getProperty2() { return null; } } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/Simple.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/Si0000644000175000017500000002142610655621033033151 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.managed.factory.support; import java.io.Serializable; import java.math.BigDecimal; import java.math.BigInteger; import java.util.Date; import org.jboss.managed.api.annotation.ManagementObject; /** * Simple. * * @author Adrian Brock * @version $Revision: 1.1 $ */ @ManagementObject public class Simple implements Serializable { /** The serialVersionUID */ private static final long serialVersionUID = -1; private BigDecimal bigDecimalValue; private BigInteger bigIntegerValue; private boolean booleanvalue; private Boolean booleanValue; private byte bytevalue; private Byte byteValue; private char charactervalue; private Character characterValue; private Date dateValue; private double doublevalue; private Double doubleValue; private float floatvalue; private Float floatValue; private int integervalue; private Integer integerValue; private long longvalue; private Long longValue; private short shortvalue; private Short shortValue; private String stringValue; /** * Get the bigDecimalValue. * * @return the bigDecimalValue. */ public BigDecimal getBigDecimalValue() { return bigDecimalValue; } /** * Set the bigDecimalValue. * * @param bigDecimalValue the bigDecimalValue. */ public void setBigDecimalValue(BigDecimal bigDecimalValue) { this.bigDecimalValue = bigDecimalValue; } /** * Get the bigIntegerValue. * * @return the bigIntegerValue. */ public BigInteger getBigIntegerValue() { return bigIntegerValue; } /** * Set the bigIntegerValue. * * @param bigIntegerValue the bigIntegerValue. */ public void setBigIntegerValue(BigInteger bigIntegerValue) { this.bigIntegerValue = bigIntegerValue; } /** * Get the booleanvalue. * * @return the booleanvalue. */ public boolean isBooleanvalue() { return booleanvalue; } /** * Set the booleanvalue. * * @param booleanvalue the booleanvalue. */ public void setBooleanvalue(boolean booleanvalue) { this.booleanvalue = booleanvalue; } /** * Get the booleanValue. * * @return the booleanValue. */ public Boolean getBooleanValue() { return booleanValue; } /** * Set the booleanValue. * * @param booleanValue the booleanValue. */ public void setBooleanValue(Boolean booleanValue) { this.booleanValue = booleanValue; } /** * Get the bytevalue. * * @return the bytevalue. */ public byte getBytevalue() { return bytevalue; } /** * Set the bytevalue. * * @param bytevalue the bytevalue. */ public void setBytevalue(byte bytevalue) { this.bytevalue = bytevalue; } /** * Get the byteValue. * * @return the byteValue. */ public Byte getByteValue() { return byteValue; } /** * Set the byteValue. * * @param byteValue the byteValue. */ public void setByteValue(Byte byteValue) { this.byteValue = byteValue; } /** * Get the charactervalue. * * @return the charactervalue. */ public char getCharactervalue() { return charactervalue; } /** * Set the charactervalue. * * @param charactervalue the charactervalue. */ public void setCharactervalue(char charactervalue) { this.charactervalue = charactervalue; } /** * Get the characterValue. * * @return the characterValue. */ public Character getCharacterValue() { return characterValue; } /** * Set the characterValue. * * @param characterValue the characterValue. */ public void setCharacterValue(Character characterValue) { this.characterValue = characterValue; } /** * Get the dateValue. * * @return the dateValue. */ public Date getDateValue() { return dateValue; } /** * Set the dateValue. * * @param dateValue the dateValue. */ public void setDateValue(Date dateValue) { this.dateValue = dateValue; } /** * Get the doublevalue. * * @return the doublevalue. */ public double getDoublevalue() { return doublevalue; } /** * Set the doublevalue. * * @param doublevalue the doublevalue. */ public void setDoublevalue(double doublevalue) { this.doublevalue = doublevalue; } /** * Get the doubleValue. * * @return the doubleValue. */ public Double getDoubleValue() { return doubleValue; } /** * Set the doubleValue. * * @param doubleValue the doubleValue. */ public void setDoubleValue(Double doubleValue) { this.doubleValue = doubleValue; } /** * Get the floatvalue. * * @return the floatvalue. */ public float getFloatvalue() { return floatvalue; } /** * Set the floatvalue. * * @param floatvalue the floatvalue. */ public void setFloatvalue(float floatvalue) { this.floatvalue = floatvalue; } /** * Get the floatValue. * * @return the floatValue. */ public Float getFloatValue() { return floatValue; } /** * Set the floatValue. * * @param floatValue the floatValue. */ public void setFloatValue(Float floatValue) { this.floatValue = floatValue; } /** * Get the integervalue. * * @return the integervalue. */ public int getIntegervalue() { return integervalue; } /** * Set the integervalue. * * @param integervalue the integervalue. */ public void setIntegervalue(int integervalue) { this.integervalue = integervalue; } /** * Get the integerValue. * * @return the integerValue. */ public Integer getIntegerValue() { return integerValue; } /** * Set the integerValue. * * @param integerValue the integerValue. */ public void setIntegerValue(Integer integerValue) { this.integerValue = integerValue; } /** * Get the longvalue. * * @return the longvalue. */ public long getLongvalue() { return longvalue; } /** * Set the longvalue. * * @param longvalue the longvalue. */ public void setLongvalue(long longvalue) { this.longvalue = longvalue; } /** * Get the longValue. * * @return the longValue. */ public Long getLongValue() { return longValue; } /** * Set the longValue. * * @param longValue the longValue. */ public void setLongValue(Long longValue) { this.longValue = longValue; } /** * Get the shortvalue. * * @return the shortvalue. */ public short getShortvalue() { return shortvalue; } /** * Set the shortvalue. * * @param shortvalue the shortvalue. */ public void setShortvalue(short shortvalue) { this.shortvalue = shortvalue; } /** * Get the shortValue. * * @return the shortValue. */ public Short getShortValue() { return shortValue; } /** * Set the shortValue. * * @param shortValue the shortValue. */ public void setShortValue(Short shortValue) { this.shortValue = shortValue; } /** * Get the stringValue. * * @return the stringValue. */ public String getStringValue() { return stringValue; } /** * Set the stringValue. * * @param stringValue the stringValue. */ public void setStringValue(String stringValue) { this.stringValue = stringValue; } } ././@LongLink0000000000000000000000000000020700000000000011564 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/ManagementPropertySimpleManaged.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/Ma0000644000175000017500000000332710655621033033133 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.managed.factory.support; import java.io.Serializable; import org.jboss.managed.api.annotation.ManagementObject; import org.jboss.managed.api.annotation.ManagementProperty; /** * ManagementPropertySimpleManaged. * * @author Adrian Brock * @version $Revision: 1.1 $ */ @ManagementObject public class ManagementPropertySimpleManaged implements Serializable { private ManagementObjectAll property = new ManagementObjectAll(); /** The serialVersionUID */ private static final long serialVersionUID = -1L; /** * Get property * * @return property */ @ManagementProperty(managed=true) public ManagementObjectAll getProperty() { return property; } } ././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/ManagementObjectIgnored.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/Ma0000644000175000017500000000351310645072106033130 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.managed.factory.support; import java.io.Serializable; import org.jboss.managed.api.annotation.ManagementObject; import org.jboss.managed.api.annotation.ManagementProperties; import org.jboss.managed.api.annotation.ManagementProperty; /** * ManagementObjectIgnored. * * @author Adrian Brock * @version $Revision: 1.1 $ */ @ManagementObject(properties=ManagementProperties.ALL) public class ManagementObjectIgnored implements Serializable { /** The serialVersionUID */ private static final long serialVersionUID = -1L; /** * Get property 1 * * @return null */ @ManagementProperty(ignored=true) public String getProperty1() { return null; } /** * Get property 2 * * @return null */ public String getProperty2() { return null; } } ././@LongLink0000000000000000000000000000020300000000000011560 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/ManagementObjectChangedName.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/Ma0000644000175000017500000000265010645072106033131 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.managed.factory.support; import java.io.Serializable; import org.jboss.managed.api.annotation.ManagementObject; /** * ManagementObjectChangedName. * * @author Adrian Brock * @version $Revision: 1.1 $ */ @ManagementObject(name="changed") public class ManagementObjectChangedName implements Serializable { /** The serialVersionUID */ private static final long serialVersionUID = -1L; } ././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/ManagementObjectNone.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/Ma0000644000175000017500000000335110645072106033130 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.managed.factory.support; import java.io.Serializable; import org.jboss.managed.api.annotation.ManagementObject; import org.jboss.managed.api.annotation.ManagementProperties; /** * ManagementObjectNone. * * @author Adrian Brock * @version $Revision: 1.1 $ */ @ManagementObject(properties=ManagementProperties.EXPLICIT) public class ManagementObjectNone implements Serializable { /** The serialVersionUID */ private static final long serialVersionUID = -1L; /** * Get property 1 * * @return null */ public String getProperty1() { return null; } /** * Get property 2 * * @return null */ public String getProperty2() { return null; } } ././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/ManagementPropertyDescription.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/Ma0000644000175000017500000000317710655621033033136 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.managed.factory.support; import java.io.Serializable; import org.jboss.managed.api.annotation.ManagementObject; import org.jboss.managed.api.annotation.ManagementProperty; /** * ManagementPropertyDescription. * * @author Adrian Brock * @version $Revision: 1.1 $ */ @ManagementObject public class ManagementPropertyDescription implements Serializable { /** The serialVersionUID */ private static final long serialVersionUID = -1L; /** * Get property * * @return null */ @ManagementProperty(description="changed") public String getProperty() { return null; } } ././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/WriteOnlyPropertyObject.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/Wr0000644000175000017500000000320711060232304033151 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2008, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.managed.factory.support; import java.io.Serializable; import javax.management.MBeanServer; import org.jboss.managed.api.annotation.ManagementObject; import org.jboss.managed.api.annotation.ManagementProperty; /** * A managed object with a write-only property * @author Scott.Stark@jboss.org * @version $Revision:$ */ @ManagementObject public class WriteOnlyPropertyObject implements Serializable { private static final long serialVersionUID = 1L; @SuppressWarnings("unused") private MBeanServer server; @ManagementProperty(mandatory=true) public void setServerProperty(MBeanServer server) { this.server = server; } } ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/SimpleUnannotated.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/Si0000644000175000017500000002142411104137625033146 0ustar twernertwerner/* * 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.io.Serializable; import java.math.BigDecimal; import java.math.BigInteger; import java.util.Date; /** * A variation of the Simple bean that does not have an ManagementObject annotation * @author Scott.Stark@jboss.org * @version $Revision:$ */ public class SimpleUnannotated implements Serializable { /** The serialVersionUID */ private static final long serialVersionUID = -1; private BigDecimal bigDecimalValue; private BigInteger bigIntegerValue; private boolean booleanvalue; private Boolean booleanValue; private byte bytevalue; private Byte byteValue; private char charactervalue; private Character characterValue; private Date dateValue; private double doublevalue; private Double doubleValue; private float floatvalue; private Float floatValue; private int integervalue; private Integer integerValue; private long longvalue; private Long longValue; private short shortvalue; private Short shortValue; private String stringValue; /** * Get the bigDecimalValue. * * @return the bigDecimalValue. */ public BigDecimal getBigDecimalValue() { return bigDecimalValue; } /** * Set the bigDecimalValue. * * @param bigDecimalValue the bigDecimalValue. */ public void setBigDecimalValue(BigDecimal bigDecimalValue) { this.bigDecimalValue = bigDecimalValue; } /** * Get the bigIntegerValue. * * @return the bigIntegerValue. */ public BigInteger getBigIntegerValue() { return bigIntegerValue; } /** * Set the bigIntegerValue. * * @param bigIntegerValue the bigIntegerValue. */ public void setBigIntegerValue(BigInteger bigIntegerValue) { this.bigIntegerValue = bigIntegerValue; } /** * Get the booleanvalue. * * @return the booleanvalue. */ public boolean isBooleanvalue() { return booleanvalue; } /** * Set the booleanvalue. * * @param booleanvalue the booleanvalue. */ public void setBooleanvalue(boolean booleanvalue) { this.booleanvalue = booleanvalue; } /** * Get the booleanValue. * * @return the booleanValue. */ public Boolean getBooleanValue() { return booleanValue; } /** * Set the booleanValue. * * @param booleanValue the booleanValue. */ public void setBooleanValue(Boolean booleanValue) { this.booleanValue = booleanValue; } /** * Get the bytevalue. * * @return the bytevalue. */ public byte getBytevalue() { return bytevalue; } /** * Set the bytevalue. * * @param bytevalue the bytevalue. */ public void setBytevalue(byte bytevalue) { this.bytevalue = bytevalue; } /** * Get the byteValue. * * @return the byteValue. */ public Byte getByteValue() { return byteValue; } /** * Set the byteValue. * * @param byteValue the byteValue. */ public void setByteValue(Byte byteValue) { this.byteValue = byteValue; } /** * Get the charactervalue. * * @return the charactervalue. */ public char getCharactervalue() { return charactervalue; } /** * Set the charactervalue. * * @param charactervalue the charactervalue. */ public void setCharactervalue(char charactervalue) { this.charactervalue = charactervalue; } /** * Get the characterValue. * * @return the characterValue. */ public Character getCharacterValue() { return characterValue; } /** * Set the characterValue. * * @param characterValue the characterValue. */ public void setCharacterValue(Character characterValue) { this.characterValue = characterValue; } /** * Get the dateValue. * * @return the dateValue. */ public Date getDateValue() { return dateValue; } /** * Set the dateValue. * * @param dateValue the dateValue. */ public void setDateValue(Date dateValue) { this.dateValue = dateValue; } /** * Get the doublevalue. * * @return the doublevalue. */ public double getDoublevalue() { return doublevalue; } /** * Set the doublevalue. * * @param doublevalue the doublevalue. */ public void setDoublevalue(double doublevalue) { this.doublevalue = doublevalue; } /** * Get the doubleValue. * * @return the doubleValue. */ public Double getDoubleValue() { return doubleValue; } /** * Set the doubleValue. * * @param doubleValue the doubleValue. */ public void setDoubleValue(Double doubleValue) { this.doubleValue = doubleValue; } /** * Get the floatvalue. * * @return the floatvalue. */ public float getFloatvalue() { return floatvalue; } /** * Set the floatvalue. * * @param floatvalue the floatvalue. */ public void setFloatvalue(float floatvalue) { this.floatvalue = floatvalue; } /** * Get the floatValue. * * @return the floatValue. */ public Float getFloatValue() { return floatValue; } /** * Set the floatValue. * * @param floatValue the floatValue. */ public void setFloatValue(Float floatValue) { this.floatValue = floatValue; } /** * Get the integervalue. * * @return the integervalue. */ public int getIntegervalue() { return integervalue; } /** * Set the integervalue. * * @param integervalue the integervalue. */ public void setIntegervalue(int integervalue) { this.integervalue = integervalue; } /** * Get the integerValue. * * @return the integerValue. */ public Integer getIntegerValue() { return integerValue; } /** * Set the integerValue. * * @param integerValue the integerValue. */ public void setIntegerValue(Integer integerValue) { this.integerValue = integerValue; } /** * Get the longvalue. * * @return the longvalue. */ public long getLongvalue() { return longvalue; } /** * Set the longvalue. * * @param longvalue the longvalue. */ public void setLongvalue(long longvalue) { this.longvalue = longvalue; } /** * Get the longValue. * * @return the longValue. */ public Long getLongValue() { return longValue; } /** * Set the longValue. * * @param longValue the longValue. */ public void setLongValue(Long longValue) { this.longValue = longValue; } /** * Get the shortvalue. * * @return the shortvalue. */ public short getShortvalue() { return shortvalue; } /** * Set the shortvalue. * * @param shortvalue the shortvalue. */ public void setShortvalue(short shortvalue) { this.shortvalue = shortvalue; } /** * Get the shortValue. * * @return the shortValue. */ public Short getShortValue() { return shortValue; } /** * Set the shortValue. * * @param shortValue the shortValue. */ public void setShortValue(Short shortValue) { this.shortValue = shortValue; } /** * Get the stringValue. * * @return the stringValue. */ public String getStringValue() { return stringValue; } /** * Set the stringValue. * * @param stringValue the stringValue. */ public void setStringValue(String stringValue) { this.stringValue = stringValue; } } ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/ManagementObjectAll.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/Ma0000644000175000017500000000334210645072106033130 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.managed.factory.support; import java.io.Serializable; import org.jboss.managed.api.annotation.ManagementObject; import org.jboss.managed.api.annotation.ManagementProperties; /** * ManagementObjectAll. * * @author Adrian Brock * @version $Revision: 1.1 $ */ @ManagementObject(properties=ManagementProperties.ALL) public class ManagementObjectAll implements Serializable { /** The serialVersionUID */ private static final long serialVersionUID = -1L; /** * Get property 1 * * @return null */ public String getProperty1() { return null; } /** * Get property 2 * * @return null */ public String getProperty2() { return null; } } ././@LongLink0000000000000000000000000000021200000000000011560 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/ManagementPropertyClassAndExplicit.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/support/Ma0000644000175000017500000000413311104137625033126 0ustar twernertwerner/* * 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.io.Serializable; import org.jboss.managed.api.annotation.ManagementObject; import org.jboss.managed.api.annotation.ManagementProperties; import org.jboss.managed.api.annotation.ManagementProperty; /** * Test that properties specified at the class level ManagementObject * and fields/methods marked with ManagementProperty are seen. * * @author Scott.Stark@jboss.org * @version $Revision:$ */ @ManagementObject(properties=ManagementProperties.CLASS_AND_EXPLICIT, classProperties={ @ManagementProperty(name="property2") } ) public class ManagementPropertyClassAndExplicit implements Serializable { private static final long serialVersionUID = 1; /** * Get property 1 * * @return null */ @ManagementProperty public String getProperty1() { return null; } /** * Get property 2 * * @return null */ public String getProperty2() { return null; } /** * Get property 3 * * @return null */ public String getProperty3() { return null; } } ././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/AbstractManagedObjectFactoryTest.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/AbstractMa0000644000175000017500000003165711104137625033111 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.managed.factory; import java.io.Serializable; import java.util.Arrays; import java.util.Set; import org.jboss.managed.api.ManagedObject; import org.jboss.managed.api.ManagedProperty; import org.jboss.managed.api.factory.ManagedObjectFactory; import org.jboss.managed.plugins.factory.AbstractManagedObjectFactory; import org.jboss.managed.spi.factory.ManagedObjectBuilder; import org.jboss.metadata.spi.MetaData; import org.jboss.metatype.api.types.CompositeMetaType; 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.GenericValueSupport; import org.jboss.metatype.api.values.MetaValue; import org.jboss.metatype.api.values.MetaValueFactory; import org.jboss.test.BaseTestCase; import org.jboss.util.Strings; /** * AbstractManagedObjectFactoryTest. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public abstract class AbstractManagedObjectFactoryTest extends BaseTestCase { /** The managed object factory */ private static final ManagedObjectFactory managedObjectFactory = ManagedObjectFactory.getInstance(); /** The meta type factory */ private static final MetaTypeFactory metaTypeFactory = MetaTypeFactory.getInstance(); /** The meta value factory */ private static final MetaValueFactory metaValueFactory = MetaValueFactory.getInstance(); /** * Create a new AbstractManagedObjectFactoryTest. * * @param name the test name */ public AbstractManagedObjectFactoryTest(String name) { super(name); } /** * Initialize a managed object * * @param object the object * @return the managed object */ protected ManagedObject initManagedObject(Serializable object) { ManagedObject result = getMOF().initManagedObject(object, null, null); getLog().debug("Inited managed: " + result + " for object=" + Strings.defaultToString(object)); return result; } protected ManagedObjectFactory getMOF() { return managedObjectFactory; } /** * Create a managed object * * @param the type * @param clazz the type * @param metaData the metadata repository * @return the managed object */ protected ManagedObject createManagedObject(Class clazz) { MetaData metaData = null; ManagedObject result = getMOF().createManagedObject(clazz, metaData); getLog().debug("Created managed: " + result + " for class=" + clazz.getName()); return result; } /** * Set a builder for a class * * @param clazz the class * @param builder the builder */ protected void setBuilder(Class clazz, ManagedObjectBuilder builder) { getMOF().setBuilder(clazz, builder); } /** * Resolve a meta type * * @param clazz the class * @return the meta type */ protected MetaType resolve(Class clazz) { return metaTypeFactory.resolve(clazz); } /** * Create and check a managed object * * @param clazz the object * @return the managed obejct */ protected ManagedObject createAndCheckDefaultManagedObject(Class clazz) { ManagedObject managedObject = createManagedObject(clazz); checkManagedObjectDefaults(clazz, managedObject); checkDefaultManagedProperties(managedObject, clazz); return managedObject; } /** * Initialize and check a managed object * * @param test the object * @return the managed object */ protected ManagedObject checkManagedObject(Serializable test) { ManagedObject managedObject = initManagedObject(test); checkManagedObjectDefaults(test.getClass(), managedObject); checkDefaultManagedProperties(managedObject, test.getClass()); return managedObject; } /** * Check managed object defaults * * @param clazz the class * @param managedObject the managed object */ protected void checkManagedObjectDefaults(Class clazz, ManagedObject managedObject) { checkManagedObjectDefaults(clazz, managedObject, null); } /** * Check managed object defaults * * @param clazz the class * @param managedObject the managed object * @param expectedAttachment the expected attachment */ protected void checkManagedObjectDefaults(Class clazz, ManagedObject managedObject, Object expectedAttachment) { checkManagedObject(clazz, managedObject, clazz.getName(), expectedAttachment); } /** * Check a managed object * * @param clazz the class * @param managedObject the managed object * @param name the managed object name * @param expectedAttachment the expected attachment */ protected void checkManagedObject(Class clazz, ManagedObject managedObject, String name, Object expectedAttachment) { getLog().debug("CheckMangedObject: clazz=" + clazz.getName() + " managedObject=" + managedObject + " name=" + name + " expectedAttachment=" + Strings.defaultToString(expectedAttachment)); assertNotNull(managedObject); String managedObjectName = managedObject.getName(); getLog().debug("... name=" + managedObjectName); assertEquals(name, managedObjectName); Object attachment = managedObject.getAttachment(); getLog().debug("... attachment=" + Strings.defaultToString(attachment)); assertInstanceOf(attachment, clazz, false); if (expectedAttachment != null) assertTrue("ManagedObject should have the correct attachment expected " + Strings.defaultToString(expectedAttachment) + " got " + Strings.defaultToString(attachment), expectedAttachment == attachment); } /** * Check default managed properties * * @param managedObject the managed object * @param clazz the class */ protected void checkDefaultManagedProperties(ManagedObject managedObject, Class clazz) { CompositeMetaType metaType = assertInstanceOf(resolve(clazz), CompositeMetaType.class); Set expectedNames = metaType.itemSet(); Set propertyNames = managedObject.getPropertyNames(); getLog().debug("checkDefaultProperties"); getLog().debug("... expectedNames=" + expectedNames); getLog().debug("..... actualNames=" + propertyNames); assertEquals("Expected properties " + expectedNames + " got " + propertyNames, expectedNames.size(), propertyNames.size()); for (String name : expectedNames) { ManagedProperty managedProperty = managedObject.getProperty(name); assertNotNull("Expected property '" + name + "' in " + propertyNames, managedProperty); assertEquals(managedObject, managedProperty.getManagedObject()); } } /** * Check managed properties * * @param managedObject the managed object * @param names the expected property names */ protected void checkManagedProperties(ManagedObject managedObject, String... names) { Set propertyNames = managedObject.getPropertyNames(); getLog().debug("checkManagedProperties"); getLog().debug("... expectedNames=" + Arrays.asList(names)); getLog().debug("..... actualNames=" + propertyNames); assertEquals("Expected properties " + Arrays.asList(names) + " got " + propertyNames, names.length, propertyNames.size()); for (String name : names) { ManagedProperty managedProperty = managedObject.getProperty(name); assertNotNull("Expected property '" + name + "' in " + propertyNames, managedProperty); assertEquals(managedObject, managedProperty.getManagedObject()); } } /** * Check property defaults * * @param managedObject the managed object * @param name the property name * @param clazz the property class */ protected void checkPropertyDefaults(ManagedObject managedObject, String name, Class clazz) { checkPropertyDefaults(managedObject, name, clazz, null); } /** * Check property defaults * * @param managedObject the managed object * @param name the property name * @param clazz the property class * @param value the expected property value */ protected void checkPropertyDefaults(ManagedObject managedObject, String name, Class clazz, Object value) { checkProperty(managedObject, name, clazz, name, false, value); } /** * Check property * * @param managedObject the managed object * @param name the property name * @param clazz the property class * @param description the property description * @param mandatory whether the property is expected mandatory * @param value the expected property value */ protected void checkProperty(ManagedObject managedObject, String name, Class clazz, String description, boolean mandatory, Object value) { MetaType expectedType = resolve(clazz); MetaValue expectedValue = metaValueFactory.create(value, clazz); checkProperty(managedObject, name, expectedType, expectedValue, description, mandatory); } /** * Check a property is a managed object * * @param managedObject the managed object * @param name the property name * @param description the property description * @param mandatory whether the property is expected mandatory * @param value the expected property value */ protected void checkPropertyIsManagedObject(ManagedObject managedObject, String name, String description, boolean mandatory, Object value) { GenericMetaType expectedType = AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE; MetaValue expectedValue = new GenericValueSupport(expectedType, initManagedObject((Serializable) value)); checkProperty(managedObject, name, expectedType, expectedValue, description, mandatory); } /** * Check a property * * @param managedObject the managed object * @param name the property name * @param expectedType the expected meta type * @param expectedValue the expected meta value * @param description the property description * @param mandatory whether the property is expected mandatory */ protected void checkProperty(ManagedObject managedObject, String name, MetaType expectedType, MetaValue expectedValue, String description, boolean mandatory) { getLog().debug("checkProperty name=" + name + " type=" + expectedType + " desc=" + description + " mandatory=" + mandatory + " value=" + expectedValue); ManagedProperty managedProperty = managedObject.getProperty(name); getLog().debug("... managedProperty=" + managedProperty); assertNotNull("Expected property " + name + " in " + managedObject.getPropertyNames(), managedProperty); String propertyName = managedProperty.getName(); getLog().debug("... name=" + propertyName); assertEquals("Property '" + name + "' has the wrong name", name, propertyName); String propertyDescription = managedProperty.getDescription(); getLog().debug("... description=" + propertyDescription); assertEquals("Property '" + name + "' has the wrong description", description, propertyDescription); boolean propertyMandatory = managedProperty.isMandatory(); getLog().debug("... mandatory=" + propertyMandatory); assertEquals("Property '" + name + "' has the wrong mandatory flag", mandatory, propertyMandatory); getLog().debug("... expected metaType=" + expectedType); MetaType actualType = managedProperty.getMetaType(); getLog().debug("..... actual metaType=" + expectedType); assertEquals("Property '" + name + "' has the wrong type", expectedType, actualType); getLog().debug("... expected value=" + expectedValue); Object actualValue = managedProperty.getValue(); getLog().debug("..... actual value=" + actualValue); assertEquals("Property '" + name + "' has the wrong value", expectedValue, actualValue); } } ././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/ManagedObjectFactoryTestSuite.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/factory/ManagedObj0000644000175000017500000000440510645072106033047 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2005, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.managed.factory; import junit.framework.Test; import junit.framework.TestSuite; import junit.textui.TestRunner; import org.jboss.test.managed.factory.test.ManagementObjectPropertiesUnitTestCase; import org.jboss.test.managed.factory.test.ManagementObjectUnitTestCase; import org.jboss.test.managed.factory.test.ManagementPropertyUnitTestCase; import org.jboss.test.managed.factory.test.SimpleManagedObjectFactoryUnitTestCase; /** * ManagedObjectFactory Test Suite. * * @author Adrian Brock * @version $Revision: 37459 $ */ public class ManagedObjectFactoryTestSuite extends TestSuite { /** * For running the testsuite from the command line * * @param args the command line args */ public static void main(String[] args) { TestRunner.run(suite()); } /** * Create the testsuite * * @return the testsuite */ public static Test suite() { TestSuite suite = new TestSuite("ManagedObjectFactory Tests"); suite.addTest(SimpleManagedObjectFactoryUnitTestCase.suite()); suite.addTest(ManagementObjectUnitTestCase.suite()); suite.addTest(ManagementObjectPropertiesUnitTestCase.suite()); suite.addTest(ManagementPropertyUnitTestCase.suite()); return suite; } } libjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/mock/0000755000175000017500000000000011105402545030410 5ustar twernertwerner././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/mock/MockDataSourceManagedObject.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/mock/MockDataSourc0000644000175000017500000000613610756347602033055 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.managed.mock; import java.util.Map; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.jboss.managed.api.ManagedProperty; import org.jboss.managed.plugins.ManagedObjectImpl; import org.jboss.managed.plugins.ManagedPropertyImpl; import org.jboss.util.xml.DOMWriter; import org.w3c.dom.DOMImplementation; import org.w3c.dom.Document; import org.w3c.dom.Element; /** * MockDataSourceManagedObject. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class MockDataSourceManagedObject extends ManagedObjectImpl { /** The serialVersionUID */ private static final long serialVersionUID = 1L; /** The document */ private Document document; /** * Create a new MockDataSourceManagedObject. */ public MockDataSourceManagedObject() { super("Mock"); Element element; try { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); DOMImplementation impl = builder.getDOMImplementation(); document = impl.createDocument(null, null, null); element = document.createElement("data-source"); document.appendChild(element); } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new RuntimeException("Error creating dom", e); } Map properties = getProperties(); properties.put("jndi-name", new ManagedPropertyImpl(this, new MockDOMFields(element, "jndi-name"))); properties.put("connection-url", new ManagedPropertyImpl(this, new MockDOMFields(element, "connection-url"))); properties.put("user", new ManagedPropertyImpl(this, new MockDOMFields(element, "user"))); properties.put("password", new ManagedPropertyImpl(this, new MockDOMFields(element, "password"))); } /** * Pretty print the xml * * @return the xml */ public String prettyPrint() { return DOMWriter.printNode(document, true); } } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/mock/ManagedMockTestSuite.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/mock/ManagedMockTe0000644000175000017500000000340110645072106032774 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2005, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.managed.mock; import org.jboss.test.managed.mock.MockTest; import junit.framework.Test; import junit.framework.TestSuite; import junit.textui.TestRunner; /** * Managed Mock Test Suite. * * @author Adrian Brock * @version $Revision: 37459 $ */ public class ManagedMockTestSuite extends TestSuite { /** * For running the testsuite from the command line * * @param args the command line args */ public static void main(String[] args) { TestRunner.run(suite()); } /** * Create the testsuite * * @return the testsuite */ public static Test suite() { TestSuite suite = new TestSuite("Managed Mock Tests"); suite.addTest(MockTest.suite()); return suite; } } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/mock/MockDOMFields.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/mock/MockDOMFields0000644000175000017500000000612510645072106032723 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.managed.mock; import java.io.Serializable; import org.jboss.managed.api.Fields; import org.w3c.dom.Element; import org.w3c.dom.NodeList; /** * DOMFields. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class MockDOMFields implements Fields { /** The serialVersionUID */ private static final long serialVersionUID = 1L; /** The datasource element */ private Element element; /** The element name */ private String elementName; /** * Create a new DOMFields. * * @param element the data source element * @param elementName the element name */ public MockDOMFields(Element element, String elementName) { this.element = element; this.elementName = elementName; } public Serializable getField(String name) { if (NAME.equals(name)) return elementName; if (VALUE.equals(name)) { NodeList nodes = element.getElementsByTagName(elementName); if (nodes.getLength() == 0) return null; else { Element element = (Element) nodes.item(0); return element.getTextContent(); } } return null; } public void setField(String name, Serializable value) { if (VALUE.equals(name)) { String string = (String) value; NodeList nodes = element.getElementsByTagName(elementName); Element childElement = null; if (nodes.getLength() == 0) { if (string == null || string.length() == 0) return; childElement = element.getOwnerDocument().createElement(elementName); element.appendChild(childElement); } else { childElement = (Element) nodes.item(0); if (string == null || string.length() == 0) { element.removeChild(childElement); return; } } childElement.setTextContent(string); return; } throw new UnsupportedOperationException("setField " + name); } } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/mock/MockTest.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/mock/MockTest.java0000644000175000017500000001450110763537300033014 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.managed.mock; import java.io.Serializable; import java.util.HashMap; import junit.framework.Test; import org.jboss.managed.api.Fields; import org.jboss.managed.api.ManagedObject; import org.jboss.managed.api.ManagedProperty; import org.jboss.test.managed.ManagedTest; /** * MockTest * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class MockTest extends ManagedTest { /** * Create a testsuite for this this * * @return the testsuite */ public static Test suite() { return suite(MockTest.class); } /** * Create a new MockTest. * * @param name the test name */ public MockTest(String name) { super(name); } /** * Test the mock * * @throws Exception for any problem */ public void testMock() throws Exception { MockDataSourceManagedObject mock = new MockDataSourceManagedObject(); ManagedObject mo = mock; getLog().debug("MockDataSourceManagedObject, available propertes..."); getLog().debug(mock.getPropertyNames()); getLog().debug("Initial MetaData..."); getLog().debug(mock.prettyPrint()); getLog().debug("Adding jndi-name..."); mo.getProperty("jndi-name").setValue("DefaultDS"); getLog().debug(mock.prettyPrint()); getLog().debug("Adding user and password..."); mo.getProperty("user").setValue("Scott"); mo.getProperty("password").setValue("Tiger"); getLog().debug(mock.prettyPrint()); getLog().debug("Changing jndi-name..."); mo.getProperty("jndi-name").setValue("ChangedDS"); getLog().debug(mock.prettyPrint()); getLog().debug("Removing jndi-name..."); mo.getProperty("jndi-name").setValue(null); getLog().debug(mock.prettyPrint()); getLog().debug("Displaying properties..."); for (ManagedProperty property : mo.getProperties().values()) getLog().debug(property.getName() + "=" + property.getValue()); ManagedProperty jndiName = mo.getProperty("jndi-name"); getLog().debug("Displaying jndi-name field values..."); getLog().debug("jndi-name name field is: " + jndiName.getFields().getField(Fields.NAME)); getLog().debug("jndi-name value field is: " + jndiName.getFields().getField(Fields.VALUE)); assertEquals(mo, jndiName.getManagedObject()); } /** * Test the managed object serialization * * @throws Exception for any problem */ public void testManagedObjectSerialization() throws Exception { MockDataSourceManagedObject mock = new MockDataSourceManagedObject(); ManagedObject mo = mock; mo.getProperty("jndi-name").setValue("DefaultDS"); mo.getProperty("user").setValue("Scott"); mo.getProperty("password").setValue("Tiger"); mo.getProperty("jndi-name").setValue("ChangedDS"); getLog().debug(mock.prettyPrint()); byte[] data = super.serialize(mo); ManagedObject mo2 = (ManagedObject) super.deserialize(data); assertEquals("jndiName", "ChangedDS", mo2.getProperty("jndi-name").getValue()); assertEquals("user", "Scott", mo2.getProperty("user").getValue()); assertEquals("password", "Tiger", mo2.getProperty("password").getValue()); } /** * Test the managed object property map serialization * * @throws Exception for any problem */ @SuppressWarnings("unchecked") public void testManagedPropertyMapSerialization() throws Exception { MockDataSourceManagedObject mock = new MockDataSourceManagedObject(); ManagedObject mo = mock; ManagedProperty jndiName = mo.getProperty("jndi-name"); jndiName.setValue("DefaultDS"); ManagedProperty user = mo.getProperty("user"); user.setValue("Scott"); ManagedProperty password = mo.getProperty("password"); password.setValue("Tiger"); jndiName.setValue("ChangedDS"); HashMap props = new HashMap(); props.put(jndiName.getName(), jndiName); props.put(user.getName(), user); props.put(password.getName(), password); HashMap props2 = serializeDeserialize(props, HashMap.class); ManagedProperty jndiName2 = props2.get("jndi-name"); assertEquals("jndiName", "ChangedDS", jndiName2.getValue()); ManagedProperty jndiName3 = jndiName2.getManagedObject().getProperty("jndi-name"); assertEquals("jndiName", "ChangedDS", jndiName3.getValue()); ManagedProperty user2 = props2.get("user"); assertEquals("user", "Scott", user2.getValue()); ManagedProperty password2 = props2.get("password"); assertEquals("password", "Tiger", password2.getValue()); } /** * Serialize/deserialize * * TODO move to AbstractTestCase * @param the expected type * @param value the value * @param expected the expected type * @return the result * @throws Exception for any problem */ protected T serializeDeserialize(Serializable value, Class expected) throws Exception { byte[] bytes = serialize(value); Object result = deserialize(bytes); return assertInstanceOf(result, expected); } @Override protected void configureLogging() { enableTrace("org.jboss.managed.plugins.advice"); } } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/ManagedAllTestSuite.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/ManagedAllTestSuit0000644000175000017500000000366310645072106033110 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2005, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.managed; import junit.framework.Test; import junit.framework.TestSuite; import junit.textui.TestRunner; import org.jboss.test.managed.factory.ManagedObjectFactoryTestSuite; import org.jboss.test.managed.mock.ManagedMockTestSuite; /** * Managed All Test Suite. * * @author Adrian Brock * @author Scott.Stark@jboss.org * @version $Revision: 37459 $ */ public class ManagedAllTestSuite extends TestSuite { /** * For running the testsuite from the command line * * @param args the command line args */ public static void main(String[] args) { TestRunner.run(suite()); } /** * Create the testsuite * * @return the testsuite */ public static Test suite() { TestSuite suite = new TestSuite("Managed All Tests"); suite.addTest(ManagedMockTestSuite.suite()); suite.addTest(ManagedObjectFactoryTestSuite.suite()); return suite; } } libjboss-managed-java-2.0.0.CR4.orig/managed/src/test/java/org/jboss/test/managed/ManagedTest.java0000644000175000017500000000314610763537300032531 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.managed; import org.jboss.test.BaseTestCase; /** * ManagedTest base class that extends AbstractTestCaseWithSetup * to introduce the ManagedTestDelegate as the setUp delegate. * * @see org.jboss.test.AbstractTestSetup#setUp * @see org.jboss.test.AbstractTestDelegate#getDelegate * * @author Adrian Brock * @author Scott.Stark@jboss.org * @version $Revision: 70432 $ */ public abstract class ManagedTest extends BaseTestCase { /** * Create a new Managed test * * @param name the test name */ public ManagedTest(String name) { super(name); } } libjboss-managed-java-2.0.0.CR4.orig/managed/src/test/resources/0000755000175000017500000000000011105402545024266 5ustar twernertwernerlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/resources/org/0000755000175000017500000000000011105402546025056 5ustar twernertwernerlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/resources/org/jboss/0000755000175000017500000000000011105402546026176 5ustar twernertwernerlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/resources/org/jboss/test/0000755000175000017500000000000011105402546027155 5ustar twernertwernerlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/resources/org/jboss/test/managed/0000755000175000017500000000000011105402547030552 5ustar twernertwerner././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/resources/org/jboss/test/managed/ManagedPropertyWrapper-aop.xmllibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/resources/org/jboss/test/managed/ManagedProper0000644000175000017500000000072710542512650033230 0ustar twernertwerner ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/resources/org/jboss/test/managed/ManagedObjectWrapper-aop.xmllibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/resources/org/jboss/test/managed/ManagedObject0000644000175000017500000000065410542512650033166 0ustar twernertwerner ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/resources/org/jboss/test/managed/ManagedAdvices-aop.xmllibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/resources/org/jboss/test/managed/ManagedAdvice0000644000175000017500000000041710542512650033150 0ustar twernertwerner ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/resources/org/jboss/test/managed/ManagedTest-aop.xmllibjboss-managed-java-2.0.0.CR4.orig/managed/src/test/resources/org/jboss/test/managed/ManagedTest-a0000644000175000017500000000273610542512650033120 0ustar twernertwerner ]> &ManagedAdvices; &ManagedObjectWrapper; &ManagedPropertyWrapper; libjboss-managed-java-2.0.0.CR4.orig/managed/src/main/0000755000175000017500000000000011105402547022223 5ustar twernertwernerlibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/0000755000175000017500000000000011105402547023144 5ustar twernertwernerlibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/0000755000175000017500000000000011105402547023733 5ustar twernertwernerlibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/0000755000175000017500000000000011105402547025053 5ustar twernertwernerlibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/0000755000175000017500000000000011105402551026442 5ustar twernertwernerlibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/plugins/0000755000175000017500000000000011105402550030122 5ustar twernertwernerlibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/plugins/factory/0000755000175000017500000000000011105402550031571 5ustar twernertwerner././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/plugins/factory/Utility.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/plugins/factory/Utility0000644000175000017500000000757411104137625033203 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.managed.plugins.factory; import java.util.Map; import org.jboss.managed.spi.factory.InstanceClassFactory; import org.jboss.metadata.spi.MetaData; /** * Common untility methods used by the factory plugins. * * @author Scott.Stark@jboss.org * @version $Revision:$ */ public class Utility { /** * Get the instance factory for a class * * @param clazz the class * @param instanceFactories - the registered mapping of classes to InstanceClassFactorys * @param defaultInstanceFactory - the default InstanceClassFactory to use * if no class match is found. * @return the InstanceClassFactory */ @SuppressWarnings("unchecked") public static InstanceClassFactory getInstanceClassFactory(Class clazz, Map, InstanceClassFactory> instanceFactories, InstanceClassFactory defaultInstanceFactory) { return getInstanceClassFactory(clazz, instanceFactories, defaultInstanceFactory, null); } /** * Get the instance factory for a class * * @param clazz the class * @param instanceFactories - the registered mapping of classes to InstanceClassFactorys * @param defaultInstanceFactory - the default InstanceClassFactory to use * if no class match is found. * @param metaData - the possibly null metdata repository accessor. Its used to * query for an mdr InstanceClassFactory.class as an override to the defaultInstanceFactory * @return the InstanceClassFactory */ @SuppressWarnings("unchecked") public static InstanceClassFactory getInstanceClassFactory(Class clazz, Map, InstanceClassFactory> instanceFactories, InstanceClassFactory defaultInstanceFactory, MetaData metaData) { InstanceClassFactory defaultFactory = defaultInstanceFactory; if(metaData != null) { InstanceClassFactory mdrFactory = metaData.getMetaData(InstanceClassFactory.class); if(mdrFactory != null) defaultFactory = mdrFactory; } synchronized (instanceFactories) { Class c = clazz; InstanceClassFactory factory = instanceFactories.get(c); while(factory == null && c != Object.class) { // First check for interfaces Class[] ifaces = c.getInterfaces(); if(ifaces != null) { for(Class i : ifaces) { factory = instanceFactories.get(i); if(factory != null) break; } } // Next look at superclasses if(factory == null) { c = c.getSuperclass(); factory = instanceFactories.get(c); } } if (factory != null) return factory; } InstanceClassFactory factory = defaultFactory; return factory; } } ././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/plugins/factory/AbstractManagedObjectFactory.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/plugins/factory/Abstrac0000644000175000017500000010204411104137625033103 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.managed.plugins.factory; import java.io.Serializable; import java.lang.annotation.Annotation; import java.lang.reflect.Constructor; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; import java.util.WeakHashMap; import org.jboss.beans.info.spi.BeanInfo; import org.jboss.beans.info.spi.PropertyInfo; import org.jboss.config.spi.Configuration; import org.jboss.logging.Logger; import org.jboss.managed.api.Fields; import org.jboss.managed.api.ManagedObject; import org.jboss.managed.api.ManagedOperation; import org.jboss.managed.api.ManagedParameter; import org.jboss.managed.api.ManagedProperty; import org.jboss.managed.api.MutableManagedObject; import org.jboss.managed.api.ManagedOperation.Impact; import org.jboss.managed.api.annotation.AnnotationDefaults; import org.jboss.managed.api.annotation.ManagementComponent; import org.jboss.managed.api.annotation.ManagementConstants; import org.jboss.managed.api.annotation.ManagementDeployment; import org.jboss.managed.api.annotation.ManagementObject; import org.jboss.managed.api.annotation.ManagementObjectID; import org.jboss.managed.api.annotation.ManagementObjectRef; import org.jboss.managed.api.annotation.ManagementOperation; import org.jboss.managed.api.annotation.ManagementParameter; import org.jboss.managed.api.annotation.ManagementProperties; import org.jboss.managed.api.annotation.ManagementProperty; import org.jboss.managed.api.annotation.ManagementRuntimeRef; import org.jboss.managed.api.factory.ManagedObjectFactory; import org.jboss.managed.plugins.DefaultFieldsImpl; import org.jboss.managed.plugins.ManagedObjectImpl; import org.jboss.managed.plugins.ManagedOperationImpl; import org.jboss.managed.plugins.ManagedParameterImpl; import org.jboss.managed.plugins.WritethroughManagedPropertyImpl; import org.jboss.managed.spi.factory.InstanceClassFactory; import org.jboss.managed.spi.factory.ManagedObjectBuilder; import org.jboss.managed.spi.factory.ManagedObjectPopulator; import org.jboss.managed.spi.factory.ManagedParameterConstraintsPopulator; import org.jboss.managed.spi.factory.ManagedParameterConstraintsPopulatorFactory; import org.jboss.managed.spi.factory.ManagedPropertyConstraintsPopulator; import org.jboss.managed.spi.factory.ManagedPropertyConstraintsPopulatorFactory; import org.jboss.metadata.spi.MetaData; import org.jboss.metatype.api.types.ArrayMetaType; import org.jboss.metatype.api.types.CollectionMetaType; import org.jboss.metatype.api.types.GenericMetaType; import org.jboss.metatype.api.types.MetaType; import org.jboss.metatype.api.types.MetaTypeFactory; import org.jboss.metatype.api.values.MetaValueFactory; import org.jboss.reflect.spi.AnnotatedInfo; import org.jboss.reflect.spi.ClassInfo; import org.jboss.reflect.spi.MethodInfo; import org.jboss.reflect.spi.ParameterInfo; import org.jboss.reflect.spi.TypeInfo; /** * The base ManagedObjectFactory implementation. * * @author Adrian Brock * @author Scott.Stark@jboss.org * @version $Revision: 80522 $ */ 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, ManagedObjectBuilder> builders = new WeakHashMap, ManagedObjectBuilder>(); /** The instance to class factories */ private Map, InstanceClassFactory> instanceFactories = new WeakHashMap, 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 factory, Fields fields) { ManagedProperty property = null; try { Class[] sig = {Fields.class}; Constructor 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(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, ManagedObjectBuilder> builders, Map, InstanceClassFactory> instanceFactories) { this.metaTypeFactory = metaTypeFactory; this.metaValueFactory = metaValueFactory; this.defaultInstanceFactory = defaultInstanceFactory; this.defaultManagedObjectPopulator = defaultManagedObjectPopulator; this.builders = builders; this.instanceFactories = instanceFactories; } /** * Get the configuration * * @return the configuration */ public Configuration getConfiguration() { return configuration; } public MetaTypeFactory getMetaTypeFactory() { return metaTypeFactory; } public void setMetaTypeFactory(MetaTypeFactory metaTypeFactory) { this.metaTypeFactory = metaTypeFactory; } public MetaValueFactory getMetaValueFactory() { return metaValueFactory; } public void setMetaValueFactory(MetaValueFactory metaValueFactory) { this.metaValueFactory = metaValueFactory; } public Map, ManagedObjectBuilder> getBuilders() { return builders; } public void setBuilders(Map, ManagedObjectBuilder> builders) { this.builders = builders; } public Map, InstanceClassFactory> getInstanceFactories() { return instanceFactories; } public void setInstanceFactories( Map, 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 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 defaultManagedObjectPopulator) { this.defaultManagedObjectPopulator = defaultManagedObjectPopulator; } @Override public ManagedObject createManagedObject(Class clazz, MetaData metaData) { if (clazz == null) throw new IllegalArgumentException("Null class"); ManagedObject result = createSkeletonManagedObject(clazz, metaData); ManagedObjectPopulator 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 moClass; try { moClass = icf.getManagedObjectClass(instance); } catch(ClassNotFoundException e) { log.debug("Failed to load class for ManagedObject", e); return null; } if(moClass == null) { log.debug("ICF returned null class: "+instance); return null; } ManagedObject result = createSkeletonManagedObject(moClass, metaData); if (result == null ) { log.debug("Null ManagedObject created for: "+moClass); return null; } if(result instanceof MutableManagedObject) { MutableManagedObject mmo = (MutableManagedObject) result; ManagedObjectPopulator 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 void setInstanceClassFactory(Class clazz, InstanceClassFactory 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 the type * @param clazz the clazz * @return the skeleton managed object, null if clazz is not * marked as a ManagementObject. * {@linkplain ManagementObject} */ protected ManagedObject createSkeletonManagedObject(Class clazz, MetaData metaData) { if (clazz == null) throw new IllegalArgumentException("Null class"); ManagedObjectBuilder builder = getBuilder(clazz); return builder.buildManagedObject(clazz, metaData); } /** * The ManagedObjectBuilder.buildManagedObject implementation. This is based * on the org.jboss.managed.api.annotation.* package annotations. * @param clazz the attachment class * @param metaData - the optional metadata repository accessor used to query * for management annotation overrides/additions to the clazz * @return the ManagementObject if clazz is properly annotated, null if * it does not have a ManagementObject annotation on the class or metaData */ @SuppressWarnings("unchecked") public ManagedObject buildManagedObject(Class clazz, MetaData metaData) { boolean trace = log.isTraceEnabled(); BeanInfo beanInfo = configuration.getBeanInfo(clazz); ClassInfo classInfo = beanInfo.getClassInfo(); ManagementObject managementObject = getAnnotation(ManagementObject.class, classInfo, metaData); if( managementObject == null ) { if (trace) log.trace("No ManagementObject annotation, skipping ManagedObject for class: "+clazz); // Skip the ManagedObject creation return null; } HashMap moAnnotations = new HashMap(); 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 moFieldsFactory = null; Class moConstraintsFactory = null; Class moPropertyFactory = null; if (managementObject != null) { name = managementObject.name(); if (name.length() == 0 || name.equals(ManagementConstants.GENERATED)) name = classInfo.getName(); nameType = managementObject.type(); if (nameType.length() == 0) nameType = null; attachmentName = managementObject.attachmentName(); if (attachmentName.length() == 0) attachmentName = classInfo.getName(); // Check for a component specification ManagementComponent mc = managementObject.componentType(); // Work around JBMDR-51 by checking type/subtype // if (mc.equals(AnnotationDefaults.COMP_TYPE) == false) if (mc.type().length() > 0 || mc.subtype().length() > 0) moAnnotations.put(ManagementComponent.class.getName(), mc); // ManagementObject level default factory classes moFieldsFactory = managementObject.fieldsFactory(); moConstraintsFactory = managementObject.constraintsFactory(); moPropertyFactory = managementObject.propertyFactory(); } if (trace) { log.trace("Building MangedObject(name="+name+",nameType="+nameType +",attachmentName="+attachmentName+",isRuntime="+isRuntime+")"); } ManagementProperties propertyType = ManagementProperties.ALL; Set classProperties = null; if (managementObject != null) { propertyType = managementObject.properties(); if(propertyType == ManagementProperties.CLASS || propertyType == ManagementProperties.CLASS_AND_EXPLICIT) { classProperties = new HashSet(); 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 properties = new HashSet(); Set propertyInfos = beanInfo.getProperties(); if (propertyInfos != null && propertyInfos.isEmpty() == false) { for (PropertyInfo propertyInfo : propertyInfos) { // Ignore the "class" property if ("class".equals(propertyInfo.getName())) continue; ManagementProperty managementProperty = getAnnotation(ManagementProperty.class, propertyInfo, metaData); ManagementObjectID id = getAnnotation(ManagementObjectID.class, propertyInfo, metaData); ManagementObjectRef ref = getAnnotation(ManagementObjectRef.class, propertyInfo, metaData); ManagementRuntimeRef runtimeRef = getAnnotation(ManagementRuntimeRef.class, propertyInfo, metaData); HashMap propAnnotations = new HashMap(); if (managementProperty != null) propAnnotations.put(ManagementProperty.class.getName(), managementProperty); if (id != null) { propAnnotations.put(ManagementObjectID.class.getName(), id); // This overrides the MO nameType nameType = id.type(); } if (ref != null) propAnnotations.put(ManagementObjectRef.class.getName(), ref); if (runtimeRef != null) propAnnotations.put(ManagementRuntimeRef.class.getName(), runtimeRef); // Check whether this property should be included boolean includeProperty = false; switch(propertyType) { // Only if the property as a ManagementProperty case EXPLICIT: includeProperty = managementProperty != null && (managementProperty.ignored() == false); break; // Only if the property is listed in the classProperties case CLASS: includeProperty = classProperties.contains(propertyInfo.getName()); break; // Only if the property is listed in the classProperties case CLASS_AND_EXPLICIT: includeProperty = classProperties.contains(propertyInfo.getName()) || (managementProperty != null && managementProperty.ignored() == false); break; // Any property that is not ignored case ALL: includeProperty = managementProperty == null || managementProperty.ignored() == false; break; } if (includeProperty) { Fields fields = null; if (managementProperty != null) { Class factory = moFieldsFactory; if (factory == ManagementProperty.NULL_FIELDS_FACTORY.class) factory = managementProperty.fieldsFactory(); if (factory != ManagementProperty.NULL_FIELDS_FACTORY.class) { try { fields = factory.newInstance(); } catch (Exception e) { log.debug("Failed to created Fields", e); } } } if (fields == null) fields = new DefaultFieldsImpl(); if( propertyInfo instanceof Serializable ) { Serializable info = Serializable.class.cast(propertyInfo); fields.setField(Fields.PROPERTY_INFO, info); } String propertyName = propertyInfo.getName(); if (managementProperty != null) propertyName = managementProperty.name(); if( propertyName.length() == 0 ) propertyName = propertyInfo.getName(); fields.setField(Fields.NAME, propertyName); // This should probably always the the propertyInfo name? String mappedName = propertyInfo.getName(); if (managementProperty != null) mappedName = managementProperty.mappedName(); if( mappedName.length() == 0 ) mappedName = propertyInfo.getName(); fields.setField(Fields.MAPPED_NAME, mappedName); String description = ManagementConstants.GENERATED; if (managementProperty != null) description = managementProperty.description(); if (description.equals(ManagementConstants.GENERATED)) description = propertyName; fields.setField(Fields.DESCRIPTION, description); if (trace) { log.trace("Building MangedProperty(name="+propertyName +",mappedName="+mappedName +") ,annotations="+propAnnotations); } boolean mandatory = false; if (managementProperty != null) mandatory = managementProperty.mandatory(); if (mandatory) fields.setField(Fields.MANDATORY, Boolean.TRUE); boolean managed = false; if (managementProperty != null) managed = managementProperty.managed(); MetaType metaType; if (managed) { TypeInfo typeInfo = propertyInfo.getType(); if(typeInfo.isArray()) metaType = new ArrayMetaType(1, MANAGED_OBJECT_META_TYPE); else if (typeInfo.isCollection()) metaType = new CollectionMetaType(typeInfo.getName(), MANAGED_OBJECT_META_TYPE); else metaType = MANAGED_OBJECT_META_TYPE; } else { metaType = metaTypeFactory.resolve(propertyInfo.getType()); } fields.setField(Fields.META_TYPE, metaType); if (propAnnotations.isEmpty() == false) fields.setField(Fields.ANNOTATIONS, propAnnotations); // Delegate others (legal values, min/max etc.) to the constraints factory try { Class factoryClass = moConstraintsFactory; if (factoryClass == ManagementProperty.NULL_CONSTRAINTS.class) { if (managementProperty != null) factoryClass = managementProperty.constraintsFactory(); } ManagedPropertyConstraintsPopulatorFactory factory = factoryClass.newInstance(); ManagedPropertyConstraintsPopulator populator = factory.newInstance(); if (populator != null) populator.populateManagedProperty(clazz, propertyInfo, fields); } catch(Exception e) { log.debug("Failed to populate constraints for: "+propertyInfo, e); } ManagedProperty property = null; if (managementProperty != null) { Class factory = moPropertyFactory; if (factory == ManagementProperty.NULL_PROPERTY_FACTORY.class) factory = managementProperty.propertyFactory(); if (factory != ManagementProperty.NULL_PROPERTY_FACTORY.class) property = getManagedProperty(factory, fields); } // we should have write-through by default // use factory to change this default behavior if (property == null) property = createDefaultManagedProperty(fields); properties.add(property); } else if (trace) log.trace("Ignoring property: " + propertyInfo); } } /* TODO: Operations. In general the bean metadata does not contain operation information. */ Set operations = new HashSet(); Set methodInfos = beanInfo.getMethods(); if (methodInfos != null && methodInfos.isEmpty() == false) { for (MethodInfo methodInfo : methodInfos) { ManagementOperation managementOp = getAnnotation(ManagementOperation.class, methodInfo, metaData); if (managementOp == null) continue; ManagedOperation op = getManagedOperation(methodInfo, managementOp); operations.add(op); } } ManagedObjectImpl result = new ManagedObjectImpl(name, properties); result.setAnnotations(moAnnotations); if (nameType != null) result.setNameType(nameType); if (attachmentName != null) result.setAttachmentName(attachmentName); if (operations.size() > 0 ) result.setOperations(operations); for (ManagedProperty property : properties) property.setManagedObject(result); return result; } /** * Create default MangedProperty instance. * Override this method for different default. * * @param fields the fields * @return new ManagedProperty instance */ protected ManagedProperty createDefaultManagedProperty(Fields fields) { return new WritethroughManagedPropertyImpl(fields, metaValueFactory, this); } /** * Get the property name. * * @param property managed property * @return property name */ protected String getPropertyName(ManagedProperty property) { // First look to the mapped name String name = property.getMappedName(); if (name == null) property.getName(); return name; } /** * * @param methodInfo * @param opAnnotation * @return the managed operation */ protected ManagedOperation getManagedOperation(MethodInfo methodInfo, ManagementOperation opAnnotation) { String name = methodInfo.getName(); String description = opAnnotation.description(); Impact impact = opAnnotation.impact(); ManagementParameter[] params = opAnnotation.params(); ParameterInfo[] paramInfo = methodInfo.getParameters(); TypeInfo returnInfo = methodInfo.getReturnType(); MetaType returnType = metaTypeFactory.resolve(returnInfo); ArrayList mparams = new ArrayList(); Class opConstraintsFactor = opAnnotation.constraintsFactory(); if( paramInfo != null ) { for(int i = 0; i < paramInfo.length; i ++) { ParameterInfo pinfo = paramInfo[i]; String pname = pinfo.getName(); String pdescription = null; ManagementParameter mpa = null; // Look to ManagementParameter for info if (i < params.length) { mpa = params[i]; if (mpa.name().equals(AnnotationDefaults.EMPTY_STRING) == false) pname = mpa.name(); if (mpa.description().equals(AnnotationDefaults.EMPTY_STRING) == false) pdescription = mpa.description(); } // Generate a name if there is none if (pname == null) pname = "arg#" + i; Fields fields = new DefaultFieldsImpl(pname); if (pdescription != null) fields.setField(Fields.DESCRIPTION, pdescription); MetaType metaType = metaTypeFactory.resolve(pinfo.getParameterType()); fields.setField(Fields.META_TYPE, metaType); // Delegate others (legal values, min/max etc.) to the constraints factory try { Class factoryClass = opConstraintsFactor; if (factoryClass == ManagementParameter.NULL_CONSTRAINTS.class) { if (mpa != null) factoryClass = mpa.constraintsFactory(); } ManagedParameterConstraintsPopulatorFactory factory = factoryClass.newInstance(); ManagedParameterConstraintsPopulator populator = factory.newInstance(); if (populator != null) populator.populateManagedParameter(name, pinfo, fields); } catch(Exception e) { log.debug("Failed to populate constraints for: "+pinfo, e); } ManagedParameterImpl mp = new ManagedParameterImpl(fields); mparams.add(mp); } } ManagedParameter[] parameters = new ManagedParameter[mparams.size()]; mparams.toArray(parameters); return new ManagedOperationImpl(name, description, impact, parameters, returnType); } /** * Get the builder for a class * * @param clazz the class * @return the builder */ protected ManagedObjectBuilder getBuilder(Class clazz) { synchronized (builders) { ManagedObjectBuilder builder = builders.get(clazz); if (builder != null) return builder; } return this; } /** * Get the instance factory for a class * * @param clazz the class * @return the InstanceClassFactory */ @SuppressWarnings("unchecked") public InstanceClassFactory getInstanceClassFactory(Class clazz, MetaData metaData) { InstanceClassFactory defaultFactory = defaultInstanceFactory; if(metaData != null) { InstanceClassFactory mdrFactory = metaData.getMetaData(InstanceClassFactory.class); if(mdrFactory != null) defaultFactory = mdrFactory; } InstanceClassFactory factory = (InstanceClassFactory) Utility.getInstanceClassFactory(clazz, instanceFactories, defaultFactory); return factory; } /** * Get the populator for a class * * @param clazz the class * @return the populator */ @SuppressWarnings("unchecked") protected ManagedObjectPopulator getPopulator(Class clazz) { ManagedObjectBuilder builder = getBuilder(clazz); if (builder instanceof ManagedObjectPopulator) return (ManagedObjectPopulator) builder; ManagedObjectPopulator mop = (ManagedObjectPopulator) 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 factory, Fields fields) { return createManagedProperty(factory, fields); } protected X getAnnotation(Class annotationType, AnnotatedInfo info, MetaData metaData) { X annotation = null; if(metaData != null) { annotation = metaData.getAnnotation(annotationType); if(annotation != null) log.trace("Loaded "+annotationType+" from MetaData"); } if(annotation == null) annotation = info.getUnderlyingAnnotation(annotationType); return annotation; } } ././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/plugins/factory/DeploymentTemplateInfoFactory.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/plugins/factory/Deploym0000644000175000017500000003016410770514540033143 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, Red Hat Middleware LLC, and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.managed.plugins.factory; import java.io.Serializable; import java.lang.annotation.Annotation; import java.lang.reflect.Constructor; import java.util.HashMap; import java.util.Map; import java.util.Set; 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.DeploymentTemplateInfo; import org.jboss.managed.api.Fields; import org.jboss.managed.api.ManagedObject; import org.jboss.managed.api.ManagedProperty; import org.jboss.managed.api.annotation.ManagementConstants; import org.jboss.managed.api.annotation.ManagementProperty; import org.jboss.managed.plugins.BasicDeploymentTemplateInfo; import org.jboss.managed.plugins.DefaultFieldsImpl; import org.jboss.managed.plugins.WritethroughManagedPropertyImpl; import org.jboss.managed.spi.factory.ManagedPropertyConstraintsPopulator; import org.jboss.managed.spi.factory.ManagedPropertyConstraintsPopulatorFactory; import org.jboss.metatype.api.types.ArrayMetaType; import org.jboss.metatype.api.types.CollectionMetaType; import org.jboss.metatype.api.types.MetaType; import org.jboss.metatype.api.types.MetaTypeFactory; import org.jboss.metatype.api.values.MetaValueFactory; import org.jboss.reflect.spi.TypeInfo; /** * Creates a DeploymentTemplateInfo from a ManagedObject view, or * the deployment attachment class * * @author Scott.Stark@jboss.org * @version $Revision: 71085 $ */ public class DeploymentTemplateInfoFactory { private static final Logger log = Logger.getLogger(DeploymentTemplateInfoFactory.class); /** The configuration */ private static final Configuration configuration = PropertyConfigurationAccess.getConfiguration(); /** The meta type factory */ private MetaTypeFactory metaTypeFactory = MetaTypeFactory.getInstance(); /** The meta value factory */ private MetaValueFactory metaValueFactory = MetaValueFactory.getInstance(); 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; } /** * Create a DeploymentTemplateInfo from the ManagedObject view. This is * based on locating the ManagedPropertys with a ManagementProperty * annotation with a includeInTemplate=true field. * @param mo - the ManagedObject for the deployment template * @param name - the name of the deployment template * @param description - a description of the deployment template * @return a DeploymentTemplateInfo containing the template properties. */ public DeploymentTemplateInfo createTemplateInfo(ManagedObject mo, String name, String description) { Map infoProps = new HashMap(); Map props = mo.getProperties(); if(props != null) { for(ManagedProperty prop : props.values()) { Map pannotations = prop.getAnnotations(); if(pannotations != null) { ManagementProperty mp = (ManagementProperty) pannotations.get(ManagementProperty.class.getName()); if(mp != null && mp.includeInTemplate()) infoProps.put(prop.getName(), prop); } } } DeploymentTemplateInfo info = new BasicDeploymentTemplateInfo(name, description, infoProps); return info; } /** * Create a DeploymentTemplateInfo by scanning the metadata attachment * class for ManagementProperty annotations. * @param attachmentClass - the metadata class to scan for ManagementProperty annotations * @param name - the template name * @param description - the template description * @return the DeploymentTemplateInfo instance * @throws Exception on failure to create the DeploymentTemplateInfo */ public DeploymentTemplateInfo createTemplateInfo(Class attachmentClass, String name, String description) throws Exception { return createTemplateInfo(BasicDeploymentTemplateInfo.class, attachmentClass, name, description); } /** * Create a DeploymentTemplateInfo by scanning the metadata attachment * class for ManagementProperty annotations. * @param infoClass - the DeploymentTemplateInfo implementation to use. Must * have a ctor with sig (String,String,Map). * @param attachmentClass - the metadata class to scan for ManagementProperty annotations * @param name - the template name * @param description - the template description * @return the DeploymentTemplateInfo instance * @throws Exception on failure to create the DeploymentTemplateInfo */ public DeploymentTemplateInfo createTemplateInfo(Class infoClass, Class attachmentClass, String name, String description) throws Exception { BeanInfo beanInfo = configuration.getBeanInfo(attachmentClass); Map infoProps = new HashMap(); Set propertyInfos = beanInfo.getProperties(); if (propertyInfos != null && propertyInfos.isEmpty() == false) { for (PropertyInfo propertyInfo : propertyInfos) { ManagementProperty managementProperty = propertyInfo.getUnderlyingAnnotation(ManagementProperty.class); if(managementProperty != null && managementProperty.includeInTemplate()) { ManagedProperty mp = createProperty(propertyInfo, managementProperty); infoProps.put(mp.getName(), mp); } } } Class[] parameterTypes = {String.class, String.class, Map.class}; Constructor ctor = infoClass.getConstructor(parameterTypes); DeploymentTemplateInfo info = ctor.newInstance(name, description, infoProps); return info; } @SuppressWarnings("deprecation") protected ManagedProperty createProperty(PropertyInfo propertyInfo, ManagementProperty managementProperty) { boolean trace = log.isTraceEnabled(); ManagedProperty property = null; // Check for a simple property boolean includeProperty = (managementProperty.ignored() == false); if (includeProperty) { HashMap propAnnotations = new HashMap(); propAnnotations.put(ManagementProperty.class.getName(), managementProperty); Fields fields = null; if (managementProperty != null) { Class factory = managementProperty.fieldsFactory(); if (factory != ManagementProperty.NULL_FIELDS_FACTORY.class) { try { fields = factory.newInstance(); } catch (Exception e) { log.debug("Failed to created Fields", e); } } } if (fields == null) fields = new DefaultFieldsImpl(); if( propertyInfo instanceof Serializable ) { Serializable info = Serializable.class.cast(propertyInfo); fields.setField(Fields.PROPERTY_INFO, info); } String propertyName = propertyInfo.getName(); if (managementProperty != null) propertyName = managementProperty.name(); if( propertyName.length() == 0 ) propertyName = propertyInfo.getName(); fields.setField(Fields.NAME, propertyName); // This should probably always the the propertyInfo name? String mappedName = propertyInfo.getName(); if (managementProperty != null) mappedName = managementProperty.mappedName(); if( mappedName.length() == 0 ) mappedName = propertyInfo.getName(); fields.setField(Fields.MAPPED_NAME, mappedName); String description = ManagementConstants.GENERATED; if (managementProperty != null) description = managementProperty.description(); if (description.equals(ManagementConstants.GENERATED)) description = propertyName; fields.setField(Fields.DESCRIPTION, description); if (trace) { log.trace("Building MangedProperty(name="+propertyName +",mappedName="+mappedName +") ,annotations="+propAnnotations); } boolean mandatory = false; if (managementProperty != null) mandatory = managementProperty.mandatory(); if (mandatory) fields.setField(Fields.MANDATORY, Boolean.TRUE); boolean managed = false; if (managementProperty != null) managed = managementProperty.managed(); MetaType metaType; if (managed) { TypeInfo typeInfo = propertyInfo.getType(); if(typeInfo.isArray()) metaType = new ArrayMetaType(1, AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE); else if (typeInfo.isCollection()) metaType = new CollectionMetaType(typeInfo.getName(), AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE); else metaType = AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE; } else { metaType = metaTypeFactory.resolve(propertyInfo.getType()); } fields.setField(Fields.META_TYPE, metaType); if (propAnnotations.isEmpty() == false) fields.setField(Fields.ANNOTATIONS, propAnnotations); // Delegate others (legal values, min/max etc.) to the constraints factory try { Class factoryClass = managementProperty.constraintsFactory(); ManagedPropertyConstraintsPopulatorFactory factory = factoryClass.newInstance(); ManagedPropertyConstraintsPopulator populator = factory.newInstance(); if (populator != null) { Class clazz = propertyInfo.getBeanInfo().getClassInfo().getType(); populator.populateManagedProperty(clazz, propertyInfo, fields); } } catch(Exception e) { log.debug("Failed to populate constraints for: "+propertyInfo, e); } if (managementProperty != null) { Class factory = managementProperty.propertyFactory(); if (factory != ManagementProperty.NULL_PROPERTY_FACTORY.class) property = AbstractManagedObjectFactory.createManagedProperty(factory, fields); } // we should have write-through by default // use factory to change this default behavior if (property == null) property = new WritethroughManagedPropertyImpl(fields, metaValueFactory, null); } return property; } } ././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/plugins/factory/ManagedObjectFactoryBuilder.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/plugins/factory/Managed0000644000175000017500000000650011044240053033051 0ustar twernertwerner/* * 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.security.AccessController; import java.security.PrivilegedAction; import org.jboss.managed.api.factory.ManagedObjectFactory; /** * ManagedObjectFactoryBuilder factory for ManagedObjectFactory. * * TODO this class only creates a singleton implementation for now, configurable * via the org.jboss.managed.api.factory.ManagedObjectFactory system property. * * @author Adrian Brock * @author Scott.Stark@jboss.org * @version $Revision: 76500 $ */ public class ManagedObjectFactoryBuilder { /** The singleton */ private static final ManagedObjectFactory singleton; static { singleton = AccessController.doPrivileged(new PrivilegedAction() { public ManagedObjectFactory run() { ManagedObjectFactory mof = null; String defaultMOF = AbstractManagedObjectFactory.class.getName(); // The system property for the ManagedObjectFactory class to use String className = System.getProperty(ManagedObjectFactory.class.getName(), defaultMOF); try { Class clazz; try { clazz = Thread.currentThread().getContextClassLoader().loadClass(className); } catch (ClassNotFoundException e) { try { clazz = getClass().getClassLoader().loadClass(className); } catch (ClassNotFoundException ignored) { throw e; } } Object result = clazz.newInstance(); mof = ManagedObjectFactory.class.cast(result); } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new Error("Unexpected error loading ManagedObjectFactory " + className, e); } return mof; } }); } /** * Create the factory * * @return the factory */ public static ManagedObjectFactory create() { return singleton; } } ././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/plugins/factory/DefaultInstanceClassFactory.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/plugins/factory/Default0000644000175000017500000000311411104137625033106 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.managed.plugins.factory; import org.jboss.managed.api.factory.ManagedObjectFactory; /** * A simple extension of AbstractInstanceClassFactory that handles the * default Object.class type. * * @author Scott.Stark@jboss.org * @version $Revision:$ */ public class DefaultInstanceClassFactory extends AbstractInstanceClassFactory { public DefaultInstanceClassFactory() { super(); } public DefaultInstanceClassFactory(ManagedObjectFactory mof) { super(mof); } public Class getType() { return Object.class; } } ././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/plugins/factory/AbstractInstanceClassFactory.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/plugins/factory/Abstrac0000644000175000017500000003470111104137625033107 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, Red Hat Middleware LLC, and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.managed.plugins.factory; import java.lang.reflect.UndeclaredThrowableException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.List; import java.util.Map; import java.util.WeakHashMap; import org.jboss.beans.info.spi.BeanInfo; import org.jboss.beans.info.spi.PropertyInfo; import org.jboss.config.plugins.property.PropertyConfiguration; import org.jboss.config.spi.Configuration; import org.jboss.managed.api.ManagedObject; import org.jboss.managed.api.ManagedProperty; import org.jboss.managed.api.MutableManagedObject; import org.jboss.managed.api.annotation.ManagementObjectRef; import org.jboss.managed.api.annotation.ManagementRuntimeRef; import org.jboss.managed.api.factory.ManagedObjectFactory; import org.jboss.managed.spi.factory.InstanceClassFactory; import org.jboss.managed.spi.factory.RuntimeComponentNameTransformer; import org.jboss.metadata.spi.MetaData; import org.jboss.metatype.api.types.ArrayMetaType; import org.jboss.metatype.api.types.CollectionMetaType; import org.jboss.metatype.api.types.MetaType; import org.jboss.metatype.api.values.ArrayValueSupport; import org.jboss.metatype.api.values.CollectionValueSupport; import org.jboss.metatype.api.values.GenericValue; import org.jboss.metatype.api.values.GenericValueSupport; import org.jboss.metatype.api.values.MetaValue; import org.jboss.metatype.api.values.MetaValueFactory; import org.jboss.reflect.spi.TypeInfo; import org.jboss.util.NotImplementedException; /** * A base InstanceClassFactory implementation that uses jboss reflection to * get/set values on the underlying property object. * * Runtime component names are handled via a mapping from TypeInfo to * {@linkplain RuntimeComponentNameTransformer} using property ManagementRuntimeRef * information. * * @param the instance type * @author Scott.Stark@jboss.org * @version $Revision: 80522 $ */ public abstract class AbstractInstanceClassFactory implements InstanceClassFactory { /** The configuration */ private Configuration configuration = new PropertyConfiguration(); /** The meta value factory */ private MetaValueFactory metaValueFactory = MetaValueFactory.getInstance(); /** The instance to name transformers */ private Map transformers = new WeakHashMap(); /** The ManagedObjectFactory used in getValue for MANAGED_OBJECT_META_TYPEs */ private ManagedObjectFactory mof; public AbstractInstanceClassFactory() { this(null); } /** * Create an AbstractInstanceClassFactory with a ManagedObjectFactory. The * ManagedObjectFactory is neede for GenericValue creation. * @param mof - the ManagedObjectFactory delegated to for GenericValue handling. * @see #getManagedObjectValue(BeanInfo, ManagedProperty, Object) * @see #getManagedObjectArray(BeanInfo, ManagedProperty, Object) */ public AbstractInstanceClassFactory(ManagedObjectFactory mof) { this.mof = mof; } public Map getTransformers() { return transformers; } public void setTransformers(Map transformers) { this.transformers = transformers; } public void setNameTransformers(Class clazz, RuntimeComponentNameTransformer transformer) { TypeInfo type = configuration.getTypeInfo(clazz); setNameTransformers(type, transformer); } public void setNameTransformers(TypeInfo type, RuntimeComponentNameTransformer transformer) { synchronized (transformers) { if (transformer == null) transformers.remove(type); else transformers.put(type, transformer); } } public Configuration getConfiguration() { return configuration; } public void setConfiguration(Configuration configuration) { this.configuration = configuration; } public MetaValueFactory getMetaValueFactory() { return metaValueFactory; } public void setMetaValueFactory(MetaValueFactory metaValueFactory) { this.metaValueFactory = metaValueFactory; } public ManagedObjectFactory getMof() { return mof; } public void setMof(ManagedObjectFactory mof) { this.mof = mof; } /** * Default InstanceClassFactory implementation simply returns the * attachment class. */ public Class getManagedObjectClass(T attachment) throws ClassNotFoundException { return attachment.getClass(); } public Object getComponentName(BeanInfo beanInfo, ManagedProperty property, T attachment, MetaValue value) { if (beanInfo != null && property != null && value != null) { String name = getPropertyName(property); PropertyInfo propertyInfo = beanInfo.getProperty(name); ManagementRuntimeRef componentRef = propertyInfo.getUnderlyingAnnotation(ManagementRuntimeRef.class); if (componentRef != null) { Object original = this.unwrapValue(beanInfo, property, value); try { Class tClass = componentRef.transformer(); RuntimeComponentNameTransformer transformer; if (tClass != ManagementRuntimeRef.DEFAULT_NAME_TRANSFORMER.class) transformer = getComponentNameTransformer(configuration.getTypeInfo(tClass)); else transformer = getComponentNameTransformer(propertyInfo.getType()); return (transformer != null) ? transformer.transform(original) : original; } catch (Throwable t) { throw new UndeclaredThrowableException(t); } } } return null; } public MetaValue getValue(BeanInfo beanInfo, ManagedProperty property, MetaData metaData, T object) { String name = getPropertyName(property); PropertyInfo propertyInfo = beanInfo.getProperty(name); Object value; try { value = propertyInfo.get(object); } catch (RuntimeException e) { throw e; } catch (Error e) { throw e; } catch (Throwable t) { throw new RuntimeException("Error getting property " + name + " for " + object.getClass().getName(), t); } if (value == null) return null; MetaType propertyType = property.getMetaType(); if (AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE == propertyType) { GenericValue gvs = getManagedObjectValue(beanInfo, property, metaData, value); return gvs; } else if (propertyType.isArray()) { ArrayMetaType arrayType = ArrayMetaType.class.cast(propertyType); if (AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE == arrayType.getElementType()) { ArrayMetaType moType = new ArrayMetaType(1, AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE); ArrayValueSupport moArrayValue = new ArrayValueSupport(moType); List tmp = getManagedObjectArray(beanInfo, property, metaData, value); GenericValue[] mos = new GenericValue[tmp.size()]; moArrayValue.setValue(tmp.toArray(mos)); return moArrayValue; } } else if (propertyType.isCollection()) { CollectionMetaType collectionType = CollectionMetaType.class.cast(propertyType); if (AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE == collectionType.getElementType()) { List tmp = getManagedObjectArray(beanInfo, property, metaData, value); GenericValue[] mos = new GenericValue[tmp.size()]; CollectionMetaType moType = new CollectionMetaType(propertyType.getClassName(), AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE); tmp.toArray(mos); return new CollectionValueSupport(moType, mos); } } return getNonManagedObjectValue(beanInfo, property, propertyInfo, value); } /** * Set a value * * @param beanInfo the bean info * @param property the property * @param object the object * @param value the meta value */ public void setValue(BeanInfo beanInfo, ManagedProperty property, T object, MetaValue value) { String name = getPropertyName(property); PropertyInfo propertyInfo = beanInfo.getProperty(name); Object unwrapValue = unwrapValue(beanInfo, property, value); try { if(unwrapValue instanceof ManagedObject) { ManagedObject mo = (ManagedObject) unwrapValue; setManagedObject(beanInfo, propertyInfo, object, mo); } else setValue(beanInfo, propertyInfo, object, unwrapValue); } catch(Throwable t) { throw new UndeclaredThrowableException(t); } } public GenericValue getManagedObjectValue(ManagedProperty property, ManagedObject value) { return getManagedObjectValue(null, property, null, value); } public GenericValue getManagedObjectValue(ManagedProperty property, MetaData metaData, ManagedObject value) { return getManagedObjectValue(null, property, metaData, value); } protected GenericValue getManagedObjectValue(BeanInfo beanInfo, ManagedProperty property, MetaData metaData, Object value) { // Look for a ManagementObjectRef ManagementObjectRef ref = (ManagementObjectRef) property.getAnnotations().get(ManagementObjectRef.class.getName()); String moName = (ref != null ? ref.name() : value.getClass().getName()); String moNameType = (ref != null ? ref.type() : ""); ManagedObject mo; if(value instanceof ManagedObject) mo = ManagedObject.class.cast(value); else mo = mof.initManagedObject(value, null, metaData, moName, moNameType); ManagedObject parentMO = property.getManagedObject(); if(parentMO != null && mo instanceof MutableManagedObject) { MutableManagedObject mmo = (MutableManagedObject) mo; mmo.setParent(parentMO); } return new GenericValueSupport(AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE, mo); } protected List getManagedObjectArray(BeanInfo beanInfo, ManagedProperty property, MetaData metaData, Object value) { Collection cvalue = getAsCollection(value); List tmp = new ArrayList(); for(Object element : cvalue) { GenericValue gv = getManagedObjectValue(beanInfo, property, metaData, element); tmp.add(gv); } return tmp; } protected MetaValue getNonManagedObjectValue(BeanInfo beanInfo, ManagedProperty property, PropertyInfo propertyInfo, Object value) { return metaValueFactory.create(value, propertyInfo.getType()); } /** * Currently just a stub method subclasses have to override to avoid * the NotImplementedException. * * TODO: how to map the managed properties onto the corresponding attachment * object, create another ManagedObject? * * @param beanInfo * @param propertyInfo * @param object * @param mo */ protected void setManagedObject(BeanInfo beanInfo, PropertyInfo propertyInfo, T object, ManagedObject mo) { throw new NotImplementedException("Use a custom InstanceClassFactory, property="+propertyInfo); } /** * Get component name transformer. * * @param type the type info * @return transformer instance * @throws Throwable for any error */ protected RuntimeComponentNameTransformer getComponentNameTransformer(TypeInfo type) throws Throwable { synchronized(transformers) { RuntimeComponentNameTransformer transformer = transformers.get(type); if (transformer != null) return transformer; TypeInfo rcntType = configuration.getTypeInfo(RuntimeComponentNameTransformer.class); if (rcntType.isAssignableFrom(type)) { BeanInfo beanInfo = configuration.getBeanInfo(type); RuntimeComponentNameTransformer newTransformer = (RuntimeComponentNameTransformer)beanInfo.newInstance(); transformers.put(type, newTransformer); return newTransformer; } return null; } } protected Object unwrapValue(BeanInfo beanInfo, ManagedProperty property, MetaValue value) { String name = getPropertyName(property); PropertyInfo propertyInfo = beanInfo.getProperty(name); Object unwrapValue = metaValueFactory.unwrap(value, propertyInfo.getType()); return unwrapValue; } protected void setValue(BeanInfo beanInfo, PropertyInfo propertyInfo, Object object, Object unwrapValue) throws Throwable { propertyInfo.set(object, unwrapValue); } 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; } /** * 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; } } ././@LongLink0000000000000000000000000000020300000000000011560 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/plugins/factory/AbstractComponentNameTransformer.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/plugins/factory/Abstrac0000644000175000017500000000406410701754233033110 0ustar twernertwerner/* * 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.factory; import org.jboss.managed.spi.factory.RuntimeComponentNameTransformer; /** * Abstract component name transformer. * * @param exact value type * @author Ales Justin */ public abstract class AbstractComponentNameTransformer implements RuntimeComponentNameTransformer { private Class type; protected AbstractComponentNameTransformer(Class type) { if (type == null) throw new IllegalArgumentException("Null type."); this.type = type; } public Object transform(Object value) { if (value == null) return null; if (type.isAssignableFrom(value.getClass()) == false) return new IllegalArgumentException("Value is not instance of " + type + ", value: " + value); return doTransform(type.cast(value)); } /** * Transform on exact type. * * @param value the value * @return transformed name */ protected abstract Object doTransform(T value); } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/plugins/factory/ObjectNameTransformer.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/plugins/factory/ObjectN0000644000175000017500000000272210701754233033054 0ustar twernertwerner/* * 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.factory; import javax.management.ObjectName; /** * Object name transformer. * * @author Ales Justin */ public class ObjectNameTransformer extends AbstractComponentNameTransformer { public ObjectNameTransformer() { super(ObjectName.class); } protected Object doTransform(ObjectName value) { return value.getCanonicalName(); } } ././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/plugins/factory/AbstractManagedObjectPopulator.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/plugins/factory/Abstrac0000644000175000017500000002216111104137625033104 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.managed.plugins.factory; import java.lang.annotation.Annotation; import java.util.Map; import org.jboss.beans.info.spi.BeanInfo; 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.ManagedProperty; import org.jboss.managed.api.MutableManagedObject; import org.jboss.managed.api.annotation.ManagementObjectID; import org.jboss.managed.api.annotation.ManagementRuntimeRef; import org.jboss.managed.spi.factory.InstanceClassFactory; import org.jboss.managed.spi.factory.ManagedObjectPopulator; import org.jboss.metadata.spi.MetaData; import org.jboss.metatype.api.values.MetaValue; import org.jboss.metatype.api.values.SimpleValue; /** * A default ManagedObjectPopulator implementation that relies on mc configuration * for obtaining BeanInfos for a class, and InstanceClassFactorys for * class, name and values from a value to be managed. * * @param the type to populate * @author Scott.Stark@jboss.org * @version $Revision: 80522 $ */ public class AbstractManagedObjectPopulator implements ManagedObjectPopulator { private static Logger log = Logger.getLogger(AbstractManagedObjectPopulator.class); /** The configuration */ private Configuration configuration; private InstanceClassFactory defaultInstanceFactory; /** The instance to class factories */ private Map, InstanceClassFactory> instanceFactories; public AbstractManagedObjectPopulator(Configuration configuration) { this(configuration, null, null); } public AbstractManagedObjectPopulator( Configuration configuration, InstanceClassFactory defaultInstanceFactory, Map, InstanceClassFactory> instanceFactories) { super(); this.configuration = configuration; this.defaultInstanceFactory = defaultInstanceFactory; this.instanceFactories = instanceFactories; } public Configuration getConfiguration() { return configuration; } public void setConfiguration(Configuration configuration) { this.configuration = configuration; } public InstanceClassFactory getDefaultInstanceFactory() { return defaultInstanceFactory; } public void setDefaultInstanceFactory(InstanceClassFactory defaultInstanceFactory) { this.defaultInstanceFactory = defaultInstanceFactory; } public Map, InstanceClassFactory> getInstanceFactories() { return instanceFactories; } public void setInstanceFactories(Map, InstanceClassFactory> instanceFactories) { this.instanceFactories = instanceFactories; } public void createObject(ManagedObject managedObject, Class clazz) { createObject(managedObject, clazz, null); } public void createObject(ManagedObject managedObject, Class clazz, MetaData metaData) { if (managedObject == null) throw new IllegalArgumentException("Null managed object"); if (managedObject instanceof MutableManagedObject == false) throw new IllegalStateException("Unable to create object " + managedObject.getClass().getName()); MutableManagedObject managedObjectImpl = (MutableManagedObject) managedObject; T object = createUnderlyingObject(managedObjectImpl, clazz); populateManagedObject(managedObjectImpl, object, null); } public void populateManagedObject(MutableManagedObject managedObject, T object) { populateManagedObject(managedObject, object); } public void populateManagedObject(MutableManagedObject managedObject, T object, MetaData metaData) { managedObject.setAttachment(object); populateValues(managedObject, object, metaData); } /** * Get the instance factory for a class * * @param the class to get an instance factory for * @param clazz the class * @return the InstanceClassFactory */ @SuppressWarnings("unchecked") public InstanceClassFactory getInstanceClassFactory(Class clazz, MetaData metaData) { InstanceClassFactory factory = (InstanceClassFactory) Utility.getInstanceClassFactory(clazz, instanceFactories, defaultInstanceFactory, metaData); return factory; } /** * Create the underlying object * * @param managedObject the managed object * @param clazz the class * @return the object */ protected T createUnderlyingObject(MutableManagedObject managedObject, Class clazz) { BeanInfo beanInfo = configuration.getBeanInfo(clazz); try { Object result = beanInfo.newInstance(); return clazz.cast(result); } catch (Throwable t) { throw new RuntimeException("Unable to create new object for " + managedObject + " clazz=" + clazz, t); } } /** * Populate the values * * @param managedObject the managed object * @param object the object */ @SuppressWarnings("unchecked") protected void populateValues(MutableManagedObject managedObject, T object, MetaData metaData) { InstanceClassFactory icf = getInstanceClassFactory(object.getClass(), metaData); Class moClass; try { moClass = icf.getManagedObjectClass(object); } catch(ClassNotFoundException e) { throw new IllegalStateException(e); } BeanInfo beanInfo = configuration.getBeanInfo(moClass); Object componentName = null; Map properties = managedObject.getProperties(); if (properties != null && properties.size() > 0) { for (ManagedProperty property : properties.values()) { MetaValue value = null; try { value = icf.getValue(beanInfo, property, metaData, object); } catch(Throwable t) { if(log.isTraceEnabled()) log.trace("Failed to access value for property: "+property, t); } if (value != null) property.setField(Fields.VALUE, value); /* Need to look for a ManagementObjectID at the property level which defines the ManagedObject id name from the property value. */ Map annotations = property.getAnnotations(); if (annotations == null && metaData == null) continue; ManagementObjectID id = getAnnotation(ManagementObjectID.class, annotations, metaData); if (id != null) { if (value == null || value.getMetaType().isSimple() == false) { log.warn("Cannot create String name from non-Simple property: " + property + ", value=" + value); continue; } SimpleValue svalue = (SimpleValue) value; String name = "" + svalue.getValue(); managedObject.setName(name); } ManagementRuntimeRef runtimeRef = getAnnotation(ManagementRuntimeRef.class, annotations, metaData); if (runtimeRef != null) { componentName = icf.getComponentName(beanInfo, property, object, value); if(componentName == null && defaultInstanceFactory != null) { InstanceClassFactory dicf = defaultInstanceFactory; componentName = dicf.getComponentName(beanInfo, property, object, value); } } } } if (componentName == null) componentName = icf.getComponentName(null, null, object, null); // set it, even if it's null managedObject.setComponentName(componentName); } private static X getAnnotation(Class clazz, Map annotations, MetaData metaData) { X annotation = null; if(metaData != null) annotation = metaData.getAnnotation(clazz); if(annotation == null && annotations != null) annotation = (X) annotations.get(clazz.getName()); return annotation; } } ././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/plugins/factory/PropertyConfigurationAccess.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/plugins/factory/Propert0000644000175000017500000000365210763656725033205 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, Red Hat Middleware LLC, and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.managed.plugins.factory; import java.security.AccessController; import java.security.PrivilegedAction; import org.jboss.config.plugins.property.PropertyConfiguration; import org.jboss.config.spi.Configuration; /** * A package protected PrivilegedAction impl * * @author Scott.Stark@jboss.org * @version $Revision: 70458 $ */ class PropertyConfigurationAccess implements PrivilegedAction { public Configuration run() { return new PropertyConfiguration(); } static Configuration getConfiguration() { SecurityManager secMgr = System.getSecurityManager(); Configuration config = null; if(secMgr != null) { PropertyConfigurationAccess pca = new PropertyConfigurationAccess(); config = AccessController.doPrivileged(pca); } else { config = new PropertyConfiguration(); } return config; } } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/plugins/ManagedPropertyImpl.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/plugins/ManagedProperty0000644000175000017500000002657710763706473033213 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.managed.plugins; import java.io.IOException; import java.io.InvalidObjectException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.lang.annotation.Annotation; import java.util.Map; import java.util.Set; import org.jboss.managed.api.Fields; import org.jboss.managed.api.ManagedObject; import org.jboss.managed.api.ManagedProperty; import org.jboss.managed.api.annotation.ManagementProperty; import org.jboss.managed.api.annotation.ViewUse; import org.jboss.metatype.api.types.MetaType; import org.jboss.metatype.api.values.MetaValue; import org.jboss.metatype.api.values.SimpleValue; /** * ManagedProperty. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class ManagedPropertyImpl implements ManagedProperty { /** The serialVersionUID */ private static final long serialVersionUID = 2; /* writeObject format: * - int version * - Fields fields * - ManagedObject managedObject * - ManagedObject targetManagedObject */ private static final int VERSION1 = 1; /** The serialization version used by writeObject */ private static final int STREAM_VERSION = VERSION1; /** The managed object */ private ManagedObject managedObject; /** The managed object target for a ManagementObjectRef */ private ManagedObject targetManagedObject; /** The fields */ private Fields fields; /** The property name */ private transient String name; /** * Create a new ManagedProperty that is not associated to * a ManagedObject. * * @param name the managed property name * @throws IllegalArgumentException for null fields or * missing Fields.NAME */ public ManagedPropertyImpl(String name) { this(null, new DefaultFieldsImpl(name)); } /** * Create a new ManagedProperty that is not associated to * a ManagedObject. * * @param fields the fields * @throws IllegalArgumentException for null fields or * missing Fields.NAME */ public ManagedPropertyImpl(Fields fields) { this(null, fields); } /** * Create a new ManagedProperty. * * @param managedObject the managed object, may be null * @param fields the fields * @throws IllegalArgumentException for null fields or * missing Fields.NAME */ public ManagedPropertyImpl(ManagedObject managedObject, Fields fields) { init(managedObject, fields); } public ManagedObject getManagedObject() { return managedObject; } /** * Set managed object * * @param managedObject the managed object */ public void setManagedObject(ManagedObject managedObject) { this.managedObject = managedObject; } public ManagedObject getTargetManagedObject() { return targetManagedObject; } public void setTargetManagedObject(ManagedObject target) { this.targetManagedObject = target; } public Fields getFields() { return fields; } // TODO general reconstruction code for metatypes @SuppressWarnings("unchecked") public T getField(String fieldName, Class expected) { if (fieldName == null) throw new IllegalArgumentException("Null field name"); if (expected == null) throw new IllegalArgumentException("Null expected type"); Serializable field = getFields().getField(fieldName); if (field == null) return null; if (expected.isInstance(field)) return expected.cast(field); if (field instanceof SimpleValue) { SimpleValue value = (SimpleValue) field; Object result = value.getValue(); if (result == null) return null; return expected.cast(result); } throw new IllegalStateException("Field " + fieldName + " with value " + field + " is not of the expected type: " + expected.getName()); } // TODO metaType stuff public void setField(String fieldName, Serializable value) { if (fieldName == null) throw new IllegalArgumentException("Null field name"); getFields().setField(fieldName, value); } public String getName() { return name; } public String getMappedName() { return getField(Fields.MAPPED_NAME, String.class); } public String getDescription() { return getField(Fields.DESCRIPTION, String.class); } /** * Set the description * * @param description the description */ public void setDescription(String description) { setField(Fields.DESCRIPTION, description); } /** * Get the annotations associated with the property * @return the annotations associated with the property */ @SuppressWarnings("unchecked") public Map getAnnotations() { Object set = getField(Fields.ANNOTATIONS, Object.class); return (Map) set; } public void setAnnotations(Map annotations) { setField(Fields.ANNOTATIONS, (Serializable) annotations); } /** * See if the property has the indicated ViewUse among its * @ManagementProperty annotation uses. * * @param use - the ViewUse to check for * @return true if the ViewUse exists in the property uses, false otherwise */ public boolean hasViewUse(ViewUse use) { boolean hasViewUse = false; Map annotations = getAnnotations(); if(annotations != null) { ManagementProperty mp = (ManagementProperty) annotations.get(ManagementProperty.class.getName()); if(mp != null) { for(ViewUse vu : mp.use()) hasViewUse |= vu == use; } } return hasViewUse; } public MetaType getMetaType() { return getField(Fields.META_TYPE, MetaType.class); } /** * Set the meta type * * @param type the meta type */ public void setMetaType(MetaType type) { setField(Fields.META_TYPE, type); } public Object getValue() { return getField(Fields.VALUE, Object.class); } public void setValue(Serializable value) { setField(Fields.VALUE, value); } @SuppressWarnings("unchecked") public Set getLegalValues() { return getField(Fields.LEGAL_VALUES, Set.class); } /** * Set the legal values * * @param values the values */ public void setLegalValues(Set values) { setField(Fields.LEGAL_VALUES, (Serializable)values); } public Comparable getMinimumValue() { return getField(Fields.MINIMUM_VALUE, Comparable.class); } /** * Set the minimum value * * @param value the value */ public void setMinimumValue(Comparable value) { setField(Fields.MINIMUM_VALUE, (Serializable)value); } public Comparable getMaximumValue() { return getField(Fields.MAXIMUM_VALUE, Comparable.class); } /** * Set the maximum value * * @param value the value */ public void setMaximumValue(Comparable value) { setField(Fields.MAXIMUM_VALUE, (Serializable)value); } public String checkValidValue(Serializable value) { // TODO check min/max/etc. return null; } public boolean isMandatory() { Boolean result = getField(Fields.MANDATORY, Boolean.class); if (result == null) return false; return result; } /** * Set whether the field is mandatory * * @param flag true for mandatory */ public void setMandatory(boolean flag) { if (flag) setField(Fields.MANDATORY, flag); else setField(Fields.MANDATORY, null); } @Override public String toString() { StringBuilder tmp = new StringBuilder("ManagedProperty"); tmp.append('{'); tmp.append(name); if( getMappedName() != null ) { tmp.append(','); tmp.append(getMappedName()); } tmp.append(",metaType="); tmp.append(this.getMetaType()); tmp.append('}'); return tmp.toString(); } @Override public int hashCode() { return name.hashCode(); } @Override public boolean equals(Object obj) { if (obj == this) return true; if (obj == null || obj instanceof ManagedProperty == false) return false; ManagedProperty other = (ManagedProperty) obj; return getName().equals(other.getName()); } /** * Initialise a ManagedPropertyImpl. * * @param managedObject the managed object, may be null * @param fields the fields * @throws IllegalArgumentException for null fields or * missing Fields.NAME */ private void init(ManagedObject managedObject, Fields fields) { if (fields == null) throw new IllegalArgumentException("Null fields"); this.managedObject = managedObject; this.fields = fields; name = getField(Fields.NAME, String.class); if (name == null) throw new IllegalArgumentException("No " + Fields.NAME + " in fields"); } /** * Read from a stream * * @param in the stream * @throws IOException for IO problem * @throws ClassNotFoundException for a classloading problem */ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { int version = in.readInt(); if( version == VERSION1 ) readVersion1(in); else throw new InvalidObjectException("Unknown version="+version); } /** * Write out the property fields * @param out * @throws IOException */ private void writeObject(ObjectOutputStream out) throws IOException { out.writeInt(STREAM_VERSION); out.writeObject(fields); out.writeObject(managedObject); out.writeObject(targetManagedObject); } /** * The VERSION1 expected format: * - Fields fields * - ManagedObject managedObject */ private void readVersion1(ObjectInputStream in) throws IOException, ClassNotFoundException { fields = (Fields) in.readObject(); name = getField(Fields.NAME, String.class); if (name == null) throw new IOException("No " + Fields.NAME + " in fields"); managedObject = (ManagedObject) in.readObject(); targetManagedObject = (ManagedObject) in.readObject(); } } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/plugins/ManagedDeploymentImpl.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/plugins/ManagedDeployme0000644000175000017500000001324110732116446033114 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, Red Hat Middleware LLC, and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.managed.plugins; import java.io.Serializable; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; import org.jboss.managed.api.DeploymentTemplateInfo; import org.jboss.managed.api.ManagedComponent; import org.jboss.managed.api.ManagedDeployment; import org.jboss.managed.api.ManagedObject; import org.jboss.managed.api.ManagedProperty; /** * A simple ManagedDeployment bean implementation * * @author Scott.Stark@jboss.org * @version $Revision: 68394 $ */ public class ManagedDeploymentImpl implements ManagedDeployment, Serializable { private static final long serialVersionUID = 1; /** The full deployment name */ private String name; /** The simple deployment name */ private String simpleName; /** The set of types assigned to the deployment */ private Set types; /** The profile service phase for the deployment */ private DeploymentPhase phase; /** The parent deployment if any */ private ManagedDeployment parent; /** The deployment ManagedObjects */ private Map unitMOs; /** The flattened map of all ManagedObject properties */ private Map properties; /** The ManagedComponent wrappers for ManagedObjects marked as components */ private Map components = new HashMap(); /** The child deployemnts */ private List children = new ArrayList(); public ManagedDeploymentImpl(String name, String simpleName, DeploymentPhase phase, ManagedDeployment parent, Map unitMOs) { this.name = name; this.simpleName = simpleName; this.phase = phase; this.parent = parent; this.unitMOs = unitMOs; properties = new HashMap(); for(ManagedObject mo : unitMOs.values()) { properties.putAll(mo.getProperties()); } if(parent != null) { parent.getChildren().add(this); } } public String getName() { return name; } public String getSimpleName() { return simpleName; } public boolean addType(String type) { return types.add(type); } public Set getTypes() { return types; } public void setTypes(Set types) { this.types = types; } public DeploymentPhase getDeploymentPhase() { return phase; } public ManagedDeployment getParent() { return parent; } public Set getComponentTemplateNames() { // TODO Auto-generated method stub return null; } public void addComponent(String name, ManagedComponent comp) { components.put(name, comp); } public ManagedComponent getComponent(String name) { return components.get(name); } public Map getComponents() { return components; } public boolean removeComponent(String name) { ManagedComponent mc = components.remove(name); return mc != null; } public Set getDeploymentTemplateNames() { // TODO Auto-generated method stub return null; } public List getChildren() { return children; } public ManagedDeployment addModule(String deplymentBaseName, DeploymentTemplateInfo info) { // TODO Auto-generated method stub return null; } public Map getProperties() { return properties; } public ManagedProperty getProperty(String name) { return properties.get(name); } public Set getPropertyNames() { return properties.keySet(); } public Set getManagedObjectNames() { return unitMOs.keySet(); } public Map getManagedObjects() { return unitMOs; } public ManagedObject getManagedObject(String name) { return unitMOs.get(name); } public String toString() { StringBuilder tmp = new StringBuilder(super.toString()); tmp.append('{'); tmp.append("name="); tmp.append(getName()); tmp.append(", types="); tmp.append(types); tmp.append(", phase="); tmp.append(phase); tmp.append(", parent="); if( parent != null ) { tmp.append("ManagedDeployment@"); tmp.append(System.identityHashCode(parent)); } else { tmp.append("null"); } tmp.append(", components="); tmp.append(components); tmp.append(", children="); tmp.append(children); tmp.append('}'); return tmp.toString(); } } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/plugins/ManagedOperationImpl.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/plugins/ManagedOperatio0000644000175000017500000000700510761511660033120 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, Red Hat Middleware LLC, and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.managed.plugins; import org.jboss.managed.api.ManagedOperation; import org.jboss.managed.api.ManagedParameter; import org.jboss.metatype.api.types.MetaType; import org.jboss.metatype.api.types.SimpleMetaType; import org.jboss.metatype.api.values.MetaValue; /** * A default implementation of ManagedOperation * * @author Scott.Stark@jboss.org * @version $Revision: 70207 $ */ public class ManagedOperationImpl implements ManagedOperation { private static final long serialVersionUID = 1; private String description; private Impact impact; private String name; private ManagedParameter[] parameters; private MetaType returnType; public ManagedOperationImpl(String name, String description) { this(description, name, Impact.Unknown, new ManagedParameter[0], SimpleMetaType.VOID); } public ManagedOperationImpl(String name, String description, Impact impact, ManagedParameter[] parameters, MetaType returnType) { super(); this.description = description; this.impact = impact; this.name = name; this.parameters = parameters; this.returnType = returnType; } public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } public Impact getImpact() { return impact; } public void setImpact(Impact impact) { this.impact = impact; } public String getName() { return name; } public void setName(String name) { this.name = name; } public ManagedParameter[] getParameters() { return parameters; } public void setParameters(ManagedParameter[] parameters) { this.parameters = parameters; } public MetaType getReturnType() { return returnType; } public void setReturnType(MetaType returnType) { this.returnType = returnType; } /** * This does not have a meaningful implementation because the target * is unknown. A runtime aspect that understand the context of this * operation needs to perform the invocation. */ public Object invoke(MetaValue... param) { return null; } public String toString() { StringBuilder tmp = new StringBuilder(); tmp.append("ManagedOperation(name="); tmp.append(name); tmp.append(",description="); tmp.append(description); tmp.append(",impact="); tmp.append(impact); tmp.append(")"); return tmp.toString(); } } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/plugins/ManagedParameterImpl.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/plugins/ManagedParamete0000644000175000017500000002060710761511660033077 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, Red Hat Middleware LLC, and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.managed.plugins; import java.io.IOException; import java.io.InvalidObjectException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.lang.annotation.Annotation; import java.util.Map; import java.util.Set; import org.jboss.managed.api.Fields; import org.jboss.managed.api.ManagedParameter; import org.jboss.metatype.api.types.MetaType; import org.jboss.metatype.api.values.MetaValue; import org.jboss.metatype.api.values.SimpleValue; /** * @author Scott.Stark@jboss.org * @version $Revision: 70207 $ */ public class ManagedParameterImpl implements ManagedParameter { private static final long serialVersionUID = 1; private static final int VERSION1 = 1; /** The serialization version used by writeObject */ private static final int STREAM_VERSION = VERSION1; /** The fields */ private Fields fields; /** The property name */ private transient String name; /** * Create a new ManagedProperty that is not associated to * a ManagedObject. * * @param name the managed property name * @throws IllegalArgumentException for null fields or * missing Fields.NAME */ public ManagedParameterImpl(String name) { this(new DefaultFieldsImpl(name)); } /** * Create a new ManagedProperty that is not associated to * a ManagedObject. * * @param fields the fields * @throws IllegalArgumentException for null fields or * missing Fields.NAME */ public ManagedParameterImpl(Fields fields) { init(fields); } public Fields getFields() { return fields; } // TODO general reconstruction code for metatypes @SuppressWarnings("unchecked") public T getField(String fieldName, Class expected) { if (fieldName == null) throw new IllegalArgumentException("Null field name"); if (expected == null) throw new IllegalArgumentException("Null expected type"); Serializable field = getFields().getField(fieldName); if (field == null) return null; if (expected.isInstance(field)) return expected.cast(field); if (field instanceof SimpleValue) { SimpleValue value = (SimpleValue) field; Object result = value.getValue(); if (result == null) return null; return expected.cast(result); } throw new IllegalStateException("Field " + fieldName + " with value " + field + " is not of the expected type: " + expected.getName()); } // TODO metaType stuff public void setField(String fieldName, Serializable value) { if (fieldName == null) throw new IllegalArgumentException("Null field name"); getFields().setField(fieldName, value); } public String getName() { return name; } public String getDescription() { return getField(Fields.DESCRIPTION, String.class); } /** * Set the description * * @param description the description */ public void setDescription(String description) { setField(Fields.DESCRIPTION, description); } /** * Get the annotations associated with the property * @return the annotations associated with the property */ @SuppressWarnings("unchecked") public Map getAnnotations() { Object set = getField(Fields.ANNOTATIONS, Object.class); return (Map) set; } public void setAnnotations(Map annotations) { setField(Fields.ANNOTATIONS, (Serializable) annotations); } public MetaType getMetaType() { return getField(Fields.META_TYPE, MetaType.class); } /** * Set the meta type * * @param type the meta type */ public void setMetaType(MetaType type) { setField(Fields.META_TYPE, type); } public Object getValue() { return getField(Fields.VALUE, Object.class); } public void setValue(Serializable value) { setField(Fields.VALUE, value); } @SuppressWarnings("unchecked") public Set getLegalValues() { return getField(Fields.LEGAL_VALUES, Set.class); } /** * Set the legal values * * @param values the values */ public void setLegalValues(Set values) { setField(Fields.LEGAL_VALUES, (Serializable)values); } public Comparable getMinimumValue() { return getField(Fields.MINIMUM_VALUE, Comparable.class); } /** * Set the minimum value * * @param value the value */ public void setMinimumValue(Comparable value) { setField(Fields.MINIMUM_VALUE, (Serializable)value); } public Comparable getMaximumValue() { return getField(Fields.MAXIMUM_VALUE, Comparable.class); } /** * Set the maximum value * * @param value the value */ public void setMaximumValue(Comparable value) { setField(Fields.MAXIMUM_VALUE, (Serializable)value); } public String checkValidValue(Serializable value) { // TODO check min/max/etc. return null; } @Override public String toString() { StringBuilder tmp = new StringBuilder("ManagedProperty"); tmp.append('{'); tmp.append(name); tmp.append(",metaType="); tmp.append(this.getMetaType()); tmp.append('}'); return tmp.toString(); } @Override public int hashCode() { return name.hashCode(); } @Override public boolean equals(Object obj) { if (obj == this) return true; if (obj == null || obj instanceof ManagedParameter == false) return false; ManagedParameter other = (ManagedParameter) obj; return getName().equals(other.getName()); } /** * Initialise a ManagedPropertyImpl. * * @param managedObject the managed object, may be null * @param fields the fields * @throws IllegalArgumentException for null fields or * missing Fields.NAME */ private void init(Fields fields) { if (fields == null) throw new IllegalArgumentException("Null fields"); this.fields = fields; name = getField(Fields.NAME, String.class); if (name == null) throw new IllegalArgumentException("No " + Fields.NAME + " in fields"); } /** * Read from a stream * * @param in the stream * @throws IOException for IO problem * @throws ClassNotFoundException for a classloading problem */ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { int version = in.readInt(); if( version == VERSION1 ) readVersion1(in); else throw new InvalidObjectException("Unknown version="+version); } /** * Write out the property fields * @param out * @throws IOException */ private void writeObject(ObjectOutputStream out) throws IOException { out.writeInt(STREAM_VERSION); out.writeObject(fields); } /** * The VERSION1 expected format: * - Fields fields */ private void readVersion1(ObjectInputStream in) throws IOException, ClassNotFoundException { fields = (Fields) in.readObject(); name = getField(Fields.NAME, String.class); if (name == null) throw new IOException("No " + Fields.NAME + " in fields"); } } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/plugins/ManagedComponentImpl.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/plugins/ManagedComponen0000644000175000017500000000441210701754233033112 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, Red Hat Middleware LLC, and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.managed.plugins; import java.io.Serializable; import org.jboss.managed.api.ComponentType; import org.jboss.managed.api.ManagedComponent; import org.jboss.managed.api.ManagedDeployment; import org.jboss.managed.api.ManagedObject; /** * Managed component impl. * * @author Scott.Stark@jboss.org * @version $Revision: 65897 $ */ public class ManagedComponentImpl extends DelegateManagedCommonImpl implements ManagedComponent, Serializable { private static final long serialVersionUID = 1; private ManagedDeployment owner; private ComponentType type; public ManagedComponentImpl(ComponentType type, ManagedDeployment owner, ManagedObject mo) { super(mo); this.type = type; this.owner = owner; } public ManagedDeployment getDeployment() { return owner; } public ComponentType getType() { return type; } public String toString() { StringBuilder tmp = new StringBuilder(super.toString()); tmp.append('{'); tmp.append("name="); tmp.append(super.getName()); tmp.append(", type="); tmp.append(type); tmp.append(", owner=ManagedDeployment@"); tmp.append(System.identityHashCode(owner)); tmp.append('}'); return tmp.toString(); } } ././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/plugins/WritethroughManagedPropertyImpl.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/plugins/WritethroughMan0000644000175000017500000001044211104137625033204 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, Red Hat Middleware LLC, and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.managed.plugins; import java.io.ObjectStreamException; import java.io.Serializable; import org.jboss.beans.info.spi.BeanInfo; import org.jboss.beans.info.spi.PropertyInfo; import org.jboss.managed.api.Fields; import org.jboss.managed.api.ManagedObject; import org.jboss.managed.api.factory.ManagedObjectFactory; import org.jboss.managed.plugins.factory.ManagedObjectFactoryBuilder; import org.jboss.managed.spi.factory.InstanceClassFactory; import org.jboss.metatype.api.values.MetaValue; import org.jboss.metatype.api.values.MetaValueFactory; import org.jboss.metatype.plugins.values.MetaValueFactoryBuilder; /** * An extension of ManagedPropertyImpl. * * @author Scott.Stark@jboss.org * @author Ales.Justin@jboss.org * @version $Revision: 80522 $ */ public class WritethroughManagedPropertyImpl extends ManagedPropertyImpl { private static final long serialVersionUID = 1; /** The meta value factory */ private transient MetaValueFactory valueFactory; /** The managed object factory */ private transient ManagedObjectFactory objectFactory; public WritethroughManagedPropertyImpl(Fields fields) { super(fields); } public WritethroughManagedPropertyImpl(ManagedObject managedObject, Fields fields) { super(managedObject, fields); } public WritethroughManagedPropertyImpl(Fields fields, MetaValueFactory valueFactory, ManagedObjectFactory objectFactory) { super(fields); this.valueFactory = valueFactory; this.objectFactory = objectFactory; } protected ManagedObjectFactory getObjectFactory() { if (objectFactory == null) objectFactory = ManagedObjectFactoryBuilder.create(); return objectFactory; } protected MetaValueFactory getValueFactory() { if (valueFactory == null) valueFactory = MetaValueFactoryBuilder.create(); return valueFactory; } /** * Write the value back to the attachment if there is a PropertyInfo * in the Fields.PROPERTY_INFO field. */ @Override @SuppressWarnings("unchecked") public void setValue(Serializable value) { super.setValue(value); PropertyInfo propertyInfo = getField(Fields.PROPERTY_INFO, PropertyInfo.class); if (propertyInfo != null) { Object attachment = getManagedObject().getAttachment(); if (attachment != null) { MetaValue metaValue; if (value instanceof MetaValue == false) metaValue = getValueFactory().create(value, propertyInfo.getType()); else metaValue = (MetaValue)value; ManagedObjectFactory mof = getObjectFactory(); InstanceClassFactory icf = mof.getInstanceClassFactory(attachment.getClass(), null); BeanInfo beanInfo = propertyInfo.getBeanInfo(); icf.setValue(beanInfo, this, attachment, metaValue); } } } /** * Expose only plain ManangedPropertyImpl. * * @return simpler ManagedPropertyImpl * @throws ObjectStreamException for any error */ private Object writeReplace() throws ObjectStreamException { ManagedPropertyImpl managedProperty = new ManagedPropertyImpl(getManagedObject(), getFields()); managedProperty.setTargetManagedObject(getTargetManagedObject()); return managedProperty; } } ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/plugins/DelegateManagedObjectImpl.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/plugins/DelegateManaged0000644000175000017500000000510711104137625033046 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, Red Hat Middleware LLC, and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.managed.plugins; import java.io.Serializable; import java.lang.annotation.Annotation; import java.util.Map; import java.util.Set; import org.jboss.managed.api.ManagedObject; import org.jboss.managed.api.ManagedOperation; import org.jboss.managed.api.ManagedProperty; /** * * @author Scott.Stark@jboss.org * @version $Revision: 80522 $ */ public class DelegateManagedObjectImpl implements ManagedObject { private static final long serialVersionUID = 1; private ManagedObject delegate; public DelegateManagedObjectImpl(ManagedObject delegate) { this.delegate = delegate; } public Map getAnnotations() { return delegate.getAnnotations(); } public Object getAttachment() { return delegate.getAttachment(); } public String getAttachmentName() { return delegate.getAttachmentName(); } public String getName() { return delegate.getName(); } public String getNameType() { return delegate.getNameType(); } public Set getOperations() { return delegate.getOperations(); } public Map getProperties() { return delegate.getProperties(); } public ManagedProperty getProperty(String name) { return delegate.getProperty(name); } public Set getPropertyNames() { return delegate.getPropertyNames(); } public Object getComponentName() { return delegate.getComponentName(); } public ManagedObject getParent() { return delegate.getParent(); } } ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/plugins/DelegateManagedCommonImpl.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/plugins/DelegateManaged0000644000175000017500000000463311104137625033051 0ustar twernertwerner/* * 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.util.Map; import java.util.Set; import org.jboss.managed.api.ManagedCommon; import org.jboss.managed.api.ManagedObject; import org.jboss.managed.api.ManagedOperation; import org.jboss.managed.api.ManagedProperty; /** * Delegate managed common. * * @author ales.justin@jboss.org * @author Scott.Stark@jboss.org * @version $Revision:$ */ public class DelegateManagedCommonImpl implements ManagedCommon { private static final long serialVersionUID = 1; private ManagedObject delegate; public DelegateManagedCommonImpl(ManagedObject delegate) { this.delegate = delegate; } public String getAttachmentName() { return delegate.getAttachmentName(); } public String getName() { return delegate.getName(); } public String getNameType() { return delegate.getNameType(); } public Set getOperations() { return delegate.getOperations(); } public Map getProperties() { return delegate.getProperties(); } public ManagedProperty getProperty(String name) { return delegate.getProperty(name); } public Set getPropertyNames() { return delegate.getPropertyNames(); } public ManagedCommon getParent() { return delegate.getParent(); } } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/plugins/ManagedObjectImpl.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/plugins/ManagedObjectIm0000644000175000017500000002121411104137625033025 0ustar twernertwerner/* * 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.Serializable; import java.lang.annotation.Annotation; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; import org.jboss.managed.api.ManagedObject; import org.jboss.managed.api.ManagedOperation; import org.jboss.managed.api.ManagedProperty; import org.jboss.managed.api.MutableManagedObject; /** * ManagedObjectImpl. * * @author Adrian Brock * @author Scott.Stark@jboss.org * @version $Revision: 80522 $ */ public class ManagedObjectImpl implements MutableManagedObject { /** The serialVersionUID */ private static final long serialVersionUID = 2L; /** The object name used for ManagementRef resolution */ private String name; /** The name type/qualifier used for ManagementRef resolution */ private String nameType; /** The attachment name */ private String attachmentName; /** The attachment */ private transient Object attachment; /** The object annotations */ private Map annotations = Collections.emptyMap(); /** The properties */ private Map properties; /** The operations */ private Set operations; /** The option parent of this ManagedObject */ private ManagedObject parent; /** The runtime component name */ private transient Object componentName; /** * Create a new ManagedObjectImpl * * @param name - The object name used for ManagementRef resolution */ public ManagedObjectImpl(String name) { this(name, name, null, toMap(null), new HashSet(), null); } /** * Create a new ManagedObjectImpl * * @param name - The object name used for ManagementRef resolution * @param properties the properties */ public ManagedObjectImpl(String name, Set properties) { this(name, name, null, properties, new HashSet(), null); } /** * Create a new ManagedObjectImpl * * @param name - The object name used for ManagementRef resolution * @param properties the properties * @param operations the operations */ public ManagedObjectImpl(String name, Set properties, HashSet operations) { this(name, name, null, properties, operations, null); } /** * Create a new ManagedObjectImpl * * @param name - The object name used for ManagementRef resolution * @param nameType - The name type/qualifier used for ManagementRef resolution * @param attachmentName the attachment name * @param properties the properties * @param operations the operations * @param attachment the attachment */ public ManagedObjectImpl( String name, String nameType, String attachmentName, Set properties, HashSet operations, Serializable attachment ) { this(name, nameType, attachmentName, toMap(properties), operations, attachment); } /** * Create a new ManagedObjectImpl * * @param name - The object name used for ManagementRef resolution * @param nameType - The name type/qualifier used for ManagementRef resolution * @param attachmentName the attachment name * @param properties the properties * @param operations the operations * @param attachment the attachment */ public ManagedObjectImpl( String name, String nameType, String attachmentName, Map properties, HashSet operations, Serializable attachment ) { if (name == null) throw new IllegalArgumentException("Null name"); if (properties == null) throw new IllegalArgumentException("Null properties"); this.name = name; // todo - check for null? this.nameType = nameType; this.attachmentName = attachmentName; this.properties = properties; this.operations = operations; setAttachment(attachment); } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getNameType() { return nameType; } public void setNameType(String nameType) { this.nameType = nameType; } public String getAttachmentName() { return attachmentName; } public void setAttachmentName(String attachmentName) { this.attachmentName = attachmentName; } /** * Get the annotations associated with the property * @return the annotations associated with the property */ public Map getAnnotations() { return annotations; } public void setAnnotations(Map annotations) { if (this.annotations.isEmpty()) this.annotations = new HashMap(); else this.annotations.clear(); this.annotations.putAll(annotations); } public Set getPropertyNames() { return properties.keySet(); } public ManagedProperty getProperty(String name) { if (name == null) throw new IllegalArgumentException("Null name"); return properties.get(name); } public Map getProperties() { return properties; } public void setProperties(Map properties) { this.properties = properties; } public Object getAttachment() { return attachment; } /** * Set the attachment. * * @param attachment the attachment. */ public void setAttachment(Object attachment) { this.attachment = attachment; } /** * get the ManagedOperations * @return set of managed operations */ public Set getOperations() { return operations; } public void setOperations(Set operations) { this.operations = operations; } public ManagedObject getParent() { return parent; } public void setParent(ManagedObject parent) { this.parent = parent; } public Object getComponentName() { return componentName; } public void setComponentName(Object name) { this.componentName = name; } @Override public boolean equals(Object obj) { if (obj == this) return true; if (obj == null || obj instanceof ManagedObject == false) return false; ManagedObject other = (ManagedObject) obj; return getName().equals(other.getName()) && getProperties().equals(other.getProperties()); } @Override public int hashCode() { return name.hashCode(); } @Override public String toString() { return "ManagedObject{" + name + "}"; } /** * Append the name and props * @param sb the buffer to append the name and props to */ protected void toString(StringBuilder sb) { sb.append("name="); sb.append(name); sb.append(", nameType="); sb.append(nameType); sb.append(", attachmentName="); sb.append(attachmentName); sb.append(", properties="); sb.append(properties); } private static Map toMap(Set props) { HashMap properties = new HashMap(); if (props != null && props.isEmpty() == false) { for (ManagedProperty prop : props) { properties.put(prop.getName(), prop); } } return properties; } } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/plugins/DefaultFieldsImpl.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/plugins/DefaultFieldsIm0000644000175000017500000001656610761511660033076 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, Red Hat Middleware LLC, and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.managed.plugins; import java.io.IOException; import java.io.Serializable; import java.util.HashMap; import java.util.Map; import java.util.Set; import org.jboss.managed.api.Fields; import org.jboss.metatype.api.types.MetaType; import org.jboss.metatype.api.values.MetaValue; import org.jboss.metatype.api.values.SimpleValue; /** * A default implementation of the Fields interface. * * @author Scott.Stark@jboss.org * @version $Revision:$ */ public class DefaultFieldsImpl implements Fields { private static String END_MARKER = "__END_OF_FIELDS__"; /** The serialVersionUID */ private static final long serialVersionUID = 1; /** The fields */ private HashMap fields = new HashMap(); /** * Create a new DefaultFieldsImpl. */ public DefaultFieldsImpl() { } /** * Create a new DefaultFieldsImpl. * * @param name the property name */ public DefaultFieldsImpl(String name) { this.setName(name); } /** * Get the property name * * @return the name */ public String getName() { return getField(NAME, String.class); } /** * Set the property name * * @param name the name */ public void setName(String name) { setField(NAME, name); } /** * Get the description * * @return the description */ public String getDescription() { return getField(DESCRIPTION, String.class); } /** * Set the description * * @param description the description */ public void setDescription(String description) { setField(DESCRIPTION, description); } /** * Get the meta type * * @return the meta type */ public MetaType getMetaType() { return getField(META_TYPE, MetaType.class); } /** * Set the meta type * * @param type the meta type */ public void setMetaType(MetaType type) { setField(META_TYPE, type); } /** * Get the value * * @return the value */ public Object getValue() { return getField(VALUE); } /** * Set the value * * @param value the value */ public void setValue(Serializable value) { setField(VALUE, value); } /** * Get the legal values * * @return the values */ @SuppressWarnings("unchecked") public Set getLegalValues() { return getField(LEGAL_VALUES, Set.class); } /** * Set the legal values * * @param values the values */ public void setLegalValues(Set values) { setField(LEGAL_VALUES, (Serializable)values); } /** * Get the minimum value * * @return the minimum value */ public Comparable getMinimumValue() { return getField(MINIMUM_VALUE, Comparable.class); } /** * Set the minimum value * * @param value the value */ public void setMinimumValue(Comparable value) { setField(MINIMUM_VALUE, (Serializable)value); } /** * Get the maximum value * * @return the value */ public Comparable getMaximumValue() { return getField(MAXIMUM_VALUE, Comparable.class); } /** * Get the maximum value * * @param value the value */ public void setMaximumValue(Comparable value) { setField(MAXIMUM_VALUE, (Serializable)value); } /** * Get whether the property is mandatory * * @return true when mandaotry */ public boolean isMandatory() { Boolean result = getField(MANDATORY, Boolean.class); if (result == null) return false; return result; } /** * Set the mandatory value * * @param flag true when mandatory */ public void setMandatory(boolean flag) { if (flag) setField(MANDATORY, flag); else setField(MANDATORY, null); } /** * Get a field * * @param name the field name */ public Serializable getField(String name) { return fields.get(name); } /** * Set a field * * @param name the field name * @param value the value */ public void setField(String name, Serializable value) { fields.put(name, value); } /** * Get a field * * @param the expected type * @param fieldName the field name * @param expected the expected type * @return the field value */ @SuppressWarnings("unchecked") public T getField(String fieldName, Class expected) { if (fieldName == null) throw new IllegalArgumentException("Null field name"); if (expected == null) throw new IllegalArgumentException("Null expected type"); Serializable field = getField(fieldName); if (field == null) return null; if (expected.isInstance(field)) return expected.cast(field); if (field instanceof SimpleValue) { SimpleValue value = (SimpleValue) field; Object result = value.getValue(); if (result == null) return null; return expected.cast(result); } throw new IllegalStateException("Field " + fieldName + " with value " + field + " is a of the expected type: " + expected.getName()); } /** * Only write out the fields that should be usable by a remote client. * Excludes: * PROPERTY_INFO * ATTACHMENT * * @param out * @throws IOException */ private void writeObject(java.io.ObjectOutputStream out) throws IOException { for (Map.Entry entry : fields.entrySet()) { if(entry.getKey().equals(PROPERTY_INFO)) continue; if(entry.getKey().equals(ATTACHMENT)) continue; out.writeUTF(entry.getKey()); out.writeObject(entry.getValue()); } out.writeUTF(END_MARKER); } private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException { fields = new HashMap(); String key; do { key = in.readUTF(); if(key.equals(END_MARKER)) key = null; else { Serializable value = (Serializable) in.readObject(); fields.put(key, value); } } while(key != null); } } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/plugins/BasicDeploymentTemplateInfo.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/plugins/BasicDeployment0000644000175000017500000000656410763516020033151 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, Red Hat Middleware LLC, and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.managed.plugins; import java.io.Serializable; import java.util.HashMap; import java.util.Map; import org.jboss.managed.api.DeploymentTemplateInfo; import org.jboss.managed.api.ManagedProperty; /** * A simple bean type of implementation of DeploymentTemplateInfo * @author Scott.Stark@jboss.org * @version $Revision: 70420 $ */ public class BasicDeploymentTemplateInfo implements DeploymentTemplateInfo, Serializable { private static final long serialVersionUID = 1; /** The name the template is registered under with the profile service */ private String name; /** The template description */ private String description; /** The name of the ManagedProperty in the Map map * obtained from the mainDeployer.getManagedObjects(VFSDeployment) * for the DeploymentTemplate this info is associated with. */ private String rootManagedPropertyName; /** * The template properties */ private Map properties; public BasicDeploymentTemplateInfo(String name, String description) { this(name, description, new HashMap()); } public BasicDeploymentTemplateInfo(String name, String description, Map properties) { this.name = name; this.description = description; this.properties = properties; } public String getDescription() { return description; } public String getName() { return name; } public String getRootManagedPropertyName() { return rootManagedPropertyName; } public void setRootManagedPropertyName(String rootManagedPropertyName) { this.rootManagedPropertyName = rootManagedPropertyName; } public Map getProperties() { return properties; } public void setProperties(Map properties) { this.properties = properties; } public void addProperty(ManagedProperty property) { this.properties.put(property.getName(), property); } public String toString() { StringBuilder tmp = new StringBuilder(super.toString()); tmp.append('{'); tmp.append(name); tmp.append(",description="); tmp.append(description); tmp.append(",properties="); tmp.append(properties); tmp.append('}'); return tmp.toString(); } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/plugins/ManagedPropertyImplFactory.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/plugins/ManagedProperty0000644000175000017500000000363610645072106033166 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, Red Hat Middleware LLC, and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.managed.plugins; import org.jboss.managed.api.ManagedProperty; import org.jboss.metatype.api.types.SimpleMetaType; /** * javabean factory for ManagedPropertyImpls. * * @author Scott.Stark@jboss.org * @version $Revision:$ */ public class ManagedPropertyImplFactory { /** * Create a new managed property * * @param name the property name * @param description the property description * @param metaType the metatype * @param manadatory whether the property is mandatory * @return the managed property */ public static ManagedProperty newInstance(String name, String description, String metaType, boolean manadatory) { ManagedPropertyImpl property = new ManagedPropertyImpl(name); property.setDescription(description); property.setMandatory(manadatory); property.setMetaType(SimpleMetaType.resolve(metaType)); return property; } } libjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/api/0000755000175000017500000000000011105402551027213 5ustar twernertwernerlibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/api/factory/0000755000175000017500000000000011105402550030661 5ustar twernertwerner././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/api/factory/ManagedObjectFactory.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/api/factory/ManagedObje0000644000175000017500000001355111104137625032754 0ustar twernertwerner/* * 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.factory; import org.jboss.managed.api.ManagedObject; import org.jboss.managed.api.annotation.ManagementObjectID; import org.jboss.managed.plugins.factory.ManagedObjectFactoryBuilder; import org.jboss.managed.spi.factory.InstanceClassFactory; import org.jboss.managed.spi.factory.ManagedObjectBuilder; import org.jboss.metadata.spi.MetaData; /** * ManagedObjectFactory. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public abstract class ManagedObjectFactory { /** The managed object factory instance */ private static ManagedObjectFactoryBuilder builder = new ManagedObjectFactoryBuilder(); /** * Get the managed object factory instance * * @return the instance */ public static ManagedObjectFactory getInstance() { return builder.create(); } /** * Create a managed object from the given object * * @param instance - the object to build the ManagedObject from * @param name - the name of the managed object. If null, the name will * be derived from the object annotations or attachment name. * @param nameType - the name of the managed object. If null, the name will * be derived from the object annotations or default to "". * * @see ManagementObjectID * * @return the managed object * @throws IllegalArgumentException for a null object */ public ManagedObject initManagedObject(Object instance, String name, String nameType) { return initManagedObject(instance, null, name, nameType); } public ManagedObject initManagedObject(Object instance, Class instanceType, String name, String nameType) { return initManagedObject(instance, null, null, name, nameType); } public ManagedObject initManagedObject(Object instance, MetaData metaData) { return initManagedObject(instance, null, metaData, null, null); } /** * Create a managed object from the given object * * @param instance - the object to build the ManagedObject from * @param instanceType - the optional type to determine InstanceClassFactory registration from. * If not specified instance.getClass() is used. * @param metaData - the optional metadata repository accessor used to query * for management annotation overrides/additions to the clazz * @param name - the name of the managed object. If null, the name will * be derived from the object annotations or attachment name. * @param nameType - the name of the managed object. If null, the name will * be derived from the object annotations or default to "". * * @see ManagementObjectID * * @return the managed object */ public abstract ManagedObject initManagedObject(Object instance, Class instanceType, MetaData metaData, String name, String nameType); /** * Create a shell managed object from the given class * * @param the class * @param clazz the class * @return the managed object * @throws IllegalArgumentException for a null class */ public ManagedObject createManagedObject(Class clazz) { return createManagedObject(clazz, null); } public abstract ManagedObject createManagedObject(Class clazz, MetaData metaData); /** * Set a managed object builder * * @param clazz the class * @param builder the builder (null to remove the builder) */ public abstract void setBuilder(Class clazz, ManagedObjectBuilder builder); /** * Set the InstanceClassFactory for an instance type. * * @param the class type * @param clazz the class * @param factory - the factory used to obtain the class to scan for * management annotations. */ public abstract void setInstanceClassFactory(Class clazz, InstanceClassFactory factory); /** * Add an InstanceClassFactory. Calls setInstanceClassFactory(factory.getType(), factory);. * @param factory - the factory used to obtain the class to scan for */ public void addInstanceClassFactory(InstanceClassFactory factory) { setInstanceClassFactory(factory.getType(), factory); } /** * Remove an InstanceClassFactory. Calls setInstanceClassFactory(factory.getType(), null);. * @param factory */ public void removeInstanceClassFactory(InstanceClassFactory factory) { setInstanceClassFactory(factory.getType(), null); } /** * Get the InstanceClassFactory for an instance type. * * @param the class type * @param clazz the class * @return the factory used to obtain the class to scan for * management annotations. */ public InstanceClassFactory getInstanceClassFactory(Class clazz) { return getInstanceClassFactory(clazz, null); } public abstract InstanceClassFactory getInstanceClassFactory(Class clazz, MetaData metaData); } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/api/ManagedProperty.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/api/ManagedProperty.jav0000644000175000017500000001056610763706473033051 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.managed.api; import java.io.Serializable; import java.lang.annotation.Annotation; import java.util.Map; import java.util.Set; import org.jboss.managed.api.annotation.ManagementObjectRef; import org.jboss.managed.api.annotation.ViewUse; import org.jboss.metatype.api.types.MetaType; import org.jboss.metatype.api.values.MetaValue; /** * ManagedProperty. * * @author Adrian Brock * @author Scott.Stark@jboss.org * @version $Revision: 1.1 $ */ public interface ManagedProperty extends Serializable { /** * Get the managed object the property is associated with. * * @return the managed object */ ManagedObject getManagedObject(); void setManagedObject(ManagedObject managedObject); /** * Get the ManagedObject * @see {@linkplain ManagementObjectRef} * @return the ManagedObject the property references, null * if there is no reference or its unresolved. */ ManagedObject getTargetManagedObject(); void setTargetManagedObject(ManagedObject target); /** * Get the fields * * @return the fields */ Fields getFields(); /** * Get a field * * @param the expected type * @param fieldName the field name * @param expected the expected type * @return the value */ T getField(String fieldName, Class 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 getAnnotations(); /** * See if the property has the indicated ViewUse among its * @ManagementProperty annotation uses. * * @param use - the ViewUse to check for * @return true if the ViewUse exists in the property uses, false otherwise */ boolean hasViewUse(ViewUse use); /** * Get the value * * @return the value */ Object getValue(); /** * Set the value * * @param value the value */ void setValue(Serializable value); /** * Get the legal values * * @return the legal values */ Set getLegalValues(); /** * Get the minimum value * * @return the minimum value */ Comparable getMinimumValue(); /** * Get the miximum value * * @return the maximum value */ Comparable getMaximumValue(); /** * Check whether this is a valid value * * @param value the value * @return null for a valid value, an error message otherwise */ String checkValidValue(Serializable value); /** * Whether the property is mandatory * * @return true when mandatory */ boolean isMandatory(); } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/api/ManagedComponent.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/api/ManagedComponent.ja0000644000175000017500000000276110701754233032764 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, Red Hat Middleware LLC, and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.managed.api; /** * A runtime component associated with a deployment. * * @author Scott.Stark@jboss.org * @version $Revision: 65897 $ */ public interface ManagedComponent extends ManagedCommon { /** * The component classification as a type/subtype. * @return component type. */ public ComponentType getType(); /** * The deployment the component is associated with. * @return component deployment. */ public ManagedDeployment getDeployment(); } libjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/api/ManagedObject.java0000644000175000017500000000441611104137625032554 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.managed.api; import java.io.Serializable; import java.lang.annotation.Annotation; import java.util.Map; import org.jboss.managed.api.annotation.ManagementRuntimeRef; /** * ManagedObject is an interface for a manageable element. It * consists of: * - a name/name type for a registry/references * - an attachment name to associate the ManagedObject with a * deployment attachment * - annotations from the metadata making up the ManagedObject * - the attachment instance * - the ManagedPropertys for the interface * - the ManagedOperations for the interface * * @author Adrian Brock * @author Scott.Stark@jboss.org * @version $Revision: 1.1 $ */ public interface ManagedObject extends ManagedCommon { /** * Get the underlying object * * @return the underlying object */ Object getAttachment(); /** * Get the annotations associated with the property * @return the annotations associated with the property */ public Map getAnnotations(); /** * Get the runtime component name. * * @see {@linkplain ManagementRuntimeRef} * @return name of runtime component if one exists, null if no component exists. */ Object getComponentName(); public ManagedObject getParent(); } libjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/api/ManagedCommon.java0000644000175000017500000000536111104137625032576 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.managed.api; import java.io.Serializable; import java.util.Map; import java.util.Set; import org.jboss.managed.api.annotation.ManagementObject; import org.jboss.managed.api.annotation.ManagementObjectID; /** * ManagedCommon is used to hold common * properties that both, server side and client side, * object can see . * * @author Ales Justin * @author Scott.Stark@jboss.org * @version $Revision:$ */ public interface ManagedCommon extends Serializable { /** * Get the attachment name * @see {@linkplain ManagementObject#attachmentName}} * * @return the name */ String getAttachmentName(); /** * Get the external name by which the ManagedObject is known * @see {@linkplain ManagementObject#name}} * @see {@linkplain ManagementObjectID#name}} * @return the name */ String getName(); /** * Get the external name type/qualifier. * @see {@linkplain ManagementObject#type} * @see {@linkplain ManagementObjectID#type} * @return the name type */ String getNameType(); /** * Get the property names * * @return the property names */ Set getPropertyNames(); /** * Get a property * * @param name the name * @return the property */ ManagedProperty getProperty(String name); /** * Get the properties * * @return the properties */ Map getProperties(); /** * Get the operations * * @return the operations */ Set getOperations(); /** * * @return */ ManagedCommon getParent(); } libjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/api/ComponentType.java0000644000175000017500000000623110651703311032667 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, Red Hat Middleware LLC, and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.managed.api; import java.io.Serializable; /** * A simple type/subtype key for a ManagedComponent. Example * type/subtypes include: DataSource/{XA,LocalTx,NoTX}, * JMSDestination/{Queue,Topic}, * EJB/{StatelessSession,StatefulSession,Entity,MDB}, * MBean/{Standard,XMBean,Dynamic}, * ... * * @author Scott.Stark@jboss.org * @version $Revision: 64275 $ */ public class ComponentType implements Serializable { private static final long serialVersionUID = 1; private String type; private String subtype; public ComponentType() { } public ComponentType(String type, String subtype) { this.type = type; this.subtype = subtype; } public String getType() { return type; } public void setType(String type) { this.type = type; } public String getSubtype() { return subtype; } public void setSubtype(String subtype) { this.subtype = subtype; } @Override public int hashCode() { int hashCode = 1; if( type != null ) hashCode += type.hashCode(); if( subtype != null ) hashCode += subtype.hashCode(); return hashCode; } @Override public boolean equals(Object obj) { if( this == obj ) return true; if( (obj instanceof ComponentType) == false ) return false; boolean equals = false; final ComponentType other = (ComponentType) obj; // type if( type != null ) { equals = type.equals(other.getType()); } else { equals = type == other.getType(); } // subtype if( equals ) { if( subtype != null ) { equals = subtype.equals(other.getSubtype()); } else { equals = subtype == other.getSubtype(); } } return equals; } public String toString() { StringBuilder tmp = new StringBuilder("ComponentType"); tmp.append('{'); tmp.append("type="); tmp.append(type); tmp.append(", subtype="); tmp.append(subtype); tmp.append('}'); return tmp.toString(); } } libjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/api/Fields.java0000644000175000017500000000475610700167420031303 0ustar twernertwerner/* * 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 Adrian Brock * @version $Revision: 1.1 $ */ public interface Fields extends Serializable { /** The name field name */ String NAME = "name"; /** The mapped name field name */ String MAPPED_NAME = "mappedName"; /** The description field name */ String DESCRIPTION = "description"; /** The meta type field name */ String META_TYPE = "metaType"; /** The value */ String VALUE = "value"; /** The legal values */ String LEGAL_VALUES = "legalValues"; /** The minimum value */ String MINIMUM_VALUE = "minValue"; /** The maximum value */ String MAXIMUM_VALUE = "maxValue"; /** The mandatory */ String MANDATORY = "mandatory"; /** The PropertyInfo info for the ManagedObject attachment */ String PROPERTY_INFO = "propertyInfo"; /** The annotations associated with the property */ String ANNOTATIONS = "annotations"; /** The attachment */ String ATTACHMENT = "attachment"; // TODO other standard fields here /** * Get a field with the given name * * @param name the name * @return the field value */ Serializable getField(String name); /** * Set a field with the given name * * @param name the name * @param value the field value */ void setField(String name, Serializable value); } libjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/api/annotation/0000755000175000017500000000000011105402551031365 5ustar twernertwerner././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/api/annotation/ManagementObjectClass.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/api/annotation/Manageme0000644000175000017500000000326211077433664033046 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.managed.api.annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** * ManagementObjectClass annotation for describing the actual class * annotated with org.jboss.managed.api.annotation.ManagementObject. * * @see {@linkplain org.jboss.managed.api.annotation.ManagementObject} * * @author Dimitris Andreadis * @version $Revision: 1.1 $ */ @Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) public @interface ManagementObjectClass { /** The class annotated with ManagementObject */ Class code(); } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/api/annotation/ManagementObject.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/api/annotation/Manageme0000644000175000017500000001001211104137625033022 0ustar twernertwerner/* * 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; import org.jboss.managed.api.Fields; import org.jboss.managed.api.ManagedObject; import org.jboss.managed.api.ManagedProperty; import org.jboss.managed.api.annotation.ManagementProperty.NULL_CONSTRAINTS; import org.jboss.managed.api.annotation.ManagementProperty.NULL_FIELDS_FACTORY; import org.jboss.managed.api.annotation.ManagementProperty.NULL_PROPERTY_FACTORY; import org.jboss.managed.spi.factory.ManagedPropertyConstraintsPopulatorFactory; /** * ManagementObject annotation for describing ManagedObjects. * {@linkplain ManagedObject} * * @author Adrian Brock * @author Scott.Stark@jboss.org * @version $Revision: 1.1 $ */ @Inherited @Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) public @interface ManagementObject { /** The name used for ManagementObjectRef resolution. Generally * this is taken from a property annotated with * {@linkplain ManagementObjectID}. */ String name() default ManagementConstants.GENERATED; /** * A description for the managed object. */ String description() default ManagementConstants.GENERATED; /** The name type used for ManagementObjectRef resolution. Generally * this is taken from a property annotated with * {@linkplain ManagementObjectID}. */ String type() default AnnotationDefaults.EMPTY_STRING; /** The metadata attachment name for the ManagedObject */ String attachmentName() default AnnotationDefaults.EMPTY_STRING; /** Is this a runtime extension of another ManagedObject. This * is used to tie together */ boolean isRuntime() default false; /** The component type for MCs that are ManagedComponents */ ManagementComponent componentType() default @ManagementComponent(type="", subtype=""); /** What properties to include */ ManagementProperties properties() default ManagementProperties.ALL; /** * A class level specification of the management properties. Depending on the * properties() value, this can either override or augment the ManagementProperty * annotations found on the bean fields/methods. * @return */ ManagementProperty[] classProperties() default {}; /** The exposed operations. If empty the operations will be obtained from * the annotated bean in a bean type specific way. */ ManagementOperation[] operations() default {}; /** The class to use for the ManagedProperty implementation */ Class propertyFactory() default NULL_PROPERTY_FACTORY.class; /** The class to use for the ManagedProperty Fields implementation */ Class fieldsFactory() default NULL_FIELDS_FACTORY.class; /** The constraints, allowed values populator factory */ Class constraintsFactory() default NULL_CONSTRAINTS.class; } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/api/annotation/ManagementComponent.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/api/annotation/Manageme0000644000175000017500000000267511104137625033042 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, Red Hat Middleware LLC, and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.managed.api.annotation; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** * An annotation that identifies property as metdata identifying * a ManagedComponent * * @author Scott.Stark@jboss.org * @version $Revision: 80522 $ */ @Target({}) @Retention(RetentionPolicy.RUNTIME) public @interface ManagementComponent { String type(); String subtype(); } ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/api/annotation/ManagementObjectID.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/api/annotation/Manageme0000644000175000017500000000347110665114544033043 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, Red Hat Middleware LLC, and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.managed.api.annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** * An annotation that identifies a ManagedObject key/type * qualifier source. * * @author Scott.Stark@jboss.org * @version $Revision: 64930 $ */ @Target({ElementType.TYPE, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) public @interface ManagementObjectID { /** An explicit ManagedObject name. If empty, the name is * taken from the annotated property. */ String name() default AnnotationDefaults.EMPTY_STRING; /** A qualifier for the name that provides a context to * identify the type or scope of the ManagedObject name. */ String type() default AnnotationDefaults.EMPTY_STRING; } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/api/annotation/ManagementObjectRef.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/api/annotation/Manageme0000644000175000017500000000365210756347602033050 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, Red Hat Middleware LLC, and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.managed.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.managed.api.ManagedObject; /** * Indicates a property that references another ManagedObject * * @author Scott.Stark@jboss.org * @version $Revision: 69903 $ */ @Target({ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) public @interface ManagementObjectRef { /** An explicit ManagedObject name. If empty, the name is * taken from the annotated property. * @see {@linkplain ManagedObject#getName()} */ String name() default AnnotationDefaults.EMPTY_STRING; /** A qualifier for the name that provides a context to * identify the type or scope of the ManagedObject name. * @see {@linkplain ManagedObject#getNameType()} */ String type() default AnnotationDefaults.EMPTY_STRING; } ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/api/annotation/ManagementProperty.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/api/annotation/Manageme0000644000175000017500000001100511104137625033025 0ustar twernertwerner/* * 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.io.Serializable; import java.lang.annotation.Annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import org.jboss.managed.api.Fields; import org.jboss.managed.api.ManagedProperty; import org.jboss.managed.spi.factory.InstanceClassFactory; import org.jboss.managed.spi.factory.ManagedPropertyConstraintsPopulator; import org.jboss.managed.spi.factory.ManagedPropertyConstraintsPopulatorFactory; /** * ManagementProperty annotation for describing a ManagedProperty * * @author Adrian Brock * @author Scott.Stark@jboss.org * @version $Revision: 80522 $ */ @Target({ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) 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 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}; /** Strings describing free form association to admin views (Ports, Networks, ...} */ String[] adminViews() default {}; /** The class to use for the ManagedProperty implementation */ Class propertyFactory() default NULL_PROPERTY_FACTORY.class; /** The class to use for the ManagedProperty Fields implementation */ Class fieldsFactory() default NULL_FIELDS_FACTORY.class; /** The constraints, allowed values populator factory */ Class constraintsFactory() default NULL_CONSTRAINTS.class; /** The constraints, allowed values populator factory */ Class> marshallerFactory() default NULL_MARSHALLER_FACTORY.class; /** * Used in {@link ManagementProperty#constraintsFactory()} to * signal that the factory be inferred from the type * of the property. */ public static final class NULL_CONSTRAINTS implements ManagedPropertyConstraintsPopulatorFactory { public ManagedPropertyConstraintsPopulator newInstance() { return null; } } /** * Used in {@link ManagementProperty#fieldsFactory()} to * indicate that no Fields factory is defined. */ public static abstract class NULL_FIELDS_FACTORY implements Fields { } /** * Used in {@link ManagementProperty#propertyFactory()} to * indicate that no ManagedProperty factory is defined. */ public static abstract class NULL_PROPERTY_FACTORY implements ManagedProperty { } /** * Used in {@link ManagementProperty#propertyFactory()} to * indicate that no ManagedProperty factory is defined. */ public static abstract class NULL_MARSHALLER_FACTORY implements InstanceClassFactory { } } ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/api/annotation/AnnotationDefaults.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/api/annotation/Annotati0000644000175000017500000000370611104137625033101 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, Red Hat Middleware LLC, and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.managed.api.annotation; /** * Defaults for annotations to test whether object annotations * are at their default value and unitialized. * * @author Scott.Stark@jboss.org * @version $Revision: 80522 $ */ public class AnnotationDefaults { @ManagementObject(name="AnnotationDefaults", componentType=@ManagementComponent(type="", subtype="")) private static class COMP_TYPE_CLASS {} /** The ManagementComponent uninitialized default */ public static final ManagementComponent COMP_TYPE = defaultCompType(); /** The default uninitialized String value */ public static final String EMPTY_STRING = ""; /** * The unitialized/default ManagementComponent value * @return The unitialized/default ManagementComponent value */ public static synchronized ManagementComponent defaultCompType() { ManagementObject mo = COMP_TYPE_CLASS.class.getAnnotation(ManagementObject.class); return mo.componentType(); } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/api/annotation/ViewUse.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/api/annotation/ViewUse.0000644000175000017500000000306211104137625032764 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2005, 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 org.jboss.managed.api.ManagedProperty; /** * An enum for the types of management views a {@link ManagedProperty property} * is associated with. * * @author Scott.Stark@jboss.org * @version $Revision: 80522 $ */ public enum ViewUse { /** A read-write property used for creating/updating a config */ CONFIGURATION, /** A read-write type of property that can be set on the runtime component */ RUNTIME, /** A read-only type of property that provides runtime stats */ STATISTIC } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/api/annotation/ManagementConstants.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/api/annotation/Manageme0000644000175000017500000000237310645072106033036 0ustar twernertwerner/* * 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; /** * ManagementConstants. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public interface ManagementConstants { /** Whether to generate the value */ String GENERATED = "%Generated%"; } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/api/annotation/ManagementRuntimeRef.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/api/annotation/Manageme0000644000175000017500000000412710756347602033046 0ustar twernertwerner/* * 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.annotation; import java.lang.annotation.Target; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import org.jboss.managed.spi.factory.RuntimeComponentNameTransformer; /** * ManagementRuntimeRef annotation that can be used * to identify which property defines the component name. * * @author Ales Justin */ @Target({ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) public @interface ManagementRuntimeRef { /** * The name transformer. * * @return the transformer class */ Class transformer() default DEFAULT_NAME_TRANSFORMER.class; /** * Used in {@link ManagementRuntimeRef#transformer()} to * indicate that no name transformation is defined. */ public static final class DEFAULT_NAME_TRANSFORMER implements RuntimeComponentNameTransformer { public Object transform(Object value) { return value; } } } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/api/annotation/ManagementProperties.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/api/annotation/Manageme0000644000175000017500000000312411104137625033030 0ustar twernertwerner/* * 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; /** * ManagementProperities. * * @author Adrian Brock * @author Scott.Stark@jboss.org * @version $Revision: 80522 $ */ public enum ManagementProperties { /** All properties by default */ ALL, /** Only bean properties annotated with @ManagementProperty */ EXPLICIT, /** Only @ManagementProperty from the @ManagementObject class annotation */ CLASS, /** Merge @ManagementProperty from the @ManagementObject class annotation * and any bean properties annotated with @ManagementProperty */ CLASS_AND_EXPLICIT } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/api/annotation/ManagementDeployment.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/api/annotation/Manageme0000644000175000017500000000432711013571146033035 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.managed.api.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; import org.jboss.managed.api.ManagedDeployment.DeploymentPhase; /** * An annotation identifying a managed deployment * * @author Scott.Stark@jboss.org * @version $Revision: 73460 $ */ @Inherited @Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) public @interface ManagementDeployment { /** * Get the simple name (x.ear) for the deployment. Generally * this is taken from the DeploymentUnit.simpleName. * @return simple name of the deployment */ String simpleName() default ManagementConstants.GENERATED; /** * A description of the managed deployment * @return description of the managed deployment */ String description() default ManagementConstants.GENERATED; /** * The phase the deployment belongs to * @return the phase of the deployment */ DeploymentPhase phase() default DeploymentPhase.APPLICATION; /** * Get the deployment/module types. * @return deployment types */ String[] types() default {}; } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/api/annotation/ManagementOperation.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/api/annotation/Manageme0000644000175000017500000000427710665114544033050 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, Red Hat Middleware LLC, and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.managed.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.managed.api.ManagedOperation.Impact; import org.jboss.managed.api.annotation.ManagementParameter.NULL_CONSTRAINTS; import org.jboss.managed.spi.factory.ManagedParameterConstraintsPopulatorFactory; /** * An annotation for describing a ManagedOperation * * @author Scott.Stark@jboss.org * @version $Revision: 64930 $ */ @Target({ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) public @interface ManagementOperation { /** The name of the operation */ String name() default AnnotationDefaults.EMPTY_STRING; /** The parameters of the operation */ ManagementParameter[] params() default {}; /** The description */ String description() default AnnotationDefaults.EMPTY_STRING; /** The side-effect impact of invoking the operation */ Impact impact() default Impact.Unknown; /** The parameter constraints, allowed values populator factory */ Class constraintsFactory() default NULL_CONSTRAINTS.class; } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/api/annotation/ManagementParameter.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/api/annotation/Manageme0000644000175000017500000000433411060232304033023 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, Red Hat Middleware LLC, and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.managed.api.annotation; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import org.jboss.managed.spi.factory.ManagedParameterConstraintsPopulator; import org.jboss.managed.spi.factory.ManagedParameterConstraintsPopulatorFactory; /** * Annotation for documenting a ManagementOperation parameter. * * @author Scott.Stark@jboss.org * @version $Revision: 78084 $ */ @Retention(RetentionPolicy.RUNTIME) public @interface ManagementParameter { /** The parameter name */ String name() default AnnotationDefaults.EMPTY_STRING; /** The parameter description */ String description() default AnnotationDefaults.EMPTY_STRING; /** The constraints, allowed values populator factory */ Class constraintsFactory() default NULL_CONSTRAINTS.class; /** * Used in {@link ManagementParameter#constraintsFactory()} to * signal that the factory be inferred from the type * of the property. */ public static final class NULL_CONSTRAINTS implements ManagedParameterConstraintsPopulatorFactory { public ManagedParameterConstraintsPopulator newInstance() { return null; } } } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/api/DeploymentTemplateInfo.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/api/DeploymentTemplateI0000644000175000017500000000405411104137625033074 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, Red Hat Middleware LLC, and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.managed.api; import java.util.Map; import org.jboss.managed.api.ManagedProperty; /** * The exportable information for a DeploymentTemplate. * * @author Scott.Stark@jboss.org * @version $Revision: 80522 $ */ public interface DeploymentTemplateInfo { /** * The name of the DeploymentTemplate this info corresponds to * @return name of the deployment template */ public String getName(); /** * Information about the deployment template * @return Information about the deployment template */ public String getDescription(); /** * The name of the ManagedProperty in the Map map * obtained from the mainDeployer.getManagedObjects(VFSDeployment) * for the DeploymentTemplate this info is associated with. */ public String getRootManagedPropertyName(); /** * Get the template properties. * @return A name to property mapping of the properties that can be set * for use by the deployment template. */ public Map getProperties(); } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/api/MutableManagedObject.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/api/MutableManagedObjec0000644000175000017500000000527211104137625032763 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.managed.api; import java.util.Map; import java.util.Set; import org.jboss.managed.api.annotation.ManagementObject; import org.jboss.managed.api.annotation.ManagementObjectID; import org.jboss.managed.api.annotation.ManagementRuntimeRef; /** * An extension of ManagedObject that allows setting of key values after * the ManagedObject has been created. * * @author Scott.Stark@jboss.org * @version $Revision: 80522 $ */ public interface MutableManagedObject extends ManagedObject { /** * Set the external name by which the ManagedObject is known * @see {@linkplain ManagementObject#name}} * @see {@linkplain ManagementObjectID#name}} * @return the name */ public void setName(String name); /** * Set the runtime component name. * * @see {@linkplain ManagementRuntimeRef} * @return name of runtime component if one exists, null if no component exists. */ public void setComponentName(Object name); /** * Set the parent ManagedObject. * @param parent - the parent ManagedObject, null if no parent exists. */ public void setParent(ManagedObject parent); /** * Set the metadata attachment. * @param attachment - the metadata attachment this ManagedObject maps to. */ public void setAttachment(Object attachment); /** * Set the ManagedObject ManagedProperty mapping. * @param properties - the ManagedProperty mapping. */ public void setProperties(Map properties); /** * Set the ManagedOperation associated with the ManagedObject. * @param operations - the ManagedOperations for the ManagedObject. */ public void setOperations(Set operations); } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/api/ManagedDeployment.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/api/ManagedDeployment.j0000644000175000017500000001121111022031721032752 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, Red Hat Middleware LLC, and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.managed.api; import java.util.List; import java.util.Map; import java.util.Set; import org.jboss.managed.api.ManagedProperty; /** * A collection of ManagedComponent and structural information * about a deployment. * * @author Scott.Stark@jboss.org * @version $Revision: 74147 $ */ public interface ManagedDeployment { /** The phase of deployment */ public enum DeploymentPhase { /** A deployment loaded during the server bootstrap phase */ BOOTSTRAP, /** An mc/service deployment for a Deployer to be loaded after the BOOTSTRAP phase */ DEPLOYER, /** Any deployment content to be loaded after the DEPLOYER phase */ APPLICATION, /** Any unversioned deployment content to be loaded after the APPLICATION phase */ APPLICATION_TRANSIENT }; /** * Get the full name of the associated DeploymentUnit. * @return full name of the DeploymentUnit */ public String getName(); /** * Get the simple name (x.ear) for the deployment * @return simple name of the deployment */ public String getSimpleName(); /** * Get the phase this deployment is associated with * @return the phase */ public DeploymentPhase getDeploymentPhase(); /** * Add a deployment/module type * @param type * @return true if the type was added, false if it already exists */ public boolean addType(String type); /** * Get the deployment/module types. * @return deployment types */ public Set getTypes(); /** * Get the deployment/module types. * @param types */ public void setTypes(Set types); /** * Get the managed property names * * @return the property names */ public Set getPropertyNames(); /** * Get a property * * @param name the name * @return the property */ public ManagedProperty getProperty(String name); /** * Get the properties * * @return the properties */ public Map getProperties(); /** * Get the managed object names * * @return the property names */ public Set getManagedObjectNames(); public Map getManagedObjects(); public ManagedObject getManagedObject(String name); /** * * @return the parent */ public ManagedDeployment getParent(); public ManagedComponent getComponent(String name); /** * Get the ManagedComponents for the deployment module. * @return ManagedComponents for the deployment module. */ public Map getComponents(); /** * Get the nested deployment modules. * @return nested deployment modules. */ public List getChildren(); /** * Get the DeploymentTemplate names for components * that can be added to this deployment. * @return the template names */ public Set getComponentTemplateNames(); /** * Add a component to this deployment * @param name the name * @param comp the component */ public void addComponent(String name, ManagedComponent comp); /** * * @param name the name * @return true when it was removed */ public boolean removeComponent(String name); /** * Get the DeploymentTemplate names for deployments * that can be added to this deployment. * @return the template names */ public Set getDeploymentTemplateNames(); /** * Add a deployment * @param deplymentBaseName * @param info * @return the deployment */ public ManagedDeployment addModule(String deplymentBaseName, DeploymentTemplateInfo info); } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/api/ManagedOperation.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/api/ManagedOperation.ja0000644000175000017500000000526110761511660032761 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.managed.api; import java.io.Serializable; import org.jboss.metatype.api.types.MetaType; import org.jboss.metatype.api.values.MetaValue; /** * A representation of a managed operation. * * @author Scott.Stark@jboss.org * @version $Revision: 70207 $ */ public interface ManagedOperation extends Serializable { /** * The side-effect impact of invoking an operation */ public enum Impact { /** There is not modification of the ManagedObject */ ReadOnly, /** The impact may modify the ManagedObject */ ReadWrite, /** The impact is to modify the ManagedObject */ WriteOnly, /** The impact is not known */ Unknown }; /** * Get the operation description * @return the operation description */ public String getDescription(); /** * Get the name of the operation * @return the name of the operation */ public String getName(); /** * Get the impact of the operation * @return the side-effect type invoking the operation has. */ public Impact getImpact(); /** * The MetaType for the operation return value. * @return MetaType for the operation return value. */ public MetaType getReturnType(); /** * The parameter information for the operation arguments. An empty * signature array is returned if the operation takes no arguments. * @return parameter information for the operation arguments. */ public ManagedParameter[] getParameters(); /** * Invoke the operation given its parameter values. * * @param param the varags for the operation parameters. * @return the MetaValue for the result. */ public Object invoke(MetaValue... param); } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/api/ManagedParameter.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/api/ManagedParameter.ja0000644000175000017500000000554010761511660032741 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.managed.api; import java.io.Serializable; import java.util.Set; import org.jboss.metatype.api.types.MetaType; import org.jboss.metatype.api.values.MetaValue; /** * A representation of a ManagedOperation parameter * * @author Scott.Stark@jboss.org * @version $Revision: 70207 $ */ public interface ManagedParameter extends Serializable { /** * Get the fields * * @return the fields */ Fields getFields(); /** * Get a field * * @param the expected type * @param fieldName the field name * @param expected the expected type * @return the value */ T getField(String fieldName, Class expected); /** * Set a field * * @param fieldName the field name * @param value the value */ void setField(String fieldName, Serializable value); /** * Get the property's name * * @return the property's name */ String getName(); /** * Get the description * * @return the description */ String getDescription(); /** * Get the type * * @return the type */ MetaType getMetaType(); /** * Get the value * * @return the value */ Object getValue(); /** * Set the value * * @param value the value */ void setValue(Serializable value); /** * Get the legal values * * @return the legal values */ Set getLegalValues(); /** * Get the minimum value * * @return the minimum value */ Comparable getMinimumValue(); /** * Get the miximum value * * @return the maximum value */ Comparable getMaximumValue(); /** * Check whether this is a valid value * * @param value the value * @return null for a valid value, an error message otherwise */ String checkValidValue(Serializable value); } libjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/spi/0000755000175000017500000000000011105402551027235 5ustar twernertwernerlibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/spi/factory/0000755000175000017500000000000011105402551030704 5ustar twernertwerner././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/spi/factory/ManagedObjectBuilder.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/spi/factory/ManagedObje0000644000175000017500000000311511104137625032771 0ustar twernertwerner/* * 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.spi.factory; import org.jboss.managed.api.ManagedObject; import org.jboss.metadata.spi.MetaData; /** * ManagedObjectBuilder. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public interface ManagedObjectBuilder { /** * Build the managed object * * @param clazz the class * @param metaData - the optional metadata repository accessor used to query * for management annotation overrides/additions to the clazz * @return the managed object */ ManagedObject buildManagedObject(Class clazz, MetaData metaData); } ././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/spi/factory/ManagedPropertyConstraintsPopulator.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/spi/factory/ManagedProp0000644000175000017500000000334510756347602033051 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, Red Hat Middleware LLC, and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.managed.spi.factory; import org.jboss.beans.info.spi.PropertyInfo; import org.jboss.managed.api.Fields; /** * Plugin for the ManagedProperty fields constraint related info. * * @author Scott.Stark@jboss.org * @version $Revision: 69903 $ */ public interface ManagedPropertyConstraintsPopulator { /** Populate the ManagedProperty fields constraint related info. * @param attachmentClass - the attachment class the property is * associated with * @param info - the PropertyInfo for the attachment class property * @param fields - the fields to add the constraints to */ @SuppressWarnings("unchecked") public void populateManagedProperty(Class attachmentClass, PropertyInfo info, Fields fields); } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/spi/factory/InstanceClassFactory.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/spi/factory/InstanceCla0000644000175000017500000000640011104137625033021 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, Red Hat Middleware LLC, and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.managed.spi.factory; import org.jboss.beans.info.spi.BeanInfo; import org.jboss.managed.api.ManagedProperty; import org.jboss.metadata.spi.MetaData; import org.jboss.metatype.api.values.MetaValue; /** * A plugin for obtaining the class to scan for management object * related annotations, converting property values to/from MetaValue, * and determining runtime component names. * * @param actual attachment type * @author Scott.Stark@jboss.org * @author Ales.Justin@jboss.org * @version $Revision: 80522 $ */ public interface InstanceClassFactory { Class getType(); /** * Return the Class that represents the root ManagedObject to scan * for management object related annotations. * * @param attachment - the instance a ManagedObject is to be created for. * @return the Class that represents the root ManagedObject. * @throws ClassNotFoundException if MO class not found */ Class getManagedObjectClass(T attachment) throws ClassNotFoundException; /** * Get the value from object. * * @param beanInfo managed object's bean info * @param property managed property being set * @param attachment - the object which own's the property * @return value - the meta value form of the property value */ MetaValue getValue(BeanInfo beanInfo, ManagedProperty property, MetaData metaData, T attachment); /** * Set the property value to attachment object. * * @param beanInfo managed object's bean info * @param property managed property being set * @param attachment - the object which own's the property * @param value - the meta value form of the property value */ void setValue(BeanInfo beanInfo, ManagedProperty property, T attachment, MetaValue value); /** * Get the runtime component name. * * @param beanInfo managed object's bean info * @param property managed property being set * @param attachment - the object which own's the property * @param value - the meta value form of the property value * @return the name of the runtime object which is associated with the property. May * be null if no such component exists. */ Object getComponentName(BeanInfo beanInfo, ManagedProperty property, T attachment, MetaValue value); } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/spi/factory/ManagedObjectPopulator.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/spi/factory/ManagedObje0000644000175000017500000000534111104137625032774 0ustar twernertwerner/* * 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.spi.factory; import org.jboss.managed.api.ManagedObject; import org.jboss.managed.api.MutableManagedObject; import org.jboss.metadata.spi.MetaData; /** * ManagedObjectPopulator. * * @param the underlying object * @author Adrian Brock * @author Scott.Stark@jboss.org * @version $Revision: 80522 $ */ public interface ManagedObjectPopulator { /** * Create a new underlying object from clazz and construct its ManagedObject. * * @param managedObject the managed object * @param clazz the class */ void createObject(ManagedObject managedObject, Class clazz); /** * Create a new underlying object from clazz and construct its ManagedObject. * * @param managedObject the managed object * @param clazz the class * @param metaData - the optional metadata repository accessor used to query * for property annotations. */ void createObject(ManagedObject managedObject, Class clazz, MetaData metaData); /** * Populate the managed object with property values from the object. * * @param managedObject the managed object to populate with values * @param object the object used to populate the managed object */ void populateManagedObject(MutableManagedObject managedObject, T object); /** * Populate the managed object with property values from the object. * * @param managedObject the managed object to populate with values * @param object the object used to populate the managed object * @param metaData - the optional metadata repository accessor used to query * for property annotations. */ void populateManagedObject(MutableManagedObject managedObject, T object, MetaData metaData); } ././@LongLink0000000000000000000000000000021200000000000011560 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/spi/factory/ManagedParameterConstraintsPopulatorFactory.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/spi/factory/ManagedPara0000644000175000017500000000245310665114544033007 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, Red Hat Middleware LLC, and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.managed.spi.factory; /** * Stateless factory for obtaining a ManagedParameterConstraintsPopulator * * @author Scott.Stark@jboss.org * @version $Revision: 64930 $ */ public interface ManagedParameterConstraintsPopulatorFactory { ManagedParameterConstraintsPopulator newInstance(); } ././@LongLink0000000000000000000000000000021100000000000011557 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/spi/factory/ManagedPropertyConstraintsPopulatorFactory.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/spi/factory/ManagedProp0000644000175000017500000000245010665114544033041 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, Red Hat Middleware LLC, and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.managed.spi.factory; /** * Stateless factory for obtaining a ManagedPropertyConstraintsPopulator * * @author Scott.Stark@jboss.org * @version $Revision: 64930 $ */ public interface ManagedPropertyConstraintsPopulatorFactory { ManagedPropertyConstraintsPopulator newInstance(); } ././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/spi/factory/RuntimeComponentNameTransformer.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/spi/factory/RuntimeComp0000644000175000017500000000253310701754233033104 0ustar twernertwerner/* * 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.spi.factory; /** * Runtime component name transformer. * * @author ales.justin@jboss.org */ public interface RuntimeComponentNameTransformer { /** * Transform the name from string. * * @param value current name value * @return transformed name */ Object transform(Object value); } ././@LongLink0000000000000000000000000000020300000000000011560 Lustar rootrootlibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/spi/factory/ManagedParameterConstraintsPopulator.javalibjboss-managed-java-2.0.0.CR4.orig/managed/src/main/java/org/jboss/managed/spi/factory/ManagedPara0000644000175000017500000000334610756347602033015 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, Red Hat Middleware LLC, and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.managed.spi.factory; import org.jboss.managed.api.Fields; import org.jboss.managed.api.ManagedParameter; import org.jboss.reflect.spi.ParameterInfo; /** * Plugin for the {@linkplain ManagedParameter} constraint related info. * * @author Scott.Stark@jboss.org * @version $Revision: 69903 $ */ public interface ManagedParameterConstraintsPopulator { /** Populate the ManagedParameter fields constraint related info. * @param methodName - the name of the method the param is * associated with * @param info - the ParameterInfo for the method param * @param fields - the fields to add the constraints to */ public void populateManagedParameter(String methodName, ParameterInfo info, Fields fields); } libjboss-managed-java-2.0.0.CR4.orig/managed/.settings/0000755000175000017500000000000011105402551022421 5ustar twernertwernerlibjboss-managed-java-2.0.0.CR4.orig/managed/.settings/org.eclipse.jdt.core.prefs0000644000175000017500000000032010674774740027424 0ustar twernertwerner#Fri Sep 21 17:49:07 BST 2007 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.source=1.5 org.eclipse.jdt.core.compiler.compliance=1.5 libjboss-managed-java-2.0.0.CR4.orig/managed/pom.xml0000644000175000017500000000401411104141463022020 0ustar twernertwerner org.jboss.man jboss-man 2.0.0.CR4 4.0.0 jboss-managed jar JBoss Managed http://www.jboss.com/products/jbossmc JBoss Managed org.apache.maven.plugins maven-assembly-plugin src/assembly/api.xml src/assembly/plugins.xml org.jboss.man jboss-metatype org.jboss jboss-mdr sun-jaxb jaxb-api org.jboss.logging jboss-logging-log4j test org.jboss.test jboss-test test junit junit test javassist javassist test libjboss-managed-java-2.0.0.CR4.orig/pom.xml0000644000175000017500000002147011104141463020431 0ustar twernertwerner 4.0.0 org.jboss jboss-parent 4 org.jboss.man jboss-man 2.0.0.CR4 pom JBoss Managed Parent POM http://www.jboss.com/products/jbossmc JBoss Managed Parent POM scm:svn:https://svn.jboss.org/repos/jbossas/projects/jboss-man/tags/2.0.0.CR4 scm:svn:https://svn.jboss.org/repos/jbossas/projects/jboss-man/tags/2.0.0.CR4 scm:svn:https://svn.jboss.org/repos/jbossas/projects/jboss-man/tags/2.0.0.CR4 2.2.8.GA 2.0.5.GA 2.0.5.GA 2.0.0.CR1 2.0.0.GA 1.1.1.GA 4.4 2.1.4 3.9.0.GA metatype managed build ${microcontainer.outputDirectory} ${microcontainer.testOutputDirectory} ${artifactId} org.apache.maven.plugins maven-compiler-plugin 2.0.2 1.5 1.5 true true true org.apache.maven.plugins maven-release-plugin 2.0-beta-7 https://svn.jboss.org/repos/jbossas/projects/jboss-man/tags true org.apache.maven.plugins maven-assembly-plugin 2.2-beta-2 make-assembly package attached maven-idea-plugin true org.apache.maven.plugins maven-jar-plugin 2.2 org.apache.maven.plugins maven-surefire-plugin 2.4.1 true org/jboss/test/**/*TestCase.java org.apache.maven.plugins maven-project-info-reports-plugin dependencies issue-tracking license scm org.codehaus.mojo findbugs-maven-plugin 1.0.0 org.jboss.man jboss-managed ${project.version} org.jboss.man jboss-metatype ${project.version} org.jboss jboss-common-core ${version.jboss.common.core} org.jboss.logging jboss-logging-spi ${version.jboss.common.logging.spi} org.jboss.logging jboss-logging-log4j ${version.jboss.common.logging.log4j} org.jboss jboss-reflect ${version.org.jboss.reflect} org.jboss jboss-mdr ${version.org.jboss.mdr} org.jboss.test jboss-test ${version.org.jboss.test} test junit junit ${version.junit} test sun-jaxb jaxb-api ${version.sun.jaxb} javassist javassist ${version.javassist} repository.jboss.org JBoss Repository default http://repository.jboss.org/maven2/ true false snapshots.jboss.org JBoss Snapshots Repository default http://snapshots.jboss.org/maven2/ true false default true target/classes target/tests-classes eclipse process-test-resources maven-eclipse-plugin eclipse process-test-resources eclipse true ${microcontainer.outputDirectory} eclipse-target/classes eclipse-target/tests-classes