Skip to content

Commit

Permalink
Merge pull request #23 from support-project/develop
Browse files Browse the repository at this point in the history
Release/v1.7.0
  • Loading branch information
koda-masaru authored Jan 20, 2017
2 parents e553165 + 24a984d commit 37339c7
Show file tree
Hide file tree
Showing 14 changed files with 316 additions and 102 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>org.support-project</groupId>
<artifactId>common</artifactId>
<version>1.6.0</version>
<version>1.7.0</version>
<packaging>jar</packaging>

<name>common</name>
Expand Down
67 changes: 67 additions & 0 deletions src/main/java/org/support/project/common/bat/JavaJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ public static JavaJob get() {

/** コンソール出力を渡すリスナー */
private ConsoleListener consoleListener = null;

/** ヒープ・メモリ全体の起動時のサイズ */
private int xms = -1;
/** ヒープ・メモリ全体の最大サイズ */
private int xmx = -1;
/** NEW領域のサイズ */
private int xmn = -1;

/**
* 実行するメインクラスを設定します。
Expand Down Expand Up @@ -123,6 +130,18 @@ public JobResult execute() throws Exception {
}

batJob.addCommand("java");
if (xms != -1) {
batJob.addCommand("-Xms" + xms + "m");
}
if (xmx != -1) {
batJob.addCommand("-Xmx" + xmx + "m");
}
if (xmn != -1) {
batJob.addCommand("-Xmn" + xmn + "m");
}



if (!jarDirs.isEmpty() || !classPathDirs.isEmpty()) {
batJob.addCommand("-classpath");
batJob.addCommand(makeClassPath());
Expand Down Expand Up @@ -223,4 +242,52 @@ public void setConsoleListener(ConsoleListener consoleListener) {
this.consoleListener = consoleListener;
}

/**
* Get xms
* @return the xms
*/
public int getXms() {
return xms;
}

/**
* Set xms
* @param xms the xms to set
*/
public void setXms(int xms) {
this.xms = xms;
}

/**
* Get xmx
* @return the xmx
*/
public int getXmx() {
return xmx;
}

/**
* Set xmx
* @param xmx the xmx to set
*/
public void setXmx(int xmx) {
this.xmx = xmx;
}

/**
* Get xmn
* @return the xmn
*/
public int getXmn() {
return xmn;
}

/**
* Set xmn
* @param xmn the xmn to set
*/
public void setXmn(int xmn) {
this.xmn = xmn;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,22 @@ public static String objectToBase64(Object obj) throws SerializeException {
return string;
}

/**
* Base64のエンコードの内容を、オブジェクトに変換する
*
* @param base64 string
* @param type type
* @return object
* @throws SerializeException SerializeException
*/
public static <T> T Base64ToObject(String base64, final Class<? extends T> type) throws SerializeException {
byte[] bytes = Base64Utils.fromBase64(base64);
return bytesToObject(bytes, type);
}




/**
* オブジェクトをXML形式で出力する
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public static final String decrypt(String string, String key)
* @return
* @throws NoSuchAlgorithmException
*/
private static String hash(String string) throws NoSuchAlgorithmException {
public static String hash(String string) throws NoSuchAlgorithmException {
byte[] bytes = sha256(string);
return Base64Utils.toBase64(bytes);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,10 @@ public static void load(ResultSet rs, Object object, String driverClass) {
// Postgresql
LOG.trace("Postgresql LOB");
byte[] bytes = rs.getBytes(column);
ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes);
PropertyUtil.setPropertyValue(object, prop, inputStream);
if (bytes != null) {
ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes);
PropertyUtil.setPropertyValue(object, prop, inputStream);
}
}
} else {
LOG.warn("処理出来ない型のデータです:" + accessType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private void make() {
DatabaseMetaDataDao metaDataDao = Container.getComp(DatabaseMetaDataDao.class);
metaDataDao.dbAnalysis();

// データベース毎のEntity生成クラスに処理を委譲
// データベース毎のDao生成クラスに処理を委譲
ConnectionManager connectionManager = ConnectionManager.getInstance();
DaoClassCreator creator = ORMappingToolFactory.getDaoClassCreator(connectionManager.getDriverClass());
creator.create(metaDataDao.getTableInfos(), config);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,66 +13,68 @@

public class DatabaseInitializer {

public static void main(String[] args) throws Exception, IOException {
String configFileName = ORMappingParameter.OR_MAPPING_TOOL_CONFIG;
if (args != null && args.length == 1) {
configFileName = args[0];
}
DatabaseInitializer initializer = new DatabaseInitializer(configFileName);
initializer.dropAllTable();
initializer.initDatabase();
}
/** 設定ファイル名 */
private String configFileName;
/** 設定ファイル情報 */
private ORmappingToolConfig config;
public static void main(String[] args) throws Exception, IOException {
String configFileName = ORMappingParameter.OR_MAPPING_TOOL_CONFIG;
if (args != null && args.length == 1) {
configFileName = args[0];
}
DatabaseInitializer initializer = new DatabaseInitializer(configFileName);
initializer.dropAllTable();
initializer.initDatabase();
}
/** 設定ファイル名 */
private String configFileName;
/** 設定ファイル情報 */
private ORmappingToolConfig config;

public DatabaseInitializer(String configFileName) throws SerializeException, IOException {
super();
this.configFileName = configFileName;
config = SerializeUtils.bytesToObject(
getClass().getResourceAsStream(configFileName),
ORmappingToolConfig.class);
config.getConnectionConfig().convURL();
ConnectionManager.getInstance().addConnectionConfig(config.getConnectionConfig());
InitializeDao initializeDao = InitializeDao.get();
initializeDao.initializeDatabase();
// initializeDao.setConnectionConfig(config.getConnectionConfig());
}
public DatabaseInitializer(String configFileName) throws SerializeException, IOException {
super();
this.configFileName = configFileName;
config = SerializeUtils.bytesToObject(
getClass().getResourceAsStream(configFileName),
ORmappingToolConfig.class);
config.getConnectionConfig().convURL();
ConnectionManager.getInstance().addConnectionConfig(config.getConnectionConfig());
InitializeDao initializeDao = InitializeDao.get();
initializeDao.initializeDatabase();
// initializeDao.setConnectionConfig(config.getConnectionConfig());
}

/**
* 初期SQLの実行
*/
public void initDatabase() {
InitializeDao initializeDao = InitializeDao.get();
initializeDao.initializeDatabase();
ORMappingDatabaseInitializeConfig initializeConfig = config.getInitializeConfig();
if (initializeConfig != null) {
List<String> sqlpaths = config.getInitializeConfig().getSqlPaths();
if (sqlpaths != null && !sqlpaths.isEmpty()) {
String[] sqls = sqlpaths.toArray(new String[0]);
initializeDao.initializeDatabase(sqls);
}
}
}

/**
* DBのテーブルのデータを全て削除
*/
public void deleteAllTable() {
InitializeDao initializeDao = InitializeDao.get();
initializeDao.deleteAllData();
}
/**
* 初期SQLの実行
*/
public void initDatabase() {
InitializeDao initializeDao = InitializeDao.get();
initializeDao.initializeDatabase();
ORMappingDatabaseInitializeConfig initializeConfig = config.getInitializeConfig();
if (initializeConfig != null) {
List<String> sqlpaths = config.getInitializeConfig().getSqlPaths();
if (sqlpaths != null && !sqlpaths.isEmpty()) {
String[] sqls = sqlpaths.toArray(new String[0]);
initializeDao.initializeDatabase(sqls);
}
}
}

/**
* DBのテーブルのデータを全て削除
*/
@Deprecated
public void deleteAllTable() {
InitializeDao initializeDao = InitializeDao.get();
initializeDao.deleteAllData();
}

/**
* DBのテーブルを全て削除
*/
public void dropAllTable() {
InitializeDao initializeDao = InitializeDao.get();
initializeDao.dropAllTable();
}
/**
* DBのテーブルを全て削除
*/
@Deprecated
public void dropAllTable() {
InitializeDao initializeDao = InitializeDao.get();
initializeDao.dropAllTable();
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,33 @@
import org.support.project.ormapping.tool.impl.DefaultEntityCteatorImpl;

public class ORMappingToolFactory {
/**
* ドライバークラスにあったEntity生成クラスを取得する
* @param driverClassName JDBCドライバークラス
* @return Entity生成クラス
*/
public static EntityClassCreator getEntityClassCreator(String driverClassName) {
if (driverClassName.equals(ORMappingParameter.DRIVER_NAME_H2)) {
// 今のところ分けていない
return Container.getComp(DefaultEntityCteatorImpl.class);
}
return Container.getComp(DefaultEntityCteatorImpl.class);
}
/**
* ドライバークラスにあったDao生成クラスを取得する
* @param driverClass JDBCドライバークラス
* @return Entity生成クラス
*/
public static DaoClassCreator getDaoClassCreator(String driverClass) {
if (driverClass.equals(ORMappingParameter.DRIVER_NAME_H2)) {
// 今のところ分けていない
return Container.getComp(DefaultDaoCreatorImpl.class);
}
return Container.getComp(DefaultDaoCreatorImpl.class);
}
/**
* ドライバークラスにあったEntity生成クラスを取得する
* @param driverClassName JDBCドライバークラス
* @return Entity生成クラス
*/
public static EntityClassCreator getEntityClassCreator(String driverClassName) {
if (driverClassName.equals(ORMappingParameter.DRIVER_NAME_H2)) {
// 今のところ分けていない
return Container.getComp(DefaultEntityCteatorImpl.class);
}
return Container.getComp(DefaultEntityCteatorImpl.class);
}
/**
* ドライバークラスにあったDao生成クラスを取得する
* @param driverClass JDBCドライバークラス
* @return Entity生成クラス
*/
public static DaoClassCreator getDaoClassCreator(String driverClass) {
if (driverClass.equals(ORMappingParameter.DRIVER_NAME_H2)) {
// 今のところ分けていない
return Container.getComp(DefaultDaoCreatorImpl.class);
}
return Container.getComp(DefaultDaoCreatorImpl.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public void initializeDatabase(String... sqlPaths) {
/**
* 全てのデータをクリア
*/
@Deprecated
public void deleteAllData() {
// DBの情報を解析
super.dbAnalysis();
Expand All @@ -75,6 +76,7 @@ public void deleteAllData() {
/**
* 全てのテーブルを削除
*/
@Deprecated
public void dropAllTable() {
// DBの情報を解析
super.dbAnalysis();
Expand Down
Loading

0 comments on commit 37339c7

Please sign in to comment.