Lucio Lelii 2017-10-06 13:21:32 +00:00
parent b95572fe28
commit 543f765d09
4 changed files with 225 additions and 223 deletions

View File

@ -11,7 +11,7 @@
<groupId>org.gcube.dataanalysis</groupId> <groupId>org.gcube.dataanalysis</groupId>
<artifactId>52n-wps-algorithm-gcube</artifactId> <artifactId>52n-wps-algorithm-gcube</artifactId>
<name>52North WPS Algorithm API modified for gcube</name> <name>52North WPS Algorithm API modified for gcube</name>
<version>3.6.1-SNAPSHOT</version> <version>3.6.2-SNAPSHOT</version>
<description>API for implementation of algorithms to be exposed as web processes</description> <description>API for implementation of algorithms to be exposed as web processes</description>
<licenses> <licenses>
@ -76,11 +76,6 @@
</plugins> </plugins>
</build> </build>
<dependencies> <dependencies>
<dependency>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.12.1.GA</version>
</dependency>
<dependency> <dependency>
<groupId>org.n52.wps</groupId> <groupId>org.n52.wps</groupId>
<artifactId>52n-wps-commons</artifactId> <artifactId>52n-wps-commons</artifactId>

View File

@ -29,11 +29,6 @@ import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javassist.ClassClassPath;
import javassist.ClassPool;
import javassist.CtClass;
import javassist.CtMethod;
import org.n52.wps.algorithm.annotation.AnnotationBinding.ExecuteMethodBinding; import org.n52.wps.algorithm.annotation.AnnotationBinding.ExecuteMethodBinding;
import org.n52.wps.algorithm.annotation.AnnotationBinding.InputBinding; import org.n52.wps.algorithm.annotation.AnnotationBinding.InputBinding;
import org.n52.wps.algorithm.annotation.AnnotationBinding.OutputBinding; import org.n52.wps.algorithm.annotation.AnnotationBinding.OutputBinding;
@ -155,19 +150,18 @@ public class AnnotatedAlgorithmIntrospector {
//MODIFICATIONS BY G CORO TO ACCOUNT FOR METHODS ORDER //MODIFICATIONS BY G CORO TO ACCOUNT FOR METHODS ORDER
List<Method> sortedMethods = new ArrayList<Method>(); List<Method> sortedMethods = new ArrayList<Method>();
List<Integer> methodsIdxs = new ArrayList<Integer>(); List<Integer> methodsIdxs = new ArrayList<Integer>();
List<Method> notOrderedMethod = new ArrayList<Method>();
try{ try{
for (Method m:algorithmClass.getDeclaredMethods()){ for (Method m:algorithmClass.getDeclaredMethods()){
//System.out.println("Javaassist Analysing method "+m.getName());
ClassPool pool = ClassPool.getDefault();
ClassClassPath ccpath = new ClassClassPath(m.getDeclaringClass());
pool.insertClassPath(ccpath);
//System.out.println("Javaassist searching for canonical name "+m.getDeclaringClass().getCanonicalName());
CtClass cc = pool.get(m.getDeclaringClass().getCanonicalName());
//System.out.println("Javaassist cc "+cc.getName());
CtMethod javassistMethod = cc.getDeclaredMethod(m.getName());
//System.out.println("Javaassist method "+javassistMethod.getName());
int linenumber = javassistMethod.getMethodInfo().getLineNumber(0);
if (!m.isAnnotationPresent(MethodOrder.class)){
LOGGER.warn("METHOD {} in not annotated with MethodOrder in class {}", m.getName(), algorithmClass.getSimpleName());
notOrderedMethod.add(m);
continue;
}
int linenumber = m.getAnnotation(MethodOrder.class).value();
//System.out.println("Javaassist line number "+linenumber); //System.out.println("Javaassist line number "+linenumber);
int i=0; int i=0;
for (Integer methodsIdx :methodsIdxs){ for (Integer methodsIdx :methodsIdxs){
@ -182,7 +176,7 @@ public class AnnotatedAlgorithmIntrospector {
}catch(Exception e){ }catch(Exception e){
LOGGER.warn("error getting method order",e); LOGGER.warn("error getting method order",e);
} }
sortedMethods.addAll(notOrderedMethod);
Method[] sMethods = sortedMethods.toArray(new Method[sortedMethods.size()]); Method[] sMethods = sortedMethods.toArray(new Method[sortedMethods.size()]);
algorithmBuilder = AlgorithmDescriptor.builder( algorithmBuilder = AlgorithmDescriptor.builder(

View File

@ -0,0 +1,13 @@
package org.n52.wps.algorithm.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface MethodOrder {
int value() default Integer.MAX_VALUE;
}