Search in sources :

Example 1 with HookPointElementContainer

use of com.agiletec.apsadmin.system.plugin.HookPointElementContainer in project entando-core by entando.

the class HookPointTag method extractElements.

private List<HookPointElementContainer> extractElements(HttpServletRequest request) {
    WebApplicationContext wac = ApsWebApplicationUtils.getWebApplicationContext(request);
    String[] beanNames = wac.getBeanNamesForType(HookPointElementContainer.class);
    List<HookPointElementContainer> containers = new ArrayList<HookPointElementContainer>();
    for (int i = 0; i < beanNames.length; i++) {
        HookPointElementContainer container = (HookPointElementContainer) wac.getBean(beanNames[i]);
        if (null != container && null != container.getHookPointKey() && container.getHookPointKey().equals(this.getKey())) {
            containers.add(container);
        }
    }
    BeanComparator comparator = new BeanComparator("priority");
    Collections.sort(containers, comparator);
    return containers;
}
Also used : ArrayList(java.util.ArrayList) BeanComparator(org.apache.commons.beanutils.BeanComparator) WebApplicationContext(org.springframework.web.context.WebApplicationContext) HookPointElementContainer(com.agiletec.apsadmin.system.plugin.HookPointElementContainer)

Example 2 with HookPointElementContainer

use of com.agiletec.apsadmin.system.plugin.HookPointElementContainer in project entando-core by entando.

the class HookPointTag method doStartTag.

@Override
public int doStartTag() throws JspException {
    HttpServletRequest request = (HttpServletRequest) this.pageContext.getRequest();
    ValueStack stack = this.getStack();
    try {
        List<HookPointElementContainer> containers = extractElements(request);
        if (containers.size() > 0) {
            stack.getContext().put(this.getObjectName(), containers);
            stack.setValue("#attr['" + this.getObjectName() + "']", containers, false);
            return EVAL_BODY_INCLUDE;
        }
    } catch (Throwable t) {
        throw new JspException("Error detected ", t);
    }
    return super.doStartTag();
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) JspException(javax.servlet.jsp.JspException) ValueStack(com.opensymphony.xwork2.util.ValueStack) HookPointElementContainer(com.agiletec.apsadmin.system.plugin.HookPointElementContainer)

Aggregations

HookPointElementContainer (com.agiletec.apsadmin.system.plugin.HookPointElementContainer)2 ValueStack (com.opensymphony.xwork2.util.ValueStack)1 ArrayList (java.util.ArrayList)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 JspException (javax.servlet.jsp.JspException)1 BeanComparator (org.apache.commons.beanutils.BeanComparator)1 WebApplicationContext (org.springframework.web.context.WebApplicationContext)1