本文整理汇总了Java中net.sourceforge.stripes.controller.Intercepts类的典型用法代码示例。如果您正苦于以下问题:Java Intercepts类的具体用法?Java Intercepts怎么用?Java Intercepts使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Intercepts类属于net.sourceforge.stripes.controller包,在下文中一共展示了Intercepts类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addInterceptor
import net.sourceforge.stripes.controller.Intercepts; //导入依赖的package包/类
/**
* Adds the interceptor to the map, associating it with the {@link LifecycleStage}s indicated
* by the {@link Intercepts} annotation. If the interceptor implements
* {@link ConfigurableComponent}, then its init() method will be called.
*/
protected void addInterceptor(Map<LifecycleStage, Collection<Interceptor>> map,
Interceptor interceptor) {
Class<? extends Interceptor> type = interceptor.getClass();
Intercepts intercepts = type.getAnnotation(Intercepts.class);
if (intercepts == null) {
log.error("An interceptor of type ", type.getName(), " was configured ",
"but was not marked with an @Intercepts annotation. As a ",
"result it is not possible to determine at which ",
"lifecycle stages the interceptor should be applied. This ",
"interceptor will be ignored.");
return;
}
else {
log.debug("Configuring interceptor '", type.getSimpleName(),
"', for lifecycle stages: ", intercepts.value());
}
// call init() if the interceptor implements ConfigurableComponent
if (interceptor instanceof ConfigurableComponent) {
try {
((ConfigurableComponent) interceptor).init(this);
}
catch (Exception e) {
log.error("Error initializing interceptor of type " + type.getName(), e);
}
}
for (LifecycleStage stage : intercepts.value()) {
Collection<Interceptor> stack = map.get(stage);
if (stack == null) {
stack = new LinkedList<Interceptor>();
map.put(stage, stack);
}
stack.add(interceptor);
}
}