Hi,
Following are the question.
Please tell me if I am wrong.
1) Consider the following logging interceptor that is applied to a business
method 'start()' of an enterprise bean by name 'Session',
public class Logging
{
@AroundInvoke
public Object log(InvocationContext invocation) throws Exception
{
String methodName = invocation.getMethod().getName();
System.out.println("Start of the method->" + methodName);
try
{
return invocation.proceed( );
}
finally
{
System.out.println("End of the method->" + methodName);
}
}
}
What will be the behavior when the statement 'invocation.proceed()' is
commented?
a. It is mandatory for any interceptor to invoke the method
'InvocationContext.proceed()', else during deployment of the bean, the
EJB container will throw an Error telling that 'Invalid interceptor class'.
b. The business method 'Session.start()' won't be invoked at all.
c. The behavior of the EJB container in the absence of the statement
'invocation.proceed()' will vary across implementations.
d. None of the above.
My reasoning: The baove code won't be compiled. so, d is the answere.
22) Which of the following statements are correct regarding Interceptors?
a. Interceptors can be applied only to Stateful session beans, they cannot be applied to
stateless session beans as well as to message-driven beans.
b. Calling a interceptor method defined on an enterprise bean is not allowed.
My reasoning: Can we call interceptor method from client or any other bean?
can we call @AroundInvoke method explicitly?