@InterceptorBinding
@Target(
{METHOD, TYPE}
)
@Retention(RUNTIME)
public @interface MyInterceptor {
}
@Interceptor
@GridInterceptor
public class GridSynchronizer implements Serializable{
private static final long serialVersionUID = 7685137612002720995L;
@AroundInvoke
public Object intercept(InvocationContext ctx) throws Exception
{
System.out.println("Within interceptor");
Object result = ctx.proceed();
return result;
}
}
@NormalScope(passivating=true)
public @interface MyScope {
}
public class MyScopeContext implements Context {
// implementation removed
}
public class MyScopeExtension implements Extension {
public void beforeBeanDiscovery(@Observes BeforeBeanDiscovery event, BeanManager manager)
{
event.addScope(MyScope.class, true, true);
}
public void afterBeanDiscovery(@Observes AfterBeanDiscovery event, BeanManager manager)
{
event.addContext(new MyScopeContext());
}
}
@MyScope
@Named
public class HelloBean implements Serializable {
private static final long serialVersionUID = -3216074155876250969L;
@GridInterceptor
public String getMessage()
{
return "Hello World";
}
}