Author: aadamchik
Date: Fri Sep 22 12:54:40 2006
New Revision: 449067
URL: http://svn.apache.org/viewvc?view=rev&rev=449067
Log:
CAY-660 - major refactoring to store entity callbacks in the EntityResolver to
be able to reuse them across the stack
Added:
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/map/CallbackOnEntity.java
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/map/CallbackOnListener.java
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/map/LifecycleEventCallback.java
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/map/LifecycleEventCallbackMap.java
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/map/CallbackOnEntityTst.java
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/map/CallbackOnListenerTst.java
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/map/MockCallingBackEntity.java
- copied, changed from r448439,
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/intercept/MockCallingBackEntity.java
Removed:
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/intercept/CallbackMap.java
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/intercept/EntityCallback.java
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/intercept/ListenerCallback.java
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/intercept/EntityCallbackTst.java
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/intercept/ListenerCallbackTst.java
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/intercept/MockCallingBackEntity.java
Modified:
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/intercept/DataChannelCallbackInterceptor.java
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/intercept/ObjectContextCallbackInterceptor.java
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/map/EntityResolver.java
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/intercept/DataChannelCallbackInterceptorTst.java
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/intercept/ObjectContextCallbackInterceptorTst.java
Modified:
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/intercept/DataChannelCallbackInterceptor.java
URL:
http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/intercept/DataChannelCallbackInterceptor.java?view=diff&rev=449067&r1=449066&r2=449067
==============================================================================
---
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/intercept/DataChannelCallbackInterceptor.java
(original)
+++
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/intercept/DataChannelCallbackInterceptor.java
Fri Sep 22 12:54:40 2006
@@ -30,6 +30,9 @@
import org.apache.cayenne.graph.GraphChangeHandler;
import org.apache.cayenne.graph.GraphDiff;
import org.apache.cayenne.graph.GraphManager;
+import org.apache.cayenne.map.EntityResolver;
+import org.apache.cayenne.map.LifecycleEventCallback;
+import org.apache.cayenne.map.LifecycleEventCallbackMap;
import org.apache.cayenne.query.Query;
/**
@@ -47,19 +50,48 @@
*/
public class DataChannelCallbackInterceptor extends DataChannelDecorator {
- protected boolean empty;
+ protected LifecycleEventCallbackMap preUpdate;
+ protected LifecycleEventCallbackMap postPersist;
+ protected LifecycleEventCallbackMap postRemove;
+ protected LifecycleEventCallbackMap postUpdate;
+ protected LifecycleEventCallbackMap postLoad;
+
+ public void setChannel(DataChannel channel) {
+ this.channel = channel;
+
+ // init callback ivars for faster access...
+ if (channel != null) {
+ EntityResolver resolver = getEntityResolver();
+
+ preUpdate =
resolver.getCallbacks(LifecycleEventCallback.PRE_UPDATE);
+ postPersist =
resolver.getCallbacks(LifecycleEventCallback.POST_PERSIST);
+ postRemove =
resolver.getCallbacks(LifecycleEventCallback.POST_REMOVE);
+ postUpdate =
resolver.getCallbacks(LifecycleEventCallback.POST_UPDATE);
+ postLoad = resolver.getCallbacks(LifecycleEventCallback.POST_LOAD);
+ }
+ else {
+ preUpdate = null;
+ postPersist = null;
+ postRemove = null;
+ postUpdate = null;
+ postLoad = null;
+ }
+ }
- CallbackMap preUpdate = new CallbackMap();
- CallbackMap postUpdate = new CallbackMap();
- CallbackMap postPersist = new CallbackMap();
- CallbackMap postRemove = new CallbackMap();
- CallbackMap postLoad = new CallbackMap();
+ protected boolean isEmpty() {
+ return preUpdate.isEmpty()
+ && postPersist.isEmpty()
+ && postRemove.isEmpty()
+ && postUpdate.isEmpty()
+ && postLoad.isEmpty();
+ }
public QueryResponse onQuery(ObjectContext originatingContext, Query
query) {
- QueryResponse response = super.onQuery(originatingContext, query);
+ QueryResponse response = channel.onQuery(originatingContext, query);
// TODO: andrus, 9/21/2006 - this method incorrectly calls "postLoad"
when query
// refresh flag is set to false and object is already there.
+
if (!postLoad.isEmpty()) {
List list = response.firstList();
@@ -67,7 +99,7 @@
&& !list.isEmpty()
&&
!(query.getMetaData(originatingContext.getEntityResolver()))
.isFetchingDataRows()) {
- postLoad.applyCallbacks(list);
+ postLoad.performCallbacks(list);
}
}
@@ -80,81 +112,18 @@
int syncType) {
if (isEmpty()) {
- return super.onSync(originatingContext, changes, syncType);
+ return channel.onSync(originatingContext, changes, syncType);
}
CommitState commitState = new CommitState(originatingContext, changes);
commitState.applyPreCommit(syncType);
- GraphDiff parentDiff = super.onSync(originatingContext, changes,
syncType);
+ GraphDiff parentDiff = channel.onSync(originatingContext, changes,
syncType);
commitState.applyPostCommit(syncType);
return parentDiff;
}
- public boolean isEmpty() {
- return empty;
- }
-
- public void addPreUpdateCallback(Class entityClass, String methodName) {
- preUpdate.addCallback(entityClass, methodName);
- empty = false;
- }
-
- public void addPreUpdateCallback(Object listener, String methodName, Class
entityClass) {
- preUpdate.addCallback(listener, methodName, entityClass);
- empty = false;
- }
-
- public void addPostPersistCallback(Class entityClass, String methodName) {
- postPersist.addCallback(entityClass, methodName);
- empty = false;
- }
-
- public void addPostPersistCallback(
- Object listener,
- String methodName,
- Class entityClass) {
- postPersist.addCallback(listener, methodName, entityClass);
- empty = false;
- }
-
- public void addPostRemoveCallback(Class entityClass, String methodName) {
- postRemove.addCallback(entityClass, methodName);
- empty = false;
- }
-
- public void addPostRemoveCallback(
- Object listener,
- String methodName,
- Class entityClass) {
- postRemove.addCallback(listener, methodName, entityClass);
- empty = false;
- }
-
- public void addPostUpdateCallback(Class entityClass, String methodName) {
- postUpdate.addCallback(entityClass, methodName);
- empty = false;
- }
-
- public void addPostUpdateCallback(
- Object listener,
- String methodName,
- Class entityClass) {
- postUpdate.addCallback(listener, methodName, entityClass);
- empty = false;
- }
-
- public void addPostLoadCallback(Class entityClass, String methodName) {
- postLoad.addCallback(entityClass, methodName);
- empty = false;
- }
-
- public void addPostLoadCallback(Object listener, String methodName, Class
entityClass) {
- postLoad.addCallback(listener, methodName, entityClass);
- empty = false;
- }
-
class CommitState implements GraphChangeHandler {
private GraphManager graphManager;
@@ -191,38 +160,39 @@
}
private void applyPostLoad() {
+
if (!postLoad.isEmpty()) {
if (updated != null) {
- postLoad.applyCallbacks(updated);
+ postLoad.performCallbacks(updated);
}
-
+
if (removed != null) {
- postLoad.applyCallbacks(removed);
+ postLoad.performCallbacks(removed);
}
}
}
private void applyPreUpdate() {
if (updated != null && !preUpdate.isEmpty()) {
- preUpdate.applyCallbacks(updated);
+ preUpdate.performCallbacks(updated);
}
}
private void applyPostUpdate() {
if (updated != null && !postUpdate.isEmpty()) {
- postUpdate.applyCallbacks(updated);
+ postUpdate.performCallbacks(updated);
}
}
private void applyPostPersist() {
if (persisted != null && !postPersist.isEmpty()) {
- postPersist.applyCallbacks(persisted);
+ postPersist.performCallbacks(persisted);
}
}
private void applyPostRemove() {
if (removed != null && !postRemove.isEmpty()) {
- postRemove.applyCallbacks(removed);
+ postRemove.performCallbacks(removed);
}
}
Modified:
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/intercept/ObjectContextCallbackInterceptor.java
URL:
http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/intercept/ObjectContextCallbackInterceptor.java?view=diff&rev=449067&r1=449066&r2=449067
==============================================================================
---
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/intercept/ObjectContextCallbackInterceptor.java
(original)
+++
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/intercept/ObjectContextCallbackInterceptor.java
Fri Sep 22 12:54:40 2006
@@ -22,9 +22,13 @@
import java.util.Iterator;
import org.apache.cayenne.DeleteDenyException;
+import org.apache.cayenne.ObjectContext;
import org.apache.cayenne.PersistenceState;
import org.apache.cayenne.Persistent;
import org.apache.cayenne.map.DeleteRule;
+import org.apache.cayenne.map.EntityResolver;
+import org.apache.cayenne.map.LifecycleEventCallback;
+import org.apache.cayenne.map.LifecycleEventCallbackMap;
import org.apache.cayenne.map.ObjEntity;
import org.apache.cayenne.map.ObjRelationship;
import org.apache.cayenne.property.ClassDescriptor;
@@ -42,8 +46,24 @@
*/
public class ObjectContextCallbackInterceptor extends ObjectContextDecorator {
- CallbackMap prePersist = new CallbackMap();
- CallbackMap preRemove = new CallbackMap();
+ protected LifecycleEventCallbackMap prePersist;
+ protected LifecycleEventCallbackMap preRemove;
+
+ public void setContext(ObjectContext context) {
+ super.setContext(context);
+
+ // init callback ivars for faster access...
+ if (context != null) {
+ EntityResolver resolver = context.getEntityResolver();
+
+ prePersist =
resolver.getCallbacks(LifecycleEventCallback.PRE_PERSIST);
+ preRemove =
resolver.getCallbacks(LifecycleEventCallback.PRE_REMOVE);
+ }
+ else {
+ prePersist = null;
+ preRemove = null;
+ }
+ }
/**
* Creates a new object, applying "PrePersist" callbacks to it.
@@ -51,7 +71,7 @@
public Persistent newObject(Class persistentClass) {
Persistent object = super.newObject(persistentClass);
- prePersist.applyCallbacks(object);
+ prePersist.performCallbacks(object);
return object;
}
@@ -65,26 +85,6 @@
super.deleteObject(object);
}
- public void addPrePersistCallback(Class entityClass, String methodName) {
- prePersist.addCallback(entityClass, methodName);
- }
-
- public void addPrePersistCallback(
- Object listener,
- String methodName,
- Class entityClass) {
-
- prePersist.addCallback(listener, methodName, entityClass);
- }
-
- public void addPreRemoveCallback(Class entityClass, String methodName) {
- preRemove.addCallback(entityClass, methodName);
- }
-
- public void addPreRemoveCallback(Object listener, String methodName, Class
entityClass) {
- preRemove.addCallback(listener, methodName, entityClass);
- }
-
/**
* Recursively applies PreRemove callbacks to an object and objects that
will be
* cascaded
@@ -92,7 +92,7 @@
void applyPreRemoveCallbacks(Persistent object) {
if (object.getPersistenceState() != PersistenceState.NEW) {
- preRemove.applyCallbacks(object);
+ preRemove.performCallbacks(object);
}
ObjEntity entity = getEntityResolver().lookupObjEntity(object);
Added:
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/map/CallbackOnEntity.java
URL:
http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/map/CallbackOnEntity.java?view=auto&rev=449067
==============================================================================
---
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/map/CallbackOnEntity.java
(added)
+++
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/map/CallbackOnEntity.java
Fri Sep 22 12:54:40 2006
@@ -0,0 +1,82 @@
+/*****************************************************************
+ * 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.map;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+
+import org.apache.cayenne.CayenneRuntimeException;
+import org.apache.cayenne.util.Util;
+
+/**
+ * Defines a generic callback operation executed via reflection on a
persistent object.
+ * Note that the method must be declared in the class itself. Callback will
not look up
+ * the class hierarchy.
+ *
+ * @since 3.0
+ * @author Andrus Adamchik
+ */
+class CallbackOnEntity implements LifecycleEventCallback {
+
+ private Method callbackMethod;
+
+ CallbackOnEntity(Class objectClass, String methodName)
+ throws IllegalArgumentException {
+ this.callbackMethod = findMethod(objectClass, methodName);
+ }
+
+ public void performCallback(Object entity) {
+ try {
+ callbackMethod.invoke(entity, null);
+ }
+ catch (Exception e) {
+ throw new CayenneRuntimeException("Error invoking entity callback
method "
+ + callbackMethod.getName(), e);
+ }
+ }
+
+ private Method findMethod(Class objectClass, String methodName)
+ throws IllegalArgumentException {
+ Method[] methods = objectClass.getDeclaredMethods();
+ for (int i = 0; i < methods.length; i++) {
+ if (methodName.equals(methods[i].getName())) {
+
+ // must be non-static, void, with no args
+ // JPA spec also requires it to be non-final, but we don't care
+ int modifiers = methods[i].getModifiers();
+ if (!Modifier.isStatic(modifiers)
+ &&
Void.TYPE.isAssignableFrom(methods[i].getReturnType())
+ && methods[i].getParameterTypes().length == 0) {
+
+ if (!Util.isAccessible(methods[i])) {
+ methods[i].setAccessible(true);
+ }
+
+ return methods[i];
+ }
+ }
+ }
+
+ throw new IllegalArgumentException("Class "
+ + objectClass.getName()
+ + " has no valid callback method '"
+ + methodName
+ + "'");
+ }
+}
Added:
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/map/CallbackOnListener.java
URL:
http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/map/CallbackOnListener.java?view=auto&rev=449067
==============================================================================
---
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/map/CallbackOnListener.java
(added)
+++
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/map/CallbackOnListener.java
Fri Sep 22 12:54:40 2006
@@ -0,0 +1,96 @@
+/*****************************************************************
+ * 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.map;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+
+import org.apache.cayenne.CayenneRuntimeException;
+import org.apache.cayenne.util.Util;
+
+/**
+ * Defines a generic callback operation executed via reflection on an
arbitrary listener
+ * object. Note that the method must be declared in the class itself. Callback
will not
+ * look up the class hierarchy.
+ *
+ * @since 3.0
+ * @author Andrus Adamchik
+ */
+class CallbackOnListener implements LifecycleEventCallback {
+
+ private Method callbackMethod;
+ private Object listener;
+
+ CallbackOnListener(Object listener, String methodName, Class entityType)
+ throws IllegalArgumentException {
+
+ if (listener == null) {
+ throw new IllegalArgumentException("Null listener");
+ }
+
+ this.callbackMethod = findMethod(listener.getClass(), methodName,
entityType);
+ this.listener = listener;
+ }
+
+ public void performCallback(Object entity) {
+ try {
+ callbackMethod.invoke(listener, new Object[] {
+ entity
+ });
+ }
+ catch (Exception e) {
+ throw new CayenneRuntimeException(
+ "Error invoking entity listener callback method "
+ + callbackMethod.getName(),
+ e);
+ }
+ }
+
+ private Method findMethod(Class objectClass, String methodName, Class
entityType)
+ throws IllegalArgumentException {
+
+ Method[] methods = objectClass.getDeclaredMethods();
+ for (int i = 0; i < methods.length; i++) {
+ if (methodName.equals(methods[i].getName())) {
+
+ // must be non-static, void, with a single arg assinable to
entity type
+ // JPA spec also requires it to be non-final, but we don't care
+ int modifiers = methods[i].getModifiers();
+ Class[] parameters = methods[i].getParameterTypes();
+ if (!Modifier.isStatic(modifiers)
+ &&
Void.TYPE.isAssignableFrom(methods[i].getReturnType())
+ && parameters.length == 1
+ && parameters[0].isAssignableFrom(entityType)) {
+
+ if (!Util.isAccessible(methods[i])) {
+ methods[i].setAccessible(true);
+ }
+
+ return methods[i];
+ }
+ }
+ }
+
+ throw new IllegalArgumentException("Class "
+ + objectClass.getName()
+ + " has no valid listener callback method '"
+ + methodName
+ + "'");
+ }
+}
Modified:
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/map/EntityResolver.java
URL:
http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/map/EntityResolver.java?view=diff&rev=449067&r1=449066&r2=449067
==============================================================================
---
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/map/EntityResolver.java
(original)
+++
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/map/EntityResolver.java
Fri Sep 22 12:54:40 2006
@@ -65,6 +65,9 @@
// recompilation will be desired.
protected transient ClassDescriptorFactory classDescriptorFactory;
+ // callbacks are not serializable
+ protected transient LifecycleEventCallbackMap[] lifecycleEventCallbacks;
+
/**
* Creates new EntityResolver.
*/
@@ -85,6 +88,33 @@
this();
this.maps.addAll(dataMaps); // Take a copy
this.constructCache();
+ }
+
+ synchronized void initCallbacks() {
+ if (lifecycleEventCallbacks == null) {
+ LifecycleEventCallbackMap[] lifecycleEventCallbacks = new
LifecycleEventCallbackMap[7];
+
+ for (int i = 0; i < lifecycleEventCallbacks.length; i++) {
+ lifecycleEventCallbacks[i] = new LifecycleEventCallbackMap();
+ }
+
+ this.lifecycleEventCallbacks = lifecycleEventCallbacks;
+ }
+ }
+
+ /**
+ * Returns a [EMAIL PROTECTED] LifecycleEventCallbackMap} for a given type
of lifecycle events.
+ * Event types are defined as constants in LifecycleEventCallback
interface. E.g.
+ * [EMAIL PROTECTED] LifecycleEventCallback#PRE_PERSIST}, etc.
+ *
+ * @since 3.0
+ */
+ public LifecycleEventCallbackMap getCallbacks(int callbackType) {
+ if (lifecycleEventCallbacks == null) {
+ initCallbacks();
+ }
+
+ return lifecycleEventCallbacks[callbackType];
}
/**
Added:
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/map/LifecycleEventCallback.java
URL:
http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/map/LifecycleEventCallback.java?view=auto&rev=449067
==============================================================================
---
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/map/LifecycleEventCallback.java
(added)
+++
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/map/LifecycleEventCallback.java
Fri Sep 22 12:54:40 2006
@@ -0,0 +1,40 @@
+/*****************************************************************
+ * 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.map;
+
+/**
+ * Defines a callback operation.
+ *
+ * @author Andrus Adamchik
+ */
+public interface LifecycleEventCallback {
+
+ // these int constants correspond to indexes in array in EntityResolver,
so they must
+ // start with 0 and increment by 1.
+
+ public static final int PRE_PERSIST = 0;
+ public static final int PRE_REMOVE = 1;
+ public static final int PRE_UPDATE = 2;
+ public static final int POST_PERSIST = 3;
+ public static final int POST_REMOVE = 4;
+ public static final int POST_UPDATE = 5;
+ public static final int POST_LOAD = 6;
+
+ void performCallback(Object entity);
+}
Added:
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/map/LifecycleEventCallbackMap.java
URL:
http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/map/LifecycleEventCallbackMap.java?view=auto&rev=449067
==============================================================================
---
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/map/LifecycleEventCallbackMap.java
(added)
+++
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/map/LifecycleEventCallbackMap.java
Fri Sep 22 12:54:40 2006
@@ -0,0 +1,114 @@
+/*****************************************************************
+ * 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.map;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * A runtime callback processor for a single lifecycle event.
+ *
+ * @since 3.0
+ * @author Andrus Adamchik
+ */
+public class LifecycleEventCallbackMap {
+
+ protected Map listeners;
+
+ public LifecycleEventCallbackMap() {
+ listeners = new HashMap();
+ }
+
+ /**
+ * Removes all listeners.
+ */
+ public void removeAll() {
+ listeners.clear();
+ }
+
+ /**
+ * Returns true if no listeners are regsitered with this callback for any
entity.
+ */
+ public boolean isEmpty() {
+ return listeners.isEmpty();
+ }
+
+ /**
+ * Registers a callback method to be invoked on an entity class instances
when a
+ * lifecycle event occurs.
+ */
+ public void addListener(Class entityClass, String methodName) {
+ addCallback(entityClass, new CallbackOnEntity(entityClass,
methodName));
+ }
+
+ /**
+ * Registers callback method to be invoked on a provided non-entity object
when a
+ * lifecycle event occurs.
+ */
+ public void addListener(Class entityClass, Object listener, String
methodName) {
+ CallbackOnListener callback = new CallbackOnListener(
+ listener,
+ methodName,
+ entityClass);
+ addCallback(entityClass, callback);
+ }
+
+ /**
+ * Registers a callback object to be invoked when a lifecycle event occurs.
+ */
+ public void addCallback(Class entityClass, LifecycleEventCallback
callback) {
+ Collection entityListeners = (Collection)
listeners.get(entityClass.getName());
+
+ if (entityListeners == null) {
+ entityListeners = new ArrayList(3);
+ listeners.put(entityClass.getName(), entityListeners);
+ }
+
+ entityListeners.add(callback);
+ }
+
+ /**
+ * Invokes callbacks for a given entity object.
+ */
+ public void performCallbacks(Object object) {
+ String key = object.getClass().getName();
+ Collection entityListeners = (Collection) listeners.get(key);
+
+ if (entityListeners != null) {
+ Iterator it = (Iterator) entityListeners.iterator();
+ while (it.hasNext()) {
+ ((LifecycleEventCallback) it.next()).performCallback(object);
+ }
+ }
+ }
+
+ /**
+ * Invokes callbacks for a collection of entity objects.
+ */
+ public void performCallbacks(Collection objects) {
+ Iterator it = objects.iterator();
+ while (it.hasNext()) {
+ Object object = it.next();
+ performCallbacks(object);
+ }
+ }
+}
Modified:
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/intercept/DataChannelCallbackInterceptorTst.java
URL:
http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/intercept/DataChannelCallbackInterceptorTst.java?view=diff&rev=449067&r1=449066&r2=449067
==============================================================================
---
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/intercept/DataChannelCallbackInterceptorTst.java
(original)
+++
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/intercept/DataChannelCallbackInterceptorTst.java
Fri Sep 22 12:54:40 2006
@@ -22,14 +22,35 @@
import org.apache.cayenne.ObjectContext;
import org.apache.cayenne.access.DataContext;
import org.apache.cayenne.access.ObjectStore;
+import org.apache.cayenne.map.EntityResolver;
+import org.apache.cayenne.map.LifecycleEventCallback;
+import org.apache.cayenne.map.LifecycleEventCallbackMap;
import org.apache.cayenne.query.RefreshQuery;
import org.apache.cayenne.query.SelectQuery;
import org.apache.cayenne.unit.CayenneTestCase;
public class DataChannelCallbackInterceptorTst extends CayenneTestCase {
- public void testPostLoad() throws Exception {
+ protected void setUp() throws Exception {
deleteTestData();
+ }
+
+ protected void tearDown() throws Exception {
+ EntityResolver resolver = getDomain().getEntityResolver();
+
+ resolver.getCallbacks(LifecycleEventCallback.POST_LOAD).removeAll();
+ resolver.getCallbacks(LifecycleEventCallback.POST_PERSIST).removeAll();
+ resolver.getCallbacks(LifecycleEventCallback.POST_REMOVE).removeAll();
+ resolver.getCallbacks(LifecycleEventCallback.POST_UPDATE).removeAll();
+ resolver.getCallbacks(LifecycleEventCallback.PRE_PERSIST).removeAll();
+ resolver.getCallbacks(LifecycleEventCallback.PRE_REMOVE).removeAll();
+ resolver.getCallbacks(LifecycleEventCallback.PRE_UPDATE).removeAll();
+ }
+
+ public void testPostLoad() throws Exception {
+ LifecycleEventCallbackMap postLoad = getDomain()
+ .getEntityResolver()
+ .getCallbacks(LifecycleEventCallback.POST_LOAD);
DataChannelCallbackInterceptor i = new
DataChannelCallbackInterceptor();
i.setChannel(getDomain());
@@ -37,9 +58,9 @@
ObjectContext context = new DataContext(i, new ObjectStore(getDomain()
.getSharedSnapshotCache()));
- i.addPostLoadCallback(Artist.class, "postLoadCallback");
+ postLoad.addListener(Artist.class, "postLoadCallback");
MockCallingBackListener listener = new MockCallingBackListener();
- i.addPostLoadCallback(listener, "publicCallback", Artist.class);
+ postLoad.addListener(Artist.class, listener, "publicCallback");
Artist a1 = (Artist) context.newObject(Artist.class);
a1.setArtistName("XX");
@@ -77,17 +98,17 @@
context.rollbackChanges();
assertTrue(a1.isPostLoaded());
assertSame(a1, listener.getPublicCalledbackEntity());
-
- // test invalidated
+
+ // test invalidated
a1.resetCallbackFlags();
listener.reset();
assertFalse(a1.isPostLoaded());
assertNull(listener.getPublicCalledbackEntity());
-
+
context.performQuery(new RefreshQuery(a1));
assertFalse(a1.isPostLoaded());
assertNull(listener.getPublicCalledbackEntity());
-
+
a1.getArtistName();
assertTrue(a1.isPostLoaded());
assertSame(a1, listener.getPublicCalledbackEntity());
@@ -95,6 +116,10 @@
public void testPreUpdate() {
+ LifecycleEventCallbackMap preUpdate = getDomain()
+ .getEntityResolver()
+ .getCallbacks(LifecycleEventCallback.PRE_UPDATE);
+
DataChannelCallbackInterceptor i = new
DataChannelCallbackInterceptor();
i.setChannel(getDomain());
@@ -110,7 +135,7 @@
context.commitChanges();
assertFalse(a1.isPreUpdated());
- i.addPreUpdateCallback(Artist.class, "preUpdateCallback");
+ preUpdate.addListener(Artist.class, "preUpdateCallback");
a1.setArtistName("ZZ");
context.commitChanges();
assertTrue(a1.isPreUpdated());
@@ -119,7 +144,7 @@
assertFalse(a1.isPreUpdated());
MockCallingBackListener listener2 = new MockCallingBackListener();
- i.addPreUpdateCallback(listener2, "publicCallback", Artist.class);
+ preUpdate.addListener(Artist.class, listener2, "publicCallback");
a1.setArtistName("AA");
context.commitChanges();
@@ -130,6 +155,10 @@
public void testPostUpdate() {
+ LifecycleEventCallbackMap postUpdate = getDomain()
+ .getEntityResolver()
+ .getCallbacks(LifecycleEventCallback.POST_UPDATE);
+
DataChannelCallbackInterceptor i = new
DataChannelCallbackInterceptor();
i.setChannel(getDomain());
@@ -145,7 +174,7 @@
context.commitChanges();
assertFalse(a1.isPostUpdated());
- i.addPostUpdateCallback(Artist.class, "postUpdateCallback");
+ postUpdate.addListener(Artist.class, "postUpdateCallback");
a1.setArtistName("ZZ");
context.commitChanges();
assertTrue(a1.isPostUpdated());
@@ -154,7 +183,7 @@
assertFalse(a1.isPostUpdated());
MockCallingBackListener listener2 = new MockCallingBackListener();
- i.addPostUpdateCallback(listener2, "publicCallback", Artist.class);
+ postUpdate.addListener(Artist.class, listener2, "publicCallback");
a1.setArtistName("AA");
context.commitChanges();
@@ -165,6 +194,10 @@
public void testPostRemove() {
+ LifecycleEventCallbackMap postRemove = getDomain()
+ .getEntityResolver()
+ .getCallbacks(LifecycleEventCallback.POST_REMOVE);
+
DataChannelCallbackInterceptor i = new
DataChannelCallbackInterceptor();
i.setChannel(getDomain());
@@ -175,9 +208,9 @@
a1.setArtistName("XX");
context.commitChanges();
- i.addPostRemoveCallback(Artist.class, "postRemoveCallback");
+ postRemove.addListener(Artist.class, "postRemoveCallback");
MockCallingBackListener listener2 = new MockCallingBackListener();
- i.addPostRemoveCallback(listener2, "publicCallback", Artist.class);
+ postRemove.addListener(Artist.class, listener2, "publicCallback");
context.deleteObject(a1);
context.commitChanges();
@@ -188,6 +221,10 @@
public void testPostPersist() {
+ LifecycleEventCallbackMap postPersist = getDomain()
+ .getEntityResolver()
+ .getCallbacks(LifecycleEventCallback.POST_PERSIST);
+
DataChannelCallbackInterceptor i = new
DataChannelCallbackInterceptor();
i.setChannel(getDomain());
@@ -199,9 +236,9 @@
context.commitChanges();
assertFalse(a1.isPostPersisted());
- i.addPostPersistCallback(Artist.class, "postPersistCallback");
+ postPersist.addListener(Artist.class, "postPersistCallback");
MockCallingBackListener listener2 = new MockCallingBackListener();
- i.addPostPersistCallback(listener2, "publicCallback", Artist.class);
+ postPersist.addListener(Artist.class, listener2, "publicCallback");
Artist a2 = (Artist) context.newObject(Artist.class);
a2.setArtistName("XX");
Modified:
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/intercept/ObjectContextCallbackInterceptorTst.java
URL:
http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/intercept/ObjectContextCallbackInterceptorTst.java?view=diff&rev=449067&r1=449066&r2=449067
==============================================================================
---
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/intercept/ObjectContextCallbackInterceptorTst.java
(original)
+++
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/intercept/ObjectContextCallbackInterceptorTst.java
Fri Sep 22 12:54:40 2006
@@ -20,6 +20,9 @@
import org.apache.art.Artist;
import org.apache.art.Painting;
+import org.apache.cayenne.map.EntityResolver;
+import org.apache.cayenne.map.LifecycleEventCallback;
+import org.apache.cayenne.map.LifecycleEventCallbackMap;
import org.apache.cayenne.unit.CayenneTestCase;
public class ObjectContextCallbackInterceptorTst extends CayenneTestCase {
@@ -28,7 +31,24 @@
deleteTestData();
}
+ protected void tearDown() throws Exception {
+ EntityResolver resolver = getDomain().getEntityResolver();
+
+ resolver.getCallbacks(LifecycleEventCallback.POST_LOAD).removeAll();
+ resolver.getCallbacks(LifecycleEventCallback.POST_PERSIST).removeAll();
+ resolver.getCallbacks(LifecycleEventCallback.POST_REMOVE).removeAll();
+ resolver.getCallbacks(LifecycleEventCallback.POST_UPDATE).removeAll();
+ resolver.getCallbacks(LifecycleEventCallback.PRE_PERSIST).removeAll();
+ resolver.getCallbacks(LifecycleEventCallback.PRE_REMOVE).removeAll();
+ resolver.getCallbacks(LifecycleEventCallback.PRE_UPDATE).removeAll();
+ }
+
public void testPrePersistCallbacks() {
+
+ LifecycleEventCallbackMap prePersist = getDomain()
+ .getEntityResolver()
+ .getCallbacks(LifecycleEventCallback.PRE_PERSIST);
+
ObjectContextCallbackInterceptor i = new
ObjectContextCallbackInterceptor();
i.setContext(createDataContext());
@@ -37,14 +57,14 @@
assertNotNull(a1);
assertFalse(a1.isPrePersisted());
- i.addPrePersistCallback(Artist.class, "prePersistCallback");
+ prePersist.addListener(Artist.class, "prePersistCallback");
Artist a2 = (Artist) i.newObject(Artist.class);
assertNotNull(a2);
assertTrue(a2.isPrePersisted());
MockCallingBackListener listener2 = new MockCallingBackListener();
- i.addPrePersistCallback(listener2, "publicCallback", Artist.class);
+ prePersist.addListener(Artist.class, listener2, "publicCallback");
Artist a3 = (Artist) i.newObject(Artist.class);
assertNotNull(a3);
@@ -59,6 +79,10 @@
}
public void testPreRemoveCallbacks() {
+ LifecycleEventCallbackMap preRemove = getDomain()
+ .getEntityResolver()
+ .getCallbacks(LifecycleEventCallback.PRE_REMOVE);
+
ObjectContextCallbackInterceptor i = new
ObjectContextCallbackInterceptor();
i.setContext(createDataContext());
@@ -70,7 +94,7 @@
assertFalse(a1.isPrePersisted());
assertFalse(a1.isPreRemoved());
- i.addPreRemoveCallback(Artist.class, "preRemoveCallback");
+ preRemove.addListener(Artist.class, "preRemoveCallback");
Artist a2 = (Artist) i.newObject(Artist.class);
a2.setArtistName("XX");
@@ -80,7 +104,7 @@
assertTrue(a2.isPreRemoved());
MockCallingBackListener listener2 = new MockCallingBackListener();
- i.addPreRemoveCallback(listener2, "publicCallback", Artist.class);
+ preRemove.addListener(Artist.class, listener2, "publicCallback");
Artist a3 = (Artist) i.newObject(Artist.class);
a3.setArtistName("XX");
Added:
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/map/CallbackOnEntityTst.java
URL:
http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/map/CallbackOnEntityTst.java?view=auto&rev=449067
==============================================================================
---
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/map/CallbackOnEntityTst.java
(added)
+++
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/map/CallbackOnEntityTst.java
Fri Sep 22 12:54:40 2006
@@ -0,0 +1,88 @@
+/*****************************************************************
+ * 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.map;
+
+import org.apache.cayenne.map.CallbackOnEntity;
+
+import junit.framework.TestCase;
+
+public class CallbackOnEntityTst extends TestCase {
+
+ public void testPublicCallbackMethod() {
+ CallbackOnEntity callback = new CallbackOnEntity(
+ MockCallingBackEntity.class,
+ "publicCallback");
+
+ MockCallingBackEntity e = new MockCallingBackEntity();
+ callback.performCallback(e);
+ assertTrue(e.publicCallbackInvoked);
+ assertFalse(e.protectedCallbackInvoked);
+ assertFalse(e.privateCallbackInvoked);
+ assertFalse(e.defaultCallbackInvoked);
+ }
+
+ public void testProtectedCallbackMethod() {
+ CallbackOnEntity callback = new CallbackOnEntity(
+ MockCallingBackEntity.class,
+ "protectedCallback");
+
+ MockCallingBackEntity e = new MockCallingBackEntity();
+ callback.performCallback(e);
+ assertFalse(e.publicCallbackInvoked);
+ assertTrue(e.protectedCallbackInvoked);
+ assertFalse(e.privateCallbackInvoked);
+ assertFalse(e.defaultCallbackInvoked);
+ }
+
+ public void testPrivateCallbackMethod() {
+ CallbackOnEntity callback = new CallbackOnEntity(
+ MockCallingBackEntity.class,
+ "privateCallback");
+
+ MockCallingBackEntity e = new MockCallingBackEntity();
+ callback.performCallback(e);
+ assertFalse(e.publicCallbackInvoked);
+ assertFalse(e.protectedCallbackInvoked);
+ assertTrue(e.privateCallbackInvoked);
+ assertFalse(e.defaultCallbackInvoked);
+ }
+
+ public void testDefaultCallbackMethod() {
+ CallbackOnEntity callback = new CallbackOnEntity(
+ MockCallingBackEntity.class,
+ "defaultCallback");
+
+ MockCallingBackEntity e = new MockCallingBackEntity();
+ callback.performCallback(e);
+ assertFalse(e.publicCallbackInvoked);
+ assertFalse(e.protectedCallbackInvoked);
+ assertFalse(e.privateCallbackInvoked);
+ assertTrue(e.defaultCallbackInvoked);
+ }
+
+ public void testStaticCallbackMethod() {
+ try {
+ new CallbackOnEntity(MockCallingBackEntity.class,
"staticCallback");
+ fail("Static methods can't be used as callbacks");
+ }
+ catch (IllegalArgumentException e) {
+ // expected
+ }
+ }
+}
Added:
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/map/CallbackOnListenerTst.java
URL:
http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/map/CallbackOnListenerTst.java?view=auto&rev=449067
==============================================================================
---
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/map/CallbackOnListenerTst.java
(added)
+++
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/map/CallbackOnListenerTst.java
Fri Sep 22 12:54:40 2006
@@ -0,0 +1,47 @@
+/*****************************************************************
+ * 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.map;
+
+import org.apache.cayenne.intercept.MockCallingBackListener;
+import org.apache.cayenne.map.CallbackOnListener;
+
+import junit.framework.TestCase;
+
+public class CallbackOnListenerTst extends TestCase {
+
+ public void testPublicCallbackMethod() {
+
+ MockCallingBackListener listener = new MockCallingBackListener();
+ CallbackOnListener callback = new CallbackOnListener(
+ listener,
+ "publicCallback",
+ Object.class);
+
+ MockCallingBackEntity e = new MockCallingBackEntity();
+ callback.performCallback(e);
+
+ // entity itself should not be called back...
+ assertFalse(e.publicCallbackInvoked);
+ assertFalse(e.protectedCallbackInvoked);
+ assertFalse(e.privateCallbackInvoked);
+ assertFalse(e.defaultCallbackInvoked);
+
+ assertSame(e, listener.getPublicCalledbackEntity());
+ }
+}
Copied:
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/map/MockCallingBackEntity.java
(from r448439,
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/intercept/MockCallingBackEntity.java)
URL:
http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/map/MockCallingBackEntity.java?view=diff&rev=449067&p1=incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/intercept/MockCallingBackEntity.java&r1=448439&p2=incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/map/MockCallingBackEntity.java&r2=449067
==============================================================================
---
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/intercept/MockCallingBackEntity.java
(original)
+++
incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/map/MockCallingBackEntity.java
Fri Sep 22 12:54:40 2006
@@ -16,19 +16,19 @@
* specific language governing permissions and limitations
* under the License.
****************************************************************/
-package org.apache.cayenne.intercept;
+package org.apache.cayenne.map;
public class MockCallingBackEntity {
-
+
public boolean publicCallbackInvoked;
public boolean protectedCallbackInvoked;
public boolean privateCallbackInvoked;
public boolean defaultCallbackInvoked;
public static void staticCallback() {
-
+
}
-
+
public void publicCallback() {
publicCallbackInvoked = true;
}