Changeset 5600


Ignore:
Timestamp:
Apr 1, 2011, 8:17:18 AM (10 years ago)
Author:
Nicklas Nordborg
Message:

References #1593: Extension system for the core API

Now scan the plugins directory for extensions at startup.

Location:
trunk/src/core
Files:
1 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/core-extensions.xml

    r5599 r5600  
    6868      </description>
    6969    </about>
     70    <index>1</index>
    7071    <action-factory>
    7172      <factory-class>net.sf.basedb.util.uri.http.HttpConnectionManagerActionFactory</factory-class>
  • trunk/src/core/net/sf/basedb/core/Application.java

    r5599 r5600  
    541541       
    542542        // Add plugins directory to the manager
    543         //xtManager.addDirectory(pluginsDirectory);
     543        xtManager.addDirectory(pluginsDirectory);
    544544       
    545545        // Register and load core extensions
  • trunk/src/core/net/sf/basedb/util/extensions/manager/ExtensionsFile.java

    r5598 r5600  
    5151 */
    5252public class ExtensionsFile
     53  implements Comparable<ExtensionsFile>
    5354{
    5455  private static final org.apache.log4j.Logger log =
     
    107108    this.isJar = false;
    108109    this.uri = uri;
    109     this.name = uri.getPath();
    110   }
     110    this.name = uri.toString().replaceFirst(".*/", "");
     111  }
     112 
     113  /*
     114    From the Comparable interface
     115    -----------------------------
     116  */
     117  @Override
     118  public int compareTo(ExtensionsFile other)
     119  {
     120    // Compare by name and then by URI
     121    int n = this.name.compareTo(other.name);
     122    return n == 0 ? this.uri.compareTo(other.uri) : n;
     123  }
     124  // ------------------------------
     125  /*
     126    From the Object class
     127    ---------------------
     128  */
     129  @Override
     130  public int hashCode()
     131  {
     132    return uri.hashCode();
     133  }
     134  @Override
     135  public boolean equals(Object o)
     136  {
     137    if (this == o) return true;
     138    if (o == null || this.getClass() != o.getClass()) return false;
     139    ExtensionsFile other = (ExtensionsFile)o;
     140    return this.uri.equals(other.uri);
     141  }
     142  @Override
     143  public String toString()
     144  {
     145    return "ExtensionsFile@" + System.identityHashCode(this) + "[" + uri + "]";
     146  }
     147  // ------------------------------
    111148 
    112149  /**
     
    263300 
    264301  public ClassLoader getClassLoader()
    265   {
     302    throws IOException
     303  {
     304    if (jarLoader == null && isJar())
     305    {
     306      jarLoader = (JarClassLoader)JarClassLoader.getInstance(getFile().getAbsolutePath());
     307    }
    266308    return jarLoader;
    267309  }
  • trunk/src/core/net/sf/basedb/util/extensions/manager/ExtensionsManager.java

    r5598 r5600  
    118118    for (File file : dir.listFiles(filter))
    119119    {
    120       //addFile(file);
     120      addExtensionsFile(new ExtensionsFile(file));
    121121    }
    122122
Note: See TracChangeset for help on using the changeset viewer.