Browse Source

添加日志文件的配置,打印出所有错误信息到后台日志文件。

zzy.zhiyuan.foxmail 8 years ago
parent
commit
41fd0f28ea

+ 3 - 4
jfwAptWeb/src/main/java/org/jfw/apt/web/AptWebHandler.java

35
import org.jfw.apt.web.handlers.ValidateParamHandler;
35
import org.jfw.apt.web.handlers.ValidateParamHandler;
36
import org.jfw.apt.web.handlers.ViewHandler;
36
import org.jfw.apt.web.handlers.ViewHandler;
37
37
38
38
public class AptWebHandler extends CodeGenHandler {
39
public class AptWebHandler extends CodeGenHandler {
39
40
40
	private static List<Class<? extends RequestHandler>> supportedClass = new ArrayList<Class<? extends RequestHandler>>();
41
	private static List<Class<? extends RequestHandler>> supportedClass = new ArrayList<Class<? extends RequestHandler>>();
199
200
200
	@Override
201
	@Override
201
	public void proccess() throws AptException {
202
	public void proccess() throws AptException {
203
		this.out.bL("private static final  org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(");
204
		this.out.w(this.out.getClassname()).el(".class);");
202
		this.genInstanceVariable();
205
		this.genInstanceVariable();
203
		this.url = genUrl(this.url, ref);
206
		this.url = genUrl(this.url, ref);
204
		this.codes.clear();
207
		this.codes.clear();
207
		List<? extends Element> eles = ref.getEnclosedElements();
210
		List<? extends Element> eles = ref.getEnclosedElements();
208
		for (Element ele : eles) {
211
		for (Element ele : eles) {
209
			if (ele.getKind() == ElementKind.METHOD) {
212
			if (ele.getKind() == ElementKind.METHOD) {
210
211
				Path methodPath = ele.getAnnotation(Path.class);
213
				Path methodPath = ele.getAnnotation(Path.class);
212
				if (methodPath != null) {
214
				if (methodPath != null) {
213
					this.genRequestInfo(ele, methodPath.value());
215
					this.genRequestInfo(ele, methodPath.value());
216
					this.params = this.me.getParams();
218
					this.params = this.me.getParams();
217
					this.genCurrentMethodName();
219
					this.genCurrentMethodName();
218
					this.cleanConfig();
220
					this.cleanConfig();
219
220
					this.beginMethod();
221
					this.beginMethod();
221
					this.writeMethodContent();
222
					this.writeMethodContent();
222
					this.endMethod();
223
					this.endMethod();
223
				}
224
				}
224
225
			}
225
			}
226
		}
226
		}
227
227
229
			cpg.generate(this.out);
229
			cpg.generate(this.out);
230
		}
230
		}
231
		out.overClass();
231
		out.overClass();
232
233
		ClassBeanDefine cbd = this.jfwProccess.getBeanConfig()
232
		ClassBeanDefine cbd = this.jfwProccess.getBeanConfig()
234
				.addServiceBeanByClass(this.ref.getQualifiedName().toString(), null);
233
				.addServiceBeanByClass(this.ref.getQualifiedName().toString(), null);
235
		Util.buildAtuowrieProperty(cbd, this.ref);
234
		Util.buildAtuowrieProperty(cbd, this.ref);

+ 1 - 2
jfwAptWeb/src/main/java/org/jfw/apt/web/handlers/buildParam/SessionValHandler.java

39
		} else {
39
		} else {
40
			cw.bL(mpe.getTypeName()).w(" ").w(mpe.getName()).w(" = (").w(mpe.getTypeName())
40
			cw.bL(mpe.getTypeName()).w(" ").w(mpe.getName()).w(" = (").w(mpe.getTypeName())
41
					.w(")session.getAttribute(\"").w(val).el("\");");
41
					.w(")session.getAttribute(\"").w(val).el("\");");
42
42
                
43
				cw.bL("if(null==").w(mpe.getName()).el("){");
43
				cw.bL("if(null==").w(mpe.getName()).el("){");
44
				if(dv==null &&(null == mpe.getRef().getAnnotation(Nullable.class))){
44
				if(dv==null &&(null == mpe.getRef().getAnnotation(Nullable.class))){
45
					cw.l("throw new IllegalArgumentException(\"not found session value:" + val + "\");");
45
					cw.l("throw new IllegalArgumentException(\"not found session value:" + val + "\");");
46
				}else{
46
				}else{
47
					cw.bL(mpe.getName()).w(" = ").w(dv).el(";");
47
					cw.bL(mpe.getName()).w(" = ").w(dv).el(";");
48
			
49
				}
48
				}
50
				cw.l("}");
49
				cw.l("}");
51
			}
50
			}

+ 2 - 0
jfwAptWeb/src/main/java/org/jfw/apt/web/handlers/viewImpl/ViewUtil.java

8
		//e:Exception
8
		//e:Exception
9
		//res:HttpServletResponse
9
		//res:HttpServletResponse
10
		//out: jsp.out
10
		//out: jsp.out
11
		
12
		cw.l("log.error(e);");
11
		cw.l("org.jfw.util.json.JsonService.write(e,out);");		
13
		cw.l("org.jfw.util.json.JsonService.write(e,out);");		
12
	}
14
	}
13
	public static void printJSONWithValue(AptWebHandler aptWebHandler, ClassWriter cw){
15
	public static void printJSONWithValue(AptWebHandler aptWebHandler, ClassWriter cw){

+ 1 - 1
jfwUtil/src/main/java/org/jfw/util/bean/define/FixedValueDefine.java

26
		} else if(this.clazz.equals(Float.class)||this.clazz.equals(float.class)){
26
		} else if(this.clazz.equals(Float.class)||this.clazz.equals(float.class)){
27
			this.value = Float.valueOf(val.trim());
27
			this.value = Float.valueOf(val.trim());
28
		} else if(this.clazz.equals(Double.class)||this.clazz.equals(double.class)){
28
		} else if(this.clazz.equals(Double.class)||this.clazz.equals(double.class)){
29
			this.value = Double.class;
29
			this.value = Double.valueOf(val.trim());
30
		} else if(this.clazz.equals(Boolean.class)||this.clazz.equals(boolean.class)){
30
		} else if(this.clazz.equals(Boolean.class)||this.clazz.equals(boolean.class)){
31
			this.value = Boolean.valueOf(val.trim());
31
			this.value = Boolean.valueOf(val.trim());
32
		} else if(this.clazz.equals(Character.class)||this.clazz.equals(char.class)){
32
		} else if(this.clazz.equals(Character.class)||this.clazz.equals(char.class)){