001: /*
002: * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
003: * Distributed under the terms of either:
004: * - the common development and distribution license (CDDL), v1.0; or
005: * - the GNU Lesser General Public License, v2.1 or later
006: * $Id: Repository.java 3634 2007-01-08 21:42:24Z gbevin $
007: */
008: package com.uwyn.rife.rep;
009:
010: import com.uwyn.rife.ioc.HierarchicalProperties;
011: import java.util.Collection;
012:
013: /**
014: * The <code>Repository</code> provides a collection of application-wide data
015: * structures and services that typically setup the whole application
016: * structure in a modular fashion.
017: * <p>These modules are called <code>Participant</code>s and they are
018: * registered through a name so make it possible to retrieve them. The name is
019: * not necessarily a unique identifier, but can also identify a specific
020: * <code>Participant</code> type.
021: *
022: * @author Geert Bevin (gbevin[remove] at uwyn dot com)
023: * @version $Revision: 3634 $
024: * @see Participant
025: * @since 1.0
026: */
027: public interface Repository {
028: /**
029: * Verifies if a participant with a certain name is present in the
030: * repository.
031: *
032: * @param name The name of the participant that you wish to look up in the
033: * repository.
034: * @return <code>true</code> if the participant could be found, or
035: * <p><code>false</code> otherwise
036: * @since 1.0
037: */
038: public boolean hasParticipant(String name);
039:
040: /**
041: * Looks for the participant that corresponds to a given name and returns
042: * it when found.
043: *
044: * @return A <code>Participant</code> instance if the provided name could
045: * be found; or
046: * <p><code>null</code> if the participant couldn't be found
047: * @see Participant
048: * @since 1.0
049: */
050: public Participant getParticipant(String name);
051:
052: /**
053: * Returns all the participants that correspond to a given name.
054: *
055: * @param name The name of the participants that you wish to retrieve from
056: * the repository.
057: * @return A <code>Collection</code> of <code>Participant</code>s that
058: * correspond to the name; or
059: * <p><code>null</code> if no participants with the provided name could be
060: * found
061: * @see Participant
062: * @since 1.0
063: */
064: public Collection<? extends Participant> getParticipants(String name);
065:
066: /**
067: * Retrieves the repository's properties. This is meant to be similar
068: * <code>System.getProperties</code>, but then not for the whole
069: * system, but just for this application.
070: * <p>
071: * Also, instead of just have a map of <code>String</code> keys and values,
072: * the property values are of the {@link com.uwyn.rife.ioc.PropertyValue} type and are looked
073: * up at run-time in a hierachical manner. This provides them with IoC
074: * capabilities.
075: * <p>
076: * Since Java allows the configuration of an application through the use of
077: * properties, many other sub-system have adopted a similar approach (for
078: * example servlet init parameters). Most of the time an application runs
079: * through several barriers of configuration that often function
080: * independently. These properties make it possible for each sub-system to
081: * add their properties to the same pool. This makes it much more convenient
082: * to retrieve a property value.
083: *
084: * @return the repository's properties
085: * @since 1.0
086: */
087: public HierarchicalProperties getProperties();
088:
089: /**
090: * Retrieves the context in which the repository was initialized.
091: *
092: * @return a reference to the context in which the repository was
093: * initialized; or
094: * <p><code>null</code> if the context isn't accessible
095: *
096: * @since 1.0
097: */
098: public Object getContext();
099:
100: /**
101: * Obtains the finished status of the initialization.
102: *
103: * @return <code>false</code> if the initialization is still busy; or
104: * <p><code>true</code> if the initialization is finished
105: * @since 1.0
106: */
107: public boolean isFinished();
108:
109: /**
110: * Cleans up the repository, typically done at application shutdown.
111: *
112: * @since 1.0
113: */
114: public void cleanup();
115: }
|