Package org.w3c.tools.resources

Examples of org.w3c.tools.resources.FramedResource


      // startup servlets...
      String startups = (String) general.get(STARTUP_P);
      if (startups != null) {
    StringTokenizer st =
        new StringTokenizer(startups, ARGS_SEPARATOR);
    FramedResource root = server.getRoot();
    LookupState    ls   = null;
    LookupResult   lr   = null;
    String         name = null;
    String         uri  = null;
    while (st.hasMoreTokens()) {
        name = st.nextToken();
        uri  = SERVLET_BASE_P+"/"+name;
        try {
      ls   = new LookupState(uri);
      lr   = new LookupResult(root.getResourceReference());
      root.lookup(ls, lr);
      ResourceReference rr = lr.getTarget();
      if (rr != null) {
          try {
        ServletWrapper wrapper =
            (ServletWrapper) rr.lock();
View Full Code Here


     * @return a ResourceReference
     */
    protected ResourceReference getServletDirectoryReference(httpd server) {
  ResourceReference rr = server.getEditRoot();
  try {
      FramedResource root = (FramedResource) rr.lock();
      try {
    LookupState  ls = new LookupState(SERVLET_BASE_P);
    LookupResult lr =
        new LookupResult(root.getResourceReference());
    root.lookup(ls, lr);
    return lr.getTarget();
      } catch (ProtocolException ex) {
    ex.printStackTrace();
    return null;
      }
View Full Code Here

    {
  String uri  = SERVLET_BASE_P+"/"+name;
  // internal lookup
  ResourceReference rr = server.getEditRoot();
  try {
      FramedResource root = (FramedResource) rr.lock();
      try {
    DirectoryResource parent = (DirectoryResource) sdir.lock();
    LookupState  ls = new LookupState(uri);
    LookupResult lr =
        new LookupResult(root.getResourceReference());
    root.lookup(ls, lr);
    ResourceReference target = lr.getTarget();
    if (target != null) {
        try {
      ServletWrapper wrapper =
          (ServletWrapper) target.lock();
View Full Code Here

  throws ProtocolException, ResourceException
    {
  ResourceReference rr = getResource().getParent();
  if (rr != null) {
      try {
    FramedResource p = (FramedResource)rr.unsafeLock();
    // synchronize here to create locks in the right order
    synchronized (p) {
        // verify
        Class http_class = null;
        try {
      http_class =
          Class.forName("org.w3c.jigsaw.frames.HTTPFrame");
        } catch (ClassNotFoundException ex) {
      throw new ResourceException(ex.getMessage());
        }
        ResourceReference rrf = p.getFrameReference(http_class);
        if (rrf == null) {
      throw new ResourceException("DirectoryResource has "+
                "no HTTPFrame");
        }
        try {
View Full Code Here

      ResourceReference rr = lookup(noext);
      ResourceReference rr_neg_frame = null;

      if (rr != null) {
    try {
        FramedResource r = (FramedResource)rr.lock();
        Class nClass =
      Class.forName("org.w3c.jigsaw.frames.NegotiatedFrame");
        rr_neg_frame = r.getFrameReference(nClass);
        if (rr_neg_frame == null)
      return;
    } catch (ClassNotFoundException cex) {
        return;
    } catch (InvalidResourceException ex) {
        return;
    } finally {
        rr.unlock();
    }
      }

      if (rr_neg_frame == null) {
    // we can't add a NegotiatedFrame to an existing resource.
    if (rr == null) {
        // create the resource.
        FramedResource resource = new FramedResource();
        Hashtable defs = new Hashtable(5) ;
        defs.put(id, noext);
        ResourceContext context =
      updateDefaultChildAttributes(defs);
        resource.initialize(defs);
        addResource(resource, defs);
        // add a NegotiatedFrame.
        String variants[] = new String[1] ;
        variants[0] = name ;
        NegotiatedFrame negotiated = new NegotiatedFrame();
        Hashtable f_defs = new Hashtable(5) ;
        f_defs.put("variants".intern(), variants) ;
        resource.registerFrame(negotiated, f_defs);
    }
      } else {
    try {
        NegotiatedFrame negotiated =
      (NegotiatedFrame) rr_neg_frame.lock();
View Full Code Here

    lr.setTarget(null);
    return false;
      }
      try {
    lr.setTarget(rr);
    FramedResource resource = (FramedResource) rr.lock();
    return (resource != null ) ? resource.lookup(ls, lr) : false;
      } catch (InvalidResourceException ex) {
    return false;
      } finally {
    rr.unlock();
      }     
View Full Code Here

            Hashtable defs)
    {
  if (! name.endsWith(".class"))
      return super.createFileResource(directory, req, name, defs);
  ResourceReference rr = null;
  FramedResource template = null;
 
  // Check that at least one class is defined for all the extensions:
  String exts[] = getFileExtensions(name) ;
  if ( exts == null )
      return null ;
  for (int i = exts.length-1 ; i >= 0 ; i--) {
      rr = getTemplateFor(exts[i]) ;
      if ( rr != null )
    break ;
  }
  if ( rr == null ) {
      // Look for a default template:
      if ((rr = loadExtension(defname)) == null)
    return null ;
      return super.createFileResource(directory, req, name, defs);
  } else {
      //this could become a servlet
      Hashtable tempdefs = null;
      String s_dir = "directory".intern();
      String s_ide = "identifier".intern();
      String s_ser = "servlet-class".intern();
      String s_con = "context".intern();
      String s_url = "url".intern();
      if (defs != null) {
    tempdefs = (Hashtable) defs.clone();
      } else {
    tempdefs = new Hashtable(5) ;
      }
      if ( tempdefs.get(s_dir) == null )
    tempdefs.put(s_dir, directory) ;
      if ( tempdefs.get(s_con) == null )
    tempdefs.put(s_con, getContext());
      try {
    template = (FramedResource) rr.lock();
    if (template instanceof ServletWrapper) {
        if (tempdefs.get(s_ser) == null)
      tempdefs.put(s_ser, name);
        String id = getIndexedFileName(name);
        tempdefs.put(s_ide, id) ;
        String url = (String) tempdefs.get(s_url);
        if ((url != null) && (url.endsWith(".class"))) {
      int idx = url.lastIndexOf(".class");
      tempdefs.put(s_url, url.substring(0, idx));
        }
    } else {
        if ( tempdefs.get(s_ide) == null )
      tempdefs.put(s_ide, name);
    }
    if (exts != null) {
        // Merge with values defined by the extension:
        for (int i = exts.length ; --i >= 0 ; )
      mergeDefaultAttributes(template, exts[i], tempdefs) ;
    }
    // Create, initialize and return the new resource
    try {
        FramedResource cloned =
      (FramedResource) template.getClone(tempdefs);
        if (cloned instanceof ServletWrapper) {
      ServletWrapper wrapper = (ServletWrapper) cloned;
      // check the servlet class
      if (! wrapper.isWrappingAServlet())
View Full Code Here

    protected File resDirectory = null;

    protected File getResourceDirectory() {
  if (resDirectory == null) {
      FramedResource fr = getResource();
      if (fr instanceof DirectoryResource) {
    resDirectory = ((DirectoryResource) fr).getDirectory();
      }
  }
  return resDirectory;
View Full Code Here

          DirectoryResource dir =
        (DirectoryResource) resource;
          ResourceReference rr = dir.lookup(index);
          if (rr != null) {
        try {
            FramedResource rindex =
          (FramedResource) rr.lock();
            return rindex.lookup(ls,lr);
        } catch (InvalidResourceException ex) {
        } finally {
            rr.unlock();
        }
          }
View Full Code Here

    public void registerResource(FramedResource resource) {
  super.registerOtherResource(resource);
  dirResourceRef = resource.getParent();
  try {
      FramedResource fres = (FramedResource)dirResourceRef.lock();
      // register us as a listener
      fres.addStructureChangedListener(this);
  } catch(InvalidResourceException ex) {
      ex.printStackTrace();
  } finally {
      dirResourceRef.unlock();
  }
View Full Code Here

TOP

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

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.