public void setConfiguration(Configuration configuration) { Container con = configuration.getContainer(); _factory = con.getInstance(ActionProxyFactory.class); }
/** * Create a Struts 1.x ModuleConfig based on an XWork package configuration. * * @param packageName the name of the XWork package configuration to wrap. This becomes the module prefix for the * newly-created ModuleConfig. * @return a wrapper Struts 1.x ModuleConfig. */ public ModuleConfig createModuleConfig(String packageName) { assert packageName != null; return new WrapperModuleConfig(this, configuration.getPackageConfig(packageName)); }
public Set<String> getNamespaces() { Set<String> namespaces = Collections.emptySet(); Map<String, Map<String, ActionConfig>> allActionConfigs = configuration.getRuntimeConfiguration().getActionConfigs(); if (allActionConfigs != null) { namespaces = allActionConfigs.keySet(); } return namespaces; }
List<PackageConfig> parents = new ArrayList<PackageConfig>(); for (String parentPackageName : ConfigurationUtil.buildParentListFromString(parent)) { if (configuration.getPackageConfigNames().contains(parentPackageName)) { parents.add(configuration.getPackageConfig(parentPackageName)); } else if (declaredPackages.containsKey(parentPackageName)) { if (configuration.getPackageConfig(parentPackageName) == null) { addPackage(declaredPackages.get(parentPackageName)); parents.add(configuration.getPackageConfig(parentPackageName)); } else { throw new ConfigurationException("Parent package is not defined: " + parentPackageName);
LOG.trace("Checking if there is an action named index in the namespace {}", redirectNamespace); actionConfig = configuration.getRuntimeConfiguration().getActionConfig(redirectNamespace, "index"); if (actionConfig != null) { LOG.trace("Found action config"); PackageConfig packageConfig = configuration.getPackageConfig(actionConfig.getPackageName()); if (redirectNamespace.equals(packageConfig.getNamespace())) { LOG.trace("Action is not a default - redirecting"); actionConfig = configuration.getRuntimeConfiguration().getActionConfig(namespace, "index");
PackageConfig packageConfig = configuration.getPackageConfig(packageName); if (packageConfig != null) { if (LOG.isDebugEnabled()) { configuration.addPackageConfig(cfg.getName(), cfg); return cfg;
@SuppressWarnings("unchecked") protected PackageConfig findPackageNamespace( Configuration xwConfig, String name ) { Map<?,PackageConfig> xwPackageConfigMap = xwConfig.getPackageConfigs(); for ( PackageConfig xwPackageConfig : xwPackageConfigMap.values() ) { if ( StringUtils.equals( name, xwPackageConfig.getNamespace() ) ) { return xwPackageConfig; } } return null; }
/** * Destroy its managing Configuration instance */ public synchronized void destroyConfiguration() { clearContainerProviders(); // let's destroy the ConfigurationProvider first containerProviders = new CopyOnWriteArrayList<ContainerProvider>(); if (configuration != null) configuration.destroy(); // let's destroy it first, before nulling it. configuration = null; }
configuration.addPackageConfig(packageName, packageConfigs.get(packageName).build());
namespace = ""; for (Object o : config.getPackageConfigs().values()) { String ns = ((PackageConfig) o).getNamespace(); if (ns != null && prefix.startsWith(ns) && (prefix.length() == ns.length() || prefix.charAt(ns.length()) == '/')) {
@AfterClass public static void afterClass() throws Exception { StrutsTestCaseHelper.tearDown(); XWorkTestCaseHelper.tearDown(configurationManager); configuration.destroy(); configuration = null; configurationManager = null; container = null; httpSession = null; servletContext = null; session = null; }
private void updateReloadConfigsFlag() { reloadConfigs = Boolean.parseBoolean(configuration.getContainer().getInstance(String.class, XWorkConstants.RELOAD_XML_CONFIGURATION)); if (LOG.isDebugEnabled()) { LOG.debug("Updating [#0], current value is [#1], new value [#2]", XWorkConstants.RELOAD_XML_CONFIGURATION, String.valueOf(reloadConfigs), String.valueOf(reloadConfigs)); } }
public List<PackageConfig> getPackages() { List<PackageConfig> pkgs = new ArrayList<PackageConfig>(); Bundle bundle = getBundle(); if (bundle.getState() == Bundle.ACTIVE) { for (String name : bundleAccessor.getPackagesByBundle(bundle)) { PackageConfig packageConfig = configuration.getPackageConfig(name); if (packageConfig != null) pkgs.add(packageConfig); } } return pkgs; }
public Set<String> getActionNames(String namespace) { Set<String> actionNames = Collections.emptySet(); Map<String, Map<String, ActionConfig>> allActionConfigs = configuration.getRuntimeConfiguration().getActionConfigs(); if (allActionConfigs != null) { Map<String, ActionConfig> actionMappings = allActionConfigs.get(namespace); if (actionMappings != null) { actionNames = actionMappings.keySet(); } } return actionNames; }
public static synchronized ValueStack getSharedValueStack() { if (sharedValueStack == null) { // init context ConfigurationManager confManager = new ConfigurationManager(); Configuration conf = confManager.getConfiguration(); sharedValueStack = conf.getContainer().getInstance(ValueStackFactory.class).createValueStack(); if (log.isDebugEnabled()) { log.debug("init shared value stack " + sharedValueStack); } } return sharedValueStack; }
/** * Get the {@link PackageConfig} elements with the specified names. * @param configuration Configuration from which to find the package elements * @param parent Comma separated list of parent package names * @return The package elements that correspond to the names in the {@code parent} parameter. */ public static List<PackageConfig> buildParentsFromString(Configuration configuration, String parent) { List<String> parentPackageNames = buildParentListFromString(parent); List<PackageConfig> parentPackageConfigs = new ArrayList<PackageConfig>(); for (String parentPackageName : parentPackageNames) { PackageConfig parentPackageContext = configuration.getPackageConfig(parentPackageName); if (parentPackageContext != null) { parentPackageConfigs.add(parentPackageContext); } } return parentPackageConfigs; }
public ActionConfig getActionConfig(String namespace, String actionName) { ActionConfig config = null; Map<String, Map<String, ActionConfig>> allActionConfigs = configuration.getRuntimeConfiguration().getActionConfigs(); if (allActionConfigs != null) { Map<String, ActionConfig> actionMappings = allActionConfigs.get(namespace); if (actionMappings != null) { config = actionMappings.get(actionName); } } return config; }
protected void loadConfigurationProviders(ConfigurationProvider... providers) { configurationManager = XWorkTestCaseHelper.loadConfigurationProviders(configurationManager, providers); configuration = configurationManager.getConfiguration(); container = configuration.getContainer(); actionProxyFactory = container.getInstance(ActionProxyFactory.class); }
protected ActionConfig buildActionConfig(String path, ResultTypeConfig resultTypeConfig) { Map<String, ResultConfig> results = new HashMap<>(); HashMap<String, String> params = new HashMap<>(); if (resultTypeConfig.getParams() != null) { params.putAll(resultTypeConfig.getParams()); } params.put(resultTypeConfig.getDefaultResultParam(), path); PackageConfig pkg = configuration.getPackageConfig(defaultParentPackageName); List<InterceptorMapping> interceptors = InterceptorBuilder.constructInterceptorReference(pkg, pkg.getFullDefaultInterceptorRef(), Collections.<String, String>emptyMap(), null, objectFactory); ResultConfig config = new ResultConfig.Builder(Action.SUCCESS, resultTypeConfig.getClassName()). addParams(params).build(); results.put(Action.SUCCESS, config); return new ActionConfig.Builder(defaultParentPackageName, "execute", ActionSupport.class.getName()). addInterceptors(interceptors). addResultConfigs(results). addAllowedMethod(pkg.getGlobalAllowedMethods()). build(); }
/** * Returns a Map of all action names/configs * * @return Map of all action names/configs */ public static Map<String, Map<String,ActionConfig>> getActionConfigs() { if (!isXWorkStarted) initXWork(); return cm.getConfiguration().getRuntimeConfiguration().getActionConfigs(); }