本文整理汇总了Java中br.com.caelum.vraptor.interceptor.Interceptor类的典型用法代码示例。如果您正苦于以下问题:Java Interceptor类的具体用法?Java Interceptor怎么用?Java Interceptor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Interceptor类属于br.com.caelum.vraptor.interceptor包,在下文中一共展示了Interceptor类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: handlerFor
import br.com.caelum.vraptor.interceptor.Interceptor; //导入依赖的package包/类
@Override
public InterceptorHandler handlerFor(final Class<?> type) {
return cachedHandlers.fetch(type, new Supplier<InterceptorHandler>() {
@Override
public InterceptorHandler get() {
if(type.isAnnotationPresent(Intercepts.class) && !Interceptor.class.isAssignableFrom(type)){
return new AspectStyleInterceptorHandler(type, stepInvoker, container, customAcceptsExecutor,
acceptsExecutor, interceptorExecutor);
}
return new ToInstantiateInterceptorHandler(container, type, executeMethodExceptionHandler);
}
});
}
开发者ID:caelum,项目名称:vraptor4,代码行数:14,代码来源:DefaultInterceptorHandlerFactory.java
示例2: execute
import br.com.caelum.vraptor.interceptor.Interceptor; //导入依赖的package包/类
@Override
public void execute(final InterceptorStack stack, final ControllerMethod method, final Object controllerInstance)
throws InterceptionException {
final Interceptor interceptor = (Interceptor) container.instanceFor(type);
if (interceptor == null) {
throw new InterceptionException("Unable to instantiate interceptor for " + type.getName()
+ ": the container returned null.");
}
if (interceptor.accepts(method)) {
logger.debug("Invoking interceptor {}", interceptor.getClass().getSimpleName());
executeSafely(stack, method, controllerInstance, interceptor);
} else {
stack.next(method, controllerInstance);
}
}
开发者ID:caelum,项目名称:vraptor4,代码行数:16,代码来源:ToInstantiateInterceptorHandler.java
示例3: executeSafely
import br.com.caelum.vraptor.interceptor.Interceptor; //导入依赖的package包/类
private void executeSafely(final InterceptorStack stack, final ControllerMethod method, final Object controllerInstance, final Interceptor interceptor) {
Try result = Try.run(new Callable<Void>() {
@Override
public Void call() throws Exception {
interceptor.intercept(stack, method, controllerInstance);
return null;
}
});
if (result.failed()) {
executeMethodExceptionHandler.handle(result.getException());
}
}
开发者ID:caelum,项目名称:vraptor4,代码行数:13,代码来源:ToInstantiateInterceptorHandler.java
示例4: shouldInvokeInterceptorsMethodIfAbleToInstantiateIt
import br.com.caelum.vraptor.interceptor.Interceptor; //导入依赖的package包/类
@Test
public void shouldInvokeInterceptorsMethodIfAbleToInstantiateIt() throws InterceptionException, IOException {
final Object instance = new Object();
when(container.instanceFor(Interceptor.class)).thenReturn(interceptor);
when(interceptor.accepts(method)).thenReturn(true);
ToInstantiateInterceptorHandler handler = new ToInstantiateInterceptorHandler(container, Interceptor.class, new ExecuteMethodExceptionHandler());
handler.execute(stack, method, instance);
verify(interceptor).intercept(stack, method, instance);
}
开发者ID:caelum,项目名称:vraptor4,代码行数:13,代码来源:ToInstantiateInterceptorHandlerTest.java
示例5: shouldNotInvokeInterceptorsMethodIfInterceptorDoesntAcceptsResource
import br.com.caelum.vraptor.interceptor.Interceptor; //导入依赖的package包/类
@Test
public void shouldNotInvokeInterceptorsMethodIfInterceptorDoesntAcceptsResource() throws InterceptionException, IOException {
final Object instance = new Object();
when(container.instanceFor(Interceptor.class)).thenReturn(interceptor);
when(interceptor.accepts(method)).thenReturn(false);
ToInstantiateInterceptorHandler handler = new ToInstantiateInterceptorHandler(container, Interceptor.class, new ExecuteMethodExceptionHandler());
handler.execute(stack, method, instance);
verify(interceptor, never()).intercept(stack, method, instance);
verify(stack).next(method, instance);
}
开发者ID:caelum,项目名称:vraptor4,代码行数:13,代码来源:ToInstantiateInterceptorHandlerTest.java
注:本文中的br.com.caelum.vraptor.interceptor.Interceptor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论