From 5ab991154d264f110dd9d74fd7ebc0a7801a9bf9 Mon Sep 17 00:00:00 2001 From: antelder Date: Thu, 15 Oct 2009 20:14:13 +0000 Subject: Fix SCAJ CAA JCA_10048 - an implementation class must implement all methods on all its service interfaces git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@825629 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/introspect/impl/ServiceProcessor.java | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'java') diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceProcessor.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceProcessor.java index ec7507f97e..e74fa8c537 100644 --- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceProcessor.java +++ b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceProcessor.java @@ -20,6 +20,7 @@ package org.apache.tuscany.sca.implementation.java.introspect.impl; import static org.apache.tuscany.sca.implementation.java.introspect.JavaIntrospectionHelper.getAllInterfaces; +import java.lang.annotation.Annotation; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.lang.reflect.Modifier; @@ -100,6 +101,16 @@ public class ServiceProcessor extends BaseJavaClassVisitor { throw new IntrospectionException("JCA90060 The value of each element in the @Service names array MUST be unique amongst all the other element values in the array"); } } + + //validate service methods implemented + Method[] ms = clazz.getMethods(); + for (Class iface : interfaces) { + for (Method m : iface.getMethods()) { + if (!hasMethod(m, ms)) { + throw new IntrospectionException("JCA???? Implementation missing service method " + m.getName() + " service interface " + iface.getName()); + } + } + } for (int i=0; i < interfaces.length; i++) { try { @@ -114,6 +125,15 @@ public class ServiceProcessor extends BaseJavaClassVisitor { } } + protected boolean hasMethod(Method m1, Method[] ms) { + for (Method m2 : ms) { + if (JavaIntrospectionHelper.exactMethodMatch(m1, m2)) { + return true; + } + } + return false; + } + @Override public void visitMethod(Method method, JavaImplementation type) throws IntrospectionException { -- cgit v1.2.3