org.openwms.core.service.spring
Class EntityServiceImpl<T extends AbstractEntity,ID extends Serializable>

java.lang.Object
  extended by org.openwms.core.service.spring.EntityServiceImpl<T,ID>
Type Parameters:
T - Any type of AbstractEntity.
ID - The type of the Entity class' unique id
All Implemented Interfaces:
EntityService<T>, org.springframework.context.ApplicationContextAware
Direct Known Subclasses:
LocationGroupServiceImpl, LocationServiceImpl, TransportServiceImpl, TransportUnitServiceImpl

@Transactional
@Service
public class EntityServiceImpl<T extends AbstractEntity,ID extends Serializable>
extends Object
implements EntityService<T>, org.springframework.context.ApplicationContextAware

An EntityServiceImpl is a generic service that offers some basic CRUD functionality. It is a transactional Spring service annotated with Springs Service to activate exception translation. By implementing ApplicationContextAware the EntityServiceImpl gets the current ApplicationContext injected, thats useful to publish events.

Since:
0.1
Version:
$Revision: 1539 $
Author:
Heiko Scherrer
See Also:
AbstractEntity, EntityService

Field Summary
protected  org.springframework.context.ApplicationContext ctx
          Reference to the ApplicationContext instance.
protected  GenericDao<T,ID> dao
          Generic Repository DAO.
 
Constructor Summary
EntityServiceImpl()
           
 
Method Summary
 void add(T newEntity)
          Add an entity.
 List<T> findAll()
          Find all entities of type T.
 void remove(T entity)
          Removes an entity instance.
 T save(T entity)
          Save an entity of type T.
 void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
          
 void setDao(GenericDao<T,ID> dao)
          The Repository implementation to work with.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dao

protected GenericDao<T extends AbstractEntity,ID extends Serializable> dao
Generic Repository DAO.


ctx

protected org.springframework.context.ApplicationContext ctx
Reference to the ApplicationContext instance.

Constructor Detail

EntityServiceImpl

public EntityServiceImpl()
Method Detail

setApplicationContext

public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)

Specified by:
setApplicationContext in interface org.springframework.context.ApplicationContextAware
See Also:
ApplicationContextAware.setApplicationContext(org.springframework.context.ApplicationContext)

setDao

public void setDao(GenericDao<T,ID> dao)
The Repository implementation to work with. This must be set manually because it is generic.

Parameters:
dao - The Repository to set

findAll

@Transactional(readOnly=true)
public List<T> findAll()
Find all entities of type T. The result is specific to the implementation and can also be null.

Specified by:
findAll in interface EntityService<T extends AbstractEntity>
Returns:
A list of all entities

save

public T save(T entity)
Save an entity of type T.

Specified by:
save in interface EntityService<T extends AbstractEntity>
Parameters:
entity - Instance to be saved
Returns:
The saved instance

remove

public void remove(T entity)
Removes an entity instance.

Specified by:
remove in interface EntityService<T extends AbstractEntity>
Parameters:
entity - Instance to be removed

add

public void add(T newEntity)
Add an entity.

Specified by:
add in interface EntityService<T extends AbstractEntity>
Parameters:
newEntity - New entity instance to be added


Copyright © 2005-2011 openwms.org. All Rights Reserved.