You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by aa...@apache.org on 2011/01/28 15:35:54 UTC
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/
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<Object> decodeCollection(Element xml) throws CayenneRuntimeException {
+ protected Collection<Object> decodeCollection(Element xml)
+ throws CayenneRuntimeException {
Collection<Object> ret;
try {
String parentClass = ((Element) xml.getParentNode()).getAttribute("type");
Object property = Class.forName(parentClass).newInstance();
- Collection<Object> c = (Collection<Object>) PropertyUtils.getProperty(property, xml
- .getNodeName());
+ Collection<Object> c = (Collection<Object>) 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<Object> decodeList(Reader xml, String mappingUrl, ObjectContext objectContext)
- throws CayenneRuntimeException {
+ public static List<Object> 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<Element> 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<Element> getChildren(Node node) {
NodeList list = node.getChildNodes();
int len = list.getLength();
-
+
List<Element> children = new ArrayList<Element>(len);
for (int i = 0; i < len; i++) {
Node child = list.item(i);