Return-Path: Delivered-To: apmail-cayenne-commits-archive@www.apache.org Received: (qmail 42710 invoked from network); 28 Jan 2011 14:36:21 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 28 Jan 2011 14:36:21 -0000 Received: (qmail 12344 invoked by uid 500); 28 Jan 2011 14:36:21 -0000 Delivered-To: apmail-cayenne-commits-archive@cayenne.apache.org Received: (qmail 12314 invoked by uid 500); 28 Jan 2011 14:36:21 -0000 Mailing-List: contact commits-help@cayenne.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cayenne.apache.org Delivered-To: mailing list commits@cayenne.apache.org Received: (qmail 12307 invoked by uid 99); 28 Jan 2011 14:36:20 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 28 Jan 2011 14:36:20 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 28 Jan 2011 14:36:16 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id E4A8B23889DE; Fri, 28 Jan 2011 14:35:54 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1064700 - in /cayenne/main/trunk: docs/doc/src/main/resources/ framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/ framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/xml/ Date: Fri, 28 Jan 2011 14:35:54 -0000 To: commits@cayenne.apache.org From: aadamchik@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110128143554.E4A8B23889DE@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: aadamchik Date: Fri Jan 28 14:35:54 2011 New Revision: 1064700 URL: http://svn.apache.org/viewvc?rev=1064700&view=rev Log: CAY-1533 Deprecate org.apache.cayenne.xml Modified: cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/CayenneDataObject.java cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/xml/SerializableEntity.java cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/xml/XMLDecoder.java cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/xml/XMLEncoder.java cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/xml/XMLMappingDescriptor.java cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/xml/XMLSerializable.java cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/xml/XMLUtil.java Modified: cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt URL: http://svn.apache.org/viewvc/cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt?rev=1064700&r1=1064699&r2=1064700&view=diff ============================================================================== --- cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt (original) +++ cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt Fri Jan 28 14:35:54 2011 @@ -17,6 +17,7 @@ Changes/New Features Since 3.1M1: CAY-1508 Support for DataChannel filters CAY-1509 Lifecycle event annotations support CAY-1532 Import cayenne-lifecycle from sandbox +CAY-1533 Deprecate org.apache.cayenne.xml Bug Fixes Since 3.1M1: Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/CayenneDataObject.java URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/CayenneDataObject.java?rev=1064700&r1=1064699&r2=1064700&view=diff ============================================================================== --- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/CayenneDataObject.java (original) +++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/CayenneDataObject.java Fri Jan 28 14:35:54 2011 @@ -676,6 +676,12 @@ public class CayenneDataObject extends P * Encodes object to XML using provided encoder. * * @since 1.2 + * @deprecated since 3.1 this XML serialization package is deprecated and will be + * removed in the following releases. It has a number of functional and + * performance limitations that make it impossible to evolve further. A + * replacement may be provided in an undefined future. For now we + * recommend the users to implement XML serialization of persistent + * objects based JAXB, XStream or other similar frameworks. */ public void encodeAsXML(XMLEncoder encoder) { EntityResolver er = getObjectContext().getEntityResolver(); @@ -690,6 +696,14 @@ public class CayenneDataObject extends P } } + /** + * @deprecated since 3.1 this XML serialization package is deprecated and will be + * removed in the following releases. It has a number of functional and + * performance limitations that make it impossible to evolve further. A + * replacement may be provided in an undefined future. For now we + * recommend the users to implement XML serialization of persistent + * objects based JAXB, XStream or other similar frameworks. + */ public void decodeFromXML(XMLDecoder decoder) { DataChannel channel = BaseContext.getThreadDeserializationChannel(); Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/xml/SerializableEntity.java URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/xml/SerializableEntity.java?rev=1064700&r1=1064699&r2=1064700&view=diff ============================================================================== --- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/xml/SerializableEntity.java (original) +++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/xml/SerializableEntity.java Fri Jan 28 14:35:54 2011 @@ -30,6 +30,12 @@ import org.w3c.dom.Element; * A flyweight wrapper for serializing with XML mapping. This object is NOT thread-safe. * * @since 1.2 + * @deprecated since 3.1 this XML serialization package is deprecated and will be removed + * in the following releases. It has a number of functional and performance + * limitations that make it impossible to evolve further. A replacement may be + * provided in an undefined future. For now we recommend the users to + * implement XML serialization of persistent objects based JAXB, XStream or + * other similar frameworks. */ class SerializableEntity implements XMLSerializable { @@ -67,15 +73,16 @@ class SerializableEntity implements XMLS while (it.hasNext()) { encodeObject(encoder, it.next(), false); } - + // Make sure we pop the node we just pushed -- needed for fix to CAY-597. encoder.pop(); } } else { encodeObject(encoder, this.object, true); - - // Needed for fix to CAY-597. This makes sure we get back to the appropriate level in the DOM, rather than constantly re-rooting the tree. + + // Needed for fix to CAY-597. This makes sure we get back to the appropriate + // level in the DOM, rather than constantly re-rooting the tree. encoder.pop(); } } Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/xml/XMLDecoder.java URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/xml/XMLDecoder.java?rev=1064700&r1=1064699&r2=1064700&view=diff ============================================================================== --- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/xml/XMLDecoder.java (original) +++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/xml/XMLDecoder.java Fri Jan 28 14:35:54 2011 @@ -17,7 +17,6 @@ * under the License. ****************************************************************/ - package org.apache.cayenne.xml; import java.io.Reader; @@ -46,6 +45,12 @@ import org.xml.sax.InputSource; * XMLDecoder is used to decode XML into objects. * * @since 1.2 + * @deprecated since 3.1 this XML serialization package is deprecated and will be removed + * in the following releases. It has a number of functional and performance + * limitations that make it impossible to evolve further. A replacement may be + * provided in an undefined future. For now we recommend the users to + * implement XML serialization of persistent objects based JAXB, XStream or + * other similar frameworks. */ public class XMLDecoder { @@ -223,23 +228,28 @@ public class XMLDecoder { // If the object implements XMLSerializable, delegate decoding to the class's // implementation of decodeFromXML(). if (XMLSerializable.class.isAssignableFrom(objectClass)) { - // Fix for decoding 1-to-1 relationships between the same class type, per CAY-597. - // If we don't re-root the tree, the decoder goes into an infinite loop. In particular, - // if R1 -> R2, when it decodes R1, it will attempt to decode R2, but without re-rooting, - // the decoder tries to decode R1 again, think it's decoding R2, because R1 is the first - // element of that type found in the XML doc with the true root of the doc. + // Fix for decoding 1-to-1 relationships between the same class type, per + // CAY-597. + // If we don't re-root the tree, the decoder goes into an infinite loop. + // In particular, + // if R1 -> R2, when it decodes R1, it will attempt to decode R2, but + // without re-rooting, + // the decoder tries to decode R1 again, think it's decoding R2, because + // R1 is the first + // element of that type found in the XML doc with the true root of the + // doc. Element oldRoot = root; root = child; - + XMLSerializable ret = (XMLSerializable) objectClass.newInstance(); ret.decodeFromXML(this); // Restore the root when we're done decoding the child. root = oldRoot; - + return ret; } - + String text = XMLUtil.getText(child); // handle dates using hardcoded format.... @@ -249,12 +259,13 @@ public class XMLDecoder { } catch (ParseException e) { // handle pre-3.0 default data format for backwards compatibilty - + try { - return new SimpleDateFormat("E MMM dd hh:mm:ss z yyyy").parse(text); + return new SimpleDateFormat("E MMM dd hh:mm:ss z yyyy") + .parse(text); } catch (ParseException eOld) { - + // rethrow the original exception throw e; } @@ -367,14 +378,16 @@ public class XMLDecoder { * @return A List of all the decoded objects. * @throws CayenneRuntimeException */ - protected Collection decodeCollection(Element xml) throws CayenneRuntimeException { + protected Collection decodeCollection(Element xml) + throws CayenneRuntimeException { Collection ret; try { String parentClass = ((Element) xml.getParentNode()).getAttribute("type"); Object property = Class.forName(parentClass).newInstance(); - Collection c = (Collection) PropertyUtils.getProperty(property, xml - .getNodeName()); + Collection c = (Collection) PropertyUtils.getProperty( + property, + xml.getNodeName()); ret = c.getClass().newInstance(); } @@ -449,8 +462,10 @@ public class XMLDecoder { * @return The list of decoded DataObjects. * @throws CayenneRuntimeException */ - public static List decodeList(Reader xml, String mappingUrl, ObjectContext objectContext) - throws CayenneRuntimeException { + public static List decodeList( + Reader xml, + String mappingUrl, + ObjectContext objectContext) throws CayenneRuntimeException { XMLDecoder decoder = new XMLDecoder(objectContext); Element listRoot = parse(xml).getDocumentElement(); Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/xml/XMLEncoder.java URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/xml/XMLEncoder.java?rev=1064700&r1=1064699&r2=1064700&view=diff ============================================================================== --- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/xml/XMLEncoder.java (original) +++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/xml/XMLEncoder.java Fri Jan 28 14:35:54 2011 @@ -41,6 +41,12 @@ import org.w3c.dom.Node; * A helper class to encode objects to XML. * * @since 1.2 + * @deprecated since 3.1 this XML serialization package is deprecated and will be removed + * in the following releases. It has a number of functional and performance + * limitations that make it impossible to evolve further. A replacement may be + * provided in an undefined future. For now we recommend the users to + * implement XML serialization of persistent objects based JAXB, XStream or + * other similar frameworks. */ public class XMLEncoder { @@ -109,7 +115,8 @@ public class XMLEncoder { if (object instanceof Collection) { return nodeToString(getRootNode(true)); - } else { + } + else { return nodeToString(getRootNode(false)); } } @@ -145,7 +152,7 @@ public class XMLEncoder { // if synthetic root has a single child, use child as a root Node root = document.getDocumentElement(); - + if (!forceSyntheticRoot && root.getChildNodes().getLength() == 1) { root = root.getFirstChild(); } Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/xml/XMLMappingDescriptor.java URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/xml/XMLMappingDescriptor.java?rev=1064700&r1=1064699&r2=1064700&view=diff ============================================================================== --- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/xml/XMLMappingDescriptor.java (original) +++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/xml/XMLMappingDescriptor.java Fri Jan 28 14:35:54 2011 @@ -39,6 +39,12 @@ import org.w3c.dom.NamedNodeMap; * objects based upon the schema given by the map file. * * @since 1.2 + * @deprecated since 3.1 this XML serialization package is deprecated and will be removed + * in the following releases. It has a number of functional and performance + * limitations that make it impossible to evolve further. A replacement may be + * provided in an undefined future. For now we recommend the users to + * implement XML serialization of persistent objects based JAXB, XStream or + * other similar frameworks. */ final class XMLMappingDescriptor { @@ -97,14 +103,15 @@ final class XMLMappingDescriptor { * @return The decoded object. * @throws CayenneRuntimeException */ - Object decode(Element xml, ObjectContext objectContext) throws CayenneRuntimeException { + Object decode(Element xml, ObjectContext objectContext) + throws CayenneRuntimeException { // TODO: Add an error check to make sure the mapping file actually is for this // data file. // Store a local copy of the data context. this.objectContext = objectContext; - + // Create the object to be returned. Object ret = createObject(rootEntity.getDescriptor(), xml); @@ -232,8 +239,9 @@ final class XMLMappingDescriptor { throw new CayenneRuntimeException("Error creating instance of class " + className, ex); } - - // If a data context has been supplied by the user, then register the data object with the context. + + // If a data context has been supplied by the user, then register the data object + // with the context. if ((null != objectContext) && (object instanceof Persistent)) { objectContext.registerNewObject(object); } @@ -241,7 +249,8 @@ final class XMLMappingDescriptor { NamedNodeMap attributes = objectData.getAttributes(); for (int i = 0; i < attributes.getLength(); i++) { Attr attribute = (Attr) attributes.item(i); - String propertyName = getPropertyMappingName(entityMapping, attribute.getName()); + String propertyName = getPropertyMappingName(entityMapping, attribute + .getName()); if (propertyName != null) { PropertyUtils.setProperty(object, propertyName, attribute.getValue()); Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/xml/XMLSerializable.java URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/xml/XMLSerializable.java?rev=1064700&r1=1064699&r2=1064700&view=diff ============================================================================== --- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/xml/XMLSerializable.java (original) +++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/xml/XMLSerializable.java Fri Jan 28 14:35:54 2011 @@ -23,15 +23,22 @@ package org.apache.cayenne.xml; * Interface for Cayenne objects that can be saved to XML. * * @since 1.2 + * @deprecated since 3.1 this XML serialization package is deprecated and will be removed + * in the following releases. It has a number of functional and performance + * limitations that make it impossible to evolve further. A replacement may be + * provided in an undefined future. For now we recommend the users to + * implement XML serialization of persistent objects based JAXB, XStream or + * other similar frameworks. */ public interface XMLSerializable { + /** * Encodes itself as XML using the provided XMLEncoder. * * @param encoder The encoder object. */ public void encodeAsXML(XMLEncoder encoder); - + /** * Decodes itself from XML using the provided XMLDecoder. * Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/xml/XMLUtil.java URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/xml/XMLUtil.java?rev=1064700&r1=1064699&r2=1064700&view=diff ============================================================================== --- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/xml/XMLUtil.java (original) +++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/xml/XMLUtil.java Fri Jan 28 14:35:54 2011 @@ -38,11 +38,17 @@ import org.w3c.dom.NodeList; * Static utility methods to work with DOM trees. * * @since 1.2 + * @deprecated since 3.1 this XML serialization package is deprecated and will be removed + * in the following releases. It has a number of functional and performance + * limitations that make it impossible to evolve further. A replacement may be + * provided in an undefined future. For now we recommend the users to + * implement XML serialization of persistent objects based JAXB, XStream or + * other similar frameworks. */ class XMLUtil { - + // note that per CAY-792, to be locale-safe the format must not contain literal parts - static final String DEFAULT_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss zzz"; + static final String DEFAULT_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss zzz"; static DocumentBuilderFactory sharedFactory; @@ -123,8 +129,9 @@ class XMLUtil { * Returns all elements among the direct children that have a matching name. */ static List getChildren(Node node, final String name) { - + Predicate p = new Predicate() { + public boolean evaluate(Object object) { if (object instanceof Element) { Element e = (Element) object; @@ -143,7 +150,7 @@ class XMLUtil { static List getChildren(Node node) { NodeList list = node.getChildNodes(); int len = list.getLength(); - + List children = new ArrayList(len); for (int i = 0; i < len; i++) { Node child = list.item(i);