org.exoplatform.social.client.core.service
Class ServiceBase<M,S>

java.lang.Object
  extended by org.exoplatform.social.client.core.service.ServiceBase<M,S>
Type Parameters:
M - The object which implements Model interface
S - The object which implements Service interface
All Implemented Interfaces:
CRUDLifecycle<M>, Lifecycle<M,S>, Service<M>
Direct Known Subclasses:
ActivityServiceImplV1Alpha1, ActivityServiceImplV1Alpha2, IdentityServiceImplV1Alpha1

public abstract class ServiceBase<M,S>
extends Object
implements Service<M>, CRUDLifecycle<M>, Lifecycle<M,S>

Abstract implementation of the Lifecycle interface, CRUDLifecycle interface, and Service interface, moreover providing common functionality required when Service execution

Author:
thanh_vucong

Field Summary
protected  CRUDLifecycleSupport<M> crudLifecycle
          The crud lifecycle event support for this component.
protected  LifecycleSupport<M,S> lifecycle
          The lifecycle event support for this component.
protected  boolean started
          Has this component been started?
 
Fields inherited from interface org.exoplatform.social.client.api.event.CRUDLifecycle
AFTER_CREATE_EVENT, AFTER_DELETE_EVENT, AFTER_UPDATE_EVENT, BEFORE_CREATE_EVENT, BEFORE_DELETE_EVENT, BEFORE_UPDATE_EVENT, CREATE_EVENT, DELETE_EVENT, UPDATE_EVENT
 
Fields inherited from interface org.exoplatform.social.client.api.event.Lifecycle
AFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, DESTROY_EVENT, START_EVENT, STOP_EVENT
 
Constructor Summary
ServiceBase()
           
 
Method Summary
 void addCRUDLifecycleListener(CRUDLifecycleListener<M> listener)
          Adds a CRUD lifecycle event listener to this component.
 void addLifecycleListener(LifecycleListener<M,S> listener)
          Adds a lifecycle event listener to this component.
 void doCreate(M newInstance)
          This implementation performs the corresponding action for CRUD operation.
 void doDelete(M existingInstance)
          This implementation performs the corresponding action for CRUD operation.
 void doUpdate(M existingInstance)
          This implementation performs the corresponding action for CRUD operation.
 CRUDLifecycleListener<M>[] findCRUDLifecycleListeners()
          Gets the lifecycle listeners associated with this lifecycle.
 LifecycleListener<M,S>[] findLifecycleListeners()
          Get the lifecycle listeners associated with this lifecycle.
 void postCreate(M newInstance)
          Overrides this method to perform post-processing on new model being saved.
 void postDelete(M existingInstance)
          Overrides this method to perform post-processing on existing model being deleted.
 void postUpdate(M existingInstance)
          Overrides this method to perform post-processing on existing model being updated.
 void preCreate(M newInstance)
          Overrides this method to perform pre-processing on new model being saved.
 void preDelete(M existingInstance)
          Overrides this method to perform pre-processing on existing model being deleted.
 void preUpdate(M existingInstance)
          Overrides this method to perform pre-processing on existing model being updated.
 void removeCRUDLifecycleListener(CRUDLifecycleListener<M> listener)
          Removes a crud lifecycle event listener which was added to this component.
 void removeLifecycleListener(LifecycleListener<M,S> listener)
          Removes a lifecycle event listener which was added to this component.
 void start()
          Prepares for active use of the public methods of this Component.
 void stop()
          Gracefully shut down active use of the public methods of this Component.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.exoplatform.social.client.api.service.Service
create, delete, get, update
 

Field Detail

started

protected boolean started
Has this component been started?


lifecycle

protected LifecycleSupport<M,S> lifecycle
The lifecycle event support for this component.


crudLifecycle

protected CRUDLifecycleSupport<M> crudLifecycle
The crud lifecycle event support for this component.

Constructor Detail

ServiceBase

public ServiceBase()
Method Detail

start

public void start()
           throws LifecycleException
Prepares for active use of the public methods of this Component.

Specified by:
start in interface Lifecycle<M,S>
Throws:
LifecycleException - if this component detects a fatal error that prevents it from being started

stop

public void stop()
          throws LifecycleException
Gracefully shut down active use of the public methods of this Component.

Specified by:
stop in interface Lifecycle<M,S>
Throws:
LifecycleException - if this component detects a fatal error that needs to be reported

