Changeset 5613


Ignore:
Timestamp:
Apr 18, 2011, 1:41:18 PM (10 years ago)
Author:
Nicklas Nordborg
Message:

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

Changed jarPath property of PluginType to jarFile (same as has already been done for PluginDefintion).

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/net/sf/basedb/core/Install.java

    r5612 r5613  
    23272327    Create a {@link PluginType}.
    23282328  */
    2329   private static PluginTypeData createPluginType(String name, String description, String interfaceName, String jarPath)
     2329  private static PluginTypeData createPluginType(String name, String description, String interfaceName, String jarFile)
    23302330    throws BaseException
    23312331  {
     
    23542354        pluginType.setDescription(description);
    23552355        pluginType.setInterfaceName(interfaceName);
    2356         pluginType.setJarPath(jarPath);
     2356        pluginType.setJarFile(jarFile);
    23572357        HibernateUtil.saveData(session, pluginType);
    23582358        HibernateUtil.commit(tx);
  • trunk/src/core/net/sf/basedb/core/PluginDefinition.java

    r5610 r5613  
    130130    @param className The name of the class that implements the plugin
    131131      interface
    132     @param jarPath Optional path to the jar file which contains the
    133       plugin class, if missing the plugin must be in the classpath
     132    @param jarFile Optional file name of the JAR file which contains the
     133      plugin class. The JAR file must be located in the plugins.dir
     134      directory. If not specified the plugin must be in the classpath
    134135    @param useRequestedPermissions If the permissions that are returned
    135136      by the {@link Plugin#getPermissions()} method should be used or not.
     
    138139    @throws BaseException If there is an error
    139140  */
    140   public static PluginDefinition getNew(DbControl dc, String className, String jarPath,
     141  public static PluginDefinition getNew(DbControl dc, String className, String jarFile,
    141142    boolean useRequestedPermissions)
    142143    throws BaseException
    143144  {
    144145    PluginDefinition pd = dc.newItem(PluginDefinition.class);
    145     pd.loadPluginInformation(jarPath, className, useRequestedPermissions);
     146    pd.loadPluginInformation(jarFile, className, useRequestedPermissions);
    146147    pd.getData().setEntryDate(new Date());
    147148    return pd;
  • trunk/src/core/net/sf/basedb/core/PluginType.java

    r4889 r5613  
    6060    The maximum length of the jar path name that can be stored in the
    6161    database.
    62   */
    63   public static final int MAX_JARPATH_LENGTH = PluginTypeData.MAX_JARPATH_LENGTH;
     62    @since 3.0
     63  */
     64  public static final int MAX_JARFILE_LENGTH = PluginTypeData.MAX_JARFILE_LENGTH;
    6465
    6566  /**
     
    7071    @param interfaceName The name of an interface that a plugin
    7172      must implement to be of this type
    72     @param jarPath Optional path to the jar file which contains the
    73       interface class, if missing the interface must be in the classpath
     73    @param jarFile Optional file name of the JAR file which contains the
     74      plugin class. The JAR file must be located in the plugins.dir
     75      directory. If not specified the plugin must be in the classpath
    7476    @return The new <code>PluginDefinition</code> item
    7577    @throws BaseException If there is an error
    7678  */
    77   public static PluginType getNew(DbControl dc, String interfaceName, String jarPath)
     79  public static PluginType getNew(DbControl dc, String interfaceName, String jarFile)
    7880    throws BaseException
    7981  {
    8082    PluginType pt = dc.newItem(PluginType.class);
    8183    pt.setName(interfaceName);
    82     pt.loadInterfaceInformation(jarPath, interfaceName);
     84    pt.loadInterfaceInformation(jarFile, interfaceName);
    8385    pt.getData().setEntryDate(new Date());
    8486    return pt;
     
    249251
    250252  /**
     253    Get the name of the JAR file that contains this plug-in.
     254    If this value is null, the plug-in must be on the classpath
     255    (eg. in WEB-INF/lib).
     256    @since 3.0
     257  */
     258  public String getJarFile()
     259  {
     260    return getData().getJarFile();
     261  }
     262
     263  /**
    251264    Get the path to the JAR file that contains the plugin class file.
    252265    If this value is null, the plugin must be on the classpath.
     
    254267  public String getJarPath()
    255268  {
    256     return getData().getJarPath();
    257   }
     269    String file = getJarFile();
     270    if (file == null) return null;
     271    return new java.io.File(Application.getPluginsDirectory(), file).getAbsolutePath();
     272  }
     273
     274
    258275  /**
    259276    The jar path cannot be changed. Used internally only.
    260277  */
    261   private void setJarPath(String jarPath)
     278  private void setJarFile(String jarFile)
    262279    throws InvalidDataException
    263280  {
    264     getData().setJarPath(StringUtil.setNullableString(jarPath, "jarPath", MAX_JARPATH_LENGTH));
    265   }
    266  
    267   /**
    268     @param jarPath Path to the jar file where the interface is located.
    269       Null can be used only if the interface is located in the server's classpath.
     281    getData().setJarFile(StringUtil.setNullableString(jarFile, "jarFile", MAX_JARFILE_LENGTH));
     282  }
     283 
     284  /**
     285    @param jarFile File name of the jar file containing the plug-in. The
     286      JAR file must be located in the directory spercified by 'plugins.dir' setting
     287      in base.config. Null is allowed if plugin is located in the classpath (eg. WEB-INF/lib).
    270288    @param interfaceName The name of an interface that a plugin
    271289      must implement to be of this type.
     
    275293
    276294  */
    277   public void loadInterfaceInformation(String jarPath, String interfaceName)
     295  public void loadInterfaceInformation(String jarFile, String interfaceName)
    278296    throws InvalidDataException, BaseException
    279297  {
     298    checkPermission(Permission.WRITE);
     299    if (jarFile != null)
     300    {
     301      if (!Path.isValidName(jarFile))
     302      {
     303        throw new InvalidDataException("JAR file name is not a valid name: " + jarFile);
     304      }
     305    }
     306   
     307    String jarPath = jarFile == null ?
     308        null : new java.io.File(Application.getPluginsDirectory(), jarFile).getAbsolutePath();
    280309    try
    281310    {
     
    300329      }
    301330      setInterfaceName(interfaceName);
    302       setJarPath(jarPath);
     331      setJarFile(jarFile);
    303332    }
    304333    catch (Exception ex)
  • trunk/src/core/net/sf/basedb/core/data/PluginTypeData.java

    r4889 r5613  
    116116  }
    117117
    118   public static final int MAX_JARPATH_LENGTH = 65535;
    119   private String jarPath;
     118  public static final int MAX_JARFILE_LENGTH = 255;
     119  private String jarFile;
    120120  /**
    121     Get the path to the JAR file where the interface class is located. If the
    122     value is null the interface must be in the classpath.
    123     @hibernate.property column="`jar_path`" type="text" not-null="false"
     121    Get the file name of the JAR file where the plugin class is located.
     122    The JAR file must be located in the 'plugins.dir' folder specified
     123    in base.config. If the value is null the plugin must be in the
     124    classpath (eg. WEB-INF/lib).
     125    @return The class name for this plugin
     126    @hibernate.property column="`jar_file`" type="string" length="255" not-null="false"
     127    @since 3.0
    124128  */
    125   public String getJarPath()
     129  public String getJarFile()
    126130  {
    127     return jarPath;
     131    return jarFile;
    128132  }
    129   public void setJarPath(String jarPath)
     133  public void setJarFile(String jarFile)
    130134  {
    131     this.jarPath = jarPath;
     135    this.jarFile = jarFile;
    132136  }
    133137 
  • trunk/www/admin/plugintypes/edit_plugintype.jsp

    r5508 r5613  
    153153      <tr>
    154154        <td class="prompt">Jar path</td>
    155         <td><input <%=clazz%> type="text" name="jarPath"
    156           value="<%=HTML.encodeTags(pluginType == null ? cc.getPropertyValue("jarPath") : pluginType.getJarPath())%>"
    157           size="60" maxlength="<%=PluginType.MAX_JARPATH_LENGTH%>"></td>
     155        <td><input <%=clazz%> type="text" name="jarFile"
     156          value="<%=HTML.encodeTags(pluginType == null ? cc.getPropertyValue("jarFile") : pluginType.getJarFile())%>"
     157          size="60" maxlength="<%=PluginType.MAX_JARFILE_LENGTH%>"></td>
    158158      </tr>
    159159      <tr valign=top>
  • trunk/www/admin/plugintypes/index.jsp

    r5590 r5613  
    154154    PluginType pluginType = (PluginType)cc.getObject("item");
    155155    String interfaceName = Values.getStringOrNull(request.getParameter("interfaceName"));
    156     String jarPath = Values.getStringOrNull(request.getParameter("jarPath"));
     156    String jarFile = Values.getStringOrNull(request.getParameter("jarFile"));
    157157    if (pluginType == null)
    158158    {
    159       pluginType = PluginType.getNew(dc, interfaceName, jarPath);
     159      pluginType = PluginType.getNew(dc, interfaceName, jarFile);
    160160      message = "Plugin type created";
    161161      dc.saveItem(pluginType);
     
    164164    {
    165165      dc.reattachItem(pluginType, false);
    166       pluginType.loadInterfaceInformation(jarPath, interfaceName);
     166      pluginType.loadInterfaceInformation(jarFile, interfaceName);
    167167      message = "Plugin type updated";
    168168    }
  • trunk/www/admin/plugintypes/list_plugintypes.jsp

    r5610 r5613  
    247247      />
    248248      <tbl:columndef
    249         id="jarPath"
    250         property="jarPath"
     249        id="jarFile"
     250        property="jarFile"
    251251        datatype="string"
    252         title="Jar path"
     252        title="JAR file"
    253253        sortable="true"
    254254        filterable="true"
     
    420420                <tbl:cell column="entryDate" value="<%=item.getEntryDate()%>" />
    421421                <tbl:cell column="interfaceName"><%=item.getInterfaceName()%></tbl:cell>
    422                 <tbl:cell column="jarPath"><%=Values.getString(item.getJarPath(), "<i>-&nbsp;internal&nbsp;-</i>")%></tbl:cell>
     422                <tbl:cell column="jarPath"><%=Values.getString(item.getJarFile(), "<i>-&nbsp;internal&nbsp;-</i>")%></tbl:cell>
    423423                <tbl:cell column="plugins">
    424424                  <%
  • trunk/www/admin/plugintypes/view_plugintype.jsp

    r5610 r5613  
    221221      </tr>
    222222      <tr>
    223         <td class="prompt">Jar path</td>
    224         <td><%=Values.getString(pluginType.getJarPath(), "<i>- internal -</i>")%></td>
     223        <td class="prompt">JAR file</td>
     224        <td><%=Values.getString(pluginType.getJarFile(), "<i>- internal -</i>")%></td>
    225225      </tr>
    226226      <tr>
Note: See TracChangeset for help on using the changeset viewer.