FileDocCategorySizeDatePackage
ResourceLinkFactory.javaAPI DocGlassfish v2 API4230Fri May 04 22:33:00 BST 2007org.apache.naming.factory

ResourceLinkFactory

public class ResourceLinkFactory extends Object implements ObjectFactory

Object factory for resource links.

author
Remy Maucherat
version
$Revision: 1.3 $ $Date: 2007/05/05 05:33:00 $

Fields Summary
private static Context
globalContext
Global naming context.
Constructors Summary
Methods Summary
public java.lang.ObjectgetObjectInstance(java.lang.Object obj, javax.naming.Name name, javax.naming.Context nameCtx, java.util.Hashtable environment)
Create a new DataSource instance.

param
obj The reference object describing the DataSource

        
        if (!(obj instanceof ResourceLinkRef))
            return null;

        // Can we process this request?
        Reference ref = (Reference) obj;

        String type = ref.getClassName();

        // Read the global ref addr
        String globalName = null;
        RefAddr refAddr = ref.get(ResourceLinkRef.GLOBALNAME);
        if (refAddr != null) {
            globalName = refAddr.getContent().toString();
            Object result = null;
            result = globalContext.lookup(globalName);
            // FIXME: Check type
            return result;
        }

        return (null);

        
    
public static voidsetGlobalContext(javax.naming.Context newGlobalContext)
Set the global context (note: can only be used once).

param
newGlobalContext new global context value



    // --------------------------------------------------------- Public Methods


                          
         
        if (globalContext != null)
            return;
        globalContext = newGlobalContext;