当前位置: 首页>>代码示例>>Java>>正文


Java Interceptor类代码示例

本文整理汇总了Java中com.opensymphony.xwork2.interceptor.Interceptor的典型用法代码示例。如果您正苦于以下问题:Java Interceptor类的具体用法?Java Interceptor怎么用?Java Interceptor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Interceptor类属于com.opensymphony.xwork2.interceptor包,在下文中一共展示了Interceptor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildInterceptor

import com.opensymphony.xwork2.interceptor.Interceptor; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public Interceptor buildInterceptor(InterceptorConfig interceptorConfig, Map interceptorRefParams)
    throws ConfigurationException {
  // Ensure the interceptor class is present.
  Class<? extends Interceptor> interceptorClass;
  try {
    interceptorClass =
        (Class<? extends Interceptor>) getClassInstance(interceptorConfig.getClassName());
  } catch (ClassNotFoundException e) {
    throw new RuntimeException(e);
  }

  ProvidedInterceptor providedInterceptor =
      new ProvidedInterceptor(interceptorConfig, interceptorRefParams, interceptorClass);
  interceptors.add(providedInterceptor);
  if (strutsInjector != null) {
    synchronized (this) {
      if (strutsInjector != null) {
        providedInterceptor.inject();
      }
    }
  }
  return providedInterceptor;
}
 
开发者ID:google,项目名称:guice,代码行数:26,代码来源:Struts2Factory.java

示例2: validate

import com.opensymphony.xwork2.interceptor.Interceptor; //导入依赖的package包/类
void validate(Binder binder) {
  // TODO: Set source from Struts XML.
  if (hasScope(interceptorClass)) {
    binder.addError(
        "Scoping interceptors is not currently supported."
            + " Please remove the scope annotation from "
            + interceptorClass.getName()
            + ".");
  }

  // Make sure it implements Interceptor.
  if (!Interceptor.class.isAssignableFrom(interceptorClass)) {
    binder.addError(
        interceptorClass.getName() + " must implement " + Interceptor.class.getName() + ".");
  }
}
 
开发者ID:google,项目名称:guice,代码行数:17,代码来源:Struts2Factory.java

示例3: buildInterceptor

import com.opensymphony.xwork2.interceptor.Interceptor; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public Interceptor buildInterceptor(InterceptorConfig interceptorConfig, Map interceptorRefParams)
    throws ConfigurationException {
  // Ensure the interceptor class is present.
  Class<? extends Interceptor> interceptorClass;
  try {
    interceptorClass = getClassInstance(interceptorConfig.getClassName());
  } catch (ClassNotFoundException e) {
    throw new RuntimeException(e);
  }

  ProvidedInterceptor providedInterceptor =
      new ProvidedInterceptor(interceptorConfig, interceptorRefParams, interceptorClass);
  interceptors.add(providedInterceptor);
  return providedInterceptor;
}
 
开发者ID:google,项目名称:guice,代码行数:18,代码来源:GuiceObjectFactory.java

示例4: buildInterceptor

import com.opensymphony.xwork2.interceptor.Interceptor; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public Interceptor buildInterceptor(InterceptorConfig interceptorConfig,
    Map interceptorRefParams) throws ConfigurationException {
  // Ensure the interceptor class is present.
  Class<? extends Interceptor> interceptorClass;
  try {
    interceptorClass = (Class<? extends Interceptor>)
        getClassInstance(interceptorConfig.getClassName());
  } catch (ClassNotFoundException e) {
    throw new RuntimeException(e);
  }

  ProvidedInterceptor providedInterceptor = new ProvidedInterceptor(
      interceptorConfig, interceptorRefParams, interceptorClass);
  interceptors.add(providedInterceptor);
  return providedInterceptor;
}
 
开发者ID:cgruber,项目名称:guice-old,代码行数:18,代码来源:Struts2Factory.java

示例5: buildInterceptor

import com.opensymphony.xwork2.interceptor.Interceptor; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public Interceptor buildInterceptor(InterceptorConfig interceptorConfig,
    Map interceptorRefParams) throws ConfigurationException {
  // Ensure the interceptor class is present.
  Class<? extends Interceptor> interceptorClass;
  try {
    interceptorClass = getClassInstance(interceptorConfig.getClassName());
  } catch (ClassNotFoundException e) {
    throw new RuntimeException(e);
  }

  ProvidedInterceptor providedInterceptor = new ProvidedInterceptor(
      interceptorConfig, interceptorRefParams, interceptorClass);
  interceptors.add(providedInterceptor);
  return providedInterceptor;
}
 
