`
rimoer
  • 浏览: 93643 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论
收藏列表
标题 标签 来源
a a

        
CharUtil
package com.huawei.eip.ui.util;

import org.apache.commons.lang.StringEscapeUtils;

/**
 * @author WKF44877
 * @created 2011-7-19 下午5:28:30
 * @version 1.0
 */

public abstract class CharUtil {

	public final static String escapeHtml(String s) {
		if (NullUtil.notNullOrEmpty(s)) {
			return StringEscapeUtils.escapeHtml(s);
		}
		return s;
	}

	public final static String escapeSql(String s) {
		if (NullUtil.notNullOrEmpty(s)) {
			return StringEscapeUtils.escapeSql(s);
		}
		return s;
	}

}
StringUtil
package com.huawei.eip.ui.util;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public abstract class StringUtil {
	public static String DATE_FORMAT_YYYY_MM_DD = "yyyy-MM-dd";
	public static String DATE_FORMAT_YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";

	public static boolean existStrtoArray(String val, String[] array) {
		for (int i = 0; i < array.length; i++) {
			if (array[i].equals(val)) {
				return true;
			}
		}
		return false;
	}

	public static int posStrtoArray(String val, String[] array) {
		for (int i = 0; i < array.length; i++) {
			if (array[i].equals(val)) {
				return i;
			}
		}
		return -1;
	}

	public static String getDate() {
		final Date date = new Date(System.currentTimeMillis());
		final DateFormat df = new SimpleDateFormat(StringUtil.DATE_FORMAT_YYYY_MM_DD_HH_MM_SS);
		return df.format(date);
	}

	public static String getDate(final String format) {
		final Date date = new Date(System.currentTimeMillis());
		final DateFormat df = new SimpleDateFormat(format);
		return df.format(date);
	}

	public static String getDate(final String source, final String format) {
		final DateFormat df = new SimpleDateFormat(format);

		try {
			if (NullUtil.notNullOrEmpty(source)) {
				Date date = df.parse(source);
				return df.format(date);
			}
		} catch (final ParseException e) {
			LogUtil.info(e.getMessage());
		}
		return null;

	}

}
LogUtil
package com.huawei.eip.ui.util;

import org.apache.log4j.Logger;

public abstract class LogUtil {

	public static void info(Object message) {
		Logger.getLogger(LogUtil.class).info(message);
	}

	public static void info(Object message, Throwable t) {
		Logger.getLogger(LogUtil.class).info(message, t);
	}

	public static void info(Class<?> clazz, Object message, Throwable t) {
		Logger.getLogger(clazz).info(message, t);
	}

	public static void info(Class<?> clazz, Throwable t) {
		Logger.getLogger(clazz).info("", t);
	}

	public static void info(Class<?> clazz, Object message) {
		Logger.getLogger(clazz).info(message);
	}

	public static void debug(Object message) {
		Logger.getLogger(LogUtil.class).debug(message);
	}

	public static void debug(Object message, Throwable t) {
		Logger.getLogger(LogUtil.class).debug(message, t);
	}

	public static void debug(Class<?> clazz, Object message, Throwable t) {
		Logger.getLogger(clazz).debug(message, t);
	}

	public static void debug(Class<?> clazz, Throwable t) {
		Logger.getLogger(clazz).debug("", t);
	}

	public static void debug(Class<?> clazz, Object message) {
		Logger.getLogger(clazz).debug(message);
	}

	public static void error(Object message) {
		Logger.getLogger(LogUtil.class).error(message);
	}

	public static void error(Object message, Throwable t) {
		Logger.getLogger(LogUtil.class).error(message, t);
	}

	public static void error(Class<?> clazz, Object message, Throwable t) {
		Logger.getLogger(clazz).error(message, t);
	}

	public static void error(Class<?> clazz, Throwable t) {
		Logger.getLogger(clazz).error("", t);
	}

	public static void error(Class<?> clazz, Object message) {
		Logger.getLogger(clazz).error(message);
	}
}
Field
package com.huawei.eip.ui.dao.model;

import java.io.Serializable;

public class Field implements Serializable {

	private static final long serialVersionUID = 1L;

	private String name;
	private Object value;
	private int type;

	public Field() {
	}

	public Field(String name, Object value, int type) {
		super();
		this.name = name;
		this.value = value;
		this.type = type;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Object getValue() {
		return value;
	}

	public void setValue(Object value) {
		this.value = value;
	}

	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}

}
ConnectionPoolManager
package com.huawei.eip.ui.dao.conn;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.Properties;

import org.logicalcobwebs.proxool.ProxoolException;
import org.logicalcobwebs.proxool.ProxoolFacade;

import com.huawei.eip.ui.def.Constant;
import com.huawei.eip.ui.util.LogUtil;

/**
 * @author WKF44877
 * @created 2011-7-13 下午4:33:38
 * @version 1.0
 */

public abstract class ConnectionPoolManager {
	public static void initial() {
		LogUtil.info(ConnectionPoolManager.class, "初始化连接池...");

		ConnectionPoolManager.register(Constant.EIP_CONFIG.getAssocApp(),
				Constant.EIP_CONFIG.getDriver(), Constant.EIP_CONFIG.getUrl(),
				Constant.EIP_CONFIG.getUsername(),
				Constant.EIP_CONFIG.getPassword());

	}

	public static void register(String schema, String driverClass,
			String driverUrl, String username, String password) {

		try {
			Class.forName("org.logicalcobwebs.proxool.ProxoolDriver");
			Properties info = new Properties();
			String testSql = "select sysdate from dual";
			info.setProperty("proxool.minimum-connection-count", "1");
			info.setProperty("proxool.maximum-connection-count", "100");
			info.setProperty("proxool.house-keeping-test-sql", testSql);
			info.setProperty("user", username);
			info.setProperty("password", password);

			String url = "proxool." + schema + ":" + driverClass + ":"
					+ driverUrl;
			ProxoolFacade.registerConnectionPool(url, info);

		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (ProxoolException e) {
			e.printStackTrace();
		}

	}

	public static void shutdown() {
		ProxoolFacade.shutdown();
	}

	public static void main(String[] args) {
		ConnectionPoolManager.initial();
		Connection conn = ConnectionManager.getConnection("EIPCONF");

		if (conn != null) {
			System.out.println(conn);
			try {
				conn.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
			ConnectionPoolManager.shutdown();

		}
	}
}
ConnectionManager
package com.huawei.eip.ui.dao.conn;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

import com.huawei.eip.ui.def.Constant;

/**
 * @author WKF44877
 * @created 2011-7-13 下午3:04:56
 * @version 1.0
 */

public class ConnectionManager {

	public static Connection getConnection() {
		return ConnectionManager.getConnection(Constant.EIP_CONFIG
				.getAssocApp());
	}

	public static Connection getConnection(String assocApp) {
		Connection conn = null;

		try {
			conn = DriverManager.getConnection("proxool." + assocApp);
		} catch (SQLException e) {
			e.printStackTrace();
		}

		return conn;
	}

	public static void main(String[] args) {
		ConnectionPoolManager.initial();
		Connection conn = ConnectionManager.getConnection("EIPCONF");

	}

}
Global site tag (gtag.js) - Google Analytics