FileDocCategorySizeDatePackage
ResourceLinkFactory.javaAPI DocApache Tomcat 6.0.143124Fri Jul 20 04:20:36 BST 2007org.apache.naming.factory

ResourceLinkFactory

public class ResourceLinkFactory extends Object implements ObjectFactory

Object factory for resource links.

author
Remy Maucherat
version
$Revision: 467222 $ $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $

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;