Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 89849 invoked from network); 10 May 2009 18:37:02 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 10 May 2009 18:37:02 -0000 Received: (qmail 47278 invoked by uid 500); 10 May 2009 18:37:01 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 47194 invoked by uid 500); 10 May 2009 18:37:01 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 47185 invoked by uid 99); 10 May 2009 18:37:01 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 10 May 2009 18:37:01 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 10 May 2009 18:36:48 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 57D1A23888F4; Sun, 10 May 2009 18:36:27 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r773384 - in /geronimo/sandbox/blueprint/blueprint-core/src: main/java/org/apache/geronimo/blueprint/context/ main/java/org/apache/geronimo/blueprint/utils/ test/java/org/apache/geronimo/blueprint/ test/java/org/apache/geronimo/blueprint/po... Date: Sun, 10 May 2009 18:36:27 -0000 To: scm@geronimo.apache.org From: gawor@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090510183627.57D1A23888F4@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: gawor Date: Sun May 10 18:36:26 2009 New Revision: 773384 URL: http://svn.apache.org/viewvc?rev=773384&view=rev Log: support generics Added: geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/pojos/PojoGenerics.java (with props) geronimo/sandbox/blueprint/blueprint-core/src/test/resources/test-generics.xml (with props) Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintObjectRecipe.java geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/utils/ArgumentsMatch.java geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/WiringTest.java Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintObjectRecipe.java URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintObjectRecipe.java?rev=773384&r1=773383&r2=773384&view=diff ============================================================================== --- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintObjectRecipe.java (original) +++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintObjectRecipe.java Sun May 10 18:36:26 2009 @@ -175,7 +175,7 @@ private List getFinalArguments(ArgumentsMatch match, boolean refAllowed) throws ConstructionException { List arguments = match.getArguments(); - Class[] parameterTypes = match.getParameterTypes(); + Type[] parameterTypes = match.getGenericParameterTypes(); List args = new ArrayList(); for (int i = 0; i < arguments.size(); i++) { Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/utils/ArgumentsMatch.java URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/utils/ArgumentsMatch.java?rev=773384&r1=773383&r2=773384&view=diff ============================================================================== --- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/utils/ArgumentsMatch.java (original) +++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/utils/ArgumentsMatch.java Sun May 10 18:36:26 2009 @@ -20,6 +20,7 @@ import java.lang.reflect.Constructor; import java.lang.reflect.Method; +import java.lang.reflect.Type; import java.util.List; /** @@ -62,6 +63,16 @@ } } + public Type[] getGenericParameterTypes() { + if (constructor != null) { + return constructor.getGenericParameterTypes(); + } else if (method != null) { + return method.getGenericParameterTypes(); + } else { + return null; + } + } + public List getArguments() { return arguments; } Modified: geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/WiringTest.java URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/WiringTest.java?rev=773384&r1=773383&r2=773384&view=diff ============================================================================== --- geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/WiringTest.java (original) +++ geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/WiringTest.java Sun May 10 18:36:26 2009 @@ -20,8 +20,12 @@ import java.math.BigInteger; import java.net.URI; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import org.apache.geronimo.blueprint.CallbackTracker.Callback; import org.apache.geronimo.blueprint.context.BlueprintObjectInstantiator; @@ -32,6 +36,7 @@ import org.apache.geronimo.blueprint.pojos.Multiple; import org.apache.geronimo.blueprint.pojos.PojoA; import org.apache.geronimo.blueprint.pojos.PojoB; +import org.apache.geronimo.blueprint.pojos.PojoGenerics; import org.apache.xbean.recipe.Repository; import org.osgi.framework.ServiceRegistration; @@ -276,6 +281,57 @@ assertEquals(integerValue, ((Multiple)obj).getInteger()); } + public void testGenerics() throws Exception { + ComponentDefinitionRegistryImpl registry = parse("/test-generics.xml"); + RecipeBuilder i = new RecipeBuilder(new TestBlueprintContext(registry)); + Repository repository = i.createRepository(registry); + BlueprintObjectInstantiator graph = new BlueprintObjectInstantiator(repository); + + List expectedList = new ArrayList(); + expectedList.add(new Integer(10)); + expectedList.add(new Integer(20)); + expectedList.add(new Integer(50)); + + Set expectedSet = new HashSet(); + expectedSet.add(new Long(1000)); + expectedSet.add(new Long(2000)); + expectedSet.add(new Long(5000)); + + Map expectedMap = new HashMap(); + expectedMap.put(new Short((short)1), Boolean.TRUE); + expectedMap.put(new Short((short)2), Boolean.FALSE); + expectedMap.put(new Short((short)5), Boolean.TRUE); + + Object obj; + PojoGenerics pojo; + + obj = graph.create("method"); + assertTrue(obj instanceof PojoGenerics); + pojo = (PojoGenerics) obj; + + assertEquals(expectedList, pojo.getList()); + assertEquals(expectedSet, pojo.getSet()); + assertEquals(expectedMap, pojo.getMap()); + + obj = graph.create("constructorList"); + assertTrue(obj instanceof PojoGenerics); + pojo = (PojoGenerics) obj; + + assertEquals(expectedList, pojo.getList()); + + obj = graph.create("constructorSet"); + assertTrue(obj instanceof PojoGenerics); + pojo = (PojoGenerics) obj; + + assertEquals(expectedSet, pojo.getSet()); + + obj = graph.create("constructorMap"); + assertTrue(obj instanceof PojoGenerics); + pojo = (PojoGenerics) obj; + + assertEquals(expectedMap, pojo.getMap()); + } + public void testCircular() throws Exception { ComponentDefinitionRegistryImpl registry = parse("/test-circular.xml"); RecipeBuilder i = new RecipeBuilder(new TestBlueprintContext(registry)); Added: geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/pojos/PojoGenerics.java URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/pojos/PojoGenerics.java?rev=773384&view=auto ============================================================================== --- geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/pojos/PojoGenerics.java (added) +++ geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/pojos/PojoGenerics.java Sun May 10 18:36:26 2009 @@ -0,0 +1,77 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.geronimo.blueprint.pojos; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +public class PojoGenerics { + + private List list; + private Set set; + private Map map; + + public PojoGenerics() { + } + + public PojoGenerics(List list) { + this.list = list; + } + + public PojoGenerics(Set set) { + this.set = set; + } + + public PojoGenerics(Map map) { + this.map = map; + } + + public List getList() { + return list; + } + + public void setList(List list) { + this.list = list; + } + + public Set getSet() { + return set; + } + + public void setSet(Set set) { + this.set = set; + } + + public Map getMap() { + return map; + } + + public void setMap(Map map) { + this.map = map; + } + + public void start() { + System.out.println("Starting component " + this); + } + + public void stop() { + System.out.println("Stopping component " + this); + } +} Propchange: geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/pojos/PojoGenerics.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/pojos/PojoGenerics.java ------------------------------------------------------------------------------ svn:keywords = Date Revision Propchange: geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/pojos/PojoGenerics.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: geronimo/sandbox/blueprint/blueprint-core/src/test/resources/test-generics.xml URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/test/resources/test-generics.xml?rev=773384&view=auto ============================================================================== --- geronimo/sandbox/blueprint/blueprint-core/src/test/resources/test-generics.xml (added) +++ geronimo/sandbox/blueprint/blueprint-core/src/test/resources/test-generics.xml Sun May 10 18:36:26 2009 @@ -0,0 +1,70 @@ + + + + + + + 10 + 20 + 50 + + + + + 1000 + 2000 + 5000 + + + + + + + + 5 + true + + + + + + + + + 10 + 20 + 50 + + + + + + + + 1000 + 2000 + 5000 + + + + + + + + + + + 5 + true + + + + + + + Propchange: geronimo/sandbox/blueprint/blueprint-core/src/test/resources/test-generics.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/sandbox/blueprint/blueprint-core/src/test/resources/test-generics.xml ------------------------------------------------------------------------------ svn:keywords = Date Revision Propchange: geronimo/sandbox/blueprint/blueprint-core/src/test/resources/test-generics.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml