Package com.opensymphony.xwork2.config.entities

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


        assertEquals(1, acfg.getResults().size());
        assertEquals("input-parent.jsp", acfg.getResults().get("input").getParams().get("location"));
    }

    public void testActionImplementation() {
        PackageConfig pkg = config.getPackageConfig("org.apache.struts2.config.cltest");
        assertEquals("/cltest", pkg.getNamespace());
        ActionConfig acfg = pkg.getActionConfigs().get("actionImpl");
        assertNotNull(acfg);
    }
View Full Code Here


        req.setMethod("GET");

        mapper = new RestActionMapper();

        config = new DefaultConfiguration();
        PackageConfig pkg = new PackageConfig.Builder("myns").namespace("/animals").build();
        PackageConfig pkg2 = new PackageConfig.Builder("my").namespace("/my").build();
        config.addPackageConfig("mvns", pkg);
        config.addPackageConfig("my", pkg2);
        configManager = new ConfigurationManager() {
            public Configuration getConfiguration() {
                return config;
View Full Code Here

    /**
     * Test the creation of a Struts 1.x ActionMapping wrapper around an XWork ActionConfig.
     * The ActionConfig is loaded from test-struts-factory.xml.
     */
    public void testCreateActionMapping() {
        PackageConfig packageConfig = configuration.getPackageConfig(PACKAGE_NAME);
        com.opensymphony.xwork2.config.entities.ActionConfig actionConfig =
                (com.opensymphony.xwork2.config.entities.ActionConfig) packageConfig.getActionConfigs().get("action1");
        ActionMapping mapping = factory.createActionMapping(actionConfig);
        assertNotNull(mapping);

        assertNotNull(mapping.findForward("result1"));
        assertNotNull(mapping.findForwardConfig("result2"));
View Full Code Here

    /**
     * Test the creation of a Struts 1.x ActionForward wrapper around an XWork ResultConfig.
     * The ResultConfig is loaded from test-struts-factory.xml.
     */
    public void testCreateActionForward() {
        PackageConfig packageConfig = configuration.getPackageConfig(PACKAGE_NAME);
        ResultConfig resultConfig = (ResultConfig) packageConfig.getGlobalResultConfigs().get("globalResult");
        ActionForward fwd = factory.createActionForward(resultConfig);
        assertNotNull(fwd);
        assertEquals("globalResult", fwd.getName());
       
        // These methods are currently not implemented -- replace as functionality is added.
View Full Code Here

    /**
     * Test the creation of a Struts 1.x ExceptionConfig wrapper around an XWork ExceptionHandlerConfig.
     * The ExceptionConfig is loaded from test-struts-factory.xml.
     */
    public void testCreateExceptionConfig() {
        PackageConfig packageConfig = configuration.getPackageConfig(PACKAGE_NAME);
        ExceptionMappingConfig cfg = (ExceptionMappingConfig) packageConfig.getGlobalExceptionMappingConfigs().get(0);
        ExceptionConfig exceptionConfig = factory.createExceptionConfig(cfg);
        assertNotNull(exceptionConfig);
        assertEquals(Exception.class.getName(), exceptionConfig.getType());

        assertNYI(exceptionConfig, "getBundle", null);
View Full Code Here

                                    @Inject Configuration configuration) {

        this.configuration = configuration;
        this.defaultPackageName = defaultPackage;
        resultsByExtension = new LinkedHashMap<String,ResultTypeConfig>();
        PackageConfig parentPackage = configuration.getPackageConfig(defaultPackageName);
        if (parentPackage == null) {
            throw new ConfigurationException("Unknown parent package: "+parentPackage);
        }   
        Map<String,ResultTypeConfig> results = parentPackage.getAllResultTypeConfigs();
       
        resultsByExtension.put("jsp", results.get("dispatcher"));
        resultsByExtension.put("vm", results.get("velocity"));
        resultsByExtension.put("ftl", results.get("freemarker"));
      
View Full Code Here

        return actionConfig;
    }

    /** Create a new ActionConfig in the default package, with the default interceptor stack and a single result */
    protected ActionConfig buildActionConfig(String path, String namespace, String actionName, ResultTypeConfig resultTypeConfig) {
        final PackageConfig pkg = configuration.getPackageConfig(defaultPackageName);
        return new ActionConfig.Builder(defaultPackageName, "execute", pkg.getDefaultClassRef())
                .addInterceptors(InterceptorBuilder.constructInterceptorReference(new InterceptorLocator() {
                    public Object getInterceptorConfig(String name) {
                        return pkg.getAllInterceptorConfigs().get(name); // recurse package hiearchy
                    }
                }, pkg.getFullDefaultInterceptorRef(),
                Collections.EMPTY_MAP, null, objectFactory))
                .addResultConfig(new ResultConfig.Builder(Action.SUCCESS, resultTypeConfig.getClassName())
                        .addParams(resultTypeConfig.getParams())
                        .addParam(resultTypeConfig.getDefaultResultParam(), path)
                        .build())
View Full Code Here

    public Result handleUnknownResult(ActionContext actionContext, String actionName,
            ActionConfig actionConfig, String resultCode) throws XWorkException {
       
        Result result = null;
        PackageConfig pkg = configuration.getPackageConfig(actionConfig.getPackageName());
        String ns = pkg.getNamespace();
        String pathPrefix = determinePath(templatePathPrefix, ns);

        for (String ext : resultsByExtension.keySet()) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Trying to locate result with extension ."+ext+" in directory "+pathPrefix);
View Full Code Here

                actionConfig = configuration.getRuntimeConfiguration().getActionConfig(redirectNamespace, "index");
                if (actionConfig != null) {
                    if (LOG.isTraceEnabled())
                        LOG.trace("Found action config");

                    PackageConfig packageConfig = configuration.getPackageConfig(actionConfig.getPackageName());
                    if (redirectNamespace.equals(packageConfig.getNamespace())) {
                        if (LOG.isTraceEnabled())
                            LOG.trace("Action is not a default - redirecting");
                        return buildActionConfig(redirectNamespace + "/", redirectResultTypeConfig);
                    }
View Full Code Here

        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.EMPTY_MAP, 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()).
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.