/*
* 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 context provides access to the app server naming service. This
* is the default Context for GlassFish. Lookups of unqualified names (i.e.
* names not starting with "java:", "corbaname:" etc) are serviced by
* SerialContext. The namespace is implemented in the
* SerialContextProviderImpl object, which is accessed directly in the
* case that the client is collocated with the naming service impl or
* remotely via RMI-IIOP if not collocated.
* <p/>
* <b>NOT THREAD SAFE: mutable instance variables</b>
*/
// Maximum number of recursive calls to lookup on comm error
// Maximum number of recursive calls to lookup on comm error
// Sets unmanaged SerialContext in test mode to prevent attempts to contact server.
new ThreadLocal<ThreadLocalIC>() {
protected ThreadLocalIC initialValue() {
return new ThreadLocalIC() ;
}
} ;
private boolean testMode = false;
// True if we're running in the server and no orb,host, or port
// properties have been explicitly set in the properties
// Allows special optimized intra-server naming service access
private boolean intraServerLookups;
// Common Class Loader. It is used as a fallback classloader to locate
// GlassFish object factories.
/** Methods for preserving stickiness. This is a
* solution to store the sticky IC as a thread local variable. This sticky
* IC will be used by all classes that require a context object to do lookup
* (if LB is enabled) SerialContext.lookup() sets a value for the thread
* local variable (stickyContext) before performing th lookup in case LB is
* enabled. If not, the thread local variable is null. At the end of the
* SerialContext.lookup() method, the thread local variable gets set to
* null. So actually speaking, more than being a global variable for the
* entire thread, its global only during the execution of the
* SerialContext.lookup() method. bug 5050591
*
*/
}
private void grabSticky() {
}
private void releaseSticky() {
}
static void clearSticky() {
}
/** Store the sticky context as a threadlocal variable (bug 5050591).
* Count is needed to know how many times the lookup method is being called
* from within the user code's ic.lookup().
* e.g. JMS resource lookups (via ConnectorObjectFactory)
*/
private static class ThreadLocalIC {
return ctx ;
}
}
count++ ;
}
void release() {
if (count > 0) {
count-- ;
if (count == 0) {
}
} else {
"SerialContext: attempt to release StickyContext "
+ " without grab") ;
}
}
}
void clear() {
count = 0 ;
}
}
/**
* Constructor for the context. Initializes the object reference to the
* remote provider object.
*/
throws NamingException {
habitat = h;
: null;
// TODO REMOVE when property stuff is figured out
"com.sun.enterprise.naming");
"com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl" );
+ this);
testMode = true;
}
synchronized(SerialContext.class) {
// Bootstrap a hk2 environment.
// TODO This will need to be moved somewhere else. Potentially any
// piece of glassfish code that can be an initial entry point from a
// Java SE client will need to make this happen.
} else {
}
}
}
if( testMode ) {
} else {
"Serial Context initializing with process environment {0}",
}
}
// using these two temp variables allows instance variables
// to be 'final'.
} else {
}
// Set target host / port from env. If only one of the two is set, fill in the
// other with the default.
if( targetHostFromEnv != null ) {
if( targetPortFromEnv == null ) {
}
}
if( targetPortFromEnv != null ) {
if( targetHostFromEnv == null ) {
}
}
orb = orbFromEnv;
}
}
}
/**
* This constructor takes the component id as an argument. All name
* arguments to operations are prepended by the component id.
*/
}
try {
if (intraServerLookups) {
} else {
}
} catch(Exception e) {
clearSticky() ;
e.printStackTrace();
"Unable to acquire SerialContextProvider for " + this);
throw ne;
}
}
return returnValue;
}
}
return orb ;
}
}
} else if (targetHost == null) {
} else {
}
return key ;
}
private void clearProvider() {
synchronized(SerialContext.class) {
}
}
synchronized(SerialContext.class) {
}
if (cachedProvider == null) {
// Don't hold lock during this call: remote invocation
synchronized(SerialContext.class) {
if (cachedProvider == null) {
} else {
}
}
} else {
}
}
return provider;
}
/**
* The getNameInNamespace API is not supported in this context.
*
* @throws NamingException if there is a naming exception.
*/
return myName;
}
/**
* method to check if the name to look up starts with "java:"
*/
}
/**
* Lookup the specified name in the context. Returns the resolved object.
*
* @return the resolved object.
* @throws NamingException if there is a naming exception.
*/
}
// Before any lookup bind any NamedNamingObjectProxy
// Skip if in plain Java SE client
// TODO this should really be moved somewhere else
}
/**
* In case a user is creating an IC with env passed in constructor; env
* specifies endpoints in some form in that case, the sticky IC should
* be stored as a thread local variable.
*
*/
if (useSticky) {
grabSticky() ;
}
try {
// Asking to look up this context itself. Create and return
// a new instance with its own independent environment.
}
"SerialContext ==> lookup relative name : {0}", name);
}
//it is possible that the object bound in a java url ("java:") is
//reference object.
if(o instanceof Reference){
o = getObjectInstance(name, o);
}
return o;
} else {
if (obj instanceof NamingObjectProxy) {
}
}
return retObj;
}
} catch (NamingException nnfe) {
throw ne;
// Issue 14732: make this FINE, as a cluster configuration change
// can send us here in a normal retry scenario.
"enterprise_naming.serialctx_communication_exception", name);
// temp fix for 6320008
// this should be removed once we change the transient NS
// implementation to persistent
"for provider since previous obj ref was stale...");
} else {
"Communication exception for " + this);
throw ce;
}
} finally {
if (useSticky) {
}
}
}
{
// NamingManager.getObjectInstance() returns the same object
// when it can't find the factory class. Since NamingManager
// uses Thread's context class loader to locate factory classes,
// it may not be able to locate the various GlassFish factories
// when lookup is performed outside of a Java EE context like
// inside an OSGi bundle's activator.
// So, let's see if using CommonClassLoader helps or not.
// We will only try with CommonClassLoader when the passed object
// reference has a factory class name set.
"getObjectInstance",
"Trying with CommonClassLoader for name {0} ",
}
"getObjectInstance",
"Found with CommonClassLoader");
}
}
}
}
return retObj;
}
/**
* This method tries to check if the passed object is a Reference or
* Refenciable. If it is a Reference, it just casts it to a Reference and
* returns, else if it is a Referenceable, it tries to get a Reference from
* the Referenceable and returns that, otherwise, it returns null.
*
* @param obj
* @return
* @throws NamingException
*/
{
} else if (obj instanceof Referenceable) {
}
return ref;
}
/**
* It tries to load the factory class for the given reference using the
* given class loader and return an instance of the same. Returns null
* if it can't load the class.
*
* @param ref
* @param cl
* @return
* @throws IllegalAccessException
* @throws InstantiationException
*/
{
if (factoryName != null) {
try
{
return (ObjectFactory)c.newInstance();
}
catch (ClassNotFoundException e)
{
// ignore only CNFE, all other exceptions are considered errors
}
}
return null;
}
/**
* Lookup the specifed name in the context. Returns the resolved object.
*
* @return the resolved object.
* @throws NamingException if there is a naming exception.
*/
// Flat namespace; no federation; just call string version
}
/**
* Bind the object to the specified name.
*
* @param name name that the object is being bound to.
* @param obj object that is being bound.
* @throws NamingException if there is a naming exception.
*/
} else {
try {
} catch (RemoteException ex) {
}
}
}
/**
* Bind the object to the specified name.
*
* @param name name that the object is being bound to.
* @param obj object that is being bound.
* @throws NamingException if there is a naming exception.
*/
// Flat namespace; no federation; just call string version
}
/**
* Rebind the object to the specified name.
*
* @param name name that the object is being bound to.
* @param obj object that is being bound.
* @throws NamingException if there is a naming exception.
*/
} else {
try {
} catch (RemoteException ex) {
}
}
}
/**
* Rebind the object to the specified name.
*
* @param name name that the object is being bound to.
* @param obj object that is being bound.
* @throws NamingException if there is a naming exception.
*/
// Flat namespace; no federation; just call string version
}
/**
* Unbind the object with the specified name.
*
* @param name that is being unbound.
* @throws NamingException if there is a naming exception.
*/
} else {
try {
} catch (RemoteException ex) {
}
}
}
/**
* Unbind the object with the specified name.
*
* @param name name that is being unbound.
* @throws NamingException if there is a naming exception.
*/
// Flat namespace; no federation; just call string version
}
/**
* Rename the bound object.
*
* @param oldname old name that the object is bound as.
* @param newname new name that the object will be bound as.
* @throws NamingException if there is a naming exception.
*/
} else {
try {
} catch (RemoteException ex) {
}
}
}
/**
* Rename the bound object.
*
* @param oldname old name that the object is bound as.
* @param newname new name that the object will be bound as.
* @throws NamingException if there is a naming exception.
*/
// Flat namespace; no federation; just call string version
}
/**
* List the contents of the specified context.
*
* @param name context name.
* @return an enumeration of the contents.
* @throws NamingException if there is a naming exception.
*/
// listing this context
try {
} catch (RemoteException ex) {
}
}
} else {
// Perhaps 'name' names a context
}
}
}
/**
* List the contents of the specified context.
*
* @param name context name.
* @return an enumeration of the contents.
* @throws NamingException if there is a naming exception.
*/
// Flat namespace; no federation; just call string version
}
/**
* List the bindings in the specified context.
*
* @param name context name.
* @return an enumeration of the bindings.
* @throws NamingException if there is a naming exception.
*/
// listing this context
try {
} catch (RemoteException ex) {
.toString());
throw ce;
}
}
} else {
// Perhaps 'name' names a context
}
}
}
/**
* List the bindings in the specified context.
*
* @param name context name.
* @return an enumeration of the bindings.
* @throws NamingException if there is a naming exception.
*/
// Flat namespace; no federation; just call string version
}
/**
* Destroy the specified subcontext.
*
* @param name name of the subcontext.
* @throws NamingException if there is a naming exception.
*/
} else {
try {
} catch (RemoteException e) {
.toString());
throw ce;
}
}
}
/**
* Destroy the specified subcontext.
*
* @param name name of the subcontext.
* @throws NamingException if there is a naming exception.
*/
// Flat namespace; no federation; just call string version
}
/**
* Create the specified subcontext.
*
* @param name name of the subcontext.
* @return the created subcontext.
* @throws NamingException if there is a naming exception.
*/
} else {
try {
/*
* this simulates the transient context structure on the client
* side. Have to do this - as reference to Transient Context is
* not resolved properly due to rmi
*/
if (c instanceof Context) {
}
} catch (RemoteException e) {
.toString());
throw ce;
}
return c;
}
}
/**
* Create the specified subcontext.
*
* @param name name of the subcontext.
* @return the created subcontext.
* @throws NamingException if there is a naming exception.
*/
// Flat namespace; no federation; just call string version
}
/**
* Links are not treated specially.
*
* @param name name of the link.
* @return the resolved object.
* @throws NamingException if there is a naming exception.
*/
} else {
// This flat context does not treat links specially
}
}
/**
* Links are not treated specially.
*
* @param name name of the link.
* @return the resolved object.
* @throws NamingException if there is a naming exception.
*/
// Flat namespace; no federation; just call string version
}
/**
* Allow access to the name parser object.
*
* @param name JNDI name, is ignored since there is only one Name Parser
* object.
* @return NameParser object
* @throws NamingException
*/
return myParser;
}
/**
* Allow access to the name parser object.
*
* @param name JNDI name, is ignored since there is only one Name Parser
* object.
* @return NameParser object
* @throws NamingException
*/
// Flat namespace; no federation; just call string version
}
throws NamingException {
prefix));
}
return result;
}
/**
* Add to the environment for the current context.
*
* @throws NamingException if there is a naming exception.
*/
throws NamingException {
}
}
/**
* Remove from the environment for the current context.
*
* @throws NamingException if there is a naming exception.
*/
return null;
}
}
/**
* Return the environment for the current context.
*
* @throws NamingException if there is a naming exception.
*/
// Must return non-null
}
return myEnv;
}
/**
* Set the environment for the current context to null when close is called.
*
* @throws NamingException if there is a naming exception.
*/
}
}
return name;
}
}
public boolean hasMoreElements() {
return names.hasMoreElements();
}
return hasMoreElements();
}
public T nextElement() {
if (names.hasMoreElements()) {
} else {
return null;
}
}
return nextElement();
}
public void close() {
//no-op since no steps needed to free up resources
}
}
// Class for enumerating bindings
}
public boolean hasMoreElements() {
return names.hasMoreElements();
}
return hasMoreElements();
}
public T nextElement() {
if (hasMoreElements()) {
} else {
return null;
}
}
return nextElement();
}
public void close() {
//no-op since no steps needed to free up resources
}
}
if(testMode) {
}
}
private class ProviderCacheKey {
}
// Host and Port must both be non-null
+ "/NameService" ;
}
}
} else {
}
}
} else {
}
final NameComponent[] path =
SerialContextProvider.class );
return result ;
}
public int hashCode() {
}
return false ;
}
if (!(other instanceof ProviderCacheKey)) {
return false ;
}
} else {
}
}
}
}
}