Changeset 5746


Ignore:
Timestamp:
Sep 15, 2011, 1:42:31 PM (10 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #1592: Unified installation procedure for plug-ins, extensions and more...

Fixed the problem with the XJspCompiler.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/misc/compiler/net/sf/basedb/clients/web/extensions/XJspCompiler.java

    r4512 r5746  
    6464 
    6565  /**
    66     The location where the extension system is looking for extensions.
    67   */
    68   public static final String EXTENSIONS_URL = "/WEB-INF/extensions";
    69  
    70   /**
    7166    The location where the extensions resources are extracted.
    7267  */
     
    8075    Pattern.compile(RESOURCES_URL + "/([^/]+)/(.+\\.xjsp)");
    8176   
     77  // The path to the plug-ins directory
     78  private File pluginsDir;
    8279  // If this JSP is an extensions JSP
    8380  private boolean isXJsp;
     
    10097  */
    10198  @Override
    102   public void init(JspCompilationContext ctxt, JspServletWrapper jsw)
    103   {
     99  public void init(JspCompilationContext ctxt, JspServletWrapper jsw)
     100  {
     101    super.init(ctxt, jsw);
    104102    String jspName = ctxt.getJspFile();
     103    if (log.isDebugEnabled())
     104    {
     105      log.debug("Initialising XJSP compiler for file: " + jspName);
     106    }
    105107    Matcher m = PATH_MATCH.matcher(jspName);
    106108    if (m.matches())
    107109    {
    108110      String jarName = m.group(1);
    109       String jarPath = ctxt.getRealPath(EXTENSIONS_URL + "/" + jarName);
    110       extensionsJar = new File(jarPath);
     111      File pluginsDir = getPluginsDir();
     112      extensionsJar = new File(pluginsDir, jarName);
    111113      isXJsp = extensionsJar.exists();
    112         }
    113     if (log.isDebugEnabled())
    114     {
    115       log.debug("Initialising XJSP compiler for file: " + jspName +
    116         "; JAR=" + extensionsJar + "; isXJsp=" + isXJsp);
    117     }
    118     super.init(ctxt, jsw);
     114      }
     115    if (log.isDebugEnabled())
     116    {
     117      log.debug("JAR=" + extensionsJar + "; isXJsp=" + isXJsp);
     118    }
    119119  }
    120120
     
    201201  protected ClassLoader getWebAppClassLoader()
    202202  {
    203     return ctxt.getRuntimeContext().getParentClassLoader();
    204   }
    205 
     203    return getCompilationContext().getRuntimeContext().getParentClassLoader();
     204  }
     205
     206  /**
     207    Get the path to the plug-in directory from BASE.
     208    @since 3.0
     209  */
     210  protected File getPluginsDir()
     211  {
     212    if (pluginsDir == null)
     213    {
     214      try
     215      {
     216        ClassLoader webAppLoader = getWebAppClassLoader();
     217        Class<?> appClass = Class.forName("net.sf.basedb.core.Application", true, webAppLoader);
     218        Method getPluginsDirectory = appClass.getMethod("getPluginsDirectory");
     219        pluginsDir = (File)getPluginsDirectory.invoke(null);
     220      }
     221      catch (Exception ex)
     222      {
     223        log.error("Could not get plug-ins directory", ex);
     224      }
     225    }
     226    return pluginsDir;
     227  }
    206228 
    207229}
Note: See TracChangeset for help on using the changeset viewer.