cz.muni.fi.pclis.commons.service
Class GenericServiceImpl<Dom extends DomainObject,Dao extends GenericDao<Dom>>

java.lang.Object
  extended by cz.muni.fi.pclis.commons.service.GenericServiceImpl<Dom,Dao>
All Implemented Interfaces:
GenericService<Dom>

@Transactional
public class GenericServiceImpl<Dom extends DomainObject,Dao extends GenericDao<Dom>>
extends Object
implements GenericService<Dom>

Simple Generic implementation of GenericService using some implementation of GenericDao User: Ľuboš Pecho Date: 11.8.2009 Time: 13:15:11


Field Summary
private  Dao dao
          dao object
private  Class<Dom> persistentClass
          Entity class
 
Constructor Summary
GenericServiceImpl(Class<Dom> persistentClass)
          Constructs new service
 
Method Summary
protected  void assertConfigured()
           
 Dom create(Dom entity)
          persists the entity
 List<Dom> getAll()
          returns all entities
 Dom getById(long id)
          get the entity with given id
 Dao getDao()
          returns the dao
 Dom refresh(Dom entity)
          refreshes the entity from database
 void remove(Dom entity)
          removes a persisted entity
 void removeById(long id)
          removes entity with given id
 Dom searchById(long id)
          searches the entity with given id
 void setDao(Dao dao)
          sets the dao
 Dom update(Dom entity)
          updates the entity
 Dao useDao()
          tries to use dao
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

persistentClass

private Class<Dom extends DomainObject> persistentClass
Entity class


dao

private Dao extends GenericDao<Dom> dao
dao object

Constructor Detail

GenericServiceImpl

public GenericServiceImpl(Class<Dom> persistentClass)
Constructs new service

Parameters:
persistentClass -
Method Detail

getById

public Dom getById(long id)
get the entity with given id

Specified by:
getById in interface GenericService<Dom extends DomainObject>
Returns:
entity

searchById

public Dom searchById(long id)
searches the entity with given id

Specified by:
searchById in interface GenericService<Dom extends DomainObject>
Returns:
entity, null if none is found

getAll

public List<Dom> getAll()
returns all entities

Specified by:
getAll in interface GenericService<Dom extends DomainObject>
Returns:

create

public Dom create(Dom entity)
persists the entity

Specified by:
create in interface GenericService<Dom extends DomainObject>
Returns:

update

public Dom update(Dom entity)
updates the entity

Specified by:
update in interface GenericService<Dom extends DomainObject>
Returns:

remove

public void remove(Dom entity)
removes a persisted entity

Specified by:
remove in interface GenericService<Dom extends DomainObject>

removeById

public void removeById(long id)
removes entity with given id

Specified by:
removeById in interface GenericService<Dom extends DomainObject>

refresh

public Dom refresh(Dom entity)
refreshes the entity from database

Specified by:
refresh in interface GenericService<Dom extends DomainObject>
Returns:

assertConfigured

protected void assertConfigured()
Throws:
IllegalStateException - if dao is not set

useDao

public Dao useDao()
tries to use dao

Returns:

getDao

public Dao getDao()
returns the dao

Returns:

setDao

public void setDao(Dao dao)
sets the dao

Parameters:
dao -


Copyright © 2009-2010 Faculty of Informatics, Masaryk university, Brno. All Rights Reserved.