Commit 3c02cd30 authored by Philippe Merle's avatar Philippe Merle
Browse files

Retrieved @Service from an implementation class but also from all super classes.

Removed a TODO into examples/runners.
parent 6cbeb3ff
......@@ -34,7 +34,6 @@ import org.oasisopen.sca.annotation.Init;
import org.oasisopen.sca.annotation.Service;
import org.oasisopen.sca.annotation.Reference;
@Service(Runnable.class) // TODO: This annotation should be removed as already defined into class Runner.
public class RunnerMultiple extends Runner
{
/**
......
/**
* OW2 FraSCAti: SCA Parser
* Copyright (C) 2008-2011 INRIA, University of Lille 1
* Copyright (C) 2008-2013 Inria, University of Lille 1
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -14,7 +14,8 @@
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
* Contact: frascati@ow2.org
*
......@@ -26,6 +27,7 @@
package org.ow2.frascati.parser.resolver;
import java.lang.annotation.Annotation;
import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
......@@ -108,10 +110,9 @@ public class JavaInterfaceResolver
Map<String, String> annotatedServiceInterfaces = new HashMap<String, String>();
{
// Retrieve the OSOA service annotation.
org.osoa.sca.annotations.Service s = cMetaData.getAnnotation(org.osoa.sca.annotations.Service.class);
// If class is annotated with org.osoa.sca.annotations.Service
if (s != null) {
// Retrieve the OSOA service annotations.
for(org.osoa.sca.annotations.Service s :
getAllAnnotations(cMetaData.getSupportClass(), org.osoa.sca.annotations.Service.class)) {
if(s.interfaces().length > 0) {
if(s.value() != Void.class) {
parsingContext.warning("@" + org.osoa.sca.annotations.Service.class.getCanonicalName() +
......@@ -145,12 +146,11 @@ public class JavaInterfaceResolver
}
{
// Retrieve the OASIS service annotation.
org.oasisopen.sca.annotation.Service s = cMetaData.getAnnotation(org.oasisopen.sca.annotation.Service.class);
// If class is annotated with org.oasisopen.sca.annotation.Service
if (s != null) {
// Retrieve the OASIS service annotations.
for(org.oasisopen.sca.annotation.Service s :
getAllAnnotations(cMetaData.getSupportClass(), org.oasisopen.sca.annotation.Service.class)) {
// Add all interfaces of the @Service annotation.
int i = 0;
int i = 0;
for(Class<?> itf : s.value()) {
// Compute the service name.
String serviceName = null;
......@@ -389,6 +389,30 @@ public class JavaInterfaceResolver
return null;
}
/**
* Get all the annotations of a given annotation type for a given class.
* Recursively traverse super classes.
*
* @param clazz the given class.
* @param annotationType the given annotation type.
* @return all the annotations of the given annotation type for the given class.
*/
private static <ANNOTATION_TYPE extends Annotation>
List<ANNOTATION_TYPE> getAllAnnotations(
Class<?> clazz,
Class<ANNOTATION_TYPE> annotationType)
{
List<ANNOTATION_TYPE> annotations = new ArrayList<ANNOTATION_TYPE>();
while(clazz != Object.class) {
ANNOTATION_TYPE annotation = clazz.getAnnotation(annotationType);
if(annotation != null) {
annotations.add(annotation);
}
clazz = clazz.getSuperclass();
}
return annotations;
}
//---------------------------------------------------------------------------
// Public methods.
// --------------------------------------------------------------------------
......
......@@ -2,7 +2,7 @@
<!--
* OW2 FraSCAti
*
* Copyright (c) 2010-2012 Inria, University of Lille 1
* Copyright (c) 2010-2013 Inria, University of Lille 1
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -220,7 +220,9 @@
<module>maven-plugins</module>
<module>modules</module>
<module>frascati-test</module>
<!-- Currently deactivated because there are compilation issues into the frascati-starter module.
<module>osgi</module>
-->
<module>nuxeo</module>
<module>tools</module>
<!-- TODO
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment