Package com.opensymphony.xwork2.config

Examples of com.opensymphony.xwork2.config.Configuration


        public Listener(ServletContext ctx) {
            this.servletContext = ctx;
        }
       
        public void dispatcherInitialized(Dispatcher du) {
            Configuration config = du.getConfigurationManager().getConfiguration();
            String key;
            PackageConfig packageConfig;

            for (Iterator iter = config.getPackageConfigNames().iterator();
                 iter.hasNext();) {
                key = (String) iter.next();
                packageConfig = config.getPackageConfig(key);

                if (packageConfig.getExternalRefResolver()instanceof ServletContextAware) {
                    ((ServletContextAware) packageConfig.getExternalRefResolver()).setServletContext(servletContext);
                }
            }
View Full Code Here


                req,
                res,
                servletContext);

        try {
            Configuration cfg = du.getConfigurationManager().getConfiguration();
            ValidatorActionProxy proxy = new ValidatorActionProxy(cfg, namespace, action, ctx);
            proxy.execute();
            Object a = proxy.getAction();

            if (a instanceof ValidationAware) {
View Full Code Here

                actionMethod = action.substring(endIdx + 1, action.length());
                action = action.substring(0, endIdx);
            }
        }

        Configuration config = Dispatcher.getInstance().getConfigurationManager().getConfiguration();
        final ActionConfig actionConfig = config.getRuntimeConfiguration().getActionConfig(namespace, action);
        String actionName = action;
        if (actionConfig != null) {

            ActionMapping mapping = new ActionMapping(action, namespace, actionMethod, parameters);
            String result = UrlHelper.buildUrl(ActionMapperFactory.getMapper().getUriFromActionMapping(mapping), request, response, null);
View Full Code Here

    try {
      ConfigurationManager configurationManager;
      configurationManager = (ConfigurationManager) FieldUtils.readField(
          this, "configurationManager", true);
      Configuration config = configurationManager.getConfiguration();
      config.getContainer().inject(actionProxyFactory);
    } catch (Exception ex) {
      throw new RuntimeException(ex);
    }
  }
View Full Code Here

  @SuppressWarnings("unchecked")
  @Override
  protected PackageConfig.Builder buildPackageContext(Element packageElement) {
    // Struts2的API设计得没法扩展,只有用反射来扩展了……
    Configuration configuration;
    Map<String, Element> declaredPackages;
    try {
      Class<?> clazz = XmlConfigurationProvider.class;
      Field configurationField = clazz.getDeclaredField("configuration");
      configurationField.setAccessible(true);
      configuration = (Configuration) configurationField.get(this);

      Field declaredPackagesField = clazz
          .getDeclaredField("declaredPackages");
      declaredPackagesField.setAccessible(true);
      declaredPackages = (Map<String, Element>) declaredPackagesField
          .get(this);
    } catch (Exception ex) {
      throw new RuntimeException(ex);
    }
    String parent = packageElement.getAttribute("extends");
    String abstractVal = packageElement.getAttribute("abstract");
    boolean isAbstract = Boolean.parseBoolean(abstractVal);
    String name = StringUtils.defaultString(packageElement
        .getAttribute("name"));
    String namespace = handleNamespace(StringUtils
        .defaultString(packageElement.getAttribute("namespace")));
    String strictDMIVal = StringUtils.defaultString(packageElement
        .getAttribute("strict-method-invocation"));
    boolean strictDMI = Boolean.parseBoolean(strictDMIVal);

    if (StringUtils.isNotEmpty(packageElement
        .getAttribute("externalReferenceResolver"))) {
      throw new ConfigurationException(
          "The 'externalReferenceResolver' attribute has been removed.  Please use "
              + "a custom ObjectFactory or Interceptor.",
          packageElement);
    }

    PackageConfig.Builder cfg = new PackageConfig.Builder(name)
        .namespace(namespace).isAbstract(isAbstract)
        .strictMethodInvocation(strictDMI)
        .location(DomHelper.getLocationObject(packageElement));

    if (StringUtils.isNotEmpty(StringUtils.defaultString(parent))) { // has
                                      // parents,
                                      // let's
                                      // look
                                      // it
                                      // up
      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);
View Full Code Here

    private void init_AliasStandardObjects() {
        configurationManager.addConfigurationProvider(new BeanSelectionProvider());
    }

    private Container init_PreloadConfiguration() {
        Configuration config = configurationManager.getConfiguration();
        Container container = config.getContainer();

        boolean reloadi18n = Boolean.valueOf(container.getInstance(String.class, StrutsConstants.STRUTS_I18N_RELOAD));
        LocalizedTextUtil.setReloadBundles(reloadi18n);

        return container;
View Full Code Here

            UtilTimerStack.push(timerKey);
            String namespace = mapping.getNamespace();
            String name = mapping.getName();
            String method = mapping.getMethod();

            Configuration config = configurationManager.getConfiguration();
            ActionProxy proxy = config.getContainer().getInstance(ActionProxyFactory.class).createActionProxy(
                    namespace, name, method, extraContext, true, false);

            request.setAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY, proxy.getInvocation().getStack());

            // if the ActionMapping says to go straight to a result, do it!
View Full Code Here

    public Container getContainer() {
        ConfigurationManager mgr = getConfigurationManager();
        if (mgr == null) {
            throw new IllegalStateException("The configuration manager shouldn't be null");
        } else {
            Configuration config = mgr.getConfiguration();
            if (config == null) {
                throw new IllegalStateException("Unable to load configuration");
            } else {
                return config.getContainer();
            }
        }
    }
View Full Code Here

            // Simply select the namespace as everything before the last slash
            namespace = uri.substring(0, lastSlash);
            name = uri.substring(lastSlash + 1);
        } else {
            // Try to find the namespace in those defined, defaulting to ""
            Configuration config = configManager.getConfiguration();
            String prefix = uri.substring(0, lastSlash);
            namespace = "";
            // Find the longest matching namespace, defaulting to the default
            for (Iterator i = config.getPackageConfigs().values().iterator(); i
                    .hasNext();) {
                String ns = ((PackageConfig) i.next()).getNamespace();
                if (ns != null && prefix.startsWith(ns) && (prefix.length() == ns.length() || prefix.charAt(ns.length()) == '/')) {
                    if (ns.length() > namespace.length()) {
                        namespace = ns;
View Full Code Here

            // namespace anyway if not found in root namespace.
            namespace = "/";
            name = uri.substring(lastSlash + 1);
        } else {
            // Try to find the namespace in those defined, defaulting to ""
            Configuration config = configManager.getConfiguration();
            String prefix = uri.substring(0, lastSlash);
            namespace = "";
            // Find the longest matching namespace, defaulting to the default
            for (Iterator i = config.getPackageConfigs().values().iterator(); i
                    .hasNext();) {
                String ns = ((PackageConfig) i.next()).getNamespace();
                if (ns != null && prefix.startsWith(ns) && (prefix.length() == ns.length() || prefix.charAt(ns.length()) == '/')) {
                    if (ns.length() > namespace.length()) {
                        namespace = ns;
View Full Code Here

TOP

Related Classes of com.opensymphony.xwork2.config.Configuration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.