Search in sources :

Example 1 with FakeHttpServletRequest

use of org.directwebremoting.util.FakeHttpServletRequest in project ma-core-public by infiniteautomation.

the class StrutsCreator method getType.

/* (non-Javadoc)
     * @see org.directwebremoting.Creator#getType()
     */
public Class getType() {
    synchronized (this) {
        if (moduleConfig == null) {
            WebContext wc = WebContextFactory.get();
            if (getInstanceMethod != null) {
                try {
                    // ModuleUtils utils = ModuleUtils.getInstance();
                    Object utils = getInstanceMethod.invoke(null, new Object[0]);
                    // String moduleName = utils.getModuleName("/", wc.getServletContext());
                    String moduleName = (String) getModuleNameMethod.invoke(utils, new Object[] { "/", wc.getServletContext() });
                    // moduleConfig = utils.getModuleConfig(moduleName, wc.getServletContext());
                    moduleConfig = (ModuleConfig) getModuleConfigMethod.invoke(utils, new Object[] { moduleName, wc.getServletContext() });
                } catch (Exception ex) {
                    throw new IllegalArgumentException(ex.getMessage());
                }
            } else {
                HttpServletRequest request = wc.getHttpServletRequest();
                if (request == null) {
                    log.warn("Using a FakeHttpServletRequest as part of setup");
                    request = new FakeHttpServletRequest();
                }
                moduleConfig = RequestUtils.getModuleConfig(request, wc.getServletContext());
            }
        }
    }
    try {
        return LocalUtil.classForName(moduleConfig.findFormBeanConfig(formBean).getType());
    } catch (ClassNotFoundException ex) {
        throw new IllegalArgumentException(Messages.getString("Creator.ClassNotFound", moduleConfig.findFormBeanConfig(formBean).getType()));
    }
}
Also used : FakeHttpServletRequest(org.directwebremoting.util.FakeHttpServletRequest) HttpServletRequest(javax.servlet.http.HttpServletRequest) FakeHttpServletRequest(org.directwebremoting.util.FakeHttpServletRequest) WebContext(org.directwebremoting.WebContext)

Aggregations

HttpServletRequest (javax.servlet.http.HttpServletRequest)1 WebContext (org.directwebremoting.WebContext)1 FakeHttpServletRequest (org.directwebremoting.util.FakeHttpServletRequest)1