Package com.caucho.loader

Examples of com.caucho.loader.DynamicClassLoader


  public void init(FilterConfig config)
    throws ServletException
  {
    _stylePath = new MergePath();
    _stylePath.addMergePath(Vfs.lookup());
    DynamicClassLoader loader;
    loader = (DynamicClassLoader) Thread.currentThread().getContextClassLoader();
    String resourcePath = loader.getResourcePathSpecificFirst();
    _stylePath.addClassPath(resourcePath);

    _application = config.getServletContext();

    if ("true".equals(config.getInitParameter("unconditional")))
View Full Code Here


    throws Exception
  {
    ClassLoader parentLoader = getParentLoader();
   
    if (parentLoader instanceof DynamicClassLoader) {
      DynamicClassLoader dcl = (DynamicClassLoader) parentLoader;

      dcl.make();
    }

    Path workPath = getClassDir();

    _cl = beanClass;
View Full Code Here

      }

      if (_classLoader != null)
        _classLoader.getNewTempClassLoader();
      else
        new DynamicClassLoader(null);
    } finally {
      thread.setContextClassLoader(oldLoader);
    }
  }
View Full Code Here

   * Adds any class path from the manifest.
   */
  protected void addManifestClassPath()
    throws IOException
  {
    DynamicClassLoader loader = Environment.getDynamicClassLoader();
    if (loader == null)
      return;

    Manifest manifest = getManifest();

    if (manifest == null)
      return;

    Attributes main = manifest.getMainAttributes();

    if (main == null)
      return;

    String classPath = main.getValue("Class-Path");

    Path pwd = null;

    if (getArchivePath() != null)
      pwd = getArchivePath().getParent();
    else
      pwd = getRootDirectory();

    if (classPath == null) {
    }
    else if (_manifestLoader != null)
      _manifestLoader.addManifestClassPath(classPath, pwd);
    else
      loader.addManifestClassPath(classPath, pwd);
  }
View Full Code Here

      path = _resourceManager.resolvePath(location);

    if (path.exists())
      return path;

    DynamicClassLoader loader;
    loader = (DynamicClassLoader) Thread.currentThread().getContextClassLoader();
    String classPath = loader.getClassPath();
    char sep = CauchoSystem.getPathSeparatorChar();

    int head = 0;
    int tail = 0;
View Full Code Here

    WebApp webApp = req.getWebApp();
    Path appDir = webApp.getAppDir();
    Path pwd = appDir.lookupNative(webApp.getRealPath(servletPath));
    pwd = pwd.getParent();

    DynamicClassLoader loader;
    loader = (DynamicClassLoader) webApp.getClassLoader();
   
    MergePath stylePath = new MergePath();
    stylePath.addMergePath(pwd);
    stylePath.addMergePath(appDir);

    String resourcePath = loader.getResourcePathSpecificFirst();
    stylePath.addClassPath(resourcePath);
   
    Path hrefPath = stylePath.lookup(href);

    if (hrefPath.canRead()) {
      DynamicClassLoader owningLoader = getStylesheetLoader(href, hrefPath);

      if (owningLoader != null) {
  loader = owningLoader;
 
  stylePath = new MergePath();
View Full Code Here

    }
  }

  private DynamicClassLoader getStylesheetLoader(String href, Path sourcePath)
  {
    DynamicClassLoader owningLoader = null;
    ClassLoader loader = Thread.currentThread().getContextClassLoader();

    for (; loader != null; loader = loader.getParent()) {
      if (! (loader instanceof DynamicClassLoader))
  continue;

      DynamicClassLoader dynLoader = (DynamicClassLoader) loader;
     
      MergePath mp = new MergePath();
      String resourcePath = dynLoader.getResourcePathSpecificFirst();
      mp.addClassPath(resourcePath);

      Path loaderPath = mp.lookup(href);

      if (loaderPath.getNativePath().equals(sourcePath.getNativePath()))
View Full Code Here

  {
    if (isClassMatch(className)) {
      try {
  ClassLoader tempLoader
    = ((DynamicClassLoader) loader).getNewTempClassLoader();
  DynamicClassLoader workLoader
    = SimpleLoader.create(tempLoader, getPostWorkPath());
  workLoader.setServletHack(true);
  boolean isModified = true;

  Thread thread = Thread.currentThread();
  ClassLoader oldLoader = thread.getContextClassLoader();
 
View Full Code Here

  /**
   * Checks if the preload exists
   */
  public boolean preloadExists(String fullClassName)
  {
    DynamicClassLoader preloadLoader = null;
   
    Path workDir = getWorkDir();

    String classFile = fullClassName.replace('.', '/') + ".class";

View Full Code Here

   * changed, return null.
   */
  public Class loadClass(String fullClassName, boolean preload)
    throws ClassNotFoundException
  {
    DynamicClassLoader preloadLoader = null;
   
    try {
      ClassLoader loader;

      if (preload) {
  preloadLoader = SimpleLoader.create(getPreloadLoader(),
              getWorkDir(),
              fullClassName);

  // needed for cases like Amber enhancing
  preloadLoader.setServletHack(true);
  loader = preloadLoader;
      }
      else {
  // XXX: because of automatic instantiation, might cause trouble
  loader = getClassLoader();

  if (loader == null) {
    loader = SimpleLoader.create(getParentLoader(),
               getWorkDir(),
               fullClassName);
  }
      }

      Class cl = Class.forName(fullClassName, false, loader);

      if (cl == null)
  return null;
     
      if (! preload)
  return cl;

      if (isModified(cl)) {
  return null;
      }

      if (_loader != null)
  loader = _loader;
      else {
  loader = SimpleLoader.create(getParentLoader(),
             getWorkDir(),
             fullClassName);
      }

      cl = Class.forName(fullClassName, false, loader);

      return cl;
    } catch (RuntimeException e) {
      if (! preload)
  throw e;
      else {
        log.log(Level.FINE, e.toString(), e);
       
  return null;
      }
    } catch (Error e) {
      if (! preload)
  throw e;
      else {
        log.log(Level.FINE, e.toString(), e);
     
  return null;
      }
    } catch (ClassNotFoundException e) {
      if (! preload)
  throw e;
      else
  return null;
    } finally {
      if (preloadLoader != null)
  preloadLoader.destroy();
    }
  }
View Full Code Here

TOP

Related Classes of com.caucho.loader.DynamicClassLoader

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.