org.fuchss.objectcasket.sqlconnector.SqlConnectorImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of object-casket Show documentation
Show all versions of object-casket Show documentation
Object Casket is a simple O/R mapper that can be used together with the Java Persistence API (JPA). The aim is to provide a simple solution for small projects to store multi-related
entities in a simple manner.
package org.fuchss.objectcasket.sqlconnector;
import org.fuchss.objectcasket.common.CasketException;
import org.fuchss.objectcasket.sqlconnector.impl.database.SqlDatabaseFactoryImpl;
import org.fuchss.objectcasket.sqlconnector.impl.database.SqlObjectFactoryImpl;
import org.fuchss.objectcasket.sqlconnector.port.*;
import java.io.Serializable;
class SqlConnectorImpl implements SqlPort, SqlDatabaseFactory, SqlObjectFactory {
private SqlDatabaseFactoryImpl sqlDatabaseFactory;
private SqlObjectFactoryImpl sqlObjectFactory;
@Override
public synchronized SqlDatabaseFactory sqlDatabaseFactory() {
this.initSqlObjectFactory();
if (this.sqlDatabaseFactory == null) {
this.sqlDatabaseFactory = new SqlDatabaseFactoryImpl(this.sqlObjectFactory);
}
return this;
}
@Override
public synchronized SqlObjectFactory sqlObjectFactory() {
this.initSqlObjectFactory();
return this;
}
private void initSqlObjectFactory() {
if (this.sqlObjectFactory == null) {
this.sqlObjectFactory = new SqlObjectFactoryImpl();
}
}
@Override
public synchronized SqlDatabase openDatabase(DBConfiguration config) throws CasketException {
return this.sqlDatabaseFactory.openDatabase(config);
}
@Override
public synchronized void closeDatabase(SqlDatabase db) throws CasketException {
this.sqlDatabaseFactory.closeDatabase(db);
}
@Override
public synchronized DBConfiguration createConfiguration() {
return this.sqlDatabaseFactory.createConfiguration();
}
@Override
public synchronized SqlColumnSignature mkColumnSignature(StorageClass type, Class javaType, T defaultValue) throws CasketException {
return this.sqlObjectFactory.mkColumnSignature(type, javaType, defaultValue);
}
@Override
public SqlObject mkSqlObject(StorageClass type, T obj) throws CasketException {
return this.sqlObjectFactory.mkSqlObject(type, obj);
}
@Override
public synchronized SqlObject duplicate(SqlObject sqlObj) throws CasketException {
return this.sqlObjectFactory.duplicate(sqlObj);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy