Upgraded backend api with generics.
This commit is contained in:
parent
9a6227be5b
commit
1b3e65fa83
53 changed files with 282 additions and 256 deletions
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
package net.forwardfire.vasc.backend;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
|
@ -29,7 +30,7 @@ import java.util.Map;
|
|||
* @author Willem Cazander
|
||||
* @version 1.0 Aug 2, 2007
|
||||
*/
|
||||
abstract public class AbstractVascBackend implements VascBackend {
|
||||
abstract public class AbstractVascBackend<DATA_OBJECT extends Serializable> implements VascBackend<DATA_OBJECT> {
|
||||
|
||||
private String id = null;
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
package net.forwardfire.vasc.backend;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -31,7 +32,7 @@ import java.util.Map;
|
|||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 21, 2007
|
||||
*/
|
||||
public interface VascBackend {
|
||||
public interface VascBackend<DATA_OBJECT extends Serializable> {
|
||||
|
||||
public String getId();
|
||||
public void setId(String id);
|
||||
|
|
@ -39,15 +40,15 @@ public interface VascBackend {
|
|||
public void startBackend();
|
||||
public void stopBackend();
|
||||
|
||||
public List<Object> execute(VascBackendState state) throws VascBackendException;
|
||||
public List<DATA_OBJECT> execute(VascBackendState state) throws VascBackendException;
|
||||
|
||||
public boolean isReadOnly();
|
||||
|
||||
public void persist(Object object) throws VascBackendException;
|
||||
public void persist(DATA_OBJECT object) throws VascBackendException;
|
||||
|
||||
public Object merge(Object object) throws VascBackendException;
|
||||
public DATA_OBJECT merge(DATA_OBJECT object) throws VascBackendException;
|
||||
|
||||
public void delete(Object object) throws VascBackendException;
|
||||
public void delete(DATA_OBJECT object) throws VascBackendException;
|
||||
|
||||
/**
|
||||
* Creates a new Field acces obj the the given field entry.
|
||||
|
|
@ -61,7 +62,7 @@ public interface VascBackend {
|
|||
* note: Do not use inline class here because it needs to be seriabable and the backend is not seriabbzle.
|
||||
* @return
|
||||
*/
|
||||
public VascEntryRecordCreator provideVascEntryRecordCreator();
|
||||
public VascEntryRecordCreator<DATA_OBJECT> provideVascEntryRecordCreator();
|
||||
|
||||
/**
|
||||
* Defines if the backend supports sorting
|
||||
|
|
|
|||
|
|
@ -30,9 +30,7 @@ import java.io.Serializable;
|
|||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 21, 2007
|
||||
*/
|
||||
public interface VascEntryRecordCreator extends Serializable {
|
||||
public interface VascEntryRecordCreator<DATA_OBJECT extends Serializable> extends Serializable {
|
||||
|
||||
public Object newRecord() throws VascBackendException;
|
||||
|
||||
public Class<?> getObjectClass();
|
||||
public DATA_OBJECT newRecord() throws VascBackendException;
|
||||
}
|
||||
|
|
@ -22,6 +22,8 @@
|
|||
|
||||
package net.forwardfire.vasc.backend.data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import net.forwardfire.vasc.backend.VascBackendException;
|
||||
import net.forwardfire.vasc.backend.VascEntryRecordCreator;
|
||||
|
||||
|
|
@ -32,7 +34,7 @@ import net.forwardfire.vasc.backend.VascEntryRecordCreator;
|
|||
* @author Willem Cazander
|
||||
* @version 1.0 Dec 05, 2009
|
||||
*/
|
||||
public class BeanVascEntryRecordCreator implements VascEntryRecordCreator {
|
||||
public class BeanVascEntryRecordCreator<DATA_OBJECT extends Serializable> implements VascEntryRecordCreator<DATA_OBJECT> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private Class<?> resultClass = null;
|
||||
|
|
@ -43,14 +45,11 @@ public class BeanVascEntryRecordCreator implements VascEntryRecordCreator {
|
|||
}
|
||||
this.resultClass=resultClass;
|
||||
}
|
||||
|
||||
public Class<?> getObjectClass() {
|
||||
return resultClass;
|
||||
}
|
||||
|
||||
public Object newRecord() throws VascBackendException {
|
||||
@SuppressWarnings("unchecked")
|
||||
public DATA_OBJECT newRecord() throws VascBackendException {
|
||||
try {
|
||||
return resultClass.newInstance();
|
||||
return (DATA_OBJECT)resultClass.newInstance();
|
||||
} catch (InstantiationException e) {
|
||||
throw new VascBackendException(e);
|
||||
} catch (IllegalAccessException e) {
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ import net.forwardfire.vasc.backend.VascEntryFieldValue;
|
|||
* @author Willem Cazander
|
||||
* @version 1.0 Dec 05, 2009
|
||||
*/
|
||||
public class MapVascEntryFieldValue implements VascEntryFieldValue {
|
||||
public class HashMapVascEntryFieldValue implements VascEntryFieldValue {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
|
@ -23,27 +23,21 @@
|
|||
package net.forwardfire.vasc.backend.data;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.forwardfire.vasc.backend.VascBackendException;
|
||||
import net.forwardfire.vasc.backend.VascEntryRecordCreator;
|
||||
|
||||
|
||||
/**
|
||||
* MapVascEntryRecordCreator creates a new HashMap for Map based record backends.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Dec 05, 2009
|
||||
*/
|
||||
public class MapVascEntryRecordCreator implements VascEntryRecordCreator {
|
||||
public class HashMapVascEntryRecordCreator implements VascEntryRecordCreator<HashMap<String,Object>> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public Class<?> getObjectClass() {
|
||||
return Map.class;
|
||||
}
|
||||
|
||||
public Object newRecord() throws VascBackendException {
|
||||
public HashMap<String,Object> newRecord() throws VascBackendException {
|
||||
return new HashMap<String,Object>(10);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue