Package com.opensymphony.xwork2.inject

Examples of com.opensymphony.xwork2.inject.Container


            // This fix allow initialization of ActionContext.getContext() to avoid NPE

            ConfigurationManager configurationManager = new ConfigurationManager();
            configurationManager.addContainerProvider( new XWorkConfigurationProvider() );
            com.opensymphony.xwork2.config.Configuration config = configurationManager.getConfiguration();
            Container container = config.getContainer();

            ValueStack stack = container.getInstance( ValueStackFactory.class ).createValueStack();
            stack.getContext().put( ActionContext.CONTAINER, container );
            ActionContext.setContext( new ActionContext( stack.getContext() ) );
        }

        boolean checkProtocol = true;
View Full Code Here


            // This fix allow initialization of ActionContext.getContext() to avoid NPE

            ConfigurationManager configurationManager = new ConfigurationManager();
            configurationManager.addContainerProvider( new XWorkConfigurationProvider() );
            com.opensymphony.xwork2.config.Configuration config = configurationManager.getConfiguration();
            Container container = config.getContainer();

            ValueStack stack = container.getInstance( ValueStackFactory.class ).createValueStack();
            stack.getContext().put( ActionContext.CONTAINER, container );
            ActionContext.setContext( new ActionContext( stack.getContext() ) );

            assertNotNull( ActionContext.getContext() );
        }
View Full Code Here

     * cause action submited by the form is intercepted by validation interceptor which
     * "include" all methods.
     */
    public void testFormWithCustomOnsubmitEnabledWithValidateEnabled1() throws Exception {

        final Container cont = container;
        // used to determined if the form action needs js validation
        configurationManager.setConfiguration(new com.opensymphony.xwork2.config.impl.DefaultConfiguration() {
            private DefaultConfiguration self = this;
            public Container getContainer() {
                return new Container() {
                    public <T> T inject(Class<T> implementation) {return null;}
                    public void removeScopeStrategy() {}
                    public void setScopeStrategy(Strategy scopeStrategy) {}
                    public <T> T getInstance(Class<T> type, String name) {return null;}
                    public <T> T getInstance(Class<T> type) {return null;}
                    public Set<String> getInstanceNames(Class<?> type) {return null;}

                    public void inject(Object o) {
                        cont.inject(o);
                        if (o instanceof Form) {
                            ((Form)o).setConfiguration(self);
                        }
                    }
                };
View Full Code Here

    public void testFormWithCustomOnsubmitEnabledWithValidateEnabled2() throws Exception {

        com.opensymphony.xwork2.config.Configuration originalConfiguration = configurationManager.getConfiguration();
        ObjectFactory originalObjectFactory = ObjectFactory.getObjectFactory();

        final Container cont = container;
        try {
            // used to determined if the form action needs js validation
            configurationManager.setConfiguration(new DefaultConfiguration() {
                private DefaultConfiguration self = this;
                public Container getContainer() {
                    return new Container() {
                        public <T> T inject(Class<T> implementation) {return null;}
                        public void removeScopeStrategy() {}
                        public void setScopeStrategy(Strategy scopeStrategy) {}
                        public <T> T getInstance(Class<T> type, String name) {return null;}
                        public <T> T getInstance(Class<T> type) {return null;}
                        public Set<String> getInstanceNames(Class<?> type) {return null;}

                        public void inject(Object o) {
                            cont.inject(o);
                            if (o instanceof Form) {
                                ((Form)o).setConfiguration(self);
                            }
                        }
                    };
View Full Code Here

    /**
     * Tests the numbers are formatted correctly to not break the javascript
     */
    public void testFormWithCustomOnsubmitEnabledWithValidateEnabled3() throws Exception {

        final Container cont = container;
        // used to determined if the form action needs js validation
        configurationManager.setConfiguration(new com.opensymphony.xwork2.config.impl.DefaultConfiguration() {
            private DefaultConfiguration self = this;
            public Container getContainer() {
                return new Container() {
                    public <T> T inject(Class<T> implementation) {return null;}
                    public void removeScopeStrategy() {}
                    public void setScopeStrategy(Strategy scopeStrategy) {}
                    public <T> T getInstance(Class<T> type, String name) {return null;}
                    public <T> T getInstance(Class<T> type) {return null;}
                    public Set<String> getInstanceNames(Class<?> type) {return null;}

                    public void inject(Object o) {
                        cont.inject(o);
                        if (o instanceof Form) {
                            ((Form)o).setConfiguration(self);
                        }
                    }
                };
View Full Code Here

        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

        init_LegacyStrutsProperties(); // [3]
        init_CustomConfigurationProviders(); // [5]
        init_FilterInitParameters() ; // [6]
        init_AliasStandardObjects() ; // [7]

        Container container = init_PreloadConfiguration();
        container.inject(this);
        init_CheckConfigurationReloading(container);
        init_CheckWebLogicWorkaround(container);

        if (!dispatcherListeners.isEmpty()) {
            for (DispatcherListener l : dispatcherListeners) {
View Full Code Here

        // get the bean
        ValueStack stack = (ValueStack) ctx.get("stack");
        HttpServletRequest req = (HttpServletRequest) stack.getContext().get(ServletActionContext.HTTP_REQUEST);
        HttpServletResponse res = (HttpServletResponse) stack.getContext().get(ServletActionContext.HTTP_RESPONSE);
        Component bean = getBean(stack, req, res);
        Container container = (Container) stack.getContext().get(ActionContext.CONTAINER);
        container.inject(bean);
        // get the parameters
        Map params = createPropertyMap(ctx, node);
        bean.copyParams(params);
        //bean.addAllParameters(params);
        bean.start(writer);
View Full Code Here

        EasyMock.expect(request.getContextPath()).andReturn("/some/path").anyTimes();
        response = EasyMock.createNiceMock(HttpServletResponse.class);

        EasyMock.expect(stack.getContext()).andReturn(stackContext).anyTimes();

        Container container = EasyMock.createNiceMock(Container.class);
        XWorkConverter converter = new ConverterEx();
        EasyMock.expect(container.getInstance(String.class, StrutsConstants.STRUTS_TAG_ALTSYNTAX)).andReturn("true").anyTimes();
        EasyMock.expect(container.getInstance(XWorkConverter.class)).andReturn(converter).anyTimes();
        stackContext.put(ActionContext.CONTAINER, container);


        EasyMock.replay(request);
        EasyMock.replay(stack);
View Full Code Here

        EasyMock.expect(request.getContextPath()).andReturn("/some/path").anyTimes();
        response = EasyMock.createNiceMock(HttpServletResponse.class);

        EasyMock.expect(stack.getContext()).andReturn(stackContext).anyTimes();

        Container container = EasyMock.createNiceMock(Container.class);
        XWorkConverter converter = new ConverterEx();
        EasyMock.expect(container.getInstance(String.class, StrutsConstants.STRUTS_TAG_ALTSYNTAX)).andReturn("true").anyTimes();
        EasyMock.expect(container.getInstance(XWorkConverter.class)).andReturn(converter).anyTimes();
        stackContext.put(ActionContext.CONTAINER, container);


        EasyMock.replay(request);
        EasyMock.replay(stack);
View Full Code Here

TOP

Related Classes of com.opensymphony.xwork2.inject.Container

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.