[jboss-user] [JBoss Seam] - Re: Interceptor for seam component

2007-08-22 Thread [EMAIL PROTECTED]
Post readable code.

View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=4076776#4076776

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4076776
___
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user


[jboss-user] [JBoss Seam] - Re: Interceptor for seam component

2007-08-17 Thread chlol
i do it as the doc,but i can't invoke the interceptor,my code is the following

theinterceptor:
package cn.sh.guanghua.manhour.service.manhour;

import java.lang.reflect.Modifier;
import java.util.Map;

import javax.interceptor.AroundInvoke;
import javax.interceptor.InvocationContext;

import org.jboss.seam.annotations.Logger;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.framework.EntityHome;
import org.jboss.seam.log.Log;

import cn.sh.guanghua.manhour.model.manhour.Logs;

@Name(logsHome)
public class LogsHome extends EntityHome {
@Logger
Log log;

public void setLogsId(Long id) {
setId(id);
}

public Long getLogsId() {
return (Long) getId();
}

@Override
protected Logs createInstance() {
Logs logs = new Logs();
return logs;
}

public void wire() {
}

public boolean isWired() {
return true;
}

public Logs getDefinedInstance() {
return isIdDefined() ? getInstance() : null;
}

@AroundInvoke
public Object doLogs(InvocationContext inv) throws Exception {
int methodModify = inv.getMethod().getModifiers();
String methodName = inv.getMethod().getName();

System.out.println(111);
if (methodModify == Modifier.PUBLIC 
 (methodName.startsWith(create) 
|| 
methodName.startsWith(update)
|| 
methodName.startsWith(persist)
|| 
methodName.startsWith(remove))) {

Map data = inv.getContextData();
Object target = inv.getTarget();
log.debug(ContextData: + data);
log.debug(Target: + target);
}

return inv.proceed();
}

}


the invoke interceptor class:
package cn.sh.guanghua.manhour.service.admin;

import java.util.ArrayList;
import java.util.List;

import javax.interceptor.Interceptors;

import org.jboss.seam.annotations.Name;
import org.jboss.seam.framework.EntityHome;

import cn.sh.guanghua.manhour.model.admin.Role;
import cn.sh.guanghua.manhour.model.admin.RoleResource;
import cn.sh.guanghua.manhour.service.manhour.LogsHome;

@Name(roleHome)
@Interceptors(LogsHome.class)
public class RoleHome extends EntityHome {

public void setRoleId(Long id) {
setId(id);
}

public Long getRoleId() {
return (Long) getId();
}

@Override
protected Role createInstance() {
Role role = new Role();
return role;
}

public void wire() {
}

public boolean isWired() {
return true;
}

public Role getDefinedInstance() {
return isIdDefined() ? getInstance() : null;
}

public List getRoleResources() {
return getInstance() == null ? null : new ArrayList(
getInstance().getRoleResources());
}

}

but when RoleHome excute the persist method,the interceptor don't work

thank you!

View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=4075146#4075146

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4075146
___
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user


[jboss-user] [JBoss Seam] - Re: Interceptor for seam component

2007-06-27 Thread [EMAIL PROTECTED]
Yes, just use @Interceptors as a meta-annotation, as described in the docs.

View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=4058271#4058271

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4058271
___
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user