|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectflex.data.assemblers.AbstractAssembler
flex.data.assemblers.HibernateAssembler
An assembler that provides support for hibernate entities as flex destinations in Flex Data Management Services. You can use this class out of the box, or you can extend it get complete control over how your persistence functionality is exposed to clients. You can also add your own fill and count methods to a subclass and refer to them from the configuration file.
| Field Summary | |
protected flex.data.DataDestination |
dataDestination
|
protected String |
destinationId
|
protected flex.data.assemblers.HibernateManager |
hibernateManager
|
protected static Map |
hibernateManagers
|
protected flex.data.assemblers.HibernateType |
hibernateType
|
static String |
LOG_CATEGORY
|
| Fields inherited from interface flex.data.adapters.JavaAdapterConstants |
AUTO_REFRESH_ELEMENT, CONFLICT_MODE_DEFAULT, CONFLICT_MODE_DELETE_ATTR, CONFLICT_MODE_UPDATE_ATTR, COUNT_ELEMENT, FILL_CONTAINS_METHOD_ELEMENT, FILL_ELEMENT, GET_ELEMENT, METHOD_NAME_ELEMENT, ORDERED_ELEMENT, PARAM_TYPES_ELEMENT, SECURITY_CONSTRAINT_ELEMENT, SECURITY_REF_ATTR, SECURITY_RUN_AS_ELEMENT, SYNC_ELEMENT |
| Fields inherited from interface flex.data.assemblers.Assembler |
APPEND_TO_FILL, DO_NOT_EXECUTE_FILL, EXECUTE_FILL, REMOVE_FROM_FILL |
| Constructor Summary | |
HibernateAssembler()
The Assembler class is constructed by Data Management Services so you do not need to construct this yourself. |
|
| Method Summary | |
boolean |
autoRefreshFill(List fillParameters)
The Hibernate assembler always refreshes fill methods automatically so this method returns true for all fills. |
int |
count(List countParams)
Implements the count queries for the hibernate assembler. |
protected org.hibernate.cfg.Configuration |
createHibernateConfiguration(String hibernateConfigFile)
This method returns the hibernate configuration for the given configuration file name. |
void |
createItem(Object item)
Actually performs the createItem operation. |
void |
deleteItem(Object clientVersion)
Deletes the hibernate item. |
protected void |
fetchObjectProperties(Object inst)
Responsible for ensuring that all data that is needed by the serialization process has been fetched. |
Collection |
fill(List fillArgs)
Implements the fill method for the hibernate assembler. |
Object |
getItem(Map identity)
Returns the item for the specified identity. |
protected void |
handleHibernateException(RuntimeException ite,
String type)
This method is called when an exception occurs when processing a hibernate operation. |
void |
initialize(String id,
ConfigMap properties)
This initialize method is called once for each destination. |
int |
refreshFill(List fillParameters,
Object item,
boolean isCreate)
The hibernate assembler refreshes all outstanding fills whenever any item is created or modified. |
void |
updateItem(Object newItem,
Object prevItem,
List changes)
This method is called to update an item in hibernate. |
| Methods inherited from class flex.data.assemblers.AbstractAssembler |
addItemToFill, getItems, removeItemFromFill |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final String LOG_CATEGORY
protected static Map hibernateManagers
protected flex.data.assemblers.HibernateManager hibernateManager
protected flex.data.assemblers.HibernateType hibernateType
protected String destinationId
protected flex.data.DataDestination dataDestination
| Constructor Detail |
public HibernateAssembler()
| Method Detail |
public void initialize(String id,
ConfigMap properties)
The hibernate assembler uses two utility classes. The HibernateManager is a class which is created for each hibernate configuration file you specify. It manages the Data Management Services state for a group of related hibernate entitites. The HibernateType class is created for each assembler instance.
initialize in interface FlexConfigurableinitialize in class AbstractAssemblerid - the destination name for this assembler.properties - the properties used to configure this destination underneath
the properties tag.protected org.hibernate.cfg.Configuration createHibernateConfiguration(String hibernateConfigFile)
public int count(List countParams)
count in interface Assemblercount in class AbstractAssemblercountParams - a list of parameters to the count method provided by the
client invocation.
public Object getItem(Map identity)
getItem in interface AssemblergetItem in class AbstractAssembleridentity - a java.util.Map which contains key/value pairs for
each identity property.
public Collection fill(List fillArgs)
If the destination configuration sets the allow-hql-queries attribute to true, your client can also pass in arbitrary HQL queries. In this case, the first parameter is the string token: "flex:hql", the second parameter is the HQL string and the third parameter specifies the parameter set for the queries as either an array or a java.util.Map.
You can override this method to add additional queries or augment how hibernate queries are implemented in general.
fill in interface Assemblerfill in class AbstractAssemblerfillArgs - the list of fill parameters provided to the DataService.fill
method on the client. Note that the first parameter - the ArrayCollection is not
included in this list.
public boolean autoRefreshFill(List fillParameters)
autoRefreshFill in interface AssemblerautoRefreshFill in class AbstractAssemblerfillParameters - Client-side parameters to a fill method that
created a managed collection still managed by one or more clients.
public int refreshFill(List fillParameters,
Object item,
boolean isCreate)
refreshFill in interface AssemblerrefreshFill in class AbstractAssemblerfillParameters - the parameters which identify a fill method that
is still actively being managed by one or more clients connected to this
server.item - The item which is being created or updated in a recently committed
transactino.isCreate - true if this item was just created operation, false if it was just
updated.
protected void handleHibernateException(RuntimeException ite,
String type)
public void createItem(Object item)
createItem in interface AssemblercreateItem in class AbstractAssembleritem - the initial instance of the item to create.
public void updateItem(Object newItem,
Object prevItem,
List changes)
updateItem in interface AssemblerupdateItem in class AbstractAssemblernewItem - the new version of the item with which to perform the updateprevItem - the original version of the item before these changes were
made (used for conflict detection).changes - the list of changed property names.public void deleteItem(Object clientVersion)
deleteItem in interface AssemblerdeleteItem in class AbstractAssemblerclientVersion - the original version of the item on the client which
the client intends to removeprotected void fetchObjectProperties(Object inst)
The basic rule used here is to do a deep traversal of the property value unless the property is marked as a lazy Data Management Services association. In that case, Data Management Services will only look at the id of the associated object so that is all we need to provide.
One awkward thing about this process is that event a lazy Data Management Services destination fetches the ids of the referenced objects in a collection property. Thus even if the collection is lazy, we need to at least traverse the collection enough to be sure the ids of the referenced items are available.
Also note that we need to be aware the object graphs can contain cycles so stop the traversal if we hit an object we have already visited.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||