开发者ID:cgruber,项目名称:guice-old,代码行数:17,代码来源:GuiceObjectFactory.java

示例6: constructInterceptorReference

import com.opensymphony.xwork2.interceptor.Interceptor; //导入依赖的package包/类
/**
 * Builds a list of interceptors referenced by the refName in the supplied PackageConfig (InterceptorMapping object).
 *
 * @param interceptorLocator interceptor locator
 * @param refName reference name
 * @param refParams reference parameters
 * @param location location
 * @param objectFactory object factory
 * @return list of interceptors referenced by the refName in the supplied PackageConfig (InterceptorMapping object).
 * @throws ConfigurationException in case of any configuration errors
 */
public static List<InterceptorMapping> constructInterceptorReference(InterceptorLocator interceptorLocator,
                                                                     String refName, Map<String,String> refParams, Location location, ObjectFactory objectFactory) throws ConfigurationException {
    Object referencedConfig = interceptorLocator.getInterceptorConfig(refName);
    List<InterceptorMapping> result = new ArrayList<>();

    if (referencedConfig == null) {
        throw new ConfigurationException("Unable to find interceptor class referenced by ref-name " + refName, location);
    } else {
        if (referencedConfig instanceof InterceptorConfig) {
            InterceptorConfig config = (InterceptorConfig) referencedConfig;
            Interceptor inter;
            try {

                inter = objectFactory.buildInterceptor(config, refParams);
                result.add(new InterceptorMapping(refName, inter));
            } catch (ConfigurationException ex) {
          	    LOG.warn("Unable to load config class {} at {} probably due to a missing jar, which might be fine if you never plan to use the {} interceptor",
                        config.getClassName(), ex.getLocation(), config.getName());
                LOG.error("Unable to load config class {}", config.getClassName(), ex);
            }

        } else if (referencedConfig instanceof InterceptorStackConfig) {
            InterceptorStackConfig stackConfig = (InterceptorStackConfig) referencedConfig;

            if ((refParams != null) && (refParams.size() > 0)) {
                result = constructParameterizedInterceptorReferences(interceptorLocator, stackConfig, refParams, objectFactory);
            } else {
                result.addAll(stackConfig.getInterceptors());
            }

        } else {
            LOG.error("Got unexpected type for interceptor {}. Got {}", refName, referencedConfig);
        }
    }

    return result;
}
 
开发者ID:txazo,项目名称:struts2,代码行数:49,代码来源:InterceptorBuilder.java

示例7: ProvidedInterceptor

import com.opensymphony.xwork2.interceptor.Interceptor; //导入依赖的package包/类
ProvidedInterceptor(
    InterceptorConfig config,
    Map<String, String> params,
    Class<? extends Interceptor> interceptorClass) {
  this.config = config;
  this.params = params;
  this.interceptorClass = interceptorClass;
}
 
开发者ID:google,项目名称:guice,代码行数:9,代码来源:Struts2Factory.java

示例8: hasScope

import com.opensymphony.xwork2.interceptor.Interceptor; //导入依赖的package包/类
/** Returns true if the given class has a scope annotation. */
private static boolean hasScope(Class<? extends Interceptor> interceptorClass) {
  for (Annotation annotation : interceptorClass.getAnnotations()) {
    if (Annotations.isScopeAnnotation(annotation.annotationType())) {
      return true;
    }
  }
  return false;
}
 
开发者ID:google,项目名称:guice,代码行数:10,代码来源:Struts2Factory.java

示例9: validate

import com.opensymphony.xwork2.interceptor.Interceptor; //导入依赖的package包/类
void validate(Binder binder) {
  // TODO: Set source from Struts XML.
  if (hasScope(interceptorClass)) {
    binder.addError("Scoping interceptors is not currently supported."
        + " Please remove the scope annotation from "
        + interceptorClass.getName() + ".");
  }

  // Make sure it implements Interceptor.
  if (!Interceptor.class.isAssignableFrom(interceptorClass)) {
    binder.addError(interceptorClass.getName() + " must implement "
      + Interceptor.class.getName() + ".");
  }
}
 
开发者ID:cgruber,项目名称:guice-old,代码行数:15,代码来源:Struts2Factory.java

