[jboss-cvs] JBossAS SVN: r81218 - in projects/ejb3/trunk/interceptors/src: test/java/org/jboss/ejb3/interceptors/test and 5 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Nov 18 07:53:11 EST 2008
Author: wolfc
Date: 2008-11-18 07:53:10 -0500 (Tue, 18 Nov 2008)
New Revision: 81218
Added:
projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree1595/
projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree1595/XMLMethodInterceptor.java
projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree1595/XMLOnlySLSB.java
projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree1595/XMLOnlySLSBLocal.java
projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree1595/unit/
projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree1595/unit/ParameterSignatureTestCase.java
projects/ejb3/trunk/interceptors/src/test/resources/ejbthree1595/
projects/ejb3/trunk/interceptors/src/test/resources/ejbthree1595/META-INF/
projects/ejb3/trunk/interceptors/src/test/resources/ejbthree1595/META-INF/ejb-jar.xml
Modified:
projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/metadata/BeanInterceptorMetaDataBridge.java
Log:
EJBTHREE-1595: matching on canonical class name
Modified: projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/metadata/BeanInterceptorMetaDataBridge.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/metadata/BeanInterceptorMetaDataBridge.java 2008-11-18 11:49:54 UTC (rev 81217)
+++ projects/ejb3/trunk/interceptors/src/main/java/org/jboss/ejb3/interceptors/metadata/BeanInterceptorMetaDataBridge.java 2008-11-18 12:53:10 UTC (rev 81218)
@@ -145,7 +145,7 @@
* @param refMethod
* @return the binding or null
*/
- private static InterceptorBindingMetaData findBestMatch(List<InterceptorBindingMetaData> bindings, DeclaredMethodSignature refMethod)
+ private InterceptorBindingMetaData findBestMatch(List<InterceptorBindingMetaData> bindings, DeclaredMethodSignature refMethod)
{
for (InterceptorBindingMetaData binding : bindings)
{
@@ -540,13 +540,17 @@
}
}
- private static boolean matches(DeclaredMethodSignature signature, NamedMethodMetaData method)
+ private boolean matches(DeclaredMethodSignature signature, NamedMethodMetaData method)
{
if(!signature.getName().equals(method.getMethodName()))
return false;
if(method.getMethodParams() == null)
return true;
- return Arrays.equals(signature.getParameters(), method.getMethodParams().toArray());
+ Class<?> parameterTypes[] = signature.getParametersTypes(beanClass);
+ String parameters[] = new String[parameterTypes.length];
+ for(int i = 0; i < parameters.length; i++)
+ parameters[i] = parameterTypes[i].getCanonicalName();
+ return Arrays.equals(parameters, method.getMethodParams().toArray());
}
@Override
Added: projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree1595/XMLMethodInterceptor.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree1595/XMLMethodInterceptor.java (rev 0)
+++ projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree1595/XMLMethodInterceptor.java 2008-11-18 12:53:10 UTC (rev 81218)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.
+ */
+package org.jboss.ejb3.interceptors.test.ejbthree1595;
+
+import javax.interceptor.InvocationContext;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class XMLMethodInterceptor
+{
+ public Object intercept(InvocationContext ctx) throws Exception
+ {
+ return (Long) ctx.proceed() + 1;
+ }
+}
Added: projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree1595/XMLOnlySLSB.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree1595/XMLOnlySLSB.java (rev 0)
+++ projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree1595/XMLOnlySLSB.java 2008-11-18 12:53:10 UTC (rev 81218)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.
+ */
+package org.jboss.ejb3.interceptors.test.ejbthree1595;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class XMLOnlySLSB implements XMLOnlySLSBLocal
+{
+ public long overloadedMethod(long l, String[][] s)
+ {
+ return l + 1;
+ }
+}
Added: projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree1595/XMLOnlySLSBLocal.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree1595/XMLOnlySLSBLocal.java (rev 0)
+++ projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree1595/XMLOnlySLSBLocal.java 2008-11-18 12:53:10 UTC (rev 81218)
@@ -0,0 +1,31 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.
+ */
+package org.jboss.ejb3.interceptors.test.ejbthree1595;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public interface XMLOnlySLSBLocal
+{
+ long overloadedMethod(long l, String[][] s);
+}
Added: projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree1595/unit/ParameterSignatureTestCase.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree1595/unit/ParameterSignatureTestCase.java (rev 0)
+++ projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree1595/unit/ParameterSignatureTestCase.java 2008-11-18 12:53:10 UTC (rev 81218)
@@ -0,0 +1,122 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.
+ */
+package org.jboss.ejb3.interceptors.test.ejbthree1595.unit;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.net.URL;
+
+import org.jboss.aspects.common.AOPDeployer;
+import org.jboss.ejb3.interceptors.container.BeanContext;
+import org.jboss.ejb3.interceptors.test.common.ManagedObjectContainer;
+import org.jboss.ejb3.interceptors.test.ejbthree1595.XMLOnlySLSB;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.ejb.jboss.JBoss50MetaData;
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
+import org.jboss.metadata.ejb.spec.EjbJar30MetaData;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBindingResolver;
+import org.jboss.xb.builder.JBossXBBuilder;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.w3c.dom.ls.LSInput;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class ParameterSignatureTestCase
+{
+ private static final Logger log = Logger.getLogger(ParameterSignatureTestCase.class);
+
+ private static final AOPDeployer deployer = new AOPDeployer("proxy/jboss-aop.xml");
+ private JBossEnterpriseBeanMetaData beanMetaData;
+
+ protected static SchemaBindingResolver schemaResolverForClass(final Class<?> root)
+ {
+ return new SchemaBindingResolver()
+ {
+ public String getBaseURI()
+ {
+ return null;
+ }
+
+ public SchemaBinding resolve(String nsUri, String baseURI, String schemaLocation)
+ {
+ return JBossXBBuilder.build(root);
+ }
+
+ public LSInput resolveAsLSInput(String nsUri, String baseUri, String schemaLocation)
+ {
+ return null;
+ }
+
+ public void setBaseURI(String baseURI)
+ {
+ }
+ };
+ }
+
+ @AfterClass
+ public static void afterClass() throws Exception
+ {
+ log.info(deployer.undeploy());
+ }
+
+ @Before
+ public void before() throws Exception
+ {
+ // Bootstrap metadata
+ UnmarshallerFactory unmarshallerFactory = UnmarshallerFactory.newInstance();
+ Unmarshaller unmarshaller = unmarshallerFactory.newUnmarshaller();
+ URL url = Thread.currentThread().getContextClassLoader().getResource("ejbthree1595/META-INF/ejb-jar.xml");
+ assertNotNull("Can't find descriptor ejbthree1595/META-INF/ejb-jar.xml", url);
+ EjbJar30MetaData metaData = (EjbJar30MetaData) unmarshaller.unmarshal(url.toString(), schemaResolverForClass(EjbJar30MetaData.class));
+ JBoss50MetaData jbossMetaData = new JBoss50MetaData();
+ jbossMetaData.merge(null, metaData);
+
+ beanMetaData = jbossMetaData.getEnterpriseBean("XMLOnlySLSB");
+ assertNotNull(beanMetaData);
+ }
+
+ @BeforeClass
+ public static void beforeClass() throws Exception
+ {
+ log.info(deployer.deploy());
+ }
+
+ @Test
+ public void test1() throws Throwable
+ {
+ ManagedObjectContainer<XMLOnlySLSB> container = new ManagedObjectContainer<XMLOnlySLSB>(beanMetaData.getEjbName(), "Test", XMLOnlySLSB.class, beanMetaData);
+
+ BeanContext<XMLOnlySLSB> bean = container.construct();
+
+ Long actual = container.invoke(bean, "overloadedMethod", 1L, new String[][] {{"Hello"}, {"Whatever"}});
+ assertEquals((Long) 3L, actual);
+ }
+}
Added: projects/ejb3/trunk/interceptors/src/test/resources/ejbthree1595/META-INF/ejb-jar.xml
===================================================================
--- projects/ejb3/trunk/interceptors/src/test/resources/ejbthree1595/META-INF/ejb-jar.xml (rev 0)
+++ projects/ejb3/trunk/interceptors/src/test/resources/ejbthree1595/META-INF/ejb-jar.xml 2008-11-18 12:53:10 UTC (rev 81218)
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ejb-jar
+ xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+ http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
+ version="3.0">
+ <display-name>ParameterSignatureTest</display-name>
+ <enterprise-beans>
+ <session>
+ <ejb-name>XMLOnlySLSB</ejb-name>
+ <business-local>org.jboss.ejb3.interceptors.test.ejbthree1595.XMLOnlySLSBLocal</business-local>
+ <ejb-class>org.jboss.ejb3.interceptors.test.ejbthree1595.XMLOnlySLSB</ejb-class>
+ <session-type>Stateless</session-type>
+ </session>
+ </enterprise-beans>
+ <interceptors>
+ <interceptor>
+ <interceptor-class>org.jboss.ejb3.interceptors.test.ejbthree1595.XMLMethodInterceptor</interceptor-class>
+ <around-invoke>
+ <method-name>intercept</method-name>
+ </around-invoke>
+ </interceptor>
+ </interceptors>
+ <assembly-descriptor>
+ <interceptor-binding>
+ <ejb-name>XMLOnlySLSB</ejb-name>
+ <interceptor-class>org.jboss.ejb3.interceptors.test.ejbthree1595.XMLMethodInterceptor</interceptor-class>
+ <method>
+ <method-name>overloadedMethod</method-name>
+ <method-params>
+ <method-param>long</method-param>
+ <method-param>java.lang.String[][]</method-param>
+ </method-params>
+ </method>
+ </interceptor-binding>
+ </assembly-descriptor>
+</ejb-jar>
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list