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 2009/12/17 16:46:09 UTC
svn commit: r891776 - in /cayenne/main/trunk: docs/doc/src/main/resources/
framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/
framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/
framework/caye...
Author: aadamchik
Date: Thu Dec 17 15:45:38 2009
New Revision: 891776
URL: http://svn.apache.org/viewvc?rev=891776&view=rev
Log:
CAY-1340 Implement ConfigurationNode / ConfigurationNodeVisitor for the Cayenne project tree, including DataMap objects.
Added:
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/BaseConfigurationNodeVisitor.java
cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/SaveableNodesGetter.java
- copied, changed from r891768, cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/ConfigurationNodesGetter.java
Removed:
cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/ConfigurationLocationSetter.java
cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/ConfigurationNodesGetter.java
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/access/DataDomainQuery.java
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/ConfigurationNode.java
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/ConfigurationNodeVisitor.java
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/DataNodeDescriptor.java
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/DefaultConfigurationNameMapper.java
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/DbAttribute.java
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/DbEntity.java
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/DbRelationship.java
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/Embeddable.java
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/EmbeddableAttribute.java
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ObjAttribute.java
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ObjEntity.java
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ObjRelationship.java
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/Procedure.java
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ProcedureParameter.java
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/AbstractQuery.java
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/BatchQuery.java
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/EJBQLQuery.java
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/IndirectQuery.java
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/Query.java
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/QueryChain.java
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/RefreshQuery.java
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/remote/IncrementalQuery.java
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/remote/RangeQuery.java
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/MockQuery.java
cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/ConfigurationSaver.java
cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/ConfigurationSourceGetter.java
cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/ConfigurationSourceSetter.java
cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/FileProjectSaver.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=891776&r1=891775&r2=891776&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 Thu Dec 17 15:45:38 2009
@@ -21,6 +21,7 @@
CAY-1319 Minimal DI container-based configuration to run Cayenne
CAY-1323 oracle.sql.TIMESTAMP in Result of query
CAY-1329 DI-based cayenne-project module
+CAY-1340 Implement ConfigurationNode / ConfigurationNodeVisitor for the Cayenne project tree, including DataMap objects.
Bug Fixes Since 3.0:
Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataDomainQuery.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataDomainQuery.java?rev=891776&r1=891775&r2=891776&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataDomainQuery.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataDomainQuery.java Thu Dec 17 15:45:38 2009
@@ -21,6 +21,7 @@
import java.util.List;
import java.util.Map;
+import org.apache.cayenne.configuration.ConfigurationNodeVisitor;
import org.apache.cayenne.map.DataMap;
import org.apache.cayenne.map.DbEntity;
import org.apache.cayenne.map.EntityResolver;
@@ -46,6 +47,13 @@
public SQLAction createSQLAction(SQLActionVisitor visitor) {
throw new UnsupportedOperationException("Not an executable query.");
}
+
+ /**
+ * @since 3.1
+ */
+ public <T> T acceptVisitor(ConfigurationNodeVisitor<T> visitor) {
+ return visitor.visitQuery(this);
+ }
public QueryMetadata getMetaData(EntityResolver resolver) {
return this;
Added: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/BaseConfigurationNodeVisitor.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/BaseConfigurationNodeVisitor.java?rev=891776&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/BaseConfigurationNodeVisitor.java (added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/BaseConfigurationNodeVisitor.java Thu Dec 17 15:45:38 2009
@@ -0,0 +1,101 @@
+/*****************************************************************
+ * 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.
+ ****************************************************************/
+package org.apache.cayenne.configuration;
+
+import org.apache.cayenne.map.DataMap;
+import org.apache.cayenne.map.DbAttribute;
+import org.apache.cayenne.map.DbEntity;
+import org.apache.cayenne.map.DbRelationship;
+import org.apache.cayenne.map.Embeddable;
+import org.apache.cayenne.map.EmbeddableAttribute;
+import org.apache.cayenne.map.ObjAttribute;
+import org.apache.cayenne.map.ObjEntity;
+import org.apache.cayenne.map.ObjRelationship;
+import org.apache.cayenne.map.Procedure;
+import org.apache.cayenne.map.ProcedureParameter;
+import org.apache.cayenne.query.Query;
+
+/**
+ * A {@link ConfigurationNodeVisitor} that does nothing, used as a convenience superclass
+ * for partial visitors. All methods of this visitor throw an
+ * {@link UnsupportedOperationException}.
+ *
+ * @since 3.1
+ */
+public abstract class BaseConfigurationNodeVisitor<T> implements
+ ConfigurationNodeVisitor<T> {
+
+ public T visitDataChannelDescriptor(DataChannelDescriptor channelDescriptor) {
+ throw new UnsupportedOperationException(
+ "Not implemented for DataChannelDescriptor");
+ }
+
+ public T visitDataMap(DataMap dataMap) {
+ throw new UnsupportedOperationException("Not implemented for DataMap");
+ }
+
+ public T visitDataNodeDescriptor(DataNodeDescriptor nodeDescriptor) {
+ throw new UnsupportedOperationException("Not implemented for DataNodeDescriptor");
+ }
+
+ public T visitDbAttribute(DbAttribute attribute) {
+ throw new UnsupportedOperationException("Not implemented for DbAttribute");
+ }
+
+ public T visitDbEntity(DbEntity entity) {
+ throw new UnsupportedOperationException("Not implemented for DbEntity");
+ }
+
+ public T visitDbRelationship(DbRelationship relationship) {
+ throw new UnsupportedOperationException("Not implemented for DbRelationship");
+ }
+
+ public T visitEmbeddable(Embeddable embeddable) {
+ throw new UnsupportedOperationException("Not implemented for Embeddable");
+ }
+
+ public T visitEmbeddableAttribute(EmbeddableAttribute attribute) {
+ throw new UnsupportedOperationException("Not implemented for EmbeddableAttribute");
+ }
+
+ public T visitObjAttribute(ObjAttribute attribute) {
+ throw new UnsupportedOperationException("Not implemented for ObjAttribute");
+ }
+
+ public T visitObjEntity(ObjEntity entity) {
+ throw new UnsupportedOperationException("Not implemented for ObjEntity");
+ }
+
+ public T visitObjRelationship(ObjRelationship relationship) {
+ throw new UnsupportedOperationException("Not implemented for ObjRelationship");
+ }
+
+ public T visitProcedure(Procedure procedure) {
+ throw new UnsupportedOperationException("Not implemented for Procedure");
+ }
+
+ public T visitProcedureParameter(ProcedureParameter parameter) {
+ throw new UnsupportedOperationException("Not implemented for ProcedureParameter");
+ }
+
+ public T visitQuery(Query query) {
+ throw new UnsupportedOperationException("Not implemented for Query");
+ }
+
+}
Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/ConfigurationNode.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/ConfigurationNode.java?rev=891776&r1=891775&r2=891776&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/ConfigurationNode.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/ConfigurationNode.java Thu Dec 17 15:45:38 2009
@@ -20,7 +20,7 @@
/**
* Implemented by the "nodes" on the Cayenne configuration tree. Allows to extract
- * information from the nodes or manipulate them in a consistent fashion.
+ * information from the nodes or manipulate them in a consistent manner.
*
* @since 3.1
*/
Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/ConfigurationNodeVisitor.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/ConfigurationNodeVisitor.java?rev=891776&r1=891775&r2=891776&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/ConfigurationNodeVisitor.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/ConfigurationNodeVisitor.java Thu Dec 17 15:45:38 2009
@@ -19,6 +19,17 @@
package org.apache.cayenne.configuration;
import org.apache.cayenne.map.DataMap;
+import org.apache.cayenne.map.DbAttribute;
+import org.apache.cayenne.map.DbEntity;
+import org.apache.cayenne.map.DbRelationship;
+import org.apache.cayenne.map.Embeddable;
+import org.apache.cayenne.map.EmbeddableAttribute;
+import org.apache.cayenne.map.ObjAttribute;
+import org.apache.cayenne.map.ObjEntity;
+import org.apache.cayenne.map.ObjRelationship;
+import org.apache.cayenne.map.Procedure;
+import org.apache.cayenne.map.ProcedureParameter;
+import org.apache.cayenne.query.Query;
/**
* A visitor interface for implementing operations on different types of
@@ -28,7 +39,31 @@
*/
public interface ConfigurationNodeVisitor<T> {
- T visitDataChannelDescriptor(DataChannelDescriptor node);
+ T visitDataChannelDescriptor(DataChannelDescriptor channelDescriptor);
- T visitDataMap(DataMap node);
+ T visitDataNodeDescriptor(DataNodeDescriptor nodeDescriptor);
+
+ T visitDataMap(DataMap dataMap);
+
+ T visitObjEntity(ObjEntity entity);
+
+ T visitDbEntity(DbEntity entity);
+
+ T visitEmbeddable(Embeddable embeddable);
+
+ T visitEmbeddableAttribute(EmbeddableAttribute attribute);
+
+ T visitObjAttribute(ObjAttribute attribute);
+
+ T visitDbAttribute(DbAttribute attribute);
+
+ T visitObjRelationship(ObjRelationship relationship);
+
+ T visitDbRelationship(DbRelationship relationship);
+
+ T visitProcedure(Procedure procedure);
+
+ T visitProcedureParameter(ProcedureParameter parameter);
+
+ T visitQuery(Query query);
}
Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/DataNodeDescriptor.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/DataNodeDescriptor.java?rev=891776&r1=891775&r2=891776&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/DataNodeDescriptor.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/DataNodeDescriptor.java Thu Dec 17 15:45:38 2009
@@ -34,7 +34,7 @@
*
* @since 3.1
*/
-public class DataNodeDescriptor implements XMLSerializable,
+public class DataNodeDescriptor implements ConfigurationNode, XMLSerializable,
Comparable<DataNodeDescriptor> {
protected String name;
@@ -75,6 +75,10 @@
}
}
+ public <T> T acceptVisitor(ConfigurationNodeVisitor<T> visitor) {
+ return visitor.visitDataNodeDescriptor(this);
+ }
+
public void encodeAsXML(XMLEncoder encoder) {
encoder.print("<node");
encoder.printlnAttribute("name", name);
Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/DefaultConfigurationNameMapper.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/DefaultConfigurationNameMapper.java?rev=891776&r1=891775&r2=891776&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/DefaultConfigurationNameMapper.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/DefaultConfigurationNameMapper.java Thu Dec 17 15:45:38 2009
@@ -34,7 +34,7 @@
protected ConfigurationNodeVisitor<String> nameMapper;
public DefaultConfigurationNameMapper() {
- this.nameMapper = new NameMapper();
+ nameMapper = new NameMapper();
}
public String configurationLocation(ConfigurationNode node) {
@@ -110,12 +110,14 @@
return name + DATA_MAP_SUFFIX;
}
- final class NameMapper implements ConfigurationNodeVisitor<String> {
+ final class NameMapper extends BaseConfigurationNodeVisitor<String> {
+ @Override
public String visitDataChannelDescriptor(DataChannelDescriptor descriptor) {
return getDataChannelName(descriptor.getName());
}
+ @Override
public String visitDataMap(DataMap dataMap) {
return getDataMapName(dataMap.getName());
}
Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/DbAttribute.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/DbAttribute.java?rev=891776&r1=891775&r2=891776&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/DbAttribute.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/DbAttribute.java Thu Dec 17 15:45:38 2009
@@ -19,6 +19,8 @@
package org.apache.cayenne.map;
+import org.apache.cayenne.configuration.ConfigurationNode;
+import org.apache.cayenne.configuration.ConfigurationNodeVisitor;
import org.apache.cayenne.dba.TypesMapping;
import org.apache.cayenne.map.event.AttributeEvent;
import org.apache.cayenne.map.event.DbAttributeListener;
@@ -27,9 +29,8 @@
/**
* A DbAttribute defines a descriptor for a single database table column.
- *
*/
-public class DbAttribute extends Attribute {
+public class DbAttribute extends Attribute implements ConfigurationNode {
/**
* Defines JDBC type of the column.
@@ -82,6 +83,10 @@
this.setEntity(entity);
}
+ public <T> T acceptVisitor(ConfigurationNodeVisitor<T> visitor) {
+ return visitor.visitDbAttribute(this);
+ }
+
/**
* Prints itself as XML to the provided XMLEncoder.
*
@@ -173,7 +178,7 @@
}
for (Relationship relationship : getEntity().getRelationships()) {
- for (DbJoin join : ((DbRelationship)relationship).getJoins()) {
+ for (DbJoin join : ((DbRelationship) relationship).getJoins()) {
if (name.equals(join.getSourceName())) {
DbAttribute target = join.getTarget();
if (target != null && target.isPrimaryKey()) {
Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/DbEntity.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/DbEntity.java?rev=891776&r1=891775&r2=891776&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/DbEntity.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/DbEntity.java Thu Dec 17 15:45:38 2009
@@ -30,6 +30,8 @@
import org.apache.cayenne.CayenneRuntimeException;
import org.apache.cayenne.ObjectId;
+import org.apache.cayenne.configuration.ConfigurationNode;
+import org.apache.cayenne.configuration.ConfigurationNodeVisitor;
import org.apache.cayenne.exp.Expression;
import org.apache.cayenne.exp.ExpressionException;
import org.apache.cayenne.exp.ExpressionFactory;
@@ -48,7 +50,7 @@
/**
* A DbEntity is a mapping descriptor that defines a structure of a database table.
*/
-public class DbEntity extends Entity implements DbEntityListener, DbAttributeListener,
+public class DbEntity extends Entity implements ConfigurationNode, DbEntityListener, DbAttributeListener,
DbRelationshipListener {
protected String catalog;
@@ -83,6 +85,13 @@
this();
this.setName(name);
}
+
+ /**
+ * @since 3.1
+ */
+ public <T> T acceptVisitor(ConfigurationNodeVisitor<T> visitor) {
+ return visitor.visitDbEntity(this);
+ }
/**
* Prints itself as XML to the provided XMLEncoder.
Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/DbRelationship.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/DbRelationship.java?rev=891776&r1=891775&r2=891776&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/DbRelationship.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/DbRelationship.java Thu Dec 17 15:45:38 2009
@@ -27,6 +27,8 @@
import java.util.Map;
import org.apache.cayenne.CayenneRuntimeException;
+import org.apache.cayenne.configuration.ConfigurationNode;
+import org.apache.cayenne.configuration.ConfigurationNodeVisitor;
import org.apache.cayenne.util.Util;
import org.apache.cayenne.util.XMLEncoder;
import org.apache.commons.collections.CollectionUtils;
@@ -36,7 +38,7 @@
* A DbRelationship is a descriptor of a database inter-table relationship based on one or
* more primary key/foreign key pairs.
*/
-public class DbRelationship extends Relationship {
+public class DbRelationship extends Relationship implements ConfigurationNode {
// The columns through which the join is implemented.
protected List<DbJoin> joins = new ArrayList<DbJoin>(2);
@@ -53,6 +55,13 @@
public DbRelationship(String name) {
super(name);
}
+
+ /**
+ * @since 3.1
+ */
+ public <T> T acceptVisitor(ConfigurationNodeVisitor<T> visitor) {
+ return visitor.visitDbRelationship(this);
+ }
/**
* Prints itself as XML to the provided XMLEncoder.
Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/Embeddable.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/Embeddable.java?rev=891776&r1=891775&r2=891776&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/Embeddable.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/Embeddable.java Thu Dec 17 15:45:38 2009
@@ -25,6 +25,8 @@
import java.util.TreeMap;
import org.apache.cayenne.CayenneRuntimeException;
+import org.apache.cayenne.configuration.ConfigurationNode;
+import org.apache.cayenne.configuration.ConfigurationNodeVisitor;
import org.apache.cayenne.util.Util;
import org.apache.cayenne.util.XMLEncoder;
import org.apache.cayenne.util.XMLSerializable;
@@ -37,7 +39,7 @@
*
* @since 3.0
*/
-public class Embeddable implements XMLSerializable, Serializable {
+public class Embeddable implements ConfigurationNode, XMLSerializable, Serializable {
protected String className;
protected SortedMap<String, EmbeddableAttribute> attributes;
@@ -52,12 +54,17 @@
this.className = className;
}
-
+ /**
+ * @since 3.1
+ */
+ public <T> T acceptVisitor(ConfigurationNodeVisitor<T> visitor) {
+ return visitor.visitEmbeddable(this);
+ }
+
public DataMap getDataMap() {
return dataMap;
}
-
public void setDataMap(DataMap dataMap) {
this.dataMap = dataMap;
}
Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/EmbeddableAttribute.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/EmbeddableAttribute.java?rev=891776&r1=891775&r2=891776&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/EmbeddableAttribute.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/EmbeddableAttribute.java Thu Dec 17 15:45:38 2009
@@ -20,6 +20,8 @@
import java.io.Serializable;
+import org.apache.cayenne.configuration.ConfigurationNode;
+import org.apache.cayenne.configuration.ConfigurationNodeVisitor;
import org.apache.cayenne.util.Util;
import org.apache.cayenne.util.XMLEncoder;
import org.apache.cayenne.util.XMLSerializable;
@@ -29,7 +31,8 @@
*
* @since 3.0
*/
-public class EmbeddableAttribute implements XMLSerializable, Serializable {
+public class EmbeddableAttribute implements ConfigurationNode, XMLSerializable,
+ Serializable {
protected String name;
protected String type;
@@ -45,6 +48,13 @@
this.name = name;
}
+ /**
+ * @since 3.1
+ */
+ public <T> T acceptVisitor(ConfigurationNodeVisitor<T> visitor) {
+ return visitor.visitEmbeddableAttribute(this);
+ }
+
public void encodeAsXML(XMLEncoder encoder) {
encoder.print("<embeddable-attribute name=\"" + getName() + '\"');
Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ObjAttribute.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ObjAttribute.java?rev=891776&r1=891775&r2=891776&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ObjAttribute.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ObjAttribute.java Thu Dec 17 15:45:38 2009
@@ -22,6 +22,8 @@
import java.util.Iterator;
import org.apache.cayenne.CayenneRuntimeException;
+import org.apache.cayenne.configuration.ConfigurationNode;
+import org.apache.cayenne.configuration.ConfigurationNodeVisitor;
import org.apache.cayenne.util.CayenneMapEntry;
import org.apache.cayenne.util.Util;
import org.apache.cayenne.util.XMLEncoder;
@@ -30,7 +32,7 @@
/**
* An ObjAttribute is a mapping descriptor of a Java class property.
*/
-public class ObjAttribute extends Attribute {
+public class ObjAttribute extends Attribute implements ConfigurationNode {
protected String type;
protected boolean usedForLocking;
@@ -63,6 +65,13 @@
}
/**
+ * @since 3.1
+ */
+ public <T> T acceptVisitor(ConfigurationNodeVisitor<T> visitor) {
+ return visitor.visitObjAttribute(this);
+ }
+
+ /**
* Returns Java class of an object property described by this attribute. Wraps any
* thrown exceptions into CayenneRuntimeException.
*/
Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ObjEntity.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ObjEntity.java?rev=891776&r1=891775&r2=891776&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ObjEntity.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ObjEntity.java Thu Dec 17 15:45:38 2009
@@ -30,6 +30,8 @@
import java.util.TreeMap;
import org.apache.cayenne.CayenneRuntimeException;
+import org.apache.cayenne.configuration.ConfigurationNode;
+import org.apache.cayenne.configuration.ConfigurationNodeVisitor;
import org.apache.cayenne.dba.TypesMapping;
import org.apache.cayenne.exp.Expression;
import org.apache.cayenne.exp.ExpressionException;
@@ -46,7 +48,7 @@
* ObjEntity is a mapping descriptor for a DataObject Java class. It contains the
* information about the Java class itself, as well as its mapping to the DbEntity layer.
*/
-public class ObjEntity extends Entity implements ObjEntityListener {
+public class ObjEntity extends Entity implements ObjEntityListener, ConfigurationNode {
final public static int LOCK_TYPE_NONE = 0;
final public static int LOCK_TYPE_OPTIMISTIC = 1;
@@ -92,6 +94,13 @@
this.entityListeners = new ArrayList<EntityListener>(2);
this.attributeOverrides = new TreeMap<String, String>();
}
+
+ /**
+ * @since 3.1
+ */
+ public <T> T acceptVisitor(ConfigurationNodeVisitor<T> visitor) {
+ return visitor.visitObjEntity(this);
+ }
/**
* Prints itself as XML to the provided XMLEncoder.
Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ObjRelationship.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ObjRelationship.java?rev=891776&r1=891775&r2=891776&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ObjRelationship.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ObjRelationship.java Thu Dec 17 15:45:38 2009
@@ -26,6 +26,8 @@
import java.util.ListIterator;
import org.apache.cayenne.CayenneRuntimeException;
+import org.apache.cayenne.configuration.ConfigurationNode;
+import org.apache.cayenne.configuration.ConfigurationNodeVisitor;
import org.apache.cayenne.exp.ExpressionException;
import org.apache.cayenne.exp.parser.ASTDbPath;
import org.apache.cayenne.util.CayenneMapEntry;
@@ -37,7 +39,7 @@
* Describes an association between two Java classes mapped as source and target
* ObjEntity. Maps to a path of DbRelationships.
*/
-public class ObjRelationship extends Relationship {
+public class ObjRelationship extends Relationship implements ConfigurationNode {
/**
* Denotes a default type of to-many relationship collection which is a Java List.
@@ -82,6 +84,13 @@
public ObjRelationship(String name) {
super(name);
}
+
+ /**
+ * @since 3.1
+ */
+ public <T> T acceptVisitor(ConfigurationNodeVisitor<T> visitor) {
+ return visitor.visitObjRelationship(this);
+ }
/**
* Prints itself as XML to the provided XMLEncoder.
Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/Procedure.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/Procedure.java?rev=891776&r1=891775&r2=891776&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/Procedure.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/Procedure.java Thu Dec 17 15:45:38 2009
@@ -24,6 +24,8 @@
import java.util.Collections;
import java.util.List;
+import org.apache.cayenne.configuration.ConfigurationNode;
+import org.apache.cayenne.configuration.ConfigurationNodeVisitor;
import org.apache.cayenne.util.CayenneMapEntry;
import org.apache.cayenne.util.Util;
import org.apache.cayenne.util.XMLEncoder;
@@ -31,9 +33,9 @@
/**
* A mapping descriptor for a database stored procedure.
- *
*/
-public class Procedure implements CayenneMapEntry, XMLSerializable, Serializable {
+public class Procedure implements ConfigurationNode, CayenneMapEntry, XMLSerializable,
+ Serializable {
protected String name;
protected DataMap dataMap;
@@ -55,6 +57,13 @@
public Procedure(String name) {
setName(name);
}
+
+ /**
+ * @since 3.1
+ */
+ public <T> T acceptVisitor(ConfigurationNodeVisitor<T> visitor) {
+ return visitor.visitProcedure(this);
+ }
public String getName() {
return name;
Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ProcedureParameter.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ProcedureParameter.java?rev=891776&r1=891775&r2=891776&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ProcedureParameter.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ProcedureParameter.java Thu Dec 17 15:45:38 2009
@@ -21,6 +21,8 @@
import java.io.Serializable;
+import org.apache.cayenne.configuration.ConfigurationNode;
+import org.apache.cayenne.configuration.ConfigurationNodeVisitor;
import org.apache.cayenne.dba.TypesMapping;
import org.apache.cayenne.util.CayenneMapEntry;
import org.apache.cayenne.util.Util;
@@ -29,9 +31,9 @@
/**
* A descriptor for the Procedure parameter.
- *
*/
-public class ProcedureParameter implements CayenneMapEntry, XMLSerializable, Serializable {
+public class ProcedureParameter implements ConfigurationNode, CayenneMapEntry,
+ XMLSerializable, Serializable {
public static final int IN_OUT_PARAMETER = 3;
public static final int IN_PARAMETER = 1;
@@ -64,6 +66,10 @@
setType(type);
setDirection(direction);
}
+
+ public <T> T acceptVisitor(ConfigurationNodeVisitor<T> visitor) {
+ return visitor.visitProcedureParameter(this);
+ }
public String getName() {
return name;
Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/AbstractQuery.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/AbstractQuery.java?rev=891776&r1=891775&r2=891776&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/AbstractQuery.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/AbstractQuery.java Thu Dec 17 15:45:38 2009
@@ -20,6 +20,7 @@
package org.apache.cayenne.query;
import org.apache.cayenne.CayenneRuntimeException;
+import org.apache.cayenne.configuration.ConfigurationNodeVisitor;
import org.apache.cayenne.map.DataMap;
import org.apache.cayenne.map.DbEntity;
import org.apache.cayenne.map.EntityResolver;
@@ -39,6 +40,13 @@
*/
protected Object root;
protected String name;
+
+ /**
+ * @since 3.1
+ */
+ public <T> T acceptVisitor(ConfigurationNodeVisitor<T> visitor) {
+ return visitor.visitQuery(this);
+ }
/**
* Returns a symbolic name of the query.
Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/BatchQuery.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/BatchQuery.java?rev=891776&r1=891775&r2=891776&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/BatchQuery.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/BatchQuery.java Thu Dec 17 15:45:38 2009
@@ -24,6 +24,7 @@
import org.apache.cayenne.CayenneRuntimeException;
import org.apache.cayenne.ObjectId;
+import org.apache.cayenne.configuration.ConfigurationNodeVisitor;
import org.apache.cayenne.map.DbAttribute;
import org.apache.cayenne.map.DbEntity;
import org.apache.cayenne.map.EntityResolver;
@@ -53,6 +54,10 @@
this.dbEntity = dbEntity;
this.batchIndex = -1;
}
+
+ public <T> T acceptVisitor(ConfigurationNodeVisitor<T> visitor) {
+ return visitor.visitQuery(this);
+ }
public String getName() {
return name;
Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/EJBQLQuery.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/EJBQLQuery.java?rev=891776&r1=891775&r2=891776&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/EJBQLQuery.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/EJBQLQuery.java Thu Dec 17 15:45:38 2009
@@ -23,6 +23,7 @@
import java.util.Map;
import org.apache.cayenne.CayenneRuntimeException;
+import org.apache.cayenne.configuration.ConfigurationNodeVisitor;
import org.apache.cayenne.ejbql.EJBQLCompiledExpression;
import org.apache.cayenne.ejbql.EJBQLException;
import org.apache.cayenne.ejbql.EJBQLParserFactory;
@@ -52,6 +53,10 @@
public EJBQLQuery() {
}
+
+ public <T> T acceptVisitor(ConfigurationNodeVisitor<T> visitor) {
+ return visitor.visitQuery(this);
+ }
public void initWithProperties(Map<String, ?> properties) {
Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/IndirectQuery.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/IndirectQuery.java?rev=891776&r1=891775&r2=891776&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/IndirectQuery.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/IndirectQuery.java Thu Dec 17 15:45:38 2009
@@ -20,6 +20,7 @@
package org.apache.cayenne.query;
import org.apache.cayenne.CayenneRuntimeException;
+import org.apache.cayenne.configuration.ConfigurationNodeVisitor;
import org.apache.cayenne.map.EntityResolver;
/**
@@ -36,6 +37,13 @@
protected transient EntityResolver lastResolver;
/**
+ * @since 3.1
+ */
+ public <T> T acceptVisitor(ConfigurationNodeVisitor<T> visitor) {
+ return visitor.visitQuery(this);
+ }
+
+ /**
* Returns the metadata obtained from the replacement query.
*/
public QueryMetadata getMetaData(EntityResolver resolver) {
Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/Query.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/Query.java?rev=891776&r1=891775&r2=891776&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/Query.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/Query.java Thu Dec 17 15:45:38 2009
@@ -22,13 +22,14 @@
import java.io.Serializable;
import org.apache.cayenne.access.QueryEngine;
+import org.apache.cayenne.configuration.ConfigurationNode;
import org.apache.cayenne.map.EntityResolver;
/**
* Defines minimal API of a query descriptor that is executable via Cayenne.
*
*/
-public interface Query extends Serializable {
+public interface Query extends Serializable, ConfigurationNode {
/**
* Returns query runtime parameters. The method is called at various stages of the
Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/QueryChain.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/QueryChain.java?rev=891776&r1=891775&r2=891776&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/QueryChain.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/QueryChain.java Thu Dec 17 15:45:38 2009
@@ -24,6 +24,7 @@
import java.util.Collection;
import org.apache.cayenne.CayenneRuntimeException;
+import org.apache.cayenne.configuration.ConfigurationNodeVisitor;
import org.apache.cayenne.map.EntityResolver;
/**
@@ -61,6 +62,13 @@
this.chain = new ArrayList<Query>(queries);
}
}
+
+ /**
+ * @since 3.1
+ */
+ public <T> T acceptVisitor(ConfigurationNodeVisitor<T> visitor) {
+ return visitor.visitQuery(this);
+ }
/**
* Adds a query to the chain.
Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/RefreshQuery.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/RefreshQuery.java?rev=891776&r1=891775&r2=891776&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/RefreshQuery.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/RefreshQuery.java Thu Dec 17 15:45:38 2009
@@ -23,6 +23,7 @@
import org.apache.cayenne.CayenneRuntimeException;
import org.apache.cayenne.Persistent;
+import org.apache.cayenne.configuration.ConfigurationNodeVisitor;
import org.apache.cayenne.map.EntityResolver;
/**
@@ -75,6 +76,13 @@
public RefreshQuery(String... groupKeys) {
this.groupKeys = groupKeys;
}
+
+ /**
+ * @since 3.1
+ */
+ public <T> T acceptVisitor(ConfigurationNodeVisitor<T> visitor) {
+ return visitor.visitQuery(this);
+ }
public QueryMetadata getMetaData(EntityResolver resolver) {
return new BaseQueryMetadata();
@@ -119,6 +127,10 @@
public SQLAction createSQLAction(SQLActionVisitor visitor) {
throw new CayenneRuntimeException("Unsupported");
}
+
+ public <T> T acceptVisitor(ConfigurationNodeVisitor<T> visitor) {
+ return visitor.visitQuery(this);
+ }
public QueryMetadata getMetaData(EntityResolver resolver) {
QueryMetadata md = query.getMetaData(resolver);
Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/remote/IncrementalQuery.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/remote/IncrementalQuery.java?rev=891776&r1=891775&r2=891776&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/remote/IncrementalQuery.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/remote/IncrementalQuery.java Thu Dec 17 15:45:38 2009
@@ -22,6 +22,7 @@
import java.util.List;
import java.util.Map;
+import org.apache.cayenne.configuration.ConfigurationNodeVisitor;
import org.apache.cayenne.map.DataMap;
import org.apache.cayenne.map.DbEntity;
import org.apache.cayenne.map.EntityResolver;
@@ -52,6 +53,13 @@
this.query = query;
this.cacheKey = cacheKey;
}
+
+ /**
+ * @since 3.1
+ */
+ public <T> T acceptVisitor(ConfigurationNodeVisitor<T> visitor) {
+ return visitor.visitQuery(this);
+ }
public QueryMetadata getMetaData(EntityResolver resolver) {
final QueryMetadata metadata = query.getMetaData(resolver);
Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/remote/RangeQuery.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/remote/RangeQuery.java?rev=891776&r1=891775&r2=891776&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/remote/RangeQuery.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/remote/RangeQuery.java Thu Dec 17 15:45:38 2009
@@ -22,6 +22,7 @@
import java.util.List;
import java.util.Map;
+import org.apache.cayenne.configuration.ConfigurationNodeVisitor;
import org.apache.cayenne.map.DataMap;
import org.apache.cayenne.map.DbEntity;
import org.apache.cayenne.map.EntityResolver;
@@ -67,6 +68,13 @@
this.originatingQuery = originatingQuery;
}
+ /**
+ * @since 3.1
+ */
+ public <T> T acceptVisitor(ConfigurationNodeVisitor<T> visitor) {
+ return visitor.visitQuery(this);
+ }
+
public QueryMetadata getMetaData(EntityResolver resolver) {
final QueryMetadata originatingMetadata = originatingQuery.getMetaData(resolver);
Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/MockQuery.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/MockQuery.java?rev=891776&r1=891775&r2=891776&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/MockQuery.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/MockQuery.java Thu Dec 17 15:45:38 2009
@@ -19,6 +19,7 @@
package org.apache.cayenne.query;
+import org.apache.cayenne.configuration.ConfigurationNodeVisitor;
import org.apache.cayenne.map.EntityResolver;
public class MockQuery implements Query {
@@ -37,6 +38,10 @@
public MockQuery(String name) {
this.name = name;
}
+
+ public <T> T acceptVisitor(ConfigurationNodeVisitor<T> visitor) {
+ return visitor.visitQuery(this);
+ }
public QueryMetadata getMetaData(EntityResolver resolver) {
return DefaultQueryMetadata.defaultMetadata;
Modified: cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/ConfigurationSaver.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/ConfigurationSaver.java?rev=891776&r1=891775&r2=891776&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/ConfigurationSaver.java (original)
+++ cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/ConfigurationSaver.java Thu Dec 17 15:45:38 2009
@@ -20,7 +20,7 @@
import java.io.PrintWriter;
-import org.apache.cayenne.configuration.ConfigurationNodeVisitor;
+import org.apache.cayenne.configuration.BaseConfigurationNodeVisitor;
import org.apache.cayenne.configuration.DataChannelDescriptor;
import org.apache.cayenne.map.DataMap;
import org.apache.cayenne.util.XMLEncoder;
@@ -28,7 +28,7 @@
/**
* @since 3.1
*/
-class ConfigurationSaver implements ConfigurationNodeVisitor<Void> {
+class ConfigurationSaver extends BaseConfigurationNodeVisitor<Void> {
private PrintWriter printWriter;
private String version;
@@ -38,6 +38,7 @@
this.version = version;
}
+ @Override
public Void visitDataChannelDescriptor(DataChannelDescriptor node) {
XMLEncoder encoder = new XMLEncoder(printWriter, "\t", version);
printXMLHeader(encoder);
@@ -45,6 +46,7 @@
return null;
}
+ @Override
public Void visitDataMap(DataMap node) {
XMLEncoder encoder = new XMLEncoder(printWriter, "\t", version);
printXMLHeader(encoder);
Modified: cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/ConfigurationSourceGetter.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/ConfigurationSourceGetter.java?rev=891776&r1=891775&r2=891776&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/ConfigurationSourceGetter.java (original)
+++ cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/ConfigurationSourceGetter.java Thu Dec 17 15:45:38 2009
@@ -18,7 +18,7 @@
****************************************************************/
package org.apache.cayenne.project2;
-import org.apache.cayenne.configuration.ConfigurationNodeVisitor;
+import org.apache.cayenne.configuration.BaseConfigurationNodeVisitor;
import org.apache.cayenne.configuration.DataChannelDescriptor;
import org.apache.cayenne.map.DataMap;
import org.apache.cayenne.resource.Resource;
@@ -28,12 +28,14 @@
*
* @since 3.1
*/
-class ConfigurationSourceGetter implements ConfigurationNodeVisitor<Resource> {
+class ConfigurationSourceGetter extends BaseConfigurationNodeVisitor<Resource> {
+ @Override
public Resource visitDataChannelDescriptor(DataChannelDescriptor descriptor) {
return descriptor.getConfigurationSource();
}
+ @Override
public Resource visitDataMap(DataMap dataMap) {
return dataMap.getConfigurationSource();
}
Modified: cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/ConfigurationSourceSetter.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/ConfigurationSourceSetter.java?rev=891776&r1=891775&r2=891776&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/ConfigurationSourceSetter.java (original)
+++ cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/ConfigurationSourceSetter.java Thu Dec 17 15:45:38 2009
@@ -18,7 +18,7 @@
****************************************************************/
package org.apache.cayenne.project2;
-import org.apache.cayenne.configuration.ConfigurationNodeVisitor;
+import org.apache.cayenne.configuration.BaseConfigurationNodeVisitor;
import org.apache.cayenne.configuration.DataChannelDescriptor;
import org.apache.cayenne.configuration.DataNodeDescriptor;
import org.apache.cayenne.map.DataMap;
@@ -29,7 +29,7 @@
*
* @since 3.1
*/
-class ConfigurationSourceSetter implements ConfigurationNodeVisitor<Void> {
+class ConfigurationSourceSetter extends BaseConfigurationNodeVisitor<Void> {
private Resource configurationSource;
@@ -37,6 +37,7 @@
this.configurationSource = configurationSource;
}
+ @Override
public Void visitDataChannelDescriptor(DataChannelDescriptor node) {
node.setConfigurationSource(configurationSource);
@@ -47,6 +48,7 @@
return null;
}
+ @Override
public Void visitDataMap(DataMap node) {
node.setConfigurationSource(configurationSource);
return null;
Modified: cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/FileProjectSaver.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/FileProjectSaver.java?rev=891776&r1=891775&r2=891776&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/FileProjectSaver.java (original)
+++ cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/FileProjectSaver.java Thu Dec 17 15:45:38 2009
@@ -50,12 +50,12 @@
protected ConfigurationNameMapper nameMapper;
protected ConfigurationNodeVisitor<Resource> resourceGetter;
- protected ConfigurationNodeVisitor<Collection<ConfigurationNode>> nodesGetter;
+ protected ConfigurationNodeVisitor<Collection<ConfigurationNode>> saveableNodesGetter;
protected String fileEncoding;
public FileProjectSaver() {
resourceGetter = new ConfigurationSourceGetter();
- nodesGetter = new ConfigurationNodesGetter();
+ saveableNodesGetter = new SaveableNodesGetter();
// this is not configurable yet... probably doesn't have to be
fileEncoding = "UTF-8";
@@ -68,7 +68,7 @@
public void save(Project project) {
Collection<ConfigurationNode> nodes = project.getRootNode().acceptVisitor(
- nodesGetter);
+ saveableNodesGetter);
Collection<SaveUnit> saveUnits = new ArrayList<SaveUnit>(nodes.size());
for (ConfigurationNode node : nodes) {
@@ -85,7 +85,7 @@
}
Collection<ConfigurationNode> nodes = project.getRootNode().acceptVisitor(
- nodesGetter);
+ saveableNodesGetter);
Collection<SaveUnit> saveUnits = new ArrayList<SaveUnit>(nodes.size());
for (ConfigurationNode node : nodes) {
@@ -96,7 +96,6 @@
}
void save(Collection<SaveUnit> units, boolean deleteOldResources) {
- initLocations(units);
checkAccess(units);
try {
@@ -142,19 +141,9 @@
e.getMessage());
}
- unit.targetLocation = targetLocation;
return unit;
}
- /**
- * @deprecated since 3.1 location is deprecated.
- */
- void initLocations(Collection<SaveUnit> units) {
- for (SaveUnit unit : units) {
- unit.node.acceptVisitor(new ConfigurationLocationSetter(unit.targetLocation));
- }
- }
-
void checkAccess(Collection<SaveUnit> units) {
for (SaveUnit unit : units) {
@@ -331,10 +320,5 @@
private File targetFile;
private File targetTempFile;
- /**
- * @deprecated since 3.1 explicit location tracking is unneeded
- */
- private String targetLocation;
-
}
}
Copied: cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/SaveableNodesGetter.java (from r891768, cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/ConfigurationNodesGetter.java)
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/SaveableNodesGetter.java?p2=cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/SaveableNodesGetter.java&p1=cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/ConfigurationNodesGetter.java&r1=891768&r2=891776&rev=891776&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/ConfigurationNodesGetter.java (original)
+++ cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/SaveableNodesGetter.java Thu Dec 17 15:45:38 2009
@@ -22,17 +22,18 @@
import java.util.Collection;
import java.util.Collections;
+import org.apache.cayenne.configuration.BaseConfigurationNodeVisitor;
import org.apache.cayenne.configuration.ConfigurationNode;
-import org.apache.cayenne.configuration.ConfigurationNodeVisitor;
import org.apache.cayenne.configuration.DataChannelDescriptor;
import org.apache.cayenne.map.DataMap;
/**
* @since 3.1
*/
-class ConfigurationNodesGetter implements
- ConfigurationNodeVisitor<Collection<ConfigurationNode>> {
+class SaveableNodesGetter extends
+ BaseConfigurationNodeVisitor<Collection<ConfigurationNode>> {
+ @Override
public Collection<ConfigurationNode> visitDataChannelDescriptor(
DataChannelDescriptor descriptor) {
@@ -46,6 +47,7 @@
return nodes;
}
+ @Override
public Collection<ConfigurationNode> visitDataMap(DataMap dataMap) {
return Collections.<ConfigurationNode> singletonList(dataMap);
}