}
}
}
if (bean instanceof Session) {
final Session session = (Session) bean;
/*
* @AfterBegin
*/
final LifecycleCallback afterBegin = getFirst(session.getAfterBegin());
if (afterBegin == null) {
for (final Annotated<Method> method : sortMethods(annotationFinder.findMetaAnnotatedMethods(AfterBegin.class))) {
session.getAfterBegin().add(new LifecycleCallback(method.get()));
}
}
/*
* @BeforeCompletion
*/
final LifecycleCallback beforeCompletion = getFirst(session.getBeforeCompletion());
if (beforeCompletion == null) {
for (final Annotated<Method> method : sortMethods(annotationFinder.findMetaAnnotatedMethods(BeforeCompletion.class))) {
session.getBeforeCompletion().add(new LifecycleCallback(method.get()));
}
}
/*
* @AfterCompletion
*/
final LifecycleCallback afterCompletion = getFirst(session.getAfterCompletion());
if (afterCompletion == null) {
for (final Annotated<Method> method : sortMethods(annotationFinder.findMetaAnnotatedMethods(AfterCompletion.class))) {
session.getAfterCompletion().add(new LifecycleCallback(method.get()));
}
}
/*
* @PostActivate
*/
if (apply(override, session.getPostActivate())) {
for (final Annotated<Method> method : sortMethods(annotationFinder.findMetaAnnotatedMethods(PostActivate.class))) {
session.getPostActivate().add(new LifecycleCallback(method.get()));
}
}
/*
* @PrePassivate
*/
if (apply(override, session.getPrePassivate())) {
for (final Annotated<Method> method : sortMethods(annotationFinder.findMetaAnnotatedMethods(PrePassivate.class))) {
session.getPrePassivate().add(new LifecycleCallback(method.get()));
}
}
/*
* @Init
*/
for (final Annotated<Method> method : sortMethods(annotationFinder.findMetaAnnotatedMethods(Init.class))) {
final InitMethod initMethod = new InitMethod(method.get());
final Init init = method.getAnnotation(Init.class);
if (init.value() != null && !init.value().equals("")) {
initMethod.setCreateMethod(init.value());
}
session.getInitMethod().add(initMethod);
}
/*
* @Remove
*/
final List<Annotated<Method>> removeMethods = sortMethods(annotationFinder.findMetaAnnotatedMethods(Remove.class));
final Map<NamedMethod, RemoveMethod> declaredRemoveMethods = new HashMap<NamedMethod, RemoveMethod>();
for (final RemoveMethod removeMethod : session.getRemoveMethod()) {
declaredRemoveMethods.put(removeMethod.getBeanMethod(), removeMethod);
}
for (final Annotated<Method> method : removeMethods) {
final Remove remove = method.getAnnotation(Remove.class);
final RemoveMethod removeMethod = new RemoveMethod(method.get(), remove.retainIfException());
final RemoveMethod declaredRemoveMethod = declaredRemoveMethods.get(removeMethod.getBeanMethod());
if (declaredRemoveMethod == null) {
session.getRemoveMethod().add(removeMethod);
} else if (!declaredRemoveMethod.isExplicitlySet()) {
declaredRemoveMethod.setRetainIfException(remove.retainIfException());
}
}
}