use of org.eweb4j.mvc.Context in project eweb4j-framework by laiweiwei.
the class Lang method get.
public static Locale get() {
Locale locale = current.get();
if (locale == null) {
Context ctx = MVC.ctx();
if (ctx != null) {
HttpServletRequest req = ctx.getRequest();
HttpServletResponse res = ctx.getResponse();
if (req != null) {
resolve(req, res);
} else {
setDefaultLocale();
}
} else {
setDefaultLocale();
}
locale = current.get();
}
return locale;
}
use of org.eweb4j.mvc.Context in project eweb4j-framework by laiweiwei.
the class InterExecution method doIntercept.
private void doIntercept(InterConfigBean inter) throws Exception {
Object interceptor = null;
if ("singleton".equalsIgnoreCase(inter.getScope()))
interceptor = SingleBeanCache.get(inter.getClazz());
if (interceptor == null) {
interceptor = Thread.currentThread().getContextClassLoader().loadClass(inter.getClazz()).newInstance();
if ("singleton".equalsIgnoreCase(inter.getScope()))
SingleBeanCache.add(inter.getClazz(), interceptor);
}
ReflectUtil ru = new ReflectUtil(interceptor);
Method intercept = ru.getMethod(inter.getMethod());
if (intercept == null) {
this.error = null;
return;
}
Method setter = ru.getSetter("Context");
if (setter != null)
setter.invoke(interceptor, this.context);
Object err = null;
Class<?>[] paramCls = intercept.getParameterTypes();
if (paramCls.length == 1 && paramCls[0].isAssignableFrom(Context.class))
err = intercept.invoke(interceptor, this.context);
else
err = intercept.invoke(interceptor);
if (err == null) {
this.error = null;
return;
}
this.error = String.valueOf(err);
}
Aggregations