Interceptor

1 resposta
Helbert

Vi em alguns lugares a seguinte implementação:

@Interceptors(TesteInterceptor.class)
public @interface Custom{}
public class TesteInterceptor {

	@PostConstruct
	public void myPostConstruct(InvocationContext ctx) {
		System.out.println("Interceptor @PostConstruct: " + ctx.getTarget().getClass().getName());
	}

	@PreDestroy
	public void myPreDestroy(InvocationContext ctx) {
		System.out.println("Interceptor @PreDestroy: " + ctx.getTarget().getClass().getName());
	}

	@PostActivate
	public void postActivate(InvocationContext ctx) {
		System.out.println("Interceptor @PostActivate: " + ctx.getTarget().getClass().getName());
	}

	@PrePassivate
	public void prePassivate(InvocationContext ctx) {
		System.out.println("Interceptor @PrePassivate: " + ctx.getTarget().getClass().getName());
	}

	@AroundInvoke
	public Object businessIntercept(InvocationContext ctx) throws Exception {
		System.out.println("Interceptor @AroundInvoke: " + ctx.getTarget().getClass().getName());
		Object result = null;
		try {
			// PreInvoke: do something before handing control to the next in
			// chain
			result = ctx.proceed();
			return result;
		} finally {
			// PostInvoke: do something (cleanup, etc) after the main processing
			// is done
		}
	}
@Custom public class Teste {}

Isto realmente é possível? Não está funcionado para mim.

1 Resposta

Helbert

Em alguns fóruns retrata isso como um problema do glassfish v3.1, isso confirma?

Criado 19 de maio de 2011
Ultima resposta 20 de mai. de 2011
Respostas 1
Participantes 1