FileDocCategorySizeDatePackage
ResourceResolver.javaAPI DocJava SE 6 API9202Tue Jun 10 00:23:04 BST 2008com.sun.org.apache.xml.internal.security.utils.resolver

ResourceResolver

public class ResourceResolver extends Object
During reference validation, we have to retrieve resources from somewhere. This is done by retrieving a Resolver. The resolver needs two arguments: The URI in which the link to the new resource is defined and the BaseURI of the file/entity in which the URI occurs (the BaseURI is the same as the SystemId.
  • Verschiedene Implementierungen k??nnen sich als Resolver registrieren.
  • Standardm????ig werden erste Implementierungen auf dem XML config file registrirt.
  • Der Benutzer kann bei Bedarf Implementierungen voranstellen oder anf??gen.
  • Implementierungen k??nnen mittels Features customized werden ?? (z.B. um Proxy-Passworter ??bergeben zu k??nnen).
  • Jede Implementierung bekommt das URI Attribut und den Base URI ??bergeben und muss antworten, ob sie aufl??sen kann.
  • Die erste Implementierung, die die Aufgabe erf??llt, f??hrt die Aufl??sung durch.
author
$Author: raul $

Fields Summary
static Logger
log
{@link java.util.logging} logging facility
static boolean
_alreadyInitialized
Field _alreadyInitialized
static List
_resolverVector
these are the system-wide resolvers
List
_individualResolverVector
Field _individualResolverVector
protected ResourceResolverSpi
_resolverSpi
Field transformSpi
Constructors Summary
private ResourceResolver(String className)
Constructor ResourceResolver

param
className
throws
ClassNotFoundException
throws
IllegalAccessException
throws
InstantiationException


                 
     
             
                   
      this._resolverSpi =
         (ResourceResolverSpi) Class.forName(className).newInstance();
   
public ResourceResolver(ResourceResolverSpi resourceResolver)
Constructor ResourceResolver

param
resourceResolver

      this._resolverSpi = resourceResolver;
   
Methods Summary
public voidaddProperties(java.util.Map properties)
Method addProperties

param
properties

      this._resolverSpi.engineAddProperies(properties);
   
private booleancanResolve(org.w3c.dom.Attr uri, java.lang.String BaseURI)
Method canResolve

param
uri
param
BaseURI
return
true if it can resolve the uri

      return this._resolverSpi.engineCanResolve(uri, BaseURI);
   
public static final com.sun.org.apache.xml.internal.security.utils.resolver.ResourceResolvergetInstance(org.w3c.dom.Attr uri, java.lang.String BaseURI)
Method getInstance

param
uri
param
BaseURI
return
the instnace
throws
ResourceResolverException

      int length=ResourceResolver._resolverVector.size();
      for (int i = 0; i < length; i++) {
		  ResourceResolver resolver =
            (ResourceResolver) ResourceResolver._resolverVector.get(i);
         

         if (true)
         	if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "check resolvability by class " + resolver.getClass().getName());

         if ((resolver != null) && resolver.canResolve(uri, BaseURI)) {
            return resolver;
         }
      }

      Object exArgs[] = { ((uri != null)
                           ? uri.getNodeValue()
                           : "null"), BaseURI };

      throw new ResourceResolverException("utils.resolver.noClass", exArgs,
                                          uri, BaseURI);
   
public static final com.sun.org.apache.xml.internal.security.utils.resolver.ResourceResolvergetInstance(org.w3c.dom.Attr uri, java.lang.String BaseURI, java.util.List individualResolvers)
Method getInstance

param
uri
param
BaseURI
param
individualResolvers
return
the instance
throws
ResourceResolverException

      if (true) {
      	if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "I was asked to create a ResourceResolver and got " + individualResolvers.size());
      	if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, " extra resolvers to my existing " + ResourceResolver._resolverVector.size() + " system-wide resolvers");
      }

      // first check the individual Resolvers
	  int size=0;
      if ((individualResolvers != null) && ((size=individualResolvers.size()) > 0)) {
         for (int i = 0; i < size; i++) {
            ResourceResolver resolver =
               (ResourceResolver) individualResolvers.get(i);

            if (resolver != null) {
               String currentClass = resolver._resolverSpi.getClass().getName();
               if (true)
               	if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "check resolvability by class " + currentClass);

               if (resolver.canResolve(uri, BaseURI)) {
                  return resolver;
               }
            }
         }
      }

	  return getInstance(uri,BaseURI);
   
public java.lang.StringgetProperty(java.lang.String key)
Method getProperty

param
key
return
the value of the property

      return this._resolverSpi.engineGetProperty(key);
   
public java.lang.String[]getPropertyKeys()
Method getPropertyKeys

return
all property keys.

      return this._resolverSpi.engineGetPropertyKeys();
   
public static voidinit()
The init() function is called by com.sun.org.apache.xml.internal.security.Init.init()


      if (!ResourceResolver._alreadyInitialized) {
         ResourceResolver._resolverVector = new ArrayList(10);
         _alreadyInitialized = true;
      }
   
public static voidregister(java.lang.String className)
Method register

param
className

	    ResourceResolver resolver = null;

        try {
           resolver = new ResourceResolver(className);
		   ResourceResolver._resolverVector.add(resolver);
        } catch (Exception e) {
//			Object exArgs[] = { ((uri != null)
//                    ? uri.getNodeValue()
//                    : "null"), BaseURI };
//
//			throw new ResourceResolverException("utils.resolver.noClass",
//                                   exArgs, e, uri, BaseURI);
			log.log(java.util.logging.Level.WARNING, "Error loading resolver " + className +" disabling it");
        } catch (NoClassDefFoundError e) {
			log.log(java.util.logging.Level.WARNING, "Error loading resolver " + className +" disabling it");
        }
      
   
public static voidregisterAtStart(java.lang.String className)
Method registerAtStart

param
className

      ResourceResolver._resolverVector.add(0, className);
   
public com.sun.org.apache.xml.internal.security.signature.XMLSignatureInputresolve(org.w3c.dom.Attr uri, java.lang.String BaseURI)
Method resolve

param
uri
param
BaseURI
return
the resource
throws
ResourceResolverException

      return this._resolverSpi.engineResolve(uri, BaseURI);
   
public static com.sun.org.apache.xml.internal.security.signature.XMLSignatureInputresolveStatic(org.w3c.dom.Attr uri, java.lang.String BaseURI)
Method resolve

param
uri
param
BaseURI
return
the resource
throws
ResourceResolverException


      ResourceResolver myResolver = ResourceResolver.getInstance(uri, BaseURI);

      return myResolver.resolve(uri, BaseURI);
   
public voidsetProperty(java.lang.String key, java.lang.String value)
Method setProperty

param
key
param
value

      this._resolverSpi.engineSetProperty(key, value);
   
public booleanunderstandsProperty(java.lang.String propertyToTest)
Method understandsProperty

param
propertyToTest
return
true if the resolver understands the property

      return this._resolverSpi.understandsProperty(propertyToTest);