| java.lang.Object java.lang.ThreadGroup com.uwyn.rife.rep.BlockingRepository
BlockingRepository | public class BlockingRepository extends ThreadGroup implements Repository(Code) | | The BlockingRepository class provides a
Repository implementation that loads the participants from an
XML file.
This file defaults to rep/participants.xml , but it can be
overridden by providing another filename to the
BlockingRepository.initialize(String,ResourceFinder) initialize method. The
participants are initialized according to their listed order.
Following is an example of such an XML file :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE rep SYSTEM "/dtd/rep.dtd">
<rep>
<participant blocking="true" parameter="rep/config.xml">ParticipantConfig</participant>
<participant blocking="false" parameter="graphics/buttons/">ParticipantImages</participant>
<participant name="my cursors" blocking="false" parameter="graphics/cursors/">ParticipantCursors</participant>
</rep>
Each participant has a blocking attribute that determines
whether the repository should wait for the end of the participant's
initialization before progressing to the next participant or not. Using
this intelligently, it's possible to dramatically increase the perceived
startup time of an application.
Optionally a participant can have a name attribute which
makes it possible to declare multiple participants of the same class. If no
name is provided, the participant's class name will be used to identify the
declared participant.
Optionally a participant can also have a parameter
attribute which is merely a String that is provided to the
participant object for configuration purposes.
Listeners can be added to the repository to receive notifications about
the initialization advancement of the participants and to know when the
initialization has completely finished. These notifications can, for
example, be used to display a progress bar in a splash window and to switch
to the real application window when the initialization has finished.
The JDK's logging facility is used to output informative text during the
advancement of the initialization. Each participant has to provide an
initialization message that will be output.
author: Geert Bevin (gbevin[remove] at uwyn dot com) version: $Revision: 3634 $ See Also: RepositoryListener See Also: BlockingParticipant since: 1.0 |
Constructor Summary | |
public | BlockingRepository() Default constructor without a repository context. | public | BlockingRepository(Object context) Constructor which sets up a the context in which the repository is initialized. |
Method Summary | |
public boolean | addParticipant(String className) Adds a BlockingParticipant to the repository, using the
class name for the name of the participant.
The participant will not be blocking and have no parameter.
Parameters: className - The fully resolved name of the participant's class, oronly the class name if the participant resides in thecom.uwyn.rife.rep.participants package. | public boolean | addParticipant(String className, boolean blocking) Adds a BlockingParticipant to the repository, using the
class name for the name of the participant.
The participant will have no parameter.
Parameters: className - The fully resolved name of the participant's class, oronly the class name if the participant resides in thecom.uwyn.rife.rep.participants package. Parameters: blocking - Indicates if this a blocking participant or not. | public boolean | addParticipant(String className, String parameter) Adds a BlockingParticipant to the repository, using the
class name for the name of the participant.
The participant will not be blocking.
Parameters: className - The fully resolved name of the participant's class, oronly the class name if the participant resides in thecom.uwyn.rife.rep.participants package. Parameters: parameter - An optional string that contains the parameter forthis participant. | public boolean | addParticipant(String className, boolean blocking, String parameter) Adds a BlockingParticipant to the repository, using the
class name for the name of the participant.
Parameters: className - The fully resolved name of the participant's class, oronly the class name if the participant resides in thecom.uwyn.rife.rep.participants package. Parameters: blocking - Indicates if this a blocking participant or not. Parameters: parameter - An optional string that contains the parameter forthis participant. | public boolean | addParticipant(String className, String name, boolean blocking, String parameter) Adds a BlockingParticipant to the repository.
Parameters: className - The fully resolved name of the participant's class, oronly the class name if the participant resides in thecom.uwyn.rife.rep.participants package. Parameters: name - The name under which the participant will be registered, ifthe name is null the class name will be used Parameters: blocking - Indicates if this a blocking participant or not. Parameters: parameter - An optional string that contains the parameter forthis participant. | public boolean | addParticipant(Class klass, boolean blocking, String parameter) Adds a BlockingParticipant to the repository, using the
class name as the name of the participant.
Parameters: klass - The class of the participant. Parameters: blocking - Indicates if this a blocking participant or not. Parameters: parameter - An optional string that contains the parameter forthis participant. | public boolean | addParticipant(Class klass) Adds a BlockingParticipant to the repository, using the
class name as the name of the participant.
The participant will not be blocking and have no parameter.
Parameters: klass - The class of the participant.this participant. | public boolean | addParticipant(Class klass, boolean blocking) Adds a BlockingParticipant to the repository, using the
class name as the name of the participant.
The participant will have no parameter.
Parameters: klass - The class of the participant. Parameters: blocking - Indicates if this a blocking participant or not. | public boolean | addParticipant(Class klass, String parameter) Adds a BlockingParticipant to the repository, using the
class name as the name of the participant.
The participant will not be blocking.
Parameters: klass - The class of the participant. Parameters: parameter - An optional string that contains the parameter forthis participant. | public boolean | addParticipant(Class klass, String name, boolean blocking, String parameter) Adds a BlockingParticipant to the repository.
Parameters: klass - The class of the participant. Parameters: name - The name under which the participant will be registered, ifthe name is null the class name will be used Parameters: blocking - Indicates if this a blocking participant or not. Parameters: parameter - An optional string that contains the parameter forthis participant. | public void | addRepListener(RepositoryListener repListener) Adds the specified repository listener to receive repository
initialization events. | public void | cleanup() Cleans up the participants in the order in which they have been
declared. | public void | fireInitActionPerformed(BlockingParticipant participant) Notifies the registered listeners that a new initialization action has
been performed.
This is always triggered when a participant's initialization has
finished. | public void | fireInitFinished() Notifies the registered listeners that the repository initialization
has finished. | public Object | getContext() | public BlockingParticipant | getParticipant(String name) Looks for the participant that corresponds to a given name and returns
it when found.
Parameters: name - The name of the participant instance that you wish toretrieve from the repository.If no name was provided during the XML specification, theparticipant will have been registered with its class name. | public Collection<BlockingParticipant> | getParticipants(String className) Returns all the participants with a given class name
Parameters: className - The class name of the participants that you wish toretrieve from the repository.If the participant's class is not part of thecom.uwyn.rife.rep.participants package, its full classname has to be provided, otherwise just the name of the class itself issufficient. | public HierarchicalProperties | getProperties() | public boolean | hasParticipant(String name) Verifies if a participant that corresponds to a given name is present.
Parameters: name - The name of the participant object that you wish toretrieve from the repository. | public void | initialize(String repXmlPath, ResourceFinder resourcefinder) Parses the XML file to determine what the participants are. | public boolean | isFinished() Obtains the finished status of the initialization. | public void | removeRepListener(RepositoryListener repListener) Removes the repository listener so that it no longer receives
repository initialization events. | public void | runParticipants() Sequentially execute the participants according to their registration
order. | public void | runParticipants(ResourceFinder resourceFinder) Sequentially execute the participants according to their registration
order. | public void | uncaughtException(Thread thread, Throwable e) If participants call an exception, clean up correctly and rethrow the
exception afterwards. |
BlockingRepository | public BlockingRepository()(Code) | | Default constructor without a repository context.
|
BlockingRepository | public BlockingRepository(Object context)(Code) | | Constructor which sets up a the context in which the repository is initialized.
|
addParticipant | public boolean addParticipant(String className) throws RepException(Code) | | Adds a BlockingParticipant to the repository, using the
class name for the name of the participant.
The participant will not be blocking and have no parameter.
Parameters: className - The fully resolved name of the participant's class, oronly the class name if the participant resides in thecom.uwyn.rife.rep.participants package. true if the participants was added successfully;or false if errors occurred See Also: BlockingParticipant See Also: Participant See Also: BlockingRepository.addParticipant(Class,String,boolean,String) since: 1.5
|
addParticipant | public boolean addParticipant(String className, boolean blocking) throws RepException(Code) | | Adds a BlockingParticipant to the repository, using the
class name for the name of the participant.
The participant will have no parameter.
Parameters: className - The fully resolved name of the participant's class, oronly the class name if the participant resides in thecom.uwyn.rife.rep.participants package. Parameters: blocking - Indicates if this a blocking participant or not. true if the participants was added successfully;or false if errors occurred See Also: BlockingParticipant See Also: Participant See Also: BlockingRepository.addParticipant(Class,String,boolean,String) since: 1.5
|
addParticipant | public boolean addParticipant(String className, String parameter) throws RepException(Code) | | Adds a BlockingParticipant to the repository, using the
class name for the name of the participant.
The participant will not be blocking.
Parameters: className - The fully resolved name of the participant's class, oronly the class name if the participant resides in thecom.uwyn.rife.rep.participants package. Parameters: parameter - An optional string that contains the parameter forthis participant. true if the participants was added successfully;or false if errors occurred See Also: BlockingParticipant See Also: Participant See Also: BlockingRepository.addParticipant(Class,String,boolean,String) since: 1.5
|
addParticipant | public boolean addParticipant(String className, boolean blocking, String parameter) throws RepException(Code) | | Adds a BlockingParticipant to the repository, using the
class name for the name of the participant.
Parameters: className - The fully resolved name of the participant's class, oronly the class name if the participant resides in thecom.uwyn.rife.rep.participants package. Parameters: blocking - Indicates if this a blocking participant or not. Parameters: parameter - An optional string that contains the parameter forthis participant. true if the participants was added successfully;orfalse if errors occurred See Also: BlockingParticipant See Also: Participant See Also: BlockingRepository.addParticipant(Class,String,boolean,String) since: 1.5
|
addParticipant | public boolean addParticipant(String className, String name, boolean blocking, String parameter) throws RepException(Code) | | Adds a BlockingParticipant to the repository.
Parameters: className - The fully resolved name of the participant's class, oronly the class name if the participant resides in thecom.uwyn.rife.rep.participants package. Parameters: name - The name under which the participant will be registered, ifthe name is null the class name will be used Parameters: blocking - Indicates if this a blocking participant or not. Parameters: parameter - An optional string that contains the parameter forthis participant. true if the participants was added successfully;orfalse if errors occurred See Also: BlockingParticipant See Also: Participant See Also: BlockingRepository.addParticipant(Class,String,boolean,String) since: 1.0
|
addParticipant | public boolean addParticipant(Class klass, boolean blocking, String parameter) throws RepException(Code) | | Adds a BlockingParticipant to the repository, using the
class name as the name of the participant.
Parameters: klass - The class of the participant. Parameters: blocking - Indicates if this a blocking participant or not. Parameters: parameter - An optional string that contains the parameter forthis participant. true if the participants was added successfully;orfalse if errors occurred See Also: BlockingParticipant See Also: Participant See Also: BlockingRepository.addParticipant(Class,String,boolean,String) since: 1.5
|
addParticipant | public boolean addParticipant(Class klass, String name, boolean blocking, String parameter) throws RepException(Code) | | Adds a BlockingParticipant to the repository.
Parameters: klass - The class of the participant. Parameters: name - The name under which the participant will be registered, ifthe name is null the class name will be used Parameters: blocking - Indicates if this a blocking participant or not. Parameters: parameter - An optional string that contains the parameter forthis participant. true if the participants was added successfully;orfalse if errors occurred See Also: BlockingParticipant See Also: Participant since: 1.0
|
cleanup | public void cleanup() throws RepException(Code) | | Cleans up the participants in the order in which they have been
declared. Every participant's cleanup() method is
successively called.
exception: RepException - when an error occurs during the cleanup. since: 1.0 |
fireInitActionPerformed | public void fireInitActionPerformed(BlockingParticipant participant)(Code) | | Notifies the registered listeners that a new initialization action has
been performed.
This is always triggered when a participant's initialization has
finished. Each participant however has the possibility to call this
method directly, allowed for finer-grained notification of the
advancement of the initialization.
Parameters: participant - The participant that triggered the action. See Also: RepositoryListener since: 1.0 |
fireInitFinished | public void fireInitFinished()(Code) | | Notifies the registered listeners that the repository initialization
has finished.
See Also: RepositoryListener since: 1.0 |
getParticipant | public BlockingParticipant getParticipant(String name)(Code) | | Looks for the participant that corresponds to a given name and returns
it when found.
Parameters: name - The name of the participant instance that you wish toretrieve from the repository.If no name was provided during the XML specification, theparticipant will have been registered with its class name. If theparticipant's class is not part of thecom.uwyn.rife.rep.participants package, its full classname has to be provided, otherwise just the name of the class itself issufficient. Also, even though a participant has been registered with a name,it'll still be known under its class name. When a class name isprovided as the argument, the first known participant of that classwill be returned. This can be seen as the default participant for thespecified type. A BlockingParticipant instance if the providedname could be found amongst the registered participants in therepository; or null if the participant couldn't be found See Also: BlockingParticipant See Also: BlockingRepository.hasParticipant(String) since: 1.0
|
getParticipants | public Collection<BlockingParticipant> getParticipants(String className)(Code) | | Returns all the participants with a given class name
Parameters: className - The class name of the participants that you wish toretrieve from the repository.If the participant's class is not part of thecom.uwyn.rife.rep.participants package, its full classname has to be provided, otherwise just the name of the class itself issufficient. A Collection of BlockingParticipant instances of the provided class name; or null if no participants with the provided class namecould be found See Also: BlockingParticipant See Also: BlockingRepository.getParticipant(String) since: 1.0
|
initialize | public void initialize(String repXmlPath, ResourceFinder resourcefinder) throws RepException(Code) | | Parses the XML file to determine what the participants are. Then, one
by one, initializes each participant with the
BlockingRepository.runParticipants(ResourceFinder) runParticipants method, waiting for
it to finish if its blocking attribute was set to
true .
Parameters: repXmlPath - The path of the XML file.If this is null , rep/participants.xml willbe used. Parameters: resourcefinder - The resource finder that will be used to look upresources such as XML files and DTDs. It will also be used by otherclasses after initialization through thegetResourceFinder() method. If this is null , an instance of ResourceFinderClasspath will be used. exception: RepException - when an error occurs during the initialization. since: 1.0 |
isFinished | public boolean isFinished()(Code) | | Obtains the finished status of the initialization.
false if the initialization is still busy; ortrue if the initialization is finished since: 1.0
|
removeRepListener | public void removeRepListener(RepositoryListener repListener)(Code) | | Removes the repository listener so that it no longer receives
repository initialization events. This method performs no function, nor
does it throw an exception, if the listener specified by the argument
was not previously added to this component. If repListener
is null , no exception is thrown and no action is
performed.
Parameters: repListener - The repository listener that will be removed. See Also: RepositoryListener See Also: BlockingRepository.addRepListener(RepositoryListener) since: 1.0 |
runParticipants | public void runParticipants()(Code) | | Sequentially execute the participants according to their registration
order. If the participant has already been run or is still running, it
is not executed anymore. The repository waits for the participant's
execution to finish if this has been indicated by registering with the
blocking attribute.
The resource finder that will be used is an instance of
ResourceFinderClasspath .
See Also: ResourceFinderClasspath See Also: BlockingRepository.runParticipants(ResourceFinder) since: 1.5 |
runParticipants | public void runParticipants(ResourceFinder resourceFinder)(Code) | | Sequentially execute the participants according to their registration
order. If the participant has already been run or is still running, it
is not executed anymore. The repository waits for the participant's
execution to finish if this has been indicated by registering with the
blocking attribute.
Parameters: resourceFinder - The resource finder that is used during theinitialization. since: 1.0 |
uncaughtException | public void uncaughtException(Thread thread, Throwable e)(Code) | | If participants call an exception, clean up correctly and rethrow the
exception afterwards.
since: 1.0 |
|
|