Package org.w3c.tools.resources

Examples of org.w3c.tools.resources.ResourceReference


  throws ProtocolException, ResourceException
    {
  long lmbest = 0;
  String best = null;

  ResourceReference rr = getResource().getParent();
  if (rr != null) {
      try {
    FramedResource p = (FramedResource)rr.lock();
    // if the father is a container (it should always be)
    if (p instanceof ContainerResource) {
        ContainerResource cr = (ContainerResource) p;
        Enumeration res_enum;
        res_enum = cr.enumerateResourceIdentifiers(false);
        String childname;
        ResourceReference childrr;
        Class http_class = null;
        ResourceReference framrr;
        // get all the children, and find the container with
        // the most recent last-modified.
        while (res_enum.hasMoreElements()) {
      childname = (String) res_enum.nextElement();
      childrr = cr.lookup(childname);
View Full Code Here


     */
    protected static String getRealPath(String path,
          ResourceReference rr_root,
          ResourceReference rr)
    {
  ResourceReference local_root = getLocalRoot(rr_root, rr);
  try {
      FramedResource root = (FramedResource)local_root.lock();
      LookupState    ls   = new LookupState(path);
      LookupResult   lr   = new LookupResult(local_root);
      if (root.lookup(ls,lr)) {
    ResourceReference  target = lr.getTarget();
    if (target != null) {
        try {
      FramedResource res = (FramedResource)target.lock();
      if (res instanceof FileResource) {
          File file = ((FileResource)res).getFile();
          return file.getAbsolutePath();
      } else if (res instanceof DirectoryResource) {
          DirectoryResource dir = (DirectoryResource) res;
          return dir.getDirectory().getAbsolutePath();
          //return getFilePath(dir);
      }
        } finally {
      target.unlock();
        }
    }
      }
      return null;
  } catch (InvalidResourceException ex) {
View Full Code Here

     * ServletContext implementation - Translate a piece of path.
     * @param path the virtual path to translate
     * @return the real path
     */
    public String getRealPath(String path) {
  ResourceReference rr_root = ((httpd) getServer()).getRootReference();
  return getRealPath(path, rr_root, reference);
    }
View Full Code Here

  String indexes[] = frame.getIndexes();
  if (indexes != null) {
      for (int i = 0 ; i < indexes.length ; i++) {
    String index = indexes[i];
    if ( index != null && index.length() > 0) {
        ResourceReference rr = dir.lookup(index);
        if (rr != null) {
      try {
          FramedResource ri = (FramedResource) rr.lock();
          if (ri instanceof FileResource) {
        FileResource fr = (FileResource) ri;
        File file = fr.getFile();
        return file.getAbsolutePath();
          } else {
        // we don't know
        return null;
          }
      } catch (InvalidResourceException ex) {
      } finally {
          rr.unlock();
      }
        }
    }
      }
      return dir.getDirectory().getAbsolutePath();
View Full Code Here

    {
  try {
      FramedResource root = (FramedResource)rr_root.lock();
      if (root instanceof VirtualHostResource) {
    //backward to the virtual host resource
    ResourceReference rr  = null;
    ResourceReference rrp = null;
    FramedResource    res = null;
    try {
        res = (FramedResource)ref.lock();
        if (res instanceof ResourceFrame) {
      ResourceFrame fr = (ResourceFrame)res;
      rr = fr.getResource().getResourceReference();
        } else {
      rr = ref;
        }
    } catch (InvalidResourceException ex) {
        return rr_root;
    } finally {
        ref.unlock();
    }

    while (true) {
        try {
      res = (FramedResource)rr.lock();
      rrp = res.getParent();
      if ((rrp == rr_root) || (rrp == null)) {
          return getLocalRoot(rr, ref);
      }
        } catch (InvalidResourceException ex) {
      return rr_root;
        } finally {
      rr.unlock();
        }
        rr = rrp;
    }
      } else {
    try {
        FramedResource res = (FramedResource)rr_root.lock();
        ForwardFrame   ffr = (ForwardFrame)
      res.getFrame("org.w3c.jigsaw.proxy.ForwardFrame");
        if (ffr == null) {
      return rr_root;
        } else {
      ResourceReference rr = ffr.getLocalRootResource();
      return getLocalRoot(rr, ref);
        }
    } catch (InvalidResourceException ex) {
        return rr_root;
    }
View Full Code Here

    public ServletContext getContext(String uripath) {
  if (uripath == null)
      return null;
  //first, find the ServletDirectoryFrame.
  // Prepare for lookup:
  ResourceReference rr_root = null;
  rr_root = ((httpd) getServer()).getRootReference();

  FramedResource root = null;
  root = ((httpd) getServer()).getRoot();

  // Do the lookup:
  ResourceReference r_target = null;
  try {
      LookupState  ls = new LookupState(uripath);
      LookupResult lr = new LookupResult(rr_root);
      root.lookup(ls, lr);
      r_target = lr.getTarget();
  } catch (Exception ex) {
      r_target = null;
  }
  //then return its context
  if (r_target != null) {
      try {
    Resource target = r_target.lock();
    if (target instanceof FramedResource) {
        ServletDirectoryFrame frame = (ServletDirectoryFrame)
      ((FramedResource) target).
          getFrame("org.w3c.jigsaw.servlet.ServletDirectoryFrame");
        if (frame != null)
      return frame.getServletContext();
    }
      } catch (InvalidResourceException ex) {
    // continue
      } finally {
    r_target.unlock();
      }
  }
  return null;
    }
View Full Code Here

     * @deprecated since jsdk1.2
     */

    public String getRealPath(String name) {
  httpd             server  = getServer();
  ResourceReference rr_root = server.getRootReference();
  return JigsawServletContext.getRealPath(name,
            rr_root,
            request.getTargetResource());
    }
View Full Code Here

    public RequestDispatcher getRequestDispatcher(String path) {
  if (path == null) {
      throw new IllegalArgumentException("null");
  }
  String            urlpath = null;
  ResourceReference rr      = request.getTargetResource();
  if (! path.startsWith("/")) {
      String uri = null;
      try {
    ResourceReference rrp = rr.lock().getParent();
    try {
        Resource r = rrp.lock();
        uri = r.getURLPath();
    } catch (InvalidResourceException irex) {
        return null;
    } finally {
        rrp.unlock();
    }
      } catch (InvalidResourceException ex) {
    return null;
      } finally {
    rr.unlock();
View Full Code Here

    public String getServletPath() {
  if (request.hasState(JigsawRequestDispatcher.SERVLET_PATH_P)) {
      return (String)
    request.getState(JigsawRequestDispatcher.SERVLET_PATH_P);
  } else {
      ResourceReference rr = request.getTargetResource();
      try {
    return rr.lock().getURLPath();
      } catch (InvalidResourceException ex) {
    return null;
      } finally {
    rr.unlock();
      }
  }
    }
View Full Code Here

  Hashtable defs = new Hashtable(11) ;
  defs.put("url", "/"+name);
  defs.put("directory", space_dir) ;
  ResourceContext context = new ResourceContext(getDefaultContext());
  defs.put("context", context) ;
  ResourceReference rr = manager.loadRootResource(name, defs);
  if (rr != null)
      context.setResourceReference(rr);
  return rr;
    }
View Full Code Here

TOP

Related Classes of org.w3c.tools.resources.ResourceReference

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.