use of jodd.petite.meta.PetiteInitMethod in project jodd by oblac.
the class InjectorsManager method createInjectors.
@PetiteInitMethod(order = 1, invoke = POST_DEFINE)
void createInjectors() {
requestScopeInjector = new RequestScopeInjector(madvocConfig, scopeDataResolver);
sessionScopeInjector = new SessionScopeInjector(scopeDataResolver);
actionPathMacroInjector = new ActionPathMacroInjector(scopeDataResolver);
madvocContextScopeInjector = new MadvocContextScopeInjector(scopeDataResolver, madpc);
madvocParamsInjector = new MadvocParamsInjector(madvocConfig);
applicationScopeInjector = new ApplicationScopeInjector(scopeDataResolver);
servletContextScopeInjector = new ServletContextScopeInjector(scopeDataResolver);
}
use of jodd.petite.meta.PetiteInitMethod in project jodd by oblac.
the class InitMethodResolver method resolve.
public InitMethodPoint[] resolve(Object bean) {
Class<?> type = bean.getClass();
// lookup methods
List<InitMethodPoint> list = new ArrayList<>();
ClassDescriptor cd = new ClassDescriptor(type, false, false, false, null);
MethodDescriptor[] allMethods = cd.getAllMethodDescriptors();
for (MethodDescriptor methodDescriptor : allMethods) {
Method method = methodDescriptor.getMethod();
PetiteInitMethod petiteInitMethod = method.getAnnotation(PetiteInitMethod.class);
if (petiteInitMethod == null) {
continue;
}
if (method.getParameterTypes().length > 0) {
throw new PetiteException("Arguments are not allowed for Petite init method: " + type.getName() + '#' + method.getName());
}
int order = petiteInitMethod.order();
list.add(new InitMethodPoint(method, order, petiteInitMethod.invoke()));
}
InitMethodPoint[] methods;
if (list.isEmpty()) {
methods = InitMethodPoint.EMPTY;
} else {
Collections.sort(list);
methods = list.toArray(new InitMethodPoint[list.size()]);
}
return methods;
}
Aggregations