Changeset 5607
- Timestamp:
- Apr 15, 2011, 9:52:28 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/build.xml
r5591 r5607 60 60 <!-- set BASE version 61 61 Use numerical versions for bugfix (maintenance) releases starting 62 with "1". Use "0" for the first release of a new trunk version. Add63 " pre" to unreleased versions. Examples: 2.1.1pre, 2.1.1,64 2.1.2 pre, 2.2.2, 2.2.0pre, 2.2.0, 2.2.1pre, 2.2.162 with "1". Use "0" for the first release of a new trunk version. Set 63 "base.versionsuffix" to "-dev" for unreleased versions. Examples: 2.1.1-dev, 2.1.1, 64 2.1.2-dev, 2.2.2, 2.2.0-dev, 2.2.0, 2.2.1-dev, 2.2.1 65 65 --> 66 66 <property name="base.majorversion" value="3" /> 67 67 <property name="base.minorversion" value="0" /> 68 <property name="base.maintenanceversion" value="0pre" /> 68 <property name="base.maintenanceversion" value="0" /> 69 <property name="base.versionsuffix" value="-dev" /> 69 70 <property name="base.version" 70 71 value="${base.majorversion}.${base.minorversion}.${base.maintenanceversion}" /> … … 493 494 token="@BUILD@" 494 495 value="${base.build}" 496 /> 497 <replacefilter 498 token="@SUFFIX@" 499 value="${base.versionsuffix}" 495 500 /> 496 501 </replace> … … 1164 1169 use="false" 1165 1170 private="true" 1166 windowtitle="BASE ${base.version} API documentation"1171 windowtitle="BASE ${base.version}${base.versionsuffix} API documentation" 1167 1172 stylesheetfile="${javadoc.src}/javadoc.css" 1168 1173 classpathref="javadoc.classpath" … … 1205 1210 </group> 1206 1211 1207 <header><![CDATA[${base.version} : ${TODAY}]]></header>1212 <header><![CDATA[${base.version}${base.versionsuffix}: ${TODAY}]]></header> 1208 1213 <link href="http://download.oracle.com/javase/6/docs/api"/> 1209 1214 <link href="http://docs.jboss.org/hibernate/stable/core/api/"/> … … 1315 1320 <property name="distribution.dir" location="${docbook.html.out}" /> 1316 1321 <property name="build.dir" location="${build}/docbook/html" /> 1317 <property name="base.version" value="${base.version} "/>1322 <property name="base.version" value="${base.version}${base.versionsuffix}"/> 1318 1323 </ant> 1319 1324 <copy todir="${docbook.html.out}"> … … 1369 1374 <property name="build.dir" location="${build}/docbook/pdf" /> 1370 1375 <property name="pdf.name" value="base.pdf" /> 1371 <property name="base.version" value="${base.version} "/>1376 <property name="base.version" value="${base.version}${base.versionsuffix}"/> 1372 1377 </ant> 1373 1378 </target> -
trunk/src/clients/web/net/sf/basedb/clients/web/extensions/ExtensionsControl.java
r5606 r5607 184 184 private static ProcessResults scan(boolean initialScan, boolean forceUpdate) 185 185 { 186 log.info("Starting scan: intial=" + initialScan + "; forceUpdate="+forceUpdate); 186 187 String rootPath = servletContext.getContextPath(); 187 188 File resourceDir = new File(servletContext.getRealPath(RESOURCES_URL)); … … 203 204 if (!initialScan) 204 205 { 206 log.debug("Checking for deleted files"); 205 207 // 1. Process files that has been deleted 206 208 DeletedFilter deleted = new DeletedFilter(); … … 214 216 manager.processFiles(unregister, deleted); 215 217 numUnregistered = unregister.getNumUnregistered(); 218 219 log.debug("Processed " + unregister.getNumFiles() + " deleted files"); 216 220 } 217 221 222 log.debug("Checking for new and updated files"); 218 223 // 2. Update the manager with new and modified files 219 224 manager.scanForNewAndUpdated(); … … 221 226 numModifiedFiles = manager.getNumModified(); 222 227 numDeletedFiles = manager.getNumDeleted(); 228 log.debug("Found " + numNewFiles + " new and " + numModifiedFiles + " modified files"); 223 229 224 230 if (initialScan || numNewFiles > 0 || numModifiedFiles > 0 || forceUpdate) 225 231 { 226 // Process files that are valid and new/updated (unless forceUpdate=true)232 // 3. Process files that are valid and new/updated (unless forceUpdate=true) 227 233 ValidAndNewOrModifiedFilter valid = new ValidAndNewOrModifiedFilter(initialScan || forceUpdate); 228 234 229 // 3 . Load extension definitions235 // 3a. Load extension definitions 230 236 WebClientRegisterExtensionsProcessor registerExtensions = 231 237 new WebClientRegisterExtensionsProcessor(rootPath, rootPath + RESOURCES_URL, rootPath + SERVLET_URL, results); … … 238 244 manager.processFiles(registerExtensions, valid); 239 245 240 // 4. Extract web resources246 // 3b. Extract web resources 241 247 ExtractResourcesProcessor extractResources = new ExtractResourcesProcessor(resourceDir, Pattern.compile("resources/(.*)"), "$1", results); 242 248 extractResources.setForceOverwrite(forceUpdate); 243 249 manager.processFiles(extractResources, valid); 244 250 245 // 5. Servlets251 // 3c. Servlets 246 252 LoadServletsProcessor loadServlets = new LoadServletsProcessor(servletContext, results); 247 253 manager.processFiles(loadServlets, valid); 248 254 249 // 6. Actual registration of all extensions255 // 3d. Actual registration of all extensions 250 256 registerExtensions.finalizeRegistration(manager); 251 257 numRegistered = registerExtensions.getNumRegistered(); 252 258 } 253 259 254 // Reset the 'last modifed' status of all files and generated summary per file260 // 4. Reset the 'last modifed' status of all files and generated summary per file 255 261 manager.processFiles(new SetFileStatusProcessor(results)); 256 262 results.setEnded(); … … 468 474 @throws PermissionDeniedException If the logged in user doesn't 469 475 have WRITE permission 476 @since 3.0 470 477 */ 471 478 public ProcessResults installAndUpdateExtensions(boolean forceUpdate) … … 479 486 @return A {@link ProcessResults} object, or null if no scan 480 487 has taken place 488 @since 3.0 481 489 */ 482 490 public ProcessResults getLastScanResults() … … 495 503 496 504 /** 497 Get an iteratorreturning all registered extension points.505 Get an list returning all registered extension points. 498 506 @see Registry#getExtensionPoints() 507 @since 3.0 (Returned an Iterator in BASE 2.x) 499 508 */ 500 509 public List<ExtensionPoint<?>> getExtensionPoints() … … 560 569 561 570 /** 562 Get a n iteratorreturning all registered extensions.571 Get a list returning all registered extensions. 563 572 @see Registry#getExtensions() 573 @since 3.0 (Returned an Iterator in BASE 2.x) 564 574 */ 565 575 public List<Extension<?>> getExtensions() … … 569 579 570 580 /** 571 Get a n iteratorreturning all registered extensions for a581 Get a list returning all registered extensions for a 572 582 specific extension point. 573 583 @param id The ID of the extension point 574 584 @see Registry#getExtensions(String) 585 @since 3.0 (Returned an Iterator in BASE 2.x) 575 586 */ 576 587 public List<Extension<?>> getExtensions(String id) -
trunk/src/clients/web/net/sf/basedb/clients/web/taglib/Page.java
r5384 r5607 25 25 import net.sf.basedb.core.Application; 26 26 import net.sf.basedb.core.SessionControl; 27 import net.sf.basedb.core.Version; 27 28 import net.sf.basedb.clients.web.Base; 28 29 import net.sf.basedb.util.Values; … … 183 184 MAX_URL_LENGTH = maxUrlLength > 0 ? String.valueOf(maxUrlLength) : null; 184 185 ROOT = ((HttpServletRequest)pageContext.getRequest()).getContextPath()+"/"; 185 BASE_VERSION = "BASE " + Application.getMajorVersion() + "." + 186 Application.getMinorVersion() + "." + 187 Application.getMaintenanceVersion(); 186 BASE_VERSION = "BASE " + Version.getMajor() + "." + 187 Version.getMinor() + "." + Version.getMaintenance() + Version.getSuffix(); 188 188 SERVER_NAME = Application.getHostName(); 189 189 initialized = true; -
trunk/src/core/base.version
r2960 r5607 3 3 maintenance: @MAINTENANCE@ 4 4 build: @BUILD@ 5 suffix: @SUFFIX@ -
trunk/src/core/net/sf/basedb/core/Application.java
r5606 r5607 37 37 import net.sf.basedb.util.extensions.manager.ExtensionsManager; 38 38 import net.sf.basedb.util.extensions.manager.ProcessResults; 39 import net.sf.basedb.util.extensions.manager.filter.ValidAndNewOrModifiedFilter; 39 40 import net.sf.basedb.util.extensions.manager.filter.WasProcessedFilter; 40 41 import net.sf.basedb.util.extensions.manager.processor.MarkAsProcessedProcessor; … … 208 209 /** 209 210 Get the major version. 210 */ 211 public static String getMajorVersion() 211 @since 3.0 (was returning a String in 2.x) 212 */ 213 public static int getMajorVersion() 212 214 { 213 215 return Version.getMajor(); … … 216 218 /** 217 219 Get the minor version. 218 */ 219 public static String getMinorVersion() 220 @since 3.0 (was returning a String in 2.x) 221 */ 222 public static int getMinorVersion() 220 223 { 221 224 return Version.getMinor(); … … 225 228 /** 226 229 Get the maintenance version. 227 */ 228 public static String getMaintenanceVersion() 230 @since 3.0 (was returning a String in 2.x) 231 */ 232 public static int getMaintenanceVersion() 229 233 { 230 234 return Version.getMaintenance(); … … 239 243 } 240 244 245 /** 246 Get the version suffix (eg. "-dev"). 247 @since 3.0 248 */ 249 public String getVersionSuffix() 250 { 251 return Version.getSuffix(); 252 } 253 241 254 /** 242 255 Get the BASE version string. It is created by combining … … 245 258 public static String getVersionString() 246 259 { 247 return "BASE " + getMajorVersion() + "." + getMinorVersion() +248 "." + getMaintenanceVersion() + " (build #" +getBuild() +260 return "BASE " + Version.getMajor() + "." + Version.getMinor() + 261 "." + Version.getMaintenance() + Version.getSuffix() + " (build #" + Version.getBuild() + 249 262 "; schema #" + Application.getSchemaVersion()+")"; 250 263 } 251 264 265 private static int schemaVersion = -2; 252 266 /** 253 267 Get the current database schema version number. … … 259 273 org.hibernate.Session session = null; 260 274 org.hibernate.Transaction tx = null; 261 int schemaVersion = -2; 262 try 263 { 264 session = HibernateUtil.newSession(); 265 schemaVersion++; 266 tx = HibernateUtil.newTransaction(session); 267 org.hibernate.Query query = HibernateUtil.getPredefinedQuery(session, "GET_SCHEMA_VERSION"); 268 schemaVersion = HibernateUtil.loadData(SchemaVersionData.class, query).getSchemaVersion(); 269 HibernateUtil.commit(tx); 270 } 271 catch (Throwable t) 272 { 273 if (tx != null) HibernateUtil.rollback(tx); 274 log.error("getSchemaVersion", t); 275 } 276 finally 277 { 278 if (session != null) HibernateUtil.close(session); 275 if (schemaVersion > 0) return schemaVersion; 276 277 synchronized (Application.class) 278 { 279 schemaVersion = -2; 280 try 281 { 282 session = HibernateUtil.newSession(); 283 schemaVersion++; 284 tx = HibernateUtil.newTransaction(session); 285 org.hibernate.Query query = HibernateUtil.getPredefinedQuery(session, "GET_SCHEMA_VERSION"); 286 schemaVersion = HibernateUtil.loadData(SchemaVersionData.class, query).getSchemaVersion(); 287 HibernateUtil.commit(tx); 288 } 289 catch (Throwable t) 290 { 291 if (tx != null) HibernateUtil.rollback(tx); 292 log.error("getSchemaVersion", t); 293 } 294 finally 295 { 296 if (session != null) HibernateUtil.close(session); 297 } 279 298 } 280 299 return schemaVersion; … … 550 569 // Filter that only load core extension points 551 570 loader.setFilter(new ExtensionPointFilter("net\\.sf\\.basedb\\.core\\..*")); 552 xtManager.processFiles(new RegisterExtensionsProcessor(loader, results) );571 xtManager.processFiles(new RegisterExtensionsProcessor(loader, results), new ValidAndNewOrModifiedFilter(false)); 553 572 xtManager.processFiles(new MarkAsProcessedProcessor(), new WasProcessedFilter(results)); 554 573 -
trunk/src/core/net/sf/basedb/core/Version.java
r5384 r5607 31 31 32 32 import net.sf.basedb.util.FileUtil; 33 import net.sf.basedb.util.Values; 33 34 34 35 /** … … 43 44 public class Version 44 45 { 45 private static Stringmajor;46 private static Stringminor;47 private static Stringmaintenance;46 private static int major; 47 private static int minor; 48 private static int maintenance; 48 49 private static int build; 50 private static String suffix; 49 51 50 52 static … … 72 74 Properties config = new Properties(); 73 75 config.load(is); 74 major = config.getProperty("major");75 minor = config.getProperty("minor");76 maintenance = config.getProperty("maintenance");76 major = Values.getInt(config.getProperty("major")); 77 minor = Values.getInt(config.getProperty("minor")); 78 maintenance = Values.getInt(config.getProperty("maintenance")); 77 79 build = parseBuildNumber(config.getProperty("build")); 80 suffix = config.getProperty("suffix", ""); 78 81 } 79 82 catch (IOException ex) … … 89 92 /** 90 93 Get the major version. 94 @since 3.0 (was returning a String in 2.x) 91 95 */ 92 public static StringgetMajor()96 public static int getMajor() 93 97 { 94 98 return major; … … 97 101 /** 98 102 Get the minor version. 103 @since 3.0 (was returning a String in 2.x) 99 104 */ 100 public static StringgetMinor()105 public static int getMinor() 101 106 { 102 107 return minor; … … 104 109 /** 105 110 Get the maintentance version. 111 @since 3.0 (was returning a String in 2.x) 106 112 */ 107 public static StringgetMaintenance()113 public static int getMaintenance() 108 114 { 109 115 return maintenance; … … 118 124 } 119 125 126 /** 127 Get the version suffix string (eg "-dev" for development versions) 128 @since 3.0 129 */ 130 public static String getSuffix() 131 { 132 return suffix; 133 } 134 120 135 public static String getVersion() 121 136 { 122 return major+"."+minor+"."+maintenance + "(build " + build + ")";137 return major+"."+minor+"."+maintenance + suffix + "(build " + build + ")"; 123 138 } 124 139 140 /** 141 Compare the given version string, which should be of the 142 form a.b or a.b.c, with the current BASE version. 143 If they are exactly equal 0 is returned. 144 If the given string is less than the current version 145 -1 is returned, if the given string is greater than 146 the current version +1 is returned. 147 148 @param version 149 @return 0, -1 or +1 150 @since 3.0 151 @throws InvalidDataException If the given string isn't correctly formatted 152 */ 153 public static int compareWith(String version) 154 { 155 if (version == null) throw new NullPointerException("version"); 156 Pattern p = Pattern.compile("(\\d+)\\.(\\d+)\\.?(\\d*)"); 157 Matcher m = p.matcher(version); 158 if (!m.matches()) 159 { 160 throw new InvalidDataException("Version is not correctly formatted: " + version); 161 } 162 163 // Major and minor as a first step 164 int vMajor = Values.getInt(m.group(1)); 165 int vMinor = Values.getInt(m.group(2)); 166 if (vMajor != major) return vMajor < major ? -1 : 1; 167 if (vMinor != minor) return vMinor < minor ? -1 : 1; 168 169 // Need to check maintenance as well (if given) 170 if (m.groupCount() > 2) 171 { 172 int vMaintenance = Values.getInt(m.group(3)); 173 if (vMaintenance != maintenance) return vMaintenance < maintenance ? -1 : 1; 174 } 175 return 0; 176 } 177 125 178 /** 126 179 Find the first digits in a string and return those as the build number. -
trunk/src/core/net/sf/basedb/core/plugin/About.java
r4889 r5607 51 51 52 52 /** 53 Get the minimum BASE version that the plug-in requires. 54 The returned value should be 2 or 3 numbers separated by 55 a dot (eg. 3.0, 3.1.2, etc). A null return value indicates 56 that the plug-in works with all BASE versions. 57 @return A string or null 58 @since 3.0 59 */ 60 public String getMinBaseVersion(); 61 62 /** 63 Get the maximum BASE version were to plug-in no longer is 64 expected to work. The returned value should be 2 or 3 numbers separated 65 by a dot (eg. 3.0, 3.1.2, etc). A null return value indicates 66 that the plug-in works with all BASE versions. 67 @return A string or null 68 @since 3.0 69 */ 70 public String getMaxBaseVersion(); 71 72 73 /** 53 74 A description of the plugin and what it does. May return null. 54 75 */ -
trunk/src/core/net/sf/basedb/core/plugin/AboutImpl.java
r4889 r5607 35 35 private final String description; 36 36 private final String version; 37 private final String minBaseVersion; 38 private final String maxBaseVersion; 37 39 private final String copyright; 38 40 private final String contact; 39 41 private final String email; 40 42 private final String url; 43 44 45 /** 46 Create a new about object without any min or max BASE version requirement. 47 */ 48 public AboutImpl(String name, String description, String version, String copyright, String contact, String email, String url) 49 { 50 this(name, description, version, null, null, copyright, contact, email, url); 51 } 52 41 53 42 54 /** … … 46 58 @param description A description of the plugin 47 59 @param version The version of the plugin 60 @param minBaseVersion The minium version of BASE that is required by the plugin 61 @param maxBaseVersion The maxium version of BASE that the plugin is expected to work with 48 62 @param copyright A copyright notice 49 63 @param contact Contact information for the plugin … … 51 65 @param url An URL to get more inforamtion about the plugin 52 66 @throws NullPointerException If the name is null 67 @since 3.0 53 68 */ 54 public AboutImpl(String name, String description, String version, String copyright, String contact, String email, String url)69 public AboutImpl(String name, String description, String version, String minBaseVersion, String maxBaseVersion, String copyright, String contact, String email, String url) 55 70 { 56 71 if (name == null) throw new NullPointerException("The 'name' parameter mustn't be null."); … … 62 77 this.url = url; 63 78 this.version = version; 79 this.minBaseVersion = minBaseVersion; 80 this.maxBaseVersion = maxBaseVersion; 64 81 } 65 82 … … 68 85 ------------------------------------------- 69 86 */ 87 @Override 70 88 public String getContact() 71 89 { … … 73 91 } 74 92 93 @Override 75 94 public String getCopyright() 76 95 { … … 78 97 } 79 98 99 @Override 80 100 public String getDescription() 81 101 { … … 83 103 } 84 104 105 @Override 85 106 public String getEmail() 86 107 { … … 88 109 } 89 110 111 @Override 90 112 public String getName() 91 113 { … … 93 115 } 94 116 117 @Override 95 118 public String getUrl() 96 119 { … … 98 121 } 99 122 123 @Override 100 124 public String getVersion() 101 125 { 102 126 return version; 103 127 } 128 129 @Override 130 public String getMinBaseVersion() 131 { 132 return minBaseVersion; 133 } 134 135 @Override 136 public String getMaxBaseVersion() 137 { 138 return maxBaseVersion; 139 } 104 140 // ------------------------------------------- 105 141 } -
trunk/src/core/net/sf/basedb/core/xsd/extensions.xsd
r5519 r5607 30 30 <xsd:complexType> 31 31 <xsd:sequence> 32 <!-- global 'about' element --> 32 33 <xsd:element name="about" type="aboutType" minOccurs="0" /> 34 35 <!-- 'extension-point' element --> 33 36 <xsd:element name="extension-point" minOccurs="0" maxOccurs="unbounded"> 34 37 <xsd:complexType> … … 52 55 </xsd:element> 53 56 57 <!-- 'extension' element --> 54 58 <xsd:element name="extension" minOccurs="0" maxOccurs="unbounded"> 55 59 <xsd:complexType> … … 97 101 <xsd:element name="description" type="xsd:string" minOccurs="0" maxOccurs="1" /> 98 102 <xsd:element name="version" type="xsd:string" minOccurs="0" maxOccurs="1" /> 103 <xsd:element name="min-base-version" type="baseVersionType" minOccurs="0" maxOccurs="1" /> 104 <xsd:element name="max-base-version" type="baseVersionType" minOccurs="0" maxOccurs="1" /> 99 105 <xsd:element name="copyright" type="xsd:string" minOccurs="0" maxOccurs="1" /> 100 106 <xsd:element name="contact" type="xsd:string" minOccurs="0" maxOccurs="1" /> … … 103 109 </xsd:all> 104 110 </xsd:complexType> 111 112 <!-- A string matching BASE version number with or without patch number --> 113 <xsd:simpleType name="baseVersionType" > 114 <xsd:restriction base="xsd:string"> 115 <xsd:pattern value="\d\.\d+\.?\d*"></xsd:pattern> 116 </xsd:restriction> 117 </xsd:simpleType> 105 118 106 119 <!-- … … 121 134 </xsd:sequence> 122 135 </xsd:complexType> 123 124 <xsd:group name="extends"> 125 <xsd:sequence> 126 <xsd:element name="extends" minOccurs="0" maxOccurs="unbounded"> 127 <xsd:complexType> 128 <xsd:simpleContent> 129 <xsd:extension base="xsd:string"> 130 <xsd:attribute name="index" type="xsd:float" /> 131 </xsd:extension> 132 </xsd:simpleContent> 133 </xsd:complexType> 134 </xsd:element> 135 </xsd:sequence> 136 </xsd:group> 137 136 138 137 </xsd:schema> -
trunk/src/core/net/sf/basedb/util/extensions/AboutBean.java
r4515 r5607 39 39 private String description; 40 40 private String version; 41 private String minBaseVersion; 42 private String maxBaseVersion; 41 43 private String copyright; 42 44 private String contact; … … 119 121 } 120 122 123 @Override 124 public String getMinBaseVersion() 125 { 126 return minBaseVersion; 127 } 128 public void setMinBaseVersion(String version) 129 { 130 this.minBaseVersion = version; 131 } 132 133 @Override 134 public String getMaxBaseVersion() 135 { 136 return maxBaseVersion; 137 } 138 public void setMaxBaseVersion(String version) 139 { 140 this.maxBaseVersion = version; 141 } 142 143 121 144 /** 122 145 Copy information from antoher <code>About</code> object … … 132 155 description = overwrite || description == null ? from.getDescription() : description; 133 156 version = overwrite || version == null ? from.getVersion() : version; 157 minBaseVersion = overwrite || minBaseVersion == null ? from.getMinBaseVersion() : minBaseVersion; 158 maxBaseVersion = overwrite || maxBaseVersion == null ? from.getMaxBaseVersion() : maxBaseVersion; 134 159 copyright = overwrite || copyright == null ? from.getCopyright() : copyright; 135 160 contact = overwrite || contact == null ? from.getContact() : contact; -
trunk/src/core/net/sf/basedb/util/extensions/Registry.java
r5606 r5607 287 287 { 288 288 handleEvent(EventType.BEFORE_UNREGISTRATION, rep, null); 289 for (RegisteredExtension<?> rext : rep.getExtensions()) 290 { 291 handleEvent(EventType.BEFORE_UNREGISTRATION, rep, rext); 292 extensions.remove(rext.getId()); 293 } 289 294 extensionPoints.remove(id); 290 295 } … … 894 899 private String description; 895 900 private String version; 901 private String minBaseVersion; 902 private String maxBaseVersion; 896 903 private String copyright; 897 904 private String contact; … … 953 960 return version; 954 961 } 962 963 @Override 964 public String getMinBaseVersion() 965 { 966 return minBaseVersion; 967 } 968 969 @Override 970 public String getMaxBaseVersion() 971 { 972 return maxBaseVersion; 973 } 955 974 // --------------------------------- 956 975 … … 963 982 this.description = about.getDescription(); 964 983 this.version = about.getVersion(); 984 this.minBaseVersion = about.getMinBaseVersion(); 985 this.maxBaseVersion = about.getMaxBaseVersion(); 965 986 this.contact = about.getContact(); 966 987 this.copyright = about.getCopyright(); -
trunk/src/core/net/sf/basedb/util/extensions/manager/ExtensionsFile.java
r5606 r5607 82 82 private boolean hasError; 83 83 84 private volatile boolean hasValidated;85 84 private volatile boolean isValid; 86 85 private Throwable validationError; … … 380 379 Validate the XML file with the extension definitions. 381 380 */ 382 synchronized void validate() 383 { 384 if (hasValidated) return; 385 381 synchronized boolean validate() 382 { 386 383 log.info("Validating extensions in file: " + this); 387 hasValidated = false;388 384 isValid = false; 385 hasError = false; 389 386 validationError = null; 390 387 jarLoader = null; 388 391 389 InputStream in = null; 392 390 try … … 394 392 in = getXmlStream(); 395 393 about = new XmlLoader().validateXmlFile(in, getName()); 396 } 397 catch (RuntimeException ex) 398 { 399 log.error("Error validating extensions in file: " + this, ex); 400 validationError = ex; 401 throw ex; 394 log.info("Successfully validated extensions in file: " + this); 395 isValid = true; 402 396 } 403 397 catch (Throwable t) … … 405 399 log.error("Error validating extensions in file: " + this, t); 406 400 validationError = t; 407 throw new RuntimeException(t);408 401 } 409 402 finally 410 403 { 411 404 FileUtil.close(in); 412 hasValidated = true; 413 } 414 log.info("Successfully validated extensions in file: " + this); 415 isValid = true; 405 } 406 return isValid; 416 407 } 417 408 … … 427 418 public boolean hasError() 428 419 { 429 return hasError ;420 return hasError || !isValid; 430 421 } 431 422 … … 541 532 } 542 533 534 /** 535 Get the class loader used to load classes for the extension. Only JAR 536 files have class loaders so this method may return null. 537 */ 543 538 public ClassLoader getClassLoader() 544 539 throws IOException … … 546 541 if (jarLoader == null && isJar()) 547 542 { 548 jarLoader = (JarClassLoader)JarClassLoader.getInstance(getFile().getAbsolutePath() );543 jarLoader = (JarClassLoader)JarClassLoader.getInstance(getFile().getAbsolutePath(), true); 549 544 } 550 545 return jarLoader; 551 546 } 552 553 554 547 555 548 /** … … 669 662 xtFile.lastLength = xtFile.file.length(); 670 663 } 664 if (!xtFile.isValid) 665 { 666 // Cleanup to avoid leaking memory 667 xtFile.allObjects.clear(); 668 xtFile.jarLoader = null; 669 xtFile.objectMetadata.clear(); 670 } 671 671 } 672 672 -
trunk/src/core/net/sf/basedb/util/extensions/manager/ExtensionsManager.java
r5606 r5607 220 220 if (!xtFile.exists()) 221 221 { 222 log. info("File '" + xtFile + "' has been deleted.");222 log.debug("File '" + xtFile + "' has been deleted."); 223 223 unregisterAllObjects(xtFile); 224 224 it.remove(); … … 227 227 else if (xtFile.isNew()) 228 228 { 229 numNew++; 230 } 231 else if (xtFile.checkModified()) 232 { 233 log.debug("File '" + xtFile + "' is modified. Validating..."); 229 234 xtFile.validate(); 230 numNew++; 231 } 232 else if (xtFile.checkModified()) 233 { 234 xtFile.validate(); 235 log.debug("File '" + xtFile + "' is " + (xtFile.isValid() ? "valid" : "invalid")); 235 236 numModified++; 236 237 } … … 305 306 if (files != null && files.length > 0) 306 307 { 307 log. info("Found " + files.length + " file(s)");308 log.debug("Found " + files.length + " files"); 308 309 for (File file : files) 309 310 { 310 311 if (ignore.contains(file)) 311 312 { 312 log. info("File '" + file + "' is ignored.");313 log.debug("File '" + file + "' is ignored."); 313 314 continue; // with the next file 314 315 } … … 318 319 if (xtFile != null) 319 320 { 320 log. info("File '" + xtFile + "' is a known file.");321 log.debug("File '" + xtFile + "' is a known file."); 321 322 } 322 323 else … … 327 328 } 328 329 } 330 log.info("Found " + numNew + " files"); 329 331 } 330 332 else … … 389 391 installedObjects.put(key, xtFile); 390 392 } 391 else 393 else if (!xtFile.equals(xtOther)) 392 394 { 393 395 throw new ItemAlreadyExistsException(key.toDescription() + " is defined in '" + xtOther.getName() + "'"); … … 442 444 { 443 445 if (processor == null) throw new NullPointerException("processor"); 446 log.info("Processing files with processor: " + processor); 444 447 445 448 // 1. Filter files with the given filter … … 448 451 { 449 452 filtered = new ArrayList<ExtensionsFile>(xtFiles.size()); 450 log. debug("Filtering files with filter: " + filter);453 log.info("Filtering files with filter: " + filter); 451 454 for (ExtensionsFile xtFile : xtFiles.values()) 452 455 { … … 481 484 } 482 485 processor.done(this); 483 log.debug("All files processed successfullywith processor: " + processor);486 log.debug("All files processed with processor: " + processor); 484 487 } 485 488 catch (Throwable t) 486 489 { 487 log. warn("Error when processing extensions with " + processor, t);490 log.error("Error when processing extensions with " + processor, t); 488 491 processor.done(null, t); 489 492 } -
trunk/src/core/net/sf/basedb/util/extensions/manager/filter/ValidAndNewOrModifiedFilter.java
r5605 r5607 62 62 public boolean evaluate(ExtensionsFile xtFile) 63 63 { 64 if (!xtFile.isValid() || xtFile.hasError())64 if (!xtFile.isValid() || (xtFile.hasError() && !allowUnmodified)) 65 65 { 66 66 log.info("File has errors (skipping): " + xtFile); -
trunk/src/core/net/sf/basedb/util/extensions/manager/processor/RegisterExtensionsProcessor.java
r5606 r5607 24 24 import java.io.InputStream; 25 25 import java.util.ArrayList; 26 import java.util.Collections; 26 27 import java.util.List; 27 28 … … 117 118 { 118 119 log.info("Loading extensions from file: " + xtFile); 120 FileData data = new FileData(); 121 data.writeableFile = wFile; 122 allData.add(data); 119 123 in = xtFile.getXmlStream(); 120 124 loader.loadXmlFile(in, xtFile.getName(), xtFile.getClassLoader(), true); 121 FileData data = new FileData();122 data.writeableFile = wFile;123 125 data.extensionPoints = new ArrayList<ExtensionPoint<?>>(loader.getExtensionPoints()); 124 126 data.extensions = new ArrayList<Extension<?>>(loader.getExtensions()); … … 126 128 log.info("Loaded " + data.extensionPoints.size() + "/" + data.extensions.size() + 127 129 " extensions from file: " + xtFile); 128 allData.add(data);129 130 } 130 131 catch (Exception ex) … … 134 135 if (results != null) 135 136 { 136 results.addErrorMessage(xtFile, "Failed to load extension s:" + ex.getMessage());137 results.addErrorMessage(xtFile, "Failed to load extension(s): " + ex.getMessage()); 137 138 } 138 139 log.error("Failed to load extensions from file: " + xtFile, ex); … … 218 219 ExtensionsFile xtFile = wFile.getExtensionsFile(); 219 220 220 // NOTE! Do not register files with an error221 if (xtFile.hasError())222 {223 log.debug("Skipping file with error: " + xtFile);224 continue; // with the next file225 }226 227 221 if (!forceUpdate && (!xtFile.wasModified() || xtFile.isNew())) 228 222 { 229 223 log.debug("Skipping new or unmodified file: " + xtFile); 230 224 continue; 225 } 226 227 // Unregister all extensions if the file has an error 228 if (xtFile.hasError()) 229 { 230 data.extensions = Collections.emptyList(); 231 data.extensionPoints = Collections.emptyList(); 231 232 } 232 233 … … 405 406 if (forceUpdate || !registry.extensionPointIsRegistered(ep.getId())) 406 407 { 408 log.debug("Registering extension point: " + ep); 407 409 ExtensionPointKey key = new ExtensionPointKey(ep); 408 410 data.writeableFile.registerObject(key, ep); … … 425 427 private boolean unregisterExtensionPoint(FileData data, ExtensionPoint ep, Registry registry) 426 428 { 429 log.debug("Unregistering extension point: " + ep); 427 430 unregisterFactory(data, ep.getRendererFactory()); 428 431 unregisterFactory(data, ep.getErrorHandlerFactory()); … … 444 447 if (forceUpdate || !registry.extensionIsRegistered(ext.getId())) 445 448 { 449 log.debug("Registering extension: " + ext); 446 450 ExtensionKey key = new ExtensionKey(ext); 447 451 data.writeableFile.registerObject(key, ext); … … 464 468 private boolean unregisterExtension(FileData data, Extension ext, Registry registry) 465 469 { 470 log.debug("Unregistering extension: " + ext); 466 471 unregisterFactory(data, ext.getRendererFactory()); 467 472 unregisterFactory(data, ext.getActionFactory()); -
trunk/src/core/net/sf/basedb/util/extensions/manager/processor/UnregisterExtensionsProcessor.java
r5603 r5607 25 25 import net.sf.basedb.util.extensions.ExtensionPoint; 26 26 import net.sf.basedb.util.extensions.Registry; 27 import net.sf.basedb.util.extensions.manager.ExtensionKey; 28 import net.sf.basedb.util.extensions.manager.ExtensionPointKey; 27 29 import net.sf.basedb.util.extensions.manager.ExtensionsFile; 28 30 import net.sf.basedb.util.extensions.manager.ExtensionsFileProcessor; 29 31 import net.sf.basedb.util.extensions.manager.ExtensionsManager; 32 import net.sf.basedb.util.extensions.manager.FactoryParametersKey; 30 33 import net.sf.basedb.util.extensions.manager.ProcessResults; 31 34 import net.sf.basedb.util.extensions.manager.ExtensionsFile.WriteableExtensionsFile; … … 85 88 try 86 89 { 90 wFile.open(); 87 91 int num = 0; 88 92 Registry registry = manager.getRegistry(); 89 93 for (ExtensionPoint ep : xtFile.getObjectsOfClass(ExtensionPoint.class)) 90 94 { 91 registry.unregisterExtensionPoint(ep.getId());95 unregisterExtensionPoint(wFile, ep, registry); 92 96 num++; 93 97 } 94 98 for (Extension ext : xtFile.getObjectsOfClass(Extension.class)) 95 99 { 96 registry.unregisterExtension(ext.getId());100 unregisterExtension(wFile, ext, registry); 97 101 num++; 98 102 } … … 101 105 if (results != null) 102 106 { 103 results.setStatus(xtFile, "Deleted");104 results.addMessage(xtFile, num + " extensionsunregisterered.");107 if (!xtFile.exists()) results.setStatus(xtFile, "Deleted"); 108 if (num > 0) results.addMessage(xtFile, num + " extension(s) unregisterered."); 105 109 } 106 110 log.info("Unregistered " + num + " extensions from file: " + xtFile); … … 115 119 } 116 120 log.error("Could not unregister extensions in file: " + xtFile, ex); 121 } 122 finally 123 { 124 wFile.close(); 117 125 } 118 126 } … … 132 140 {} 133 141 // ---------------------------------------------------- 142 143 /** 144 Unregister the given extension including factory metadata etc. 145 */ 146 private void unregisterExtension(WriteableExtensionsFile wFile, Extension ext, Registry registry) 147 { 148 unregisterFactory(wFile, ext.getRendererFactory()); 149 unregisterFactory(wFile, ext.getActionFactory()); 150 ExtensionKey key = new ExtensionKey(ext); 151 wFile.unregisterObject(key); 152 registry.unregisterExtension(ext.getId()); 153 } 154 155 /** 156 Unregister the given extension point including factory metadata etc. 157 */ 158 private void unregisterExtensionPoint(WriteableExtensionsFile wFile, ExtensionPoint ep, Registry registry) 159 { 160 unregisterFactory(wFile, ep.getRendererFactory()); 161 unregisterFactory(wFile, ep.getErrorHandlerFactory()); 162 ExtensionPointKey key = new ExtensionPointKey(ep); 163 wFile.unregisterObject(key); 164 registry.unregisterExtensionPoint(ep.getId()); 165 } 166 167 private void unregisterFactory(WriteableExtensionsFile wFile, Object factory) 168 { 169 if (factory == null) return; 170 wFile.unregisterMetadata(new FactoryParametersKey(factory)); 171 } 172 134 173 135 174 /** -
trunk/src/core/net/sf/basedb/util/extensions/xml/XmlLoader.java
r5598 r5607 41 41 import org.jdom.output.XMLOutputter; 42 42 43 import net.sf.basedb.core.BaseException; 43 44 import net.sf.basedb.core.InvalidUseOfNullException; 44 45 import net.sf.basedb.core.StringUtil; 46 import net.sf.basedb.core.Version; 45 47 import net.sf.basedb.core.plugin.About; 46 48 import net.sf.basedb.util.ClassUtil; … … 273 275 lastName = filename; 274 276 About globalAbout = loadGlobalAbout(validatedDom); 277 verifyBaseVersion(globalAbout, true); 275 278 return globalAbout; 276 279 } … … 444 447 { 445 448 log.debug("Validating file: " + filename); 446 return XMLUtil.getSchemaValidatedXML(xmlFile, filename, namespace, schemaFileURL); 449 Document dom = XMLUtil.getSchemaValidatedXML(xmlFile, filename, namespace, schemaFileURL); 450 return dom; 451 } 452 453 protected boolean verifyBaseVersion(About about, boolean throwException) 454 { 455 if (about == null) return true; 456 String minVersion = about.getMinBaseVersion(); 457 String maxVersion = about.getMaxBaseVersion(); 458 if (minVersion != null && Version.compareWith(minVersion) > 0) 459 { 460 if (throwException) 461 { 462 throw new BaseException("BASE version "+ minVersion + " or higher is required"); 463 } 464 return false; 465 } 466 if (maxVersion != null && Version.compareWith(maxVersion) <= 0) 467 { 468 if (throwException) 469 { 470 throw new BaseException("BASE version "+ maxVersion + " or higher is not supported"); 471 } 472 return false; 473 } 474 return true; 447 475 } 448 476 … … 472 500 about.setDescription(Values.getStringOrNull(aboutTag.getChildText("description", ns))); 473 501 about.setVersion(Values.getStringOrNull(aboutTag.getChildText("version", ns))); 502 about.setMinBaseVersion(Values.getStringOrNull(aboutTag.getChildText("min-base-version", ns))); 503 about.setMaxBaseVersion(Values.getStringOrNull(aboutTag.getChildText("max-base-version", ns))); 474 504 about.setContact(Values.getStringOrNull(aboutTag.getChildText("contact", ns))); 475 505 about.setCopyright(Values.getStringOrNull(aboutTag.getChildText("copyright", ns))); … … 672 702 about.copy(globalAbout, false); 673 703 } 674 675 // <action-factory> 676 Element afTag = epTag.getChild("action-factory", ns); 677 ActionFactory af = null; 678 if (afTag != null) 704 705 if (!verifyBaseVersion(about, false)) 679 706 { 680 af = createFactory(afTag, classLoader, ActionFactory.class); 707 String min = about.getMinBaseVersion(); 708 String max = about.getMaxBaseVersion(); 709 log.info("Extension '" + id + "' require BASE version between " + 710 (min == null ? "*" : min) + " and " + (max == null ? "*" : max) 711 ); 681 712 } 682 683 // <renderer-factory> 684 Element rfTag = epTag.getChild("renderer-factory", ns); 685 RendererFactory rf = null; 686 if (rfTag != null) 713 else 687 714 { 688 rf = createFactory(rfTag, classLoader, RendererFactory.class); 689 } 715 // <action-factory> 716 Element afTag = epTag.getChild("action-factory", ns); 717 ActionFactory af = null; 718 if (afTag != null) 719 { 720 af = createFactory(afTag, classLoader, ActionFactory.class); 721 } 690 722 691 String commonIdPrefix = null; 692 if (extensionPoints.size() > 1) 693 { 694 // We need to calculate the common id prefix for the extension points 695 // so that we can create unique extension id:s 696 commonIdPrefix = StringUtil.getCommonPrefix(extensionPoints); 697 } 698 699 for (int i = 0; i < extensionPoints.size(); ++i) 700 { 701 epId = extensionPoints.get(i); 702 float index = indexes.get(i); 703 ExtensionBean<Action> ext = new ExtensionBean<Action>(); 704 temp.add(ext); 705 numLoaded++; 706 707 String thisId = id; 708 if (commonIdPrefix != null) 723 // <renderer-factory> 724 Element rfTag = epTag.getChild("renderer-factory", ns); 725 RendererFactory rf = null; 726 if (rfTag != null) 709 727 { 710 thisId += ":" + epId.substring(commonIdPrefix.length());728 rf = createFactory(rfTag, classLoader, RendererFactory.class); 711 729 } 712 730 713 ext.setId(thisId); 714 ext.setExtends(epId); 715 ext.setIndex(index); 716 ext.setAbout(about); 717 ext.setActionFactory(af); 718 ext.setRendererFactory(rf); 731 String commonIdPrefix = null; 732 if (extensionPoints.size() > 1) 733 { 734 // We need to calculate the common id prefix for the extension points 735 // so that we can create unique extension id:s 736 commonIdPrefix = StringUtil.getCommonPrefix(extensionPoints); 737 } 738 739 for (int i = 0; i < extensionPoints.size(); ++i) 740 { 741 epId = extensionPoints.get(i); 742 float index = indexes.get(i); 743 ExtensionBean<Action> ext = new ExtensionBean<Action>(); 744 temp.add(ext); 745 numLoaded++; 746 747 String thisId = id; 748 if (commonIdPrefix != null) 749 { 750 thisId += ":" + epId.substring(commonIdPrefix.length()); 751 } 752 753 ext.setId(thisId); 754 ext.setExtends(epId); 755 ext.setIndex(index); 756 ext.setAbout(about); 757 ext.setActionFactory(af); 758 ext.setRendererFactory(rf); 759 } 719 760 } 720 761 } -
trunk/src/info/net/sf/basedb/info/VersionInfo.java
r4512 r5607 35 35 private static final long serialVersionUID = 9189853948028180946L; 36 36 37 private Stringmajor;38 private Stringminor;39 private Stringmaintenance;37 private int major; 38 private int minor; 39 private int maintenance; 40 40 private int build; 41 41 private int schema; … … 64 64 @return Returns the maintenance version 65 65 @see net.sf.basedb.core.Application#getMaintenanceVersion() 66 @since 3.0 (was returning a String in 2.x) 66 67 */ 67 public StringgetMaintenance()68 public int getMaintenance() 68 69 { 69 70 return maintenance; 70 71 } 71 72 72 public void setMaintenance( Stringmaintenance)73 public void setMaintenance(int maintenance) 73 74 { 74 75 this.maintenance = maintenance; … … 78 79 @return Returns the major version 79 80 @see net.sf.basedb.core.Application#getMajorVersion() 81 @since 3.0 (was returning a String in 2.x) 80 82 */ 81 public StringgetMajor()83 public int getMajor() 82 84 { 83 85 return major; 84 86 } 85 87 86 public void setMajor( Stringmajor)88 public void setMajor(int major) 87 89 { 88 90 this.major = major; … … 92 94 @return Returns the minor version 93 95 @see net.sf.basedb.core.Application#getMinorVersion() 96 @since 3.0 (was returning a String in 2.x) 94 97 */ 95 public StringgetMinor()98 public int getMinor() 96 99 { 97 100 return minor; 98 101 } 99 102 100 public void setMinor( Stringminor)103 public void setMinor(int minor) 101 104 { 102 105 this.minor = minor; -
trunk/www/admin/extensions/details.jsp
r5606 r5607 463 463 List<String> messages = fileResults.getMessages(); 464 464 Throwable validationError = file.getValidationError(); 465 %> 466 <ul style="padding-left: 20px; margin: 0px; text-align: left;" class="error"> 467 <% 468 if (validationError != null) 469 { 470 %> 471 <li><%=validationError.getClass().getSimpleName()%>: <%=HTML.niceFormat(validationError.getMessage())%> 472 <% 473 } 465 474 for (String msg : messages) 466 475 { … … 469 478 <% 470 479 } 471 if (validationError != null) 472 { 473 %> 474 <li><%=HTML.niceFormat(validationError.getMessage())%> 475 <% 476 } 480 %> 481 </ul> 482 <% 477 483 } 478 484 else -
trunk/www/admin/extensions/index.jsp
r5606 r5607 34 34 import="net.sf.basedb.util.extensions.Extension" 35 35 import="net.sf.basedb.clients.web.extensions.ExtensionsControl" 36 import="net.sf.basedb.clients.web.extensions.ExtensionsFile"37 36 import="java.util.List" 38 37 %> -
trunk/www/admin/extensions/scan_results.jsp
r5602 r5607 109 109 { 110 110 ExtensionsFile extFile = fileResults.getExtensionsFile(); 111 boolean isError = fileResults.hasError();112 111 String detailsId = Integer.toString(extFile.hashCode()); 113 112 List<String> messages = fileResults.getMessages(); 114 boolean hasMessages = messages != null && messages.size() > 0;115 113 Throwable validationError = extFile.getValidationError(); 114 boolean hasMessages = (messages != null && messages.size() > 0) || validationError != null; 116 115 %> 117 116 <tr> 118 117 <td class="prompt"><%=extFile.getName() %></td> 119 <td><%= isError ? "Error" :fileResults.getStatus() %>118 <td><%=fileResults.getStatus() %> 120 119 <base:icon 121 120 id="<%="icon." + detailsId %>" … … 123 122 onclick="<%="showDetails('" + detailsId + "')" %>" 124 123 visible="<%=hasMessages%>" 125 124 /> 126 125 </td> 127 126 </tr> 128 127 <% 129 if (hasMessages || validationError != null)128 if (hasMessages) 130 129 { 131 130 %> 132 131 <tr id="details.<%=detailsId %>" style="display:none;"> 133 132 <td></td><td> 133 <ul style="padding-left: 20px; margin: 0px; text-align: left;"> 134 134 <% 135 135 for (String msg : messages) … … 142 142 { 143 143 %> 144 <li><%= HTML.niceFormat(validationError.getMessage())%>144 <li><%=validationError.getClass().getSimpleName()%>: <%=HTML.niceFormat(validationError.getMessage())%> 145 145 <% 146 146 } 147 147 %> 148 </ul> 148 149 </td> 149 150 </tr>
Note: See TracChangeset
for help on using the changeset viewer.