addLifecycleListener

public void addLifecycleListener(LifecycleListener<M,S> listener)
Adds a lifecycle event listener to this component.

Specified by:
addLifecycleListener in interface Lifecycle<M,S>
Parameters:
listener - The listener is added

removeLifecycleListener

public void removeLifecycleListener(LifecycleListener<M,S> listener)
Removes a lifecycle event listener which was added to this component.

Specified by:
removeLifecycleListener in interface Lifecycle<M,S>
Parameters:
listener - The listener will be removed.

findLifecycleListeners

public LifecycleListener<M,S>[] findLifecycleListeners()
Get the lifecycle listeners associated with this lifecycle. If this Lifecycle has no listeners registered, a zero-length array is returned.

Specified by:
findLifecycleListeners in interface Lifecycle<M,S>

addCRUDLifecycleListener

public void addCRUDLifecycleListener(CRUDLifecycleListener<M> listener)
Adds a CRUD lifecycle event listener to this component.

Specified by:
addCRUDLifecycleListener in interface CRUDLifecycle<M>
Parameters:
listener - The listener is added

removeCRUDLifecycleListener

public void removeCRUDLifecycleListener(CRUDLifecycleListener<M> listener)
Removes a crud lifecycle event listener which was added to this component.

Specified by:
removeCRUDLifecycleListener in interface CRUDLifecycle<M>
Parameters:
listener - The listener will be removed.

findCRUDLifecycleListeners

public CRUDLifecycleListener<M>[] findCRUDLifecycleListeners()
Gets the lifecycle listeners associated with this lifecycle. If this Lifecycle has no listeners registered, a zero-length array is returned.

Specified by:
findCRUDLifecycleListeners in interface CRUDLifecycle<M>
Returns:
array of listeners registered

doCreate

public final void doCreate(M newInstance)
                    throws SocialClientLibException
This implementation performs the corresponding action for CRUD operation. Create the newInstance model order by preCreate(), create(), postCreate();

Parameters:
newInstance - A new instance
Throws:
AccessDeniedException
ServiceException
SocialClientLibException

preCreate

public void preCreate(M newInstance)
               throws SocialClientLibException
Overrides this method to perform pre-processing on new model being saved.

Parameters:
newInstance - A new instance
Throws:
AccessDeniedException
ServiceException
SocialClientLibException

postCreate

public void postCreate(M newInstance)
                throws SocialClientLibException
Overrides this method to perform post-processing on new model being saved.

Parameters:
newInstance - A new instance
Throws:
AccessDeniedException
ServiceException
SocialClientLibException

doDelete

public final void doDelete(M existingInstance)
                    throws SocialClientLibException
This implementation performs the corresponding action for CRUD operation. Delete the existingInstance model order by preDelete(), delete(), postDelete();

Parameters:
existingInstance - An existing instance
Throws:
AccessDeniedException
ServiceException
SocialClientLibException

preDelete

public void preDelete(M existingInstance)
               throws SocialClientLibException
Overrides this method to perform pre-processing on existing model being deleted.

Parameters:
existingInstance - An existing instance
Throws:
AccessDeniedException
ServiceException
SocialClientLibException

postDelete

public void postDelete(M existingInstance)
                throws SocialClientLibException
Overrides this method to perform post-processing on existing model being deleted.

Parameters:
existingInstance - An existing instance
Throws:
AccessDeniedException
ServiceException
SocialClientLibException

doUpdate

public final void doUpdate(M existingInstance)
                    throws SocialClientLibException
This implementation performs the corresponding action for CRUD operation. Updating the existingInstance model order by preUpdate(), update(), postUpdate();

Parameters:
existingInstance - An existing instance
Throws:
AccessDeniedException
ServiceException
SocialClientLibException

preUpdate

public void preUpdate(M existingInstance)
               throws SocialClientLibException
Overrides this method to perform pre-processing on existing model being updated.

Parameters:
existingInstance - An existing instance
Throws:
AccessDeniedException
ServiceException
SocialClientLibException

postUpdate

public void postUpdate(M existingInstance)
                throws SocialClientLibException
Overrides this method to perform post-processing on existing model being updated.

Parameters:
existingInstance - An existing instance
Throws:
AccessDeniedException
ServiceException
SocialClientLibException


Copyright © 2011 eXo Platform. All Rights Reserved.