|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.dasein.persist.PersistentFactory<T>
T - the type of object managed by this factory
public final class PersistentFactory<T>
Manages the movement of persistent objects between the data store and a memory cache. This class is generally used as a delegate by true factory classes.
public class EmployeeFactory {
private PersistentFactory<Employee> factory;
public EmployeeFactory() {
factory = new PersistentFactory<Employee>(Employee.class, "employeeId", "ssn");
}
public Collection<Employee> findEmployees(String ln) throws PersistenceException {
return factory.find("lastName", ln);
}
public Employee getEmployee(Long empid) throws PersistenceException {
return factory.get("employeeId", empid);
}
public Employee getEmployee(String ssn) throws PersistenceException {
return factory.get("ssn", ssn);
}
public void updateEmployee(Transaction xaction, Employee emp, Map<String,Object> state)
throws PersistenceException {
factory.update(xaction, emp, state);
}
}
This persistence is automatic. You may, however, specify your own queries that will be
managed by passing in an extension of the Execution class.
Last modified: $Date: 2009/07/02 01:36:20 $
| Nested Class Summary | |
|---|---|
static interface |
PersistentFactory.DependencyManager<T>
Deprecated. |
| Field Summary | |
|---|---|
static String |
LISTING
Deprecated. Convenience constant used by search executions as they key for multi-valued results. |
static org.apache.log4j.Logger |
logger
Deprecated. |
| Constructor Summary | |
|---|---|
PersistentFactory(Class<T> cls,
AutomatedSql.TranslationMethod transMeth,
String... keys)
Deprecated. Constructs a new persistent factory for objects of the specified class with the named unique identifier attributes. |
|
PersistentFactory(Class<T> cls,
boolean custom,
String... keys)
Deprecated. |
|
PersistentFactory(Class<T> cls,
String... keys)
Deprecated. Constructs a new persistent factory for objects of the specified class with the named unique identifier attributes. |
|
| Method Summary | |
|---|---|
void |
addCounter(String field,
Class<? extends Execution> cls)
Deprecated. Adds a query for counts on a specified field. |
void |
addSearch(String field,
Class<? extends Execution> cls)
Deprecated. Adds a query for searches on a specified field. |
void |
addSingleton(String field,
Class<? extends Execution> cls)
Deprecated. Adds a query for searches on a specified field. |
static Class<? extends Execution> |
compileTranslator(Class<?> t,
String which)
Deprecated. |
long |
count()
Deprecated. Counts the total number of objects governed by this factory in the database. |
long |
count(Class<? extends Execution> cls,
Map<String,Object> criteria)
Deprecated. Counts the number of items matching an arbitrary query. |
long |
count(SearchTerm[] terms)
Deprecated. |
long |
count(String field,
Object val)
Deprecated. Counts the total number of objects in the database matching the specified criteria. |
long |
countJoin(Class<? extends Object> jc,
String key,
Object val)
Deprecated. |
T |
create(Transaction xaction,
Map<String,Object> state)
Deprecated. Creates the specified object with the data provided in the specified state under the governance of the specified transaction. |
Collection<T> |
find(Class<? extends Execution> cls,
Map<String,Object> criteria)
Deprecated. Executes an arbitrary search using the passed in search class and criteria. |
Collection<T> |
find(Class<? extends Object> jc,
String key,
Object id)
Deprecated. |
Collection<T> |
find(SearchTerm... terms)
Deprecated. |
Collection<T> |
find(SearchTerm[] terms,
Boolean orderDesc,
String... orderFields)
Deprecated. |
Collection<T> |
find(SearchTerm[] terms,
org.dasein.util.JiteratorFilter<T> filter,
Boolean orderDesc,
String... orderFields)
Deprecated. |
Collection<T> |
find(String field,
Object val)
Deprecated. Executes a search that may return multiple values. |
Collection<T> |
find(String field,
Object val,
Boolean orderDesc,
String... orderFields)
Deprecated. |
T |
get(Map<String,Object> state)
Deprecated. |
T |
get(String id,
Object val)
Deprecated. Retrieves the object uniquely identified by the value for the specified ID field. |
String |
getKey()
Deprecated. |
long |
getNewKeyValue()
Deprecated. |
Collection<T> |
list()
Deprecated. Loads all elements of this class from the data store. |
Collection<T> |
list(boolean orderDesc,
String... orderFields)
Deprecated. |
Collection<T> |
list(Class<? extends Execution> cls)
Deprecated. |
Map<String,org.dasein.util.Translator<String>> |
loadTranslations(Transaction xaction,
String idstr)
Deprecated. |
void |
loadXml(InputStream in)
Deprecated. |
void |
remove(Transaction xaction,
T item)
Deprecated. Removes the specified item from the system permanently. |
void |
removeTranslations(Transaction xaction,
String idstr)
Deprecated. |
void |
saveTranslation(Transaction xaction,
String idstr,
String attr,
org.dasein.util.Translator<String> val)
Deprecated. |
void |
setCreate(Class<? extends Execution> cls)
Deprecated. Sets the class that manages the query that will create objects in this factory in the data store. |
void |
setDependency(PersistentFactory.DependencyManager<T> mgr)
Deprecated. Sets the callback class to handle the management of dependencies. |
void |
setExportHook(ExportHook<T> hook)
Deprecated. |
void |
setImportHook(ImportHook<T> hook)
Deprecated. |
void |
setRemove(Class<? extends Execution> cls)
Deprecated. Sets the class that manages the query that will remove objects in this factory from the data store. |
void |
setUpdate(Class<? extends Execution> cls)
Deprecated. Sets the class that manages the query that will update objects in this factory in the data store. |
String |
toString()
Deprecated. |
void |
update(Transaction xaction,
T item,
Map<String,Object> state)
Deprecated. Updates the specified object with the data provided in the specified state under the governance of the specified transaction. |
void |
write(File file,
InputStream is)
Deprecated. |
void |
write(File file,
String data)
Deprecated. |
void |
writeXml(PrintWriter output)
Deprecated. |
void |
writeXml(PrintWriter output,
Class<? extends Execution> cls,
Map<String,Object> criteria)
Deprecated. |
void |
writeXml(PrintWriter output,
String field,
Object val)
Deprecated. |
void |
writeXml(PrintWriter output,
T item)
Deprecated. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final org.apache.log4j.Logger logger
public static final String LISTING
| Constructor Detail |
|---|
public PersistentFactory(Class<T> cls,
String... keys)
cls - the class of objects managed by this factorykeys - a list of unique identifiers for instances of the specified class
@Deprecated
public PersistentFactory(Class<T> cls,
boolean custom,
String... keys)
cls - the class of objects managed by this factorykeys - a list of unique identifiers for instances of the specified class
public PersistentFactory(Class<T> cls,
AutomatedSql.TranslationMethod transMeth,
String... keys)
cls - the class of objects managed by this factorykeys - a list of unique identifiers for instances of the specified class| Method Detail |
|---|
public static Class<? extends Execution> compileTranslator(Class<?> t,
String which)
throws PersistenceException
PersistenceException
public void addCounter(String field,
Class<? extends Execution> cls)
field - the field to count matches oncls - the class of the query that performs the count
public void addSearch(String field,
Class<? extends Execution> cls)
field - the field to search oncls - the class of the query that performs the search
public void addSingleton(String field,
Class<? extends Execution> cls)
field - the field to search oncls - the class of the query that performs the search
public long count()
throws PersistenceException
PersistenceException - an error occurred counting the elements in the database
public long count(String field,
Object val)
throws PersistenceException
field - the field to match onval - the value to match against
PersistenceException - an error occurred counting the elements in the database
public long count(SearchTerm[] terms)
throws PersistenceException
PersistenceException
public long count(Class<? extends Execution> cls,
Map<String,Object> criteria)
throws PersistenceException
cls - the execution class for the arbitrary querycriteria - the criteria to match against for the query
PersistenceException - an error occurred executing the query.
public long countJoin(Class<? extends Object> jc,
String key,
Object val)
throws PersistenceException
PersistenceException
public T create(Transaction xaction,
Map<String,Object> state)
throws PersistenceException
xaction - the transaction governing this eventstate - the new state for the new object
PersistenceException - an error occurred talking to the data store, or
creates are not supported
public Collection<T> find(String field,
Object val)
throws PersistenceException
field - the field being searched onval - the value being searched against
PersistenceException - an error occurred talking to the data store
public Collection<T> find(String field,
Object val,
Boolean orderDesc,
String... orderFields)
throws PersistenceException
PersistenceException
public Collection<T> find(SearchTerm... terms)
throws PersistenceException
PersistenceException
public Collection<T> find(SearchTerm[] terms,
Boolean orderDesc,
String... orderFields)
throws PersistenceException
PersistenceException
public Collection<T> find(SearchTerm[] terms,
org.dasein.util.JiteratorFilter<T> filter,
Boolean orderDesc,
String... orderFields)
throws PersistenceException
PersistenceException
public Collection<T> find(Class<? extends Object> jc,
String key,
Object id)
throws PersistenceException
PersistenceException
public Collection<T> find(Class<? extends Execution> cls,
Map<String,Object> criteria)
throws PersistenceException
cls - the class to perform the searchcriteria - the search criteria
PersistenceException - an error occurred performing the search
public T get(Map<String,Object> state)
throws PersistenceException
PersistenceException
public T get(String id,
Object val)
throws PersistenceException
id - the ID field identifying the objectval - the value that uniquely identifies the desired object
PersistenceException - an error occurred talking to the data storepublic String getKey()
public long getNewKeyValue()
throws PersistenceException
PersistenceException
public Collection<T> list()
throws PersistenceException
PersistenceException - an error occurred executing the query
public Collection<T> list(boolean orderDesc,
String... orderFields)
throws PersistenceException
PersistenceException
public Collection<T> list(Class<? extends Execution> cls)
throws PersistenceException
PersistenceException
public Map<String,org.dasein.util.Translator<String>> loadTranslations(Transaction xaction,
String idstr)
throws PersistenceException
PersistenceException
public void loadXml(InputStream in)
throws PersistenceException
PersistenceException
public void remove(Transaction xaction,
T item)
throws PersistenceException
xaction - the transaction under which this event is occurringitem - the item to be removed
PersistenceException - an error occurred talking to the data store or
removal of these objects is prohibited
public void removeTranslations(Transaction xaction,
String idstr)
throws PersistenceException
PersistenceException
public void saveTranslation(Transaction xaction,
String idstr,
String attr,
org.dasein.util.Translator<String> val)
throws PersistenceException
PersistenceExceptionpublic void setCreate(Class<? extends Execution> cls)
cls - the execution class that creates objects in the data storepublic void setDependency(PersistentFactory.DependencyManager<T> mgr)
mgr - the dependency manager to use for dependency managementpublic void setExportHook(ExportHook<T> hook)
public void setImportHook(ImportHook<T> hook)
public void setRemove(Class<? extends Execution> cls)
cls - the execution class that removes objects from the data storepublic void setUpdate(Class<? extends Execution> cls)
cls - the execution class that updates objects in the data storepublic String toString()
toString in class Object
public void update(Transaction xaction,
T item,
Map<String,Object> state)
throws PersistenceException
xaction - the transaction governing this eventitem - the item to be updatedstate - the new state for the updated object
PersistenceException - an error occurred talking to the data store, or
updates are not supported
public void write(File file,
String data)
throws IOException
IOException
public void write(File file,
InputStream is)
throws IOException
IOException
public void writeXml(PrintWriter output)
throws PersistenceException
PersistenceException
public void writeXml(PrintWriter output,
T item)
throws PersistenceException
PersistenceException
public void writeXml(PrintWriter output,
String field,
Object val)
throws PersistenceException
PersistenceException
public void writeXml(PrintWriter output,
Class<? extends Execution> cls,
Map<String,Object> criteria)
throws PersistenceException
PersistenceException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||