001: // ***************************************************************
002: // * *
003: // * File:ServiceContext.java *
004: // * *
005: // * Copyright (c) 2002 Sun Microsystems, Inc. *
006: // * All rights reserved. *
007: // * *
008: // * *
009: // * Date - Jul/16/2002 *
010: // * Author - alejandro.abdelnur@sun.com *
011: // * *
012: // ***************************************************************
013:
014: package com.sun.portal.common.service;
015:
016: import java.io.InputStream;
017: import java.io.IOException;
018:
019: import java.util.Iterator;
020:
021: /**
022: * Defines a set of methods that a services uses to communicate with
023: * its service container.
024: * <P>
025: * A ServiceContext groups a set of services.
026: * <P>
027: * The ServiceContext object is contained within the ServiceConfig
028: * object, which the service container provides the service when the
029: * service is initialized.
030: *
031: * @author <A HREF="mailto:tucu@sun.com">Alejandro Abdelnur</A>
032: *
033: */
034: public interface ServiceContext {
035:
036: /**
037: * Returns a service from a ServiceContext.
038: * <P>
039: *
040: * @param name a String with the name ofthe service to retrieve
041: *
042: * @return the service with the specified name or null if the
043: * service does not exist
044: *
045: */
046: public Service getService(String name);
047:
048: /**
049: * Returns a String containing the value of the named context-wide
050: * initialization parameter, or null if the parameter does not exist.
051: * <P>
052: *
053: * @param name a String containing the name of the parameter whose
054: * value is requested
055: *
056: * @return a String containing at value of the specified parameter
057: *
058: */
059: public String getInitParameter(String name);
060:
061: /**
062: * Returns the names of the context's initialization parameters as
063: * an Iterator of String objects, or an empty Iterator if the context
064: * has no initialization parameters.
065: * <P>
066: *
067: * @return an Iterator of String objects containing the names of the
068: * context's initialization parameters
069: *
070: */
071: public Iterator getInitParameterNames();
072:
073: /**
074: * Returns an Iterator containing the attribute names available within
075: * this service context. Use the getAttribute(java.lang.String) method
076: * with an attribute name to get the value of an attribute.
077: * <P>
078: *
079: * @return an Iterator of attribute names
080: *
081: */
082: public Iterator getAttributeNames();
083:
084: /**
085: * Returns the service container attribute with the given name, or null
086: * if there is no attribute by that name.
087: * <P>
088: *
089: * @param name a String specifying the name of the attribute
090: *
091: * @return an Object containing the value of the attribute, or null
092: * if no attribute exists matching the given name
093: *
094: */
095: public Object getAttribute(String name);
096:
097: /**
098: * Removes the attribute with the given name from the service context.
099: * After removal, subsequent calls to getAttribute(java.lang.String)
100: * to retrieve the attribute's value will return null.
101: * <P>
102: *
103: * @param name a String specifying the name of the attribute
104: *
105: */
106: public void removeAttribute(String name);
107:
108: /**
109: * Binds an object to a given attribute name in this service context.
110: * If the name specified is already used for an attribute, this method
111: * will replace the attribute with the new to the new attribute.
112: * <P>
113: *
114: * @param name a String specifying the name of the attribute
115: *
116: * @return value an Object representing the attribute to be bound
117: *
118: */
119: public void setAttribute(String name, Object value);
120:
121: }
|