Search in sources :

Example 1 with Inject

use of com.opensymphony.xwork2.inject.Inject in project onebusaway-application-modules by camsys.

the class ResourceUrlFunction method setServletContext.

@Inject(required = true)
public void setServletContext(ServletContext servletContext) {
    WebApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(servletContext);
    context.getAutowireCapableBeanFactory().autowireBean(this);
}
Also used : WebApplicationContext(org.springframework.web.context.WebApplicationContext) Inject(com.opensymphony.xwork2.inject.Inject)

Example 2 with Inject

use of com.opensymphony.xwork2.inject.Inject in project onebusaway-application-modules by camsys.

the class MultiActionProxyFactory method setActionMappers.

@Inject(MAPPINGS)
public void setActionMappers(String list) {
    if (list != null) {
        String[] tokens = list.split(",");
        for (String token : tokens) {
            String[] kvp = token.split("=");
            String key = kvp[0];
            String name = kvp[1];
            ActionProxyFactory factory = container.getInstance(ActionProxyFactory.class, name);
            if (factory != null) {
                _prefixedActionProxyFactories.add(new Prefixed<ActionProxyFactory>(key, factory));
            } else {
                throw new IllegalStateException("unknown ActionProxyFactory " + name);
            }
        }
    }
}
Also used : ActionProxyFactory(com.opensymphony.xwork2.ActionProxyFactory) DefaultActionProxyFactory(com.opensymphony.xwork2.DefaultActionProxyFactory) Inject(com.opensymphony.xwork2.inject.Inject)

Example 3 with Inject

use of com.opensymphony.xwork2.inject.Inject in project onebusaway-application-modules by camsys.

the class ConfigurationValueFunction method setServletContext.

@Inject(required = true)
public void setServletContext(ServletContext servletContext) {
    WebApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(servletContext);
    context.getAutowireCapableBeanFactory().autowireBean(this);
}
Also used : WebApplicationContext(org.springframework.web.context.WebApplicationContext) Inject(com.opensymphony.xwork2.inject.Inject)

Example 4 with Inject

use of com.opensymphony.xwork2.inject.Inject in project onebusaway-application-modules by camsys.

the class SpringContainer method register.

@Override
public void register(ContainerBuilder builder, LocatableProperties props) throws ConfigurationException {
    // Since we're about to override...
    builder.setAllowDuplicates(true);
    builder.factory(ObjectFactory.class, new Factory<ObjectFactory>() {

        public ObjectFactory create(Context xworkContext) throws Exception {
            SpringObjectFactory f = new SpringObjectFactory();
            xworkContext.getContainer().inject(f);
            f.setApplicationContext(_applicationContext);
            f.setAutowireStrategy(_autoWireStrategy);
            return f;
        }
    });
}
Also used : Context(com.opensymphony.xwork2.inject.Context) ApplicationContext(org.springframework.context.ApplicationContext) SpringObjectFactory(com.opensymphony.xwork2.spring.SpringObjectFactory) SpringObjectFactory(com.opensymphony.xwork2.spring.SpringObjectFactory) ObjectFactory(com.opensymphony.xwork2.ObjectFactory) ConfigurationException(com.opensymphony.xwork2.config.ConfigurationException)

Example 5 with Inject

use of com.opensymphony.xwork2.inject.Inject in project onebusaway-application-modules by camsys.

the class MultiActionMapper method setActionMappers.

@Inject(MAPPINGS)
public void setActionMappers(String list) {
    if (list != null) {
        String[] tokens = list.split(",");
        for (String token : tokens) {
            String[] kvp = token.split("=");
            String key = kvp[0];
            String name = kvp[1];
            ActionMapper mapper = container.getInstance(ActionMapper.class, name);
            if (mapper != null) {
                _prefixedActionMappers.add(new Prefixed<ActionMapper>(key, mapper));
            } else {
                throw new IllegalStateException("unknown ActionMapper " + name);
            }
        }
    }
}
Also used : DefaultActionMapper(org.apache.struts2.dispatcher.mapper.DefaultActionMapper) ActionMapper(org.apache.struts2.dispatcher.mapper.ActionMapper) Inject(com.opensymphony.xwork2.inject.Inject)

Aggregations

Inject (com.opensymphony.xwork2.inject.Inject)4 WebApplicationContext (org.springframework.web.context.WebApplicationContext)2 ActionProxyFactory (com.opensymphony.xwork2.ActionProxyFactory)1 DefaultActionProxyFactory (com.opensymphony.xwork2.DefaultActionProxyFactory)1 ObjectFactory (com.opensymphony.xwork2.ObjectFactory)1 ConfigurationException (com.opensymphony.xwork2.config.ConfigurationException)1 Context (com.opensymphony.xwork2.inject.Context)1 SpringObjectFactory (com.opensymphony.xwork2.spring.SpringObjectFactory)1 ActionMapper (org.apache.struts2.dispatcher.mapper.ActionMapper)1 DefaultActionMapper (org.apache.struts2.dispatcher.mapper.DefaultActionMapper)1 ApplicationContext (org.springframework.context.ApplicationContext)1