[討論]J2EE專案自動生成工具

jshuwei發表於2009-09-23
最近在做一個程式碼自動生成工具,下面的程式碼是自動生成的,歡迎大家討論生成的程式碼有什麼地方需要修改的。
變數名和包名等資訊都是生成的時候配置檔案配置的。
線上演示地址:http://java.jshuwei.org.cn:8080
程式碼看得閒累的話直接下載原始碼吧:檢視原始碼(程式碼附件太大,只能放我自己部落格中提供下載了,請見諒!)
BaseAction.java:

package cn.org.jshuwei.j2ee.test.action;

import cn.org.jshuwei.j2ee.test.core.JshuweiContext;
import cn.org.jshuwei.j2ee.util.StringUtil;

import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.ServletResponseAware;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * Copyright 2009 huwei(jshuwei.org.cn)
 * Generate by huwei's generate Util
 * 本類由胡偉j2ee自動生成工具生成,歡迎與作者交流討論, 
 * <p>聯絡方式:<br>Web:[url]http://jshuwei.org.cn[/url] <br>Email:huwei@jshuwei.org.cn<br>QQ:772627301<p/>
 */

public class BaseAction extends ActionSupport  implements ServletRequestAware, ServletResponseAware {
	private static final long serialVersionUID = 1L;

    protected HttpServletRequest request;
    protected HttpServletResponse response;
    private String serviceId;
	private String serviceName;
	private int eventCode;
	protected Object requestObj;
	private int id;
	private int start;
	private int limit = 25;

    public void setServletRequest(HttpServletRequest httpServletRequest) {
        request = httpServletRequest;
    }

    public void setServletResponse(HttpServletResponse httpServletResponse) {
        response = httpServletResponse;
    }

    public HttpServletRequest getRequest() {
        return request;
    }

    public void setRequest(HttpServletRequest request) {
        this.request = request;
    }

    public HttpServletResponse getResponse() {
        return response;
    }

    public void setResponse(HttpServletResponse response) {
        this.response = response;
    }

    public String getServiceId() {
        return serviceId;
    }

    public void setServiceId(String serviceId) {
        this.serviceId = serviceId;
    }

    public String getServiceName() {
        return serviceName;
    }

    public void setServiceName(String serviceName) {
        this.serviceName = serviceName;
    }

    public int getEventCode() {
        return eventCode;
    }

    public void setEventCode(int eventCode) {
        this.eventCode = eventCode;
    }

    public Object getRequestObj() {
        return requestObj;
    }

    public void setRequestObj(Object requestObj) {
        this.requestObj = requestObj;
    }
    
    public int getId() {
    	return id;
    }
    
    public void setId(int id) {
    	this.id = id;
    }
    
    public int getStart() {
    	return start;
    }
    
    public void setStart(int start) {
    	this.start = start;
    }
    
    public int getLimit() {
    	return limit;
    }
    
    public void setLimit(int limit) {
    	this.limit = limit;
    }
    
    @SuppressWarnings("unchecked")
    public JshuweiContext generateJshuweiContext() {
    	JshuweiContext jshuweiContext = new JshuweiContext();
    	if (serviceId != null || !"".equals(serviceId))
            jshuweiContext.setServiceId(serviceId);
    	if (serviceName != null || !"".equals(serviceName))
            jshuweiContext.setServiceName(serviceName);
    	if (eventCode != 0)
            jshuweiContext.setEventCode(eventCode);
        if (eventCode % 100 ==1)
    		setRequestObj(new Integer[]{start,limit});
    	if (eventCode % 100 ==2 || eventCode % 100 ==6)
    		setRequestObj(new Integer(id));
    	if (eventCode % 100 ==3) {
    		List list = new ArrayList();
    		list.add(generateEntity());
    		list.add(new Integer[]{start,limit});
    		setRequestObj(list);
    	}
    	if (eventCode % 100 ==4 || eventCode % 100 ==5)
    		setRequestObj(generateEntity());
    	if (requestObj != null)
            jshuweiContext.setRequestObj(requestObj);
……
<p class="indent">

省去n多程式碼(字數有限制),配置檔案和web端程式碼,實在是太多了,各位還是直接下載原始碼直接檢視討論吧!
附件太大了,這裡上傳不了,只能發到我自己的部落格裡下載!

[該貼被jshuwei於2009-09-23 12:53修改過]

相關文章