Author: arminw Date: Mon Oct 1 09:07:08 2007 New Revision: 580999 URL: http://svn.apache.org/viewvc?rev=580999&view=rev Log: - get rid of commos-lang dependency - fix super-reference automatic super-class detection
Modified: db/ojb/trunk/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/ClassDescriptorConstraints.java db/ojb/trunk/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/FieldDescriptorConstraints.java db/ojb/trunk/src/xdoclet/java/src/xdoclet/modules/ojb/model/ClassDescriptorDef.java db/ojb/trunk/src/xdoclet/java/src/xdoclet/modules/ojb/model/PropertyHelper.java db/ojb/trunk/src/xdoclet/java/src/xdoclet/modules/ojb/model/ReferenceDescriptorDef.java Modified: db/ojb/trunk/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/ClassDescriptorConstraints.java URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/ClassDescriptorConstraints.java?rev=580999&r1=580998&r2=580999&view=diff ============================================================================== --- db/ojb/trunk/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/ClassDescriptorConstraints.java (original) +++ db/ojb/trunk/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/ClassDescriptorConstraints.java Mon Oct 1 09:07:08 2007 @@ -22,12 +22,18 @@ import java.lang.reflect.Method; import java.lang.reflect.Modifier; -import java.util.*; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Properties; import xdoclet.modules.ojb.CommaListIterator; import xdoclet.modules.ojb.LogHelper; -import xdoclet.modules.ojb.model.*; -import org.apache.commons.lang.SystemUtils; +import xdoclet.modules.ojb.model.ClassDescriptorDef; +import xdoclet.modules.ojb.model.FeatureDescriptorDef; +import xdoclet.modules.ojb.model.ObjectCacheDef; +import xdoclet.modules.ojb.model.ProcedureArgumentDef; +import xdoclet.modules.ojb.model.ProcedureDef; +import xdoclet.modules.ojb.model.PropertyHelper; /** * Checks constraints for class descriptors. Note that constraints may modify the class descriptor. @@ -173,7 +179,7 @@ } else if(curExtent.hasSuperReference()) { - String eol = SystemUtils.LINE_SEPARATOR; + String eol = PropertyHelper.LINE_SEPARATOR; String msg = new StringBuffer().append("Sub-class ").append(curExtent.getName()) .append(" declare a 'super-reference' to class ").append(classDef.getName()) .append(eol).append("If table per sub-class inheritance is used, it's not allowed to use the 'extent' attribute in class ") Modified: db/ojb/trunk/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/FieldDescriptorConstraints.java URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/FieldDescriptorConstraints.java?rev=580999&r1=580998&r2=580999&view=diff ============================================================================== --- db/ojb/trunk/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/FieldDescriptorConstraints.java (original) +++ db/ojb/trunk/src/xdoclet/java/src/xdoclet/modules/ojb/constraints/FieldDescriptorConstraints.java Mon Oct 1 09:07:08 2007 @@ -425,7 +425,7 @@ ClassDescriptorDef cld = (ClassDescriptorDef) fieldDef.getOwner(); if(fieldDef.isPrimaryKey() && cld.hasSuperReference() && !cld.hasSuperReferenceViaForeignKey()) { - String eol = SystemUtils.LINE_SEPARATOR; + String eol = PropertyHelper.LINE_SEPARATOR; LogHelper.warn(true, FieldDescriptorConstraints.class, "checkTablePerSubclass", Modified: db/ojb/trunk/src/xdoclet/java/src/xdoclet/modules/ojb/model/ClassDescriptorDef.java URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/xdoclet/java/src/xdoclet/modules/ojb/model/ClassDescriptorDef.java?rev=580999&r1=580998&r2=580999&view=diff ============================================================================== --- db/ojb/trunk/src/xdoclet/java/src/xdoclet/modules/ojb/model/ClassDescriptorDef.java (original) +++ db/ojb/trunk/src/xdoclet/java/src/xdoclet/modules/ojb/model/ClassDescriptorDef.java Mon Oct 1 09:07:08 2007 @@ -20,13 +20,23 @@ */ -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Properties; +import java.util.SortedMap; +import java.util.TreeMap; import xdoclet.modules.ojb.CommaListIterator; import xdoclet.modules.ojb.LogHelper; -import xdoclet.modules.ojb.constraints.*; +import xdoclet.modules.ojb.constraints.ClassDescriptorConstraints; +import xdoclet.modules.ojb.constraints.CollectionDescriptorConstraints; +import xdoclet.modules.ojb.constraints.ConstraintException; +import xdoclet.modules.ojb.constraints.FieldDescriptorConstraints; +import xdoclet.modules.ojb.constraints.ReferenceDescriptorConstraints; import xjavadoc.XClass; -import org.apache.commons.lang.SystemUtils; /** * Definition of a class for the ojb repository file. @@ -162,7 +172,7 @@ if(hasSuperReference()) { - String eol = SystemUtils.LINE_SEPARATOR; + String eol = PropertyHelper.LINE_SEPARATOR; String msg = new StringBuffer().append("This class ").append(getName()) .append(" is a sub-class and declare a 'super-reference' to its super class").append(eol) .append("If table per sub-class inheritance is used, it's not allowed to include non-primary key inherited fields in the sub-class.") @@ -653,7 +663,7 @@ ReferenceDescriptorDef subClassSuperRef = subType.getSuperReference(); if(subClassSuperRef != null && subClassSuperRef.isTablePerSubclass()) { - String eol = SystemUtils.LINE_SEPARATOR; + String eol = PropertyHelper.LINE_SEPARATOR; String msg = new StringBuffer().append("Sub-class ").append(subType.getName()) .append(" declare a 'super-reference' to class ").append(getName()).append(eol) .append("If table per sub-class inheritance is used, it's not allowed to declare an 'extent' attribute in class ") Modified: db/ojb/trunk/src/xdoclet/java/src/xdoclet/modules/ojb/model/PropertyHelper.java URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/xdoclet/java/src/xdoclet/modules/ojb/model/PropertyHelper.java?rev=580999&r1=580998&r2=580999&view=diff ============================================================================== --- db/ojb/trunk/src/xdoclet/java/src/xdoclet/modules/ojb/model/PropertyHelper.java (original) +++ db/ojb/trunk/src/xdoclet/java/src/xdoclet/modules/ojb/model/PropertyHelper.java Mon Oct 1 09:07:08 2007 @@ -3,21 +3,21 @@ import java.util.HashMap; /* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations * under the License. */ @@ -27,101 +27,103 @@ */ public abstract class PropertyHelper { + public static final String LINE_SEPARATOR = getSystemProperty("line.separator"); + // ojb repository properties public static final String OJB_PROPERTY_STATE_DETECTION = "state-detection"; public static final String OJB_PROPERTY_FIELD_CLASS = "field-class"; public static final String OJB_PROPERTY_TARGET_FIELD_REF = "target-field-ref"; - public static final String OJB_PROPERTY_ACCEPT_LOCKS = "accept-locks"; - public static final String OJB_PROPERTY_ACCESS = "access"; - public static final String OJB_PROPERTY_ARGUMENTS = "arguments"; - public static final String OJB_PROPERTY_ARRAY_ELEMENT_CLASS_REF = "array-element-class-ref"; - public static final String OJB_PROPERTY_ATTRIBUTES = "attributes"; - public static final String OJB_PROPERTY_AUTOINCREMENT = "autoincrement"; - public static final String OJB_PROPERTY_AUTO_DELETE = "auto-delete"; - public static final String OJB_PROPERTY_AUTO_RETRIEVE = "auto-retrieve"; - public static final String OJB_PROPERTY_AUTO_UPDATE = "auto-update"; - public static final String OJB_PROPERTY_CLASS = "class"; - public static final String OJB_PROPERTY_CLASS_REF = "class-ref"; - public static final String OJB_PROPERTY_COLLECTION_CLASS = "collection-class"; - public static final String OJB_PROPERTY_COLUMN = "column"; + public static final String OJB_PROPERTY_ACCEPT_LOCKS = "accept-locks"; + public static final String OJB_PROPERTY_ACCESS = "access"; + public static final String OJB_PROPERTY_ARGUMENTS = "arguments"; + public static final String OJB_PROPERTY_ARRAY_ELEMENT_CLASS_REF = "array-element-class-ref"; + public static final String OJB_PROPERTY_ATTRIBUTES = "attributes"; + public static final String OJB_PROPERTY_AUTOINCREMENT = "autoincrement"; + public static final String OJB_PROPERTY_AUTO_DELETE = "auto-delete"; + public static final String OJB_PROPERTY_AUTO_RETRIEVE = "auto-retrieve"; + public static final String OJB_PROPERTY_AUTO_UPDATE = "auto-update"; + public static final String OJB_PROPERTY_CLASS = "class"; + public static final String OJB_PROPERTY_CLASS_REF = "class-ref"; + public static final String OJB_PROPERTY_COLLECTION_CLASS = "collection-class"; + public static final String OJB_PROPERTY_COLUMN = "column"; public static final String OJB_PROPERTY_COLUMN_DOCUMENTATION = "column-documentation"; - public static final String OJB_PROPERTY_CONVERSION = "conversion"; + public static final String OJB_PROPERTY_CONVERSION = "conversion"; public static final String OJB_PROPERTY_DATABASE_FOREIGNKEY = "database-foreignkey"; - public static final String OJB_PROPERTY_DEFAULT_CLASS_REF = "default-class-ref"; - public static final String OJB_PROPERTY_DEFAULT_CONVERSION = "default-conversion"; - public static final String OJB_PROPERTY_DEFAULT_FETCH = "default-fetch"; - public static final String OJB_PROPERTY_DEFAULT_JDBC_TYPE = "default-jdbc-type"; - public static final String OJB_PROPERTY_DEFAULT_PRECISION = "default-precision"; - public static final String OJB_PROPERTY_DEFAULT_SCALE = "default-scale"; - public static final String OJB_PROPERTY_DETERMINE_EXTENTS = "determine-extents"; - public static final String OJB_PROPERTY_DOCUMENTATION = "documentation"; - public static final String OJB_PROPERTY_ELEMENT_CLASS_REF = "element-class-ref"; - public static final String OJB_PROPERTY_FACTORY_CLASS = "factory-class"; - public static final String OJB_PROPERTY_FACTORY_METHOD = "factory-method"; - public static final String OJB_PROPERTY_FIELD_REF = "field-ref"; - public static final String OJB_PROPERTY_FIELDS = "fields"; - public static final String OJB_PROPERTY_FOREIGNKEY = "foreignkey"; + public static final String OJB_PROPERTY_DEFAULT_CLASS_REF = "default-class-ref"; + public static final String OJB_PROPERTY_DEFAULT_CONVERSION = "default-conversion"; + public static final String OJB_PROPERTY_DEFAULT_FETCH = "default-fetch"; + public static final String OJB_PROPERTY_DEFAULT_JDBC_TYPE = "default-jdbc-type"; + public static final String OJB_PROPERTY_DEFAULT_PRECISION = "default-precision"; + public static final String OJB_PROPERTY_DEFAULT_SCALE = "default-scale"; + public static final String OJB_PROPERTY_DETERMINE_EXTENTS = "determine-extents"; + public static final String OJB_PROPERTY_DOCUMENTATION = "documentation"; + public static final String OJB_PROPERTY_ELEMENT_CLASS_REF = "element-class-ref"; + public static final String OJB_PROPERTY_FACTORY_CLASS = "factory-class"; + public static final String OJB_PROPERTY_FACTORY_METHOD = "factory-method"; + public static final String OJB_PROPERTY_FIELD_REF = "field-ref"; + public static final String OJB_PROPERTY_FIELDS = "fields"; + public static final String OJB_PROPERTY_FOREIGNKEY = "foreignkey"; public static final String OJB_PROPERTY_FOREIGNKEY_DOCUMENTATION = "foreignkey-documentation"; public static final String OJB_PROPERTY_FOREIGNKEY_NAME = "foreignkey-name"; public static final String OJB_PROPERTY_FOREIGNKEY_ON_DELETE = "foreignkey-on-delete"; public static final String OJB_PROPERTY_FOREIGNKEY_ON_UPDATE = "foreignkey-on-update"; public static final String OJB_PROPERTY_GENERATE_REPOSITORY_INFO = "generate-repository-info"; - public static final String OJB_PROPERTY_GENERATE_TABLE_INFO = "generate-table-info"; - public static final String OJB_PROPERTY_ID = "id"; - public static final String OJB_PROPERTY_INDEXED = "indexed"; - public static final String OJB_PROPERTY_IGNORE = "ignore"; - public static final String OJB_PROPERTY_INCLUDE_INHERITED = "include-inherited"; - public static final String OJB_PROPERTY_INDIRECTION_TABLE = "indirection-table"; + public static final String OJB_PROPERTY_GENERATE_TABLE_INFO = "generate-table-info"; + public static final String OJB_PROPERTY_ID = "id"; + public static final String OJB_PROPERTY_INDEXED = "indexed"; + public static final String OJB_PROPERTY_IGNORE = "ignore"; + public static final String OJB_PROPERTY_INCLUDE_INHERITED = "include-inherited"; + public static final String OJB_PROPERTY_INDIRECTION_TABLE = "indirection-table"; public static final String OJB_PROPERTY_INDIRECTION_TABLE_DOCUMENTATION = "indirection-table-documentation"; public static final String OJB_PROPERTY_INDIRECTION_TABLE_PRIMARYKEYS = "indirection-table-primarykeys"; - public static final String OJB_PROPERTY_INITIALIZATION_METHOD = "initialization-method"; - public static final String OJB_PROPERTY_ISOLATION_LEVEL = "isolation-level"; - public static final String OJB_PROPERTY_JAVA_TYPE = "java-type"; - public static final String OJB_PROPERTY_JDBC_TYPE = "jdbc-type"; - public static final String OJB_PROPERTY_LENGTH = "length"; - public static final String OJB_PROPERTY_LOCKING = "locking"; - public static final String OJB_PROPERTY_NAME = "name"; - public static final String OJB_PROPERTY_NULLABLE = "nullable"; - public static final String OJB_PROPERTY_OJB_PERSISTENT = "ojb-persistent"; - public static final String OJB_PROPERTY_ORDERBY = "orderby"; - public static final String OJB_PROPERTY_OTM_DEPENDENT = "otm-dependent"; - public static final String OJB_PROPERTY_PRIMARYKEY = "primarykey"; - public static final String OJB_PROPERTY_PRECISION = "precision"; - public static final String OJB_PROPERTY_PROXY = "proxy"; - public static final String OJB_PROPERTY_PROXY_PREFETCHING_LIMIT = "proxy-prefetching-limit"; - public static final String OJB_PROPERTY_QUERY_CUSTOMIZER = "query-customizer"; - public static final String OJB_PROPERTY_QUERY_CUSTOMIZER_ATTRIBUTES = "query-customizer-attributes"; - public static final String OJB_PROPERTY_REFRESH = "refresh"; - public static final String OJB_PROPERTY_REMOTE_FOREIGNKEY = "remote-foreignkey"; + public static final String OJB_PROPERTY_INITIALIZATION_METHOD = "initialization-method"; + public static final String OJB_PROPERTY_ISOLATION_LEVEL = "isolation-level"; + public static final String OJB_PROPERTY_JAVA_TYPE = "java-type"; + public static final String OJB_PROPERTY_JDBC_TYPE = "jdbc-type"; + public static final String OJB_PROPERTY_LENGTH = "length"; + public static final String OJB_PROPERTY_LOCKING = "locking"; + public static final String OJB_PROPERTY_NAME = "name"; + public static final String OJB_PROPERTY_NULLABLE = "nullable"; + public static final String OJB_PROPERTY_OJB_PERSISTENT = "ojb-persistent"; + public static final String OJB_PROPERTY_ORDERBY = "orderby"; + public static final String OJB_PROPERTY_OTM_DEPENDENT = "otm-dependent"; + public static final String OJB_PROPERTY_PRIMARYKEY = "primarykey"; + public static final String OJB_PROPERTY_PRECISION = "precision"; + public static final String OJB_PROPERTY_PROXY = "proxy"; + public static final String OJB_PROPERTY_PROXY_PREFETCHING_LIMIT = "proxy-prefetching-limit"; + public static final String OJB_PROPERTY_QUERY_CUSTOMIZER = "query-customizer"; + public static final String OJB_PROPERTY_QUERY_CUSTOMIZER_ATTRIBUTES = "query-customizer-attributes"; + public static final String OJB_PROPERTY_REFRESH = "refresh"; + public static final String OJB_PROPERTY_REMOTE_FOREIGNKEY = "remote-foreignkey"; public static final String OJB_PROPERTY_REMOTE_FOREIGNKEY_DOCUMENTATION = "remote-foreignkey-documentation"; public static final String OJB_PROPERTY_REMOTE_FOREIGNKEY_NAME = "remote-foreignkey-name"; public static final String OJB_PROPERTY_REMOTE_FOREIGNKEY_ON_DELETE = "remote-foreignkey-on-delete"; public static final String OJB_PROPERTY_REMOTE_FOREIGNKEY_ON_UPDATE = "remote-foreignkey-on-update"; - public static final String OJB_PROPERTY_RETURN_FIELD_REF = "return-field-ref"; - public static final String OJB_PROPERTY_ROW_READER = "row-reader"; - public static final String OJB_PROPERTY_SCALE = "scale"; - public static final String OJB_PROPERTY_SEQUENCE_NAME = "sequence-name"; - public static final String OJB_PROPERTY_TABLE = "table"; + public static final String OJB_PROPERTY_RETURN_FIELD_REF = "return-field-ref"; + public static final String OJB_PROPERTY_ROW_READER = "row-reader"; + public static final String OJB_PROPERTY_SCALE = "scale"; + public static final String OJB_PROPERTY_SEQUENCE_NAME = "sequence-name"; + public static final String OJB_PROPERTY_TABLE = "table"; public static final String OJB_PROPERTY_TABLE_DOCUMENTATION = "table-documentation"; - public static final String OJB_PROPERTY_TYPE = "type"; - public static final String OJB_PROPERTY_UNIQUE = "unique"; - public static final String OJB_PROPERTY_UPDATE_LOCK = "update-lock"; - public static final String OJB_PROPERTY_VARIABLE_TYPE = "variable-type"; + public static final String OJB_PROPERTY_TYPE = "type"; + public static final String OJB_PROPERTY_UNIQUE = "unique"; + public static final String OJB_PROPERTY_UPDATE_LOCK = "update-lock"; + public static final String OJB_PROPERTY_VARIABLE_TYPE = "variable-type"; public static final String OJB_PROPERTY_VIRTUAL_FIELD = "virtual-field"; // torque schema properties - public static final String TORQUE_PROPERTY_AUTOINCREMENT = "autoIncrement"; - public static final String TORQUE_PROPERTY_FOREIGNTABLE = "foreignTable"; - public static final String TORQUE_PROPERTY_ID = "id"; - public static final String TORQUE_PROPERTY_JAVANAME = "javaName"; - public static final String TORQUE_PROPERTY_PRIMARYKEY = "primaryKey"; - public static final String TORQUE_PROPERTY_RELATION_NAME = "relation-name"; - public static final String TORQUE_PROPERTY_INV_RELATION_NAME = "inv-relation-name"; - public static final String TORQUE_PROPERTY_REQUIRED = "required"; - public static final String TORQUE_PROPERTY_SIZE = "size"; - public static final String TORQUE_PROPERTY_TYPE = "type"; + public static final String TORQUE_PROPERTY_AUTOINCREMENT = "autoIncrement"; + public static final String TORQUE_PROPERTY_FOREIGNTABLE = "foreignTable"; + public static final String TORQUE_PROPERTY_ID = "id"; + public static final String TORQUE_PROPERTY_JAVANAME = "javaName"; + public static final String TORQUE_PROPERTY_PRIMARYKEY = "primaryKey"; + public static final String TORQUE_PROPERTY_RELATION_NAME = "relation-name"; + public static final String TORQUE_PROPERTY_INV_RELATION_NAME = "inv-relation-name"; + public static final String TORQUE_PROPERTY_REQUIRED = "required"; + public static final String TORQUE_PROPERTY_SIZE = "size"; + public static final String TORQUE_PROPERTY_TYPE = "type"; /** Contains which properties are defined for the various defs */ private static HashMap _properties = new HashMap(); @@ -276,5 +278,21 @@ public static boolean toBoolean(String value, boolean defaultValue) { return "true".equals(value) ? true : ("false".equals(value) ? false : defaultValue); + } + + // copied from apache commons-lang + private static String getSystemProperty(String property) + { + try + { + return System.getProperty(property); + } catch (SecurityException ex) + { + // we are not allowed to look at this property + System.err.println( + "Caught a SecurityException reading the system property '" + property + + "'; the SystemUtils property value will default to null."); + return null; + } } } Modified: db/ojb/trunk/src/xdoclet/java/src/xdoclet/modules/ojb/model/ReferenceDescriptorDef.java URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/xdoclet/java/src/xdoclet/modules/ojb/model/ReferenceDescriptorDef.java?rev=580999&r1=580998&r2=580999&view=diff ============================================================================== --- db/ojb/trunk/src/xdoclet/java/src/xdoclet/modules/ojb/model/ReferenceDescriptorDef.java (original) +++ db/ojb/trunk/src/xdoclet/java/src/xdoclet/modules/ojb/model/ReferenceDescriptorDef.java Mon Oct 1 09:07:08 2007 @@ -1,9 +1,7 @@ package xdoclet.modules.ojb.model; -import java.util.List; import xdoclet.modules.ojb.LogHelper; -import org.apache.commons.lang.ClassUtils; import xjavadoc.XClass; /* @@ -132,11 +130,13 @@ } if(superClassStr == null) { - Class ownerClass = ClassUtils.getClass(classDef.getQualifiedName()); - List superClasses = ClassUtils.getAllSuperclasses(ownerClass); - if(!superClasses.isEmpty()) + Class ownerClass = Class.forName(classDef.getQualifiedName()); + Class superClass = ownerClass.getSuperclass(); + if(superClass != null + && !superClass.isInterface() + && !superClass.isPrimitive() + && !superClass.equals(Object.class)) { - Class superClass = (Class) superClasses.get(0); superClassStr = superClass.getName(); } } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]