Package com.opensymphony.xwork2.config.entities

Examples of com.opensymphony.xwork2.config.entities.PackageConfig


        public boolean needsReload() {
            return false;
        }

        public void init(Configuration configuration) throws ConfigurationException {
            PackageConfig wait = new PackageConfig("");

            Map results = new HashMap();
            results.put(Action.SUCCESS, new ResultConfig(Action.SUCCESS, MockResult.class.getName(), null));
            results.put(ExecuteAndWaitInterceptor.WAIT, new ResultConfig(ExecuteAndWaitInterceptor.WAIT, MockResult.class.getName(), null));

            // interceptors
            waitInterceptor = new ExecuteAndWaitInterceptor();
            List interceptors = new ArrayList();
            interceptors.add(new InterceptorMapping("params", new ParametersInterceptor()));
            interceptors.add(new InterceptorMapping("execAndWait", waitInterceptor));

            ActionConfig ac = new ActionConfig(null, ExecuteAndWaitDelayAction.class, null, results, interceptors);
            wait.addActionConfig("action1", ac);

            configuration.addPackageConfig("", wait);
        }
View Full Code Here


        Dispatcher.setInstance(du);
        ConfigurationManager cm = new ConfigurationManager();
        cm.addConfigurationProvider(new StrutsXmlConfigurationProvider("struts.xml", false));
        du.setConfigurationManager(cm);
        du.getConfigurationManager().getConfiguration().
            addPackageConfig("foo", new PackageConfig("foo", "/namespace", false, null));
       

        view = new ServletRedirectResult();

        responseMock = new Mock(HttpServletResponse.class);
View Full Code Here

        //add
        pkgCfg.addActionConfig(actionName, actionConfig.build());

        //check if an action with the same name exists on that package (from XML config probably)
        PackageConfig existingPkg = configuration.getPackageConfig(pkgCfg.getName());
        if (existingPkg != null) {
            // there is a package already with that name, check action
            ActionConfig existingActionConfig = existingPkg.getActionConfigs().get(actionName);
            if (existingActionConfig != null && LOG.isWarnEnabled())
                LOG.warn("Duplicated action definition in package [#0] with name [#1].", pkgCfg.getName(), actionName);
        }

        //watch class file
View Full Code Here

        if (parentName == null) {
            throw new ConfigurationException("Unable to determine the parent XWork package for the action class [" +
                    actionClass.getName() + "]");
        }

        PackageConfig parentPkg = configuration.getPackageConfig(parentName);
        if (parentPkg == null) {
            throw new ConfigurationException("Unable to locate parent package [" + parentName + "]");
        }

        // Grab based on package-namespace and if it exists, we need to ensure the existing one has
        // the correct parent package. If not, we need to create a new package config
        String name = actionPackage + "#" + parentPkg.getName() + "#" + actionNamespace;
        PackageConfig.Builder pkgConfig = packageConfigs.get(name);
        if (pkgConfig == null) {
            pkgConfig = new PackageConfig.Builder(name).namespace(actionNamespace).addParent(parentPkg);
            packageConfigs.put(name, pkgConfig);
View Full Code Here

       
        InterceptorMapping interceptorMapping = new InterceptorMapping("test", (Interceptor) mockInterceptor.proxy());
       
        InterceptorStackConfig isc = new InterceptorStackConfig.Builder("test").addInterceptor(interceptorMapping).build();
       
        PackageConfig packageConfig = new PackageConfig.Builder("test").addInterceptorStackConfig(isc).build();
       
        Map<String, PackageConfig> packageConfigs = new HashMap<String, PackageConfig>();
        packageConfigs.put("test", packageConfig);
       
        Mock mockContainer = new Mock(Container.class);
View Full Code Here

    public Container getContainer() {
        return container;
    }

    public void addPackageConfig(String name, PackageConfig packageContext) {
        PackageConfig check = packageContexts.get(name);
        if (check != null) {
            if (check.getLocation() != null && packageContext.getLocation() != null
                    && check.getLocation().equals(packageContext.getLocation())) {
                if (LOG.isDebugEnabled()) {
                    LOG.debug("The package name '" + name
                    + "' is already been loaded by the same location and could be removed: "
                    + packageContext.getLocation());
                }
            } else {
                throw new ConfigurationException("The package name '" + name
                        + "' at location "+packageContext.getLocation()
                        + " is already been used by another package at location " + check.getLocation(),
                        packageContext);
            }
        }
        packageContexts.put(name, packageContext);
    }
View Full Code Here

        }

        Annotation annotation = cls.getAnnotation(ParentPackage.class);
        if (annotation != null) {
            String parent = ((ParentPackage)annotation).value();
            PackageConfig parentPkg = configuration.getPackageConfig(parent);
            if (parentPkg == null) {
                throw new ConfigurationException("ClasspathPackageProvider: Unable to locate parent package "+parent, annotation);
            }
            pkgConfig.addParent(parentPkg);

            if (!TextUtils.stringSet(pkgConfig.getNamespace()) && TextUtils.stringSet(parentPkg.getNamespace())) {
                pkgConfig.namespace(parentPkg.getNamespace());
            }
        }

        ResultTypeConfig defaultResultType = packageLoader.getDefaultResultType(pkgConfig);
        ActionConfig actionConfig = new ActionConfig.Builder(actionPackage, actionName, cls.getName())
View Full Code Here

        if (pkgConfig == null) {
            pkgConfig = new PackageConfig.Builder(actionPackage);

            pkgConfig.namespace(actionNamespace);
            if (parent == null) {
                PackageConfig cfg = configuration.getPackageConfig(defaultParentPackage);
                if (cfg != null) {
                    pkgConfig.addParent(cfg);
                } else {
                    throw new ConfigurationException("ClasspathPackageProvider: Unable to locate default parent package: " +
                        defaultParentPackage);
View Full Code Here

            Map<String, PackageConfig> configs = new HashMap<String, PackageConfig>();

            Set<PackageConfig.Builder> builders;
            while ((builders = findPackagesWithNoParents()).size() > 0) {
                for (PackageConfig.Builder parent : builders) {
                    PackageConfig config = parent.build();
                    configs.put(config.getName(), config);
                    packageConfigBuilders.remove(config.getName());

                    for (Iterator<Map.Entry<PackageConfig.Builder,PackageConfig.Builder>> i = childToParent.entrySet().iterator(); i.hasNext(); ) {
                        Map.Entry<PackageConfig.Builder,PackageConfig.Builder> entry = i.next();
                        if (entry.getValue() == parent) {
                            entry.getKey().addParent(config);
View Full Code Here

    public void setUp() throws Exception {
        provider = new ClasspathPackageProvider();
        provider.setActionPackages("org.apache.struts2.config");
        config = new DefaultConfiguration();
        PackageConfig strutsDefault = new PackageConfig.Builder("struts-default")
                .addResultTypeConfig(new ResultTypeConfig.Builder("dispatcher", ServletDispatcherResult.class.getName())
                        .defaultResultParam("location")
                        .build())
                .defaultResultType("dispatcher")
                .build();
        config.addPackageConfig("struts-default", strutsDefault);
        PackageConfig customPackage = new PackageConfig.Builder("custom-package")
            .namespace("/custom")
            .build();
        config.addPackageConfig("custom-package", customPackage);
        provider.init(config);
        provider.loadPackages();
View Full Code Here

TOP

Related Classes of com.opensymphony.xwork2.config.entities.PackageConfig

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.