Skip to content
stemey edited this page Jul 28, 2012 · 1 revision

The atem pojo store is used by the "in memory"-MetaAttributeService to store meta data in memory.

The store holds a collection of entities who provide the IdentityService. It can be extended by adding parameterized views. These are mappings of a key to an entity or set of entities. The Viewcreator is the main class to implement to create a custom view. Here is a trivial implementation, that creates a view that maps the entity's id to the entity:

FindByIdViewCreator implements ViewCreator {
// return the keys under which the entity can be found
public Serializable[] getKeys(Object entity) {
	Serializable id=entityTypeRepository.getEntityType(entity).getService(IdentityService.class);
	return new Serializable[]{id};		
}
// return the key for the query parameter. The parameter is the id.
public Serializable getKeyForParams(Object[] params) {
	return  (Serializable) params[0];		
}
}

To execute a view:

@Resource("atem-pojo-store")
PojoStore store;

public Object findById(int id) {
	return store.getView("findById").execute(new Object[]{id});
}