/*
* @PostConstruct
*/
if (apply(override, bean.getPostConstruct())) {
for (final Annotated<Method> method : sortMethods(annotationFinder.findMetaAnnotatedMethods(PostConstruct.class))) {
bean.getPostConstruct().add(new LifecycleCallback(method.get()));
}
}
/*
* @PreDestroy
*/
if (apply(override, bean.getPreDestroy())) {
for (final Annotated<Method> method : sortMethods(annotationFinder.findMetaAnnotatedMethods(PreDestroy.class))) {
bean.getPreDestroy().add(new LifecycleCallback(method.get()));
}
}
if (bean instanceof Invokable) {
final Invokable invokable = (Invokable) bean;
/*
* @AroundInvoke
*/
if (apply(override, invokable.getAroundInvoke())) {
for (final Annotated<Method> method : sortMethods(annotationFinder.findMetaAnnotatedMethods(javax.interceptor.AroundInvoke.class))) {
invokable.getAroundInvoke().add(new AroundInvoke(method.get()));
}
}
/*
* @AroundTimeout
*/
if (apply(override, invokable.getAroundInvoke())) {
for (final Annotated<Method> method : sortMethods(annotationFinder.findMetaAnnotatedMethods(javax.interceptor.AroundTimeout.class))) {
invokable.getAroundTimeout().add(new AroundTimeout(method.get()));
}
}
}
/*
* @Timeout
*/
if (bean instanceof TimerConsumer) {
final TimerConsumer timerConsumer = (TimerConsumer) bean;
if (timerConsumer.getTimeoutMethod() == null) {
final List<Annotated<Method>> timeoutMethods = sortMethods(annotationFinder.findMetaAnnotatedMethods(javax.ejb.Timeout.class));
//Validation Logic is moved to CheckCallback class.
if (timeoutMethods.size() >= 1) {
// Use the timeout method most near the child class because
// the timeout method in child class will override the timeout method in super classes
timerConsumer.setTimeoutMethod(new NamedMethod(timeoutMethods.get(timeoutMethods.size() - 1).get()));
}
}
}
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
*/