You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by mi...@apache.org on 2009/03/23 00:45:35 UTC
svn commit: r757280 [5/23] - in /openjpa/branches/1.0.x:
openjpa-examples/src/main/java/hellojpa/
openjpa-examples/src/main/java/relations/
openjpa-jdbc-5/src/main/java/org/apache/openjpa/jdbc/meta/strats/
openjpa-jdbc/src/main/java/org/apache/openjpa/...
Modified: openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCSubclassValidator.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCSubclassValidator.java?rev=757280&r1=757279&r2=757280&view=diff
==============================================================================
--- openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCSubclassValidator.java (original)
+++ openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCSubclassValidator.java Sun Mar 22 23:45:15 2009
@@ -1,272 +1,272 @@
-/*
- * 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.openjpa.enhance;
-
-import java.lang.reflect.Modifier;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Collection;
-
-import org.apache.commons.lang.StringUtils;
-import org.apache.openjpa.meta.ClassMetaData;
-import org.apache.openjpa.meta.FieldMetaData;
-import org.apache.openjpa.util.UserException;
-import org.apache.openjpa.util.InternalException;
-import org.apache.openjpa.lib.util.Localizer;
-import org.apache.openjpa.lib.util.Localizer.Message;
-import org.apache.openjpa.lib.log.Log;
-import serp.bytecode.BCField;
-import serp.bytecode.BCClass;
-import serp.bytecode.BCMethod;
-
-/**
- * <p>Validates that a given type meets the JPA contract, plus a few
- * OpenJPA-specific additions for subclassing / redefinition:
- *
- * <ul>
- * <li>must have an accessible no-args constructor</li>
- * <li>must be a public or protected class</li>
- * <li>must not be final</li>
- * <li>must not extend an enhanced class</li>
- * <li>all persistent data represented by accessible setter/getter
- * methods (persistent properties)</li>
- * <li>if versioning is to be used, exactly one persistent property for
- * the numeric version data</li> <!-- ##### is this true? -->
- *
- * <li>When using property access, the backing field for a persistent
- * property must be:
- * <ul>
- * <!-- ##### JPA validation of these needs to be tested -->
- * <li>private</li>
- * <li>set only in the designated setter,
- * in the constructor, or in {@link Object#clone()},
- * <code>readObject(ObjectInputStream)</code>, or
- * {@link Externalizable#readExternal(ObjectInput)}.</li>
- * <li>read only in the designated getter and the
- * constructor.</li>
- * </ul>
- * </li>
- * </ul>
- *
- * <p>If you use this technique and use the <code>new</code> keyword instead of
- * a OpenJPA-supplied construction routine, OpenJPA will need to do extra work
- * with persistent-new-flushed instances, since OpenJPA cannot in this case
- * track what happens to such an instance.</p>
- *
- * @since 1.0.0
- */
-public class PCSubclassValidator {
-
- private static final Localizer loc =
- Localizer.forPackage(PCSubclassValidator.class);
-
- private final ClassMetaData meta;
- private final BCClass pc;
- private final Log log;
- private final boolean failOnContractViolations;
-
- private Collection errors;
- private Collection contractViolations;
-
- public PCSubclassValidator(ClassMetaData meta, BCClass bc, Log log,
- boolean enforceContractViolations) {
- this.meta = meta;
- this.pc = bc;
- this.log = log;
- this.failOnContractViolations = enforceContractViolations;
- }
-
- public void assertCanSubclass() {
- Class superclass = meta.getDescribedType();
- String name = superclass.getName();
- if (superclass.isInterface())
- addError(loc.get("subclasser-no-ifaces", name), meta);
- if (Modifier.isFinal(superclass.getModifiers()))
- addError(loc.get("subclasser-no-final-classes", name), meta);
- if (Modifier.isPrivate(superclass.getModifiers()))
- addError(loc.get("subclasser-no-private-classes", name), meta);
- if (PersistenceCapable.class.isAssignableFrom(superclass))
- addError(loc.get("subclasser-super-already-pc", name), meta);
-
- try {
- Constructor c = superclass.getDeclaredConstructor(new Class[0]);
- if (!(Modifier.isProtected(c.getModifiers())
- || Modifier.isPublic(c.getModifiers())))
- addError(loc.get("subclasser-private-ctor", name), meta);
- }
- catch (NoSuchMethodException e) {
- addError(loc.get("subclasser-no-void-ctor", name),
- meta);
- }
-
- // if the BCClass we loaded is already pc and the superclass is not,
- // then we should never get here, so let's make sure that the
- // calling context is caching correctly by throwing an exception.
- if (pc.isInstanceOf(PersistenceCapable.class) &&
- !PersistenceCapable.class.isAssignableFrom(superclass))
- throw new InternalException(
- loc.get("subclasser-class-already-pc", name));
-
- if (meta.getAccessType() == ClassMetaData.ACCESS_PROPERTY)
- checkPropertiesAreInterceptable();
-
- if (errors != null && !errors.isEmpty())
- throw new UserException(errors.toString());
- else if (contractViolations != null &&
- !contractViolations.isEmpty() && log.isWarnEnabled())
- log.warn(contractViolations.toString());
- }
-
- private void checkPropertiesAreInterceptable() {
- // just considers accessor methods for now.
- FieldMetaData[] fmds = meta.getFields();
- for (int i = 0; i < fmds.length; i++) {
- Method getter = (Method) fmds[i].getBackingMember();
- if (getter == null) {
- addError(loc.get("subclasser-no-getter",
- fmds[i].getName()), fmds[i]);
- continue;
- }
- BCField returnedField = checkGetterIsSubclassable(getter, fmds[i]);
-
- Method setter = setterForField(fmds[i]);
- if (setter == null) {
- addError(loc.get("subclasser-no-setter", fmds[i].getName()),
- fmds[i]);
- continue;
- }
- BCField assignedField = checkSetterIsSubclassable(setter, fmds[i]);
- if (assignedField == null)
- continue;
-
- if (assignedField != returnedField)
- addContractViolation(loc.get
- ("subclasser-setter-getter-field-mismatch",
- fmds[i].getName(), returnedField,assignedField),
- fmds[i]);
-
- // ### scan through all the rest of the class to make sure it
- // ### doesn't use the field.
- }
- }
-
- private Method setterForField(FieldMetaData fmd) {
- try {
- return fmd.getDeclaringType().getDeclaredMethod(
- "set" + StringUtils.capitalize(fmd.getName()),
- new Class[]{ fmd.getDeclaredType() });
- }
- catch (NoSuchMethodException e) {
- return null;
- }
- }
-
- /**
- * @return the name of the field that is returned by <code>meth</code>, or
- * <code>null</code> if something other than a single field is
- * returned, or if it cannot be determined what is returned.
- */
- private BCField checkGetterIsSubclassable(Method meth, FieldMetaData fmd) {
- checkMethodIsSubclassable(meth, fmd);
- BCField field = PCEnhancer.getReturnedField(getBCMethod(meth));
- if (field == null) {
- addContractViolation(loc.get("subclasser-invalid-getter",
- fmd.getName()), fmd);
- return null;
- } else {
- return field;
- }
- }
-
- /**
- * @return the field that is set in <code>meth</code>, or
- * <code>null</code> if something other than a single field is
- * set, or if it cannot be determined what is set.
- */
- private BCField checkSetterIsSubclassable(Method meth, FieldMetaData fmd) {
- checkMethodIsSubclassable(meth, fmd);
- BCField field = PCEnhancer.getAssignedField(getBCMethod(meth));
- if (field == null) {
- addContractViolation(loc.get("subclasser-invalid-setter",
- fmd.getName()), fmd);
- return null;
- } else {
- return field;
- }
- }
-
- private BCMethod getBCMethod(Method meth) {
- BCClass bc = pc.getProject().loadClass(meth.getDeclaringClass());
- return bc.getDeclaredMethod(meth.getName(), meth.getParameterTypes());
- }
-
- private void checkMethodIsSubclassable(Method meth, FieldMetaData fmd) {
- String className = fmd.getDefiningMetaData().
- getDescribedType().getName();
- if (!(Modifier.isProtected(meth.getModifiers())
- || Modifier.isPublic(meth.getModifiers())))
- addError(loc.get("subclasser-private-accessors-unsupported",
- className, meth.getName()), fmd);
- if (Modifier.isFinal(meth.getModifiers()))
- addError(loc.get("subclasser-final-methods-not-allowed",
- className, meth.getName()), fmd);
- if (Modifier.isNative(meth.getModifiers()))
- addContractViolation(loc.get
- ("subclasser-native-methods-not-allowed", className,
- meth.getName()),
- fmd);
- if (Modifier.isStatic(meth.getModifiers()))
- addError(loc.get("subclasser-static-methods-not-supported",
- className, meth.getName()), fmd);
- }
-
- private void addError(Message s, ClassMetaData cls) {
- if (errors == null)
- errors = new ArrayList();
-
- errors.add(loc.get("subclasser-error-meta", s,
- cls.getDescribedType().getName(),
- cls.getSourceFile()));
- }
-
- private void addError(Message s, FieldMetaData fmd) {
- if (errors == null)
- errors = new ArrayList();
-
- errors.add(loc.get("subclasser-error-field", s,
- fmd.getFullName(),
- fmd.getDeclaringMetaData().getSourceFile()));
- }
-
- private void addContractViolation(Message m, FieldMetaData fmd) {
- // add the violation as an error in case we're processing violations
- // as errors; this keeps them in the order that they were found rather
- // than just adding the violations to the end of the list.
- if (failOnContractViolations)
- addError(m, fmd);
-
- if (contractViolations == null)
- contractViolations = new ArrayList();
-
- contractViolations.add(loc.get
- ("subclasser-contract-violation-field", m.getMessage(),
- fmd.getFullName(), fmd.getDeclaringMetaData().getSourceFile()));
- }
-}
+/*
+ * 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.openjpa.enhance;
+
+import java.lang.reflect.Modifier;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.openjpa.meta.ClassMetaData;
+import org.apache.openjpa.meta.FieldMetaData;
+import org.apache.openjpa.util.UserException;
+import org.apache.openjpa.util.InternalException;
+import org.apache.openjpa.lib.util.Localizer;
+import org.apache.openjpa.lib.util.Localizer.Message;
+import org.apache.openjpa.lib.log.Log;
+import serp.bytecode.BCField;
+import serp.bytecode.BCClass;
+import serp.bytecode.BCMethod;
+
+/**
+ * <p>Validates that a given type meets the JPA contract, plus a few
+ * OpenJPA-specific additions for subclassing / redefinition:
+ *
+ * <ul>
+ * <li>must have an accessible no-args constructor</li>
+ * <li>must be a public or protected class</li>
+ * <li>must not be final</li>
+ * <li>must not extend an enhanced class</li>
+ * <li>all persistent data represented by accessible setter/getter
+ * methods (persistent properties)</li>
+ * <li>if versioning is to be used, exactly one persistent property for
+ * the numeric version data</li> <!-- ##### is this true? -->
+ *
+ * <li>When using property access, the backing field for a persistent
+ * property must be:
+ * <ul>
+ * <!-- ##### JPA validation of these needs to be tested -->
+ * <li>private</li>
+ * <li>set only in the designated setter,
+ * in the constructor, or in {@link Object#clone()},
+ * <code>readObject(ObjectInputStream)</code>, or
+ * {@link Externalizable#readExternal(ObjectInput)}.</li>
+ * <li>read only in the designated getter and the
+ * constructor.</li>
+ * </ul>
+ * </li>
+ * </ul>
+ *
+ * <p>If you use this technique and use the <code>new</code> keyword instead of
+ * a OpenJPA-supplied construction routine, OpenJPA will need to do extra work
+ * with persistent-new-flushed instances, since OpenJPA cannot in this case
+ * track what happens to such an instance.</p>
+ *
+ * @since 1.0.0
+ */
+public class PCSubclassValidator {
+
+ private static final Localizer loc =
+ Localizer.forPackage(PCSubclassValidator.class);
+
+ private final ClassMetaData meta;
+ private final BCClass pc;
+ private final Log log;
+ private final boolean failOnContractViolations;
+
+ private Collection errors;
+ private Collection contractViolations;
+
+ public PCSubclassValidator(ClassMetaData meta, BCClass bc, Log log,
+ boolean enforceContractViolations) {
+ this.meta = meta;
+ this.pc = bc;
+ this.log = log;
+ this.failOnContractViolations = enforceContractViolations;
+ }
+
+ public void assertCanSubclass() {
+ Class superclass = meta.getDescribedType();
+ String name = superclass.getName();
+ if (superclass.isInterface())
+ addError(loc.get("subclasser-no-ifaces", name), meta);
+ if (Modifier.isFinal(superclass.getModifiers()))
+ addError(loc.get("subclasser-no-final-classes", name), meta);
+ if (Modifier.isPrivate(superclass.getModifiers()))
+ addError(loc.get("subclasser-no-private-classes", name), meta);
+ if (PersistenceCapable.class.isAssignableFrom(superclass))
+ addError(loc.get("subclasser-super-already-pc", name), meta);
+
+ try {
+ Constructor c = superclass.getDeclaredConstructor(new Class[0]);
+ if (!(Modifier.isProtected(c.getModifiers())
+ || Modifier.isPublic(c.getModifiers())))
+ addError(loc.get("subclasser-private-ctor", name), meta);
+ }
+ catch (NoSuchMethodException e) {
+ addError(loc.get("subclasser-no-void-ctor", name),
+ meta);
+ }
+
+ // if the BCClass we loaded is already pc and the superclass is not,
+ // then we should never get here, so let's make sure that the
+ // calling context is caching correctly by throwing an exception.
+ if (pc.isInstanceOf(PersistenceCapable.class) &&
+ !PersistenceCapable.class.isAssignableFrom(superclass))
+ throw new InternalException(
+ loc.get("subclasser-class-already-pc", name));
+
+ if (meta.getAccessType() == ClassMetaData.ACCESS_PROPERTY)
+ checkPropertiesAreInterceptable();
+
+ if (errors != null && !errors.isEmpty())
+ throw new UserException(errors.toString());
+ else if (contractViolations != null &&
+ !contractViolations.isEmpty() && log.isWarnEnabled())
+ log.warn(contractViolations.toString());
+ }
+
+ private void checkPropertiesAreInterceptable() {
+ // just considers accessor methods for now.
+ FieldMetaData[] fmds = meta.getFields();
+ for (int i = 0; i < fmds.length; i++) {
+ Method getter = (Method) fmds[i].getBackingMember();
+ if (getter == null) {
+ addError(loc.get("subclasser-no-getter",
+ fmds[i].getName()), fmds[i]);
+ continue;
+ }
+ BCField returnedField = checkGetterIsSubclassable(getter, fmds[i]);
+
+ Method setter = setterForField(fmds[i]);
+ if (setter == null) {
+ addError(loc.get("subclasser-no-setter", fmds[i].getName()),
+ fmds[i]);
+ continue;
+ }
+ BCField assignedField = checkSetterIsSubclassable(setter, fmds[i]);
+ if (assignedField == null)
+ continue;
+
+ if (assignedField != returnedField)
+ addContractViolation(loc.get
+ ("subclasser-setter-getter-field-mismatch",
+ fmds[i].getName(), returnedField,assignedField),
+ fmds[i]);
+
+ // ### scan through all the rest of the class to make sure it
+ // ### doesn't use the field.
+ }
+ }
+
+ private Method setterForField(FieldMetaData fmd) {
+ try {
+ return fmd.getDeclaringType().getDeclaredMethod(
+ "set" + StringUtils.capitalize(fmd.getName()),
+ new Class[]{ fmd.getDeclaredType() });
+ }
+ catch (NoSuchMethodException e) {
+ return null;
+ }
+ }
+
+ /**
+ * @return the name of the field that is returned by <code>meth</code>, or
+ * <code>null</code> if something other than a single field is
+ * returned, or if it cannot be determined what is returned.
+ */
+ private BCField checkGetterIsSubclassable(Method meth, FieldMetaData fmd) {
+ checkMethodIsSubclassable(meth, fmd);
+ BCField field = PCEnhancer.getReturnedField(getBCMethod(meth));
+ if (field == null) {
+ addContractViolation(loc.get("subclasser-invalid-getter",
+ fmd.getName()), fmd);
+ return null;
+ } else {
+ return field;
+ }
+ }
+
+ /**
+ * @return the field that is set in <code>meth</code>, or
+ * <code>null</code> if something other than a single field is
+ * set, or if it cannot be determined what is set.
+ */
+ private BCField checkSetterIsSubclassable(Method meth, FieldMetaData fmd) {
+ checkMethodIsSubclassable(meth, fmd);
+ BCField field = PCEnhancer.getAssignedField(getBCMethod(meth));
+ if (field == null) {
+ addContractViolation(loc.get("subclasser-invalid-setter",
+ fmd.getName()), fmd);
+ return null;
+ } else {
+ return field;
+ }
+ }
+
+ private BCMethod getBCMethod(Method meth) {
+ BCClass bc = pc.getProject().loadClass(meth.getDeclaringClass());
+ return bc.getDeclaredMethod(meth.getName(), meth.getParameterTypes());
+ }
+
+ private void checkMethodIsSubclassable(Method meth, FieldMetaData fmd) {
+ String className = fmd.getDefiningMetaData().
+ getDescribedType().getName();
+ if (!(Modifier.isProtected(meth.getModifiers())
+ || Modifier.isPublic(meth.getModifiers())))
+ addError(loc.get("subclasser-private-accessors-unsupported",
+ className, meth.getName()), fmd);
+ if (Modifier.isFinal(meth.getModifiers()))
+ addError(loc.get("subclasser-final-methods-not-allowed",
+ className, meth.getName()), fmd);
+ if (Modifier.isNative(meth.getModifiers()))
+ addContractViolation(loc.get
+ ("subclasser-native-methods-not-allowed", className,
+ meth.getName()),
+ fmd);
+ if (Modifier.isStatic(meth.getModifiers()))
+ addError(loc.get("subclasser-static-methods-not-supported",
+ className, meth.getName()), fmd);
+ }
+
+ private void addError(Message s, ClassMetaData cls) {
+ if (errors == null)
+ errors = new ArrayList();
+
+ errors.add(loc.get("subclasser-error-meta", s,
+ cls.getDescribedType().getName(),
+ cls.getSourceFile()));
+ }
+
+ private void addError(Message s, FieldMetaData fmd) {
+ if (errors == null)
+ errors = new ArrayList();
+
+ errors.add(loc.get("subclasser-error-field", s,
+ fmd.getFullName(),
+ fmd.getDeclaringMetaData().getSourceFile()));
+ }
+
+ private void addContractViolation(Message m, FieldMetaData fmd) {
+ // add the violation as an error in case we're processing violations
+ // as errors; this keeps them in the order that they were found rather
+ // than just adding the violations to the end of the list.
+ if (failOnContractViolations)
+ addError(m, fmd);
+
+ if (contractViolations == null)
+ contractViolations = new ArrayList();
+
+ contractViolations.add(loc.get
+ ("subclasser-contract-violation-field", m.getMessage(),
+ fmd.getFullName(), fmd.getDeclaringMetaData().getSourceFile()));
+ }
+}
Propchange: openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCSubclassValidator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PersistenceCapable.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/RedefinitionHelper.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/RedefinitionHelper.java?rev=757280&r1=757279&r2=757280&view=diff
==============================================================================
--- openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/RedefinitionHelper.java (original)
+++ openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/RedefinitionHelper.java Sun Mar 22 23:45:15 2009
@@ -1,188 +1,188 @@
-/*
- * 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.openjpa.enhance;
-
-import org.apache.openjpa.kernel.OpenJPAStateManager;
-import org.apache.openjpa.kernel.StateManagerImpl;
-import org.apache.openjpa.util.ImplHelper;
-
-/**
- * Helper methods for managed types that use method redefinition for field
- * tracking.
- *
- * @since 1.0.0
- */
-public class RedefinitionHelper {
-
- /**
- * Call {@link StateManagerImpl#dirtyCheck} if the argument is a
- * {@link StateManagerImpl}.
- */
- public static void dirtyCheck(StateManager sm) {
- if (sm instanceof StateManagerImpl)
- ((StateManagerImpl) sm).dirtyCheck();
- }
-
- /**
- * Notify the state manager for <code>o</code> (if any) that a field
- * is about to be accessed.
- */
- public static void accessingField(Object o, int absoluteIndex) {
- PersistenceCapable pc = ImplHelper.toPersistenceCapable(o, null);
- if (pc == null)
- return;
- StateManager sm = pc.pcGetStateManager();
- if (sm != null)
- sm.accessingField(absoluteIndex);
- }
-
- /**
- * Setting state callback.
- */
- public static void settingField(Object o, int idx, boolean cur,
- boolean next) {
- PersistenceCapable pc = ImplHelper.toPersistenceCapable(o, null);
- if (pc == null)
- return;
- StateManager sm = pc.pcGetStateManager();
- if (sm != null)
- sm.settingBooleanField(pc, idx, cur, next,
- OpenJPAStateManager.SET_USER);
- }
-
- /**
- * Setting state callback.
- */
- public static void settingField(Object o, int idx, char cur, char next) {
- PersistenceCapable pc = ImplHelper.toPersistenceCapable(o, null);
- if (pc == null)
- return;
- StateManager sm = pc.pcGetStateManager();
- if (sm != null)
- sm.settingCharField(pc, idx, cur, next,
- OpenJPAStateManager.SET_USER);
- }
-
- /**
- * Setting state callback.
- */
- public static void settingField(Object o, int idx, byte cur, byte next) {
- PersistenceCapable pc = ImplHelper.toPersistenceCapable(o, null);
- if (pc == null)
- return;
- StateManager sm = pc.pcGetStateManager();
- if (sm != null)
- sm.settingByteField(pc, idx, cur, next,
- OpenJPAStateManager.SET_USER);
- }
-
- /**
- * Setting state callback.
- */
- public static void settingField(Object o, int idx, short cur, short next) {
- PersistenceCapable pc = ImplHelper.toPersistenceCapable(o, null);
- if (pc == null)
- return;
- StateManager sm = pc.pcGetStateManager();
- if (sm != null)
- sm.settingShortField(pc, idx, cur, next,
- OpenJPAStateManager.SET_USER);
- }
-
- /**
- * Setting state callback.
- */
- public static void settingField(Object o, int idx, int cur, int next) {
- PersistenceCapable pc = ImplHelper.toPersistenceCapable(o, null);
- if (pc == null)
- return;
- StateManager sm = pc.pcGetStateManager();
- if (sm != null)
- sm.settingIntField(pc, idx, cur, next,
- OpenJPAStateManager.SET_USER);
- }
-
- /**
- * Setting state callback.
- */
- public static void settingField(Object o, int idx, long cur, long next) {
- PersistenceCapable pc = ImplHelper.toPersistenceCapable(o, null);
- if (pc == null)
- return;
- StateManager sm = pc.pcGetStateManager();
- if (sm != null)
- sm.settingLongField(pc, idx, cur, next,
- OpenJPAStateManager.SET_USER);
- }
-
- /**
- * Setting state callback.
- */
- public static void settingField(Object o, int idx, float cur, float next) {
- PersistenceCapable pc = ImplHelper.toPersistenceCapable(o, null);
- if (pc == null)
- return;
- StateManager sm = pc.pcGetStateManager();
- if (sm != null)
- sm.settingFloatField(pc, idx, cur, next,
- OpenJPAStateManager.SET_USER);
- }
-
- /**
- * Setting state callback.
- */
- public static void settingField(Object o, int idx, double cur,
- double next) {
- PersistenceCapable pc = ImplHelper.toPersistenceCapable(o, null);
- if (pc == null)
- return;
- StateManager sm = pc.pcGetStateManager();
- if (sm != null)
- sm.settingDoubleField(pc, idx, cur, next,
- OpenJPAStateManager.SET_USER);
- }
-
- /**
- * Setting state callback.
- */
- public static void settingField(Object o, int idx, String cur,
- String next) {
- PersistenceCapable pc = ImplHelper.toPersistenceCapable(o, null);
- if (pc == null)
- return;
- StateManager sm = pc.pcGetStateManager();
- if (sm != null)
- sm.settingStringField(pc, idx, cur, next,
- OpenJPAStateManager.SET_USER);
- }
-
- /**
- * Setting state callback.
- */
- public static void settingField(Object o, int idx, Object cur,
- Object next) {
- PersistenceCapable pc = ImplHelper.toPersistenceCapable(o, null);
- if (pc == null)
- return;
- StateManager sm = pc.pcGetStateManager();
- if (sm != null)
- sm.settingObjectField(pc, idx, cur, next,
- OpenJPAStateManager.SET_USER);
- }
-}
+/*
+ * 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.openjpa.enhance;
+
+import org.apache.openjpa.kernel.OpenJPAStateManager;
+import org.apache.openjpa.kernel.StateManagerImpl;
+import org.apache.openjpa.util.ImplHelper;
+
+/**
+ * Helper methods for managed types that use method redefinition for field
+ * tracking.
+ *
+ * @since 1.0.0
+ */
+public class RedefinitionHelper {
+
+ /**
+ * Call {@link StateManagerImpl#dirtyCheck} if the argument is a
+ * {@link StateManagerImpl}.
+ */
+ public static void dirtyCheck(StateManager sm) {
+ if (sm instanceof StateManagerImpl)
+ ((StateManagerImpl) sm).dirtyCheck();
+ }
+
+ /**
+ * Notify the state manager for <code>o</code> (if any) that a field
+ * is about to be accessed.
+ */
+ public static void accessingField(Object o, int absoluteIndex) {
+ PersistenceCapable pc = ImplHelper.toPersistenceCapable(o, null);
+ if (pc == null)
+ return;
+ StateManager sm = pc.pcGetStateManager();
+ if (sm != null)
+ sm.accessingField(absoluteIndex);
+ }
+
+ /**
+ * Setting state callback.
+ */
+ public static void settingField(Object o, int idx, boolean cur,
+ boolean next) {
+ PersistenceCapable pc = ImplHelper.toPersistenceCapable(o, null);
+ if (pc == null)
+ return;
+ StateManager sm = pc.pcGetStateManager();
+ if (sm != null)
+ sm.settingBooleanField(pc, idx, cur, next,
+ OpenJPAStateManager.SET_USER);
+ }
+
+ /**
+ * Setting state callback.
+ */
+ public static void settingField(Object o, int idx, char cur, char next) {
+ PersistenceCapable pc = ImplHelper.toPersistenceCapable(o, null);
+ if (pc == null)
+ return;
+ StateManager sm = pc.pcGetStateManager();
+ if (sm != null)
+ sm.settingCharField(pc, idx, cur, next,
+ OpenJPAStateManager.SET_USER);
+ }
+
+ /**
+ * Setting state callback.
+ */
+ public static void settingField(Object o, int idx, byte cur, byte next) {
+ PersistenceCapable pc = ImplHelper.toPersistenceCapable(o, null);
+ if (pc == null)
+ return;
+ StateManager sm = pc.pcGetStateManager();
+ if (sm != null)
+ sm.settingByteField(pc, idx, cur, next,
+ OpenJPAStateManager.SET_USER);
+ }
+
+ /**
+ * Setting state callback.
+ */
+ public static void settingField(Object o, int idx, short cur, short next) {
+ PersistenceCapable pc = ImplHelper.toPersistenceCapable(o, null);
+ if (pc == null)
+ return;
+ StateManager sm = pc.pcGetStateManager();
+ if (sm != null)
+ sm.settingShortField(pc, idx, cur, next,
+ OpenJPAStateManager.SET_USER);
+ }
+
+ /**
+ * Setting state callback.
+ */
+ public static void settingField(Object o, int idx, int cur, int next) {
+ PersistenceCapable pc = ImplHelper.toPersistenceCapable(o, null);
+ if (pc == null)
+ return;
+ StateManager sm = pc.pcGetStateManager();
+ if (sm != null)
+ sm.settingIntField(pc, idx, cur, next,
+ OpenJPAStateManager.SET_USER);
+ }
+
+ /**
+ * Setting state callback.
+ */
+ public static void settingField(Object o, int idx, long cur, long next) {
+ PersistenceCapable pc = ImplHelper.toPersistenceCapable(o, null);
+ if (pc == null)
+ return;
+ StateManager sm = pc.pcGetStateManager();
+ if (sm != null)
+ sm.settingLongField(pc, idx, cur, next,
+ OpenJPAStateManager.SET_USER);
+ }
+
+ /**
+ * Setting state callback.
+ */
+ public static void settingField(Object o, int idx, float cur, float next) {
+ PersistenceCapable pc = ImplHelper.toPersistenceCapable(o, null);
+ if (pc == null)
+ return;
+ StateManager sm = pc.pcGetStateManager();
+ if (sm != null)
+ sm.settingFloatField(pc, idx, cur, next,
+ OpenJPAStateManager.SET_USER);
+ }
+
+ /**
+ * Setting state callback.
+ */
+ public static void settingField(Object o, int idx, double cur,
+ double next) {
+ PersistenceCapable pc = ImplHelper.toPersistenceCapable(o, null);
+ if (pc == null)
+ return;
+ StateManager sm = pc.pcGetStateManager();
+ if (sm != null)
+ sm.settingDoubleField(pc, idx, cur, next,
+ OpenJPAStateManager.SET_USER);
+ }
+
+ /**
+ * Setting state callback.
+ */
+ public static void settingField(Object o, int idx, String cur,
+ String next) {
+ PersistenceCapable pc = ImplHelper.toPersistenceCapable(o, null);
+ if (pc == null)
+ return;
+ StateManager sm = pc.pcGetStateManager();
+ if (sm != null)
+ sm.settingStringField(pc, idx, cur, next,
+ OpenJPAStateManager.SET_USER);
+ }
+
+ /**
+ * Setting state callback.
+ */
+ public static void settingField(Object o, int idx, Object cur,
+ Object next) {
+ PersistenceCapable pc = ImplHelper.toPersistenceCapable(o, null);
+ if (pc == null)
+ return;
+ StateManager sm = pc.pcGetStateManager();
+ if (sm != null)
+ sm.settingObjectField(pc, idx, cur, next,
+ OpenJPAStateManager.SET_USER);
+ }
+}
Propchange: openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/RedefinitionHelper.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/ReflectingPersistenceCapable.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/ReflectingPersistenceCapable.java?rev=757280&r1=757279&r2=757280&view=diff
==============================================================================
--- openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/ReflectingPersistenceCapable.java (original)
+++ openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/ReflectingPersistenceCapable.java Sun Mar 22 23:45:15 2009
@@ -1,353 +1,353 @@
-/*
- * 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.openjpa.enhance;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-
-import org.apache.openjpa.meta.ClassMetaData;
-import org.apache.openjpa.meta.JavaTypes;
-import org.apache.openjpa.meta.FieldMetaData;
-import org.apache.openjpa.conf.OpenJPAConfiguration;
-import org.apache.openjpa.util.ApplicationIds;
-import org.apache.openjpa.util.InternalException;
-import org.apache.openjpa.util.ObjectId;
-import org.apache.openjpa.kernel.StateManagerImpl;
-
-/**
- * Implementation of the {@link PersistenceCapable} interface that can handle
- * the persistence-capable contract for instances that were not enhanced
- * before class load time.
- *
- * @since 1.0.0
- */
-public class ReflectingPersistenceCapable
- implements PersistenceCapable, ManagedInstanceProvider {
-
- private Object o;
- private StateManager sm;
- private PersistenceCapable pcSubclassInstance;
- private ClassMetaData meta;
-
- public ReflectingPersistenceCapable(Object o, OpenJPAConfiguration conf) {
- this.o = o;
- Class type = o.getClass();
- pcSubclassInstance = PCRegistry.newInstance(type, null, false);
- meta = conf.getMetaDataRepositoryInstance()
- .getMetaData(type, null, true);
- }
-
- public int pcGetEnhancementContractVersion() {
- return PCEnhancer.ENHANCER_VERSION;
- }
-
- public Object pcGetGenericContext() {
- if (sm == null)
- return null;
- else
- return sm.getGenericContext();
- }
-
- public StateManager pcGetStateManager() {
- return sm;
- }
-
- public void pcReplaceStateManager(StateManager sm) {
- this.sm = sm;
- }
-
- public void pcProvideField(int i) {
- switch (meta.getField(i).getTypeCode()) {
- case JavaTypes.BOOLEAN:
- sm.providedBooleanField(this, i,
- ((Boolean) getValue(i, o)).booleanValue());
- break;
- case JavaTypes.BYTE:
- sm.providedByteField(this, i,
- ((Byte) getValue(i, o)).byteValue());
- break;
- case JavaTypes.CHAR:
- sm.providedCharField(this, i,
- ((Character) getValue(i, o)).charValue());
- break;
- case JavaTypes.DOUBLE:
- sm.providedDoubleField(this, i,
- ((Double) getValue(i, o)).doubleValue());
- break;
- case JavaTypes.FLOAT:
- sm.providedFloatField(this, i,
- ((Float) getValue(i, o)).floatValue());
- break;
- case JavaTypes.INT:
- sm.providedIntField(this, i,
- ((Integer) getValue(i, o)).intValue());
- break;
- case JavaTypes.LONG:
- sm.providedLongField(this, i,
- ((Long) getValue(i, o)).longValue());
- break;
- case JavaTypes.SHORT:
- sm.providedShortField(this, i,
- ((Short) getValue(i, o)).shortValue());
- break;
- case JavaTypes.STRING:
- sm.providedStringField(this, i,
- (String) getValue(i, o));
- break;
- default:
- sm.providedObjectField(this, i, getValue(i, o));
- break;
- }
- }
-
- public void pcProvideFields(int[] fieldIndices) {
- for(int i = 0; i < fieldIndices.length; i++)
- pcProvideField(fieldIndices[i]);
- }
-
- public void pcReplaceField(int i) {
- switch(meta.getField(i).getTypeCode()) {
- case JavaTypes.BOOLEAN:
- setValue(i, o, Boolean.valueOf(
- sm.replaceBooleanField(this, i)));
- break;
- case JavaTypes.BYTE:
- setValue(i, o, new Byte(sm.replaceByteField(this, i)));
- break;
- case JavaTypes.CHAR:
- setValue(i, o, new Character(sm.replaceCharField(this, i)));
- break;
- case JavaTypes.DOUBLE:
- setValue(i, o, new Double(sm.replaceDoubleField(this, i)));
- break;
- case JavaTypes.FLOAT:
- setValue(i, o, new Float(sm.replaceFloatField(this, i)));
- break;
- case JavaTypes.INT:
- setValue(i, o, new Integer(sm.replaceIntField(this, i)));
- break;
- case JavaTypes.LONG:
- setValue(i, o, new Long(sm.replaceLongField(this, i)));
- break;
- case JavaTypes.SHORT:
- setValue(i, o, new Short(sm.replaceShortField(this, i)));
- break;
- case JavaTypes.STRING:
- setValue(i, o, sm.replaceStringField(this, i));
- break;
- default:
- setValue(i, o, sm.replaceObjectField(this, i));
- break;
- }
- }
-
- public void pcReplaceFields(int[] fieldIndices) {
- for(int i = 0; i < fieldIndices.length; i++)
- pcReplaceField(fieldIndices[i]);
- }
-
- public void pcCopyField(Object fromObject, int i) {
- // this doesn't need switch treatment because we're just
- // reflecting on both sides, bypassing field managers.
- setValue(i, o, getValue(i, fromObject));
- }
-
- public void pcCopyFields(Object fromObject, int[] fieldIndices) {
- for(int i = 0; i < fieldIndices.length; i++)
- pcCopyField(fromObject, fieldIndices[i]);
- }
-
- public void pcDirty(String fieldName) {
- if (sm != null)
- sm.dirty(fieldName);
- }
-
- public Object pcFetchObjectId() {
- if (sm != null)
- return sm.fetchObjectId();
- else
- return null;
- }
-
- public Object pcGetVersion() {
- if (sm == null)
- return null;
- else
- return sm.getVersion();
- }
-
- public boolean pcIsDirty() {
- if (sm == null)
- return false;
- else {
- if (sm instanceof StateManagerImpl)
- ((StateManagerImpl) sm).dirtyCheck();
- return sm.isDirty();
- }
- }
-
- public boolean pcIsTransactional() {
- if (sm == null)
- return false;
- else
- return sm.isTransactional();
- }
-
- public boolean pcIsPersistent() {
- if (sm == null)
- return false;
- else
- return sm.isPersistent();
- }
-
- public boolean pcIsNew() {
- if (sm == null)
- return false;
- else
- return sm.isNew();
- }
-
- public boolean pcIsDeleted() {
- if (sm == null)
- return false;
- else
- return sm.isDeleted();
- }
-
- // null == unknown
- public Boolean pcIsDetached() {
- if (sm != null)
- return Boolean.valueOf(sm.isDetached());
-
- // ##### we could do a lot more here if a detached state field
- // ##### was specified.
- return null;
- }
-
- public PersistenceCapable pcNewInstance(StateManager sm, boolean clear) {
- return pcSubclassInstance.pcNewInstance(sm, clear);
- }
-
- public PersistenceCapable pcNewInstance(StateManager sm, Object oid,
- boolean clear) {
- return pcSubclassInstance.pcNewInstance(sm, oid, clear);
- }
-
- public Object pcNewObjectIdInstance() {
- FieldMetaData[] pkFields = meta.getPrimaryKeyFields();
- Object[] pks = new Object[pkFields.length];
- for (int i = 0; i < pkFields.length; i++)
- pks[i] = getValue(pkFields[i].getIndex(), o);
- return ApplicationIds.fromPKValues(pks, meta);
- }
-
- public Object pcNewObjectIdInstance(Object oid) {
- return pcSubclassInstance.pcNewObjectIdInstance(oid);
- }
-
- public void pcCopyKeyFieldsToObjectId(Object oid) {
- Object target;
- if (oid instanceof ObjectId)
- target = ((ObjectId) oid).getId();
- else
- target = oid;
-
- FieldMetaData[] pks = meta.getPrimaryKeyFields();
- for (int i = 0; i < pks.length; i++) {
- Object val = getValue(pks[i].getIndex(), o);
- Field f = Reflection.findField(target.getClass(), pks[i].getName(),
- true);
- Reflection.set(target, f, val);
- }
- }
-
- public void pcCopyKeyFieldsToObjectId(FieldSupplier supplier, Object obj) {
- // This is only ever invoked against PCs in the PCRegistry. Such PCs
- // will always be enhanced types or subtypes of user types, and will
- // never be a ReflectingPersistenceCapable.
- throw new InternalException();
- }
-
- public void pcCopyKeyFieldsFromObjectId(FieldConsumer consumer,
- Object obj) {
- // This is only ever invoked against PCs in the PCRegistry. Such PCs
- // will always be enhanced types or subtypes of user types, and will
- // never be a ReflectingPersistenceCapable.
- throw new InternalException();
- }
-
- public Object pcGetDetachedState() {
- // ##### we can implement this if a state field has been set
- return null;
- }
-
- public void pcSetDetachedState(Object state) {
- // StateManagerImpl will invoke this with null during instance
- // initialization
- if (state != null)
- throw new UnsupportedOperationException();
- // ##### we can implement this if a state field has been set
- }
-
- public Object getManagedInstance() {
- return o;
- }
-
- private Object getValue(int i, Object o) {
- if (meta.getAccessType() == ClassMetaData.ACCESS_PROPERTY) {
- if (!meta.isIntercepting()) {
- Method meth = Reflection.findGetter(meta.getDescribedType(),
- meta.getField(i).getName(), true);
- return Reflection.get(o, meth);
- } else {
- Field field = Reflection.findField(meta.getDescribedType(),
- toFieldName(i), true);
- return Reflection.get(o, field);
- }
- } else {
- Field field = (Field) meta.getField(i).getBackingMember();
- return Reflection.get(o, field);
- }
- }
-
- private String toFieldName(int i) {
- if (pcSubclassInstance instanceof AttributeTranslator)
- return ((AttributeTranslator) pcSubclassInstance)
- .pcAttributeIndexToFieldName(i);
- else
- return meta.getField(i).getName();
- }
-
- private void setValue(int i, Object o, Object val) {
- if (meta.getAccessType() == ClassMetaData.ACCESS_PROPERTY) {
- if (!meta.isIntercepting()) {
- Method meth = Reflection.findSetter(meta.getDescribedType(),
- meta.getField(i).getName(), true);
- Reflection.set(o, meth, val);
- } else {
- Field field = Reflection.findField(meta.getDescribedType(),
- toFieldName(i), true);
- Reflection.set(o, field, val);
- }
- } else {
- Field field = (Field) meta.getField(i).getBackingMember();
- Reflection.set(o, field, val);
- }
- }
-}
+/*
+ * 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.openjpa.enhance;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import org.apache.openjpa.meta.ClassMetaData;
+import org.apache.openjpa.meta.JavaTypes;
+import org.apache.openjpa.meta.FieldMetaData;
+import org.apache.openjpa.conf.OpenJPAConfiguration;
+import org.apache.openjpa.util.ApplicationIds;
+import org.apache.openjpa.util.InternalException;
+import org.apache.openjpa.util.ObjectId;
+import org.apache.openjpa.kernel.StateManagerImpl;
+
+/**
+ * Implementation of the {@link PersistenceCapable} interface that can handle
+ * the persistence-capable contract for instances that were not enhanced
+ * before class load time.
+ *
+ * @since 1.0.0
+ */
+public class ReflectingPersistenceCapable
+ implements PersistenceCapable, ManagedInstanceProvider {
+
+ private Object o;
+ private StateManager sm;
+ private PersistenceCapable pcSubclassInstance;
+ private ClassMetaData meta;
+
+ public ReflectingPersistenceCapable(Object o, OpenJPAConfiguration conf) {
+ this.o = o;
+ Class type = o.getClass();
+ pcSubclassInstance = PCRegistry.newInstance(type, null, false);
+ meta = conf.getMetaDataRepositoryInstance()
+ .getMetaData(type, null, true);
+ }
+
+ public int pcGetEnhancementContractVersion() {
+ return PCEnhancer.ENHANCER_VERSION;
+ }
+
+ public Object pcGetGenericContext() {
+ if (sm == null)
+ return null;
+ else
+ return sm.getGenericContext();
+ }
+
+ public StateManager pcGetStateManager() {
+ return sm;
+ }
+
+ public void pcReplaceStateManager(StateManager sm) {
+ this.sm = sm;
+ }
+
+ public void pcProvideField(int i) {
+ switch (meta.getField(i).getTypeCode()) {
+ case JavaTypes.BOOLEAN:
+ sm.providedBooleanField(this, i,
+ ((Boolean) getValue(i, o)).booleanValue());
+ break;
+ case JavaTypes.BYTE:
+ sm.providedByteField(this, i,
+ ((Byte) getValue(i, o)).byteValue());
+ break;
+ case JavaTypes.CHAR:
+ sm.providedCharField(this, i,
+ ((Character) getValue(i, o)).charValue());
+ break;
+ case JavaTypes.DOUBLE:
+ sm.providedDoubleField(this, i,
+ ((Double) getValue(i, o)).doubleValue());
+ break;
+ case JavaTypes.FLOAT:
+ sm.providedFloatField(this, i,
+ ((Float) getValue(i, o)).floatValue());
+ break;
+ case JavaTypes.INT:
+ sm.providedIntField(this, i,
+ ((Integer) getValue(i, o)).intValue());
+ break;
+ case JavaTypes.LONG:
+ sm.providedLongField(this, i,
+ ((Long) getValue(i, o)).longValue());
+ break;
+ case JavaTypes.SHORT:
+ sm.providedShortField(this, i,
+ ((Short) getValue(i, o)).shortValue());
+ break;
+ case JavaTypes.STRING:
+ sm.providedStringField(this, i,
+ (String) getValue(i, o));
+ break;
+ default:
+ sm.providedObjectField(this, i, getValue(i, o));
+ break;
+ }
+ }
+
+ public void pcProvideFields(int[] fieldIndices) {
+ for(int i = 0; i < fieldIndices.length; i++)
+ pcProvideField(fieldIndices[i]);
+ }
+
+ public void pcReplaceField(int i) {
+ switch(meta.getField(i).getTypeCode()) {
+ case JavaTypes.BOOLEAN:
+ setValue(i, o, Boolean.valueOf(
+ sm.replaceBooleanField(this, i)));
+ break;
+ case JavaTypes.BYTE:
+ setValue(i, o, new Byte(sm.replaceByteField(this, i)));
+ break;
+ case JavaTypes.CHAR:
+ setValue(i, o, new Character(sm.replaceCharField(this, i)));
+ break;
+ case JavaTypes.DOUBLE:
+ setValue(i, o, new Double(sm.replaceDoubleField(this, i)));
+ break;
+ case JavaTypes.FLOAT:
+ setValue(i, o, new Float(sm.replaceFloatField(this, i)));
+ break;
+ case JavaTypes.INT:
+ setValue(i, o, new Integer(sm.replaceIntField(this, i)));
+ break;
+ case JavaTypes.LONG:
+ setValue(i, o, new Long(sm.replaceLongField(this, i)));
+ break;
+ case JavaTypes.SHORT:
+ setValue(i, o, new Short(sm.replaceShortField(this, i)));
+ break;
+ case JavaTypes.STRING:
+ setValue(i, o, sm.replaceStringField(this, i));
+ break;
+ default:
+ setValue(i, o, sm.replaceObjectField(this, i));
+ break;
+ }
+ }
+
+ public void pcReplaceFields(int[] fieldIndices) {
+ for(int i = 0; i < fieldIndices.length; i++)
+ pcReplaceField(fieldIndices[i]);
+ }
+
+ public void pcCopyField(Object fromObject, int i) {
+ // this doesn't need switch treatment because we're just
+ // reflecting on both sides, bypassing field managers.
+ setValue(i, o, getValue(i, fromObject));
+ }
+
+ public void pcCopyFields(Object fromObject, int[] fieldIndices) {
+ for(int i = 0; i < fieldIndices.length; i++)
+ pcCopyField(fromObject, fieldIndices[i]);
+ }
+
+ public void pcDirty(String fieldName) {
+ if (sm != null)
+ sm.dirty(fieldName);
+ }
+
+ public Object pcFetchObjectId() {
+ if (sm != null)
+ return sm.fetchObjectId();
+ else
+ return null;
+ }
+
+ public Object pcGetVersion() {
+ if (sm == null)
+ return null;
+ else
+ return sm.getVersion();
+ }
+
+ public boolean pcIsDirty() {
+ if (sm == null)
+ return false;
+ else {
+ if (sm instanceof StateManagerImpl)
+ ((StateManagerImpl) sm).dirtyCheck();
+ return sm.isDirty();
+ }
+ }
+
+ public boolean pcIsTransactional() {
+ if (sm == null)
+ return false;
+ else
+ return sm.isTransactional();
+ }
+
+ public boolean pcIsPersistent() {
+ if (sm == null)
+ return false;
+ else
+ return sm.isPersistent();
+ }
+
+ public boolean pcIsNew() {
+ if (sm == null)
+ return false;
+ else
+ return sm.isNew();
+ }
+
+ public boolean pcIsDeleted() {
+ if (sm == null)
+ return false;
+ else
+ return sm.isDeleted();
+ }
+
+ // null == unknown
+ public Boolean pcIsDetached() {
+ if (sm != null)
+ return Boolean.valueOf(sm.isDetached());
+
+ // ##### we could do a lot more here if a detached state field
+ // ##### was specified.
+ return null;
+ }
+
+ public PersistenceCapable pcNewInstance(StateManager sm, boolean clear) {
+ return pcSubclassInstance.pcNewInstance(sm, clear);
+ }
+
+ public PersistenceCapable pcNewInstance(StateManager sm, Object oid,
+ boolean clear) {
+ return pcSubclassInstance.pcNewInstance(sm, oid, clear);
+ }
+
+ public Object pcNewObjectIdInstance() {
+ FieldMetaData[] pkFields = meta.getPrimaryKeyFields();
+ Object[] pks = new Object[pkFields.length];
+ for (int i = 0; i < pkFields.length; i++)
+ pks[i] = getValue(pkFields[i].getIndex(), o);
+ return ApplicationIds.fromPKValues(pks, meta);
+ }
+
+ public Object pcNewObjectIdInstance(Object oid) {
+ return pcSubclassInstance.pcNewObjectIdInstance(oid);
+ }
+
+ public void pcCopyKeyFieldsToObjectId(Object oid) {
+ Object target;
+ if (oid instanceof ObjectId)
+ target = ((ObjectId) oid).getId();
+ else
+ target = oid;
+
+ FieldMetaData[] pks = meta.getPrimaryKeyFields();
+ for (int i = 0; i < pks.length; i++) {
+ Object val = getValue(pks[i].getIndex(), o);
+ Field f = Reflection.findField(target.getClass(), pks[i].getName(),
+ true);
+ Reflection.set(target, f, val);
+ }
+ }
+
+ public void pcCopyKeyFieldsToObjectId(FieldSupplier supplier, Object obj) {
+ // This is only ever invoked against PCs in the PCRegistry. Such PCs
+ // will always be enhanced types or subtypes of user types, and will
+ // never be a ReflectingPersistenceCapable.
+ throw new InternalException();
+ }
+
+ public void pcCopyKeyFieldsFromObjectId(FieldConsumer consumer,
+ Object obj) {
+ // This is only ever invoked against PCs in the PCRegistry. Such PCs
+ // will always be enhanced types or subtypes of user types, and will
+ // never be a ReflectingPersistenceCapable.
+ throw new InternalException();
+ }
+
+ public Object pcGetDetachedState() {
+ // ##### we can implement this if a state field has been set
+ return null;
+ }
+
+ public void pcSetDetachedState(Object state) {
+ // StateManagerImpl will invoke this with null during instance
+ // initialization
+ if (state != null)
+ throw new UnsupportedOperationException();
+ // ##### we can implement this if a state field has been set
+ }
+
+ public Object getManagedInstance() {
+ return o;
+ }
+
+ private Object getValue(int i, Object o) {
+ if (meta.getAccessType() == ClassMetaData.ACCESS_PROPERTY) {
+ if (!meta.isIntercepting()) {
+ Method meth = Reflection.findGetter(meta.getDescribedType(),
+ meta.getField(i).getName(), true);
+ return Reflection.get(o, meth);
+ } else {
+ Field field = Reflection.findField(meta.getDescribedType(),
+ toFieldName(i), true);
+ return Reflection.get(o, field);
+ }
+ } else {
+ Field field = (Field) meta.getField(i).getBackingMember();
+ return Reflection.get(o, field);
+ }
+ }
+
+ private String toFieldName(int i) {
+ if (pcSubclassInstance instanceof AttributeTranslator)
+ return ((AttributeTranslator) pcSubclassInstance)
+ .pcAttributeIndexToFieldName(i);
+ else
+ return meta.getField(i).getName();
+ }
+
+ private void setValue(int i, Object o, Object val) {
+ if (meta.getAccessType() == ClassMetaData.ACCESS_PROPERTY) {
+ if (!meta.isIntercepting()) {
+ Method meth = Reflection.findSetter(meta.getDescribedType(),
+ meta.getField(i).getName(), true);
+ Reflection.set(o, meth, val);
+ } else {
+ Field field = Reflection.findField(meta.getDescribedType(),
+ toFieldName(i), true);
+ Reflection.set(o, field, val);
+ }
+ } else {
+ Field field = (Field) meta.getField(i).getBackingMember();
+ Reflection.set(o, field, val);
+ }
+ }
+}
Propchange: openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/ReflectingPersistenceCapable.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/RuntimeUnenhancedClasssesModes.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/RuntimeUnenhancedClasssesModes.java?rev=757280&r1=757279&r2=757280&view=diff
==============================================================================
--- openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/RuntimeUnenhancedClasssesModes.java (original)
+++ openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/RuntimeUnenhancedClasssesModes.java Sun Mar 22 23:45:15 2009
@@ -1,31 +1,31 @@
-/*
- * 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.openjpa.enhance;
-
-/**
- * Possible values for the <code>openjpa.RuntimeUnenhancedClasses</code>
- * configuration setting.
- *
- * @since 1.0.0
- */
-public interface RuntimeUnenhancedClasssesModes {
- public final static int SUPPORTED = 0;
- public final static int UNSUPPORTED = 1;
- public final static int WARN = 2;
-}
+/*
+ * 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.openjpa.enhance;
+
+/**
+ * Possible values for the <code>openjpa.RuntimeUnenhancedClasses</code>
+ * configuration setting.
+ *
+ * @since 1.0.0
+ */
+public interface RuntimeUnenhancedClasssesModes {
+ public final static int SUPPORTED = 0;
+ public final static int UNSUPPORTED = 1;
+ public final static int WARN = 2;
+}
Propchange: openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/RuntimeUnenhancedClasssesModes.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/StateManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/event/AbstractLifecycleListener.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/event/AbstractRemoteCommitProvider.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/event/AbstractTransactionListener.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/event/AttachListener.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/event/BeanLifecycleCallbacks.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/event/BeginTransactionListener.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/event/BrokerFactoryEvent.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/event/BrokerFactoryEvent.java?rev=757280&r1=757279&r2=757280&view=diff
==============================================================================
--- openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/event/BrokerFactoryEvent.java (original)
+++ openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/event/BrokerFactoryEvent.java Sun Mar 22 23:45:15 2009
@@ -1,56 +1,56 @@
-/*
- * 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.openjpa.event;
-
-import java.util.EventObject;
-
-import org.apache.openjpa.kernel.BrokerFactory;
-
-/**
- * Event fired when a {@link BrokerFactory} is created.
- *
- * @since 1.0.0
- */
-public class BrokerFactoryEvent
- extends EventObject {
-
- /**
- * Fired after a {@link BrokerFactory} has been fully created.
- * This happens after the factory has been made read-only.
- */
- public static final int BROKER_FACTORY_CREATED = 0;
-
- private int eventType;
-
- public BrokerFactoryEvent(BrokerFactory brokerFactory, int eventType) {
- super(brokerFactory);
- this.eventType = eventType;
- }
-
- public BrokerFactory getBrokerFactory() {
- return (BrokerFactory) getSource();
- }
-
- /**
- * @return one of the event type codes defined in this event class.
- */
- public int getEventType() {
- return eventType;
- }
-}
+/*
+ * 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.openjpa.event;
+
+import java.util.EventObject;
+
+import org.apache.openjpa.kernel.BrokerFactory;
+
+/**
+ * Event fired when a {@link BrokerFactory} is created.
+ *
+ * @since 1.0.0
+ */
+public class BrokerFactoryEvent
+ extends EventObject {
+
+ /**
+ * Fired after a {@link BrokerFactory} has been fully created.
+ * This happens after the factory has been made read-only.
+ */
+ public static final int BROKER_FACTORY_CREATED = 0;
+
+ private int eventType;
+
+ public BrokerFactoryEvent(BrokerFactory brokerFactory, int eventType) {
+ super(brokerFactory);
+ this.eventType = eventType;
+ }
+
+ public BrokerFactory getBrokerFactory() {
+ return (BrokerFactory) getSource();
+ }
+
+ /**
+ * @return one of the event type codes defined in this event class.
+ */
+ public int getEventType() {
+ return eventType;
+ }
+}
Propchange: openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/event/BrokerFactoryEvent.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/event/BrokerFactoryEventManager.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/event/BrokerFactoryEventManager.java?rev=757280&r1=757279&r2=757280&view=diff
==============================================================================
--- openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/event/BrokerFactoryEventManager.java (original)
+++ openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/event/BrokerFactoryEventManager.java Sun Mar 22 23:45:15 2009
@@ -1,53 +1,53 @@
-/*
- * 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.openjpa.event;
-
-import org.apache.openjpa.lib.util.concurrent.AbstractConcurrentEventManager;
-import org.apache.openjpa.lib.util.Localizer;
-import org.apache.openjpa.lib.conf.Configuration;
-import org.apache.openjpa.conf.OpenJPAConfiguration;
-
-/**
- * {@link EventManager} responsible for notifying listeners of
- * {@link BrokerFactoryEvent}s.
- *
- * @since 1.0.0
- */
-public class BrokerFactoryEventManager
- extends AbstractConcurrentEventManager {
-
- private static final Localizer _loc = Localizer.forPackage(
- BrokerFactoryEventManager.class);
-
- private final Configuration _conf;
-
- public BrokerFactoryEventManager(Configuration conf) {
- _conf = conf;
- }
-
- protected void fireEvent(Object event, Object listener) {
- try {
- BrokerFactoryEvent e = (BrokerFactoryEvent) event;
- ((BrokerFactoryListener) listener).eventFired(e);
- } catch (Exception e) {
- _conf.getLog(OpenJPAConfiguration.LOG_RUNTIME).warn(
- _loc.get("broker-factory-listener-exception"), e);
- }
- }
-}
+/*
+ * 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.openjpa.event;
+
+import org.apache.openjpa.lib.util.concurrent.AbstractConcurrentEventManager;
+import org.apache.openjpa.lib.util.Localizer;
+import org.apache.openjpa.lib.conf.Configuration;
+import org.apache.openjpa.conf.OpenJPAConfiguration;
+
+/**
+ * {@link EventManager} responsible for notifying listeners of
+ * {@link BrokerFactoryEvent}s.
+ *
+ * @since 1.0.0
+ */
+public class BrokerFactoryEventManager
+ extends AbstractConcurrentEventManager {
+
+ private static final Localizer _loc = Localizer.forPackage(
+ BrokerFactoryEventManager.class);
+
+ private final Configuration _conf;
+
+ public BrokerFactoryEventManager(Configuration conf) {
+ _conf = conf;
+ }
+
+ protected void fireEvent(Object event, Object listener) {
+ try {
+ BrokerFactoryEvent e = (BrokerFactoryEvent) event;
+ ((BrokerFactoryListener) listener).eventFired(e);
+ } catch (Exception e) {
+ _conf.getLog(OpenJPAConfiguration.LOG_RUNTIME).warn(
+ _loc.get("broker-factory-listener-exception"), e);
+ }
+ }
+}
Propchange: openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/event/BrokerFactoryEventManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/event/BrokerFactoryListener.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/event/BrokerFactoryListener.java?rev=757280&r1=757279&r2=757280&view=diff
==============================================================================
--- openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/event/BrokerFactoryListener.java (original)
+++ openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/event/BrokerFactoryListener.java Sun Mar 22 23:45:15 2009
@@ -1,35 +1,35 @@
-/*
- * 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.openjpa.event;
-
-/**
- * Interface for listening to {@link BrokerFactoryEvent} objects. Should be
- * registered with a {@link OpenJPAConfiguration}'s
- * {@link BrokerFactoryEventManager}.
- *
- * @since 1.0.0
- */
-public interface BrokerFactoryListener {
-
- /**
- * Invoked after a {@link BrokerFactory} has been fully created.
- * This happens after the factory has been made read-only.
- */
- public void eventFired(BrokerFactoryEvent event);
-}
+/*
+ * 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.openjpa.event;
+
+/**
+ * Interface for listening to {@link BrokerFactoryEvent} objects. Should be
+ * registered with a {@link OpenJPAConfiguration}'s
+ * {@link BrokerFactoryEventManager}.
+ *
+ * @since 1.0.0
+ */
+public interface BrokerFactoryListener {
+
+ /**
+ * Invoked after a {@link BrokerFactory} has been fully created.
+ * This happens after the factory has been made read-only.
+ */
+ public void eventFired(BrokerFactoryEvent event);
+}
Propchange: openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/event/BrokerFactoryListener.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/event/CallbackModes.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/event/ClearListener.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/event/DeleteListener.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/event/DetachListener.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/event/DirtyListener.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/event/EndTransactionListener.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/event/ExceptionOrphanedKeyAction.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/event/FlushTransactionListener.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/event/JMSRemoteCommitProvider.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/event/LifecycleCallbacks.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/event/LifecycleEvent.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/event/LifecycleEventManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/event/LifecycleListener.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/event/LoadListener.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/event/LogOrphanedKeyAction.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/event/MethodLifecycleCallbacks.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/event/NoneOrphanedKeyAction.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/event/OrphanedKeyAction.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/event/PersistListener.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/event/PostDeleteListener.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/event/PostDeleteListener.java?rev=757280&r1=757279&r2=757280&view=diff
==============================================================================
--- openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/event/PostDeleteListener.java (original)
+++ openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/event/PostDeleteListener.java Sun Mar 22 23:45:15 2009
@@ -1,33 +1,33 @@
-/*
- * 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.openjpa.event;
-
-/**
- * @since 1.1.0
- */
-public interface PostDeleteListener {
-
- /**
- * Receives notifications before an update is performed. Differs from
- * {@link DeleteListener#afterDelete(LifecycleEvent)} in that the latter
- * is called after the delete operation, whereas this is called after the
- * delete statements have been sent to the data store.
- */
- public void afterDeletePerformed(LifecycleEvent event);
-}
+/*
+ * 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.openjpa.event;
+
+/**
+ * @since 1.1.0
+ */
+public interface PostDeleteListener {
+
+ /**
+ * Receives notifications before an update is performed. Differs from
+ * {@link DeleteListener#afterDelete(LifecycleEvent)} in that the latter
+ * is called after the delete operation, whereas this is called after the
+ * delete statements have been sent to the data store.
+ */
+ public void afterDeletePerformed(LifecycleEvent event);
+}
Propchange: openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/event/PostDeleteListener.java
------------------------------------------------------------------------------
svn:eol-style = native