I also tried to create a new annotation using the @InterceptorBinding way:
@Inherited
@InterceptorBinding
@Retention(RUNTIME)
@Target({ METHOD, TYPE })
public @interface Logging {
}
@Interceptor
@Logging
public class LoggingInterceptor {
@AroundInvoke
public Object intercept(InvocationContext context) throws Exception {...}
@Logging
@WebService(serviceName = "MyWebService", portName = "MyWebService",
targetNamespace = "...")
@Stateless(name = "MyWebServiceBean", mappedName = "ejb/seb/MyWebServiceBean")
public class MyWebServiceBean implements MyWebService
{....}
but this does not compile too, i receive the same error:
[ERROR] Failed to execute goal org.jvnet.jax-ws-commons:jaxws-maven-plugin:2.2:w
sgen (EDocWebService) on project eDoc-ws-ejb: Failed to execute wsgen: javax/int
erceptor/InterceptorBinding : Unsupported major.minor version 51.0 -> [Help 1]
Probably this is a case where ejb-jar.xml should be used
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="3.0" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd">
<interceptors>
<interceptor>
<interceptor-class>com.mypackage.LoggingInterceptor </interceptor-class>
</interceptor>
</interceptors>
<assembly-descriptor>
<interceptor-binding>
<ejb-name>MyWebServiceBean</ejb-name>
<interceptor-class>com.package.Interceptor</interceptor-class>
</interceptor-binding>
</assembly-descriptor>
</ejb-jar>