All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.googlecode.mycontainer.ejb.interceptor.DefaultEJBCallbackInterceptor Maven / Gradle / Ivy

There is a newer version: 1.7.5
Show newest version
package com.googlecode.mycontainer.ejb.interceptor;

import java.lang.reflect.Method;
import java.util.List;

import javax.annotation.PostConstruct;

import com.googlecode.mycontainer.kernel.reflect.ReflectUtil;
import com.googlecode.mycontainer.kernel.reflect.proxy.ProxyChain;
import com.googlecode.mycontainer.kernel.reflect.proxy.Request;

public class DefaultEJBCallbackInterceptor extends
		AbstractEJBCallbackInterceptor {

	private static final long serialVersionUID = 6506426121914781363L;

	@Override
	public Object interceptBusiness(Request request, ProxyChain chain)
			throws Throwable {
		return chain.proceed(request);
	}

	public void ejbPreConstruct(Request request, ProxyChain chain) {

	}

	public Object ejbPostConstruct(Request request, ProxyChain chain)
			throws Throwable {
		ReflectUtil util = new ReflectUtil(request.getImpl().getClass());
		List methods = util.getMethods(PostConstruct.class);
		if (methods.size() > 1) {
			throw new RuntimeException(
					"You can define just one callback by the spec (PostConstruct): "
							+ request);
		}
		if (methods.isEmpty()) {
			return null;
		}
		Method callback = methods.get(0);
		Request req = request.copy();
		req.setMethod(callback);

		return chain.proceed(req);
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy