use of jodd.madvoc.MadvocException in project jodd by oblac.
the class ActionsManager method register.
/**
* Registers action with provided action signature.
*/
public ActionConfig register(String actionSignature, ActionDef actionDef) {
int ndx = actionSignature.indexOf('#');
if (ndx == -1) {
throw new MadvocException("Madvoc action signature syntax error: " + actionSignature);
}
String actionClassName = actionSignature.substring(0, ndx);
String actionMethodName = actionSignature.substring(ndx + 1);
Class actionClass;
try {
actionClass = ClassLoaderUtil.loadClass(actionClassName);
} catch (ClassNotFoundException cnfex) {
throw new MadvocException("Madvoc action class not found: " + actionClassName, cnfex);
}
return register(actionClass, actionMethodName, actionDef);
}
use of jodd.madvoc.MadvocException in project jodd by oblac.
the class MadvocController method render.
// ---------------------------------------------------------------- render
/**
* Invokes a result after the action invocation.
* <p>
* Results may be objects that specify which action result will be used
* to render the result.
* <p>
* Result value may consist of two parts: type and value. Result type is optional and, if exists, it is separated
* by semi-colon from the value. If type is not specified
* then the default result type if still not defined. Result type defines which
* {@link ActionResult} should be used for rendering the value.
* <p>
* Result value is first checked against aliased values. Then, it is resolved and then passed
* to the founded {@link ActionResult}.
*
* @see ActionResult#render(jodd.madvoc.ActionRequest, Object)
*/
@SuppressWarnings("unchecked")
public void render(ActionRequest actionRequest, Object resultObject) throws Exception {
ActionResult actionResult = resultsManager.lookup(actionRequest, resultObject);
if (actionResult == null) {
throw new MadvocException("Action result not found");
}
if (madvocConfig.isPreventCaching()) {
ServletUtil.preventCaching(actionRequest.getHttpServletResponse());
}
actionResult.render(actionRequest, actionRequest.getActionResult());
}
use of jodd.madvoc.MadvocException in project jodd by oblac.
the class WrapperManager method expand.
/**
* Replaces all {@link #getDefaultWebAppWrapper()} with {@link #getDefaultWebAppWrapper()}
* and {@link BaseActionWrapperStack} with stack values.
*/
protected Class<? extends T>[] expand(Class<? extends T>[] actionWrappers) {
if (actionWrappers == null) {
return null;
}
List<Class<? extends T>> list = new ArrayList<>(actionWrappers.length);
list.addAll(Arrays.asList(actionWrappers));
int i = 0;
while (i < list.size()) {
Class<? extends T> wrapperClass = list.get(i);
if (wrapperClass == null) {
continue;
}
if (wrapperClass.equals(getDefaultWebAppWrapper())) {
list.remove(i);
// add default wrappers list
Class<? extends T>[] defaultWrappers = getDefaultWrappers();
if (defaultWrappers != null) {
int ndx = i;
for (Class<? extends T> defaultWrapper : defaultWrappers) {
// can't add default list stack to default list
if (defaultWrapper.equals(getDefaultWebAppWrapper())) {
throw new MadvocException("Default wrapper list is self-contained (cyclic dependency)!");
}
list.add(ndx, defaultWrapper);
ndx++;
}
}
continue;
}
if (ReflectUtil.isTypeOf(wrapperClass, BaseActionWrapperStack.class)) {
BaseActionWrapperStack stack = (BaseActionWrapperStack) resolve(wrapperClass);
list.remove(i);
Class<? extends T>[] stackWrappers = stack.getWrappers();
if (stackWrappers != null) {
list.addAll(i, Arrays.asList(stackWrappers));
}
i--;
//continue;
}
i++;
}
return list.toArray(new Class[list.size()]);
}
use of jodd.madvoc.MadvocException in project jodd by oblac.
the class ServletDispatcherResultWithJspp method processTarget.
@Override
protected String processTarget(ActionRequest actionRequest, String target) {
ServletContext servletContext = actionRequest.getHttpServletRequest().getServletContext();
String jspPath = servletContext.getRealPath(target);
if (jspPath == null) {
throw new MadvocException("Real path not found: " + target);
}
File jspFile = new File(jspPath);
File targetFile = new File(convertToNewName(jspPath));
target = convertToNewName(target);
if (!targetFile.exists() || FileUtil.isNewer(jspFile, targetFile)) {
if (log.isDebugEnabled()) {
log.debug("JSPP target: " + target);
}
if (jspp == null) {
jspp = createJspp(servletContext);
}
try {
preprocess(jspFile, targetFile);
} catch (IOException ioex) {
throw new JsppException(ioex);
}
} else {
if (log.isDebugEnabled()) {
log.debug("JSPP ok: " + target);
}
}
return target;
}
Aggregations