001: /*
002: * Enhydra Java Application Server Project
003: *
004: * The contents of this file are subject to the Enhydra Public License
005: * Version 1.1 (the "License"); you may not use this file except in
006: * compliance with the License. You may obtain a copy of the License on
007: * the Enhydra web site ( http://www.enhydra.org/ ).
008: *
009: * Software distributed under the License is distributed on an "AS IS"
010: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
011: * the License for the specific terms governing rights and limitations
012: * under the License.
013: *
014: * The Initial Developer of the Enhydra Application Server is Lutris
015: * Technologies, Inc. The Enhydra Application Server and portions created
016: * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
017: * All Rights Reserved.
018: *
019: * Contributor(s):
020: *
021: * $Id: ContainerNaming.java 6893 2005-06-06 11:20:35Z benoitf $
022: */
023: package org.objectweb.jonas_lib.naming;
024:
025: import javax.naming.Context;
026: import javax.naming.NamingException;
027: import java.util.Hashtable;
028: import javax.naming.InitialContext;
029:
030: /**
031: * Provide naming services for Web and EJB containers. Containers use this
032: * interface for binding the environment entries, remote object references,
033: * resource factories and for managing the naming context of the current
034: * thread.
035: *
036: * @author Lutris
037: */
038: public interface ContainerNaming {
039:
040: /**
041: * Create context for application and component environments.
042: * Called by Web Container for each Web Application (as defined in
043: * web.xml). Called by EJB Container for each ejb component (as defined
044: * in ejb-jar.xml). The returned context provides an independent
045: * namespace for each components environment values, and resources.
046: *
047: * @param namespace Subcontext name(s) to create under Server Root.
048: * Usually consists of application name + component name.
049: * <pre>
050: * Examples:
051: * "App1/WebWar1" for Web Application
052: * "App1/EJBJar1/EJBName" for ejb in Enterprise Application.
053: * </pre>
054: * @return Naming context for component environment
055: * @throws NamingException If exception encountered creating namespace.
056: *
057: */
058: Context createEnvironmentContext(String namespace)
059: throws NamingException;
060:
061: /**
062: * Create immutable context for application and component environments.
063: * Called by Web Container for each Web Application (as defined in
064: * web.xml). Called by EJB Container for each ejb component (as defined
065: * in ejb-jar.xml). The returned context provides an independent
066: * namespace for each components environment values, and resources. This
067: * context must exist in the underlying name service. It must be
068: * previously created by an earlier deployment.
069: *
070: * @param namespace Subcontext name(s) to create under Server Root.
071: * Usually consists of application name + component name.
072: * <pre>
073: * Examples:
074: * "App1/WebWar1" for Web Application
075: * "App1/EJBJar1/EJBName" for ejb in Enterprise Application.
076: * </pre>
077: * @return Naming context for component environment
078: * @throws NamingException If context namespace does not exist.
079: *
080: */
081: Context createImmutableEnvironmentContext(String namespace)
082: throws NamingException;
083:
084: /**
085: * Return the Context associated with the current thread.
086: *
087: * @return Context for current thread.
088: * @throws NamingException If context namespace does not exist.
089: */
090: Context getComponentContext() throws NamingException;
091:
092: /**
093: * Aassociate this Context with the current thread.
094: * This method should be called in preinvoke/postinvoke
095: * and when we build the bean environment.
096: *
097: * @param ctx Context to associate with the current thread.
098: * @return Previous context setting for current thread.
099: */
100: Context setComponentContext(Context ctx);
101:
102: /**
103: * Set back the context with the given value.
104: * Don't return the previous context, use setComponentContext() method for this.
105: * @param ctx the context to associate to the current thread.
106: */
107: void resetComponentContext(Context ctx);
108:
109: /**
110: * Associate the specified CompNamingContext with the given classloader.
111: * @param ctx the context to associate to the classloader.
112: * @param cl the classloader which is bind to the context.
113: */
114: void setComponentContext(Context ctx, ClassLoader cl);
115:
116: /**
117: * Set the context used by client container (per JVM instead of per thread)
118: * @param ctx the context to set
119: */
120: void setClientContainerComponentContext(Context ctx);
121:
122: /**
123: * Return the CompNamingContext associated with the given classloader.
124: * @param cl the classloader which is bind to the context.
125: * @return the CompNamingContext associated with the given classloader.
126: */
127: Context getComponentContext(ClassLoader cl);
128:
129: /**
130: * Remove the CompNamingContext associated with the given classloader.
131: * @param cl the classloader which is bind to the context.
132: */
133: void unSetComponentContext(ClassLoader cl);
134:
135: /**
136: * Gets the initial context
137: * @return the initial context
138: */
139: InitialContext getInitialContext();
140:
141: /**
142: * @return the environment associated to this initial context
143: */
144: Hashtable getEnv();
145: }
|