mirror of https://github.com/apache/openjpa.git
reformatted comments to follow Sun standards and use the standard ASL comment formatting
git-svn-id: https://svn.apache.org/repos/asf/incubator/openjpa/trunk@421741 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4ddf63ea3f
commit
7cf69d8bcc
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -31,8 +31,8 @@ import org.apache.openjpa.util.GeneralException;
|
|||
import serp.bytecode.Project;
|
||||
|
||||
/**
|
||||
* <p>Transformer that makes persistent classes implement the
|
||||
* {@link PersistenceCapable} interface at runtime.</p>
|
||||
* Transformer that makes persistent classes implement the
|
||||
* {@link PersistenceCapable} interface at runtime.
|
||||
*
|
||||
* @author Abe White
|
||||
* @nojavadoc
|
||||
|
@ -52,9 +52,9 @@ public class PCClassFileTransformer
|
|||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param repos metadata repository to use internally
|
||||
* @param opts enhancer configuration options
|
||||
* @param loader temporary class loader for loading intermediate classes
|
||||
* @param repos metadata repository to use internally
|
||||
* @param opts enhancer configuration options
|
||||
* @param loader temporary class loader for loading intermediate classes
|
||||
*/
|
||||
public PCClassFileTransformer(MetaDataRepository repos, Options opts,
|
||||
ClassLoader loader) {
|
||||
|
@ -79,10 +79,10 @@ public class PCClassFileTransformer
|
|||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param repos metadata repository to use internally
|
||||
* @param flags enhancer configuration
|
||||
* @param loader temporary class loader for loading intermediate classes
|
||||
* @param devscan whether to scan the dev classpath for persistent types
|
||||
* @param repos metadata repository to use internally
|
||||
* @param flags enhancer configuration
|
||||
* @param loader temporary class loader for loading intermediate classes
|
||||
* @param devscan whether to scan the dev classpath for persistent types
|
||||
* if none are configured
|
||||
*/
|
||||
public PCClassFileTransformer(MetaDataRepository repos,
|
||||
|
@ -183,21 +183,21 @@ public class PCClassFileTransformer
|
|||
for (int i = 1; i < entries.length; i++) {
|
||||
entries[i] = idx + 1; // skip entry type
|
||||
switch (b[idx]) {
|
||||
case 1: // utf8
|
||||
case 1: // utf8
|
||||
idx += 3 + readUnsignedShort(b, idx + 1);
|
||||
break;
|
||||
case 3: // integer
|
||||
case 4: // float
|
||||
case 9: // field
|
||||
case 10: // method
|
||||
case 11: // interface method
|
||||
case 12: // name
|
||||
case 3: // integer
|
||||
case 4: // float
|
||||
case 9: // field
|
||||
case 10: // method
|
||||
case 11: // interface method
|
||||
case 12: // name
|
||||
idx += 5;
|
||||
break;
|
||||
case 5: // long
|
||||
case 6: // double
|
||||
case 5: // long
|
||||
case 6: // double
|
||||
idx += 9;
|
||||
i++; // wide entry
|
||||
i++; // wide entry
|
||||
break;
|
||||
default:
|
||||
idx += 3;
|
||||
|
@ -226,7 +226,7 @@ public class PCClassFileTransformer
|
|||
}
|
||||
|
||||
/**
|
||||
* Read an unsigned short from the given array at the given offset.
|
||||
* Read an unsigned short from the given array at the given offset.
|
||||
*/
|
||||
private static int readUnsignedShort(byte[] b, int idx) {
|
||||
return ((b[idx] & 0xFF) << 8) | (b[idx + 1] & 0xFF);
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -26,16 +26,15 @@ import org.apache.openjpa.meta.MetaDataRepository;
|
|||
import org.apache.openjpa.util.ClassResolver;
|
||||
|
||||
/**
|
||||
* <p>Java agent that makes persistent classes implement the
|
||||
* {@link PersistenceCapable} interface at runtime. The agent is launched
|
||||
* at JVM startup from the command line:</p>
|
||||
* <p/>
|
||||
* Java agent that makes persistent classes implement the
|
||||
* {@link PersistenceCapable} interface at runtime. The agent is launched
|
||||
* at JVM startup from the command line:
|
||||
*
|
||||
* <code>java -javaagent:openjpa.jar[=<options>]</code>
|
||||
* <p/>
|
||||
* <p>The options string should be formatted as a OpenJPA plugin, and may
|
||||
* contain any properties understood by the OpenJPA enhancer or any
|
||||
* configuration properties. For example:</p>
|
||||
* <p/>
|
||||
* The options string should be formatted as a OpenJPA plugin, and may
|
||||
* contain any properties understood by the OpenJPA enhancer or any
|
||||
* configuration properties. For example:
|
||||
*
|
||||
* <code>java -javaagent:openjpa.jar</code>
|
||||
*
|
||||
* @author Abe White
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -29,7 +29,7 @@ import org.apache.openjpa.lib.util.Localizer;
|
|||
import org.apache.openjpa.util.UserException;
|
||||
|
||||
/**
|
||||
* <p>{@link BrokerFactory} implementation for use with the
|
||||
* {@link BrokerFactory} implementation for use with the
|
||||
* {@link AbstractStoreManager}. This provides integration into the
|
||||
* {@link Bootstrap#getBrokerFactory()} bootstrapping mechanism, to facilitate
|
||||
* the process of creating a subclass of {@link AbstractStoreManager}. New
|
||||
|
@ -37,13 +37,12 @@ import org.apache.openjpa.util.UserException;
|
|||
* <code>org.apache.openjpa.BrokerFactory</code> configuration property to
|
||||
* <code>abstractstore</code>,
|
||||
* and set the <code>org.apache.openjpa.abstractstore.AbstractStoreManager</code>
|
||||
* configuration property to the full class name of your implementation.</p>
|
||||
* <p/>
|
||||
* <p>Additionally, you can optionally create your own
|
||||
* configuration property to the full class name of your implementation.
|
||||
* Additionally, you can optionally create your own
|
||||
* <code>BrokerFactory</code> implementation. However, we recommend that you
|
||||
* use the <code>AbstractStoreBrokerFactory</code>, as it deals with pooling
|
||||
* and bootstrapping from a {@link Map} object (the strategy used by
|
||||
* {@link Bootstrap} to create a factory in a vendor-neutral manner).</p>
|
||||
* {@link Bootstrap} to create a factory in a vendor-neutral manner).
|
||||
*/
|
||||
public class AbstractStoreBrokerFactory
|
||||
extends AbstractBrokerFactory {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -43,8 +43,8 @@ import org.apache.openjpa.util.Id;
|
|||
import org.apache.openjpa.util.ImplHelper;
|
||||
|
||||
/**
|
||||
* <p>Abstract store manager implementation to ease development of custom
|
||||
* OpenJPA back-ends. A concrete subclass must define implementations for the
|
||||
* Abstract store manager implementation to ease development of custom
|
||||
* OpenJPA back-ends. A concrete subclass must define implementations for the
|
||||
* following methods:
|
||||
* <ul>
|
||||
* <li>{@link StoreManager#exists}</li>
|
||||
|
@ -53,14 +53,12 @@ import org.apache.openjpa.util.ImplHelper;
|
|||
* <li>{@link
|
||||
* #flush(Collection,Collection,Collection,Collection,Collection)}</li>
|
||||
* <li>{@link #executeExtent}</li>
|
||||
* </ul>
|
||||
* Additionally, subclasses should not attempt to acquire resources
|
||||
* until {@link #open} has been called. Store manager instances might be
|
||||
* </ul> Additionally, subclasses should not attempt to acquire resources
|
||||
* until {@link #open} has been called. Store manager instances might be
|
||||
* created to call metadata methods such as {@link #newConfiguration} or
|
||||
* {@link #getUnsupportedOptions} and never opened. These instances should
|
||||
* not consume any data store resources.</p>
|
||||
* <p/>
|
||||
* <p>Notes:
|
||||
* {@link #getUnsupportedOptions} and never opened. These instances should
|
||||
* not consume any data store resources.
|
||||
* Notes:
|
||||
* <ul>
|
||||
* <li>The {@link StoreManager#initialize} method is responsible
|
||||
* for creating new instances of objects freshly loaded from the
|
||||
|
@ -91,7 +89,7 @@ import org.apache.openjpa.util.ImplHelper;
|
|||
* provide that facility on top of your data store), implement
|
||||
* the {@link #getDataStoreIdSequence} method if you want to use a
|
||||
* <code>long</code> as your datastore identity type and are
|
||||
* happy with OpenJPA's {@link Id} class. To use another datastore identity
|
||||
* happy with OpenJPA's {@link Id} class. To use another datastore identity
|
||||
* type, override {@link #getManagedType},
|
||||
* {@link #getDataStoreIdType}, {@link #copyDataStoreId}, and
|
||||
* {@link #newDataStoreId} instead. In either case, override
|
||||
|
@ -113,7 +111,7 @@ import org.apache.openjpa.util.ImplHelper;
|
|||
* {@link org.apache.openjpa.lib.rop.ResultList}. For more details on
|
||||
* MethodQL, see the OpenJPA Reference Guide.</li>
|
||||
* </ul></li>
|
||||
* </ul></p>
|
||||
* </ul>
|
||||
*
|
||||
* @since 3.1
|
||||
*/
|
||||
|
@ -136,8 +134,7 @@ public abstract class AbstractStoreManager
|
|||
}
|
||||
|
||||
/**
|
||||
* No-op implementation. Ready this store manager for persistent
|
||||
* operations.
|
||||
* No-op implementation. Ready this store manager for persistent operations.
|
||||
*/
|
||||
protected void open() {
|
||||
}
|
||||
|
@ -153,20 +150,18 @@ public abstract class AbstractStoreManager
|
|||
/**
|
||||
* No-op implementation. Override this method to provide optimistic
|
||||
* locking semantics for your data store if you need notification of
|
||||
* a rollback of an optimistic transaction before {@link #begin} is
|
||||
* invoked.
|
||||
* a rollback of an optimistic transaction before {@link #begin} is invoked.
|
||||
*/
|
||||
public void rollbackOptimistic() {
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>OpenJPA assumes that after this method is invoked, all data
|
||||
* OpenJPA assumes that after this method is invoked, all data
|
||||
* accesses through this store manager will be part of a single
|
||||
* unit of work that can be rolled back.</p>
|
||||
* <p/>
|
||||
* <p>This is a no-op implementation. If your data store does not
|
||||
* unit of work that can be rolled back.
|
||||
* This is a no-op implementation. If your data store does not
|
||||
* support any concept of locking or transactions, you need not
|
||||
* override this method.</p>
|
||||
* override this method.
|
||||
*/
|
||||
public void begin() {
|
||||
}
|
||||
|
@ -175,8 +170,7 @@ public abstract class AbstractStoreManager
|
|||
* This is a no-op implementation. If your data store does not
|
||||
* have a concept of transactions or a unit of work, you need not
|
||||
* override this method. If it does, then override this method to
|
||||
* notify the data store that the current transaction should be
|
||||
* committed.
|
||||
* notify the data store that the current transaction should be committed.
|
||||
*/
|
||||
public void commit() {
|
||||
}
|
||||
|
@ -185,8 +179,7 @@ public abstract class AbstractStoreManager
|
|||
* This is a no-op implementation. If your data store does not
|
||||
* have a concept of transactions or a unit of work, you need not
|
||||
* override this method. If it does, then override this method to
|
||||
* notify the data store that the current transaction should be
|
||||
* rolled back.
|
||||
* notify the data store that the current transaction should be rolled back.
|
||||
*/
|
||||
public void rollback() {
|
||||
}
|
||||
|
@ -200,15 +193,14 @@ public abstract class AbstractStoreManager
|
|||
}
|
||||
|
||||
/**
|
||||
* <p>This method is invoked when OpenJPA needs to load an object whose
|
||||
* This method is invoked when OpenJPA needs to load an object whose
|
||||
* identity is known but which has not yet been loaded from the data
|
||||
* store. <code>sm</code> is a partially-set-up state manager for this
|
||||
* object. The ID and least-derived type information for the instance
|
||||
* to load can be obtained by invoking
|
||||
* <code>sm.getObjectId()</code> and <code>sm.getMetaData()</code>.
|
||||
* </p>
|
||||
* <p/>
|
||||
* <p>When implementing this method, load the data for this object from
|
||||
*
|
||||
* When implementing this method, load the data for this object from
|
||||
* the data store, determine the most-derived subclass of the newly-loaded
|
||||
* data, and then use the {@link OpenJPAStateManager#initialize} method to
|
||||
* populate <code>sm</code> with a new instance of the appropriate type.
|
||||
|
@ -216,20 +208,19 @@ public abstract class AbstractStoreManager
|
|||
* load field data into <code>sm</code> as in the {@link #load} method, by
|
||||
* using {@link OpenJPAStateManager#store} (or the appropriate
|
||||
* <code>OpenJPAStateManager.store<em>type</em></code> method) to put the
|
||||
* data into the object.</p>
|
||||
* data into the object.
|
||||
*/
|
||||
public abstract boolean initialize(OpenJPAStateManager sm, PCState state,
|
||||
FetchState fetchState, Object context);
|
||||
|
||||
/**
|
||||
* <p>This method is invoked when OpenJPA needs to load additional data
|
||||
* This method is invoked when OpenJPA needs to load additional data
|
||||
* into an object that has already been at least partially loaded by
|
||||
* a previous {@link #initialize} invocation.</p>
|
||||
* <p/>
|
||||
* <p>Load data into <code>sm</code> by using {@link
|
||||
* a previous {@link #initialize} invocation.
|
||||
* Load data into <code>sm</code> by using {@link
|
||||
* OpenJPAStateManager#store} (or the appropriate
|
||||
* <code>OpenJPAStateManager.store<em>type</em></code> method) to put the
|
||||
* data into the object.</p>
|
||||
* data into the object.
|
||||
*/
|
||||
public abstract boolean load(OpenJPAStateManager sm, BitSet fields,
|
||||
FetchState fetchState, int lockLevel, Object context);
|
||||
|
@ -300,7 +291,7 @@ public abstract class AbstractStoreManager
|
|||
}
|
||||
|
||||
/**
|
||||
* Assign a new datastore identity to the given instance. This given
|
||||
* Assign a new datastore identity to the given instance. This given
|
||||
* value may be null.
|
||||
*/
|
||||
protected boolean assignDataStoreId(OpenJPAStateManager sm, Object val) {
|
||||
|
@ -367,15 +358,13 @@ public abstract class AbstractStoreManager
|
|||
}
|
||||
|
||||
/**
|
||||
* <p>Create a {@link ResultObjectProvider} that can return all instances
|
||||
* Create a {@link ResultObjectProvider} that can return all instances
|
||||
* of <code>type</code>, optionally including subclasses as defined
|
||||
* by <code>subclasses</code>.</p>
|
||||
* <p/>
|
||||
* <p>The implementation of the result provider will typically execute
|
||||
* by <code>subclasses</code>.
|
||||
* The implementation of the result provider will typically execute
|
||||
* some sort of data store query to find all the applicable objects, loop
|
||||
* through the returned data, extracting object IDs from the data, and
|
||||
* invoking {@link
|
||||
* StoreContext#find(Object,FetchState,BitSet,Object,int)}
|
||||
* invoking {@link StoreContext#find(Object,FetchState,BitSet,Object,int)}
|
||||
* on each OID. When invoking this method, the first argument is the OID.
|
||||
* The second is the given fetch configuration. The
|
||||
* third argument is a mask of fields to exclude from loading; it will
|
||||
|
@ -385,7 +374,7 @@ public abstract class AbstractStoreManager
|
|||
* manager, this might be the result set that is being iterated over. If
|
||||
* this argument is <code>null</code>, then the {@link #initialize} or
|
||||
* {@link #load} method will have to issue another command to the data
|
||||
* store in order to fetch the data to be loaded.</p>
|
||||
* store in order to fetch the data to be loaded.
|
||||
*/
|
||||
public abstract ResultObjectProvider executeExtent(ClassMetaData meta,
|
||||
boolean subs, FetchConfiguration fetch);
|
||||
|
@ -399,12 +388,12 @@ public abstract class AbstractStoreManager
|
|||
}
|
||||
|
||||
/**
|
||||
* <p>Casts <code>v1</code> and <code>v2</code> to {@link Comparable}, and
|
||||
* Casts <code>v1</code> and <code>v2</code> to {@link Comparable}, and
|
||||
* invokes <code>v1.compareTo (v2)</code>. If <code>v1</code> is less
|
||||
* than <code>v2</code>, returns {@link #VERSION_EARLIER}. If the same,
|
||||
* returns {@link #VERSION_SAME}. Otherwise, returns {@link
|
||||
* #VERSION_LATER}. If either <code>v1</code> or <code>v2</code> are
|
||||
* <code>null</code>, returns {@link #VERSION_DIFFERENT}.</p>
|
||||
* <code>null</code>, returns {@link #VERSION_DIFFERENT}.
|
||||
*/
|
||||
public int compareVersion(OpenJPAStateManager state, Object v1, Object v2) {
|
||||
if (v1 == null || v2 == null)
|
||||
|
@ -450,40 +439,35 @@ public abstract class AbstractStoreManager
|
|||
}
|
||||
|
||||
/**
|
||||
* <p>Responsible for writing modifications happened back to the data
|
||||
* Responsible for writing modifications happened back to the data
|
||||
* store. If you do not remove the
|
||||
* {@link OpenJPAConfiguration#OPTION_INC_FLUSH} option in
|
||||
* {@link #getUnsupportedOptions}, this will be called only once at the
|
||||
* end of a transaction. Otherwise, it may be called periodically
|
||||
* throughout the course of a transaction.</p>
|
||||
* <p/>
|
||||
* <p>If this store manager supports optimistic transactions, datastore
|
||||
* throughout the course of a transaction.
|
||||
* If this store manager supports optimistic transactions, datastore
|
||||
* version information should be updated during flush, and the state
|
||||
* manager's version indicator should be updated through the
|
||||
* {@link OpenJPAStateManager#setNextVersion} method.</p>
|
||||
* <p/>
|
||||
* <p>This method will only be invoked if there are meaningful changes
|
||||
* {@link OpenJPAStateManager#setNextVersion} method.
|
||||
* This method will only be invoked if there are meaningful changes
|
||||
* to store. This differs from the behavior of {@link StoreManager#flush},
|
||||
* which may be invoked with a collection of objects in states that
|
||||
* do not require any datastore action (for example, objects in the
|
||||
* transient-transactional state).</p>
|
||||
* transient-transactional state).
|
||||
*
|
||||
* @param pNew Objects that should be added to the store,
|
||||
* and that have not previously been flushed.
|
||||
* @param pNewUpdated New objects that have been modified since
|
||||
* they were initially flushed. These were
|
||||
* in <code>persistentNew</code> in an earlier
|
||||
* flush invocation.
|
||||
* in <code>persistentNew</code> in an earlier flush invocation.
|
||||
* @param pNewFlushedDeleted New objects that have been deleted since
|
||||
* they were initially flushed. These were
|
||||
* in <code>persistentNew</code> in an earlier
|
||||
* flush invocation.
|
||||
* in <code>persistentNew</code> in an earlier flush invocation.
|
||||
* @param pDirty Objects that were loaded from the data
|
||||
* store and have since been modified.
|
||||
* @param pDeleted Objects that were loaded from the data
|
||||
* store and have since been deleted. These
|
||||
* may have been in a previous flush
|
||||
* invocation's persistentDirty list.
|
||||
* may have been in a previous flush invocation's persistentDirty list.
|
||||
* @return a collection of exceptions encountered during flushing.
|
||||
*/
|
||||
protected abstract Collection flush(Collection pNew,
|
||||
|
@ -491,18 +475,18 @@ public abstract class AbstractStoreManager
|
|||
Collection pDirty, Collection pDeleted);
|
||||
|
||||
/**
|
||||
* Return a new configuration instance for this runtime. Configuration
|
||||
* Return a new configuration instance for this runtime. Configuration
|
||||
* data is maintained at the factory level and is available to all OpenJPA
|
||||
* components; therefore it is a good place to maintain shared resources
|
||||
* such as connection pools, etc.</p>
|
||||
* such as connection pools, etc.
|
||||
*/
|
||||
protected OpenJPAConfiguration newConfiguration() {
|
||||
return new OpenJPAConfigurationImpl();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Returns a set of option names that this store manager does
|
||||
* not support. By default, returns the following:
|
||||
* Returns a set of option names that this store manager does
|
||||
* not support. By default, returns the following:
|
||||
* <ul>
|
||||
* <li>{@link OpenJPAConfiguration#OPTION_OPTIMISTIC}</li>
|
||||
* <li>{@link OpenJPAConfiguration#OPTION_ID_DATASTORE}</li>
|
||||
|
@ -510,7 +494,7 @@ public abstract class AbstractStoreManager
|
|||
* <li>{@link OpenJPAConfiguration#OPTION_VALUE_AUTOASSIGN}</li>
|
||||
* <li>{@link OpenJPAConfiguration#OPTION_VALUE_INCREMENT}</li>
|
||||
* <li>{@link OpenJPAConfiguration#OPTION_DATASTORE_CONNECTION}</li>
|
||||
* </ul></p>
|
||||
* </ul>
|
||||
*/
|
||||
protected Collection getUnsupportedOptions() {
|
||||
Collection c = new HashSet();
|
||||
|
@ -524,9 +508,8 @@ public abstract class AbstractStoreManager
|
|||
}
|
||||
|
||||
/**
|
||||
* <p>Returns a string name to identify the platform of this
|
||||
* store manager. Returns the class name of this store manager by
|
||||
* default.</p>
|
||||
* Returns a string name to identify the platform of this
|
||||
* store manager. Returns the class name of this store manager by default.
|
||||
*/
|
||||
protected String getPlatform ()
|
||||
{
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -13,9 +13,6 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*********************************************************************
|
||||
|
||||
**********************************************************************/
|
||||
package org.apache.openjpa.ant;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -32,11 +29,11 @@ import org.apache.openjpa.lib.util.Localizer;
|
|||
import org.apache.openjpa.meta.MetaDataTool;
|
||||
|
||||
/**
|
||||
* <p>Executes the metadata tool on the specified files. This task can
|
||||
* Executes the metadata tool on the specified files. This task can
|
||||
* take the following arguments:
|
||||
* <ul>
|
||||
* <li><code>file</code></li>
|
||||
* </ul></p>
|
||||
* </ul>
|
||||
*/
|
||||
public class MetaDataToolTask
|
||||
extends AbstractTask {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -13,9 +13,6 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*********************************************************************
|
||||
|
||||
**********************************************************************/
|
||||
package org.apache.openjpa.ant;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -29,14 +26,14 @@ import org.apache.openjpa.lib.util.Files;
|
|||
import org.apache.openjpa.meta.MetaDataRepository;
|
||||
|
||||
/**
|
||||
* <p>Executes the enhancer on the specified files. This task can take
|
||||
* Executes the enhancer on the specified files. This task can take
|
||||
* the following arguments:
|
||||
* <ul>
|
||||
* <li><code>directory</code></li>
|
||||
* <li><code>addDefaultConstructor</code></li>
|
||||
* <li><code>tmpClassLoader</code></li>
|
||||
* <li><code>enforcePropertyRestrictions</code></li>
|
||||
* </ul></p>
|
||||
* </ul>
|
||||
*/
|
||||
public class PCEnhancerTask
|
||||
extends AbstractTask {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -20,8 +20,8 @@ import org.apache.openjpa.lib.conf.Value;
|
|||
import serp.util.Strings;
|
||||
|
||||
/**
|
||||
* <p>Value type used to represent auto detach flags. Separate to
|
||||
* optimize translation of Strings to bit flags.</p>
|
||||
* Value type used to represent auto detach flags. Separate to
|
||||
* optimize translation of Strings to bit flags.
|
||||
*
|
||||
* @author Steve Kim
|
||||
* @nojavadoc
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -19,10 +19,10 @@ import org.apache.openjpa.kernel.BrokerFactory;
|
|||
import org.apache.openjpa.lib.conf.PluginValue;
|
||||
|
||||
/**
|
||||
* <p>Value type used to represent the {@link BrokerFactory}. This type is
|
||||
* Value type used to represent the {@link BrokerFactory}. This type is
|
||||
* defined separately so that it can be used both in the global configuration
|
||||
* and in {@link org.apache.openjpa.kernel.Bootstrap} with the same
|
||||
* encapsulated configuration.</p>
|
||||
* and in {@link org.apache.openjpa.kernel.Bootstrap} with the same
|
||||
* encapsulated configuration.
|
||||
*
|
||||
* @author Abe White
|
||||
* @nojavadoc
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -16,7 +16,7 @@
|
|||
package org.apache.openjpa.conf;
|
||||
|
||||
/**
|
||||
* <p>Struct encompassing backwards-compatibility options.</p>
|
||||
* Struct encompassing backwards-compatibility options.
|
||||
*/
|
||||
public class Compatibility {
|
||||
|
||||
|
@ -29,7 +29,7 @@ public class Compatibility {
|
|||
|
||||
/**
|
||||
* Whether to require exact identity value types when creating object
|
||||
* ids from a class and value. Defaults to false.
|
||||
* ids from a class and value. Defaults to false.
|
||||
*/
|
||||
public boolean getStrictIdentityValues() {
|
||||
return _strictIdValues;
|
||||
|
@ -37,7 +37,7 @@ public class Compatibility {
|
|||
|
||||
/**
|
||||
* Whether to require exact identity value types when creating object
|
||||
* ids from a class and value. Defaults to false.
|
||||
* ids from a class and value. Defaults to false.
|
||||
*/
|
||||
public void setStrictIdentityValues(boolean strictVals) {
|
||||
_strictIdValues = strictVals;
|
||||
|
@ -63,9 +63,9 @@ public class Compatibility {
|
|||
|
||||
/**
|
||||
* Whether to return hollow instances to broker lookups with a
|
||||
* <code>validate</code> parameter of false. OpenJPA versions prior to
|
||||
* <code>validate</code> parameter of false. OpenJPA versions prior to
|
||||
* 4.0 did not return hollow instances without special configuration
|
||||
* (the <code>ObjectLookupMode</code>). Beginning with 4.0, hollow
|
||||
* (the <code>ObjectLookupMode</code>). Beginning with 4.0, hollow
|
||||
* objects are the default.
|
||||
*/
|
||||
public boolean getValidateFalseReturnsHollow() {
|
||||
|
@ -74,9 +74,9 @@ public class Compatibility {
|
|||
|
||||
/**
|
||||
* Whether to return hollow instances to broker lookups with a
|
||||
* <code>validate</code> parameter of false. OpenJPA versions prior to
|
||||
* <code>validate</code> parameter of false. OpenJPA versions prior to
|
||||
* 4.0 did not return hollow instances without special configuration
|
||||
* (the <code>ObjectLookupMode</code>). Beginning with 4.0, hollow
|
||||
* (the <code>ObjectLookupMode</code>). Beginning with 4.0, hollow
|
||||
* objects are the default.
|
||||
*/
|
||||
public void setValidateFalseReturnsHollow(boolean hollow) {
|
||||
|
@ -86,7 +86,7 @@ public class Compatibility {
|
|||
/**
|
||||
* Whether to check the datastore for the existence of a nontransactional
|
||||
* cached object in broker lookups with a <code>validate</code> parameter
|
||||
* of true. OpenJPA versions prior to 4.0 checked the datastore.
|
||||
* of true. OpenJPA versions prior to 4.0 checked the datastore.
|
||||
*/
|
||||
public boolean getValidateTrueChecksStore() {
|
||||
return _checkStore;
|
||||
|
@ -95,7 +95,7 @@ public class Compatibility {
|
|||
/**
|
||||
* Whether to check the datastore for the existence of a nontransactional
|
||||
* cached object in broker lookups with a <code>validate</code> parameter
|
||||
* of true. OpenJPA versions prior to 4.0 checked the datastore.
|
||||
* of true. OpenJPA versions prior to 4.0 checked the datastore.
|
||||
*/
|
||||
public void setValidateTrueChecksStore(boolean check) {
|
||||
_checkStore = check;
|
||||
|
@ -103,7 +103,7 @@ public class Compatibility {
|
|||
|
||||
/**
|
||||
* Whether to copy identity objects before returning them to client code.
|
||||
* Versions of OpenJPA prior to 3.0 always copied identity objects. Also,
|
||||
* Versions of OpenJPA prior to 3.0 always copied identity objects. Also,
|
||||
* you should configure OpenJPA to copy identity objects if you mutate them
|
||||
* after use.
|
||||
*/
|
||||
|
@ -113,7 +113,7 @@ public class Compatibility {
|
|||
|
||||
/**
|
||||
* Whether to copy identity objects before returning them to client code.
|
||||
* Versions of OpenJPA prior to 3.0 always copied identity objects. Also,
|
||||
* Versions of OpenJPA prior to 3.0 always copied identity objects. Also,
|
||||
* you should configure OpenJPA to copy identity objects if you mutate them
|
||||
* after use.
|
||||
*/
|
||||
|
@ -130,8 +130,8 @@ public class Compatibility {
|
|||
}
|
||||
|
||||
/**
|
||||
* Whether to close the broker when the managed transaction commits.
|
||||
* Versions of OpenJPA prior to 3.0 did not close the broker.
|
||||
* Whether to close the broker when the managed transaction commits.
|
||||
* Versions of OpenJPA prior to 3.0 did not close the broker.
|
||||
*/
|
||||
public void setCloseOnManagedCommit(boolean close) {
|
||||
_closeOnCommit = close;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -18,7 +18,7 @@ package org.apache.openjpa.conf;
|
|||
import org.apache.openjpa.kernel.DetachState;
|
||||
|
||||
/**
|
||||
* <p>Detach options.</p>
|
||||
* Detach options.
|
||||
*
|
||||
* @author Abe White
|
||||
* @nojavadoc
|
||||
|
@ -53,7 +53,7 @@ public abstract class DetachOptions
|
|||
}
|
||||
|
||||
/**
|
||||
* For auto-configuration of the detached state field. Accepts values
|
||||
* For auto-configuration of the detached state field. Accepts values
|
||||
* "true", "false", or "transient".
|
||||
*/
|
||||
public void setDetachedStateField(String val) {
|
||||
|
@ -90,7 +90,7 @@ public abstract class DetachOptions
|
|||
* Whether to use a detached state manager on types that allow it.
|
||||
* Types that do not use detached state or that declare a custom detached
|
||||
* state field to maintain serialization compatibility will never use
|
||||
* a detached state manager. Defaults to true.
|
||||
* a detached state manager. Defaults to true.
|
||||
*/
|
||||
public boolean getDetachedStateManager() {
|
||||
return _manager;
|
||||
|
@ -100,14 +100,14 @@ public abstract class DetachOptions
|
|||
* Whether to use a detached state manager on types that allow it.
|
||||
* Types that do not use detached state or that declare a custom detached
|
||||
* state field to maintain serialization compatibility will never use
|
||||
* a detached state manager. Defaults to true.
|
||||
* a detached state manager. Defaults to true.
|
||||
*/
|
||||
public void setDetachedStateManager(boolean val) {
|
||||
_manager = val;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether to allow access to unloaded detached fields. This setting only
|
||||
* Whether to allow access to unloaded detached fields. This setting only
|
||||
* applies to instances with detached state managers.
|
||||
*/
|
||||
public boolean getAccessUnloaded() {
|
||||
|
@ -115,7 +115,7 @@ public abstract class DetachOptions
|
|||
}
|
||||
|
||||
/**
|
||||
* Whether to allow access to unloaded detached fields. This setting only
|
||||
* Whether to allow access to unloaded detached fields. This setting only
|
||||
* applies to instances with detached state managers.
|
||||
*/
|
||||
public void setAccessUnloaded(boolean val) {
|
||||
|
@ -145,7 +145,7 @@ public abstract class DetachOptions
|
|||
}
|
||||
|
||||
/**
|
||||
* Public to allow reflection.
|
||||
* Public to allow reflection.
|
||||
*/
|
||||
public static class All
|
||||
extends DetachOptions {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -44,17 +44,16 @@ import org.apache.openjpa.util.ClassResolver;
|
|||
import org.apache.openjpa.util.ProxyManager;
|
||||
|
||||
/**
|
||||
* <p>Defines the properties necessary to configure runtime properties and
|
||||
* connect to a data source. There is a 1-1 relation between a configuration
|
||||
* and a {@link BrokerFactory}.</p>
|
||||
* <p/>
|
||||
* <p>All setter methods that take primitive parameters also have wrapper
|
||||
* setter with the appropriate primitive wrapper. This is so the interface
|
||||
* can be in accordance with the J2EE Connector Architecture.</p>
|
||||
* Defines the properties necessary to configure runtime properties and
|
||||
* connect to a data source. There is a 1-1 relation between a configuration
|
||||
* and a {@link BrokerFactory}.
|
||||
* All setter methods that take primitive parameters also have wrapper
|
||||
* setter with the appropriate primitive wrapper. This is so the interface
|
||||
* can be in accordance with the J2EE Connector Architecture.
|
||||
*
|
||||
* @author Marc Prud'hommeaux
|
||||
* @author Abe White
|
||||
* @see Configuration
|
||||
* @see Configuration
|
||||
*/
|
||||
public interface OpenJPAConfiguration
|
||||
extends Configuration {
|
||||
|
@ -203,7 +202,7 @@ public interface OpenJPAConfiguration
|
|||
"org.apache.openjpa.option.JDBCConnection";
|
||||
|
||||
/**
|
||||
* Return the set of option strings supported by this runtime. This set
|
||||
* Return the set of option strings supported by this runtime. This set
|
||||
* is mutable.
|
||||
*/
|
||||
public Collection supportedOptions();
|
||||
|
@ -219,7 +218,7 @@ public interface OpenJPAConfiguration
|
|||
* spec environments. This should be invoked before any configuration
|
||||
* options are set, as it will mutate various values.
|
||||
* You can only assign the specification once, though it is not fatal
|
||||
* to attempt to do so multiple times. Attempts to set to null will
|
||||
* to attempt to do so multiple times. Attempts to set to null will
|
||||
* be ignored.
|
||||
*/
|
||||
public boolean setSpecification(String spec);
|
||||
|
@ -293,7 +292,7 @@ public interface OpenJPAConfiguration
|
|||
|
||||
/**
|
||||
* The data cache manager manages this configuration's cache instances.
|
||||
* The cache manager is created if it has not been set. Once the cache
|
||||
* The cache manager is created if it has not been set. Once the cache
|
||||
* manager has been set/created, all changes to caching configuration
|
||||
* must proceed through the cache manager.
|
||||
*
|
||||
|
@ -593,7 +592,7 @@ public interface OpenJPAConfiguration
|
|||
public MetaDataFactory newMetaDataFactoryInstance();
|
||||
|
||||
/**
|
||||
* The metadata repository of managed class information. If no
|
||||
* The metadata repository of managed class information. If no
|
||||
* repository has been set, creates one.
|
||||
*
|
||||
* @since 3.0
|
||||
|
@ -690,24 +689,22 @@ public interface OpenJPAConfiguration
|
|||
public void setConnectionFactoryProperties(String props);
|
||||
|
||||
/**
|
||||
* The mode of the connection factory in use. Available options are:
|
||||
* The mode of the connection factory in use. Available options are:
|
||||
* <ul>
|
||||
* <li>local: OpenJPA controls the connections.</li>
|
||||
* <li>managed: Connections are automatically enlisted in
|
||||
* the current global transaction by an application server.</li>
|
||||
* </ul>
|
||||
* Defaults to local.
|
||||
* </ul> Defaults to local.
|
||||
*/
|
||||
public String getConnectionFactoryMode();
|
||||
|
||||
/**
|
||||
* The mode of the connection factory in use. Available options are:
|
||||
* The mode of the connection factory in use. Available options are:
|
||||
* <ul>
|
||||
* <li>local: OpenJPA controls the connections.</li>
|
||||
* <li>managed: Connections are automatically enlisted in
|
||||
* the current global transaction by an application server.</li>
|
||||
* </ul>
|
||||
* Defaults to local.
|
||||
* </ul> Defaults to local.
|
||||
*/
|
||||
public void setConnectionFactoryMode(String mode);
|
||||
|
||||
|
@ -900,7 +897,7 @@ public interface OpenJPAConfiguration
|
|||
|
||||
/**
|
||||
* A comma-separated list of events which trigger auto-detachment
|
||||
* in place of managed states. Possible values are:
|
||||
* in place of managed states. Possible values are:
|
||||
* <ul>
|
||||
* <li><code>commit</code>: When the current transaction commits.</li>
|
||||
* <li><code>close</code>: When the broker closes.</li>
|
||||
|
@ -912,7 +909,7 @@ public interface OpenJPAConfiguration
|
|||
|
||||
/**
|
||||
* A comma-separated list of events which trigger auto-detachment
|
||||
* in place of managed states. Possible values are:
|
||||
* in place of managed states. Possible values are:
|
||||
* <ul>
|
||||
* <li><code>commit</code>: When the current transaction commits.</li>
|
||||
* <li><code>close</code>: When the broker closes.</li>
|
||||
|
@ -998,13 +995,13 @@ public interface OpenJPAConfiguration
|
|||
|
||||
/**
|
||||
* Get the size of the batch that will be pre-selected when accessing
|
||||
* elements in a query or relationship. Use -1 to prefetch all results.
|
||||
* elements in a query or relationship. Use -1 to prefetch all results.
|
||||
*/
|
||||
public int getFetchBatchSize();
|
||||
|
||||
/**
|
||||
* Set the size of the batch that will be pre-selected when accessing
|
||||
* elements in a query or relationship. Use -1 to prefetch all results.
|
||||
* elements in a query or relationship. Use -1 to prefetch all results.
|
||||
*/
|
||||
public void setFetchBatchSize(int size);
|
||||
|
||||
|
@ -1181,7 +1178,7 @@ public interface OpenJPAConfiguration
|
|||
|
||||
/**
|
||||
* Specifies the behavior of the broker with respect to data store
|
||||
* connections. Possible values are:
|
||||
* connections. Possible values are:
|
||||
* <ul>
|
||||
* <li><code>always</code>: Each broker obtains a single connection and
|
||||
* uses it until the broker is closed.</li>
|
||||
|
@ -1189,8 +1186,8 @@ public interface OpenJPAConfiguration
|
|||
* transaction begins (optimistic or datastore), and is released
|
||||
* when the transaction completes.</li>
|
||||
* <li><code>on-demand</code>: Connections are obtained only when needed.
|
||||
* This is the default mode. It is equivalent to the previous option
|
||||
* when datastore transactions are used. For optimistic transactions,
|
||||
* This is the default mode. It is equivalent to the previous option
|
||||
* when datastore transactions are used. For optimistic transactions,
|
||||
* though, it means that a connection will be retained only for
|
||||
* the duration of the data store commit process.</li>
|
||||
* </ul>
|
||||
|
@ -1201,7 +1198,7 @@ public interface OpenJPAConfiguration
|
|||
|
||||
/**
|
||||
* Specifies the behavior of the broker with respect to data store
|
||||
* connections. Possible values are:
|
||||
* connections. Possible values are:
|
||||
* <ul>
|
||||
* <li><code>always</code>: Each broker obtains a single connection and
|
||||
* uses it until the broker is closed.</li>
|
||||
|
@ -1209,8 +1206,8 @@ public interface OpenJPAConfiguration
|
|||
* transaction begins (optimistic or datastore), and is released
|
||||
* when the transaction completes.</li>
|
||||
* <li><code>on-demand</code>: Connections are obtained only when needed.
|
||||
* This is the default mode. It is equivalent to the previous option
|
||||
* when datastore transactions are used. For optimistic transactions,
|
||||
* This is the default mode. It is equivalent to the previous option
|
||||
* when datastore transactions are used. For optimistic transactions,
|
||||
* though, it means that a connection will be retained only for
|
||||
* the duration of the data store commit process.</li>
|
||||
* </ul>
|
||||
|
@ -1254,13 +1251,13 @@ public interface OpenJPAConfiguration
|
|||
public void setFilterListeners(String listeners);
|
||||
|
||||
/**
|
||||
* Return the query filter listeners. If none have been set explicitly,
|
||||
* Return the query filter listeners. If none have been set explicitly,
|
||||
* this method instantiates the listeners from the set plugin list.
|
||||
*/
|
||||
public FilterListener[] getFilterListenerInstances();
|
||||
|
||||
/**
|
||||
* Set the query filter listeners. Overrides the list of listener classes.
|
||||
* Set the query filter listeners. Overrides the list of listener classes.
|
||||
*/
|
||||
public void setFilterListeners(FilterListener[] listeners);
|
||||
|
||||
|
@ -1277,14 +1274,13 @@ public interface OpenJPAConfiguration
|
|||
public void setAggregateListeners(String listeners);
|
||||
|
||||
/**
|
||||
* Return the query function listeners. If none have been set explicitly,
|
||||
* Return the query function listeners. If none have been set explicitly,
|
||||
* this method instantiates the listeners from the set plugin list.
|
||||
*/
|
||||
public AggregateListener[] getAggregateListenerInstances();
|
||||
|
||||
/**
|
||||
* Set the query function listeners. Overrides the list of listener
|
||||
* classes.
|
||||
* Set the query function listeners. Overrides the list of listener classes.
|
||||
*/
|
||||
public void setAggregateListeners(AggregateListener[] listeners);
|
||||
|
||||
|
@ -1299,38 +1295,34 @@ public interface OpenJPAConfiguration
|
|||
public boolean getRetryClassRegistration();
|
||||
|
||||
/**
|
||||
* Whether to warn and defer registration instead of throwing an
|
||||
* exception when a registered persistent class cannot be processed.
|
||||
* Should only be set to true in complex classloader topologies.
|
||||
* Defaults to <code>false</code>.
|
||||
* Whether to warn and defer registration instead of throwing an
|
||||
* exception when a registered persistent class cannot be processed.
|
||||
* Should only be set to true in complex classloader topologies.
|
||||
* Defaults to <code>false</code>.
|
||||
*
|
||||
* @since 3.2.3
|
||||
* @since 3.2.3
|
||||
*/
|
||||
public void setRetryClassRegistration (boolean warn);
|
||||
|
||||
|
||||
/**
|
||||
* Wrapper for JCA usage of {@link #setRetryClassRegistration(boolean)}.
|
||||
* Wrapper for JCA usage of {@link #setRetryClassRegistration(boolean)}.
|
||||
*
|
||||
* @since 3.2.3
|
||||
* @since 3.2.3
|
||||
*/
|
||||
public void setRetryClassRegistration (Boolean warn);
|
||||
|
||||
|
||||
/**
|
||||
* Backwards compatibility options.
|
||||
* Backwards compatibility options.
|
||||
*/
|
||||
public String getCompatibility ();
|
||||
|
||||
|
||||
/**
|
||||
* Backwards compatibility options.
|
||||
* Backwards compatibility options.
|
||||
*/
|
||||
public void setCompatibility (String compatibility);
|
||||
|
||||
|
||||
/**
|
||||
* Backwards compatibility options.
|
||||
* Backwards compatibility options.
|
||||
*/
|
||||
public Compatibility getCompatibilityInstance ();
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -56,14 +56,13 @@ import org.apache.openjpa.util.ImplHelper;
|
|||
import org.apache.openjpa.util.ProxyManager;
|
||||
|
||||
/**
|
||||
* <p>Implementation of the {@link OpenJPAConfiguration} interface.</p>
|
||||
* <p/>
|
||||
* <p>On construction, the class will attempt to locate a default properties
|
||||
* Implementation of the {@link OpenJPAConfiguration} interface.
|
||||
* On construction, the class will attempt to locate a default properties
|
||||
* file called <code>org.apache.openjpa.properties</code> located at any top level token
|
||||
* of the CLASSPATH. See the {@link ConfigurationImpl} class description
|
||||
* for details.</p>
|
||||
* of the CLASSPATH. See the {@link ConfigurationImpl} class description
|
||||
* for details.
|
||||
*
|
||||
* @see ConfigurationImpl
|
||||
* @see ConfigurationImpl
|
||||
* @author Marc Prud'hommeaux
|
||||
* @author Abe White
|
||||
*/
|
||||
|
@ -144,7 +143,7 @@ public class OpenJPAConfigurationImpl
|
|||
private String spec = null;
|
||||
|
||||
/**
|
||||
* Default constructor. Attempts to load default properties.
|
||||
* Default constructor. Attempts to load default properties.
|
||||
*/
|
||||
public OpenJPAConfigurationImpl() {
|
||||
this(true);
|
||||
|
@ -153,7 +152,7 @@ public class OpenJPAConfigurationImpl
|
|||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param loadDefaults whether to attempt to load the default
|
||||
* @param loadDefaults whether to attempt to load the default
|
||||
* <code>org.apache.openjpa.properties</code> resource
|
||||
*/
|
||||
public OpenJPAConfigurationImpl(boolean loadDefaults) {
|
||||
|
@ -163,8 +162,8 @@ public class OpenJPAConfigurationImpl
|
|||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param derivations whether to apply product derivations
|
||||
* @param loadDefaults whether to attempt to load the default
|
||||
* @param derivations whether to apply product derivations
|
||||
* @param loadDefaults whether to attempt to load the default
|
||||
* <code>org.apache.openjpa.properties</code> resource
|
||||
*/
|
||||
public OpenJPAConfigurationImpl(boolean derivations, boolean loadDefaults) {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
|
|
@ -1,68 +1,68 @@
|
|||
/*
|
||||
* Copyright 2006 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed 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.conf;
|
||||
|
||||
import org.apache.openjpa.lib.conf.Configuration;
|
||||
import org.apache.openjpa.lib.conf.ConfigurationProvider;
|
||||
|
||||
/**
|
||||
* Hooks for deriving products with additional functionality.
|
||||
* All implementations of this interface will have a chance to mutate
|
||||
* a {@link Configuration} both before and after the user-specified
|
||||
* configuration data is loaded. The order in which the
|
||||
* derivations are evaluated is determined by the specificity of the
|
||||
* derivation type.
|
||||
*
|
||||
* @since 4.1
|
||||
*/
|
||||
public interface ProductDerivation {
|
||||
|
||||
public static final int TYPE_SPEC = 0;
|
||||
public static final int TYPE_PRODUCT = 1;
|
||||
public static final int TYPE_STORE = 2;
|
||||
public static final int TYPE_SPEC_STORE = 3;
|
||||
public static final int TYPE_PRODUCT_STORE = 4;
|
||||
public static final int TYPE_FEATURE = 5;
|
||||
|
||||
/**
|
||||
* Return the type of derivation.
|
||||
*/
|
||||
public int getType();
|
||||
|
||||
/**
|
||||
* Provides the instance with a callback to mutate the initial properties
|
||||
* of the {@link ConfigurationProvider}. This is primarily to alter or
|
||||
* add properties that determine what type of configuration is constructed,
|
||||
* and therefore is typically used at runtime only.
|
||||
*/
|
||||
public void beforeConfigurationConstruct(ConfigurationProvider cp);
|
||||
|
||||
/**
|
||||
* Provides the instance with the opportunity to mutate
|
||||
* <code>conf</code> before the user configuration is applied.
|
||||
*/
|
||||
public void beforeConfigurationLoad(OpenJPAConfiguration conf);
|
||||
|
||||
/**
|
||||
* Called after the specification has been set.
|
||||
*/
|
||||
public void afterSpecificationSet(OpenJPAConfiguration conf);
|
||||
|
||||
/**
|
||||
* Called after the configuration has been closed.
|
||||
*/
|
||||
public void afterClose(OpenJPAConfiguration conf);
|
||||
}
|
||||
/*
|
||||
* Copyright 2006 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed 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.conf;
|
||||
|
||||
import org.apache.openjpa.lib.conf.Configuration;
|
||||
import org.apache.openjpa.lib.conf.ConfigurationProvider;
|
||||
|
||||
/**
|
||||
* Hooks for deriving products with additional functionality.
|
||||
* All implementations of this interface will have a chance to mutate
|
||||
* a {@link Configuration} both before and after the user-specified
|
||||
* configuration data is loaded. The order in which the
|
||||
* derivations are evaluated is determined by the specificity of the
|
||||
* derivation type.
|
||||
*
|
||||
* @since 4.1
|
||||
*/
|
||||
public interface ProductDerivation {
|
||||
|
||||
public static final int TYPE_SPEC = 0;
|
||||
public static final int TYPE_PRODUCT = 1;
|
||||
public static final int TYPE_STORE = 2;
|
||||
public static final int TYPE_SPEC_STORE = 3;
|
||||
public static final int TYPE_PRODUCT_STORE = 4;
|
||||
public static final int TYPE_FEATURE = 5;
|
||||
|
||||
/**
|
||||
* Return the type of derivation.
|
||||
*/
|
||||
public int getType();
|
||||
|
||||
/**
|
||||
* Provides the instance with a callback to mutate the initial properties
|
||||
* of the {@link ConfigurationProvider}. This is primarily to alter or
|
||||
* add properties that determine what type of configuration is constructed,
|
||||
* and therefore is typically used at runtime only.
|
||||
*/
|
||||
public void beforeConfigurationConstruct(ConfigurationProvider cp);
|
||||
|
||||
/**
|
||||
* Provides the instance with the opportunity to mutate
|
||||
* <code>conf</code> before the user configuration is applied.
|
||||
*/
|
||||
public void beforeConfigurationLoad(OpenJPAConfiguration conf);
|
||||
|
||||
/**
|
||||
* Called after the specification has been set.
|
||||
*/
|
||||
public void afterSpecificationSet(OpenJPAConfiguration conf);
|
||||
|
||||
/**
|
||||
* Called after the configuration has been closed.
|
||||
*/
|
||||
public void afterClose(OpenJPAConfiguration conf);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -24,7 +24,7 @@ import org.apache.openjpa.lib.conf.ConfigurationProvider;
|
|||
import org.apache.openjpa.lib.util.Services;
|
||||
|
||||
/**
|
||||
* <p>Utilities for running product derivations.</p>
|
||||
* Utilities for running product derivations.
|
||||
*
|
||||
* @author Abe White
|
||||
* @nojavadoc
|
||||
|
@ -51,7 +51,7 @@ public class ProductDerivations {
|
|||
|
||||
/**
|
||||
* Apply {@link ProductDerivation#beforeConfigurationConstruct} callbacks
|
||||
* to the the given instance. Exceptions are swallowed.
|
||||
* to the the given instance. Exceptions are swallowed.
|
||||
*/
|
||||
public static void beforeConfigurationConstruct(ConfigurationProvider cp) {
|
||||
for (int i = 0; i < _derivations.length; i++) {
|
||||
|
@ -67,7 +67,7 @@ public class ProductDerivations {
|
|||
|
||||
/**
|
||||
* Apply {@link ProductDerivation#beforeConfigurationLoad} callbacks
|
||||
* to the the given instance. Exceptions are swallowed.
|
||||
* to the the given instance. Exceptions are swallowed.
|
||||
*/
|
||||
public static void beforeConfigurationLoad(OpenJPAConfiguration conf) {
|
||||
for (int i = 0; i < _derivations.length; i++) {
|
||||
|
@ -83,7 +83,7 @@ public class ProductDerivations {
|
|||
|
||||
/**
|
||||
* Apply {@link ProductDerivation#afterSpecificationSet} callbacks
|
||||
* to the the given instance. Exceptions are swallowed.
|
||||
* to the the given instance. Exceptions are swallowed.
|
||||
*/
|
||||
public static void afterSpecificationSet(OpenJPAConfiguration conf) {
|
||||
for (int i = 0; i < _derivations.length; i++) {
|
||||
|
@ -99,7 +99,7 @@ public class ProductDerivations {
|
|||
|
||||
/**
|
||||
* Apply {@link ProductDerivation#afterClose} callbacks
|
||||
* to the the given instance. Exceptions are swallowed.
|
||||
* to the the given instance. Exceptions are swallowed.
|
||||
*/
|
||||
public static void afterClose(OpenJPAConfigurationImpl impl) {
|
||||
for (int i = 0; i < _derivations.length; i++) {
|
||||
|
@ -114,7 +114,7 @@ public class ProductDerivations {
|
|||
}
|
||||
|
||||
/**
|
||||
* Compare {@link ProductDerivation}s.
|
||||
* Compare {@link ProductDerivation}s.
|
||||
*/
|
||||
private static class ProductDerivationComparator
|
||||
implements Comparator {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -23,9 +23,9 @@ import org.apache.openjpa.lib.conf.PluginValue;
|
|||
import org.apache.openjpa.lib.util.Options;
|
||||
|
||||
/**
|
||||
* <p>Value type used to represent a {@link RemoteCommitProvider}. This
|
||||
* Value type used to represent a {@link RemoteCommitProvider}. This
|
||||
* plugin allows users to specify whether to transmit the ids of added objects
|
||||
* in the remote commit events distributed.</p>
|
||||
* in the remote commit events distributed.
|
||||
*
|
||||
* @author Abe White
|
||||
* @nojavadoc
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -20,9 +20,9 @@ import org.apache.openjpa.lib.conf.PluginValue;
|
|||
import org.apache.openjpa.meta.SequenceMetaData;
|
||||
|
||||
/**
|
||||
* <p>Value type used to represent a sequence. This type is
|
||||
* Value type used to represent a sequence. This type is
|
||||
* defined separately so that it can be used both in the global configuration
|
||||
* and in class metadata with the same encapsulated configuration.</p>
|
||||
* and in class metadata with the same encapsulated configuration.
|
||||
*
|
||||
* @author Abe White
|
||||
* @nojavadoc
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -282,9 +282,9 @@ public abstract class AbstractDataCache
|
|||
}
|
||||
|
||||
/**
|
||||
* This method is part of the {@link RemoteCommitListener} interface. If
|
||||
* This method is part of the {@link RemoteCommitListener} interface. If
|
||||
* your cache subclass relies on OpenJPA for clustering support, make it
|
||||
* implement <code>RemoteCommitListener</code>. This method will take
|
||||
* implement <code>RemoteCommitListener</code>. This method will take
|
||||
* care of invalidating entries from remote commits.
|
||||
*/
|
||||
public void afterCommit(RemoteCommitEvent event) {
|
||||
|
@ -320,7 +320,7 @@ public abstract class AbstractDataCache
|
|||
/**
|
||||
* Return <code>true</code> if updates to data already in the
|
||||
* cache (either in {@link #commit} or the {@link #update})
|
||||
* should be put back into the cache. Returns false by default.
|
||||
* should be put back into the cache. Returns false by default.
|
||||
*/
|
||||
protected boolean recacheUpdates() {
|
||||
return false;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -182,9 +182,9 @@ public abstract class AbstractQueryCache
|
|||
}
|
||||
|
||||
/**
|
||||
* This method is part of the {@link RemoteCommitListener} interface. If
|
||||
* This method is part of the {@link RemoteCommitListener} interface. If
|
||||
* your cache subclass relies on OpenJPA for clustering support, make it
|
||||
* implement <code>RemoteCommitListener</code>. This method will take
|
||||
* implement <code>RemoteCommitListener</code>. This method will take
|
||||
* care of invalidating entries from remote commits, by delegating to
|
||||
* {@link #onTypesChanged}.
|
||||
*/
|
||||
|
@ -237,7 +237,7 @@ public abstract class AbstractQueryCache
|
|||
}
|
||||
|
||||
/**
|
||||
* Return a threadsafe view of the keys in this cache. This collection
|
||||
* Return a threadsafe view of the keys in this cache. This collection
|
||||
* must be iterable without risk of concurrent modification exceptions.
|
||||
* It does not have to implement contains() efficiently or use set
|
||||
* semantics.
|
||||
|
@ -311,9 +311,9 @@ public abstract class AbstractQueryCache
|
|||
}
|
||||
|
||||
/**
|
||||
* Individual query results will be registered as types changed
|
||||
* listeners. We want such query results to be gc'd once
|
||||
* the only reference is held by the list of expiration listeners.
|
||||
* Individual query results will be registered as types changed
|
||||
* listeners. We want such query results to be gc'd once
|
||||
* the only reference is held by the list of expiration listeners.
|
||||
*/
|
||||
protected Collection newListenerCollection() {
|
||||
//### use concurrent
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -27,8 +27,7 @@ class Caches {
|
|||
/**
|
||||
* Utility to build up a set of classes from their class names
|
||||
* when operating outside the context of a persistence manager.
|
||||
* The set classes can be null, in which case a new Set will be
|
||||
* created.
|
||||
* The set classes can be null, in which case a new Set will be created.
|
||||
*/
|
||||
static Set addTypesByName(OpenJPAConfiguration conf,
|
||||
Collection classNames, Set classes) {
|
||||
|
|
|
@ -1,140 +1,140 @@
|
|||
/*
|
||||
* Copyright 2006 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed 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.datacache;
|
||||
|
||||
import org.apache.openjpa.event.RemoteCommitListener;
|
||||
import org.apache.openjpa.util.CacheMap;
|
||||
|
||||
/**
|
||||
* A {@link DataCache} implementation that is optimized for concurrent
|
||||
* access. When the cache fills up, values to remove from cache are chosen
|
||||
* randomly. Due to race conditions, it is possible that a get call might not
|
||||
* return a cached instance if that instance is being transferred between
|
||||
* internal datastructures.
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public class ConcurrentDataCache
|
||||
extends AbstractDataCache
|
||||
implements RemoteCommitListener {
|
||||
|
||||
private final CacheMap _cache = newCacheMap();
|
||||
|
||||
/**
|
||||
* Returns the underlying {@link CacheMap} that this cache is using.
|
||||
* This is not an unmodifiable view on the map, so care should be taken
|
||||
* with this reference. Implementations should probably not modify the
|
||||
* contents of the cache, but should only use this reference to
|
||||
* obtain cache metrics.
|
||||
*/
|
||||
public CacheMap getCacheMap() {
|
||||
return _cache;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the maximum number of unpinned objects to keep hard
|
||||
* references to. If the map contains more unpinned objects than
|
||||
* <code>size</code>, then this method will result in the cache
|
||||
* flushing old values.
|
||||
*/
|
||||
public void setCacheSize(int size) {
|
||||
_cache.setCacheSize(size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum number of unpinned objects to keep hard
|
||||
* references to.
|
||||
*/
|
||||
public int getCacheSize() {
|
||||
return _cache.getCacheSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the maximum number of unpinned objects to keep soft
|
||||
* references to. If the map contains more soft references than
|
||||
* <code>size</code>, then this method will result in the cache
|
||||
* flushing values.
|
||||
*/
|
||||
public void setSoftReferenceSize(int size) {
|
||||
_cache.setSoftReferenceSize(size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum number of unpinned objects to keep soft
|
||||
* references to. Defaults to <code>-1</code>.
|
||||
*/
|
||||
public int getSoftReferenceSize() {
|
||||
return _cache.getSoftReferenceSize();
|
||||
}
|
||||
|
||||
public void initialize(DataCacheManager mgr) {
|
||||
super.initialize(mgr);
|
||||
conf.getRemoteCommitEventManager().addListener(this);
|
||||
}
|
||||
|
||||
public void writeLock() {
|
||||
_cache.writeLock();
|
||||
}
|
||||
|
||||
public void writeUnlock() {
|
||||
_cache.writeUnlock();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the map to use as an internal cache; entry expirations must
|
||||
* invoke {@link AbstractDataCache#keyRemoved}.
|
||||
*/
|
||||
protected CacheMap newCacheMap() {
|
||||
return new CacheMap() {
|
||||
protected void entryRemoved(Object key, Object value,
|
||||
boolean expired) {
|
||||
keyRemoved(key, expired);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected DataCachePCData getInternal(Object key) {
|
||||
return (DataCachePCData) _cache.get(key);
|
||||
}
|
||||
|
||||
protected DataCachePCData putInternal(Object key, DataCachePCData pc) {
|
||||
return (DataCachePCData) _cache.put(key, pc);
|
||||
}
|
||||
|
||||
protected DataCachePCData removeInternal(Object key) {
|
||||
return (DataCachePCData) _cache.remove(key);
|
||||
}
|
||||
|
||||
protected void removeAllInternal(Class cls, boolean subs) {
|
||||
// we could keep a histogram of the counts of contained classes and
|
||||
// only clear if we have the class, but that still wouldn't support subs
|
||||
// well, would involve synching, and won't yield much benefit when we're
|
||||
// used as a primary cache
|
||||
_cache.clear();
|
||||
}
|
||||
|
||||
protected void clearInternal() {
|
||||
_cache.clear();
|
||||
}
|
||||
|
||||
protected boolean pinInternal(Object key) {
|
||||
return _cache.pin(key);
|
||||
}
|
||||
|
||||
protected boolean unpinInternal(Object key) {
|
||||
return _cache.unpin (key);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright 2006 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed 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.datacache;
|
||||
|
||||
import org.apache.openjpa.event.RemoteCommitListener;
|
||||
import org.apache.openjpa.util.CacheMap;
|
||||
|
||||
/**
|
||||
* A {@link DataCache} implementation that is optimized for concurrent
|
||||
* access. When the cache fills up, values to remove from cache are chosen
|
||||
* randomly. Due to race conditions, it is possible that a get call might not
|
||||
* return a cached instance if that instance is being transferred between
|
||||
* internal datastructures.
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public class ConcurrentDataCache
|
||||
extends AbstractDataCache
|
||||
implements RemoteCommitListener {
|
||||
|
||||
private final CacheMap _cache = newCacheMap();
|
||||
|
||||
/**
|
||||
* Returns the underlying {@link CacheMap} that this cache is using.
|
||||
* This is not an unmodifiable view on the map, so care should be taken
|
||||
* with this reference. Implementations should probably not modify the
|
||||
* contents of the cache, but should only use this reference to
|
||||
* obtain cache metrics.
|
||||
*/
|
||||
public CacheMap getCacheMap() {
|
||||
return _cache;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the maximum number of unpinned objects to keep hard
|
||||
* references to. If the map contains more unpinned objects than
|
||||
* <code>size</code>, then this method will result in the cache
|
||||
* flushing old values.
|
||||
*/
|
||||
public void setCacheSize(int size) {
|
||||
_cache.setCacheSize(size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum number of unpinned objects to keep hard
|
||||
* references to.
|
||||
*/
|
||||
public int getCacheSize() {
|
||||
return _cache.getCacheSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the maximum number of unpinned objects to keep soft
|
||||
* references to. If the map contains more soft references than
|
||||
* <code>size</code>, then this method will result in the cache
|
||||
* flushing values.
|
||||
*/
|
||||
public void setSoftReferenceSize(int size) {
|
||||
_cache.setSoftReferenceSize(size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum number of unpinned objects to keep soft
|
||||
* references to. Defaults to <code>-1</code>.
|
||||
*/
|
||||
public int getSoftReferenceSize() {
|
||||
return _cache.getSoftReferenceSize();
|
||||
}
|
||||
|
||||
public void initialize(DataCacheManager mgr) {
|
||||
super.initialize(mgr);
|
||||
conf.getRemoteCommitEventManager().addListener(this);
|
||||
}
|
||||
|
||||
public void writeLock() {
|
||||
_cache.writeLock();
|
||||
}
|
||||
|
||||
public void writeUnlock() {
|
||||
_cache.writeUnlock();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the map to use as an internal cache; entry expirations must
|
||||
* invoke {@link AbstractDataCache#keyRemoved}.
|
||||
*/
|
||||
protected CacheMap newCacheMap() {
|
||||
return new CacheMap() {
|
||||
protected void entryRemoved(Object key, Object value,
|
||||
boolean expired) {
|
||||
keyRemoved(key, expired);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected DataCachePCData getInternal(Object key) {
|
||||
return (DataCachePCData) _cache.get(key);
|
||||
}
|
||||
|
||||
protected DataCachePCData putInternal(Object key, DataCachePCData pc) {
|
||||
return (DataCachePCData) _cache.put(key, pc);
|
||||
}
|
||||
|
||||
protected DataCachePCData removeInternal(Object key) {
|
||||
return (DataCachePCData) _cache.remove(key);
|
||||
}
|
||||
|
||||
protected void removeAllInternal(Class cls, boolean subs) {
|
||||
// we could keep a histogram of the counts of contained classes and
|
||||
// only clear if we have the class, but that still wouldn't support subs
|
||||
// well, would involve synching, and won't yield much benefit when we're
|
||||
// used as a primary cache
|
||||
_cache.clear();
|
||||
}
|
||||
|
||||
protected void clearInternal() {
|
||||
_cache.clear();
|
||||
}
|
||||
|
||||
protected boolean pinInternal(Object key) {
|
||||
return _cache.pin(key);
|
||||
}
|
||||
|
||||
protected boolean unpinInternal(Object key) {
|
||||
return _cache.unpin (key);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -22,8 +22,8 @@ import org.apache.openjpa.util.CacheMap;
|
|||
|
||||
/**
|
||||
* A {@link QueryCache} implementation that is optimized for concurrent
|
||||
* access. When the cache fill up, values to remove from the cache are chosen
|
||||
* randomly. Due to race conditions, it is possible that a get call might not
|
||||
* access. When the cache fill up, values to remove from the cache are chosen
|
||||
* randomly. Due to race conditions, it is possible that a get call might not
|
||||
* retur a cached instance if that instance is being transferred between
|
||||
* internal datastructures.
|
||||
*
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -22,15 +22,14 @@ import java.util.Map;
|
|||
import org.apache.openjpa.lib.util.Closeable;
|
||||
|
||||
/**
|
||||
* <p>Interface that must be implemented by any level 2 cache used by
|
||||
* Interface that must be implemented by any level 2 cache used by
|
||||
* OpenJPA. Most data caches will choose to implement the
|
||||
* {@link org.apache.openjpa.lib.conf.Configurable} interface as well so that
|
||||
* they will be given the system configuration just after construction.</p>
|
||||
* <p/>
|
||||
* <p>Implementations should take care not to return timed out data.</p>
|
||||
* they will be given the system configuration just after construction.
|
||||
* Implementations should take care not to return timed out data.
|
||||
*
|
||||
* @see AbstractDataCache
|
||||
* @see DataCachePCData#isTimedOut
|
||||
* @see AbstractDataCache
|
||||
* @see DataCachePCData#isTimedOut
|
||||
* @author Patrick Linskey
|
||||
* @author Abe White
|
||||
*/
|
||||
|
@ -51,8 +50,7 @@ public interface DataCache
|
|||
public String getName();
|
||||
|
||||
/**
|
||||
* Sets a string name to be used to identify this cache to
|
||||
* end-user needs.
|
||||
* Sets a string name to be used to identify this cache to end-user needs.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*/
|
||||
|
@ -65,39 +63,34 @@ public interface DataCache
|
|||
public void initialize(DataCacheManager manager);
|
||||
|
||||
/**
|
||||
* <p>Perform a batch update of the cache. Add all {@link DataCachePCData}
|
||||
* Perform a batch update of the cache. Add all {@link DataCachePCData}
|
||||
* objects in <code>additions</code> and in
|
||||
* <code>newUpdates</code>, make the appropriate modifications to
|
||||
* all DataCachePCDatas in <code>existingUpdates</code>, and delete all
|
||||
* OIDs in <code>deletes</code>.</p>
|
||||
* <p/>
|
||||
* <p>All changes made to cached data must be made via this
|
||||
* OIDs in <code>deletes</code>.
|
||||
* All changes made to cached data must be made via this
|
||||
* method. It is this method that is responsible for performing
|
||||
* any side-effects that should happen on meaningful cache
|
||||
* changes.</p>
|
||||
* <p/>
|
||||
* <p>Implementations should bear in mind that the
|
||||
* any side-effects that should happen on meaningful cache changes.
|
||||
* Implementations should bear in mind that the
|
||||
* <code>deletes</code> collection may contain oids that are also
|
||||
* in the <code>additions</code> map. This is possible because it
|
||||
* is valid for a user to delete an object with a particular oid
|
||||
* and then add that object in the same batch.</p>
|
||||
* and then add that object in the same batch.
|
||||
*
|
||||
* @param additions A collection of {@link DataCachePCData} objects.
|
||||
* @param additions A collection of {@link DataCachePCData} objects.
|
||||
* These represent data that have been newly created,
|
||||
* and thus must be added to the cache.
|
||||
* @param newUpdates A collection of {@link DataCachePCData} objects.
|
||||
* @param newUpdates A collection of {@link DataCachePCData} objects.
|
||||
* These represent data that have been modified but
|
||||
* were not originally in the cache, and thus
|
||||
* must be added to the cache.
|
||||
* @param existingUpdates A collection of {@link DataCachePCData} objects.
|
||||
* were not originally in the cache, and thus must be added to the cache.
|
||||
* @param existingUpdates A collection of {@link DataCachePCData} objects.
|
||||
* These represent data that have been modified and
|
||||
* were originally loaded from the cache. It is
|
||||
* up to the cache implementation to decide if
|
||||
* these values must be re-enlisted in the cache.
|
||||
* Some caches may return live data from {@link #get}
|
||||
* invocations, in which case these values need
|
||||
* not be re-enlisted.
|
||||
* @param deletes A collection of object IDs that have been deleted
|
||||
* invocations, in which case these values need not be re-enlisted.
|
||||
* @param deletes A collection of object IDs that have been deleted
|
||||
* and must therefore be dropped from the cache.
|
||||
*/
|
||||
public void commit(Collection additions, Collection newUpdates,
|
||||
|
@ -116,7 +109,7 @@ public interface DataCache
|
|||
public BitSet containsAll(Collection oids);
|
||||
|
||||
/**
|
||||
* Return the cached object for the given oid. Modifying the returned
|
||||
* Return the cached object for the given oid. Modifying the returned
|
||||
* object may or may not change the cached value; the {@link #update}
|
||||
* method should be used to re-cache any changed objects.
|
||||
*
|
||||
|
@ -137,18 +130,15 @@ public interface DataCache
|
|||
public DataCachePCData put(DataCachePCData value);
|
||||
|
||||
/**
|
||||
* <p>Update the cached value for the given instance. This does
|
||||
* Update the cached value for the given instance. This does
|
||||
* <em>not</em> result in an update of other caches. Rather, it should
|
||||
* only be used for loading clean data into the cache. Meaningful changes
|
||||
* to the state of the cache should be made via the {@link #commit}
|
||||
* method.</p>
|
||||
* <p/>
|
||||
* <p>A cache implementation may or may not return a live object
|
||||
* to the state of the cache should be made via the {@link #commit} method.
|
||||
* A cache implementation may or may not return a live object
|
||||
* from {@link #get} invocations. If an object retrieved from a
|
||||
* {@link #get} operation needs to be updated, this method can be
|
||||
* invoked instead of invoking {@link #put}. The DataCache implementation
|
||||
* can then make optimizations based on how its {@link #get} method
|
||||
* works.</p>
|
||||
* can then make optimizations based on how its {@link #get} method works.
|
||||
*/
|
||||
public void update(DataCachePCData value);
|
||||
|
||||
|
@ -169,7 +159,7 @@ public interface DataCache
|
|||
* Remove the values stored under the given oids.
|
||||
*
|
||||
* @return the indexes of the removed oids
|
||||
* @see #remove
|
||||
* @see #remove
|
||||
*/
|
||||
public BitSet removeAll(Collection oids);
|
||||
|
||||
|
@ -193,8 +183,7 @@ public interface DataCache
|
|||
* affect the behavior of {@link #remove}.
|
||||
*
|
||||
* @return <code>true</code> if <code>oid</code>'s value was
|
||||
* pinned into the cache; <code>false</code> if the
|
||||
* oid is not in the cache.
|
||||
* pinned into the cache; <code>false</code> if the oid is not in the cache.
|
||||
*/
|
||||
public boolean pin(Object oid);
|
||||
|
||||
|
@ -202,7 +191,7 @@ public interface DataCache
|
|||
* Pin all oids to the cache.
|
||||
*
|
||||
* @return the indexes of the pinned oids
|
||||
* @see #pin
|
||||
* @see #pin
|
||||
*/
|
||||
public BitSet pinAll(Collection oids);
|
||||
|
||||
|
@ -210,12 +199,11 @@ public interface DataCache
|
|||
* Unpin the value stored under <code>oid</code> from the cache.
|
||||
* This method reverses a previous invocation of {@link #pin}.
|
||||
* This method does not remove anything from the cache; it merely
|
||||
* makes <code>oid</code>'s value a candidate for flushing from
|
||||
* the cache.
|
||||
* makes <code>oid</code>'s value a candidate for flushing from the cache.
|
||||
*
|
||||
* @return <code>true</code> if <code>oid</code>'s value was
|
||||
* unpinned from the cache; <code>false</code> if the
|
||||
* oid is not in the cache.
|
||||
* unpinned from the cache; <code>false</code> if the
|
||||
* oid is not in the cache.
|
||||
*/
|
||||
public boolean unpin(Object oid);
|
||||
|
||||
|
@ -223,7 +211,7 @@ public interface DataCache
|
|||
* Unpin all oids from the cache.
|
||||
*
|
||||
* @return the indexes of the unpinned oids
|
||||
* @see #unpin
|
||||
* @see #unpin
|
||||
*/
|
||||
public BitSet unpinAll(Collection oids);
|
||||
|
||||
|
@ -252,7 +240,7 @@ public interface DataCache
|
|||
public boolean removeExpirationListener(ExpirationListener listen);
|
||||
|
||||
/**
|
||||
* Free the resources used by this cache.
|
||||
* Free the resources used by this cache.
|
||||
*/
|
||||
public void close ();
|
||||
}
|
||||
|
|
|
@ -1,74 +1,74 @@
|
|||
/*
|
||||
* Copyright 2006 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed 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.datacache;
|
||||
|
||||
import org.apache.openjpa.conf.OpenJPAConfiguration;
|
||||
import org.apache.openjpa.lib.conf.ObjectValue;
|
||||
|
||||
/**
|
||||
* <p>Manages the system's data and query caches. You can
|
||||
* retrieve the data cache manager from the {@link OpenJPAConfiguration}.</p>
|
||||
*
|
||||
* @author Abe White
|
||||
* @author Patrick Linskey
|
||||
*/
|
||||
public interface DataCacheManager {
|
||||
|
||||
/**
|
||||
* Initialize the manager, supplying the cache configuration.
|
||||
*/
|
||||
public void initialize(OpenJPAConfiguration conf, ObjectValue dataCache,
|
||||
ObjectValue queryCache);
|
||||
|
||||
/**
|
||||
* Return the system-wide data cache, or null if caching is not enabled.
|
||||
*/
|
||||
public DataCache getSystemDataCache();
|
||||
|
||||
/**
|
||||
* Return the named data cache, or null if it does not exist.
|
||||
*/
|
||||
public DataCache getDataCache(String name);
|
||||
|
||||
/**
|
||||
* Return the named data cache. If the given name is null, the default
|
||||
* data cache is returned.
|
||||
*
|
||||
* @param create if true, the cache will be created if it does
|
||||
* not already exist
|
||||
*/
|
||||
public DataCache getDataCache(String name, boolean create);
|
||||
|
||||
/**
|
||||
* Return the system query cache, or null if not configured.
|
||||
*/
|
||||
public QueryCache getSystemQueryCache();
|
||||
|
||||
/**
|
||||
* Return the PCData generator if configured.
|
||||
*/
|
||||
public DataCachePCDataGenerator getPCDataGenerator();
|
||||
|
||||
/**
|
||||
* Return the runnable which schedules evictions.
|
||||
*/
|
||||
public DataCacheScheduler getDataCacheScheduler();
|
||||
|
||||
/**
|
||||
* Close all caches.
|
||||
*/
|
||||
public void close ();
|
||||
}
|
||||
/*
|
||||
* Copyright 2006 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed 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.datacache;
|
||||
|
||||
import org.apache.openjpa.conf.OpenJPAConfiguration;
|
||||
import org.apache.openjpa.lib.conf.ObjectValue;
|
||||
|
||||
/**
|
||||
* Manages the system's data and query caches. You can
|
||||
* retrieve the data cache manager from the {@link OpenJPAConfiguration}.
|
||||
*
|
||||
* @author Abe White
|
||||
* @author Patrick Linskey
|
||||
*/
|
||||
public interface DataCacheManager {
|
||||
|
||||
/**
|
||||
* Initialize the manager, supplying the cache configuration.
|
||||
*/
|
||||
public void initialize(OpenJPAConfiguration conf, ObjectValue dataCache,
|
||||
ObjectValue queryCache);
|
||||
|
||||
/**
|
||||
* Return the system-wide data cache, or null if caching is not enabled.
|
||||
*/
|
||||
public DataCache getSystemDataCache();
|
||||
|
||||
/**
|
||||
* Return the named data cache, or null if it does not exist.
|
||||
*/
|
||||
public DataCache getDataCache(String name);
|
||||
|
||||
/**
|
||||
* Return the named data cache. If the given name is null, the default
|
||||
* data cache is returned.
|
||||
*
|
||||
* @param create if true, the cache will be created if it does
|
||||
* not already exist
|
||||
*/
|
||||
public DataCache getDataCache(String name, boolean create);
|
||||
|
||||
/**
|
||||
* Return the system query cache, or null if not configured.
|
||||
*/
|
||||
public QueryCache getSystemQueryCache();
|
||||
|
||||
/**
|
||||
* Return the PCData generator if configured.
|
||||
*/
|
||||
public DataCachePCDataGenerator getPCDataGenerator();
|
||||
|
||||
/**
|
||||
* Return the runnable which schedules evictions.
|
||||
*/
|
||||
public DataCacheScheduler getDataCacheScheduler();
|
||||
|
||||
/**
|
||||
* Close all caches.
|
||||
*/
|
||||
public void close ();
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -21,7 +21,7 @@ import org.apache.openjpa.lib.util.Closeable;
|
|||
import org.apache.openjpa.util.ImplHelper;
|
||||
|
||||
/**
|
||||
* <p>Default data cache manager.</p>
|
||||
* Default data cache manager.
|
||||
*
|
||||
* @author Abe White
|
||||
* @author Patrick Linskey
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -36,9 +36,9 @@ import serp.bytecode.Instruction;
|
|||
import serp.bytecode.JumpInstruction;
|
||||
|
||||
/**
|
||||
* <p>A {@link PCDataGenerator} instance which generates properly
|
||||
* synchronized instances suitable for use in the cache. In addition,
|
||||
* proper timed behavior is added.</p>
|
||||
* A {@link PCDataGenerator} instance which generates properly
|
||||
* synchronized instances suitable for use in the cache. In addition,
|
||||
* proper timed behavior is added.
|
||||
*
|
||||
* @author Steve Kim
|
||||
* @since 3.3.0
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -27,7 +27,7 @@ import org.apache.openjpa.meta.JavaTypes;
|
|||
import org.apache.openjpa.meta.ValueMetaData;
|
||||
|
||||
/**
|
||||
* Specialized {@link PCData} implementation for data caching. This
|
||||
* Specialized {@link PCData} implementation for data caching. This
|
||||
* implementation is properly synchronized.
|
||||
*
|
||||
* @author Patrick Linskey
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -32,15 +32,12 @@ import org.apache.openjpa.util.UserException;
|
|||
import serp.util.Strings;
|
||||
|
||||
/**
|
||||
* <p>Cron-style cache eviction. Understands schedules based on cron
|
||||
* format:<p>
|
||||
* Cron-style cache eviction. Understands schedules based on cron format:
|
||||
* <code>minute hour mday month wday</code>
|
||||
* <p/>
|
||||
* <p>For example:</p>
|
||||
* For example:
|
||||
* <code>15,30 6,19 2,10 1 2 </code>
|
||||
* <p/>
|
||||
* <p>Would run at 15 and 30 past the 6AM and 7PM, on the 2nd and 10th
|
||||
* of January when its a Monday</p>.
|
||||
* Would run at 15 and 30 past the 6AM and 7PM, on the 2nd and 10th
|
||||
* of January when its a Monday.
|
||||
*
|
||||
* @author Steve Kim
|
||||
*/
|
||||
|
@ -63,14 +60,14 @@ public class DataCacheScheduler
|
|||
}
|
||||
|
||||
/**
|
||||
* The interval time in minutes between cache checks. Defaults to 2.
|
||||
* The interval time in minutes between cache checks. Defaults to 2.
|
||||
*/
|
||||
public int getInterval() {
|
||||
return _interval;
|
||||
}
|
||||
|
||||
/**
|
||||
* The interval time in minutes between cache checks. Defaults to 2.
|
||||
* The interval time in minutes between cache checks. Defaults to 2.
|
||||
*/
|
||||
public void setInterval(int interval) {
|
||||
_interval = interval;
|
||||
|
@ -88,7 +85,7 @@ public class DataCacheScheduler
|
|||
}
|
||||
|
||||
/**
|
||||
* Schedule the given cache for eviction. Starts the scheduling thread
|
||||
* Schedule the given cache for eviction. Starts the scheduling thread
|
||||
* if not started.
|
||||
*/
|
||||
public synchronized void scheduleEviction(DataCache cache, String times) {
|
||||
|
@ -159,7 +156,7 @@ public class DataCacheScheduler
|
|||
}
|
||||
|
||||
/**
|
||||
* Simple class which represents the given time schedule.
|
||||
* Simple class which represents the given time schedule.
|
||||
*/
|
||||
private static class Schedule {
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -41,7 +41,7 @@ import org.apache.openjpa.meta.ClassMetaData;
|
|||
import org.apache.openjpa.meta.MetaDataRepository;
|
||||
|
||||
/**
|
||||
* <p>StoreManager proxy that delegates to a data cache when possible.</p>
|
||||
* StoreManager proxy that delegates to a data cache when possible.
|
||||
*
|
||||
* @author Patrick Linskey
|
||||
* @nojavadoc
|
||||
|
@ -50,9 +50,9 @@ public class DataCacheStoreManager
|
|||
extends DelegatingStoreManager {
|
||||
|
||||
// all the state managers changed in this transaction
|
||||
private Collection _inserts = null; // statemanagers
|
||||
private Map _updates = null; // statemanager -> fmd set
|
||||
private Collection _deletes = null; // statemanagers
|
||||
private Collection _inserts = null; // statemanagers
|
||||
private Map _updates = null; // statemanager -> fmd set
|
||||
private Collection _deletes = null; // statemanagers
|
||||
|
||||
// the owning context
|
||||
private StoreContext _ctx = null;
|
||||
|
@ -63,7 +63,7 @@ public class DataCacheStoreManager
|
|||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param sm the store manager to delegate to
|
||||
* @param sm the store manager to delegate to
|
||||
*/
|
||||
public DataCacheStoreManager(StoreManager sm) {
|
||||
super(sm);
|
||||
|
@ -255,8 +255,7 @@ public class DataCacheStoreManager
|
|||
|
||||
/**
|
||||
* Transforms a collection of {@link PCDataHolder}s that might contain
|
||||
* stale instances into a collection of up-to-date
|
||||
* {@link DataCachePCData}s.
|
||||
* stale instances into a collection of up-to-date {@link DataCachePCData}s.
|
||||
*/
|
||||
private void transformToVersionSafePCDatas(DataCache cache,
|
||||
List holders) {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -22,9 +22,9 @@ import org.apache.commons.lang.ObjectUtils;
|
|||
import org.apache.openjpa.util.RuntimeExceptionTranslator;
|
||||
|
||||
/**
|
||||
* <p>Delegating data cache that can also perform exception translation for
|
||||
* use in facades. This cache allows its delegate to be null, in which
|
||||
* case it returns default values for all operations.</p>
|
||||
* Delegating data cache that can also perform exception translation for
|
||||
* use in facades. This cache allows its delegate to be null, in which
|
||||
* case it returns default values for all operations.
|
||||
*
|
||||
* @author Abe White
|
||||
* @nojavadoc
|
||||
|
@ -39,7 +39,7 @@ public class DelegatingDataCache
|
|||
private final RuntimeExceptionTranslator _trans;
|
||||
|
||||
/**
|
||||
* Constructor. Supply delegate.
|
||||
* Constructor. Supply delegate.
|
||||
*/
|
||||
public DelegatingDataCache(DataCache cache) {
|
||||
this(cache, null);
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -19,9 +19,9 @@ import org.apache.commons.lang.ObjectUtils;
|
|||
import org.apache.openjpa.util.RuntimeExceptionTranslator;
|
||||
|
||||
/**
|
||||
* <p>Delegating query cache that can also perform exception translation for
|
||||
* use in facades. This cache allows its delegate to be null, in which case
|
||||
* it returns default values or all methods.</p>
|
||||
* Delegating query cache that can also perform exception translation for
|
||||
* use in facades. This cache allows its delegate to be null, in which case
|
||||
* it returns default values or all methods.
|
||||
*
|
||||
* @author Abe White
|
||||
* @since 4.0
|
||||
|
@ -35,7 +35,7 @@ public class DelegatingQueryCache
|
|||
private final RuntimeExceptionTranslator _trans;
|
||||
|
||||
/**
|
||||
* Constructor. Supply delegate.
|
||||
* Constructor. Supply delegate.
|
||||
*/
|
||||
public DelegatingQueryCache(QueryCache cache) {
|
||||
this(cache, null);
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -18,9 +18,9 @@ package org.apache.openjpa.datacache;
|
|||
import java.util.EventObject;
|
||||
|
||||
/**
|
||||
* <p>An event indicating the expiration of an object from the data cache,
|
||||
* An event indicating the expiration of an object from the data cache,
|
||||
* or an expiration of a result list from the query cache.
|
||||
* The source of the event will be the cache.</p>
|
||||
* The source of the event will be the cache.
|
||||
*
|
||||
* @since 3.0
|
||||
* @author Abe White
|
||||
|
@ -34,9 +34,9 @@ public class ExpirationEvent
|
|||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param source the data or query cache
|
||||
* @param key the expired object oid or query key
|
||||
* @param expired <code>true</code> if the object was expired
|
||||
* @param source the data or query cache
|
||||
* @param key the expired object oid or query key
|
||||
* @param expired <code>true</code> if the object was expired
|
||||
* naturally; else <code>false</code>.
|
||||
*/
|
||||
public ExpirationEvent(Object source, Object key, boolean expired) {
|
||||
|
@ -53,8 +53,8 @@ public class ExpirationEvent
|
|||
}
|
||||
|
||||
/**
|
||||
* Return whether the expired object was expired naturally, or if
|
||||
* the object was explicitly removed.
|
||||
* Return whether the expired object was expired naturally, or if
|
||||
* the object was explicitly removed.
|
||||
*/
|
||||
public boolean getExpired() {
|
||||
return _expired;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -16,7 +16,7 @@
|
|||
package org.apache.openjpa.datacache;
|
||||
|
||||
/**
|
||||
* <p>An entity that wishes to be notified when cache keys expire.</p>
|
||||
* An entity that wishes to be notified when cache keys expire.
|
||||
*
|
||||
* @author Abe White
|
||||
* @since 3.0
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -20,11 +20,11 @@ import java.util.Map;
|
|||
import org.apache.openjpa.lib.util.Closeable;
|
||||
|
||||
/**
|
||||
* <p>Interface that must be implemented by any level 2 query cache
|
||||
* Interface that must be implemented by any level 2 query cache
|
||||
* used by OpenJPA. These methods should be threadsafe.
|
||||
* Most query cache implementations will probably implement
|
||||
* {@link org.apache.openjpa.lib.conf.Configurable} to receive a handle to the
|
||||
* system configuration on construction.</p>
|
||||
* system configuration on construction.
|
||||
*
|
||||
* @since 2.5
|
||||
* @author Patrick Linskey
|
||||
|
@ -41,18 +41,17 @@ public interface QueryCache
|
|||
public void initialize(DataCacheManager manager);
|
||||
|
||||
/**
|
||||
* <p>Return a list of oids for the given query key. This is an
|
||||
* unmodifiable list.</p>
|
||||
* Return a list of oids for the given query key. This is an
|
||||
* unmodifiable list.
|
||||
*
|
||||
* @return The query results matching the given key, or null
|
||||
* if none
|
||||
* @return The query results matching the given key, or null if none
|
||||
*/
|
||||
public QueryResult get(QueryKey qk);
|
||||
|
||||
/**
|
||||
* <p>Set the list of OIDs for the given query key. A reference
|
||||
* Set the list of OIDs for the given query key. A reference
|
||||
* to the given list will be stored in the query cache, so the
|
||||
* list should not be modified after invoking this method.</p>
|
||||
* list should not be modified after invoking this method.
|
||||
*
|
||||
* @return The previously cached value, or <code>null</code> if
|
||||
* the key was not previously cached. See {@link Map#put}
|
||||
|
@ -61,13 +60,12 @@ public interface QueryCache
|
|||
public QueryResult put(QueryKey qk, QueryResult oids);
|
||||
|
||||
/**
|
||||
* <p>Remove the value stored under the given query key.</p>
|
||||
* <p/>
|
||||
* <p>This method is typically not invoked directly from outside
|
||||
* Remove the value stored under the given query key.
|
||||
* This method is typically not invoked directly from outside
|
||||
* the <code>QueryCache</code> class. Instead, the cache should
|
||||
* be updated by implementing {@link
|
||||
* be updated by implementing {@link
|
||||
* org.apache.openjpa.event.RemoteCommitListener},
|
||||
* which will result in all queries that may be invalid being dropped.</p>
|
||||
* which will result in all queries that may be invalid being dropped.
|
||||
*
|
||||
* @return The previously cached value, or <code>null</code> if
|
||||
* the key was not previously cached. See {@link Map#remove}
|
||||
|
@ -76,7 +74,7 @@ public interface QueryCache
|
|||
public QueryResult remove(QueryKey qk);
|
||||
|
||||
/**
|
||||
* <p>Remove all data from this cache.</p>
|
||||
* Remove all data from this cache.
|
||||
*/
|
||||
public void clear();
|
||||
|
||||
|
@ -90,8 +88,7 @@ public interface QueryCache
|
|||
* behavior of {@link #remove} or {@link #onTypesChanged}.
|
||||
*
|
||||
* @return <code>true</code> if <code>key</code>'s value was
|
||||
* pinned into the cache; <code>false</code> if the
|
||||
* key is not in the cache.
|
||||
* pinned into the cache; <code>false</code> if the key is not in the cache.
|
||||
*/
|
||||
public boolean pin(QueryKey qk);
|
||||
|
||||
|
@ -99,12 +96,11 @@ public interface QueryCache
|
|||
* Unpin the value stored under <code>key</code> into the cache.
|
||||
* This method reverses a previous invocation of {@link #pin}.
|
||||
* This method does not remove anything from the cache; it merely
|
||||
* makes <code>key</code>'s value a candidate for flushing from
|
||||
* the cache.
|
||||
* makes <code>key</code>'s value a candidate for flushing from the cache.
|
||||
*
|
||||
* @return <code>true</code> if <code>key</code>'s value was
|
||||
* unpinned from the cache; <code>false</code> if the
|
||||
* key is not in the cache.
|
||||
* unpinned from the cache; <code>false</code> if the
|
||||
* key is not in the cache.
|
||||
*/
|
||||
public boolean unpin(QueryKey qk);
|
||||
|
||||
|
@ -133,7 +129,7 @@ public interface QueryCache
|
|||
public boolean removeTypesChangedListener(TypesChangedListener listen);
|
||||
|
||||
/**
|
||||
* Free the resources used by this cache.
|
||||
* Free the resources used by this cache.
|
||||
*/
|
||||
public void close ();
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -46,8 +46,7 @@ import serp.util.Numbers;
|
|||
|
||||
/**
|
||||
* A {@link StoreQuery} implementation that caches the OIDs involved in
|
||||
* the query, and can determine whether or not the query has been
|
||||
* dirtied.
|
||||
* the query, and can determine whether or not the query has been dirtied.
|
||||
*
|
||||
* @author Patrick Linskey
|
||||
* @since 2.5.0
|
||||
|
@ -70,8 +69,7 @@ public class QueryCacheStoreQuery
|
|||
}
|
||||
|
||||
/**
|
||||
* Return the {@link QueryCache} that this object is associated
|
||||
* with.
|
||||
* Return the {@link QueryCache} that this object is associated with.
|
||||
*/
|
||||
public QueryCache getCache() {
|
||||
return _cache;
|
||||
|
@ -85,30 +83,25 @@ public class QueryCacheStoreQuery
|
|||
}
|
||||
|
||||
/**
|
||||
* <p>Look in the query cache for a result for the given query
|
||||
* Look in the query cache for a result for the given query
|
||||
* key. Only look if this query is being executed outside a
|
||||
* transaction or in a transaction with IgnoreChanges set to true
|
||||
* or in a transaction with IgnoreChanges set to false but in which
|
||||
* none of the classes involved in this query have been
|
||||
* touched.</p>
|
||||
* <p/>
|
||||
* <p>Caching is not used when using object locking.
|
||||
* none of the classes involved in this query have been touched.
|
||||
* Caching is not used when using object locking.
|
||||
* This is because we must obtain locks on the
|
||||
* data, and it is likely that making n trips to the database to
|
||||
* make the locks will be slower than running the query against
|
||||
* the database.</p>
|
||||
* <p/>
|
||||
* <p>If the fetch configuration has query caching disabled,
|
||||
* then this method returns <code>null</code>.</p>
|
||||
* <p/>
|
||||
* <p>Return the list if we meet the above criteria and if a list
|
||||
* the database.
|
||||
* If the fetch configuration has query caching disabled,
|
||||
* then this method returns <code>null</code>.
|
||||
* Return the list if we meet the above criteria and if a list
|
||||
* is found for <code>qk</code>. Else, return
|
||||
* <code>null</code>.</p>
|
||||
* <p/>
|
||||
* <p>This implementation means that queries against the cache
|
||||
* <code>null</code>.
|
||||
* This implementation means that queries against the cache
|
||||
* are of READ_COMMITTED isolation level. It'd be nice to support
|
||||
* READ_SERIALIZABLE -- to do so, we'd just return false when in
|
||||
* a transaction.</p>
|
||||
* a transaction.
|
||||
*/
|
||||
private List checkCache(QueryKey qk) {
|
||||
if (qk == null)
|
||||
|
@ -451,7 +444,7 @@ public class QueryCacheStoreQuery
|
|||
}
|
||||
|
||||
/**
|
||||
* Result list implementation for a cached query result. Package-protected
|
||||
* Result list implementation for a cached query result. Package-protected
|
||||
* for testing.
|
||||
*/
|
||||
public static class CachedList
|
||||
|
@ -495,8 +488,7 @@ public class QueryCacheStoreQuery
|
|||
* A wrapper around a {@link ResultObjectProvider} that builds up a list of
|
||||
* all the OIDs in this list and registers that list with the
|
||||
* query cache. Abandons monitoring and registering if one of the classes
|
||||
* in the access path is modified while the query results are being
|
||||
* loaded.
|
||||
* in the access path is modified while the query results are being loaded.
|
||||
*/
|
||||
private class CachingResultObjectProvider
|
||||
implements ResultObjectProvider, TypesChangedListener {
|
||||
|
@ -514,7 +506,7 @@ public class QueryCacheStoreQuery
|
|||
private int _size = Integer.MAX_VALUE;
|
||||
|
||||
/**
|
||||
* Constructor. Supply delegate result provider and our query key.
|
||||
* Constructor. Supply delegate result provider and our query key.
|
||||
*/
|
||||
public CachingResultObjectProvider(ResultObjectProvider rop,
|
||||
boolean proj, QueryKey key) {
|
||||
|
@ -666,7 +658,7 @@ public class QueryCacheStoreQuery
|
|||
}
|
||||
|
||||
/**
|
||||
* Struct to recognize cached oids.
|
||||
* Struct to recognize cached oids.
|
||||
*/
|
||||
private static class CachedObjectId {
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -45,11 +45,11 @@ import org.apache.openjpa.meta.MetaDataRepository;
|
|||
import org.apache.openjpa.util.ImplHelper;
|
||||
|
||||
/**
|
||||
* <p>This class stores information about a particular invocation of
|
||||
* This class stores information about a particular invocation of
|
||||
* a query. It contains a reference to the external properties of the
|
||||
* query that was executed, as well as any parameters used to execute
|
||||
* that query, with one exception: first-class objects used as
|
||||
* parameter values are converted to OIDs.</p>
|
||||
* parameter values are converted to OIDs.
|
||||
*
|
||||
* @author Patrick Linskey
|
||||
*/
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -19,7 +19,7 @@ import java.util.ArrayList;
|
|||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* <p>A query result.</p>
|
||||
* A query result.
|
||||
*
|
||||
* @author Abe White
|
||||
*/
|
||||
|
@ -56,7 +56,7 @@ public class QueryResult
|
|||
}
|
||||
|
||||
/**
|
||||
* Whether this data is timed out.
|
||||
* Whether this data is timed out.
|
||||
*/
|
||||
public boolean isTimedOut() {
|
||||
return _ex != -1 && _ex < System.currentTimeMillis();
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -19,8 +19,8 @@ import java.util.Collection;
|
|||
import java.util.EventObject;
|
||||
|
||||
/**
|
||||
* <p>An event indicating that instances of given persistent types have
|
||||
* been modified.</p>
|
||||
* An event indicating that instances of given persistent types have
|
||||
* been modified.
|
||||
*
|
||||
* @author Abe White
|
||||
*/
|
||||
|
@ -32,8 +32,8 @@ public class TypesChangedEvent
|
|||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param source the data or query cache
|
||||
* @param types the changed types
|
||||
* @param source the data or query cache
|
||||
* @param types the changed types
|
||||
*/
|
||||
public TypesChangedEvent(Object source, Collection types) {
|
||||
super(source);
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -16,7 +16,7 @@
|
|||
package org.apache.openjpa.datacache;
|
||||
|
||||
/**
|
||||
* <p>An entity that wishes to be notified when types change.</p>
|
||||
* An entity that wishes to be notified when types change.
|
||||
*
|
||||
* @author Abe White
|
||||
* @since 3.0
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -25,11 +25,10 @@ import org.apache.openjpa.lib.util.Localizer;
|
|||
import org.apache.openjpa.util.InvalidStateException;
|
||||
|
||||
/**
|
||||
* <p>Implementation of the {@link ManagedRuntime} interface that searches
|
||||
* Implementation of the {@link ManagedRuntime} interface that searches
|
||||
* through a set of known JNDI locations and method invocations to locate the
|
||||
* appropriate mechanism for obtaining a TransactionManager.</p>
|
||||
* <p/>
|
||||
* <p>Built in support is provided for the following Application Servers:
|
||||
* appropriate mechanism for obtaining a TransactionManager.
|
||||
* Built in support is provided for the following Application Servers:
|
||||
* <ul>
|
||||
* <li>Bluestone</li>
|
||||
* <li>HP Application Server</li>
|
||||
|
@ -41,7 +40,7 @@ import org.apache.openjpa.util.InvalidStateException;
|
|||
* <li>SunONE</li>
|
||||
* <li>Weblogic</li>
|
||||
* <li>Websphere</li>
|
||||
* </ul></p>
|
||||
* </ul>
|
||||
*
|
||||
* @author Marc Prud'hommeaux
|
||||
*/
|
||||
|
@ -49,12 +48,12 @@ public class AutomaticManagedRuntime
|
|||
implements ManagedRuntime, Configurable {
|
||||
|
||||
private static final String [] JNDI_LOCS = new String []{
|
||||
"javax.transaction.TransactionManager", // weblogic
|
||||
"java:/TransactionManager", // jboss & jrun
|
||||
"java:/DefaultDomain/TransactionManager", // jrun too
|
||||
"java:comp/pm/TransactionManager", // orion & oracle
|
||||
"java:comp/TransactionManager", // generic
|
||||
"java:pm/TransactionManager", // borland
|
||||
"javax.transaction.TransactionManager", // weblogic
|
||||
"java:/TransactionManager", // jboss & jrun
|
||||
"java:/DefaultDomain/TransactionManager", // jrun too
|
||||
"java:comp/pm/TransactionManager", // orion & oracle
|
||||
"java:comp/TransactionManager", // generic
|
||||
"java:pm/TransactionManager", // borland
|
||||
};
|
||||
private static final String [] METHODS = new String[]{
|
||||
"com.arjuna.jta.JTA_TransactionManager.transactionManager", // hp
|
||||
|
@ -66,7 +65,7 @@ public class AutomaticManagedRuntime
|
|||
"org.openejb.OpenEJB.getTransactionManager",
|
||||
"com.sun.jts.jta.TransactionManagerImpl.getTransactionManagerImpl",
|
||||
"com.inprise.visitransact.jta.TransactionManagerImpl."
|
||||
+ "getTransactionManagerImpl", // borland
|
||||
+ "getTransactionManagerImpl", // borland
|
||||
};
|
||||
private static final ManagedRuntime WLS;
|
||||
private static final ManagedRuntime SUNONE;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -23,12 +23,11 @@ import org.apache.openjpa.lib.conf.Configurable;
|
|||
import org.apache.openjpa.lib.conf.Configuration;
|
||||
|
||||
/**
|
||||
* <p>Implementation of the {@link ManagedRuntime} interface that uses
|
||||
* a static method call to find the TransactionManager.</p>
|
||||
* <p/>
|
||||
* <p>For example, to configure it to use IBM Websphere's TransactionManager,
|
||||
* Implementation of the {@link ManagedRuntime} interface that uses
|
||||
* a static method call to find the TransactionManager.
|
||||
* For example, to configure it to use IBM Websphere's TransactionManager,
|
||||
* use the method:<br />
|
||||
* <code>com.ibm.ejs.jts.jta.JTSXA.getTransactionManager</code></p>
|
||||
* <code>com.ibm.ejs.jts.jta.JTSXA.getTransactionManager</code>
|
||||
*
|
||||
* @author Marc Prud'hommeaux
|
||||
*/
|
||||
|
@ -49,8 +48,7 @@ public class InvocationManagedRuntime
|
|||
|
||||
/**
|
||||
* Set the method to invoke to get the {@link TransactionManager}.
|
||||
* <p/>
|
||||
* E.g.: com.ibm.ejs.jts.jta.JTSXA.getTransactionManager
|
||||
* E.g.: com.ibm.ejs.jts.jta.JTSXA.getTransactionManager
|
||||
*/
|
||||
public void setTransactionManagerMethod(String methodName) {
|
||||
_clazz = methodName.substring(0, methodName.lastIndexOf('.'));
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -20,8 +20,8 @@ import javax.naming.InitialContext;
|
|||
import javax.transaction.TransactionManager;
|
||||
|
||||
/**
|
||||
* <p>Implementation of the {@link ManagedRuntime} interface that uses JNDI to
|
||||
* find the TransactionManager.</p>
|
||||
* Implementation of the {@link ManagedRuntime} interface that uses JNDI to
|
||||
* find the TransactionManager.
|
||||
*
|
||||
* @author Abe White
|
||||
*/
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -18,15 +18,15 @@ package org.apache.openjpa.ee;
|
|||
import javax.transaction.TransactionManager;
|
||||
|
||||
/**
|
||||
* <p>This interface must be implemented by concrete plugins to application
|
||||
* servers in order to integrate the OpenJPA runtime in a managed environment.</p>
|
||||
* This interface must be implemented by concrete plugins to application
|
||||
* servers in order to integrate the OpenJPA runtime in a managed environment.
|
||||
*
|
||||
* @author Abe White
|
||||
*/
|
||||
public interface ManagedRuntime {
|
||||
|
||||
/**
|
||||
* Return the TransactionManager for the managed runtime. This
|
||||
* Return the TransactionManager for the managed runtime. This
|
||||
* manager is used to register synchronization listeners, to
|
||||
* map transactional PersistenceManagers to the current transaction,
|
||||
* and possibly to enlist XA resources.
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -58,8 +58,7 @@ import serp.bytecode.Project;
|
|||
import serp.util.Strings;
|
||||
|
||||
/**
|
||||
* <p>Generates a class appropriate for use as an application identity
|
||||
* class.</p>
|
||||
* Generates a class appropriate for use as an application identity class.
|
||||
*
|
||||
* @author Patrick Linskey
|
||||
* @author Abe White
|
||||
|
@ -174,8 +173,8 @@ public class ApplicationIdTool {
|
|||
}
|
||||
|
||||
/**
|
||||
* The directory to write source to. Defaults to the directory
|
||||
* of the Java file for the set type. If the given directory does not
|
||||
* The directory to write source to. Defaults to the directory
|
||||
* of the Java file for the set type. If the given directory does not
|
||||
* match the package of the object id, the package structure will be
|
||||
* created below the directory.
|
||||
*/
|
||||
|
@ -184,8 +183,8 @@ public class ApplicationIdTool {
|
|||
}
|
||||
|
||||
/**
|
||||
* The directory to write source to. Defaults to the directory
|
||||
* of the Java file for the set type. If the given directory does not
|
||||
* The directory to write source to. Defaults to the directory
|
||||
* of the Java file for the set type. If the given directory does not
|
||||
* match the package of the object id, the package structure will be
|
||||
* created below the directory.
|
||||
*/
|
||||
|
@ -244,8 +243,7 @@ public class ApplicationIdTool {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns true if the application identity class should
|
||||
* be an inner class.
|
||||
* Returns true if the application identity class should be an inner class.
|
||||
*/
|
||||
public boolean isInnerClass() {
|
||||
Class oidClass = _meta.getObjectIdType();
|
||||
|
@ -605,7 +603,7 @@ public class ApplicationIdTool {
|
|||
|
||||
/**
|
||||
* Create the fromString method that parses the result of our toString
|
||||
* method. If we have superclasses with id fields, this will call
|
||||
* method. If we have superclasses with id fields, this will call
|
||||
* super.fromString() so that the parent class can parse its own fields.
|
||||
*/
|
||||
private String getFromStringCode(boolean hasSuperclass) {
|
||||
|
@ -702,7 +700,7 @@ public class ApplicationIdTool {
|
|||
else if (!type.isPrimitive()) {
|
||||
parse.append("new ").append(Strings.getClassName(type)).
|
||||
openParen(true).append(var).closeParen();
|
||||
} else // primitive
|
||||
} else // primitive
|
||||
{
|
||||
switch (type.getName().charAt(0)) {
|
||||
case 'b':
|
||||
|
@ -852,8 +850,7 @@ public class ApplicationIdTool {
|
|||
|
||||
/**
|
||||
* Return a hashCode method that takes into account all
|
||||
* primary key values. Must deal correctly with both
|
||||
* primitives and objects.
|
||||
* primary key values. Must deal correctly with both primitives and objects.
|
||||
*/
|
||||
private String getHashCodeCode(boolean hasSuperclass) {
|
||||
// if we are below a concrete class then we cannot declare any
|
||||
|
@ -1025,7 +1022,7 @@ public class ApplicationIdTool {
|
|||
/**
|
||||
* Code to convert a string to a byte array.
|
||||
*
|
||||
* @see org.apache.openjpa.lib.util.Base16Encoder#decode
|
||||
* @see org.apache.openjpa.lib.util.Base16Encoder#decode
|
||||
*/
|
||||
private String getToBytesByteArrayCode() {
|
||||
CodeFormat code = newCodeFormat();
|
||||
|
@ -1071,7 +1068,7 @@ public class ApplicationIdTool {
|
|||
/**
|
||||
* Code to convert a byte array to a string.
|
||||
*
|
||||
* @see org.apache.openjpa.lib.util.Base16Encoder#encode
|
||||
* @see org.apache.openjpa.lib.util.Base16Encoder#encode
|
||||
*/
|
||||
private String getToStringByteArrayCode() {
|
||||
CodeFormat code = newCodeFormat();
|
||||
|
@ -1222,20 +1219,19 @@ public class ApplicationIdTool {
|
|||
}
|
||||
|
||||
/**
|
||||
* <p>Usage: java org.apache.openjpa.enhance.ApplicationIdTool [option]*
|
||||
* <class name | .java file | .class file | .jdo file>+</p>
|
||||
* <p/>
|
||||
* <p>Where the following options are recognized.
|
||||
* Usage: java org.apache.openjpa.enhance.ApplicationIdTool [option]*
|
||||
* <class name | .java file | .class file | .jdo file>+
|
||||
* Where the following options are recognized.
|
||||
* <ul>
|
||||
* <li><i>-properties/-p <properties file></i>: The path to a OpenJPA
|
||||
* properties file containing information as outlined in
|
||||
* properties file containing information as outlined in
|
||||
* {@link Configuration}; optional.</li>
|
||||
* <li><i>-<property name> <property value></i>: All bean
|
||||
* properties of the standard OpenJPA {@link OpenJPAConfiguration} can be
|
||||
* set by using their names and supplying a value.</li>
|
||||
* <li><i>-directory/-d <output directory></i>: Path to the base
|
||||
* source directory. The package structure will be created beneath
|
||||
* this directory if necessary. If not specified, the tool will try
|
||||
* source directory. The package structure will be created beneath
|
||||
* this directory if necessary. If not specified, the tool will try
|
||||
* to locate the .java file in the CLASSPATH and output to the same
|
||||
* directory; failing that, it will use the current directory as
|
||||
* the base directory.
|
||||
|
@ -1246,24 +1242,23 @@ public class ApplicationIdTool {
|
|||
* <li><i>-token/-t <token></i>: The token to use to separate
|
||||
* stingified primary key field values in the stringified oid.</li>
|
||||
* <li><i>-name/-n <id class name></i>: The name of the identity
|
||||
* class to generate. If this option is specified, you must only
|
||||
* give a single class argument. If the class metadata names an object
|
||||
* class to generate. If this option is specified, you must only
|
||||
* give a single class argument. If the class metadata names an object
|
||||
* id class, this argument is ignored.</li>
|
||||
* <li><i>-suffix/-s <id class suffix></i>: A string to suffix each
|
||||
* persistent class with to create the identity class name. This is
|
||||
* persistent class with to create the identity class name. This is
|
||||
* overridden by <code>-name</code> or by any identity class name
|
||||
* specified in metadata.</li>
|
||||
* <li><i>-codeFormat/-cf.<property name> < property value></i>
|
||||
* : Arguments like this will be used to configure the bean
|
||||
* properties of the internal {@link CodeFormat}.</li>
|
||||
* </ul></p>
|
||||
* <p/>
|
||||
* <p>Each additional argument can be either the full class name of the
|
||||
* </ul>
|
||||
* Each additional argument can be either the full class name of the
|
||||
* type to create an id class for, the path to the .java file for the type,
|
||||
* the path to the .class file for the type, or the path to a .jdo file
|
||||
* listing one or more types. If a .java file already exists for an
|
||||
* listing one or more types. If a .java file already exists for an
|
||||
* application id, it will be backed up to a file named
|
||||
* <orig file name>~.</p>
|
||||
* <orig file name>~.
|
||||
*/
|
||||
public static void main(String[] args)
|
||||
throws IOException, ClassNotFoundException {
|
||||
|
@ -1281,8 +1276,7 @@ public class ApplicationIdTool {
|
|||
|
||||
/**
|
||||
* Run the application id tool with the given command-line and
|
||||
* given configuration. Returns false if invalid options were
|
||||
* given.
|
||||
* given configuration. Returns false if invalid options were given.
|
||||
*/
|
||||
public static boolean run(OpenJPAConfiguration conf, String[] args,
|
||||
Options opts)
|
||||
|
@ -1326,7 +1320,7 @@ public class ApplicationIdTool {
|
|||
}
|
||||
|
||||
/**
|
||||
* Run the tool. Returns false if invalid options were given.
|
||||
* Run the tool. Returns false if invalid options were given.
|
||||
*/
|
||||
public static boolean run(OpenJPAConfiguration conf, String[] args,
|
||||
Flags flags, ClassLoader loader)
|
||||
|
@ -1450,14 +1444,13 @@ public class ApplicationIdTool {
|
|||
}
|
||||
|
||||
/**
|
||||
* Interface implemented by metadata factories that can load non-existant
|
||||
* object id classes.
|
||||
* Interface implemented by metadata factories that can load non-existant
|
||||
* object id classes.
|
||||
*/
|
||||
public static interface ObjectIdLoader
|
||||
{
|
||||
/**
|
||||
* Turn on the loading of all identity classes, even if they don't
|
||||
* exist.
|
||||
* Turn on the loading of all identity classes, even if they don't exist.
|
||||
*/
|
||||
public void setLoadObjectIds ();
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -34,7 +34,7 @@ import org.apache.openjpa.meta.MetaDataRepository;
|
|||
import serp.util.Strings;
|
||||
|
||||
/**
|
||||
* <p>Generates Java class code from metadata.</p>
|
||||
* Generates Java class code from metadata.
|
||||
*
|
||||
* @author Abe White
|
||||
* @author Stephen Kim
|
||||
|
@ -50,14 +50,14 @@ public class CodeGenerator {
|
|||
private ParameterTemplate _code = null;
|
||||
|
||||
/**
|
||||
* Constructor. Supply configuration and class to generate code for.
|
||||
* Constructor. Supply configuration and class to generate code for.
|
||||
*/
|
||||
public CodeGenerator(OpenJPAConfiguration conf, Class type) {
|
||||
this(new MetaDataRepository(conf).getMetaData(type, null, true));
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor. Supply configuration and metadata to generate code for.
|
||||
* Constructor. Supply configuration and metadata to generate code for.
|
||||
*/
|
||||
public CodeGenerator(ClassMetaData meta) {
|
||||
_meta = meta;
|
||||
|
@ -65,7 +65,7 @@ public class CodeGenerator {
|
|||
}
|
||||
|
||||
/**
|
||||
* The directory to write source to. Defaults to the current directory.
|
||||
* The directory to write source to. Defaults to the current directory.
|
||||
* If the given directory does not match the package of the metadata, the
|
||||
* package structure will be created below the directory.
|
||||
*/
|
||||
|
@ -74,7 +74,7 @@ public class CodeGenerator {
|
|||
}
|
||||
|
||||
/**
|
||||
* The directory to write source to. Defaults to the current directory.
|
||||
* The directory to write source to. Defaults to the current directory.
|
||||
* If the given directory does not match the package of the metadata, the
|
||||
* package structure will be created below the directory.
|
||||
*/
|
||||
|
@ -293,8 +293,7 @@ public class CodeGenerator {
|
|||
}
|
||||
|
||||
/**
|
||||
* Append the declaration and code for the given field to the given
|
||||
* buffers.
|
||||
* Append the declaration and code for the given field to the given buffers.
|
||||
*/
|
||||
private void appendFieldCode(FieldMetaData fmd, CodeFormat decs,
|
||||
CodeFormat code) {
|
||||
|
@ -462,25 +461,22 @@ public class CodeGenerator {
|
|||
|
||||
/**
|
||||
* Return a code template for the given class, or null to use the standard
|
||||
* system-generated Java code. To facilitate template reuse, the
|
||||
* system-generated Java code. To facilitate template reuse, the
|
||||
* following parameters can appear in the template; the proper values
|
||||
* will be subtituted by the system:
|
||||
* <ul>
|
||||
* <li>${packageDec}: The package declaration, in the form
|
||||
* "package <package name >;", or empty string if no
|
||||
* package.</li>
|
||||
* "package <package name >;", or empty string if no package.</li>
|
||||
* <li>${imports}: Imports for the packages used by the declared
|
||||
* field types.</li>
|
||||
* <li>${className}: The name of the class, without package.</li>
|
||||
* <li>${extendsDec}: Extends declaration, in the form
|
||||
* "extends <superclass>", or empty string if no superclass.</li>
|
||||
* <li>${constructor}: A constructor that takes in all primary key fields
|
||||
* of the class, or empty string if the class uses datastore
|
||||
* identity.</li>
|
||||
* of the class, or empty string if the class uses datastore identity.</li>
|
||||
* <li>${fieldDecs}: Declarations of all the declared fields.</li>
|
||||
* <li>${fieldCode}: Get/set methods for all the declared fields.</li>
|
||||
* </ul>
|
||||
* Returns null by default.
|
||||
* </ul> Returns null by default.
|
||||
*/
|
||||
protected String getClassCode() {
|
||||
return null;
|
||||
|
@ -488,7 +484,7 @@ public class CodeGenerator {
|
|||
|
||||
/**
|
||||
* Return code for the initial value for the given field, or null to use
|
||||
* the default generated by the system. Returns null by default.
|
||||
* the default generated by the system. Returns null by default.
|
||||
*/
|
||||
protected String getInitialValue(FieldMetaData field) {
|
||||
return null;
|
||||
|
@ -506,26 +502,25 @@ public class CodeGenerator {
|
|||
* <li>${fieldType}: The field's type name.</li>
|
||||
* <li>${fieldValue}: The field's initial value, in the form
|
||||
* " = <value>", or empty string if none.</li>
|
||||
* </ul>
|
||||
* Returns null by default.
|
||||
* </ul> Returns null by default.
|
||||
*/
|
||||
protected String getDeclaration(FieldMetaData field) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a code template for the get/set methods of the given field, or
|
||||
* null to use the system-generated default Java code.
|
||||
* To facilitate template reuse, the following parameters can appear in
|
||||
* your template; the proper values will be subtituted by the system:
|
||||
* <ul>
|
||||
* <li>${fieldName}: The name of the field.</li>
|
||||
* <li>${capFieldName}: The capitalized field name.</li>
|
||||
* <li>${propertyName}: The field name without leading '_', if any.</li>
|
||||
* <li>${fieldType}: The field's type name.</li>
|
||||
* <li>${fieldValue}: The field's initial value, in the form
|
||||
* "= <value>", or empty string if none.</li>
|
||||
* </ul>
|
||||
* Return a code template for the get/set methods of the given field, or
|
||||
* null to use the system-generated default Java code.
|
||||
* To facilitate template reuse, the following parameters can appear in
|
||||
* your template; the proper values will be subtituted by the system:
|
||||
* <ul>
|
||||
* <li>${fieldName}: The name of the field.</li>
|
||||
* <li>${capFieldName}: The capitalized field name.</li>
|
||||
* <li>${propertyName}: The field name without leading '_', if any.</li>
|
||||
* <li>${fieldType}: The field's type name.</li>
|
||||
* <li>${fieldValue}: The field's initial value, in the form
|
||||
* "= <value>", or empty string if none.</li>
|
||||
* </ul>
|
||||
*/
|
||||
protected String getFieldCode (FieldMetaData field)
|
||||
{
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -16,9 +16,9 @@
|
|||
package org.apache.openjpa.enhance;
|
||||
|
||||
/**
|
||||
* <p>Interface for dynamically generated classes. Certain getters/setters
|
||||
* Interface for dynamically generated classes. Certain getters/setters
|
||||
* may either return null or throw an exception depending on the
|
||||
* {@link DynamicStorageGenerator}'s field policy.</p>
|
||||
* {@link DynamicStorageGenerator}'s field policy.
|
||||
*
|
||||
* @author Steve Kim
|
||||
* @nojavadoc
|
||||
|
@ -132,7 +132,7 @@ public interface DynamicStorage {
|
|||
public void setObject(int field, Object val);
|
||||
|
||||
/**
|
||||
* Ensure object capacity
|
||||
* Ensure object capacity
|
||||
*/
|
||||
public void initialize ();
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -33,8 +33,8 @@ import serp.bytecode.Project;
|
|||
import serp.bytecode.TableSwitchInstruction;
|
||||
|
||||
/**
|
||||
* <p>Factory for creating new {@link DynamicStorage} classes. Can be
|
||||
* extended to decorate/modify the generated instances behavior.</p>
|
||||
* Factory for creating new {@link DynamicStorage} classes. Can be
|
||||
* extended to decorate/modify the generated instances behavior.
|
||||
*
|
||||
* @author Steve Kim
|
||||
* @nojavadoc
|
||||
|
@ -58,7 +58,7 @@ public class DynamicStorageGenerator {
|
|||
|
||||
/**
|
||||
* Constant to be as silent as possible during invalid index passed
|
||||
* to set/get type methods. On getting an Object, for example,
|
||||
* to set/get type methods. On getting an Object, for example,
|
||||
* null will be returned.
|
||||
* However, on primitive gets, an exception will be thrown.
|
||||
*/
|
||||
|
@ -119,7 +119,7 @@ public class DynamicStorageGenerator {
|
|||
}
|
||||
|
||||
/**
|
||||
* Return a class name to use for the given user key. By default,
|
||||
* Return a class name to use for the given user key. By default,
|
||||
* returns the stringified key prefixed by PREFIX.
|
||||
*/
|
||||
protected String getClassName(Object obj) {
|
||||
|
@ -135,7 +135,7 @@ public class DynamicStorageGenerator {
|
|||
}
|
||||
|
||||
/**
|
||||
* Return the name for the generated field at the given index. Returns
|
||||
* Return the name for the generated field at the given index. Returns
|
||||
* <code>"field" + i</code> by default.
|
||||
*/
|
||||
protected String getFieldName(int index) {
|
||||
|
@ -413,7 +413,7 @@ public class DynamicStorageGenerator {
|
|||
|
||||
/**
|
||||
* Clear code associated with the given method signature, and return
|
||||
* the empty code. Will return null if the method should be empty.
|
||||
* the empty code. Will return null if the method should be empty.
|
||||
*/
|
||||
protected Code replaceMethod(BCClass bc, String name, Class retType,
|
||||
Class[] args, boolean remove) {
|
||||
|
@ -518,7 +518,7 @@ public class DynamicStorageGenerator {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the wrapper for the given type.
|
||||
* Get the wrapper for the given type.
|
||||
*/
|
||||
protected Class getWrapper(Class c) {
|
||||
for (int i = 0; i < WRAPPERS.length; i++) {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -16,7 +16,7 @@
|
|||
package org.apache.openjpa.enhance;
|
||||
|
||||
/**
|
||||
* <p>Consumes persistent field values.</p>
|
||||
* Consumes persistent field values.
|
||||
*/
|
||||
public interface FieldConsumer {
|
||||
|
||||
|
@ -66,7 +66,7 @@ public interface FieldConsumer {
|
|||
void storeStringField(int fieldIndex, String value);
|
||||
|
||||
/**
|
||||
* Set the value of the given field.
|
||||
* Set the value of the given field.
|
||||
*/
|
||||
void storeObjectField(int fieldIndex, Object value);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -16,7 +16,7 @@
|
|||
package org.apache.openjpa.enhance;
|
||||
|
||||
/**
|
||||
* <p>Manages persistent fields.</p>
|
||||
* Manages persistent fields.
|
||||
*/
|
||||
public interface FieldManager
|
||||
extends FieldConsumer, FieldSupplier {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -16,7 +16,7 @@
|
|||
package org.apache.openjpa.enhance;
|
||||
|
||||
/**
|
||||
* <p>Supplies persistent field values.</p>
|
||||
* Supplies persistent field values.
|
||||
*/
|
||||
public interface FieldSupplier {
|
||||
|
||||
|
@ -66,7 +66,7 @@ public interface FieldSupplier {
|
|||
String fetchStringField(int fieldIndex);
|
||||
|
||||
/**
|
||||
* Return the value of the given field.
|
||||
* Return the value of the given field.
|
||||
*/
|
||||
Object fetchObjectField (int fieldIndex);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -48,9 +48,9 @@ import serp.bytecode.JumpInstruction;
|
|||
import serp.bytecode.LookupSwitchInstruction;
|
||||
|
||||
/**
|
||||
* <p>Generates {@link PCData} instances which avoid primitve wrappers
|
||||
* Generates {@link PCData} instances which avoid primitve wrappers
|
||||
* to optimize memory use and performance at the cost of slightly higher
|
||||
* startup time.</p>
|
||||
* startup time.
|
||||
*
|
||||
* @author Steve Kim
|
||||
* @nojavadoc
|
||||
|
@ -116,8 +116,7 @@ public class PCDataGenerator
|
|||
}
|
||||
|
||||
/**
|
||||
* Perform any final actions before the pcdata is returned to client
|
||||
* code.
|
||||
* Perform any final actions before the pcdata is returned to client code.
|
||||
*/
|
||||
protected void finish(DynamicPCData data, ClassMetaData meta) {
|
||||
}
|
||||
|
@ -196,7 +195,7 @@ public class PCDataGenerator
|
|||
|
||||
/**
|
||||
* Have to load the type since it may not be available to the
|
||||
* same classloader (i.e. rar vs. ear). The context classloader
|
||||
* same classloader (i.e. rar vs. ear). The context classloader
|
||||
* (i.e. the user app classloader) should be fine.
|
||||
*/
|
||||
private void addGetType(BCClass bc, ClassMetaData meta) {
|
||||
|
@ -371,7 +370,7 @@ public class PCDataGenerator
|
|||
lswitch.setDefaultTarget(target);
|
||||
|
||||
// if (obj != null)
|
||||
code.next(); // jump back over target
|
||||
code.next(); // jump back over target
|
||||
ifins = code.ifnonnull();
|
||||
code.vreturn();
|
||||
|
||||
|
@ -417,7 +416,7 @@ public class PCDataGenerator
|
|||
code.go2().setTarget(switchTarget);
|
||||
}
|
||||
lswitch.setDefaultTarget(switchTarget);
|
||||
code.next(); // step over switch target
|
||||
code.next(); // step over switch target
|
||||
|
||||
// if (arrIdx != -1)
|
||||
code.constant().setValue(-1);
|
||||
|
@ -465,7 +464,7 @@ public class PCDataGenerator
|
|||
|
||||
// if (fieldImpl != null)
|
||||
// fieldImpl[index] = null;
|
||||
code.next(); // step over nullTarget
|
||||
code.next(); // step over nullTarget
|
||||
code.getfield().setField(impl);
|
||||
ifins = code.ifnonnull();
|
||||
code.vreturn();
|
||||
|
@ -753,7 +752,7 @@ public class PCDataGenerator
|
|||
boolean.class, new Class[]{ int.class });
|
||||
jumps2.add(code.ifne());
|
||||
// sm.setIntermediate (index, inter);
|
||||
// } // end else
|
||||
// } // end else
|
||||
code.aload().setParam(0);
|
||||
code.constant().setValue(index);
|
||||
code.aload().setLocal(inter);
|
||||
|
@ -1067,8 +1066,8 @@ public class PCDataGenerator
|
|||
}
|
||||
|
||||
/**
|
||||
* Dynamic {@link PCData}s generated will implement this interface
|
||||
* to simplify initialization.
|
||||
* Dynamic {@link PCData}s generated will implement this interface
|
||||
* to simplify initialization.
|
||||
*/
|
||||
public static interface DynamicPCData extends PCData {
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -79,9 +79,9 @@ import serp.bytecode.TableSwitchInstruction;
|
|||
import serp.util.Numbers;
|
||||
|
||||
/**
|
||||
* <p>Bytecode enhancer used to enhance persistent classes from metadata. The
|
||||
* Bytecode enhancer used to enhance persistent classes from metadata. The
|
||||
* enhancer must be invoked on all persistence-capable and persistence aware
|
||||
* classes.</p>
|
||||
* classes.
|
||||
*
|
||||
* @author Abe White
|
||||
*/
|
||||
|
@ -123,14 +123,14 @@ public class PCEnhancer {
|
|||
private Set _violations = null;
|
||||
|
||||
/**
|
||||
* Constructor. Supply configuration and type to enhance.
|
||||
* Constructor. Supply configuration and type to enhance.
|
||||
*/
|
||||
public PCEnhancer(OpenJPAConfiguration conf, Class type) {
|
||||
this(conf, new Project().loadClass(type), null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor. Supply configuration and type to enhance.
|
||||
* Constructor. Supply configuration and type to enhance.
|
||||
*/
|
||||
public PCEnhancer(OpenJPAConfiguration conf, ClassMetaData type) {
|
||||
this(conf, new Project().loadClass(type.getDescribedType()),
|
||||
|
@ -138,11 +138,11 @@ public class PCEnhancer {
|
|||
}
|
||||
|
||||
/**
|
||||
* Constructor. Supply configuration.
|
||||
* Constructor. Supply configuration.
|
||||
*
|
||||
* @param type the bytecode representation fo the type to
|
||||
* @param type the bytecode representation fo the type to
|
||||
* enhance; this can be created from any stream or file
|
||||
* @param repos a metadata repository to use for metadata access,
|
||||
* @param repos a metadata repository to use for metadata access,
|
||||
* or null to create a new reporitory; the repository
|
||||
* from the given configuration isn't used by default
|
||||
* because the configuration might be an
|
||||
|
@ -187,7 +187,7 @@ public class PCEnhancer {
|
|||
|
||||
/**
|
||||
* A boolean indicating whether the enhancer should add a no-args
|
||||
* constructor if one is not already present in the class. OpenJPA
|
||||
* constructor if one is not already present in the class. OpenJPA
|
||||
* requires that a no-arg constructor (whether created by the compiler
|
||||
* or by the user) be present in a PC.
|
||||
*/
|
||||
|
@ -197,7 +197,7 @@ public class PCEnhancer {
|
|||
|
||||
/**
|
||||
* A boolean indicating whether the enhancer should add a no-args
|
||||
* constructor if one is not already present in the class. OpenJPA
|
||||
* constructor if one is not already present in the class. OpenJPA
|
||||
* requires that a no-arg constructor (whether created by the compiler
|
||||
* or by the user) be present in a PC.
|
||||
*/
|
||||
|
@ -224,8 +224,8 @@ public class PCEnhancer {
|
|||
}
|
||||
|
||||
/**
|
||||
* The base build directory to generate code to. The proper package
|
||||
* structure will be created beneath this directory. Defaults to
|
||||
* The base build directory to generate code to. The proper package
|
||||
* structure will be created beneath this directory. Defaults to
|
||||
* overwriting the existing class file if null.
|
||||
*/
|
||||
public File getDirectory() {
|
||||
|
@ -233,8 +233,8 @@ public class PCEnhancer {
|
|||
}
|
||||
|
||||
/**
|
||||
* The base build directory to generate code to. The proper package
|
||||
* structure will be creaed beneath this directory. Defaults to
|
||||
* The base build directory to generate code to. The proper package
|
||||
* structure will be creaed beneath this directory. Defaults to
|
||||
* overwriting the existing class file if null.
|
||||
*/
|
||||
public void setDirectory(File dir) {
|
||||
|
@ -242,16 +242,14 @@ public class PCEnhancer {
|
|||
}
|
||||
|
||||
/**
|
||||
* Return the current {@link BytecodeWriter} to write to
|
||||
* or null if none.
|
||||
* Return the current {@link BytecodeWriter} to write to or null if none.
|
||||
*/
|
||||
public BytecodeWriter getBytecodeWriter() {
|
||||
return _writer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the {@link BytecodeWriter} to write the bytecode
|
||||
* to or null if none.
|
||||
* Set the {@link BytecodeWriter} to write the bytecode to or null if none.
|
||||
*/
|
||||
public void setBytecodeWriter(BytecodeWriter writer) {
|
||||
_writer = writer;
|
||||
|
@ -260,7 +258,7 @@ public class PCEnhancer {
|
|||
/**
|
||||
* Perform bytecode enhancements.
|
||||
*
|
||||
* @return <code>ENHANCE_*</code> constant
|
||||
* @return <code>ENHANCE_*</code> constant
|
||||
*/
|
||||
public int run() {
|
||||
if (_log.isTraceEnabled())
|
||||
|
@ -343,7 +341,7 @@ public class PCEnhancer {
|
|||
|
||||
/**
|
||||
* Validate that the methods in this property-access instance are
|
||||
* written correctly. This method also gathers information on each
|
||||
* written correctly. This method also gathers information on each
|
||||
* property's backing field.
|
||||
*/
|
||||
private void validateProperties() {
|
||||
|
@ -435,7 +433,7 @@ public class PCEnhancer {
|
|||
}
|
||||
|
||||
/**
|
||||
* Return the field returned / assigned by <code>meth</code>. Returns
|
||||
* Return the field returned / assigned by <code>meth</code>. Returns
|
||||
* null if non-fields (methods, literals, parameters, variables) are
|
||||
* returned, or if non-parameters are assigned to fields.
|
||||
*/
|
||||
|
@ -527,7 +525,7 @@ public class PCEnhancer {
|
|||
|
||||
/**
|
||||
* Replaced all direct access to managed fields with the appropriate
|
||||
* pcGet/pcSet method. Note that this includes access to fields
|
||||
* pcGet/pcSet method. Note that this includes access to fields
|
||||
* owned by PersistenceCapable classes other than this one.
|
||||
*/
|
||||
private void replaceAndValidateFieldAccess() {
|
||||
|
@ -558,14 +556,13 @@ public class PCEnhancer {
|
|||
* Replaces all instructions matching the given template in the given
|
||||
* code block with calls to the appropriate generated getter/setter.
|
||||
*
|
||||
* @param code the code block to modify; the code iterator will
|
||||
* @param code the code block to modify; the code iterator will
|
||||
* be placed before the first instruction on method start,
|
||||
* and will be after the last instruction on method
|
||||
* completion
|
||||
* @param ins the template instruction to search for; either a
|
||||
* and will be after the last instruction on method completion
|
||||
* @param ins the template instruction to search for; either a
|
||||
* getfield or putfield instruction
|
||||
* @param get boolean indicating if this is a get instruction
|
||||
* @param stat template invokestatic instruction to replace with
|
||||
* @param get boolean indicating if this is a get instruction
|
||||
* @param stat template invokestatic instruction to replace with
|
||||
*/
|
||||
private void replaceAndValidateFieldAccess(Code code, Instruction ins,
|
||||
boolean get, Instruction stat) {
|
||||
|
@ -645,11 +642,10 @@ public class PCEnhancer {
|
|||
* Helper method to return the declaring PersistenceCapable class of
|
||||
* the given field.
|
||||
*
|
||||
* @param fieldName the name of the field
|
||||
* @param owner the nominal owner of the field
|
||||
* @param fieldName the name of the field
|
||||
* @param owner the nominal owner of the field
|
||||
* @return the metadata for the PersistenceCapable type that
|
||||
* declares the field (and therefore has the static
|
||||
* method), or null if none
|
||||
* declares the field (and therefore has the static method), or null if none
|
||||
*/
|
||||
private ClassMetaData getPersistenceCapableOwner(String fieldName,
|
||||
Class owner) {
|
||||
|
@ -672,7 +668,7 @@ public class PCEnhancer {
|
|||
|
||||
/**
|
||||
* Adds all synthetic methods to the bytecode by delegating to
|
||||
* the various addXXXMethods () functions in this class. Includes
|
||||
* the various addXXXMethods () functions in this class. Includes
|
||||
* all static field access methods.
|
||||
* Note that the 'stock' methods like <code>pcIsTransactional</code>,
|
||||
* <code>pcFetchObjectId</code>, etc are defined only in the
|
||||
|
@ -775,7 +771,7 @@ public class PCEnhancer {
|
|||
* These methods are used by the impl helper to create new
|
||||
* managed instances efficiently without reflection.
|
||||
*
|
||||
* @param oid set to true to mimic the method version that takes
|
||||
* @param oid set to true to mimic the method version that takes
|
||||
* an oid value as well as a state manager
|
||||
*/
|
||||
private void addNewInstanceMethod(boolean oid) {
|
||||
|
@ -867,8 +863,7 @@ public class PCEnhancer {
|
|||
|
||||
/**
|
||||
* Adds the {@link PersistenceCapable#pcProvideField} and
|
||||
* {@link PersistenceCapable#pcProvideFields} methods to
|
||||
* the bytecode.
|
||||
* {@link PersistenceCapable#pcProvideFields} methods to the bytecode.
|
||||
*/
|
||||
private void addProvideFieldsMethods()
|
||||
throws NoSuchMethodException {
|
||||
|
@ -918,8 +913,7 @@ public class PCEnhancer {
|
|||
|
||||
/**
|
||||
* Adds the {@link PersistenceCapable#pcReplaceField} and
|
||||
* {@link PersistenceCapable#pcReplaceFields} methods to
|
||||
* the bytecode.
|
||||
* {@link PersistenceCapable#pcReplaceFields} methods to the bytecode.
|
||||
*/
|
||||
private void addReplaceFieldsMethods()
|
||||
throws NoSuchMethodException {
|
||||
|
@ -973,8 +967,7 @@ public class PCEnhancer {
|
|||
}
|
||||
|
||||
/**
|
||||
* Adds the {@link PersistenceCapable#pcCopyFields} method to the
|
||||
* bytecode.
|
||||
* Adds the {@link PersistenceCapable#pcCopyFields} method to the bytecode.
|
||||
*/
|
||||
private void addCopyFieldsMethod()
|
||||
throws NoSuchMethodException {
|
||||
|
@ -1024,7 +1017,7 @@ public class PCEnhancer {
|
|||
|
||||
/**
|
||||
* Helper method to add the code common to the beginning of both the
|
||||
* pcReplaceField method and the pcProvideField method. This includes
|
||||
* pcReplaceField method and the pcProvideField method. This includes
|
||||
* calculating the relative field number of the desired field and calling
|
||||
* the superclass if necessary.
|
||||
*
|
||||
|
@ -1070,7 +1063,7 @@ public class PCEnhancer {
|
|||
* This helper method, given the pcReplaceField or pcProvideField
|
||||
* method, adds the bytecode for the corresponding 'plural' version
|
||||
* of the method -- the version that takes an int[] of fields to
|
||||
* to access rather than a single field. The multiple fields version
|
||||
* to access rather than a single field. The multiple fields version
|
||||
* simply loops through the provided indexes and delegates to the
|
||||
* singular version for each one.
|
||||
*/
|
||||
|
@ -1198,7 +1191,7 @@ public class PCEnhancer {
|
|||
}
|
||||
|
||||
/**
|
||||
* Helper method to add a stock method to the bytecode. Each
|
||||
* Helper method to add a stock method to the bytecode. Each
|
||||
* stock method simply delegates to a corresponding StateManager method.
|
||||
* Given the StateManager method, then, this function translates it into
|
||||
* the wrapper method that should be added to the bytecode.
|
||||
|
@ -1236,8 +1229,7 @@ public class PCEnhancer {
|
|||
}
|
||||
|
||||
/**
|
||||
* Adds the {@link PersistenceCapable#pcGetVersion}
|
||||
* method to the bytecode.
|
||||
* Adds the {@link PersistenceCapable#pcGetVersion} method to the bytecode.
|
||||
*/
|
||||
private void addGetVersionMethod()
|
||||
throws NoSuchMethodException {
|
||||
|
@ -1668,7 +1660,7 @@ public class PCEnhancer {
|
|||
|
||||
/**
|
||||
* If the given field is a wrapper-type single field identity primary key,
|
||||
* return its corresponding primitive class. Else return the field type.
|
||||
* return its corresponding primitive class. Else return the field type.
|
||||
*/
|
||||
private Class unwrapSingleFieldIdentity(FieldMetaData fmd) {
|
||||
if (!fmd.getDefiningMetaData().isOpenJPAIdentity())
|
||||
|
@ -1781,18 +1773,17 @@ public class PCEnhancer {
|
|||
|
||||
/**
|
||||
* When communicating with the StateManager, many methods are used
|
||||
* depending on the class of state being passed. This method,
|
||||
* depending on the class of state being passed. This method,
|
||||
* given the type of information being passed and the prefix
|
||||
* ('provided', 'replace', etc) of the method to
|
||||
* call, returns the StateManager method that should be used.
|
||||
*
|
||||
* @param type the type of state being passed
|
||||
* @param prefix the prefix of the method to call; all methods
|
||||
* end in '[state type]Field'; only the prefix
|
||||
* varies
|
||||
* @param get true if receiving information from the
|
||||
* @param type the type of state being passed
|
||||
* @param prefix the prefix of the method to call; all methods
|
||||
* end in '[state type]Field'; only the prefix varies
|
||||
* @param get true if receiving information from the
|
||||
* StateManager, false if passing it to the SM
|
||||
* @param curValue true if the current state value is passed to
|
||||
* @param curValue true if the current state value is passed to
|
||||
* the StateManager as an extra argument
|
||||
*/
|
||||
private Method getStateManagerMethod(Class type, String prefix,
|
||||
|
@ -1802,17 +1793,15 @@ public class PCEnhancer {
|
|||
}
|
||||
|
||||
/**
|
||||
* Return the method of the given owner type matching the given
|
||||
* criteria.
|
||||
* Return the method of the given owner type matching the given criteria.
|
||||
*
|
||||
* @param type the type of state being passed
|
||||
* @param prefix the prefix of the method to call; all methods
|
||||
* end in '[state type]Field'; only the prefix
|
||||
* varies
|
||||
* @param get true if receiving information from the
|
||||
* @param type the type of state being passed
|
||||
* @param prefix the prefix of the method to call; all methods
|
||||
* end in '[state type]Field'; only the prefix varies
|
||||
* @param get true if receiving information from the
|
||||
* owner, false if passing it to the owner
|
||||
* @param haspc true if the pc is passed as an extra argument
|
||||
* @param curValue true if the current state value is passed to
|
||||
* @param haspc true if the pc is passed as an extra argument
|
||||
* @param curValue true if the current state value is passed to
|
||||
* the owner as an extra argument
|
||||
*/
|
||||
private Method getMethod(Class owner, Class type, String prefix,
|
||||
|
@ -2036,7 +2025,7 @@ public class PCEnhancer {
|
|||
|
||||
/**
|
||||
* Adds the code to properly handle PersistenceCapable serialization
|
||||
* to the bytecode. This includes creating and initializing the
|
||||
* to the bytecode. This includes creating and initializing the
|
||||
* static <code>serialVersionUID</code> constant if not already defined,
|
||||
* as well as creating a custom <code>writeObject</code> method if the
|
||||
* class is Serializable and does not define them.
|
||||
|
@ -2375,7 +2364,7 @@ public class PCEnhancer {
|
|||
|
||||
/**
|
||||
* Compare the given field to its Java default, returning the
|
||||
* comparison instruction. The field value will already be on the stack.
|
||||
* comparison instruction. The field value will already be on the stack.
|
||||
*/
|
||||
private static JumpInstruction ifDefaultValue(Code code,
|
||||
FieldMetaData fmd) {
|
||||
|
@ -2440,7 +2429,7 @@ public class PCEnhancer {
|
|||
* Adds bytecode modifying the cloning behavior of the class being
|
||||
* enhanced to correctly replace the <code>pcFlags</code> and
|
||||
* <code>pcStateManager</code> instance fields of any clone created with
|
||||
* their default values. Also, if this class is the base PC type
|
||||
* their default values. Also, if this class is the base PC type
|
||||
* and does not declared a clone method, one will be added.
|
||||
*/
|
||||
private void addCloningCode() {
|
||||
|
@ -2664,8 +2653,8 @@ public class PCEnhancer {
|
|||
* The generated method interacts with the instance state and the
|
||||
* StateManager to get the value of the field.
|
||||
*
|
||||
* @param index the relative number of the field
|
||||
* @param fmd metadata about the field to get
|
||||
* @param index the relative number of the field
|
||||
* @param fmd metadata about the field to get
|
||||
*/
|
||||
private void addGetMethod(int index, FieldMetaData fmd)
|
||||
throws NoSuchMethodException {
|
||||
|
@ -2733,8 +2722,8 @@ public class PCEnhancer {
|
|||
* The generated method interacts with the instance state and the
|
||||
* StateManager to set the value of the field.
|
||||
*
|
||||
* @param index the relative number of the field
|
||||
* @param fmd metadata about the field to set
|
||||
* @param index the relative number of the field
|
||||
* @param fmd metadata about the field to set
|
||||
*/
|
||||
private void addSetMethod(int index, FieldMetaData fmd)
|
||||
throws NoSuchMethodException {
|
||||
|
@ -3209,7 +3198,7 @@ public class PCEnhancer {
|
|||
throws NoSuchMethodException {
|
||||
if (_meta.getAccessType() == ClassMetaData.ACCESS_FIELD)
|
||||
code.getfield().setField(fmd.getName(), fmd.getDeclaredType());
|
||||
else // property
|
||||
else // property
|
||||
{
|
||||
Method meth = (Method) fmd.getBackingMember();
|
||||
code.invokevirtual().setMethod(PRE + meth.getName(),
|
||||
|
@ -3227,7 +3216,7 @@ public class PCEnhancer {
|
|||
throws NoSuchMethodException {
|
||||
if (_meta.getAccessType() == ClassMetaData.ACCESS_FIELD)
|
||||
code.putfield().setField(fmd.getName(), fmd.getDeclaredType());
|
||||
else // property
|
||||
else // property
|
||||
code.invokevirtual().setMethod(PRE + getSetterName(fmd),
|
||||
void.class, new Class[]{ fmd.getDeclaredType() });
|
||||
}
|
||||
|
@ -3338,47 +3327,44 @@ public class PCEnhancer {
|
|||
}
|
||||
|
||||
/**
|
||||
* <p>Usage: java org.apache.openjpa.enhance.PCEnhancer [option]*
|
||||
* <class name | .java file | .class file | .jdo file>+</p>
|
||||
* <p/>
|
||||
* <p>Where the following options are recognized.
|
||||
* Usage: java org.apache.openjpa.enhance.PCEnhancer [option]*
|
||||
* <class name | .java file | .class file | .jdo file>+
|
||||
* Where the following options are recognized.
|
||||
* <ul>
|
||||
* <li><i>-properties/-p <properties file></i>: The path to a OpenJPA
|
||||
* properties file containing information as outlined in
|
||||
* properties file containing information as outlined in
|
||||
* {@link Configuration}; optional.</li>
|
||||
* <li><i>-<property name> <property value></i>: All bean
|
||||
* properties of the standard OpenJPA {@link OpenJPAConfiguration} can be
|
||||
* set by using their names and supplying a value; for example:
|
||||
* <li><i>-directory/-d <build directory></i>: The path to the base
|
||||
* directory where enhanced classes are stored. By default, the
|
||||
* directory where enhanced classes are stored. By default, the
|
||||
* enhancer overwrites the original .class file with the enhanced
|
||||
* version. Use this option to store the generated .class file in
|
||||
* another directory. The package structure will be created beneath
|
||||
* version. Use this option to store the generated .class file in
|
||||
* another directory. The package structure will be created beneath
|
||||
* the given directory.</li>
|
||||
* <li><i>-addDefaultConstructor/-adc [true/t | false/f]</i>: Whether to
|
||||
* add a default constructor to persistent classes missing one, as
|
||||
* opposed to throwing an exception. Defaults to true.</li>
|
||||
* opposed to throwing an exception. Defaults to true.</li>
|
||||
* <li><i>-tmpClassLoader/-tcl [true/t | false/f]</i>: Whether to
|
||||
* load the pre-enhanced classes using a temporary class loader.
|
||||
* Defaults to true. Set this to false when attempting to debug
|
||||
* Defaults to true. Set this to false when attempting to debug
|
||||
* class loading errors.</li>
|
||||
* <li><i>-enforcePropertyRestrictions/-epr [true/t | false/f]</i>:
|
||||
* Whether to throw an exception if a PROPERTY access entity appears
|
||||
* to be violating standard property restrictions. Defaults to
|
||||
* false.</li>
|
||||
* </ul></p>
|
||||
* <p/>
|
||||
* <p>Each additional argument can be either the full class name of the
|
||||
* to be violating standard property restrictions. Defaults to false.</li>
|
||||
* </ul>
|
||||
* Each additional argument can be either the full class name of the
|
||||
* type to enhance, the path to the .java file for the type, the path to
|
||||
* the .class file for the type, or the path to a .jdo file listing one
|
||||
* or more types to enhance.
|
||||
* If the type being enhanced has metadata, it will be enhanced as a
|
||||
* persistence capable class. If not, it will be considered a persistence
|
||||
* persistence capable class. If not, it will be considered a persistence
|
||||
* aware class, and all access to fields of persistence capable classes
|
||||
* will be replaced by the appropriate get/set method. If the type
|
||||
* will be replaced by the appropriate get/set method. If the type
|
||||
* explicitly declares the persistence-capable interface, it will
|
||||
* not be enhanced. Thus, it is safe to invoke the enhancer on classes
|
||||
* that are already enhanced.</p>
|
||||
* not be enhanced. Thus, it is safe to invoke the enhancer on classes
|
||||
* that are already enhanced.
|
||||
*/
|
||||
public static void main(String[] args)
|
||||
throws IOException {
|
||||
|
@ -3395,7 +3381,7 @@ public class PCEnhancer {
|
|||
}
|
||||
|
||||
/**
|
||||
* Run the tool. Returns false if invalid options given.
|
||||
* Run the tool. Returns false if invalid options given.
|
||||
*/
|
||||
public static boolean run(OpenJPAConfiguration conf, String[] args,
|
||||
Options opts)
|
||||
|
@ -3493,7 +3479,7 @@ public class PCEnhancer {
|
|||
}
|
||||
|
||||
/**
|
||||
* Run flags.
|
||||
* Run flags.
|
||||
*/
|
||||
public static class Flags {
|
||||
|
||||
|
@ -3503,9 +3489,8 @@ public class PCEnhancer {
|
|||
public boolean enforcePropertyRestrictions = false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Plugin interface for additional enhancement.
|
||||
* Plugin interface for additional enhancement.
|
||||
*/
|
||||
public static interface AuxiliaryEnhancer
|
||||
{
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -23,7 +23,7 @@ import java.util.Map;
|
|||
import java.util.WeakHashMap;
|
||||
|
||||
/**
|
||||
* <p>Tracks registered persistence-capable classes.</p>
|
||||
* Tracks registered persistence-capable classes.
|
||||
*
|
||||
* @since 4.0
|
||||
* @author Abe White
|
||||
|
@ -171,10 +171,10 @@ public class PCRegistry {
|
|||
* @param fieldTypes managed field types
|
||||
* @param fieldFlags managed field flags
|
||||
* @param sup the most immediate persistent superclass
|
||||
* @param pcClass the <code>PersistenceCapable</code> class
|
||||
* @param fieldNames managed field names
|
||||
* @param alias the class alias
|
||||
* @param pc an instance of the class, if not abstract
|
||||
* @param pcClass the <code>PersistenceCapable</code> class
|
||||
* @param fieldNames managed field names
|
||||
* @param alias the class alias
|
||||
* @param pc an instance of the class, if not abstract
|
||||
*/
|
||||
public static void register(Class pcClass, String[] fieldNames,
|
||||
Class[] fieldTypes, byte[] fieldFlags, Class sup, String alias,
|
||||
|
@ -234,8 +234,7 @@ public class PCRegistry {
|
|||
}
|
||||
|
||||
/**
|
||||
* This is a helper class to manage metadata per persistence-capable
|
||||
* class.
|
||||
* This is a helper class to manage metadata per persistence-capable class.
|
||||
*/
|
||||
private static class Meta {
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -19,7 +19,7 @@ import java.io.IOException;
|
|||
import java.io.ObjectOutput;
|
||||
|
||||
/**
|
||||
* <p>Internal state manager for managed instances.</p>
|
||||
* Internal state manager for managed instances.
|
||||
*/
|
||||
public interface StateManager {
|
||||
// DO NOT ADD ADDITIONAL DEPENDENCIES TO THIS CLASS
|
||||
|
@ -270,13 +270,12 @@ public interface StateManager {
|
|||
public double replaceDoubleField(PersistenceCapable pc, int idx);
|
||||
|
||||
/**
|
||||
* Replace state callback.
|
||||
* Replace state callback.
|
||||
*/
|
||||
public String replaceStringField(PersistenceCapable pc, int idx);
|
||||
|
||||
|
||||
/**
|
||||
* Replace state callback.
|
||||
* Replace state callback.
|
||||
*/
|
||||
public Object replaceObjectField (PersistenceCapable pc, int idx);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -16,8 +16,8 @@
|
|||
package org.apache.openjpa.event;
|
||||
|
||||
/**
|
||||
* <p>Abstract implementation of the {@link LifecycleListener} interface
|
||||
* which delegates events to a single method.</p>
|
||||
* Abstract implementation of the {@link LifecycleListener} interface
|
||||
* which delegates events to a single method.
|
||||
*
|
||||
* @author Steve Kim
|
||||
* @author Abe White
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -24,7 +24,7 @@ import org.apache.openjpa.lib.log.Log;
|
|||
import org.apache.openjpa.lib.util.Localizer;
|
||||
|
||||
/**
|
||||
* Abstract implementation of {@link RemoteCommitProvider}. Obtains handles
|
||||
* Abstract implementation of {@link RemoteCommitProvider}. Obtains handles
|
||||
* to the event manager and log.
|
||||
*
|
||||
* @author Patrick Linskey
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -16,8 +16,8 @@
|
|||
package org.apache.openjpa.event;
|
||||
|
||||
/**
|
||||
* <p>Abstract implementation of the {@link TransactionListener} interface
|
||||
* that provides no-op implementations of all methods.</p>
|
||||
* Abstract implementation of the {@link TransactionListener} interface
|
||||
* that provides no-op implementations of all methods.
|
||||
*
|
||||
* @author Abe White
|
||||
* @since 3.0
|
||||
|
@ -26,8 +26,8 @@ public abstract class AbstractTransactionListener
|
|||
implements TransactionListener {
|
||||
|
||||
/**
|
||||
* Catch-all for unhandled events. This method is called by all other
|
||||
* event methods if you do not override them. Does nothing by default.
|
||||
* Catch-all for unhandled events. This method is called by all other
|
||||
* event methods if you do not override them. Does nothing by default.
|
||||
*/
|
||||
protected void eventOccurred(TransactionEvent event) {
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -16,7 +16,7 @@
|
|||
package org.apache.openjpa.event;
|
||||
|
||||
/**
|
||||
* <p>Listener for when a detached instance is attached.</p>
|
||||
* Listener for when a detached instance is attached.
|
||||
*
|
||||
* @author Steve Kim
|
||||
*/
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -34,7 +34,7 @@ public class BeanLifecycleCallbacks
|
|||
private Object _listener;
|
||||
|
||||
/**
|
||||
* Constructor. Make the callback on an instance of the given type.
|
||||
* Constructor. Make the callback on an instance of the given type.
|
||||
*
|
||||
* @arg whether another argunent is expected such as AfterDetach
|
||||
*/
|
||||
|
@ -44,7 +44,7 @@ public class BeanLifecycleCallbacks
|
|||
}
|
||||
|
||||
/**
|
||||
* Constructor. Make the callback on an instance of the given type.
|
||||
* Constructor. Make the callback on an instance of the given type.
|
||||
*/
|
||||
public BeanLifecycleCallbacks(Class cls, Method method, boolean arg) {
|
||||
super(method, arg);
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -16,7 +16,7 @@
|
|||
package org.apache.openjpa.event;
|
||||
|
||||
/**
|
||||
* <p>Notified when transactions begin.</p>
|
||||
* Notified when transactions begin.
|
||||
*
|
||||
* @author Patrick Linskey
|
||||
* @author Abe White
|
||||
|
@ -27,7 +27,7 @@ public interface BeginTransactionListener {
|
|||
/**
|
||||
* Notification that a transaction has begun.
|
||||
*
|
||||
* @see TransactionEvent#AFTER_BEGIN
|
||||
* @see TransactionEvent#AFTER_BEGIN
|
||||
*/
|
||||
public void afterBegin(TransactionEvent event);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -16,7 +16,7 @@
|
|||
package org.apache.openjpa.event;
|
||||
|
||||
/**
|
||||
* <p>Callback handling constants.</p>
|
||||
* Callback handling constants.
|
||||
*
|
||||
* @author Steve Kim
|
||||
* @since 4.0
|
||||
|
@ -44,7 +44,7 @@ public interface CallbackModes {
|
|||
public static final int CALLBACK_RETHROW = 2 << 3;
|
||||
|
||||
/**
|
||||
* Flag to always rollback on a callback exception.
|
||||
* Flag to always rollback on a callback exception.
|
||||
*/
|
||||
public static final int CALLBACK_ROLLBACK = 2 << 4;
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -16,7 +16,7 @@
|
|||
package org.apache.openjpa.event;
|
||||
|
||||
/**
|
||||
* <p>Listener for when persistent state is cleared from an instance.</p>
|
||||
* Listener for when persistent state is cleared from an instance.
|
||||
*
|
||||
* @author Steve Kim
|
||||
* @author Abe White
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -16,7 +16,7 @@
|
|||
package org.apache.openjpa.event;
|
||||
|
||||
/**
|
||||
* <p>Listener for when a persistent instance is deleted.</p>
|
||||
* Listener for when a persistent instance is deleted.
|
||||
*
|
||||
* @author Steve Kim
|
||||
* @author Abe White
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -16,7 +16,7 @@
|
|||
package org.apache.openjpa.event;
|
||||
|
||||
/**
|
||||
* <p>Listener for when a persistent instance is detached.</p>
|
||||
* Listener for when a persistent instance is detached.
|
||||
*
|
||||
* @author Steve Kim
|
||||
*/
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -16,7 +16,7 @@
|
|||
package org.apache.openjpa.event;
|
||||
|
||||
/**
|
||||
* <p>Listener for when a persistent instance becomes dirty.</p>
|
||||
* Listener for when a persistent instance becomes dirty.
|
||||
*
|
||||
* @author Steve Kim
|
||||
* @author Abe White
|
||||
|
@ -39,7 +39,7 @@ public interface DirtyListener {
|
|||
public void beforeDirtyFlushed(LifecycleEvent event);
|
||||
|
||||
/**
|
||||
* Invoked after the first change is applied to a flushed instance.
|
||||
* Invoked after the first change is applied to a flushed instance.
|
||||
*/
|
||||
public void afterDirtyFlushed(LifecycleEvent event);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -16,7 +16,7 @@
|
|||
package org.apache.openjpa.event;
|
||||
|
||||
/**
|
||||
* <p>Notified when transactions end.</p>
|
||||
* Notified when transactions end.
|
||||
*
|
||||
* @author Patrick Linskey
|
||||
* @author Abe White
|
||||
|
@ -27,28 +27,28 @@ public interface EndTransactionListener {
|
|||
/**
|
||||
* Notification that the next flush is for the transaction commit.
|
||||
*
|
||||
* @see TransactionEvent#BEFORE_COMMIT
|
||||
* @see TransactionEvent#BEFORE_COMMIT
|
||||
*/
|
||||
public void beforeCommit(TransactionEvent event);
|
||||
|
||||
/**
|
||||
* Notification that a transaction has successfully committed.
|
||||
*
|
||||
* @see TransactionEvent#AFTER_COMMIT
|
||||
* @see TransactionEvent#AFTER_COMMIT
|
||||
*/
|
||||
public void afterCommit(TransactionEvent event);
|
||||
|
||||
/**
|
||||
* Notification that a transaction has been rolled back.
|
||||
*
|
||||
* @see TransactionEvent#AFTER_ROLLBACK
|
||||
* @see TransactionEvent#AFTER_ROLLBACK
|
||||
*/
|
||||
public void afterRollback(TransactionEvent event);
|
||||
|
||||
/**
|
||||
* Notification that state transitions are complete.
|
||||
*
|
||||
* @see TransactionEvent#AFTER_STATE_TRANSITIONS
|
||||
* @see TransactionEvent#AFTER_STATE_TRANSITIONS
|
||||
*/
|
||||
public void afterStateTransitions(TransactionEvent event);
|
||||
|
||||
|
@ -56,15 +56,15 @@ public interface EndTransactionListener {
|
|||
* Notification that a transaction has successfully committed and
|
||||
* the transaction is no longer active.
|
||||
*
|
||||
* @see TransactionEvent#AFTER_COMMIT_COMPLETE
|
||||
* @see TransactionEvent#AFTER_COMMIT_COMPLETE
|
||||
*/
|
||||
public void afterCommitComplete(TransactionEvent event);
|
||||
|
||||
/**
|
||||
* Notification that a transaction has been rolled back and
|
||||
* the transaction is no longer active.
|
||||
* Notification that a transaction has been rolled back and
|
||||
* the transaction is no longer active.
|
||||
*
|
||||
* @see TransactionEvent#AFTER_ROLLBACK_COMPLETE
|
||||
* @see TransactionEvent#AFTER_ROLLBACK_COMPLETE
|
||||
*/
|
||||
public void afterRollbackComplete(TransactionEvent event);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -21,8 +21,7 @@ import org.apache.openjpa.meta.ValueMetaData;
|
|||
import org.apache.openjpa.util.ObjectNotFoundException;
|
||||
|
||||
/**
|
||||
* <p>Throw a {@link ObjectNotFoundException} when an orphaned key
|
||||
* is discovered.</p>
|
||||
* Throw a {@link ObjectNotFoundException} when an orphaned key is discovered.
|
||||
*
|
||||
* @author Abe White
|
||||
* @since 3.2.2
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -16,7 +16,7 @@
|
|||
package org.apache.openjpa.event;
|
||||
|
||||
/**
|
||||
* <p>Notified on transaction flush.</p>
|
||||
* Notified on transaction flush.
|
||||
*
|
||||
* @author Patrick Linskey
|
||||
* @author Abe White
|
||||
|
@ -27,14 +27,14 @@ public interface FlushTransactionListener {
|
|||
/**
|
||||
* Notification that a transaction is about to flush all object changes.
|
||||
*
|
||||
* @see TransactionEvent#BEFORE_FLUSH
|
||||
* @see TransactionEvent#BEFORE_FLUSH
|
||||
*/
|
||||
public void beforeFlush(TransactionEvent event);
|
||||
|
||||
/**
|
||||
* Notification that a transaction has flushed all object changes.
|
||||
*
|
||||
* @see TransactionEvent#AFTER_FLUSH
|
||||
* @see TransactionEvent#AFTER_FLUSH
|
||||
*/
|
||||
public void afterFlush(TransactionEvent event);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -80,7 +80,7 @@ public class JMSRemoteCommitProvider
|
|||
|
||||
/**
|
||||
* The number of times to attempt to reconnect after a JMS send exception
|
||||
* is detected. Defaults to 0, meaning no attempt to reconnect is made;
|
||||
* is detected. Defaults to 0, meaning no attempt to reconnect is made;
|
||||
* the exception is logged and ignored.
|
||||
*/
|
||||
public void setExceptionReconnectAttempts(int attempts) {
|
||||
|
@ -89,7 +89,7 @@ public class JMSRemoteCommitProvider
|
|||
|
||||
/**
|
||||
* Set a map of properties to pass to the {@link InitialContext}
|
||||
* constructor for JNDI lookups. Implementation of
|
||||
* constructor for JNDI lookups. Implementation of
|
||||
* {@link GenericConfigurable}.
|
||||
*/
|
||||
public void setInto(Map m) {
|
||||
|
@ -102,8 +102,7 @@ public class JMSRemoteCommitProvider
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns a new {@link Context} object for use by this
|
||||
* provider.
|
||||
* Returns a new {@link Context} object for use by this provider.
|
||||
*/
|
||||
protected Context newContext()
|
||||
throws NamingException {
|
||||
|
@ -174,29 +173,27 @@ public class JMSRemoteCommitProvider
|
|||
// create a subscriber.
|
||||
TopicSubscriber s = _session.createSubscriber(topic, null,
|
||||
/* noLocal: */ true);
|
||||
MessageListener l = getMessageListener();
|
||||
s.setMessageListener(l);
|
||||
_connection.start();
|
||||
_connection.setExceptionListener(this);
|
||||
if (log.isInfoEnabled())
|
||||
log.info(s_loc.get("jms-start-listener", _topicName));
|
||||
}
|
||||
catch (OpenJPAException ke) {
|
||||
throw ke;
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new UserException(s_loc.get("jms-provider-config",
|
||||
_topicName, _tcfName), e).setFatal(true);
|
||||
}
|
||||
}
|
||||
MessageListener l = getMessageListener();
|
||||
s.setMessageListener(l);
|
||||
_connection.start();
|
||||
_connection.setExceptionListener(this);
|
||||
if (log.isInfoEnabled())
|
||||
log.info(s_loc.get("jms-start-listener", _topicName));
|
||||
}
|
||||
catch (OpenJPAException ke) {
|
||||
throw ke;
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new UserException(s_loc.get("jms-provider-config",
|
||||
_topicName, _tcfName), e).setFatal(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Returns a {@link javax.jms.MessageListener} capable of
|
||||
* understanding and processing messages created by
|
||||
* {@link #createMessage}.</p>
|
||||
* <p/>
|
||||
* <p>The listener returned by this method is responsible for
|
||||
* notifying the provider that a remote event has been received.</p>
|
||||
/* *
|
||||
* Returns a {@link javax.jms.MessageListener} capable of
|
||||
* understanding and processing messages created by {@link #createMessage}.
|
||||
* The listener returned by this method is responsible for
|
||||
* notifying the provider that a remote event has been received.
|
||||
*/
|
||||
protected MessageListener getMessageListener() {
|
||||
return new MessageListener() {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -18,8 +18,8 @@ package org.apache.openjpa.event;
|
|||
import java.util.EventObject;
|
||||
|
||||
/**
|
||||
* <p>Lifecycle event on a persistent instance. The event source
|
||||
* is the persistent instance whose state has changed.</p>
|
||||
* Lifecycle event on a persistent instance. The event source
|
||||
* is the persistent instance whose state has changed.
|
||||
*
|
||||
* @author Steve Kim
|
||||
* @author Abe White
|
||||
|
@ -148,8 +148,8 @@ public class LifecycleEvent
|
|||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param pc the persistent instance that triggered the event
|
||||
* @param type the event type
|
||||
* @param pc the persistent instance that triggered the event
|
||||
* @param type the event type
|
||||
*/
|
||||
public LifecycleEvent(Object pc, int type) {
|
||||
this(pc, null, type);
|
||||
|
@ -158,9 +158,9 @@ public class LifecycleEvent
|
|||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param pc the persistent instance that triggered the event
|
||||
* @param type the event type
|
||||
* @param related the related instance such as the detached copy.
|
||||
* @param pc the persistent instance that triggered the event
|
||||
* @param type the event type
|
||||
* @param related the related instance such as the detached copy.
|
||||
*/
|
||||
public LifecycleEvent(Object pc, Object related, int type) {
|
||||
super(pc);
|
||||
|
@ -176,7 +176,7 @@ public class LifecycleEvent
|
|||
}
|
||||
|
||||
/**
|
||||
* Return the related object.
|
||||
* Return the related object.
|
||||
*/
|
||||
public Object getRelated ()
|
||||
{
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -27,15 +27,13 @@ import org.apache.openjpa.meta.ClassMetaData;
|
|||
import org.apache.openjpa.meta.MetaDataDefaults;
|
||||
|
||||
/**
|
||||
* <p>Manager that can be used to track and notify listeners on lifecycle
|
||||
* events.</p>
|
||||
* <p/>
|
||||
* <p>This class is optimized for event firing rather than for adding and
|
||||
* removing listeners, which are O(n) operations. This class also does not
|
||||
* Manager that can be used to track and notify listeners on lifecycle events.
|
||||
* This class is optimized for event firing rather than for adding and
|
||||
* removing listeners, which are O(n) operations. This class also does not
|
||||
* maintain perfect set semantics for listeners; it is possible to wind up
|
||||
* having the same listener invoked multiple times for a single event if it
|
||||
* is added to this manager multiple times with different classes, or with
|
||||
* a base class and its subclass.</p>
|
||||
* a base class and its subclass.
|
||||
*
|
||||
* @author Steve Kim
|
||||
* @author Abe White
|
||||
|
@ -47,7 +45,7 @@ public class LifecycleEventManager
|
|||
|
||||
private static final Exception[] EMPTY_EXCEPTIONS = new Exception[0];
|
||||
|
||||
private Map _classListeners = null; // class -> listener list
|
||||
private Map _classListeners = null; // class -> listener list
|
||||
private ListenerList _listeners = null;
|
||||
private List _addListeners = new LinkedList();
|
||||
private List _remListeners = new LinkedList();
|
||||
|
@ -56,7 +54,7 @@ public class LifecycleEventManager
|
|||
private boolean _fail = false;
|
||||
|
||||
/**
|
||||
* Register a lifecycle listener for the given classes. If the classes
|
||||
* Register a lifecycle listener for the given classes. If the classes
|
||||
* array is null, register for all classes.
|
||||
*/
|
||||
public synchronized void addListener(Object listener, Class[] classes) {
|
||||
|
@ -329,7 +327,7 @@ public class LifecycleEventManager
|
|||
|
||||
/**
|
||||
* Fire an event with the given source and type to the given list of
|
||||
* listeners. The event may have already been constructed.
|
||||
* listeners. The event may have already been constructed.
|
||||
*/
|
||||
private Object fireEvent(LifecycleEvent ev, Object source, Object rel,
|
||||
int type, ListenerList listeners, boolean mock, boolean failFast,
|
||||
|
@ -497,8 +495,8 @@ public class LifecycleEventManager
|
|||
}
|
||||
|
||||
/**
|
||||
* Extended list that tracks what event types its elements care about.
|
||||
* Maintains set semantics as well.
|
||||
* Extended list that tracks what event types its elements care about.
|
||||
* Maintains set semantics as well.
|
||||
*/
|
||||
public static class ListenerList
|
||||
extends ArrayList {
|
||||
|
@ -538,7 +536,7 @@ public class LifecycleEventManager
|
|||
}
|
||||
|
||||
/**
|
||||
* Return a mask of the event types the given listener processes.
|
||||
* Return a mask of the event types the given listener processes.
|
||||
*/
|
||||
private static int getEventTypes(Object listener) {
|
||||
int types = 0;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -16,7 +16,7 @@
|
|||
package org.apache.openjpa.event;
|
||||
|
||||
/**
|
||||
* <p>Interface for listening to all {@link LifecycleEvent}s.</p>
|
||||
* Interface for listening to all {@link LifecycleEvent}s.
|
||||
*
|
||||
* @author Steve Kim
|
||||
* @author Abe White
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -16,7 +16,7 @@
|
|||
package org.apache.openjpa.event;
|
||||
|
||||
/**
|
||||
* <p>Listener for when state is loaded into a persistent instnace.</p>
|
||||
* Listener for when state is loaded into a persistent instnace.
|
||||
*
|
||||
* @author Steve Kim
|
||||
* @author Abe White
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -23,7 +23,7 @@ import org.apache.openjpa.lib.util.Localizer;
|
|||
import org.apache.openjpa.meta.ValueMetaData;
|
||||
|
||||
/**
|
||||
* <p>Log a message when an orphaned key is discovered.</p>
|
||||
* Log a message when an orphaned key is discovered.
|
||||
*
|
||||
* @author Abe White
|
||||
* @since 3.2.2
|
||||
|
@ -38,35 +38,35 @@ public class LogOrphanedKeyAction
|
|||
private short _level = Log.WARN;
|
||||
|
||||
/**
|
||||
* The channel to log to. Defaults to <code>org.apache.openjpa.Runtime</code>.
|
||||
* The channel to log to. Defaults to <code>org.apache.openjpa.Runtime</code>.
|
||||
*/
|
||||
public String getChannel() {
|
||||
return _channel;
|
||||
}
|
||||
|
||||
/**
|
||||
* The channel to log to. Defaults to <code>org.apache.openjpa.Runtime</code>.
|
||||
* The channel to log to. Defaults to <code>org.apache.openjpa.Runtime</code>.
|
||||
*/
|
||||
public void setChannel(String channel) {
|
||||
_channel = channel;
|
||||
}
|
||||
|
||||
/**
|
||||
* The level to log at. Defaults to <code>WARN</code>.
|
||||
* The level to log at. Defaults to <code>WARN</code>.
|
||||
*/
|
||||
public short getLevel() {
|
||||
return _level;
|
||||
}
|
||||
|
||||
/**
|
||||
* The level to log at. Defaults to <code>WARN</code>.
|
||||
* The level to log at. Defaults to <code>WARN</code>.
|
||||
*/
|
||||
public void setLevel(short level) {
|
||||
_level = level;
|
||||
}
|
||||
|
||||
/**
|
||||
* The level to log at. Defaults to <code>WARN</code>.
|
||||
* The level to log at. Defaults to <code>WARN</code>.
|
||||
*/
|
||||
public void setLevel(String level) {
|
||||
_level = LogFactoryImpl.getLevel(level);
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -35,7 +35,7 @@ public class MethodLifecycleCallbacks
|
|||
private boolean _arg;
|
||||
|
||||
/**
|
||||
* Constructor. Supply callback class and its callback method name.
|
||||
* Constructor. Supply callback class and its callback method name.
|
||||
*
|
||||
* @arg Whether we expect a further argument such as in AfterDetach
|
||||
*/
|
||||
|
@ -46,7 +46,7 @@ public class MethodLifecycleCallbacks
|
|||
}
|
||||
|
||||
/**
|
||||
* Constructor. Supply callback method.
|
||||
* Constructor. Supply callback method.
|
||||
*/
|
||||
public MethodLifecycleCallbacks(Method method, boolean arg) {
|
||||
_callback = method;
|
||||
|
@ -87,8 +87,8 @@ public class MethodLifecycleCallbacks
|
|||
}
|
||||
|
||||
/**
|
||||
* Helper method to return the named method of the given class, throwing
|
||||
* the proper exception on error.
|
||||
* Helper method to return the named method of the given class, throwing
|
||||
* the proper exception on error.
|
||||
*/
|
||||
protected static Method getMethod(Class cls, String method, Class[] args) {
|
||||
try {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -19,7 +19,7 @@ import org.apache.openjpa.kernel.OpenJPAStateManager;
|
|||
import org.apache.openjpa.meta.ValueMetaData;
|
||||
|
||||
/**
|
||||
* <p>Does nothing when an orphaned key is discovered.</p>
|
||||
* Does nothing when an orphaned key is discovered.
|
||||
*
|
||||
* @author Abe White
|
||||
* @since 3.2.2
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -19,7 +19,7 @@ import org.apache.openjpa.kernel.OpenJPAStateManager;
|
|||
import org.apache.openjpa.meta.ValueMetaData;
|
||||
|
||||
/**
|
||||
* <p>Perform an action when OpenJPA detects an orphaned key in the database.</p>
|
||||
* Perform an action when OpenJPA detects an orphaned key in the database.
|
||||
*
|
||||
* @author Abe White
|
||||
* @since 3.2.2
|
||||
|
@ -29,10 +29,10 @@ public interface OrphanedKeyAction {
|
|||
/**
|
||||
* Callback received when OpenJPA discovers an orphaned key.
|
||||
*
|
||||
* @param oid the orphaned key
|
||||
* @param sm the instance representing the record in which the
|
||||
* @param oid the orphaned key
|
||||
* @param sm the instance representing the record in which the
|
||||
* key was discovered; may be null
|
||||
* @param vmd the value in which the key was discovered
|
||||
* @param vmd the value in which the key was discovered
|
||||
* @return the value to load into field <code>fmd</code>; typically
|
||||
* <code>null</code>
|
||||
*/
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -26,9 +26,8 @@ import org.apache.openjpa.lib.util.Localizer;
|
|||
import org.apache.openjpa.util.UserException;
|
||||
|
||||
/**
|
||||
* <p>Event type to hold the IDs of additions, updates, and
|
||||
* deletes. This event type is also fully serializable for remote
|
||||
* communication.</p>
|
||||
* Event type to hold the IDs of additions, updates, and
|
||||
* deletes. This event type is also fully serializable for remote communication.
|
||||
*
|
||||
* @since 3.0
|
||||
* @author Patrick Linskey
|
||||
|
@ -68,15 +67,13 @@ public class RemoteCommitEvent
|
|||
}
|
||||
|
||||
/**
|
||||
* Constructor. All collections will be proxied with unmodifiable views.
|
||||
* Constructor. All collections will be proxied with unmodifiable views.
|
||||
*
|
||||
* @param payloadType PAYLOAD constant for type of data in this event
|
||||
* @param addIds set of object IDs for added instances, or null
|
||||
* @param addClasses set of class names for added instances
|
||||
* @param updates set of class names or object IDs for updated
|
||||
* instances
|
||||
* @param deletes set of class names or object IDs for deleted
|
||||
* instances
|
||||
* @param payloadType PAYLOAD constant for type of data in this event
|
||||
* @param addIds set of object IDs for added instances, or null
|
||||
* @param addClasses set of class names for added instances
|
||||
* @param updates set of class names or object IDs for updated instances
|
||||
* @param deletes set of class names or object IDs for deleted instances
|
||||
*/
|
||||
public RemoteCommitEvent(int payloadType, Collection addIds,
|
||||
Collection addClasses, Collection updates, Collection deletes) {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -30,10 +30,10 @@ import org.apache.openjpa.lib.util.concurrent.AbstractConcurrentEventManager;
|
|||
import org.apache.openjpa.util.UserException;
|
||||
|
||||
/**
|
||||
* <p>Manager that can be used to track and notify
|
||||
* Manager that can be used to track and notify
|
||||
* {@link RemoteCommitListener}s on remote commit events. If remote events
|
||||
* are enabled, this manager should be installed as a transaction listener on
|
||||
* all brokers so that it knows when commits are made.</p>
|
||||
* all brokers so that it knows when commits are made.
|
||||
*
|
||||
* @author Patrick Linskey
|
||||
* @author Abe White
|
||||
|
@ -50,7 +50,7 @@ public class RemoteCommitEventManager
|
|||
private boolean _transmitPersIds = false;
|
||||
|
||||
/**
|
||||
* Constructor. Supply configuration.
|
||||
* Constructor. Supply configuration.
|
||||
*/
|
||||
public RemoteCommitEventManager(OpenJPAConfiguration conf) {
|
||||
_provider = conf.newRemoteCommitProviderInstance();
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -18,33 +18,25 @@ package org.apache.openjpa.event;
|
|||
import org.apache.openjpa.lib.util.Closeable;
|
||||
|
||||
/**
|
||||
* <p>An entity that wishes to be notified when Brokers
|
||||
* associated with remote BrokerFactories commit.</p>
|
||||
* <p/>
|
||||
* <p>A RemoteCommitListener <b>is not</b> notified of commits that originated
|
||||
* An entity that wishes to be notified when Brokers
|
||||
* associated with remote BrokerFactories commit.
|
||||
* A RemoteCommitListener <b>is not</b> notified of commits that originated
|
||||
* with a Broker created from the BrokerFactory that it is
|
||||
* registered with. (Of course, if a listener is registered with multiple
|
||||
* factories, this situation might be complicated a bit.)</p>
|
||||
* <p/>
|
||||
* <p>Usage:
|
||||
* <code><pre>
|
||||
* import org.apache.openjpa.event.*;
|
||||
* import org.apache.openjpa.conf.*;
|
||||
* <p/>
|
||||
* {@link org.apache.openjpa.conf.OpenJPAConfiguration} conf = factory.getConfiguraiton ();
|
||||
* <p/>
|
||||
* RemoteCommitListener l = new RemoteCommitListener () {
|
||||
* public void afterCommit ({@link RemoteCommitEvent} e) {
|
||||
* // update a Swing widget when remote brokers make
|
||||
* // changes to reference data
|
||||
* }
|
||||
* <p/>
|
||||
* public void close () { }
|
||||
* };
|
||||
* <p/>
|
||||
* conf.getRemoteCommitEventManager ().addListener (l);
|
||||
* </pre></code>
|
||||
* </p>
|
||||
* factories, this situation might be complicated a bit.)
|
||||
* Usage:
|
||||
* <code><pre> import org.apache.openjpa.event.*;
|
||||
* import org.apache.openjpa.conf.*;
|
||||
*
|
||||
* {@link org.apache.openjpa.conf.OpenJPAConfiguration} conf = factory.getConfiguraiton ();
|
||||
* RemoteCommitListener l = new RemoteCommitListener () {
|
||||
* public void afterCommit ({@link RemoteCommitEvent} e) {
|
||||
* // update a Swing widget when remote brokers make
|
||||
* // changes to reference data }
|
||||
* public void close () { } };
|
||||
* conf.getRemoteCommitEventManager ().addListener (l);
|
||||
* </pre></code>
|
||||
*
|
||||
*
|
||||
* @author Patrick Linskey
|
||||
* @since 2.5.0
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -18,24 +18,20 @@ package org.apache.openjpa.event;
|
|||
import org.apache.openjpa.lib.util.Closeable;
|
||||
|
||||
/**
|
||||
* <p>An entity that is responsible for communicating commit
|
||||
* An entity that is responsible for communicating commit
|
||||
* notification to other {@link RemoteCommitEventManager}s. Each
|
||||
* event manager creates a remote commit provider, based on
|
||||
* the values of the <code>org.apache.openjpa.RemoteCommitProvider</code>
|
||||
* configuration property.</p>
|
||||
* <p/>
|
||||
* <p>An adapter that implements {@link TransactionListener} is
|
||||
* configuration property.
|
||||
* An adapter that implements {@link TransactionListener} is
|
||||
* registered with each {@link org.apache.openjpa.kernel.Broker}. This adapter
|
||||
* invokes <code>broadcast</code>, which is responsible for
|
||||
* notifying other remote commit provider objects of the commit
|
||||
* changes.</p>
|
||||
* <p/>
|
||||
* <p>Upon receiving a notification from a different remote commit provider,
|
||||
* notifying other remote commit provider objects of the commit changes.
|
||||
* Upon receiving a notification from a different remote commit provider,
|
||||
* a provider must notify all local remote commit listeners via the
|
||||
* {@link RemoteCommitEventManager#fireEvent} method.</p>
|
||||
* <p/>
|
||||
* <p>A remote commit provider <b>must not</b> fire remote events for
|
||||
* commits that originated with a local broker.</p>
|
||||
* {@link RemoteCommitEventManager#fireEvent} method.
|
||||
* A remote commit provider <b>must not</b> fire remote events for
|
||||
* commits that originated with a local broker.
|
||||
*
|
||||
* @author Patrick Linskey
|
||||
* @since 2.5.0
|
||||
|
@ -57,7 +53,7 @@ public interface RemoteCommitProvider
|
|||
public void broadcast(RemoteCommitEvent event);
|
||||
|
||||
/**
|
||||
* Free the resources used by this provider.
|
||||
* Free the resources used by this provider.
|
||||
*/
|
||||
public void close();
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -20,12 +20,12 @@ import java.util.Iterator;
|
|||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* <p>Single-JVM-only implementation of {@link RemoteCommitProvider}
|
||||
* Single-JVM-only implementation of {@link RemoteCommitProvider}
|
||||
* that listens for object modifications and propagates those changes
|
||||
* to other SingleJVMRemoteCommitProviders in the same JVM. This is
|
||||
* only useful for linking together multiple factories in the same
|
||||
* JVM that are all loaded in the same classloader, which is a rare
|
||||
* circumstance.</p>
|
||||
* circumstance.
|
||||
*
|
||||
* @author Patrick Linskey
|
||||
* @since 2.5.0
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -16,7 +16,7 @@
|
|||
package org.apache.openjpa.event;
|
||||
|
||||
/**
|
||||
* <p>Listener for when persistent instances are stored to the database.</p>
|
||||
* Listener for when persistent instances are stored to the database.
|
||||
*
|
||||
* @author Steve Kim
|
||||
* @author Abe White
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -460,8 +460,7 @@ public class TCPRemoteCommitProvider
|
|||
}
|
||||
|
||||
/**
|
||||
* Responsible for listening for incoming packets and processing
|
||||
* them.
|
||||
* Responsible for listening for incoming packets and processing them.
|
||||
*/
|
||||
private static class TCPPortListener
|
||||
implements Runnable {
|
||||
|
@ -487,14 +486,12 @@ public class TCPRemoteCommitProvider
|
|||
private int _port;
|
||||
|
||||
/**
|
||||
* Should be set to <code>true</code> once the listener is
|
||||
* listening.
|
||||
* Should be set to <code>true</code> once the listener is listening.
|
||||
*/
|
||||
private boolean _isRunning = false;
|
||||
|
||||
/**
|
||||
* Construct a new TCPPortListener configured to use the
|
||||
* specified port.
|
||||
* Construct a new TCPPortListener configured to use the specified port.
|
||||
*/
|
||||
private TCPPortListener(int port, Log log)
|
||||
throws UnknownHostException, IOException {
|
||||
|
@ -745,20 +742,19 @@ public class TCPRemoteCommitProvider
|
|||
}
|
||||
|
||||
/**
|
||||
* Utility class to store an InetAddress and an int. Not using
|
||||
* InetSocketAddress because it's a JDK1.4 API. This also
|
||||
* provides a wrapper around the socket(s) associated with this
|
||||
* address.
|
||||
* Utility class to store an InetAddress and an int. Not using
|
||||
* InetSocketAddress because it's a JDK1.4 API. This also
|
||||
* provides a wrapper around the socket(s) associated with this address.
|
||||
*/
|
||||
private class HostAddress {
|
||||
|
||||
private InetAddress _address;
|
||||
private int _port;
|
||||
private long _timeLastError; // millis
|
||||
private boolean _isAvailable; // is peer thought to be up
|
||||
private int _infosIssued = 0; // limit log entries
|
||||
private long _timeLastError; // millis
|
||||
private boolean _isAvailable; // is peer thought to be up
|
||||
private int _infosIssued = 0; // limit log entries
|
||||
|
||||
private GenericObjectPool _socketPool; // reusable open sockets
|
||||
private GenericObjectPool _socketPool; // reusable open sockets
|
||||
|
||||
/**
|
||||
* Construct a new host address from a string of the form
|
||||
|
@ -892,7 +888,7 @@ public class TCPRemoteCommitProvider
|
|||
}
|
||||
|
||||
/**
|
||||
* Factory for pooled sockets.
|
||||
* Factory for pooled sockets.
|
||||
*/
|
||||
private class SocketPoolableObjectFactory
|
||||
implements PoolableObjectFactory {
|
||||
|
@ -930,7 +926,6 @@ public class TCPRemoteCommitProvider
|
|||
{
|
||||
}
|
||||
|
||||
|
||||
public void passivateObject (Object value)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -22,8 +22,8 @@ import java.util.EventObject;
|
|||
import org.apache.openjpa.kernel.Broker;
|
||||
|
||||
/**
|
||||
* <p>A transactional event. The event source is the {@link Broker} whose
|
||||
* transaction state changed.</p>
|
||||
* A transactional event. The event source is the {@link Broker} whose
|
||||
* transaction state changed.
|
||||
*
|
||||
* @since 3.0
|
||||
* @author Abe White
|
||||
|
@ -38,8 +38,7 @@ public class TransactionEvent
|
|||
|
||||
/**
|
||||
* Event type signifying that changes are about to be flushed to the
|
||||
* datastore. This does not necessarily mean that a commit is taking
|
||||
* place.
|
||||
* datastore. This does not necessarily mean that a commit is taking place.
|
||||
*/
|
||||
public static final int BEFORE_FLUSH = 1;
|
||||
|
||||
|
@ -93,12 +92,12 @@ public class TransactionEvent
|
|||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param pm the event source
|
||||
* @param type the event type
|
||||
* @param objs transactional objects
|
||||
* @param addClss classes of added instances
|
||||
* @param updateClss classes of updated instances
|
||||
* @param deleteClss classes of deleted instances
|
||||
* @param pm the event source
|
||||
* @param type the event type
|
||||
* @param objs transactional objects
|
||||
* @param addClss classes of added instances
|
||||
* @param updateClss classes of updated instances
|
||||
* @param deleteClss classes of deleted instances
|
||||
*/
|
||||
public TransactionEvent(Broker broker, int type,
|
||||
Collection objs, Collection addClss, Collection updateClss,
|
||||
|
@ -120,7 +119,7 @@ public class TransactionEvent
|
|||
|
||||
/**
|
||||
* Return the unmodifiable set of persistence capable objects
|
||||
* participating in the transaction. This set will contain all dirty
|
||||
* participating in the transaction. This set will contain all dirty
|
||||
* objects, but may not contain clean objects.
|
||||
*/
|
||||
public Collection getTransactionalObjects() {
|
||||
|
@ -129,8 +128,7 @@ public class TransactionEvent
|
|||
|
||||
/**
|
||||
* Return the unmodifiable the set of classes of
|
||||
* persistence capable objects that were created in
|
||||
* the transaction.
|
||||
* persistence capable objects that were created in the transaction.
|
||||
*/
|
||||
public Collection getPersistedTypes() {
|
||||
return _addClss;
|
||||
|
@ -138,17 +136,15 @@ public class TransactionEvent
|
|||
|
||||
/**
|
||||
* Return the unmodifiable the set of classes of
|
||||
* persistence capable objects that were modified in
|
||||
* the transaction.
|
||||
* persistence capable objects that were modified in the transaction.
|
||||
*/
|
||||
public Collection getUpdatedTypes() {
|
||||
return _updateClss;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the unmodifiable the set of classes of
|
||||
* persistence capable objects that were deleted in
|
||||
* the transaction.
|
||||
* Return the unmodifiable the set of classes of
|
||||
* persistence capable objects that were deleted in the transaction.
|
||||
*/
|
||||
public Collection getDeletedTypes ()
|
||||
{
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -18,8 +18,8 @@ package org.apache.openjpa.event;
|
|||
import org.apache.openjpa.lib.util.concurrent.AbstractConcurrentEventManager;
|
||||
|
||||
/**
|
||||
* <p>Manager that can be used to track and notify transaction listeners
|
||||
* of transaction-related events.</p>
|
||||
* Manager that can be used to track and notify transaction listeners
|
||||
* of transaction-related events.
|
||||
*
|
||||
* @author Patrick Linskey
|
||||
* @author Abe White
|
||||
|
@ -78,7 +78,7 @@ public class TransactionEventManager
|
|||
}
|
||||
|
||||
/**
|
||||
* Fire the given event to all registered listeners.
|
||||
* Fire the given event to all registered listeners.
|
||||
*/
|
||||
protected void fireEvent(Object event, Object listener) {
|
||||
TransactionEvent ev = (TransactionEvent) event;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -16,7 +16,7 @@
|
|||
package org.apache.openjpa.event;
|
||||
|
||||
/**
|
||||
* <p>Interface for listening to all {@link TransactionEvent}s.
|
||||
* Interface for listening to all {@link TransactionEvent}s.
|
||||
*
|
||||
* @author Patrick Linskey
|
||||
* @author Abe White
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -45,8 +45,8 @@ import org.apache.openjpa.util.OpenJPAException;
|
|||
import org.apache.openjpa.util.UserException;
|
||||
|
||||
/**
|
||||
* <p>Abstract implementation of the {@link BrokerFactory}
|
||||
* that must be subclassed for a specific runtime.</p>
|
||||
* Abstract implementation of the {@link BrokerFactory}
|
||||
* that must be subclassed for a specific runtime.
|
||||
*
|
||||
* @author Abe White
|
||||
*/
|
||||
|
@ -106,7 +106,7 @@ public abstract class AbstractBrokerFactory
|
|||
}
|
||||
|
||||
/**
|
||||
* Constructor. Configuration must be provided on construction.
|
||||
* Constructor. Configuration must be provided on construction.
|
||||
*/
|
||||
protected AbstractBrokerFactory(OpenJPAConfiguration config) {
|
||||
_conf = config;
|
||||
|
@ -206,7 +206,7 @@ public abstract class AbstractBrokerFactory
|
|||
}
|
||||
|
||||
/**
|
||||
* Load the configured persistent classes list. Performed automatically
|
||||
* Load the configured persistent classes list. Performed automatically
|
||||
* whenever a broker is created.
|
||||
*/
|
||||
private void loadPersistentTypes(ClassLoader envLoader) {
|
||||
|
@ -360,7 +360,7 @@ public abstract class AbstractBrokerFactory
|
|||
}
|
||||
|
||||
/**
|
||||
* Replaces the factory with this JVMs pooled version if it exists. Also
|
||||
* Replaces the factory with this JVMs pooled version if it exists. Also
|
||||
* freezes the factory.
|
||||
*/
|
||||
protected Object readResolve()
|
||||
|
@ -382,16 +382,16 @@ public abstract class AbstractBrokerFactory
|
|||
////////////////////////
|
||||
|
||||
/**
|
||||
* Return a new StoreManager for this runtime. Note that the instance
|
||||
* Return a new StoreManager for this runtime. Note that the instance
|
||||
* returned here may be wrapped before being passed to the
|
||||
* {@link #newBroker} method.
|
||||
*/
|
||||
protected abstract StoreManager newStoreManager();
|
||||
|
||||
/**
|
||||
* Find a pooled broker, or return null if none. If using
|
||||
* Find a pooled broker, or return null if none. If using
|
||||
* managed transactions, looks for a transactional broker;
|
||||
* otherwise returns null by default. This method will be called before
|
||||
* otherwise returns null by default. This method will be called before
|
||||
* {@link #newStoreManager} so that factory subclasses implementing
|
||||
* pooling can return a matching manager before a new {@link StoreManager}
|
||||
* is created.
|
||||
|
@ -418,7 +418,7 @@ public abstract class AbstractBrokerFactory
|
|||
|
||||
/**
|
||||
* Setup transient state used by this factory based on the
|
||||
* current configuration, which will subsequently be locked down. This
|
||||
* current configuration, which will subsequently be locked down. This
|
||||
* method will be called before the first broker is requested,
|
||||
* and will be re-called each time the factory is deserialized into a JVM
|
||||
* that has no configuration for this data store.
|
||||
|
@ -563,7 +563,7 @@ public abstract class AbstractBrokerFactory
|
|||
////////////////////
|
||||
|
||||
/**
|
||||
* Throws a {@link UserException} if a transaction is active. The thrown
|
||||
* Throws a {@link UserException} if a transaction is active. The thrown
|
||||
* exception will contain all the Brokers with active transactions as
|
||||
* failed objects in the nested exceptions.
|
||||
*/
|
||||
|
@ -641,8 +641,8 @@ public abstract class AbstractBrokerFactory
|
|||
}
|
||||
|
||||
/**
|
||||
* Simple synchronization listener to remove completed transactions
|
||||
* from our cache.
|
||||
* Simple synchronization listener to remove completed transactions
|
||||
* from our cache.
|
||||
*/
|
||||
private class RemoveTransactionSync
|
||||
implements Synchronization {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -19,8 +19,8 @@ import org.apache.openjpa.enhance.FieldManager;
|
|||
import org.apache.openjpa.util.InternalException;
|
||||
|
||||
/**
|
||||
* <p>Abstract {@link FieldManager} for easy subclassing. Throws exceptions
|
||||
* for all methods.</p>
|
||||
* Abstract {@link FieldManager} for easy subclassing. Throws exceptions
|
||||
* for all methods.
|
||||
*
|
||||
* @author Abe White
|
||||
*/
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -71,7 +71,7 @@ public abstract class AbstractLockManager
|
|||
}
|
||||
|
||||
/**
|
||||
* Does nothing by default.
|
||||
* Does nothing by default.
|
||||
*/
|
||||
public void close ()
|
||||
{
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -35,7 +35,7 @@ import org.apache.openjpa.util.ChangeTracker;
|
|||
import org.apache.openjpa.util.Proxy;
|
||||
|
||||
/**
|
||||
* <p>Abstract base class which implements core PCData behavior.</p>
|
||||
* Abstract base class which implements core PCData behavior.
|
||||
*
|
||||
* @author Patrick Linskey
|
||||
* @author Abe White
|
||||
|
@ -111,7 +111,7 @@ public abstract class AbstractPCData
|
|||
}
|
||||
|
||||
/**
|
||||
* Transform the given data value to its field value. The data value
|
||||
* Transform the given data value to its field value. The data value
|
||||
* may be a key, value, or element of a map or collection.
|
||||
*/
|
||||
protected Object toNestedField(OpenJPAStateManager sm, ValueMetaData vmd,
|
||||
|
@ -142,7 +142,7 @@ public abstract class AbstractPCData
|
|||
}
|
||||
|
||||
/**
|
||||
* Transform the given data into a relation field value. Default
|
||||
* Transform the given data into a relation field value. Default
|
||||
* implementation assumes the data is an oid.
|
||||
*/
|
||||
protected Object toRelationField(OpenJPAStateManager sm, ValueMetaData vmd,
|
||||
|
@ -151,7 +151,7 @@ public abstract class AbstractPCData
|
|||
}
|
||||
|
||||
/**
|
||||
* Transform the given data into an embedded PC field value. Default
|
||||
* Transform the given data into an embedded PC field value. Default
|
||||
* implementation assumes the data is an {@link AbstractPCData}.
|
||||
*/
|
||||
protected Object toEmbeddedField(OpenJPAStateManager sm, ValueMetaData vmd,
|
||||
|
@ -165,7 +165,7 @@ public abstract class AbstractPCData
|
|||
}
|
||||
|
||||
/**
|
||||
* Transform the given field value to a data value for caching. Return
|
||||
* Transform the given field value to a data value for caching. Return
|
||||
* {@link #NULL} if unable to cache.
|
||||
*/
|
||||
protected Object toData(FieldMetaData fmd, Object val, StoreContext ctx) {
|
||||
|
@ -237,7 +237,7 @@ public abstract class AbstractPCData
|
|||
}
|
||||
|
||||
/**
|
||||
* Transform the given nested value to a cachable value. Return
|
||||
* Transform the given nested value to a cachable value. Return
|
||||
* {@link #NULL} if the value cannot be cached.
|
||||
*/
|
||||
protected Object toNestedData(ValueMetaData vmd, Object val,
|
||||
|
@ -270,7 +270,7 @@ public abstract class AbstractPCData
|
|||
}
|
||||
|
||||
/**
|
||||
* Return the value to cache for the given object. Caches its oid by
|
||||
* Return the value to cache for the given object. Caches its oid by
|
||||
* default.
|
||||
*/
|
||||
protected Object toRelationData(Object val, StoreContext ctx) {
|
||||
|
@ -278,7 +278,7 @@ public abstract class AbstractPCData
|
|||
}
|
||||
|
||||
/**
|
||||
* Return the value to cache for the given embedded PC. Caches a
|
||||
* Return the value to cache for the given embedded PC. Caches a
|
||||
* {@link PCData} from {@link #newEmbeddedPCData} by default.
|
||||
*/
|
||||
protected Object toEmbeddedData(Object val, StoreContext ctx) {
|
||||
|
@ -299,7 +299,7 @@ public abstract class AbstractPCData
|
|||
}
|
||||
|
||||
/**
|
||||
* Tracks proxy data along with list elements.
|
||||
* Tracks proxy data along with list elements.
|
||||
*/
|
||||
private static class ProxyDataList
|
||||
extends ArrayList {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -22,10 +22,9 @@ import org.apache.openjpa.util.ObjectNotFoundException;
|
|||
import org.apache.openjpa.util.StoreException;
|
||||
|
||||
/**
|
||||
* <p>Abstract implementation of {@link PCResultObjectProvider}
|
||||
* Abstract implementation of {@link PCResultObjectProvider}
|
||||
* that implements {@link ResultObjectProvider#getResultObject}
|
||||
* by assembling the necessary information about the object to be
|
||||
* loaded.</p>
|
||||
* by assembling the necessary information about the object to be loaded.
|
||||
*
|
||||
* @author Patrick Linskey
|
||||
*/
|
||||
|
@ -91,23 +90,23 @@ public abstract class AbstractPCResultObjectProvider
|
|||
|
||||
/**
|
||||
* Load data from the current input record into the given state
|
||||
* manager. Remember to call {@link OpenJPAStateManager#setVersion} to set
|
||||
* manager. Remember to call {@link OpenJPAStateManager#setVersion} to set
|
||||
* the optimistic versioning information, if it has any.
|
||||
*/
|
||||
protected abstract void load(OpenJPAStateManager sm, FetchState fetch)
|
||||
throws Exception;
|
||||
|
||||
/**
|
||||
* Override if desired. Does nothing by default.
|
||||
* Override if desired. Does nothing by default.
|
||||
*/
|
||||
public void open()
|
||||
throws Exception {
|
||||
}
|
||||
|
||||
/**
|
||||
* Override if desired. Returns false by default.
|
||||
* Override if desired. Returns false by default.
|
||||
*
|
||||
* @see ResultObjectProvider#supportsRandomAccess
|
||||
* @see ResultObjectProvider#supportsRandomAccess
|
||||
*/
|
||||
public boolean supportsRandomAccess() {
|
||||
return false;
|
||||
|
@ -116,15 +115,15 @@ public abstract class AbstractPCResultObjectProvider
|
|||
/**
|
||||
* Implement this method to advance the input.
|
||||
*
|
||||
* @see ResultObjectProvider#next
|
||||
* @see ResultObjectProvider#next
|
||||
*/
|
||||
public abstract boolean next()
|
||||
throws Exception;
|
||||
|
||||
/**
|
||||
* Override if desired. Throws an exception by default.
|
||||
* Override if desired. Throws an exception by default.
|
||||
*
|
||||
* @see ResultObjectProvider#absolute
|
||||
* @see ResultObjectProvider#absolute
|
||||
*/
|
||||
public boolean absolute(int pos)
|
||||
throws Exception {
|
||||
|
@ -132,9 +131,9 @@ public abstract class AbstractPCResultObjectProvider
|
|||
}
|
||||
|
||||
/**
|
||||
* Override if desired. Returns {@link Integer#MAX_VALUE} by default.
|
||||
* Override if desired. Returns {@link Integer#MAX_VALUE} by default.
|
||||
*
|
||||
* @see ResultObjectProvider#size
|
||||
* @see ResultObjectProvider#size
|
||||
*/
|
||||
public int size()
|
||||
throws Exception {
|
||||
|
@ -142,9 +141,9 @@ public abstract class AbstractPCResultObjectProvider
|
|||
}
|
||||
|
||||
/**
|
||||
* Override if desired. Throws an exception by default.
|
||||
* Override if desired. Throws an exception by default.
|
||||
*
|
||||
* @see ResultObjectProvider#reset
|
||||
* @see ResultObjectProvider#reset
|
||||
*/
|
||||
public void reset()
|
||||
throws Exception {
|
||||
|
@ -152,16 +151,16 @@ public abstract class AbstractPCResultObjectProvider
|
|||
}
|
||||
|
||||
/**
|
||||
* Override if desired. Does nothing by default.
|
||||
* Override if desired. Does nothing by default.
|
||||
*
|
||||
* @see ResultObjectProvider#close
|
||||
* @see ResultObjectProvider#close
|
||||
*/
|
||||
public void close()
|
||||
throws Exception {
|
||||
}
|
||||
|
||||
/**
|
||||
* Throws a {@link StoreException} by default.
|
||||
* Throws a {@link StoreException} by default.
|
||||
*/
|
||||
public void handleCheckedException(Exception e) {
|
||||
throw new StoreException (e);
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -25,7 +25,7 @@ import org.apache.openjpa.meta.ClassMetaData;
|
|||
import org.apache.openjpa.util.InternalException;
|
||||
|
||||
/**
|
||||
* <p>Abstract {@link StoreQuery} that implements most methods as no-ops.</p>
|
||||
* Abstract {@link StoreQuery} that implements most methods as no-ops.
|
||||
*
|
||||
* @author Abe White
|
||||
* @since 4.0
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -59,7 +59,7 @@ class AttachManager {
|
|||
private AttachStrategy _detach = null;
|
||||
|
||||
/**
|
||||
* Constructor. Supply broker attaching to.
|
||||
* Constructor. Supply broker attaching to.
|
||||
*/
|
||||
public AttachManager(BrokerImpl broker, boolean copyNew, OpCallbacks call) {
|
||||
_broker = broker;
|
||||
|
@ -98,7 +98,7 @@ class AttachManager {
|
|||
}
|
||||
catch (CallbackException ce) {
|
||||
excep = ce;
|
||||
return null; // won't be reached as the exceps will be rethrown
|
||||
return null; // won't be reached as the exceps will be rethrown
|
||||
}
|
||||
finally {
|
||||
List exceps = null;
|
||||
|
@ -213,10 +213,10 @@ class AttachManager {
|
|||
/**
|
||||
* Attach.
|
||||
*
|
||||
* @param toAttach the detached object
|
||||
* @param into the instance we're attaching into
|
||||
* @param owner state manager for <code>into</code>
|
||||
* @param ownerMeta the field we traversed to find <code>toAttach</code>
|
||||
* @param toAttach the detached object
|
||||
* @param into the instance we're attaching into
|
||||
* @param owner state manager for <code>into</code>
|
||||
* @param ownerMeta the field we traversed to find <code>toAttach</code>
|
||||
*/
|
||||
Object attach(Object toAttach, PersistenceCapable into,
|
||||
OpenJPAStateManager owner, ValueMetaData ownerMeta) {
|
||||
|
@ -322,8 +322,8 @@ class AttachManager {
|
|||
}
|
||||
|
||||
/**
|
||||
* Throw an exception if the given object is not managed; otherwise
|
||||
* return its state manager.
|
||||
* Throw an exception if the given object is not managed; otherwise
|
||||
* return its state manager.
|
||||
*/
|
||||
StateManagerImpl assertManaged(Object obj) {
|
||||
StateManagerImpl sm = _broker.getStateManagerImpl(obj, true);
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue