Interceptor not firing
philani Nov 1, 2010 6:43 AMHi guys
My EJB interceptors are not firing, am I missing something? Ive pasted the relevant code/details below.
Environment:
--------------------
Jboss 5.0.1 GA
EJB 3.0
Win XP
JDK_1.6.0_13, set to 1.5 code compliance (long story)
EJB class:
----------------
{code}
import java.util.List;
import javax.annotation.security.RolesAllowed;
import javax.ejb.Stateless;
import javax.interceptor.Interceptors;
import javax.persistence.Query;
import org.jboss.ejb3.annotation.SecurityDomain;
import za.co.switchonline.beans.interfaces.IQediUserDAO;
import za.co.switchonline.beans.interfaces.QediUserDAOInterceptor;
import za.co.switchonline.beans.vo.QediUser;
@Stateless
@SuppressWarnings("unchecked")
@SecurityDomain("other")
@Interceptors(value=QediUserDAOInterceptor.class)
public class QediUserDAO extends SuperDAO implements IQediUserDAO {
public static final String PASSWORD = "password";
@RolesAllowed({"admin"})
public void save(QediUser entity) {
try {
SuperDAO.getManager().persist(entity);
} catch (RuntimeException re) {
throw re;
}
}
@RolesAllowed({"admin"})
public void createQediUser(QediUser user,String hostName, String terminalName)
{
save(user);
}
@RolesAllowed({"admin"})
public void deleteQediUser(QediUser user, String hostName,String terminalName)
{
delete(user);
}
@RolesAllowed({"admin"})
public void updateQediUser(QediUser user, String hostName, String terminalName)
{
update(user);
}
@RolesAllowed({"admin"})
public void delete(QediUser entity) {
try {
entity = SuperDAO.getManager().getReference(QediUser.class,
entity.getId());
SuperDAO.getManager().remove(entity);
} catch (RuntimeException re) {
throw re;
}
}
@RolesAllowed({"admin"})
public QediUser update(QediUser entity) {
try {
QediUser result = SuperDAO.getManager().merge(entity);
return result;
} catch (RuntimeException re) {
throw re;
}
}
public QediUser findById(String id) {
try {
QediUser instance = SuperDAO.getManager().find(QediUser.class, id);
return instance;
} catch (RuntimeException re) {
throw re;
}
}
public List<QediUser> findByProperty(String propertyName, final Object value) {
try {
final String queryString = "select model from QediUser model where model."
+ propertyName + "= :propertyValue";
Query query =SuperDAO.getManager().createQuery(queryString);
query.setParameter("propertyValue", value);
return query.getResultList();
} catch (RuntimeException re) {
throw re;
}
}
public List<QediUser> findAll() {
try {
final String queryString = "select model from QediUser model";
Query query = SuperDAO.getManager().createQuery(queryString);
return query.getResultList();
} catch (RuntimeException re) {
throw re;
}
}
}
Interceptor:
------------------
import javax.annotation.Resource;
import javax.ejb.SessionContext;
import javax.interceptor.AroundInvoke;
import javax.interceptor.InvocationContext;
import javax.transaction.TransactionSynchronizationRegistry;
public class QediUserDAOInterceptor
{
private String principal = " ";
Object[] params = null;
@Resource
private SessionContext sessionContext;
@javax.annotation.Resource( mappedName = "java:comp/TransactionSynchronizationRegistry" )
private TransactionSynchronizationRegistry txRegistry;
@AroundInvoke
public Object intercept(InvocationContext invocation) throws Exception
{
InterceptorHelper helper = new InterceptorHelper();
this.principal = helper.extractPrincipal(principal, sessionContext);
helper.storePrincipalInTxRegistry(principal, txRegistry);
this.params = helper.extractInterceptedMethodParams(invocation,params);
helper.extractSecurityDetailsForSave(invocation, params, txRegistry, 1, 2, "createQediUser");
helper.extractSecurityDetailsForUpdate(invocation, params, txRegistry, 1, 2, "updateQediUser");
helper.extractSecurityDetailsForDelete(invocation, params, txRegistry, 1, 2, "deleteQediUser");
return invocation.proceed();
}
}
{code}
Where could I be going wrong?