Repository: empire-db Updated Branches: refs/heads/master 2945b5df2 -> c6f638498
correct wrong renaming: Db* -> DB* Project: http://git-wip-us.apache.org/repos/asf/empire-db/repo Commit: http://git-wip-us.apache.org/repos/asf/empire-db/commit/c6f63849 Tree: http://git-wip-us.apache.org/repos/asf/empire-db/tree/c6f63849 Diff: http://git-wip-us.apache.org/repos/asf/empire-db/diff/c6f63849 Branch: refs/heads/master Commit: c6f638498374cd86a6772e502cceb06f67c7e66e Parents: 2945b5d Author: inemeth <[email protected]> Authored: Fri Oct 23 10:09:04 2015 +0200 Committer: inemeth <[email protected]> Committed: Fri Oct 23 10:09:04 2015 +0200 ---------------------------------------------------------------------- .../empire/spring/DBDatabaseFactoryBean.java | 137 +++++++++++++++++++ .../apache/empire/spring/DBReaderExtractor.java | 27 ++++ .../empire/spring/DBRecordCallbackHandler.java | 48 +++++++ .../apache/empire/spring/DBRecordMapper.java | 45 ++++++ .../apache/empire/spring/DBRecordWriter.java | 28 ++++ .../empire/spring/DbDatabaseFactoryBean.java | 137 ------------------- .../apache/empire/spring/DbReaderExtractor.java | 27 ---- .../empire/spring/DbRecordCallbackHandler.java | 27 ---- .../apache/empire/spring/DbRecordMapper.java | 34 ----- .../apache/empire/spring/DbRecordWriter.java | 28 ---- .../apache/empire/spring/EmpireTemplate.java | 32 ++--- .../empire/spring/example1/EmpireAppImpl.java | 14 +- .../empire/spring/example2/EmployeeDaoImpl.java | 12 +- 13 files changed, 314 insertions(+), 282 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/empire-db/blob/c6f63849/empire-db-spring/src/main/java/org/apache/empire/spring/DBDatabaseFactoryBean.java ---------------------------------------------------------------------- diff --git a/empire-db-spring/src/main/java/org/apache/empire/spring/DBDatabaseFactoryBean.java b/empire-db-spring/src/main/java/org/apache/empire/spring/DBDatabaseFactoryBean.java new file mode 100644 index 0000000..01b6c40 --- /dev/null +++ b/empire-db-spring/src/main/java/org/apache/empire/spring/DBDatabaseFactoryBean.java @@ -0,0 +1,137 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.empire.spring; + +import org.apache.empire.db.DBDatabase; +import org.apache.empire.db.DBDatabaseDriver; +import org.springframework.beans.factory.FactoryBean; +import org.springframework.beans.factory.InitializingBean; + +public class DBDatabaseFactoryBean implements FactoryBean<DBDatabase>, + InitializingBean { + + private boolean singleton = true; + + private DBDatabase singletonInstance; + private String schema; + private String linkName; + private DBDatabaseDriver driver; + private boolean preparedStatementsEnabled = true; + private Class<? extends DBDatabase> databaseClass = null; + private boolean earlyOpen = true; + + private Class<DBDatabaseDriver> driverClass; + + public final void setSingleton(boolean singleton) { + this.singleton = singleton; + } + + public void setDatabaseClass(Class<? extends DBDatabase> databaseClass) { + this.databaseClass = databaseClass; + } + + public void setEarlyOpen(boolean earlyOpen) { + this.earlyOpen = earlyOpen; + } + + public void setSchema(String schema) { + this.schema = schema; + } + + public void setLinkName(String linkName) { + this.linkName = linkName; + } + + public void setDriver(DBDatabaseDriver driver) { + this.driver = driver; + } + + public void setDriverClass(Class<DBDatabaseDriver> driverClass) { + this.driverClass = driverClass; + } + + + public void setPreparedStatementsEnabled(boolean preparedStatementsEnabled) { + this.preparedStatementsEnabled = preparedStatementsEnabled; + } + + public DBDatabase getObject() throws Exception { + if (this.singleton) { + return this.singletonInstance; + } else { + return createInstance(); + } + } + + public Class<?> getObjectType() { + return DBDatabase.class; + } + + public boolean isSingleton() { + return false; + } + + public void afterPropertiesSet() throws Exception { + if (driver == null && driverClass == null){ + throw new RuntimeException("driver or driverClass must be set"); + } + + if (driver == null){ + driver = (DBDatabaseDriver) driverClass.newInstance(); + } + + if (this.singleton) { + this.singletonInstance = createInstance(); + } + } + + protected DBDatabase createInstance() { + DBDatabase database = null; + if (this.databaseClass == null) { + database = new DefaultDb(); + } else { + try { + database = this.databaseClass.newInstance(); + } catch (Exception e) { + throw new RuntimeException("Failed to create database: " + + this.databaseClass, e); + } + } + if (this.schema != null && this.schema.trim().length() > 0){ + database.setSchema(schema); + } + if (this.linkName != null && this.linkName.trim().length() > 0){ + database.setLinkName(linkName); + } + + + database.setPreparedStatementsEnabled(preparedStatementsEnabled); + if (earlyOpen) { + database.open(driver, null); + } + return database; + } + + public static class DefaultDb extends DBDatabase { + + private static final long serialVersionUID = 1L; + + } + +} http://git-wip-us.apache.org/repos/asf/empire-db/blob/c6f63849/empire-db-spring/src/main/java/org/apache/empire/spring/DBReaderExtractor.java ---------------------------------------------------------------------- diff --git a/empire-db-spring/src/main/java/org/apache/empire/spring/DBReaderExtractor.java b/empire-db-spring/src/main/java/org/apache/empire/spring/DBReaderExtractor.java new file mode 100644 index 0000000..03626ae --- /dev/null +++ b/empire-db-spring/src/main/java/org/apache/empire/spring/DBReaderExtractor.java @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.empire.spring; + +import org.apache.empire.db.DBReader; + +public interface DBReaderExtractor<K> { + + K process(DBReader reader); + +} http://git-wip-us.apache.org/repos/asf/empire-db/blob/c6f63849/empire-db-spring/src/main/java/org/apache/empire/spring/DBRecordCallbackHandler.java ---------------------------------------------------------------------- diff --git a/empire-db-spring/src/main/java/org/apache/empire/spring/DBRecordCallbackHandler.java b/empire-db-spring/src/main/java/org/apache/empire/spring/DBRecordCallbackHandler.java new file mode 100644 index 0000000..ec51d1f --- /dev/null +++ b/empire-db-spring/src/main/java/org/apache/empire/spring/DBRecordCallbackHandler.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.empire.spring; + +import org.apache.empire.db.DBRecordData; + +/** + * An interface used by {@link EmpireTemplate} for processing a DBRecordData or + * rows of a DBReader on a per-row basis. + * + * + * + * DbRecordCallbackHandler object is typically stateful: It keeps the result + * state within the object, to be available for later inspection. + * + * If you need to map exactly one object to each row from a DBReader consider + * using a {@link DbRecordDataMapper}. + * + * + */ + +public interface DBRecordCallbackHandler { + + /** + * Implementations must implement this method to process a DBRecordData. + * + * @param record + */ + + void processRow(DBRecordData record); + +} http://git-wip-us.apache.org/repos/asf/empire-db/blob/c6f63849/empire-db-spring/src/main/java/org/apache/empire/spring/DBRecordMapper.java ---------------------------------------------------------------------- diff --git a/empire-db-spring/src/main/java/org/apache/empire/spring/DBRecordMapper.java b/empire-db-spring/src/main/java/org/apache/empire/spring/DBRecordMapper.java new file mode 100644 index 0000000..4d96434 --- /dev/null +++ b/empire-db-spring/src/main/java/org/apache/empire/spring/DBRecordMapper.java @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.empire.spring; + +import org.apache.empire.db.DBRecordData; + +/** + * Interface used by {@link EmpireTemplate} for mapping + * {@link org.apache.empire.db.DBRecordData} to an Object. + * + * Typically it can be used to extract data from a DBReader, but without + * iterating over it, it is handled by EmpireTemplate. + * + * + */ + +public interface DBRecordMapper<K> { + + /** + * Implementations must implement this method to map data in a DBRecordData. + * + * @param record + * the DBRecordData to map + * @return the result object + */ + + public abstract K read(DBRecordData record); + +} http://git-wip-us.apache.org/repos/asf/empire-db/blob/c6f63849/empire-db-spring/src/main/java/org/apache/empire/spring/DBRecordWriter.java ---------------------------------------------------------------------- diff --git a/empire-db-spring/src/main/java/org/apache/empire/spring/DBRecordWriter.java b/empire-db-spring/src/main/java/org/apache/empire/spring/DBRecordWriter.java new file mode 100644 index 0000000..fe57784 --- /dev/null +++ b/empire-db-spring/src/main/java/org/apache/empire/spring/DBRecordWriter.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.empire.spring; + +import org.apache.empire.db.DBRecord; + + +public interface DBRecordWriter<K> { + + public abstract void write(DBRecord record, K entity); + +} http://git-wip-us.apache.org/repos/asf/empire-db/blob/c6f63849/empire-db-spring/src/main/java/org/apache/empire/spring/DbDatabaseFactoryBean.java ---------------------------------------------------------------------- diff --git a/empire-db-spring/src/main/java/org/apache/empire/spring/DbDatabaseFactoryBean.java b/empire-db-spring/src/main/java/org/apache/empire/spring/DbDatabaseFactoryBean.java deleted file mode 100644 index 6bb5648..0000000 --- a/empire-db-spring/src/main/java/org/apache/empire/spring/DbDatabaseFactoryBean.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.empire.spring; - -import org.apache.empire.db.DBDatabase; -import org.apache.empire.db.DBDatabaseDriver; -import org.springframework.beans.factory.FactoryBean; -import org.springframework.beans.factory.InitializingBean; - -public class DbDatabaseFactoryBean implements FactoryBean<DBDatabase>, - InitializingBean { - - private boolean singleton = true; - - private DBDatabase singletonInstance; - private String schema; - private String linkName; - private DBDatabaseDriver driver; - private boolean preparedStatementsEnabled = true; - private Class<? extends DBDatabase> databaseClass = null; - private boolean earlyOpen = true; - - private Class<DBDatabaseDriver> driverClass; - - public final void setSingleton(boolean singleton) { - this.singleton = singleton; - } - - public void setDatabaseClass(Class<? extends DBDatabase> databaseClass) { - this.databaseClass = databaseClass; - } - - public void setEarlyOpen(boolean earlyOpen) { - this.earlyOpen = earlyOpen; - } - - public void setSchema(String schema) { - this.schema = schema; - } - - public void setLinkName(String linkName) { - this.linkName = linkName; - } - - public void setDriver(DBDatabaseDriver driver) { - this.driver = driver; - } - - public void setDriverClass(Class<DBDatabaseDriver> driverClass) { - this.driverClass = driverClass; - } - - - public void setPreparedStatementsEnabled(boolean preparedStatementsEnabled) { - this.preparedStatementsEnabled = preparedStatementsEnabled; - } - - public DBDatabase getObject() throws Exception { - if (this.singleton) { - return this.singletonInstance; - } else { - return createInstance(); - } - } - - public Class<?> getObjectType() { - return DBDatabase.class; - } - - public boolean isSingleton() { - return false; - } - - public void afterPropertiesSet() throws Exception { - if (driver == null && driverClass == null){ - throw new RuntimeException("driver or driverClass must be set"); - } - - if (driver == null){ - driver = (DBDatabaseDriver) driverClass.newInstance(); - } - - if (this.singleton) { - this.singletonInstance = createInstance(); - } - } - - protected DBDatabase createInstance() { - DBDatabase database = null; - if (this.databaseClass == null) { - database = new DefaultDb(); - } else { - try { - database = this.databaseClass.newInstance(); - } catch (Exception e) { - throw new RuntimeException("Failed to create database: " - + this.databaseClass, e); - } - } - if (this.schema != null && this.schema.trim().length() > 0){ - database.setSchema(schema); - } - if (this.linkName != null && this.linkName.trim().length() > 0){ - database.setLinkName(linkName); - } - - - database.setPreparedStatementsEnabled(preparedStatementsEnabled); - if (earlyOpen) { - database.open(driver, null); - } - return database; - } - - public static class DefaultDb extends DBDatabase { - - private static final long serialVersionUID = 1L; - - } - -} http://git-wip-us.apache.org/repos/asf/empire-db/blob/c6f63849/empire-db-spring/src/main/java/org/apache/empire/spring/DbReaderExtractor.java ---------------------------------------------------------------------- diff --git a/empire-db-spring/src/main/java/org/apache/empire/spring/DbReaderExtractor.java b/empire-db-spring/src/main/java/org/apache/empire/spring/DbReaderExtractor.java deleted file mode 100644 index 5d8cf8c..0000000 --- a/empire-db-spring/src/main/java/org/apache/empire/spring/DbReaderExtractor.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.empire.spring; - -import org.apache.empire.db.DBReader; - -public interface DbReaderExtractor<K> { - - K process(DBReader reader); - -} http://git-wip-us.apache.org/repos/asf/empire-db/blob/c6f63849/empire-db-spring/src/main/java/org/apache/empire/spring/DbRecordCallbackHandler.java ---------------------------------------------------------------------- diff --git a/empire-db-spring/src/main/java/org/apache/empire/spring/DbRecordCallbackHandler.java b/empire-db-spring/src/main/java/org/apache/empire/spring/DbRecordCallbackHandler.java deleted file mode 100644 index 6fcd15a..0000000 --- a/empire-db-spring/src/main/java/org/apache/empire/spring/DbRecordCallbackHandler.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.empire.spring; - -import org.apache.empire.db.DBRecordData; - -public interface DbRecordCallbackHandler { - - void processRow(DBRecordData record); - -} http://git-wip-us.apache.org/repos/asf/empire-db/blob/c6f63849/empire-db-spring/src/main/java/org/apache/empire/spring/DbRecordMapper.java ---------------------------------------------------------------------- diff --git a/empire-db-spring/src/main/java/org/apache/empire/spring/DbRecordMapper.java b/empire-db-spring/src/main/java/org/apache/empire/spring/DbRecordMapper.java deleted file mode 100644 index 226f3b4..0000000 --- a/empire-db-spring/src/main/java/org/apache/empire/spring/DbRecordMapper.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.empire.spring; - -import org.apache.empire.db.DBRecordData; - -/** - * Interface used by {@link EmpireTemplate} for mapping a - * {@link org.apache.empire.db.DBRecordData}. - * - */ - - -public interface DbRecordMapper<K> { - - public abstract K read(DBRecordData record); - -} http://git-wip-us.apache.org/repos/asf/empire-db/blob/c6f63849/empire-db-spring/src/main/java/org/apache/empire/spring/DbRecordWriter.java ---------------------------------------------------------------------- diff --git a/empire-db-spring/src/main/java/org/apache/empire/spring/DbRecordWriter.java b/empire-db-spring/src/main/java/org/apache/empire/spring/DbRecordWriter.java deleted file mode 100644 index 2bc9a39..0000000 --- a/empire-db-spring/src/main/java/org/apache/empire/spring/DbRecordWriter.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.empire.spring; - -import org.apache.empire.db.DBRecord; - - -public interface DbRecordWriter<K> { - - public abstract void write(DBRecord record, K entity); - -} http://git-wip-us.apache.org/repos/asf/empire-db/blob/c6f63849/empire-db-spring/src/main/java/org/apache/empire/spring/EmpireTemplate.java ---------------------------------------------------------------------- diff --git a/empire-db-spring/src/main/java/org/apache/empire/spring/EmpireTemplate.java b/empire-db-spring/src/main/java/org/apache/empire/spring/EmpireTemplate.java index 558ae84..5bc96d1 100644 --- a/empire-db-spring/src/main/java/org/apache/empire/spring/EmpireTemplate.java +++ b/empire-db-spring/src/main/java/org/apache/empire/spring/EmpireTemplate.java @@ -70,13 +70,13 @@ public class EmpireTemplate implements InitializingBean { } public <K> List<K> query(final DBCommand cmd, - final DbRecordMapper<K> dataReader) { + final DBRecordMapper<K> dataReader) { return query(cmd, new DbRecordMapperExtractor<K>(dataReader)); } public List<Object> queryForList(final DBCommand cmd, final DBColumnExpr col) { - class SingleValueMapper implements DbRecordMapper<Object> { + class SingleValueMapper implements DBRecordMapper<Object> { @Override public Object read(DBRecordData record) { @@ -96,7 +96,7 @@ public class EmpireTemplate implements InitializingBean { public List<Long> queryForLongList(final DBCommand cmd, final DBColumnExpr col, final Long defaultValue) { - class SingleLongMapper implements DbRecordMapper<Long> { + class SingleLongMapper implements DBRecordMapper<Long> { @Override public Long read(DBRecordData record) { @@ -116,7 +116,7 @@ public class EmpireTemplate implements InitializingBean { public List<Integer> queryForIntegerList(final DBCommand cmd, final DBColumnExpr col, final Integer defaultValue) { - class SingleIntegerMapper implements DbRecordMapper<Integer> { + class SingleIntegerMapper implements DBRecordMapper<Integer> { @Override public Integer read(DBRecordData record) { @@ -133,7 +133,7 @@ public class EmpireTemplate implements InitializingBean { public List<String> queryForStringList(final DBCommand cmd, final DBColumnExpr col) { - class SingleStringMapper implements DbRecordMapper<String> { + class SingleStringMapper implements DBRecordMapper<String> { @Override public String read(DBRecordData record) { @@ -145,7 +145,7 @@ public class EmpireTemplate implements InitializingBean { } public <K> K query(final DBCommand cmd, - final DbReaderExtractor<K> readerHandler) { + final DBReaderExtractor<K> readerHandler) { class QueryCallback implements ConnectionCallback<K> { public K doInConnection(Connection connection) throws SQLException, @@ -158,12 +158,12 @@ public class EmpireTemplate implements InitializingBean { } public void query(final DBCommand cmd, - final DbRecordCallbackHandler rowCallbackHandler) { + final DBRecordCallbackHandler rowCallbackHandler) { query(cmd, new DbRecordCallbackHandlerExtractor(rowCallbackHandler)); } public <K> K queryForObject(final DBCommand cmd, - final DbRecordMapper<K> dataReader) { + final DBRecordMapper<K> dataReader) { return DataAccessUtils.uniqueResult(query(cmd, dataReader)); @@ -286,7 +286,7 @@ public class EmpireTemplate implements InitializingBean { public <C extends Collection<T>, T> C queryForBeanList(final DBCommand cmd, final C c, final Class<T> t, final int maxCount) { - class GetBeanListCallback implements DbReaderExtractor<C> { + class GetBeanListCallback implements DBReaderExtractor<C> { @Override public C process(DBReader reader) { @@ -316,7 +316,7 @@ public class EmpireTemplate implements InitializingBean { } private <K> K query(Connection connection, DBCommand command, - DbReaderExtractor<K> callback) { + DBReaderExtractor<K> callback) { DBReader reader = newDBReader(); try { reader.open(command, connection); @@ -333,12 +333,12 @@ public class EmpireTemplate implements InitializingBean { } private static class DbRecordCallbackHandlerExtractor implements - DbReaderExtractor<Object> { + DBReaderExtractor<Object> { - private final DbRecordCallbackHandler rowCallbackHandler; + private final DBRecordCallbackHandler rowCallbackHandler; public DbRecordCallbackHandlerExtractor( - DbRecordCallbackHandler rowCallbackHandler) { + DBRecordCallbackHandler rowCallbackHandler) { Assert.notNull(rowCallbackHandler, "RowCallbackHandler is required"); this.rowCallbackHandler = rowCallbackHandler; } @@ -358,11 +358,11 @@ public class EmpireTemplate implements InitializingBean { } private static class DbRecordMapperExtractor<K> implements - DbReaderExtractor<List<K>> { + DBReaderExtractor<List<K>> { - private final DbRecordMapper<K> dataReader; + private final DBRecordMapper<K> dataReader; - public DbRecordMapperExtractor(DbRecordMapper<K> rowMapper) { + public DbRecordMapperExtractor(DBRecordMapper<K> rowMapper) { Assert.notNull(rowMapper, "DataReader is required"); this.dataReader = rowMapper; } http://git-wip-us.apache.org/repos/asf/empire-db/blob/c6f63849/empire-db-spring/src/main/java/org/apache/empire/spring/example1/EmpireAppImpl.java ---------------------------------------------------------------------- diff --git a/empire-db-spring/src/main/java/org/apache/empire/spring/example1/EmpireAppImpl.java b/empire-db-spring/src/main/java/org/apache/empire/spring/example1/EmpireAppImpl.java index 3c152ff..d5d1e49 100644 --- a/empire-db-spring/src/main/java/org/apache/empire/spring/example1/EmpireAppImpl.java +++ b/empire-db-spring/src/main/java/org/apache/empire/spring/example1/EmpireAppImpl.java @@ -39,10 +39,10 @@ import org.apache.empire.db.h2.DBDatabaseDriverH2; import org.apache.empire.db.hsql.DBDatabaseDriverHSql; import org.apache.empire.db.postgresql.DBDatabaseDriverPostgreSQL; import org.apache.empire.spring.EmpireDaoSupport; -import org.apache.empire.spring.DbRecordMapper; -import org.apache.empire.spring.DbReaderExtractor; +import org.apache.empire.spring.DBRecordMapper; +import org.apache.empire.spring.DBReaderExtractor; import org.apache.empire.spring.EmpireRecord; -import org.apache.empire.spring.DbRecordCallbackHandler; +import org.apache.empire.spring.DBRecordCallbackHandler; import org.apache.empire.xml.XMLWriter; import org.springframework.dao.DataAccessException; import org.springframework.jdbc.core.ConnectionCallback; @@ -174,7 +174,7 @@ public class EmpireAppImpl extends EmpireDaoSupport implements EmpireApp { switch (type) { case BeanList: // Text-Output by iterating through all records. - DbRecordCallbackHandler readerImpl = new DbRecordCallbackHandler() { + DBRecordCallbackHandler readerImpl = new DBRecordCallbackHandler() { public void processRow(DBRecordData reader) { System.out.println(reader.getString(EMP.EMPLOYEE_ID) @@ -193,7 +193,7 @@ public class EmpireAppImpl extends EmpireDaoSupport implements EmpireApp { case Reader: // Text-Output using a list of Java Beans supplied by the // DBReader - DbReaderExtractor<List<SampleBean>> beanListImpl = new DbReaderExtractor<List<SampleBean>>() { + DBReaderExtractor<List<SampleBean>> beanListImpl = new DBReaderExtractor<List<SampleBean>>() { public List<SampleBean> process(DBReader reader) { return reader.getBeanList(SampleBean.class); @@ -254,7 +254,7 @@ public class EmpireAppImpl extends EmpireDaoSupport implements EmpireApp { } public static class XmlDocumentExtractor implements - DbReaderExtractor<Document> { + DBReaderExtractor<Document> { public Document process(DBReader reader) { return reader.getXmlDocument(); @@ -263,7 +263,7 @@ public class EmpireAppImpl extends EmpireDaoSupport implements EmpireApp { } public static class RowToObjectMapDataMapper implements - DbRecordMapper<Map<Object, Object>> { + DBRecordMapper<Map<Object, Object>> { DBTable table; http://git-wip-us.apache.org/repos/asf/empire-db/blob/c6f63849/empire-db-spring/src/main/java/org/apache/empire/spring/example2/EmployeeDaoImpl.java ---------------------------------------------------------------------- diff --git a/empire-db-spring/src/main/java/org/apache/empire/spring/example2/EmployeeDaoImpl.java b/empire-db-spring/src/main/java/org/apache/empire/spring/example2/EmployeeDaoImpl.java index 5d1fe50..2974180 100644 --- a/empire-db-spring/src/main/java/org/apache/empire/spring/example2/EmployeeDaoImpl.java +++ b/empire-db-spring/src/main/java/org/apache/empire/spring/example2/EmployeeDaoImpl.java @@ -27,9 +27,9 @@ import org.apache.empire.db.DBJoinType; import org.apache.empire.db.DBRecord; import org.apache.empire.db.DBRecordData; import org.apache.empire.spring.EmpireDaoSupport; -import org.apache.empire.spring.DbRecordMapper; +import org.apache.empire.spring.DBRecordMapper; import org.apache.empire.spring.EmpireRecord; -import org.apache.empire.spring.DbRecordWriter; +import org.apache.empire.spring.DBRecordWriter; import org.apache.empire.spring.example1.SampleDB; import org.apache.empire.spring.example1.SampleDB.Departments; import org.apache.empire.spring.example1.SampleDB.Employees; @@ -144,7 +144,7 @@ public class EmployeeDaoImpl extends EmpireDaoSupport implements EmployeeDao { getEmpireTemplate().updateRecord(record); } - private class EmployeeMapper implements DbRecordMapper<Employee> { + private class EmployeeMapper implements DBRecordMapper<Employee> { DepartmentMapper departmentMapper = new DepartmentMapper(); @@ -166,7 +166,7 @@ public class EmployeeDaoImpl extends EmpireDaoSupport implements EmployeeDao { } - private class EmployeeWriter implements DbRecordWriter<Employee> { + private class EmployeeWriter implements DBRecordWriter<Employee> { @Override public void write(DBRecord record, Employee entity) { @@ -184,7 +184,7 @@ public class EmployeeDaoImpl extends EmpireDaoSupport implements EmployeeDao { } - private class DepartmentMapper implements DbRecordMapper<Department> { + private class DepartmentMapper implements DBRecordMapper<Department> { // reader cache, in case of joined resultset the same object is returned @@ -213,7 +213,7 @@ public class EmployeeDaoImpl extends EmpireDaoSupport implements EmployeeDao { } - private class DepartmentWriter implements DbRecordWriter<Department> { + private class DepartmentWriter implements DBRecordWriter<Department> { @Override public void write(DBRecord record, Department entity) {
