Changeset 6602


Ignore:
Timestamp:
Nov 17, 2014, 10:45:49 AM (8 years ago)
Author:
Nicklas Nordborg
Message:

References #1889: Allow extensions to be installed in disabled state

Existing extensions was not properly detected, resulting in updated extensions was installed as new and the "disabled" state was reset.

Location:
trunk/src/core/net/sf/basedb/util/extensions
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/net/sf/basedb/util/extensions/Registry.java

    r6497 r6602  
    9494    };
    9595
    96    
     96  /**
     97    Comparator that sort extensions according to their ids.
     98    @since 3.4
     99  */
     100  public static final Comparator<ExtensionPoint> EXTENSIONPOINT_ID_COMPARATOR =
     101    new Comparator<ExtensionPoint>()
     102    {
     103      @Override
     104      public int compare(ExtensionPoint o1, ExtensionPoint o2)
     105      {
     106        return o1.getId().compareTo(o2.getId());
     107      }
     108    };
     109
     110   
     111  /**
     112    Comparator that sort extensions according to their ids.
     113    @since 3.4
     114  */
     115  public static final Comparator<Extension> EXTENSION_ID_COMPARATOR =
     116    new Comparator<Extension>()
     117    {
     118      @Override
     119      public int compare(Extension o1, Extension o2)
     120      {
     121        return o1.getId().compareTo(o2.getId());
     122      }
     123    };
     124
    97125  private final Map<String, RegisteredExtensionPoint<?>> extensionPoints;
    98126  private final Map<String, RegisteredExtension<?>> extensions;
  • trunk/src/core/net/sf/basedb/util/extensions/manager/processor/RegisterExtensionsProcessor.java

    r6595 r6602  
    130130      data.extensionPoints = new ArrayList<ExtensionPoint<?>>(loader.getExtensionPoints());
    131131      data.extensions = new ArrayList<Extension<?>>(loader.getExtensions());
     132      Collections.sort(data.extensionPoints, Registry.EXTENSIONPOINT_ID_COMPARATOR);
     133      Collections.sort(data.extensions, Registry.EXTENSION_ID_COMPARATOR);
    132134      numFiles++;
    133135      log.info("Loaded " + data.extensionPoints.size() + "/" + data.extensions.size() +
     
    440442    ExtensionPointKey key = new ExtensionPointKey(ep);
    441443    data.writeableFile.unregisterObject(key);
    442     if (!data.extensionPoints.contains(ep))
     444    if (Collections.binarySearch(data.extensionPoints, ep, Registry.EXTENSIONPOINT_ID_COMPARATOR) < 0)
    443445    {
    444446      registry.unregisterExtensionPoint(ep.getId());
     
    498500    ExtensionKey key = new ExtensionKey(ext);
    499501    data.writeableFile.unregisterObject(key);
    500     if (!data.extensions.contains(ext))
     502    if (Collections.binarySearch(data.extensions, ext, Registry.EXTENSION_ID_COMPARATOR) < 0)
    501503    {
    502504      registry.unregisterExtension(ext.getId());
Note: See TracChangeset for help on using the changeset viewer.