Changeset 4112
- Timestamp:
- Jan 31, 2008, 10:44:29 AM (15 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/src/docbook/appendix/incompatible.xml
r4093 r4112 82 82 </listitem> 83 83 </itemizedlist> 84 85 <bridgehead>Data file types</bridgehead> 86 <para> 87 The <methodname>DataFileType.setValidatorClass()</methodname> and 88 <methodname>DataFileType.setMetadataReaderClass()</methodname> no longer 89 verifies that the specified class names exists and implements the required interfaces. 90 This validation will instead happen at commit time. The reason for this change is 91 the added support for having the validator/meta data reader in external JAR files. 92 This means that the validation can't happen until both the class names and JAR paths 93 has been set. If a client application need validation before commit time it should use 94 <methodname>DataFileType.getValidator()</methodname> and 95 <methodname>DataFileType.getMetadataReader()</methodname> after the class names and JAR 96 paths has been set. 97 </para> 84 98 85 99 </sect1> -
trunk/doc/src/docbook/developerdoc/plugin_developer.xml
r4093 r4112 4148 4148 (ie. they don't have to implement the <interfacename docapi="net.sf.basedb.core.plugin">Plugin</interfacename> 4149 4149 interface). This means that you don't have to mess with configuration or 4150 job parameters. Another difference is that the plug-ins must be installed in 4151 Tomcat's classpath (ie. in one of the 4152 <filename>WEB-INF/classes</filename> or <filename>WEB-INF/lib</filename> 4153 folders). 4150 job parameters. 4154 4151 </para> 4155 4152 -
trunk/src/core/net/sf/basedb/core/DataFileType.java
r4017 r4112 35 35 import net.sf.basedb.info.ToTransferable; 36 36 import net.sf.basedb.util.ClassUtil; 37 import net.sf.basedb.util.JarClassLoader; 37 38 38 39 /** … … 50 51 public class DataFileType 51 52 extends BasicItem<DataFileTypeData> 52 implements Nameable, Removable, ToTransferable<DataFileTypeInfo> 53 implements Nameable, Removable, ToTransferable<DataFileTypeInfo>, Validatable 53 54 { 54 55 … … 103 104 public static final int MAX_CLASSNAME_LENGTH = DataFileTypeData.MAX_CLASSNAME_LENGTH; 104 105 106 /** 107 The maximum length of the jar paths that can be stored in the database. 108 @see #setValidatorJarPath(String) 109 @see #setMetadataReaderJarPath(String) 110 */ 111 public static final int MAX_JARPATH_LENGTH = DataFileTypeData.MAX_JARPATH_LENGTH; 112 105 113 /** 106 114 Create a new data file type. … … 363 371 } 364 372 373 374 375 /** 376 Check that the validator and meta data reader classes implement the 377 correct interfaces. 378 @since 2.6 379 */ 380 @Override 381 void validate() 382 throws InvalidDataException, BaseException 383 { 384 super.validate(); 385 getValidator(); 386 getMetadataReader(); 387 } 388 365 389 /** 366 390 @since 2.5 … … 479 503 have write permission 480 504 @throws StringTooLongException If the string is longer that {@link #MAX_CLASSNAME_LENGTH}. 481 @throws InvalidDataException If the named class isn't found or482 doesn't implement the <code>DataFileValidator</code> interface.483 505 */ 484 506 public void setValidatorClass(String validatorClass) 485 507 { 486 508 checkPermission(Permission.WRITE); 487 if (validatorClass != null) 488 { 489 try 490 { 491 ClassUtil.checkAndLoadClass(null, validatorClass, true, DataFileValidator.class); 492 } 493 catch (Throwable t) 494 { 495 throw new InvalidDataException(t); 496 } 497 } 498 getData().setValidatorClass(StringUtil.setNullableString(validatorClass, "validatorClass", MAX_EXTENSION_LENGTH)); 499 } 509 getData().setValidatorClass(StringUtil.setNullableString(validatorClass, 510 "validatorClass", MAX_CLASSNAME_LENGTH)); 511 } 512 513 /** 514 Get the path to the JAR file where the validator class is located. If the 515 path is null the validator must be in the class path. 516 @return The JAR path or null 517 @since 2.6 518 */ 519 public String getValidatorJarPath() 520 { 521 return getData().getValidatorJarPath(); 522 } 523 524 /** 525 Set the path to the JAR file where the validator class is located. 526 @param validatorJarPath The path to the JAR file or null if the validator is in the class path 527 @throws PermissionDeniedException If the logged in user doesn't 528 have write permission 529 @throws StringTooLongException If the string is longer that {@link #MAX_JARPATH_LENGTH}. 530 @since 2.6 531 */ 532 public void setValidatorJarPath(String validatorJarPath) 533 { 534 checkPermission(Permission.WRITE); 535 getData().setValidatorJarPath(StringUtil.setNullableString(validatorJarPath, 536 "validatorJarPath", MAX_JARPATH_LENGTH)); 537 } 538 500 539 501 540 /** … … 512 551 try 513 552 { 553 String jarPath = getValidatorJarPath(); 554 ClassLoader loader = jarPath == null ? null :JarClassLoader.getInstance(jarPath); 514 555 validator = (DataFileValidator)ClassUtil.checkAndLoadClass( 515 null, validatorClass, true, DataFileValidator.class).newInstance();556 loader, validatorClass, true, DataFileValidator.class).newInstance(); 516 557 } 517 558 catch (Throwable t) … … 539 580 have write permission 540 581 @throws StringTooLongException If the string is longer that {@link #MAX_CLASSNAME_LENGTH}. 541 @throws InvalidDataException If the named class isn't found or doesn't542 implement the <code>DataFileMetadataReader</code> interface543 582 */ 544 583 public void setMetadataReaderClass(String metadataReaderClass) 545 584 { 546 585 checkPermission(Permission.WRITE); 547 if (metadataReaderClass != null)548 {549 try550 {551 ClassUtil.checkAndLoadClass(null, metadataReaderClass, true, DataFileMetadataReader.class);552 }553 catch (Throwable t)554 {555 throw new InvalidDataException(t);556 }557 }558 586 getData().setMetadataReaderClass(StringUtil.setNullableString(metadataReaderClass, 559 "metadataReaderClass", MAX_EXTENSION_LENGTH)); 560 } 587 "metadataReaderClass", MAX_CLASSNAME_LENGTH)); 588 } 589 590 /** 591 Get the path to the JAR file where the meta data reader class is located. If the 592 path is null the reader must be in the class path. 593 @return The JAR path or null 594 @since 2.6 595 */ 596 public String getMetadataReaderJarPath() 597 { 598 return getData().getMetadataReaderJarPath(); 599 } 600 601 /** 602 Set the path to the JAR file where the meta data reader class is located. 603 @param metadataReaderJarPath The path to the JAR file or null if the reader is in the class path 604 @throws PermissionDeniedException If the logged in user doesn't 605 have write permission 606 @throws StringTooLongException If the string is longer that {@link #MAX_JARPATH_LENGTH}. 607 @since 2.6 608 */ 609 public void setMetadataReaderJarPath(String metadataReaderJarPath) 610 { 611 checkPermission(Permission.WRITE); 612 getData().setMetadataReaderJarPath(StringUtil.setNullableString(metadataReaderJarPath, 613 "metadataReaderJarPath", MAX_JARPATH_LENGTH)); 614 } 561 615 562 616 /** … … 573 627 try 574 628 { 629 String jarPath = getValidatorJarPath(); 630 ClassLoader loader = jarPath == null ? null : JarClassLoader.getInstance(jarPath); 575 631 reader = (DataFileMetadataReader)ClassUtil.checkAndLoadClass( 576 null, readerClass, true, DataFileMetadataReader.class).newInstance();632 loader, readerClass, true, DataFileMetadataReader.class).newInstance(); 577 633 } 578 634 catch (Throwable t) -
trunk/src/core/net/sf/basedb/core/Install.java
r4105 r4112 107 107 method. 108 108 */ 109 public static final int NEW_SCHEMA_VERSION = Integer.valueOf( 49).intValue();109 public static final int NEW_SCHEMA_VERSION = Integer.valueOf(50).intValue(); 110 110 111 111 public static synchronized void createTables(boolean update, final ProgressReporter progress) -
trunk/src/core/net/sf/basedb/core/Update.java
r4082 r4112 574 574 </td> 575 575 </tr> 576 <tr> 577 <td>50</td> 578 <td> 579 <ul> 580 <li>Added {@link net.sf.basedb.core.data.DataFileTypeData#getValidatorJarPath()} 581 <li>Added {@link net.sf.basedb.core.data.DataFileTypeData#getMetadataReaderJarPath()} 582 </ul> 583 No special database update is needed. Only increase the schema version. 584 </td> 585 </tr> 576 586 577 587 </table> … … 814 824 } 815 825 826 if (schemaVersion < 50) 827 { 828 if (progress != null) progress.display((int)(49*progress_factor), "Updating schema version: " + schemaVersion + " -> 50..."); 829 schemaVersion = setSchemaVersionInTransaction(session, 50); 830 } 816 831 817 832 sc.logout(); -
trunk/src/core/net/sf/basedb/core/data/DataFileTypeData.java
r3948 r4112 147 147 } 148 148 149 public static final int MAX_JARPATH_LENGTH = 65535; 150 private String validatorJarPath; 151 /** 152 Get the path to the JAR file where the validator class is located. If the 153 value is null the value must be in the classpath. 154 @return The path to the JAR file 155 @hibernate.property column="`validator_jarpath`" type="text" not-null="false" 156 @since 2.6 157 */ 158 public String getValidatorJarPath() 159 { 160 return validatorJarPath; 161 } 162 public void setValidatorJarPath(String validatorJarPath) 163 { 164 this.validatorJarPath = validatorJarPath; 165 } 166 167 149 168 private String metadataReaderClass; 150 169 /** … … 161 180 { 162 181 this.metadataReaderClass = metadataReaderClass; 182 } 183 184 private String metadataReaderJarPath; 185 /** 186 Get the path to the JAR file where the validator class is located. If the 187 value is null the value must be in the classpath. 188 @return The path to the JAR file 189 @hibernate.property column="`extractor_jarpath`" type="text" not-null="false" 190 @since 2.6 191 */ 192 public String getMetadataReaderJarPath() 193 { 194 return metadataReaderJarPath; 195 } 196 public void setMetadataReaderJarPath(String metadataReaderJarPath) 197 { 198 this.metadataReaderJarPath = metadataReaderJarPath; 163 199 } 164 200
Note: See TracChangeset
for help on using the changeset viewer.