Package com.opensymphony.xwork2.inject

Examples of com.opensymphony.xwork2.inject.ContainerBuilder


    private Container container;
    protected List<UnknownHandlerConfig> unknownHandlerStack;
    private ContainerBuilder builder;

    public MockConfiguration() {
        builder = new ContainerBuilder();
    }
View Full Code Here


*/
public class LegacyPropertiesConfigurationProviderTest extends TestCase {

    public void testRegister_DifferentLocale() {

        ContainerBuilder builder = new ContainerBuilder();
        builder.constant("foo", "bar");
        builder.constant("struts.locale", "DE_de");

        LegacyPropertiesConfigurationProvider prov = new LegacyPropertiesConfigurationProvider();
        prov.register(builder, new LocatableProperties());

        Container container = builder.create(true);

        Locale locale = container.getInstance(Locale.class);

        assertNotNull(locale);
        assertEquals("DE", locale.getCountry());
View Full Code Here

    }

    public void testRegister_NoLocale() {

        ContainerBuilder builder = new ContainerBuilder();
        builder.constant("foo", "bar");

        LegacyPropertiesConfigurationProvider prov = new LegacyPropertiesConfigurationProvider();
        prov.register(builder, new LocatableProperties());

        Container container = builder.create(true);

        Locale locale = container.getInstance(Locale.class);

        assertNotNull(locale);
        Locale vmLocale = Locale.getDefault();
View Full Code Here

        assertEquals("The form has already been processed or no token was supplied, please try again.", LocalizedTextUtil.findDefaultText("struts.messages.invalid.token", Locale.getDefault()));
       
        LocatableProperties props = new LocatableProperties();
        props.setProperty(StrutsConstants.STRUTS_CUSTOM_I18N_RESOURCES, "testmessages,testmessages2");
       
        new BeanSelectionProvider().register(new ContainerBuilder(), props);

        assertEquals("Replaced message for token tag", LocalizedTextUtil.findDefaultText("struts.messages.invalid.token", Locale.getDefault()));
    }
View Full Code Here

        final InnerDestroyableObjectFactory destroyedObjectFactory = new InnerDestroyableObjectFactory();
        FilterDispatcher filterDispatcher = new FilterDispatcher() {
            @Override
            protected Dispatcher createDispatcher(FilterConfig cfg) {
                return new Dispatcher(cfg.getServletContext(), new HashMap()) {
                    Container cont = new ContainerBuilder()
                        .factory(ObjectFactory.class, new Factory() {
                            public Object create(Context context) throws Exception { return destroyedObjectFactory; }
                        })
                        .create(false);
                   
View Full Code Here

        Dispatcher.setInstance(null);

        DefaultConfiguration conf = new DefaultConfiguration() {
          @Override
          public Container getContainer() {
            return new ContainerBuilder().create(false);
          }
        };
      
        ConfigurationManager confManager = new ConfigurationManager();
        confManager.setConfiguration(conf);
View Full Code Here

        packageContexts.clear();
        loadedFileNames.clear();
        List<PackageProvider> packageProviders = new ArrayList<PackageProvider>();

        ContainerProperties props = new ContainerProperties();
        ContainerBuilder builder = new ContainerBuilder();
        for (final ContainerProvider containerProvider : providers)
        {
            containerProvider.init(this);
            containerProvider.register(builder, props);
        }
        props.setConstants(builder);

        builder.factory(Configuration.class, new Factory<Configuration>() {
            public Configuration create(Context context) throws Exception {
                return DefaultConfiguration.this;
            }
        });

        ActionContext oldContext = ActionContext.getContext();
        try {
            // Set the bootstrap container for the purposes of factory creation
            Container bootstrap = createBootstrapContainer();
            setContext(bootstrap);
            container = builder.create(false);
            setContext(container);
            objectFactory = container.getInstance(ObjectFactory.class);

            // Process the configuration providers first
            for (final ContainerProvider containerProvider : providers)
View Full Code Here

        }
        return context;
    }

    protected Container createBootstrapContainer() {
        ContainerBuilder builder = new ContainerBuilder();
        builder.factory(ObjectFactory.class, Scope.SINGLETON);
        builder.factory(ReflectionProvider.class, OgnlReflectionProvider.class, Scope.SINGLETON);
        builder.factory(ValueStackFactory.class, OgnlValueStackFactory.class, Scope.SINGLETON);
        builder.factory(XWorkConverter.class, Scope.SINGLETON);
        builder.factory(XWorkBasicConverter.class, Scope.SINGLETON);
        builder.factory(TypeConverter.class, "collection",  CollectionConverter.class, Scope.SINGLETON);
        builder.factory(TypeConverter.class, "array", ArrayConverter.class, Scope.SINGLETON);
        builder.factory(TypeConverter.class, "date", DateConverter.class, Scope.SINGLETON);
        builder.factory(TypeConverter.class, "number",  NumberConverter.class, Scope.SINGLETON);
        builder.factory(TypeConverter.class, "string", StringConverter.class, Scope.SINGLETON);
        builder.factory(TextProvider.class, "system", DefaultTextProvider.class, Scope.SINGLETON);
        builder.factory(ObjectTypeDeterminer.class, DefaultObjectTypeDeterminer.class, Scope.SINGLETON);
        builder.factory(PropertyAccessor.class, CompoundRoot.class.getName(), CompoundRootAccessor.class, Scope.SINGLETON);
        builder.factory(OgnlUtil.class, Scope.SINGLETON);
        builder.constant("devMode", "false");
        builder.constant("logMissingProperties", "false");
        return builder.create(true);
    }
View Full Code Here

       
        LocatableProperties props = new LocatableProperties();
        props.setProperty(StrutsConstants.STRUTS_CUSTOM_I18N_RESOURCES, "testmessages,testmessages2");
        props.setProperty(StrutsConstants.STRUTS_LOCALE, "US");
       
        new DefaultBeanSelectionProvider().register(new ContainerBuilder(), props);

        assertEquals("Replaced message for token tag", LocalizedTextUtil.findDefaultText("struts.messages.invalid.token", Locale.getDefault()));
    }
View Full Code Here

        packageContexts.clear();
        loadedFileNames.clear();
        List<PackageProvider> packageProviders = new ArrayList<PackageProvider>();

        ContainerProperties props = new ContainerProperties();
        ContainerBuilder builder = new ContainerBuilder();
        Container bootstrap = createBootstrapContainer(providers);
        for (final ContainerProvider containerProvider : providers)
        {
            bootstrap.inject(containerProvider);
            containerProvider.init(this);
            containerProvider.register(builder, props);
        }
        props.setConstants(builder);

        builder.factory(Configuration.class, new Factory<Configuration>() {
            public Configuration create(Context context) throws Exception {
                return DefaultConfiguration.this;
            }
        });

        ActionContext oldContext = ActionContext.getContext();
        try {
            // Set the bootstrap container for the purposes of factory creation

            setContext(bootstrap);
            container = builder.create(false);
            setContext(container);
            objectFactory = container.getInstance(ObjectFactory.class);

            // Process the configuration providers first
            for (final ContainerProvider containerProvider : providers)
View Full Code Here

TOP

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

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.