com.uwyn.rife.rep
Class BlockingParticipant

java.lang.Object
  extended by com.uwyn.rife.rep.BlockingParticipant
All Implemented Interfaces:
Participant, Runnable
Direct Known Subclasses:
ParticipantConfig, ParticipantCursors, ParticipantDatasources, ParticipantImages, ParticipantMemoryScheduler, ParticipantMemoryUsers, ParticipantSite, ParticipantSpringWeb

public abstract class BlockingParticipant
extends Object
implements Participant, Runnable

A repository participant is basically a service that needs to be initialized before it can return objects that correspond to specified identification keys.

Each participant is launched in a seperate thread which is started to perform the initialization. This thread can run in parallel with the initializations of other participants. Whether this is the case is determined by the repository through the blocking parameter that has to be provided during the registration of the participant with the repository.

Since:
1.0
Version:
$Revision: 3634 $
Author:
Geert Bevin (gbevin[remove] at uwyn dot com)
See Also:
Rep

Constructor Summary
BlockingParticipant()
           
 
Method Summary
protected  Object _getObject()
           
protected  Object _getObject(Object key)
          Does the actual retrieval of an object from the participant according to a specified key.
protected  void cleanup()
          Performs the actual cleanup actions for the participant.
 String getCleanupMessage()
          Returns a message that is supposed to describe the cleanup of this participant.
 String getInitializationMessage()
          Returns a message that is supposed to describe the initialization of this participant.
 String getName()
          Retrieves the name of the thread.
 Object getObject()
          Returns the default object for this participant.
 Object getObject(Object key)
          Retrieves the object from the participant that corresponds to a particular key.
 String getParameter()
          Retrieves the optional parameter.
 BlockingRepository getRepository()
          Retrieves the repository that this participant belongs to.
 ResourceFinder getResourceFinder()
          Retrieves the resource finder that is used during the initialization.
 boolean hadInitializationError()
          Checks if the initialization of this participant threw an error.
protected abstract  void initialize()
          Performs the actual initialization actions for the participant.
 boolean isFinished()
          Checks if the initialization of this participant is finished.
 void run()
          Starts the initialization.
 void setCleanupMessage(String message)
          Overrides the default message that describes the cleanup of this participant.
 void setInitializationMessage(String message)
          Overrides the default message that describes the initialization of this participant.
 void setParameter(String parameter)
          Sets the optional parameter.
 void setResourceFinder(ResourceFinder resourceFinder)
          Sets the resource finder that can be used during the initialize() method.
 void waitUntilFinished()
          Makes the calling thread wait until the initialization of this participant has finished.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BlockingParticipant

public BlockingParticipant()
Method Detail

getName

public String getName()
Retrieves the name of the thread.

Since:
1.0

initialize

protected abstract void initialize()
Performs the actual initialization actions for the participant. This is an abstract method that needs to be implemented by every participant.

Since:
1.0

_getObject

protected Object _getObject(Object key)
Does the actual retrieval of an object from the participant according to a specified key. This method needs to be implemented by every participant that provides access to data, by default it just returns null.

Parameters:
key - An Object instance that is used as the key to obtain a corresponding object from the participant with.
Returns:
null if no object could be found that corresponds to the provided key; or

an Object instance that corresponds to the provided key

Since:
1.0
See Also:
getObject(), getObject(Object)

cleanup

protected void cleanup()
Performs the actual cleanup actions for the participant. This is method can be overridden when a participant needs to customize the cleanup..

Since:
1.0

getRepository

public BlockingRepository getRepository()
Retrieves the repository that this participant belongs to.

Since:
1.0

setParameter

public void setParameter(String parameter)
Sets the optional parameter.

Parameters:
parameter - A String containing the optional parameter for this participant.
Since:
1.0

getParameter

public String getParameter()
Retrieves the optional parameter.

Returns:
null if no parameter was provided; or

the requested parameter String instance otherwise

Since:
1.0

setResourceFinder

public void setResourceFinder(ResourceFinder resourceFinder)
Sets the resource finder that can be used during the initialize() method.

Parameters:
resourceFinder - A ResourceFinder instance containing the resource finder that is used during the initialization of the repository and its participants.
Since:
1.0
See Also:
getResourceFinder()

getResourceFinder

public ResourceFinder getResourceFinder()
Retrieves the resource finder that is used during the initialization.

Returns:
null if no resource finder was provided or if the method was called after the initialization; or

the requested ResourceFinder instance otherwise

Since:
1.0
See Also:
setResourceFinder(ResourceFinder)

run

public final void run()
Starts the initialization.

Specified by:
run in interface Runnable
Since:
1.0

isFinished

public final boolean isFinished()
Checks if the initialization of this participant is finished.

Specified by:
isFinished in interface Participant
Returns:
true if the initialization is finished; or

false if the initialization is in progress

Since:
1.0

hadInitializationError

public boolean hadInitializationError()
Checks if the initialization of this participant threw an error.

Returns:
true if the initialization threw an error; or

false if the initialization was successful

Since:
1.0

waitUntilFinished

public final void waitUntilFinished()
Makes the calling thread wait until the initialization of this participant has finished.

Since:
1.0

setInitializationMessage

public void setInitializationMessage(String message)
Overrides the default message that describes the initialization of this participant.

Parameters:
message - A String containing the message.
Since:
1.0
See Also:
getInitializationMessage()

getInitializationMessage

public String getInitializationMessage()
Returns a message that is supposed to describe the initialization of this participant. If no message has been set with setInitializationMessage(String message), a default message is generated.

Returns:
A String containing the message that describes the initialization of this participant.
Since:
1.0
See Also:
setInitializationMessage(String)

setCleanupMessage

public void setCleanupMessage(String message)
Overrides the default message that describes the cleanup of this participant.

Parameters:
message - A String containing the message.
Since:
1.0
See Also:
getCleanupMessage()

getCleanupMessage

public String getCleanupMessage()
Returns a message that is supposed to describe the cleanup of this participant. If no message has been set with setCleanupMessage(String message), a default message is generated.

Returns:
A String containing the message that describes the cleanup of this participant.
Since:
1.0
See Also:
setCleanupMessage(String)

getObject

public final Object getObject()
Returns the default object for this participant.

If the initialization of the participant hasn't finished yet, the thread that executes this method will be suspended and woken up when the initialization finishes.

Specified by:
getObject in interface Participant
Returns:
null if no default object exists; or

an Object instance containing the default object

Since:
1.0
See Also:
getObject(Object), _getObject(Object)

_getObject

protected Object _getObject()

getObject

public final Object getObject(Object key)
Retrieves the object from the participant that corresponds to a particular key.

If the initialization of the participant hasn't finished yet, the thread that executes this method will be suspended and woken up when the initialization finishes.

Specified by:
getObject in interface Participant
Parameters:
key - An Object instance that used as the key to obtain a corresponding object from the participant with.
Returns:
null if no object could be found that corresponds to the provided key; or

the requested Object instance

Since:
1.0
See Also:
getObject(), _getObject(Object)


Copyright © 2001-2007 Uwyn sprl/bvba. All Rights Reserved.