示例10: hasScope

import com.opensymphony.xwork2.interceptor.Interceptor; //导入依赖的package包/类
/**
 * Returns true if the given class has a scope annotation.
 */
private static boolean hasScope(Class<? extends Interceptor> interceptorClass) {
  for (Annotation annotation : interceptorClass.getAnnotations()) {
    if (Annotations.isScopeAnnotation(annotation.annotationType())) {
      return true;
    }
  }
  return false;
}
 
开发者ID:cgruber,项目名称:guice-old,代码行数:12,代码来源:Struts2Factory.java

示例11: cleanup

import com.opensymphony.xwork2.interceptor.Interceptor; //导入依赖的package包/类
/**
 * Releases all instances bound to this dispatcher instance.
 */
public void cleanup() {

	// clean up ObjectFactory
    ObjectFactory objectFactory = getContainer().getInstance(ObjectFactory.class);
    if (objectFactory == null) {
    	LOG.warn("Object Factory is null, something is seriously wrong, no clean up will be performed");
    }
    if (objectFactory instanceof ObjectFactoryDestroyable) {
        try {
            ((ObjectFactoryDestroyable)objectFactory).destroy();
        }
        catch(Exception e) {
            // catch any exception that may occurred during destroy() and log it
            LOG.error("Exception occurred while destroying ObjectFactory [{}]", objectFactory.toString(), e);
        }
    }

    // clean up Dispatcher itself for this thread
    instance.set(null);

    // clean up DispatcherListeners
    if (!dispatcherListeners.isEmpty()) {
        for (DispatcherListener l : dispatcherListeners) {
            l.dispatcherDestroyed(this);
        }
    }

    // clean up all interceptors by calling their destroy() method
    Set<Interceptor> interceptors = new HashSet<>();
    Collection<PackageConfig> packageConfigs = configurationManager.getConfiguration().getPackageConfigs().values();
    for (PackageConfig packageConfig : packageConfigs) {
        for (Object config : packageConfig.getAllInterceptorConfigs().values()) {
            if (config instanceof InterceptorStackConfig) {
                for (InterceptorMapping interceptorMapping : ((InterceptorStackConfig) config).getInterceptors()) {
            	    interceptors.add(interceptorMapping.getInterceptor());
                }
            }
        }
    }
    for (Interceptor interceptor : interceptors) {
    	interceptor.destroy();
    }

    // Clear container holder when application is unloaded / server shutdown
    ContainerHolder.clear();

    //cleanup action context
    ActionContext.setContext(null);

    // clean up configuration
	configurationManager.destroyConfiguration();
	configurationManager = null;
}
 
开发者ID:txazo,项目名称:struts2,代码行数:57,代码来源:Dispatcher.java

示例12: InterceptorMapping

import com.opensymphony.xwork2.interceptor.Interceptor; //导入依赖的package包/类
public InterceptorMapping(String name, Interceptor interceptor) {
    this.name = name;
    this.interceptor = interceptor;
}
 
开发者ID:txazo,项目名称:struts2,代码行数:5,代码来源:InterceptorMapping.java

示例13: getInterceptor

import com.opensymphony.xwork2.interceptor.Interceptor; //导入依赖的package包/类
public Interceptor getInterceptor() {
    return interceptor;
}
 
开发者ID:txazo,项目名称:struts2,代码行数:4,代码来源:InterceptorMapping.java

示例14: superBuildInterceptor

import com.opensymphony.xwork2.interceptor.Interceptor; //导入依赖的package包/类
private Interceptor superBuildInterceptor(
    InterceptorConfig interceptorConfig, Map<String, String> interceptorRefParams)
    throws ConfigurationException {
  return super.buildInterceptor(interceptorConfig, interceptorRefParams);
}
 
开发者ID:google,项目名称:guice,代码行数:6,代码来源:Struts2Factory.java

示例15: superBuildInterceptor

import com.opensymphony.xwork2.interceptor.Interceptor; //导入依赖的package包/类
Interceptor superBuildInterceptor(InterceptorConfig interceptorConfig, Map interceptorRefParams)
    throws ConfigurationException {
  return super.buildInterceptor(interceptorConfig, interceptorRefParams);
}
 
开发者ID:google,项目名称:guice,代码行数:5,代码来源:GuiceObjectFactory.java


注:本文中的com.opensymphony.xwork2.interceptor.Interceptor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。