Search in sources :

Example 1 with Container

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

the class UrlFunction method url.

public static String url(String value) {
    Dispatcher instance = Dispatcher.getInstance();
    if (instance == null)
        return null;
    Container container = instance.getContainer();
    UrlFunction function = new UrlFunction();
    container.inject(function);
    return function.getUrl(value);
}
Also used : Container(com.opensymphony.xwork2.inject.Container) Dispatcher(org.apache.struts2.dispatcher.Dispatcher)

Example 2 with Container

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

the class ResourceUrlFunction method resource.

public static String resource(String resourcePath) {
    Dispatcher instance = Dispatcher.getInstance();
    if (instance == null)
        return null;
    Container container = instance.getContainer();
    ResourceUrlFunction function = new ResourceUrlFunction();
    container.inject(function);
    return function.getExternalUrlForResource(resourcePath);
}
Also used : Container(com.opensymphony.xwork2.inject.Container) Dispatcher(org.apache.struts2.dispatcher.Dispatcher)

Example 3 with Container

use of com.opensymphony.xwork2.inject.Container in project entando-core by entando.

the class PrepareOperations method findActionMapping.

@Override
public ActionMapping findActionMapping(HttpServletRequest request, HttpServletResponse response, boolean forceLookup) {
    ActionMapping mapping = (ActionMapping) request.getAttribute(STRUTS_ACTION_MAPPING_KEY);
    if (mapping == null || forceLookup) {
        try {
            Container container = this._dispatcher.getContainer();
            ActionMapper mapper = container.getInstance(ActionMapper.class);
            String entandoActionName = EntandoActionUtils.extractEntandoActionName(request);
            mapping = mapper.getMapping(request, this._dispatcher.getConfigurationManager());
            if (null != entandoActionName) {
                mapping.setName(entandoActionName);
            }
            if (mapping != null) {
                request.setAttribute(STRUTS_ACTION_MAPPING_KEY, mapping);
            }
        } catch (Exception ex) {
            this._dispatcher.sendError(request, response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, ex);
        }
    }
    return mapping;
}
Also used : ActionMapping(org.apache.struts2.dispatcher.mapper.ActionMapping) Container(com.opensymphony.xwork2.inject.Container) ActionMapper(org.apache.struts2.dispatcher.mapper.ActionMapper)

Example 4 with Container

use of com.opensymphony.xwork2.inject.Container in project entando-core by entando.

the class PluginsSubMenuTag method doStartTag.

@Override
public int doStartTag() throws JspException {
    HttpServletRequest request = (HttpServletRequest) this.pageContext.getRequest();
    WebApplicationContext wac = ApsWebApplicationUtils.getWebApplicationContext(request);
    List<PluginSubMenuContainer> containters = new ArrayList<PluginSubMenuContainer>();
    ValueStack stack = this.getStack();
    try {
        String[] beanNames = wac.getBeanNamesForType(PluginSubMenuContainer.class);
        for (int i = 0; i < beanNames.length; i++) {
            PluginSubMenuContainer container = (PluginSubMenuContainer) wac.getBean(beanNames[i]);
            containters.add(container);
        }
        if (containters.size() > 0) {
            stack.getContext().put(this.getObjectName(), containters);
            stack.setValue("#attr['" + this.getObjectName() + "']", containters, false);
            return EVAL_BODY_INCLUDE;
        }
    } catch (Throwable t) {
        throw new JspException("Error creating the plugins menu list", t);
    }
    return super.doStartTag();
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) JspException(javax.servlet.jsp.JspException) ValueStack(com.opensymphony.xwork2.util.ValueStack) ArrayList(java.util.ArrayList) PluginSubMenuContainer(com.agiletec.apsadmin.system.plugin.PluginSubMenuContainer) WebApplicationContext(org.springframework.web.context.WebApplicationContext)

Example 5 with Container

use of com.opensymphony.xwork2.inject.Container in project entando-core by entando.

the class ApsAdminBaseTestCase method createContainer.

protected Container createContainer() {
    ContainerBuilder builder = new ContainerBuilder();
    builder.constant("devMode", "false");
    return builder.create(true);
}
Also used : ContainerBuilder(com.opensymphony.xwork2.inject.ContainerBuilder)

Aggregations

Container (com.opensymphony.xwork2.inject.Container)4 Dispatcher (org.apache.struts2.dispatcher.Dispatcher)3 PluginSubMenuContainer (com.agiletec.apsadmin.system.plugin.PluginSubMenuContainer)1 ContainerBuilder (com.opensymphony.xwork2.inject.ContainerBuilder)1 ValueStack (com.opensymphony.xwork2.util.ValueStack)1 ArrayList (java.util.ArrayList)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 JspException (javax.servlet.jsp.JspException)1 ActionMapper (org.apache.struts2.dispatcher.mapper.ActionMapper)1 ActionMapping (org.apache.struts2.dispatcher.mapper.ActionMapping)1 WebApplicationContext (org.springframework.web.context.WebApplicationContext)1