public class LoggingInterceptor implements Interceptor { @Override public Object preInvoke(MethodInvocationContext context) throws Exception { return null; } @Override public Object postInvoke(MethodInvocationContext context) throws Exception { return null; } } public class UserService { public void addUser(String username) { } } <listener> <listener-class>org.jboss.weld.environment.servlet.Listener</listener-class> </listener> <interceptors> <class>com.example.LoggingInterceptor</class> </interceptors> public class Main { public static void main(String[] args) { UserService userService = new UserService(); } }


上一篇:
下一篇:
切换中文