/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* or packager/legal/LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at packager/legal/LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
* exception as provided by Oracle in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
/**
* This is the manager that handles all naming operations including
* publishObject as well as binding environment props, resource and ejb
* references in the namespace.
*/
public final class GlassfishNamingManagerImpl
implements GlassfishNamingManager {
"com.sun.enterprise.naming.util.IIOPObjectFactory";
//@Inject
this(new InitialContext());
}
//Used only for Junit Testing
}
/**
* Create the naming manager. Creates a new initial context.
*/
throws NamingException {
initialContext = ic;
componentNamespaces = new Hashtable();
JavaURLContext.setNamingManager(this);
}
/**
* Get the initial naming context.
*/
return initialContext;
}
return nameParser;
}
try {
// Now that we have an ORB, initialize the CosNaming service
// and set it on the server's naming service.
"com.sun.jndi.cosnaming.CNCtxFactory");
// Initialize RemoteSerialProvider. This allows access to the naming
// service from clients.
} catch(RemoteException re) {
throw ne;
}
return remoteProvider;
}
return cosContext;
}
/**
* Publish a name in the naming service.
*
* @param name Name that the object is bound as.
* @param obj Object that needs to be bound.
* @param rebind flag
* @throws javax.naming.NamingException if there is a naming exception.
*/
throws NamingException {
}
/**
* Publish a name in the naming service.
*
* @param name Name that the object is bound as.
* @param obj Object that needs to be bound.
* @param rebind flag
* @throws javax.naming.NamingException if there is a naming exception.
*/
throws NamingException {
if (rebind) {
} else {
}
}
throws NamingException {
// Create any COS naming sub-contexts in name
// that don't already exist.
if (rebind) {
} else {
}
// Bind a reference to it in the SerialContext using
// the same name. This is needed to allow standalone clients
// to lookup the object using the same JNDI name.
// It is also used from bindObjects while populating ejb-refs in
// the java:comp namespace.
}
throws NamingException {
}
/**
* Remove an object from the naming service.
*
* @param name Name that the object is bound as.
* @throws Exception
*/
throws NamingException {
try {
} catch(NamingException cne) {
}
}
/**
* Remove an object from the naming service.
*
* @param name Name that the object is bound as.
* @throws Exception
*/
}
/**
* Create any sub-contexts in name that don't already exist.
*
* @param name Name containing sub-contexts to create
* @param rootCtx in which sub-contexts should be created
* @throws Exception
*/
}
try {
// @@@ thought it should throw NameNotFound when
// context doesn't exist...
}
// Doesn't exist so create it.
currentCtx = newCtx;
// OK -- no need to create it.
} else {
// Context name clashes with existing object.
throw new NameAlreadyBoundException(subCtxName);
}
}
catch (NameNotFoundException e) {
// Doesn't exist so create it.
currentCtx = newCtx;
}
} // End for -- each sub-context
return;
}
throws NamingException {
// Note: HashMap is not synchronized. The namespace is populated
// at deployment time by a single thread, and then on there are
// So the namespace doesnt need to be synchronized.
}
return namespace;
}
throws NamingException {
}
// Note: HashMap is not synchronized. The namespace is populated
// at deployment time by a single thread, and then on there are
// So the namespace doesnt need to be synchronized.
}
return namespace;
}
private Object lookupFromNamespace(String name, Map namespace, Hashtable env) throws NamingException {
if (o == null) {
} else {
if (o instanceof NamingObjectProxy) {
}
} else if (o instanceof Reference) {
try {
} catch (Exception e) {
"Hence returning the Reference object ", e);
}
}
return o;
}
}
/**
* @inheritDoc
*/
public Object lookupFromAppNamespace(String appName, String name, Hashtable env) throws NamingException {
}
/**
* @inheritDoc
*/
public Object lookupFromModuleNamespace(String appName, String moduleName, String name, Hashtable env)
throws NamingException {
}
}
}
throws NamingException {
throw new NamingException("Null appName");
}
// Note: HashMap is not synchronized. The namespace is populated
// at deployment time by a single thread, and then on there are
// So the namespace doesnt need to be synchronized.
}
return namespace;
}
}
} else {
// return component namespace
}
return namespace;
}
/**
* This method binds them in a java:namespace.
*/
throws NamingException {
"naming.bind Binding name:{0}",
new Object[]{logicalJndiName});
}
"naming.alreadyexists" +
"Reference name [{0}] already exists for {1}",
}
}
}
/**
* This method enumerates the env properties, ejb and resource references
* etc for a J2EE component and binds them in the component's java:comp
* namespace.
*/
throws NamingException {
// These are null in rare cases, e.g. default web app.
}
}
}
}
}
}
}
return logicalModuleJndiName;
}
return logicalCompJndiName;
}
/**
* @inheritDoc
*/
public void bindToModuleNamespace(String appName, String moduleName, Collection<? extends JNDIBinding> bindings)
throws NamingException {
}
}
}
/**
* @inheritDoc
*/
throws NamingException {
}
}
}
throws NamingException {
// for each component of name, put an entry into namespace
partialName = "java:comp";
partialName = "java:module";
partialName = "java:app";
} else {
}
while (toks.hasMoreTokens()) {
}
}
}
/**
* This method enumerates the env properties, ejb and resource references
* and unbinds them from the java:comp namespace.
*/
}
while( moduleEntries.hasNext() ) {
}
}
}
/**
* @inheritDoc
*/
if(namespaces != null){
}
}
/**
* @inheritDoc
*/
public void unbindModuleObject(String appName, String moduleName, String name) throws NamingException {
if(namespaces != null){
}
}
/**
* context name.
*/
throws NamingException {
+ "]. Name must start with java:");
}
}
}
/**
* This method is called from SerialContext class. The serialContext
* instance that was created by the appclient's Main class is passed so that
* stickiness is preserved. Called from javaURLContext.lookup, for java:comp
* names.
*/
throws NamingException {
if (serialContext != null) {
ic = serialContext;
} else {
ic = initialContext;
}
// initialContext is used as ic in case of PE while
+ name);
// Get the component id and namespace to lookup
}
/**
* Lookup object for a particular componentId and name.
*/
}
if( replaceName ) {
}
if (obj instanceof NamingObjectProxy) {
// Need to preserve the original prefix so that further operations
// on the context maintain the correct external view. In the case
// of a replaced java:comp, create a new equivalent javaURLContext
// and return that.
if( replaceName ) {
}
if (obj instanceof JavaURLContext) {
if (ctx instanceof SerialContext) {
(SerialContext)ctx ) ;
} else {
}
}
}
return obj;
}
}
}
// Get the component id and namespace to lookup
if( replaceName ) {
}
if (!(obj instanceof JavaURLContext))
// This iterates over all names in entire component namespace,
// so its a little inefficient. The alternative is to store
// a list of bindings in each javaURLContext instance.
// Check if key begins with name and has only 1 component extra
// (i.e. no more slashes)
// Make sure keys reflect the original prefix in the case of comp->module
// replacement
// The search string itself is excluded from the returned list
}
}
return list;
}
/**
* Get the component id from the Invocation Manager.
*
* @return the component id as a string.
*/
} else {
}
throw new NamingException("Invocation exception: Got null ComponentInvocation ");
}
try {
"Invocation exception: ComponentId is null");
throw nameEx;
}
throw ine;
}
return id;
}
}
private static class AppModuleKey {
module = moduleName;
}
boolean equal = false;
if( (o != null) && (o instanceof AppModuleKey) ) {
equal = true;
}
}
return equal;
}
public int hashCode() {
}
}
private static class ComponentIdInfo {
boolean treatComponentAsModule;
" , componentId = " + componentId
+ ", treatComponentAsModule = " + treatComponentAsModule; }
}
private boolean producesNamesOnly;
this.producesNamesOnly = producesNamesOnly;
}
public boolean hasMoreElements() {
}
return hasMoreElements();
}
public T nextElement() {
try {
return producesNamesOnly ?
} catch (RuntimeException ex) {
throw ex;
throw new RuntimeException(ex);
}
} else {
return null;
}
}
return nextElement();
}
public void close() {
//no-op since no steps needed to free up resources
}
}
}