Well, tried this with OSGi bundles on Glassfish v3.1 promoted b09:
security-api.jar
- contains @Secure:
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.METHOD})
@InterceptorBinding
public @interface Secure {
}
security-impl.jar
- contains implementation:
@Secure
@Interceptor
public class SecurityInterceptor implements Serializable {
@AroundInvoke
public Object checkAuthorization(InvocationContext ctx) throws Exception {
Method me = ctx.getMethod();
Class cls = me.getDeclaringClass();
System.out.println("Checking authorization for " + cls.getName() + "::" + me.getName());
return ctx.proceed();
}
}
user-service.jar
- contains a service implementation:
@Secure
public class UserServiceBean implements UserService {
...
All jars have their META-INF/beans.xml and the one in "user-service.jar" is defined as follows:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="
http://java.sun.com/xml/ns/javaee"
xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
<interceptors>
<class>org.mytests.security.service.SecurityInterceptor</class>
</interceptors>
</beans>
All are OSGi bundles and I have double-verified their imports/exports so that classloading is not an issue. But the problem persists.
The only thing I can do to make the Interceptor work is the old way using the @Interceptors(CLASSES) annotation at the "UserServiceBean". Also I have to get rid of the interceptors tag inside the beans.xml because if that is present the weld bootstrap complains.
There is already a bug report in weld but it is still unassigned:
https://jira.jboss.org/browse/WELD-507
So it seems we have to wait for weld to fix it and then the next glassfish release that integrates that version. As I know jboss this could take years... :-/
[Message sent by forum member 'chaoslayer']
http://forums.java.net/jive/thread.jspa?messageID=477680