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


Java PackageProvider类代码示例

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


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

示例1: loadConfigFromBundle

import com.opensymphony.xwork2.config.PackageProvider; //导入依赖的package包/类
/**
 * Loads XML config as well as Convention config from a bundle. Limitation: Constants and Beans are ignored on XML
 * config
 *
 * @param bundle bundle to load from
 */
@SuppressWarnings("PMD.ExcessiveMethodLength")
protected void loadConfigFromBundle(Bundle bundle) {
    final String bundleName = bundle.getSymbolicName();
    if (LOG.isDebugEnabled()) {
        LOG.debug("Loading packages from bundle " + bundleName);
    }

    // init action context
    ActionContext ctx = ActionContext.getContext();
    if (ctx == null) {
        ctx = new ActionContext(new HashMap());
        ActionContext.setContext(ctx);
    }

    try {
        // the Convention plugin will use BundleClassLoaderInterface from the ActionContext to find resources
        // and load classes
        ctx.put(ClassLoaderInterface.CLASS_LOADER_INTERFACE, new BundleClassLoaderInterface());
        ctx.put(DefaultBundleAccessor.CURRENT_BUNDLE_NAME, bundleName);

        LOG.debug("Loading XML config from bundle " + bundleName);

        // XML config
        final BundlePackageLoader loader = new BundlePackageLoader();
        for (final PackageConfig pkg : loader.loadPackages(bundle, this.objectFactory,
                this.configuration.getPackageConfigs())) {
            this.configuration.addPackageConfig(pkg.getName(), pkg);
            this.bundleAccessor.addPackageFromBundle(bundle, pkg.getName());
        }

        // Convention
        // get the existing packages before reloading the provider (se we can figure out what are the new packages)
        final Set<String> packagesBeforeLoading = new HashSet(this.configuration.getPackageConfigNames());

        final PackageProvider conventionPackageProvider =
                this.configuration.getContainer().getInstance(PackageProvider.class, "convention.packageProvider");
        if (conventionPackageProvider != null) {
            LOG.debug("Loading Convention config from bundle " + bundleName);
            conventionPackageProvider.loadPackages();
        }

        final Set<String> packagesAfterLoading = new HashSet(this.configuration.getPackageConfigNames());
        packagesAfterLoading.removeAll(packagesBeforeLoading);
        if (!packagesAfterLoading.isEmpty()) {
            // add the new packages to the map of bundle -> package
            for (final String packageName : packagesAfterLoading) {
                this.bundleAccessor.addPackageFromBundle(bundle, packageName);
            }
        }

        if (this.configuration.getRuntimeConfiguration() != null) {
            // if there is a runtime config, it meas that this method was called froma bundle start event
            // instead of the initial load, in that case, reload the config
            this.configuration.rebuildRuntimeConfiguration();
        }
    } finally {
        ctx.put(DefaultBundleAccessor.CURRENT_BUNDLE_NAME, null);
        ctx.put(ClassLoaderInterface.CLASS_LOADER_INTERFACE, null);
    }
}
 
开发者ID:NCIP,项目名称:caarray,代码行数:67,代码来源:OsgiConfigurationProvider.java

示例2: setOsgiConfigurationProvider

import com.opensymphony.xwork2.config.PackageProvider; //导入依赖的package包/类
/**
 * @param osgiConfigurationProvider the OSGi aware configuration provider
 */
@Inject("osgi")
public void setOsgiConfigurationProvider(PackageProvider osgiConfigurationProvider) {
    this.osgiConfigurationProvider = (OsgiConfigurationProvider) osgiConfigurationProvider;
}
 
开发者ID:NCIP,项目名称:caarray,代码行数:8,代码来源:DelegatingObjectFactory.java


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