Changeset 5601


Ignore:
Timestamp:
Apr 1, 2011, 3:03:15 PM (10 years ago)
Author:
Nicklas Nordborg
Message:

References #1592: Unified installation procedure for plug-ins, extensions and more...
References #1593: Extension system for the core API

Started to move the web client extensions into the core registry. So far the extensions are loaded at startup, but there is no support for adding more at runtime. The administrative interface is a bit of a mess right now, since a lot of the metadata that we used to get from the registration process is not yet available.

Location:
trunk
Files:
2 added
1 deleted
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/clients/web/net/sf/basedb/clients/web/extensions/ExtensionsControl.java

    r5599 r5601  
    2222
    2323import java.io.File;
     24import java.net.URI;
    2425import java.util.Collections;
    2526import java.util.EnumSet;
     
    2728import java.util.List;
    2829import java.util.Set;
    29 import java.util.TimerTask;
     30import java.util.regex.Pattern;
    3031
    3132import javax.servlet.ServletContext;
     
    3940import net.sf.basedb.core.Application;
    4041import net.sf.basedb.core.Client;
     42import net.sf.basedb.core.Config;
    4143import net.sf.basedb.core.DbControl;
    4244import net.sf.basedb.core.Permission;
     
    5254import net.sf.basedb.util.extensions.Registry;
    5355import net.sf.basedb.util.extensions.events.EventType;
     56import net.sf.basedb.util.extensions.manager.ExtensionsManager;
     57import net.sf.basedb.util.extensions.manager.ExtractResourcesProcessor;
     58import net.sf.basedb.util.extensions.manager.RegisterExtensionsProcessor;
     59import net.sf.basedb.util.extensions.xml.ExtensionPointFilter;
     60import net.sf.basedb.util.extensions.xml.PathConverter;
     61import net.sf.basedb.util.extensions.xml.VariableConverter;
     62import net.sf.basedb.util.extensions.xml.XmlLoader;
    5463
    5564/**
     
    7887 
    7988  /**
    80     The location where the extension system is looking for extensions.
    81   */
    82   public static final String EXTENSIONS_URL = "/WEB-INF/extensions";
    83  
    84   /**
    8589    The location where the extensions resources are extracted.
    8690  */
     
    115119  private static Registry registry;
    116120 
     121  // The main extensions manager
     122  private static ExtensionsManager manager;
     123 
    117124  // The directory where extension files are located
    118   private static ExtensionsDirectory extensionsDir;
     125  //private static ExtensionsDirectory extensionsDir;
    119126 
    120127  // Settings
     
    123130  // The Servlet Context provided by the web server
    124131  private static ServletContext servletContext;
    125  
    126   // Automatic check for new/updated/deleted extensions
    127   private static TimerTask autoInstallTask;
    128  
     132   
    129133  // The result of the last automatic update
    130134  private static ScanResults lastScanResults;
    131  
    132   // The scheduled time of the next automatic scan, or 0 if not enabled
    133   private static long nextAutoScan;
    134  
     135   
    135136  /**
    136137    Initialise the extension system. This method is called once from the
    137138    {@link ExtensionsServlet} when the web server starts up.
    138139  */
    139   public static synchronized void init(ExtensionsDirectory directory,
    140     ServletContext context)
     140  public static synchronized void init(ServletContext context)
    141141  {
    142142    if (initialised) return;
    143143    log.info("Initialising extensions controller");
    144     extensionsDir = directory;
     144    //extensionsDir = directory;
    145145    servletContext = context;
    146146   
    147147    // Create registry
    148     registry = new Registry();
     148    manager = Application.getExtensionsManager();
     149    registry = Application.getExtensionsManager().getRegistry();
    149150   
    150151    // Register some extension points programmatically. This
     
    154155    EditUtil.registerExtensionPoints(registry); // TabControls
    155156   
     157    manager.addExtensionsFile(new net.sf.basedb.util.extensions.manager.ExtensionsFile(URI.create(ExtensionsControl.class.getResource("/web-extensions.xml").toString())));
     158
    156159    // Load settings
    157     File settingsFile = new File(directory.getExtensionDirectory(), "settings.xml");
    158     settings = new Settings(extensionsDir, settingsFile);
    159     extensionsDir.addIgnore(settingsFile);
     160    File settingsFile = new File(Config.getConfigDirectory(), "settings.xml");
     161    settings = new Settings(settingsFile);
     162    //extensionsDir.addIgnore(settingsFile);
    160163   
    161164    // Install extensions
     165    XmlLoader loader = new XmlLoader();
     166    // Filter that only load web extension points
     167    loader.setFilter(new ExtensionPointFilter("net\\.sf\\.basedb\\.clients\\.web\\..*"));
     168
     169    final VariableConverter variableConverter = new VariableConverter();
     170    variableConverter.setVariable("ROOT", servletContext.getContextPath());
     171    variableConverter.setVariable("HOME", null);
     172    variableConverter.setVariable("SERVLET_HOME", null);   
     173    final PathConverter pathConverter = new PathConverter(servletContext.getContextPath(), null);
     174
     175    loader.addValueConverter(variableConverter);
     176    loader.addValueConverter(pathConverter);
     177
     178    manager.processFiles(new RegisterExtensionsProcessor(loader)
     179    {
     180
     181      @Override
     182      public void processFile(ExtensionsManager manager,
     183          net.sf.basedb.util.extensions.manager.ExtensionsFile xtFile)
     184      {
     185        String homePath = servletContext.getContextPath() + RESOURCES_URL + "/" + xtFile.getName();
     186        //String servletHomePath = getServletsUrl(extFile);
     187        variableConverter.setVariable("HOME", homePath);
     188        //variableConverter.setVariable("SERVLET_HOME", servletHomePath);
     189        pathConverter.setHome(homePath);
     190
     191        super.processFile(manager, xtFile);
     192      }
     193     
     194    });
     195    manager.processFiles(new ExtractResourcesProcessor(new java.io.File(servletContext.getRealPath(RESOURCES_URL)), false, Pattern.compile("resources/(.*)"), "$1"));
     196    /*
    162197    lastScanResults = extensionsDir.installAndUpdateExtensions(registry,
    163198      servletContext, false, false);
    164 
    165     initAutoInstaller();
     199    */
     200
    166201    initialised = true;
    167202   
     
    180215    Services.close();
    181216    registry = null;
    182     extensionsDir = null;
     217    //extensionsDir = null;
    183218    settings = null;
    184219    servletContext = null;
    185220    lastScanResults = null;
    186     if (autoInstallTask != null)
    187     {
    188       autoInstallTask.cancel();
    189       autoInstallTask = null;
    190     }
    191221    initialised = false;
    192222    log.info("Extensions controller closed successfully");
     
    198228  }
    199229 
    200   /**
    201     Initialise the automatic installation task. This method
    202     should be called whenever the {@link #getAutoInstall()}
    203     settings has changed.
    204   */
    205   private static synchronized void initAutoInstaller()
    206   {
    207     log.info("Initialising auto-installer");
    208     if (autoInstallTask != null)
    209     {
    210       log.debug("Cancelling existing auto-installer");
    211       autoInstallTask.cancel();
    212     }
    213     int autoInstall = settings.getAutoInstall();
    214     if (autoInstall > 0)
    215     {
    216       log.debug("Creating new auto-installer with " + autoInstall + " seconds interval");
    217       long checkInterval = autoInstall * 1000;
    218       autoInstallTask = Application.getScheduler().schedule(new AutoInstallTask(), checkInterval, checkInterval, false);
    219       nextAutoScan = System.currentTimeMillis() + checkInterval;
    220       log.info("Auto-installation system is running with " + autoInstall + " seconds interval");
    221     }
    222     else
    223     {
    224       log.debug("Disabling auto-installation system (autoInstall=" + autoInstall + ")");
    225       autoInstallTask = null;
    226       nextAutoScan = 0;
    227       log.info("Auto-installation system is now disabled");
    228     }
    229   }
    230  
     230
    231231  /**
    232232    Get an extension control object for managing the
     
    291291  public static JspContext createContext(SessionControl sc, PageContext pageContext)
    292292  {
    293     return new JspContext(extensionsDir, sc, null, pageContext, null, null);
     293    return new JspContext(sc, null, pageContext, null, null);
    294294  }
    295295 
     
    301301  public static JspContext createContext(DbControl dc, PageContext pageContext)
    302302  {
    303     return new JspContext(extensionsDir, dc.getSessionControl(), dc, pageContext,
     303    return new JspContext(dc.getSessionControl(), dc, pageContext,
    304304      null, null);
    305305  }
     
    315315    GuiContext guiContext, Object currentItem)
    316316  {
    317     return new JspContext(extensionsDir, dc.getSessionControl(), dc,
     317    return new JspContext(dc.getSessionControl(), dc,
    318318      pageContext, guiContext, currentItem);
    319319  }
     
    330330  public static String getHomeUrl(String extensionId)
    331331  {
    332     ExtensionsFile file = extensionsDir.getFileByExtensionId(extensionId);
    333     return file == null ? null : extensionsDir.getResourcesUrl(file);
     332    return null;
     333    //return file == null ? null : extensionsDir.getResourcesUrl(file);
    334334  }
    335335 
     
    354354  public static String getServletUrl(String extensionId, String servletName)
    355355  {
    356     ExtensionsFile file = extensionsDir.getFileByExtensionId(extensionId);
     356    //ExtensionsFile file = extensionsDir.getFileByExtensionId(extensionId);
    357357    String servletPath = null;
     358    /*
    358359    if (file != null)
    359360    {
    360361      servletPath = extensionsDir.getServletsUrl(file) + "/" + servletName;
    361362    }
     363    */
    362364    return servletPath;
    363365  }
     
    421423  public ScanResults installAndUpdateExtensions(boolean forceUpdate)
    422424  {
     425    /*
    423426    checkPermission(Permission.WRITE, "extensions");
    424427    ScanResults results =
     
    426429    setLastScanResults(results);
    427430    return results;
    428   }
    429  
    430   /**
    431     Get the auto-installation setting. A value > 0 means that
    432     a background thread is checking for new/updated/deleted extensions
    433     every x seconds. If the value is 0 or negative automatic installation
    434     is disabled.
    435    
    436     @return The number of seconds between automatic checking
    437   */
    438   public int getAutoInstall()
    439   {
    440     return settings.getAutoInstall();
    441   }
    442  
    443   /**
    444     Change the auto-installation setting.
    445     @param autoInstall Number of seconds between automatic checks,
    446       or 0 or negative to disable
    447     @throws PermissionDeniedException If the logged in user doesn't
    448       have WRITE permission
    449     @see #getAutoInstall()
    450   */
    451   public void setAutoInstall(int autoInstall)
    452   {
    453     checkPermission(Permission.WRITE, "settings");
    454     settings.setAutoInstall(autoInstall);
    455     initAutoInstaller();
    456   }
    457 
     431    */
     432    return new ScanResults(true, false);
     433  }
     434 
    458435  /**
    459436    Get the results of the last scan (manual or automatic).
     
    464441  {
    465442    return lastScanResults;
    466   }
    467  
    468   /**
    469     Get the next scheduled time for automatic scanning. Note!
    470     It is not guaranteed that the next automatic scan will take
    471     place at exactly the returned time. Depending on timer resolution
    472     and other activity the scan may take place sooner or later.
    473    
    474     @return A time value in milliseconds or 0 if automatic
    475       scanning is disabled
    476     @see System#currentTimeMillis()
    477   */
    478   public long getNextAutoScanTime()
    479   {
    480     return nextAutoScan;
    481443  }
    482444 
     
    633595
    634596  /**
    635     Get an iterator returning all XML/JAR files which contains installed
     597    Get an list returning all XML/JAR files which contains installed
    636598    extensions.
    637599  */
    638   public Iterator<ExtensionsFile> getFiles()
    639   {
    640     return extensionsDir.getFiles();
     600  public List<net.sf.basedb.util.extensions.manager.ExtensionsFile> getFiles()
     601  {
     602    return manager.getFiles();
    641603  }
    642604 
     
    647609      the given file doesn't exists or isn't an extensions file
    648610  */
    649   public ExtensionsFile getFile(String filename)
    650   {
    651     return extensionsDir.getFile(filename);
     611  public net.sf.basedb.util.extensions.manager.ExtensionsFile getFile(String filename)
     612  {
     613    return null;
     614    //return extensionsDir.getFile(filename);
    652615  }
    653616 
     
    659622      or null if no extension with the given ID is found
    660623  */
    661   public ExtensionsFile getFileByExtensionId(String extensionId)
    662   {
    663     return extensionsDir.getFileByExtensionId(extensionId);
     624  public net.sf.basedb.util.extensions.manager.ExtensionsFile getFileByObjectId(String objectId)
     625  {
     626    return manager.getFileByObjectId(objectId);
     627    //return null;
     628    //return extensionsDir.getFileByExtensionId(extensionId);
    664629  }
    665630 
     
    674639  {
    675640    checkPermission(Permission.WRITE, "File[" + filename + "]");
    676     ExtensionsFile file = getFile(filename);
     641    ExtensionsFile file = null; //getFile(filename);
    677642    if (file == null)
    678643    {
     
    715680  }
    716681 
    717   /**
    718     Task for starting an automatic check for new/updated/deleted
    719     extensions.
    720     @see ExtensionsControl#initAutoInstaller()
    721   */
    722   static class AutoInstallTask
    723     extends TimerTask
    724   {
    725  
    726     AutoInstallTask()
    727     {}
    728 
    729     @Override
    730     public void run()
    731     {
    732       log.debug("Checking for new/updated/deleted extensions");
    733       int autoInstall = settings.getAutoInstall();
    734       ScanResults results = extensionsDir.installAndUpdateExtensions(registry,
    735           servletContext, false, false);
    736       setLastScanResults(results);
    737       nextAutoScan = autoInstall > 0 ?
    738         System.currentTimeMillis() + autoInstall * 1000L : 0;
    739       log.debug("Done checking for new/updated/deleted extensions.");
    740     }
    741   }
    742  
    743682}
  • trunk/src/clients/web/net/sf/basedb/clients/web/extensions/JspContext.java

    r5485 r5601  
    7979  public static final String ATTRIBUTE_KEY = "net.sf.basedb.clients.web.extensions.JspContext";
    8080 
    81   private final ExtensionsDirectory directory;
    8281  private final PageContext pageContext;
    8382  private final GuiContext guiContext;
     
    8685  private Set<String> stylesheets;
    8786 
    88   JspContext(ExtensionsDirectory directory, SessionControl sc, DbControl dc,
     87  JspContext(SessionControl sc, DbControl dc,
    8988    PageContext pageContext, GuiContext guiContext, Object item)
    9089  {
    9190    super(sc, dc, item);
    92     this.directory = directory;
    9391    this.pageContext = pageContext;
    9492    this.guiContext = guiContext;
     
    148146  public String getHome(Extension extension)
    149147  {
    150     ExtensionsFile file = directory.getFileByExtensionId(extension.getId());
    151     return file == null ? null : directory.getResourcesUrl(file);
     148    //ExtensionsFile file = directory.getFileByExtensionId(extension.getId());
     149    //return file == null ? null : directory.getResourcesUrl(file);
     150    return null;
    152151  }
    153152 
  • trunk/src/clients/web/net/sf/basedb/clients/web/extensions/Settings.java

    r5384 r5601  
    3232import net.sf.basedb.core.Presets;
    3333import net.sf.basedb.core.Presets.Preset;
    34 import net.sf.basedb.util.Values;
    3534import net.sf.basedb.util.extensions.DefaultFilter;
    3635import net.sf.basedb.util.extensions.Extension;
     
    6564{
    6665 
    67   private static final String AUTO_INSTALL = "auto-install";
     66  //private static final String AUTO_INSTALL = "auto-install";
    6867
    69   private final ExtensionsDirectory directory;
     68  //private final ExtensionsDirectory directory;
    7069  private final File file;
    7170  private boolean hasChanged;
     
    8180    @param file The file to load/save settings in
    8281  */
    83   public Settings(ExtensionsDirectory directory, File file)
     82  public Settings(File file)
    8483  {
    85     this.directory = directory;
     84//    this.directory = directory;
    8685    this.file = file;
    8786    this.presets = new Presets();
     
    113112  {
    114113    if (extensionPoint == null) return false;
    115     ExtensionsFile extFile = directory.getFileByExtensionId(extensionPoint.getId());
    116     if (extFile != null && (extFile.hasError() || !extFile.isValid())) return false;
     114    //ExtensionsFile extFile = directory.getFileByExtensionId(extensionPoint.getId());
     115    //if (extFile != null && (extFile.hasError() || !extFile.isValid())) return false;
    117116    return disabledExtensionPoints.getSetting(extensionPoint.getId()) == null;
    118117  }
     
    122121  {
    123122    if (extension == null) return false;
    124     ExtensionsFile extFile = directory.getFileByExtensionId(extension.getId());
    125     if (extFile != null && (extFile.hasError() || !extFile.isValid())) return false;
     123    //ExtensionsFile extFile = directory.getFileByExtensionId(extension.getId());
     124    //if (extFile != null && (extFile.hasError() || !extFile.isValid())) return false;
    126125    return disabledExtensions.getSetting(extension.getId()) == null;
    127126  }
     
    151150 
    152151  /**
    153     Get the interval, in seconds, between automatic checks
    154     for new/modified/deleted extensions.
    155     @return The interval in seconds or 0 if the auto-install feature
    156      is disabled (the default)
    157   */
    158   public int getAutoInstall()
    159   {
    160     int autoInstall = Values.getInt(settings.getSetting(AUTO_INSTALL));
    161     return autoInstall > 0 ? autoInstall : 0;
    162   }
    163  
    164   /**
    165     Change the interval, in seconds, between automatic checks
    166     for new/modified/deleted extensions.
    167     @param autoInstall The interval in seconds, or 0 to disable the
    168       feature
    169   */
    170   public synchronized void setAutoInstall(int autoInstall)
    171   {
    172     if (autoInstall < 0) autoInstall = 0;
    173     settings.setSetting(AUTO_INSTALL, Integer.toString(autoInstall));
    174     hasChanged = true;
    175   }
    176  
    177   /**
    178152    Save the settings to disk. If the settings has not been
    179153    changed the file is not written.
  • trunk/src/clients/web/net/sf/basedb/clients/web/servlet/ExtensionsServlet.java

    r4975 r5601  
    7474    ServletConfig cfg = getServletConfig();
    7575    ServletContext context = cfg.getServletContext();
     76    /*
    7677    File extensionsDir = new File(context.getRealPath(ExtensionsControl.EXTENSIONS_URL));
    7778    File resourcesDir = new File(context.getRealPath(ExtensionsControl.RESOURCES_URL));
     
    8081    ExtensionsDirectory extensions = new ExtensionsDirectory(
    8182        extensionsDir, resourcesDir, rootUrl, rootUrl + ExtensionsControl.RESOURCES_URL);
    82     ExtensionsControl.init(extensions, context);
     83    */
     84    ExtensionsControl.init(context);
    8385  }
    8486
     
    132134
    133135    ExtensionsControl ec = ExtensionsControl.get(null);
    134     ExtensionsFile file = ec.getFile(jarName);
     136    ExtensionsFile file = null; //ec.getFile(jarName);
    135137    if (file == null)
    136138    {
  • trunk/src/core/net/sf/basedb/util/extensions/manager/ExtensionsFile.java

    r5600 r5601  
    2828import java.io.InputStream;
    2929import java.net.URI;
     30import java.util.HashMap;
     31import java.util.Map;
    3032import java.util.zip.ZipEntry;
    3133import java.util.zip.ZipFile;
     
    204206  public boolean isModified()
    205207  {
    206     return file != null && lastModified != file.lastModified() ||
     208    return file != null && (lastModified != file.lastModified() ||
    207209      lastSize != file.length() ||
    208       (jarLoader != null && jarLoader.hasChanged(true));
     210      (jarLoader != null && jarLoader.hasChanged(true)));
    209211  }
    210212 
  • trunk/src/core/net/sf/basedb/util/extensions/manager/ExtensionsManager.java

    r5600 r5601  
    2424import java.io.File;
    2525import java.io.FileFilter;
     26import java.util.ArrayList;
     27import java.util.HashMap;
    2628import java.util.HashSet;
     29import java.util.List;
     30import java.util.Map;
    2731import java.util.Set;
    2832import java.util.TreeSet;
     33
     34import org.apache.commons.collections.map.HashedMap;
    2935
    3036import net.sf.basedb.util.RegexpFileFilter;
     
    5561  private final Set<ExtensionsFile> xtFiles;
    5662 
     63  // Map objects to the file they are defined in. The key is a unique object id
     64  private final Map<String, ExtensionsFile> installedObjects;
     65 
    5766  /**
    5867    Create a new extensions manager and use the given registry
     
    6776    this.ignore = new HashSet<ExtensionsFile>();
    6877    this.xtFiles = new TreeSet<ExtensionsFile>();
     78    this.installedObjects = new HashMap<String, ExtensionsFile>();
    6979  }
    7080 
     
    147157      ignore.add(xtFile);
    148158    }
     159  }
     160 
     161  public List<ExtensionsFile> getFiles()
     162  {
     163    // Create a copy, or the iterator will fail if new
     164    // files are added by another thread
     165    List<ExtensionsFile> copy = new ArrayList<ExtensionsFile>(xtFiles);
     166    return copy;
     167  }
     168
     169  /**
     170    Find out which file the object with the given id was defined.
     171    An object id is typically created by an object-specific prefix
     172    plus the unique if of the object. Example:
     173   
     174    <ul>
     175    <li>extension:id-of-extension
     176    <li>extension-point:id-of-extension-point
     177    <li>servlet:name-of-servlet
     178    <li>etc.
     179    </ul>
     180   
     181    @param objectId The complete object id
     182    @return Information about the file the object is defined in,
     183      or null if no extension with the given ID is found
     184  */
     185  public ExtensionsFile getFileByObjectId(String objectId)
     186  {
     187    return installedObjects.get(objectId);
     188  }
     189 
     190  public void setFileForObject(String objectId, ExtensionsFile xtFile)
     191  {
     192    installedObjects.put(objectId, xtFile);
    149193  }
    150194 
  • trunk/src/core/net/sf/basedb/util/extensions/manager/RegisterExtensionsProcessor.java

    r5598 r5601  
    2323
    2424import java.io.InputStream;
     25import java.util.ArrayList;
     26import java.util.List;
    2527
    2628import net.sf.basedb.util.FileUtil;
     29import net.sf.basedb.util.extensions.Action;
     30import net.sf.basedb.util.extensions.Extension;
     31import net.sf.basedb.util.extensions.ExtensionPoint;
     32import net.sf.basedb.util.extensions.Registry;
    2733import net.sf.basedb.util.extensions.xml.XmlLoader;
    2834
     
    4551 
    4652  private final XmlLoader loader;
     53  private List<Metadata> allMeta;
    4754 
    4855  /**
     
    6269  @Override
    6370  public void begin(ExtensionsManager manager, int numFiles)
    64   {}
     71  {
     72    this.allMeta = new ArrayList<Metadata>(numFiles);
     73  }
    6574
    6675  @Override
     
    7281      in = xtFile.getXmlStream();
    7382      log.debug("Loading extensions from file: " + xtFile.getName());
    74       loader.loadXmlFile(in, xtFile.getName(), xtFile.getClassLoader(), false);
     83      loader.loadXmlFile(in, xtFile.getName(), xtFile.getClassLoader(), true);
     84     
     85      Metadata meta = new Metadata();
     86      meta.xtFile = xtFile;
     87      meta.extensionPoints = new ArrayList<ExtensionPoint>(loader.getExtensionPoints());
     88      meta.extensions = new ArrayList<Extension>(loader.getExtensions());
     89      allMeta.add(meta);
    7590    }
    7691    catch (Exception ex)
     
    90105  {
    91106    log.debug("Registering all loaded extensions");
     107    if (allMeta != null)
     108    {
     109      Registry registry = manager.getRegistry();
     110      for (Metadata meta : allMeta)
     111      {
     112        for (ExtensionPoint<Action> ep : meta.extensionPoints)
     113        {
     114          if (!registry.extensionPointIsRegistered(ep.getId()))
     115          {
     116            registry.registerExtensionPoint(ep);
     117            manager.setFileForObject("extension-point:" + ep.getId(), meta.xtFile);
     118          }
     119        }
     120      }
     121      for (Metadata meta : allMeta)
     122      {
     123        for (Extension<Action> ext : meta.extensions)
     124        {
     125          if (!registry.extensionIsRegistered(ext.getId()))
     126          {
     127            registry.registerExtension(ext);
     128            manager.setFileForObject("extension:" + ext.getId(), meta.xtFile);
     129          }
     130        }
     131      }
     132      allMeta.clear();
     133      allMeta = null;
     134    }
     135    /*
    92136    loader.registerExtensionPoints(manager.getRegistry(), false);
    93137    loader.registerExtensions(manager.getRegistry(), false);
     138    */
    94139  }
    95140 
    96141  @Override
    97142  public void done(ExtensionsManager manager, Throwable t)
    98   {}
     143  {
     144    if (allMeta != null) allMeta.clear();
     145    allMeta = null;
     146  }
    99147  // ------------------------------------------
    100148
    101149
     150  static class Metadata
     151  {
     152    ExtensionsFile xtFile;
     153    List<Extension> extensions;
     154    List<ExtensionPoint> extensionPoints;
     155  }
    102156
    103157
  • trunk/www/admin/extensions/details.jsp

    r5487 r5601  
    3939  import="net.sf.basedb.util.extensions.RendererFactory"
    4040  import="net.sf.basedb.util.extensions.AboutBean"
     41  import="net.sf.basedb.util.extensions.manager.ExtensionsFile"
    4142  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
    42   import="net.sf.basedb.clients.web.extensions.ExtensionsFile"
    4343  import="net.sf.basedb.clients.web.extensions.ScanResults"
    4444  import="net.sf.basedb.clients.web.extensions.ScanResults.FileResults"
     
    6060  }
    6161  String text = factory.getClass().getName();
    62   String parameters = file == null ? null : file.getFactoryParameters(factory);
     62  String parameters = null; //file == null ? null : file.getFactoryParameters(factory);
    6363  if (parameters != null)
    6464  {
     
    105105    }
    106106    extensionPointId = ext.getExtends();
    107     extFile = ec.getFileByExtensionId(extensionId);
     107    extFile = ec.getFileByObjectId("extension:" + extensionId);
    108108  }
    109109 
     
    115115      throw new ItemNotFoundException("ExtensionPoint[id=" + extensionPointId + "]");
    116116    }
    117     epFile = ec.getFileByExtensionId(extensionPointId);
     117    epFile = ec.getFileByObjectId("extension-point:" + extensionPointId);
    118118  }
    119119%>
     
    186186    {
    187187      boolean isEnabled = ec.isEnabled(ext);
    188       boolean hasRegistrationError = extFile != null && extFile.hasError();
     188      boolean hasRegistrationError = extFile != null; // && extFile.hasError();
    189189      boolean allow = writePermission && !hasRegistrationError;
    190190      %>
     
    207207    {
    208208      boolean isEnabled = ec.isEnabled(ep);
    209       boolean hasRegistrationError = epFile != null && epFile.hasError();
     209      boolean hasRegistrationError = epFile != null; // && epFile.hasError();
    210210      boolean allow = writePermission && !hasRegistrationError;
    211211      %>
     
    227227    else if (file != null)
    228228    {
    229       boolean hasRegistrationError = file.hasError();
     229      boolean hasRegistrationError = false; //file.hasError();
    230230      boolean allow = writePermission && !hasRegistrationError;
    231231      %>
     
    315315            ><%=extFile.getName()%></a>
    316316            (<%=extFile.isModified() ? "Modified" : "Up to date" %>;
    317             <%=extFile.hasError() ? "Error" : "Ok" %>)
     317            <%=false /*extFile.hasError()*/ ? "Error" : "Ok" %>)
    318318          </td>
    319319        </tr>
     
    403403              ><%=epFile.getName()%></a>
    404404              (<%=epFile.isModified() ? "Modified" : "Up to date" %>;
    405               <%=epFile.hasError() ? "Error" : "Ok" %>)
     405              <%=true /*epFile.hasError()*/ ? "Error" : "Ok" %>)
    406406              <%
    407407            }
     
    454454          <td>
    455455            <%
    456             if (file.hasError())
     456            if (false /*file.hasError()*/)
    457457            {
    458458              ScanResults results = ec.getLastScanResults();
    459               FileResults fileResults = results.getResults(file);
     459              FileResults fileResults = null; //results.getResults(file);
    460460              List<String> messages = fileResults.getMessages();
    461461              Throwable validationError = file.getValidationError();
     
    517517      if (ext == null && ep == null && file == null)
    518518      {
    519         int autoInstall = ec.getAutoInstall();
    520519        ScanResults results = ec.getLastScanResults();
    521520        Formatter dateTimeFormatter = FormatterFactory.getDateTimeFormatter(sc);
    522521        %>
    523522        <table class="form" cellspacing="0">
    524         <%
    525         if (autoInstall > 0)
    526         {
    527           %>
    528           <tr>
    529             <td class="prompt">Automatic scan</td>
    530             <td>
    531               Every <%=autoInstall%> seconds
    532             </td>
    533           </tr>
    534           <tr>
    535             <td class="prompt" style="text-align: right; font-weight: normal;">- next scan</td>
    536             <td><%=dateTimeFormatter.format(new Date(ec.getNextAutoScanTime())) %></td>
    537           </tr>
    538           <%
    539         }
    540         else
    541         {
    542           %>
    543           <tr>
    544             <td class="prompt">Automatic scan</td>
    545             <td>Disabled</td>
    546           </tr>
    547           <%
    548         }
    549         %>
    550523        <tr>
    551524          <td class="prompt">Last scan</td>
  • trunk/www/admin/extensions/index.jsp

    r5426 r5601  
    5858    dc = sc.newDbControl();
    5959    ExtensionsControl ec = ExtensionsControl.get(dc);
    60     ec.setAutoInstall(Values.getInt(request.getParameter("autoInstall")));
    6160    ec.saveSettings();
    6261    message = "Settings updated";
  • trunk/www/admin/extensions/settings.jsp

    r5426 r5601  
    5050  ExtensionsControl ec = ExtensionsControl.get(dc);
    5151  ec.checkPermission(Permission.WRITE);
    52  
    53   int autoInstall = ec.getAutoInstall();
    5452  %>
    5553  <base:page type="popup" title="Extension settings">
     
    8078  <t:tab id="all" title="Settings" helpid="extensions.settings">
    8179    <table class="form" cellspacing=0>
    82     <tr>
    83       <td class="prompt">Auto-installation interval</td>
    84       <td>
    85         <input type="text" class="text" name="autoInstall"
    86           value="<%=autoInstall > 0 ? autoInstall : 0%>" > seconds<br> (0 = disabled)
    87       </td>
    88     </tr>
    8980    </table>
    9081  </t:tab>
    91  
    9282  </t:tabcontrol>
    9383
  • trunk/www/admin/extensions/tree.jsp

    r5599 r5601  
    3434  import="net.sf.basedb.util.extensions.Extension"
    3535  import="net.sf.basedb.util.extensions.Action"
     36  import="net.sf.basedb.util.extensions.manager.ExtensionsFile"
    3637  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
    37   import="net.sf.basedb.clients.web.extensions.ExtensionsFile"
    3838  import="net.sf.basedb.core.plugin.About"
    3939  import="java.util.List"
     
    4848  if (name == null) name = id;
    4949  String icon = ec.isEnabled(ep) ? "ExtensionPoint" : "ExtensionPointDisabled";
    50   ExtensionsFile f = ec.getFileByExtensionId(id);
    51   if ((f != null && f.hasError()) || ec.getLastExtensionPointError(id) != null)
     50  ExtensionsFile f = null; //ec.getFileByExtensionId(id);
     51  if ((f != null /*&& f.hasError()*/) || ec.getLastExtensionPointError(id) != null)
    5252  {
    5353    icon = "ExtensionPointError";
     
    6565  if (inGroup) name = ext.getId().substring(ext.getId().indexOf(":"));
    6666  String icon = ec.isEnabled(ext) ? "Extension" : "ExtensionDisabled";
    67   ExtensionsFile f = ec.getFileByExtensionId(id);
    68   if ((f != null && f.hasError()) || ec.getLastExtensionError(id) != null)
     67  ExtensionsFile f = null; //ec.getFileByExtensionId(id);
     68  if ((f != null /*&& f.hasError()*/) || ec.getLastExtensionError(id) != null)
    6969  {
    7070    icon = "ExtensionError";
     
    158158    var group;
    159159    <%
    160     Iterator<ExtensionsFile> files = ec.getFiles();
    161     while (files.hasNext())
    162     {
    163       ExtensionsFile ef = files.next();
     160    //Iterator<ExtensionsFile> files = ec.getFiles();
     161    for (ExtensionsFile ef : ec.getFiles())
     162    {
     163      //ExtensionsFile ef = files.next();
    164164      String efName = ef.getName();
    165165      String icon = ef.isJar() ? "JarFile" : "XmlFile";
    166       if (ef.hasError()) icon += "Error";
     166      //if (ef.hasError()) icon += "Error";
    167167      String id = efName;
    168168      %>
    169169      file = JoustMenu.addChildItem(byFile, '<%=icon%>', '<%=HTML.javaScriptEncode(efName)%>', 'fileOnClick("<%=efName%>")', '', '<%=id%>');
    170170      <%
     171      /*
    171172      Iterator<ExtensionPoint<?>> eps = ef.getExtensionPoints();
    172173      while (eps.hasNext())
     
    177178        <%
    178179      }
     180      */
     181      /*
    179182      Iterator<Extension<?>> exts = ef.getExtensions();
    180183      String currentGroupId = null;
     
    203206        <%
    204207      }
     208      */
    205209    }
    206210    %>
Note: See TracChangeset for help on using the changeset viewer.