You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by pp...@apache.org on 2009/09/11 20:55:46 UTC
svn commit: r813983 -
/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAPersistenceUtil.java
Author: ppoddar
Date: Fri Sep 11 18:55:45 2009
New Revision: 813983
URL: http://svn.apache.org/viewvc?rev=813983&view=rev
Log:
Bring test for isManageable() outside of per-broker loop
Modified:
openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAPersistenceUtil.java
Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAPersistenceUtil.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAPersistenceUtil.java?rev=813983&r1=813982&r2=813983&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAPersistenceUtil.java (original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/OpenJPAPersistenceUtil.java Fri Sep 11 18:55:45 2009
@@ -61,7 +61,7 @@
PersistenceCapable pc = (PersistenceCapable)entity;
// Per contract, if not managed by the owning emf, return null.
if (emf != null) {
- if (!OpenJPAPersistenceUtil.isManagedBy(emf, pc)) {
+ if (!isManagedBy(emf, pc)) {
return null;
}
}
@@ -77,14 +77,13 @@
/**
* Determines whether the specified state manager is managed by a broker
- * within the persistence unit of this util instance.
+ * within the persistence unit of this utility instance.
* @param sm StateManager
* @return true if this state manager is managed by a broker within
* this persistence unit.
*/
- public static boolean isManagedBy(OpenJPAEntityManagerFactory emf,
- Object entity) {
- if (emf == null || !emf.isOpen()) {
+ public static boolean isManagedBy(OpenJPAEntityManagerFactory emf, Object entity) {
+ if (emf == null || !emf.isOpen() || !ImplHelper.isManageable(entity)) {
return false;
}
Object abfobj = JPAFacadeHelper.toBrokerFactory(emf);
@@ -93,21 +92,19 @@
}
if (abfobj instanceof AbstractBrokerFactory) {
AbstractBrokerFactory abf = (AbstractBrokerFactory)abfobj;
- Collection<?> brokers = abf.getOpenBrokers();
+ Collection<Broker> brokers = abf.getOpenBrokers();
if (brokers == null || brokers.size() == 0) {
return false;
}
// Cycle through all brokers managed by this factory.
- Broker[] brokerArr = brokers.toArray(new Broker[brokers.size()]);
- for (Broker broker : brokerArr) {
- if (broker != null && !broker.isClosed())
- if (ImplHelper.isManageable(entity)) {
- PersistenceCapable pc = (PersistenceCapable)entity;
- // Vfy this broker is managing the entity
- if (pc.pcGetGenericContext() == broker) {
- return true;
- }
+ for (Broker broker : brokers) {
+ if (broker != null && !broker.isClosed()) {
+ PersistenceCapable pc = (PersistenceCapable)entity;
+ // Verify this broker is managing the entity
+ if (pc.pcGetGenericContext() == broker) {
+ return true;
}
+ }
}
}
return false;
@@ -140,8 +137,7 @@
* entity manager factory, or if it does not contain the persistent
* attribute.
*/
- public static LoadState isLoaded(OpenJPAEntityManagerFactory emf,
- Object obj, String attr) {
+ public static LoadState isLoaded(OpenJPAEntityManagerFactory emf, Object obj, String attr) {
if (obj == null) {
return LoadState.UNKNOWN;