Commit 6d8123da authored by Lionel Seinturier's avatar Lionel Seinturier

Split the Util class in different Helper classes with more relevant names.

parent e24f9032
...@@ -40,9 +40,9 @@ import org.objectweb.fractal.julia.ComponentInterface; ...@@ -40,9 +40,9 @@ import org.objectweb.fractal.julia.ComponentInterface;
import org.objectweb.fractal.julia.Controller; import org.objectweb.fractal.julia.Controller;
import org.objectweb.fractal.julia.InitializationContext; import org.objectweb.fractal.julia.InitializationContext;
import org.objectweb.fractal.juliac.ipf.AnnotatedElementFilter; import org.objectweb.fractal.juliac.ipf.AnnotatedElementFilter;
import org.objectweb.fractal.juliac.ipf.ClassHelper;
import org.objectweb.fractal.juliac.ipf.Filter; import org.objectweb.fractal.juliac.ipf.Filter;
import org.objectweb.fractal.juliac.ipf.Filters; import org.objectweb.fractal.juliac.ipf.Filters;
import org.objectweb.fractal.juliac.ipf.Util;
import org.objectweb.fractal.juliac.runtime.ClassLoaderFcItf; import org.objectweb.fractal.juliac.runtime.ClassLoaderFcItf;
import org.objectweb.fractal.juliac.runtime.ClassLoaderItf; import org.objectweb.fractal.juliac.runtime.ClassLoaderItf;
import org.objectweb.fractal.juliac.runtime.Juliac; import org.objectweb.fractal.juliac.runtime.Juliac;
...@@ -158,7 +158,7 @@ implements Controller, SCAIntentController { ...@@ -158,7 +158,7 @@ implements Controller, SCAIntentController {
List<Method> ret = new ArrayList<Method>(); List<Method> ret = new ArrayList<Method>();
// Retrieve all methods annotated with annotcl // Retrieve all methods annotated with annotcl
Method[] methods = Util.getAllMethods(cl); Method[] methods = ClassHelper.getAllMethods(cl);
Filter<AnnotatedElement> filter = Filter<AnnotatedElement> filter =
new AnnotatedElementFilter(annotcl.getName()); new AnnotatedElementFilter(annotcl.getName());
Method[] ms = Filters.filter(methods,filter); Method[] ms = Filters.filter(methods,filter);
......
...@@ -37,7 +37,7 @@ import org.objectweb.fractal.juliac.conf.JuliacConfig; ...@@ -37,7 +37,7 @@ import org.objectweb.fractal.juliac.conf.JuliacConfig;
import org.objectweb.fractal.juliac.conf.JulietLoader; import org.objectweb.fractal.juliac.conf.JulietLoader;
import org.objectweb.fractal.juliac.desc.MembraneDesc; import org.objectweb.fractal.juliac.desc.MembraneDesc;
import org.objectweb.fractal.juliac.desc.NoSuchControllerDescriptorException; import org.objectweb.fractal.juliac.desc.NoSuchControllerDescriptorException;
import org.objectweb.fractal.juliac.ipf.Util; import org.objectweb.fractal.juliac.ipf.AnnotationHelper;
import org.objectweb.fractal.juliac.proxy.InterfaceImplementationClassGenerator; import org.objectweb.fractal.juliac.proxy.InterfaceImplementationClassGenerator;
import org.objectweb.fractal.juliac.proxy.ProxyClassGeneratorItf; import org.objectweb.fractal.juliac.proxy.ProxyClassGeneratorItf;
import org.objectweb.fractal.juliac.ucf.UnifiedClass; import org.objectweb.fractal.juliac.ucf.UnifiedClass;
...@@ -212,7 +212,7 @@ extends org.objectweb.fractal.juliac.opt.comp.FCCompCtrlSourceCodeGenerator { ...@@ -212,7 +212,7 @@ extends org.objectweb.fractal.juliac.opt.comp.FCCompCtrlSourceCodeGenerator {
"org.oasisopen.sca.annotation.Callback", "org.oasisopen.sca.annotation.Callback",
"org.osoa.sca.annotations.Callback"); "org.osoa.sca.annotations.Callback");
if( annot != null ) { if( annot != null ) {
Class<?> cbcl = Util.getAnnotationParamValue(annot,"value"); Class<?> cbcl = AnnotationHelper.getAnnotationParamValue(annot,"value");
InterfaceType cbit = InterfaceType cbit =
new BasicInterfaceType( new BasicInterfaceType(
"callback", cbcl.getName(), false, false, false ); "callback", cbcl.getName(), false, false, false );
......
...@@ -48,15 +48,18 @@ import org.objectweb.fractal.fraclet.annotations.Lifecycle; ...@@ -48,15 +48,18 @@ import org.objectweb.fractal.fraclet.annotations.Lifecycle;
import org.objectweb.fractal.fraclet.annotations.Requires; import org.objectweb.fractal.fraclet.annotations.Requires;
import org.objectweb.fractal.fraclet.extensions.Controller; import org.objectweb.fractal.fraclet.extensions.Controller;
import org.objectweb.fractal.fraclet.types.Step; import org.objectweb.fractal.fraclet.types.Step;
import org.objectweb.fractal.juliac.ipf.AccessibleObjectHelper;
import org.objectweb.fractal.juliac.ipf.AnnotatedElementFilter; import org.objectweb.fractal.juliac.ipf.AnnotatedElementFilter;
import org.objectweb.fractal.juliac.ipf.AnnotationHelper;
import org.objectweb.fractal.juliac.ipf.ClassHelper;
import org.objectweb.fractal.juliac.ipf.CompositeInjectionPointHashMap;
import org.objectweb.fractal.juliac.ipf.CompositeOrFilter; import org.objectweb.fractal.juliac.ipf.CompositeOrFilter;
import org.objectweb.fractal.juliac.ipf.DuplicationInjectionPointException; import org.objectweb.fractal.juliac.ipf.DuplicationInjectionPointException;
import org.objectweb.fractal.juliac.ipf.Filter; import org.objectweb.fractal.juliac.ipf.Filter;
import org.objectweb.fractal.juliac.ipf.Filters; import org.objectweb.fractal.juliac.ipf.Filters;
import org.objectweb.fractal.juliac.ipf.InjectionPoint; import org.objectweb.fractal.juliac.ipf.InjectionPoint;
import org.objectweb.fractal.juliac.ipf.InjectionPointImpl; import org.objectweb.fractal.juliac.ipf.InjectionPointImpl;
import org.objectweb.fractal.juliac.ipf.CompositeInjectionPointHashMap; import org.objectweb.fractal.juliac.ipf.MethodHelper;
import org.objectweb.fractal.juliac.ipf.Util;
import org.osoa.sca.annotations.ConversationAttributes; import org.osoa.sca.annotations.ConversationAttributes;
import org.osoa.sca.annotations.ConversationID; import org.osoa.sca.annotations.ConversationID;
import org.ow2.frascati.tinfi.annotations.Provides; import org.ow2.frascati.tinfi.annotations.Provides;
...@@ -197,17 +200,17 @@ public class ContentClassMetaData { ...@@ -197,17 +200,17 @@ public class ContentClassMetaData {
* Retrieve the scope policy of the content class. * Retrieve the scope policy of the content class.
*/ */
Annotation scopeAnnot = Annotation scopeAnnot =
Util.getAnnotation( ClassHelper.getAnnotation(
fcContentClass, fcContentClass,
Scope.class.getName(), Scope.class.getName(),
"org.osoa.sca.annotations.Scope"); "org.osoa.sca.annotations.Scope");
scope = Util.getAnnotationParamValue(scopeAnnot,"value"); scope = AnnotationHelper.getAnnotationParamValue(scopeAnnot,"value");
/* /*
* Retrieve the scope eager init policy of the content class, if any. * Retrieve the scope eager init policy of the content class, if any.
*/ */
eagerinit = eagerinit =
Util.isAnnotationPresent( ClassHelper.isAnnotationPresent(
fcContentClass, fcContentClass,
EagerInit.class.getName(), EagerInit.class.getName(),
"org.osoa.sca.annotations.EagerInit"); "org.osoa.sca.annotations.EagerInit");
...@@ -224,14 +227,14 @@ public class ContentClassMetaData { ...@@ -224,14 +227,14 @@ public class ContentClassMetaData {
* Retrieve the conversation attributes of the content class. * Retrieve the conversation attributes of the content class.
*/ */
Annotation convAttrAnnot = Annotation convAttrAnnot =
Util.getAnnotation( ClassHelper.getAnnotation(
fcContentClass, ConversationAttributes.class.getName() ); fcContentClass, ConversationAttributes.class.getName() );
convattr = convAttrAnnot != null; convattr = convAttrAnnot != null;
if(convattr) { if(convattr) {
String ma = Util.getAnnotationParamValue(convAttrAnnot,"maxAge"); String ma = AnnotationHelper.getAnnotationParamValue(convAttrAnnot,"maxAge");
convMaxAge = convDurationToMilli(ma); convMaxAge = convDurationToMilli(ma);
String mit = String mit =
Util.getAnnotationParamValue(convAttrAnnot,"maxIdleTime"); AnnotationHelper.getAnnotationParamValue(convAttrAnnot,"maxIdleTime");
convMaxIdleTime = convDurationToMilli(mit); convMaxIdleTime = convDurationToMilli(mit);
} }
...@@ -257,10 +260,10 @@ public class ContentClassMetaData { ...@@ -257,10 +260,10 @@ public class ContentClassMetaData {
* Retrieve the method annotated with @Provides, if any. * Retrieve the method annotated with @Provides, if any.
* Check that only one such method exists. * Check that only one such method exists.
*/ */
Method[] methods = Util.getAllMethods(fcContentClass); Method[] methods = ClassHelper.getAllMethods(fcContentClass);
filter = new AnnotatedElementFilter(Provides.class.getName()); filter = new AnnotatedElementFilter(Provides.class.getName());
Method[] provides = Filters.filter(methods,filter); Method[] provides = Filters.filter(methods,filter);
provides = Util.removeOverridden(provides); provides = MethodHelper.removeOverridden(provides);
providesMethod = providesMethod =
checkUniqueAnnotatedFactoryMethod( checkUniqueAnnotatedFactoryMethod(
provides, Provides.class.getName() ); provides, Provides.class.getName() );
...@@ -276,7 +279,7 @@ public class ContentClassMetaData { ...@@ -276,7 +279,7 @@ public class ContentClassMetaData {
"org.osoa.sca.annotations.Init"), "org.osoa.sca.annotations.Init"),
new LifecycleAnnotatedElementFilter(Step.CREATE) ); new LifecycleAnnotatedElementFilter(Step.CREATE) );
Method[] inits = Filters.filter(methods,filter); Method[] inits = Filters.filter(methods,filter);
inits = Util.removeOverridden(inits); inits = MethodHelper.removeOverridden(inits);
initMethod = initMethod =
checkUniqueAnnotatedVoidMethod( checkUniqueAnnotatedVoidMethod(
inits, inits,
...@@ -295,7 +298,7 @@ public class ContentClassMetaData { ...@@ -295,7 +298,7 @@ public class ContentClassMetaData {
"org.osoa.sca.annotations.Destroy"), "org.osoa.sca.annotations.Destroy"),
new LifecycleAnnotatedElementFilter(Step.DESTROY) ); new LifecycleAnnotatedElementFilter(Step.DESTROY) );
Method[] destroys = Filters.filter(methods,filter); Method[] destroys = Filters.filter(methods,filter);
destroys = Util.removeOverridden(destroys); destroys = MethodHelper.removeOverridden(destroys);
destroyMethod = destroyMethod =
checkUniqueAnnotatedVoidMethod( checkUniqueAnnotatedVoidMethod(
destroys, destroys,
...@@ -310,7 +313,7 @@ public class ContentClassMetaData { ...@@ -310,7 +313,7 @@ public class ContentClassMetaData {
*/ */
filter = new LifecycleAnnotatedElementFilter(Step.START); filter = new LifecycleAnnotatedElementFilter(Step.START);
Method[] starts = Filters.filter(methods,filter); Method[] starts = Filters.filter(methods,filter);
starts = Util.removeOverridden(starts); starts = MethodHelper.removeOverridden(starts);
startMethod = startMethod =
checkUniqueAnnotatedVoidMethod( checkUniqueAnnotatedVoidMethod(
starts, starts,
...@@ -323,7 +326,7 @@ public class ContentClassMetaData { ...@@ -323,7 +326,7 @@ public class ContentClassMetaData {
*/ */
filter = new LifecycleAnnotatedElementFilter(Step.STOP); filter = new LifecycleAnnotatedElementFilter(Step.STOP);
Method[] stops = Filters.filter(methods,filter); Method[] stops = Filters.filter(methods,filter);
stops = Util.removeOverridden(stops); stops = MethodHelper.removeOverridden(stops);
stopMethod = stopMethod =
checkUniqueAnnotatedVoidMethod( checkUniqueAnnotatedVoidMethod(
stops, stops,
...@@ -334,12 +337,12 @@ public class ContentClassMetaData { ...@@ -334,12 +337,12 @@ public class ContentClassMetaData {
* Check that only one such element exists. * Check that only one such element exists.
*/ */
AccessibleObject[] aos = AccessibleObject[] aos =
Util.getAllAnnotatedSettersAndFields( ClassHelper.getAllAnnotatedSettersAndFields(
fcContentClass, Controller.class.getName() ); fcContentClass, Controller.class.getName() );
controllerAnnotatedElements = new InjectionPoint[ aos.length ]; controllerAnnotatedElements = new InjectionPoint[ aos.length ];
for (int i = 0; i < aos.length; i++) { for (int i = 0; i < aos.length; i++) {
Annotation annot = Annotation annot =
Util.getAnnotation( aos[i], Controller.class.getName() ); AccessibleObjectHelper.getAnnotation( aos[i], Controller.class.getName() );
controllerAnnotatedElements[i] = controllerAnnotatedElements[i] =
InjectionPointImpl.getInjectionPoint(aos[i],annot); InjectionPointImpl.getInjectionPoint(aos[i],annot);
} }
...@@ -407,20 +410,20 @@ public class ContentClassMetaData { ...@@ -407,20 +410,20 @@ public class ContentClassMetaData {
/* /*
* Retrieve the unannotated setter methods. * Retrieve the unannotated setter methods.
*/ */
setters = Util.getAllUnAnnotatedSetterMethods(fcContentClass); setters = ClassHelper.getAllUnAnnotatedSetterMethods(fcContentClass);
/* /*
* Retrieve the callbacks declared in the content class. * Retrieve the callbacks declared in the content class.
*/ */
aos = aos =
Util.getAllAnnotatedSettersAndFields( ClassHelper.getAllAnnotatedSettersAndFields(
fcContentClass, fcContentClass,
Callback.class.getName(), Callback.class.getName(),
"org.osoa.sca.annotations.Callback"); "org.osoa.sca.annotations.Callback");
callbacks = new InjectionPoint[ aos.length ]; callbacks = new InjectionPoint[ aos.length ];
for (int i = 0; i < aos.length; i++) { for (int i = 0; i < aos.length; i++) {
Annotation annot = Annotation annot =
Util.getAnnotation( AccessibleObjectHelper.getAnnotation(
aos[i], aos[i],
Callback.class.getName(), Callback.class.getName(),
"org.osoa.sca.annotations.Callback"); "org.osoa.sca.annotations.Callback");
...@@ -452,9 +455,9 @@ public class ContentClassMetaData { ...@@ -452,9 +455,9 @@ public class ContentClassMetaData {
throws IllegalContentClassMetaData { throws IllegalContentClassMetaData {
AccessibleObject[] aos = AccessibleObject[] aos =
Util.getAllAnnotatedSettersAndFields( ClassHelper.getAllAnnotatedSettersAndFields(
fcContentClass,annotClassNames); fcContentClass,annotClassNames);
aos = Util.removeOverridden(aos); aos = AccessibleObjectHelper.removeOverridden(aos);
if( aos.length == 0 ) { if( aos.length == 0 ) {
return null; return null;
......
...@@ -47,10 +47,10 @@ import org.objectweb.fractal.api.type.InterfaceType; ...@@ -47,10 +47,10 @@ import org.objectweb.fractal.api.type.InterfaceType;
import org.objectweb.fractal.fraclet.types.Contingency; import org.objectweb.fractal.fraclet.types.Contingency;
import org.objectweb.fractal.julia.ComponentInterface; import org.objectweb.fractal.julia.ComponentInterface;
import org.objectweb.fractal.julia.Interceptor; import org.objectweb.fractal.julia.Interceptor;
import org.objectweb.fractal.juliac.ipf.AnnotationHelper;
import org.objectweb.fractal.juliac.ipf.InjectionPoint; import org.objectweb.fractal.juliac.ipf.InjectionPoint;
import org.objectweb.fractal.juliac.ipf.InjectionPointFieldImpl; import org.objectweb.fractal.juliac.ipf.InjectionPointFieldImpl;
import org.objectweb.fractal.juliac.ipf.SetterMethodFilter; import org.objectweb.fractal.juliac.ipf.SetterMethodFilter;
import org.objectweb.fractal.juliac.ipf.Util;
import org.ow2.frascati.tinfi.CallbackManager; import org.ow2.frascati.tinfi.CallbackManager;
import org.ow2.frascati.tinfi.TinfiComponentOutInterface; import org.ow2.frascati.tinfi.TinfiComponentOutInterface;
import org.ow2.frascati.tinfi.TinfiRuntimeException; import org.ow2.frascati.tinfi.TinfiRuntimeException;
...@@ -235,7 +235,7 @@ public abstract class AbstractScopeManager implements ScopeManager { ...@@ -235,7 +235,7 @@ public abstract class AbstractScopeManager implements ScopeManager {
for (InjectionPoint<Annotation> ip : ccmd.controllerAnnotatedElements) { for (InjectionPoint<Annotation> ip : ccmd.controllerAnnotatedElements) {
Annotation annot = ip.getAnnotation(); Annotation annot = ip.getAnnotation();
String name = Util.getAnnotationParamValue(annot,"name"); String name = AnnotationHelper.getAnnotationParamValue(annot,"name");
/* /*
* Do not try to optimize by taking the value of the comp field when * Do not try to optimize by taking the value of the comp field when
...@@ -434,7 +434,7 @@ public abstract class AbstractScopeManager implements ScopeManager { ...@@ -434,7 +434,7 @@ public abstract class AbstractScopeManager implements ScopeManager {
InjectionPoint<Annotation> ip = ccmd.props.get(name); InjectionPoint<Annotation> ip = ccmd.props.get(name);
Annotation annot = ip.getAnnotation(); Annotation annot = ip.getAnnotation();
boolean isRequired = // <Boolean> for compilation with javac boolean isRequired = // <Boolean> for compilation with javac
Util.<Boolean>getAnnotationParamValue(annot,"required"); AnnotationHelper.<Boolean>getAnnotationParamValue(annot,"required");
if(isRequired) { if(isRequired) {
NameController nc = NameController nc =
(NameController) comp.getFcInterface("name-controller"); (NameController) comp.getFcInterface("name-controller");
...@@ -489,7 +489,7 @@ public abstract class AbstractScopeManager implements ScopeManager { ...@@ -489,7 +489,7 @@ public abstract class AbstractScopeManager implements ScopeManager {
boolean isRequired = false; boolean isRequired = false;
try { try {
isRequired = // <Boolean> for compilation with javac isRequired = // <Boolean> for compilation with javac
Util.<Boolean>getAnnotationParamValue(annot,"required"); AnnotationHelper.<Boolean>getAnnotationParamValue(annot,"required");
} }
catch( NullPointerException npe ) { catch( NullPointerException npe ) {
/* /*
...@@ -500,14 +500,14 @@ public abstract class AbstractScopeManager implements ScopeManager { ...@@ -500,14 +500,14 @@ public abstract class AbstractScopeManager implements ScopeManager {
* parameter. * parameter.
*/ */
Contingency contingency = Contingency contingency =
Util.getAnnotationParamValue(annot,"contingency"); AnnotationHelper.getAnnotationParamValue(annot,"contingency");
if( contingency == null ) { if( contingency == null ) {
/* /*
* Shouldn't occur. The annotation is either SCA style with a * Shouldn't occur. The annotation is either SCA style with a
* required parameter or Fraclet style with a contingency * required parameter or Fraclet style with a contingency
* parameter. * parameter.
*/ */
String msg = final String msg =
"required or contingency parameter expected on annotation "+ "required or contingency parameter expected on annotation "+
annot; annot;
throw new TinfiRuntimeException(msg); throw new TinfiRuntimeException(msg);
...@@ -528,7 +528,7 @@ public abstract class AbstractScopeManager implements ScopeManager { ...@@ -528,7 +528,7 @@ public abstract class AbstractScopeManager implements ScopeManager {
* consists in leaving fcname as null. * consists in leaving fcname as null.
*/ */
} }
String msg = final String msg =
"Mandatory reference " + name + " in component " + fcname + "Mandatory reference " + name + " in component " + fcname +
"should have been set"; "should have been set";
throw new ContentInstantiationException(msg); throw new ContentInstantiationException(msg);
......
Markdown is supported
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