Search in sources :

Example 1 with DefaultInterceptorRef

use of org.apache.struts2.convention.annotation.DefaultInterceptorRef in project tis by qlangtech.

the class TisPackageBasedActionConfigBuilder method getPackageConfig.

@Override
protected Builder getPackageConfig(Map<String, Builder> packageConfigs, String actionNamespace, String actionPackage, Class<?> actionClass, Action action) {
    Matcher matcher = NAMESPACE_PATTERN.matcher(actionClass.getName());
    // 解析struts2的命名空间
    String name = null;
    if (// || (matcher = NAMESPACE_TIS_PATTERN.matcher(actionClass.getName())).matches()
    matcher.matches()) {
        name = '/' + matcher.group(1) + StringUtils.replace(matcher.group(3), ".", "/") + "#" + matcher.group(2);
    } else {
        throw new IllegalStateException("actionPackage:" + actionPackage + " is not a valid actionPackage");
    }
    PackageConfig.Builder pkgConfig = packageConfigs.get(name);
    if (pkgConfig == null) {
        pkgConfig = new PackageConfig.Builder(name).namespace(name).addParent(this.parentPkgConfig);
        // add by baisui: 2020/7/13
        pkgConfig.strictMethodInvocation(false);
        packageConfigs.put(name, pkgConfig);
        // check for @DefaultInterceptorRef in the package
        DefaultInterceptorRef defaultInterceptorRef = AnnotationUtils.findAnnotation(actionClass, DefaultInterceptorRef.class);
        if (defaultInterceptorRef != null) {
            pkgConfig.defaultInterceptorRef(defaultInterceptorRef.value());
            if (LOG.isTraceEnabled())
                LOG.debug("Setting [#0] as the default interceptor ref for [#1]", defaultInterceptorRef.value(), pkgConfig.getName());
        }
    }
    if (LOG.isTraceEnabled()) {
        LOG.trace("Created package config named [#0] with a namespace [#1]", name, actionNamespace);
    }
    return pkgConfig;
}
Also used : Builder(com.opensymphony.xwork2.config.entities.PackageConfig.Builder) Matcher(java.util.regex.Matcher) PackageConfig(com.opensymphony.xwork2.config.entities.PackageConfig) DefaultInterceptorRef(org.apache.struts2.convention.annotation.DefaultInterceptorRef)

Aggregations

PackageConfig (com.opensymphony.xwork2.config.entities.PackageConfig)1 Builder (com.opensymphony.xwork2.config.entities.PackageConfig.Builder)1 Matcher (java.util.regex.Matcher)1 DefaultInterceptorRef (org.apache.struts2.convention.annotation.DefaultInterceptorRef)1