本文整理汇总了Java中org.apache.ojb.broker.core.proxy.ProxyHelper类的典型用法代码示例。如果您正苦于以下问题:Java ProxyHelper类的具体用法?Java ProxyHelper怎么用?Java ProxyHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProxyHelper类属于org.apache.ojb.broker.core.proxy包,在下文中一共展示了ProxyHelper类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: materializeUpdateableCollections
import org.apache.ojb.broker.core.proxy.ProxyHelper; //导入依赖的package包/类
/**
* This method checks for updateable collections on the business object provided and materializes the corresponding
* collection proxies
*
* @param bo The business object for which you want unpdateable, proxied collections materialized
* @throws FormatException
* @throws IllegalAccessException
* @throws InvocationTargetException
* @throws NoSuchMethodException
*
* @deprecated Replaced by {@link DataObjectWrapper#materializeReferencedObjects(org.kuali.rice.krad.data.MaterializeOption...)}
*/
@Deprecated
public static void materializeUpdateableCollections(
Object bo) throws FormatException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {
if (isNotNull(bo)) {
PropertyDescriptor[] propertyDescriptors = PropertyUtils.getPropertyDescriptors(bo.getClass());
for (int i = 0; i < propertyDescriptors.length; i++) {
if (KNSServiceLocator.getPersistenceStructureService().hasCollection(bo.getClass(),
propertyDescriptors[i].getName()) && KNSServiceLocator.getPersistenceStructureService()
.isCollectionUpdatable(bo.getClass(), propertyDescriptors[i].getName())) {
Collection updateableCollection = (Collection) getPropertyValue(bo,
propertyDescriptors[i].getName());
if ((updateableCollection != null) && ProxyHelper.isCollectionProxy(updateableCollection)) {
materializeObjects(updateableCollection);
}
}
}
}
}
开发者ID:kuali,项目名称:kc-rice,代码行数:31,代码来源:ObjectUtils.java
示例2: isNull
import org.apache.ojb.broker.core.proxy.ProxyHelper; //导入依赖的package包/类
/**
* This method is a OJB Proxy-safe way to test for null on a proxied object that may or may not be materialized yet.
* It is safe
* to use on a proxy (materialized or non-materialized) or on a non-proxy (ie, regular object). Note that this will
* force a
* materialization of the proxy if the object is a proxy and unmaterialized.
*
* @param object - any object, proxied or not, materialized or not
* @return true if the object (or underlying materialized object) is null, false otherwise
*/
public static boolean isNull(Object object) {
// regardless, if its null, then its null
if (object == null) {
return true;
}
// only try to materialize the object to see if its null if this is a
// proxy object
if (ProxyHelper.isProxy(object) || ProxyHelper.isCollectionProxy(object)) {
if (ProxyHelper.getRealObject(object) == null) {
return true;
}
}
// JPA does not provide a way to determine if an object is a proxy, instead we invoke
// the equals method and catch an EntityNotFoundException
try {
object.equals(null);
} catch (EntityNotFoundException e) {
return true;
}
return false;
}
开发者ID:kuali,项目名称:kc-rice,代码行数:36,代码来源:ObjectUtils.java
示例3: materializeClassForProxiedObject
import org.apache.ojb.broker.core.proxy.ProxyHelper; //导入依赖的package包/类
/**
* Attempts to find the Class for the given potentially proxied object
*
* @param object the potentially proxied object to find the Class of
* @return the best Class which could be found for the given object
*/
public static Class materializeClassForProxiedObject(Object object) {
if (object == null) {
return null;
}
// if (object instanceof HibernateProxy) {
// final Class realClass = ((HibernateProxy) object).getHibernateLazyInitializer().getPersistentClass();
// return realClass;
// }
if (ProxyHelper.isProxy(object) || ProxyHelper.isCollectionProxy(object)) {
return ProxyHelper.getRealClass(object);
}
return object.getClass();
}
开发者ID:kuali,项目名称:kc-rice,代码行数:23,代码来源:ObjectUtils.java
示例4: getObjectByIdentity
import org.apache.ojb.broker.core.proxy.ProxyHelper; //导入依赖的package包/类
/**
* @see org.apache.ojb.otm.OTMConnection#getObjectByIdentity(Identity, int)
*/
public Object getObjectByIdentity(Identity oid, int lock) throws LockingException
{
checkTransaction("getObjectByIdentity");
Object userObject;
Object cacheObject;
cacheObject = _pb.getObjectByIdentity(oid);
if (cacheObject == null)
{
// Possibly the object was inserted in this transaction
// and was not stored to database yet
userObject = _editingContext.lookup(oid);
}
else
{
userObject = getUserObject(oid, cacheObject);
// userObject from editing context may be proxy
userObject = ProxyHelper.getRealObject(userObject);
_editingContext.insert(oid, userObject, lock);
}
return userObject;
}
开发者ID:KualiCo,项目名称:ojb,代码行数:26,代码来源:BaseConnection.java
示例5: lockAndRegisterReferences
import org.apache.ojb.broker.core.proxy.ProxyHelper; //导入依赖的package包/类
/**
* we only use the registrationList map if the object is not a proxy. During the
* reference locking, we will materialize objects and they will enter the registered for
* lock map.
*/
private void lockAndRegisterReferences(ClassDescriptor cld, Object sourceObject, int lockMode, List registeredObjects) throws LockNotGrantedException
{
if (implicitLocking)
{
Iterator i = cld.getObjectReferenceDescriptors(true).iterator();
while (i.hasNext())
{
ObjectReferenceDescriptor rds = (ObjectReferenceDescriptor) i.next();
Object refObj = rds.getPersistentField().get(sourceObject);
if (refObj != null)
{
boolean isProxy = ProxyHelper.isProxy(refObj);
RuntimeObject rt = isProxy ? new RuntimeObject(refObj, this, false) : new RuntimeObject(refObj, this);
if (!registrationList.contains(rt.getIdentity()))
{
lockAndRegister(rt, lockMode, registeredObjects);
}
}
}
}
}
开发者ID:KualiCo,项目名称:ojb,代码行数:27,代码来源:TransactionImpl.java
示例6: afterLoading
import org.apache.ojb.broker.core.proxy.ProxyHelper; //导入依赖的package包/类
/**
* Remove colProxy from list of pending collections and
* register its contents with the transaction.
*/
public void afterLoading(CollectionProxyDefaultImpl colProxy)
{
if (log.isDebugEnabled()) log.debug("loading a proxied collection a collection: " + colProxy);
Collection data = colProxy.getData();
for (Iterator iterator = data.iterator(); iterator.hasNext();)
{
Object o = iterator.next();
if(!isOpen())
{
log.error("Collection proxy materialization outside of a running tx, obj=" + o);
try{throw new Exception("Collection proxy materialization outside of a running tx, obj=" + o);}
catch(Exception e)
{e.printStackTrace();}
}
else
{
Identity oid = getBroker().serviceIdentity().buildIdentity(o);
ClassDescriptor cld = getBroker().getClassDescriptor(ProxyHelper.getRealClass(o));
RuntimeObject rt = new RuntimeObject(o, oid, cld, false, ProxyHelper.isProxy(o));
lockAndRegister(rt, Transaction.READ, isImplicitLocking(), getRegistrationList());
}
}
unregisterFromCollectionProxy(colProxy);
}
开发者ID:KualiCo,项目名称:ojb,代码行数:29,代码来源:TransactionImpl.java
示例7: ObjectEnvelope
import org.apache.ojb.broker.core.proxy.ProxyHelper; //导入依赖的package包/类
/**
* Create a wrapper by providing an Object.
*/
public ObjectEnvelope(ObjectEnvelopeTable buffer, Identity oid, Object obj, boolean isNewObject)
{
this.linkEntryList = new ArrayList();
this.buffer = buffer;
this.oid = oid;
// TODO: do we really need to materialize??
myObj = ProxyHelper.getRealObject(obj);
prepareInitialState(isNewObject);
/*
TODO: is it possible to improve this? Take care that "new"
objects should support "persistence by reachability" too
(detection of new/persistent reference objects after maon object lock)
*/
beforeImage = buildObjectImage(getBroker());
}
开发者ID:KualiCo,项目名称:ojb,代码行数:19,代码来源:ObjectEnvelope.java
示例8: initCld
import org.apache.ojb.broker.core.proxy.ProxyHelper; //导入依赖的package包/类
private void initCld(final TransactionImpl tx)
{
final IndirectionHandler handler = ProxyHelper.getIndirectionHandler(obj);
if(handler != null)
{
this.handler = handler;
isNew = Boolean.FALSE;
identity = handler.getIdentity();
if(handler.alreadyMaterialized())
{
cld = tx.getBroker().getClassDescriptor(handler.getRealSubject().getClass());
}
else
{
cld = tx.getBroker().getClassDescriptor(identity.getObjectsRealClass());
}
}
else
{
cld = tx.getBroker().getClassDescriptor(obj.getClass());
}
}
开发者ID:KualiCo,项目名称:ojb,代码行数:23,代码来源:RuntimeObject.java
示例9: cleanup
import org.apache.ojb.broker.core.proxy.ProxyHelper; //导入依赖的package包/类
public void cleanup(boolean reuse)
{
if(log.isDebugEnabled()) log.debug("Cleanup collection image, reuse=" + reuse);
if(reuse)
{
isRefreshed = false;
}
else
{
if(status == IS_UNMATERIALIZED_PROXY)
{
CollectionProxy colProxy = ProxyHelper.getCollectionProxy(collectionOrArray);
if(colProxy != null)
{
colProxy.removeListener(this);
}
}
}
}
开发者ID:KualiCo,项目名称:ojb,代码行数:20,代码来源:Image.java
示例10: getIsolationLevel
import org.apache.ojb.broker.core.proxy.ProxyHelper; //导入依赖的package包/类
/**
* determines the isolationlevel of class c by evaluating
* the ClassDescriptor of obj.getClass().
*
* @return int the isolationlevel
*/
public static int getIsolationLevel(Object obj)
{
Class c = ProxyHelper.getRealClass(obj);
int isolationLevel = IsolationLevels.IL_READ_UNCOMMITTED;
try
{
ClassDescriptor cld = TxManagerFactory.instance().getCurrentTransaction().getBroker().getClassDescriptor(c);
isolationLevel = cld.getIsolationLevel();
}
catch (PersistenceBrokerException e)
{
LoggerFactory.getDefaultLogger().error("[LockStrategyFactory] Can't detect locking isolation level", e);
}
return isolationLevel;
}
开发者ID:KualiCo,项目名称:ojb,代码行数:23,代码来源:LockStrategyFactory.java
示例11: getForeignKeyValues
import org.apache.ojb.broker.core.proxy.ProxyHelper; //导入依赖的package包/类
/**
* Returns an Object array of all FK field values of the specified object.
* If the specified object is an unmaterialized Proxy, it will be materialized
* to read the FK values.
*
* @throws MetadataException if an error occours while accessing ForeingKey values on obj
*/
public Object[] getForeignKeyValues(Object obj, ClassDescriptor mif)
throws PersistenceBrokerException
{
FieldDescriptor[] fks = getForeignKeyFieldDescriptors(mif);
// materialize object only if FK fields are declared
if(fks.length > 0) obj = ProxyHelper.getRealObject(obj);
Object[] result = new Object[fks.length];
for (int i = 0; i < result.length; i++)
{
FieldDescriptor fmd = fks[i];
PersistentField f = fmd.getPersistentField();
// BRJ: do NOT convert.
// conversion is done when binding the sql-statement
//
// FieldConversion fc = fmd.getFieldConversion();
// Object val = fc.javaToSql(f.get(obj));
result[i] = f.get(obj);
}
return result;
}
开发者ID:KualiCo,项目名称:ojb,代码行数:30,代码来源:ObjectReferenceDescriptor.java
示例12: getValueFrom
import org.apache.ojb.broker.core.proxy.ProxyHelper; //导入依赖的package包/类
private Object getValueFrom(PropertyDescriptor pd, Object target)
{
if (target == null) return null;
Method m = pd.getReadMethod();
if (m != null)
{
try
{
return m.invoke(ProxyHelper.getRealObject(target), null);
}
catch (Throwable e)
{
logProblem(pd, target, null, "Can't read value from given object");
throw new MetadataException("Error invoking method:" + m.getName() + " in object " + target.getClass().getName(), e);
}
}
else
{
throw new MetadataException("Can't get ReadMethod for property:" + pd.getName() + " in object " + target.getClass().getName());
}
}
开发者ID:KualiCo,项目名称:ojb,代码行数:22,代码来源:PersistentFieldIntrospectorImpl.java
示例13: getRealClassDescriptor
import org.apache.ojb.broker.core.proxy.ProxyHelper; //导入依赖的package包/类
/**
* Answer the real ClassDescriptor for anObj
* ie. aCld may be an Interface of anObj, so the cld for anObj is returned
*/
private ClassDescriptor getRealClassDescriptor(ClassDescriptor aCld, Object anObj)
{
ClassDescriptor result;
if(aCld.getClassOfObject() == ProxyHelper.getRealClass(anObj))
{
result = aCld;
}
else
{
result = aCld.getRepository().getDescriptorFor(anObj.getClass());
}
return result;
}
开发者ID:KualiCo,项目名称:ojb,代码行数:20,代码来源:BrokerHelper.java
示例14: hasNullPKField
import org.apache.ojb.broker.core.proxy.ProxyHelper; //导入依赖的package包/类
/**
* Detect if the given object has a PK field represents a 'null' value.
*/
public boolean hasNullPKField(ClassDescriptor cld, Object obj)
{
FieldDescriptor[] fields = cld.getPkFields();
boolean hasNull = false;
// an unmaterialized proxy object can never have nullified PK's
IndirectionHandler handler = ProxyHelper.getIndirectionHandler(obj);
if(handler == null || handler.alreadyMaterialized())
{
if(handler != null) obj = handler.getRealSubject();
FieldDescriptor fld;
for(int i = 0; i < fields.length; i++)
{
fld = fields[i];
hasNull = representsNull(fld, fld.getPersistentField().get(obj));
if(hasNull) break;
}
}
return hasNull;
}
开发者ID:KualiCo,项目名称:ojb,代码行数:23,代码来源:BrokerHelper.java
示例15: assertValidPkForDelete
import org.apache.ojb.broker.core.proxy.ProxyHelper; //导入依赖的package包/类
/**
* returns true if the primary key fields are valid for delete, else false.
* PK fields are valid if each of them contains a valid non-null value
* @param cld the ClassDescriptor
* @param obj the object
* @return boolean
*/
public boolean assertValidPkForDelete(ClassDescriptor cld, Object obj)
{
if(!ProxyHelper.isProxy(obj))
{
FieldDescriptor fieldDescriptors[] = cld.getPkFields();
int fieldDescriptorSize = fieldDescriptors.length;
for(int i = 0; i < fieldDescriptorSize; i++)
{
FieldDescriptor fd = fieldDescriptors[i];
Object pkValue = fd.getPersistentField().get(obj);
if (representsNull(fd, pkValue))
{
return false;
}
}
}
return true;
}
开发者ID:KualiCo,项目名称:ojb,代码行数:26,代码来源:BrokerHelper.java
示例16: link
import org.apache.ojb.broker.core.proxy.ProxyHelper; //导入依赖的package包/类
/**
* This method concatenate the main object and the specified reference
* object (1:1 reference a referenced object, 1:n and m:n reference a
* collection of referenced objects) by hand. This method is needed when
* in the reference metadata definitions the auto-xxx setting was disabled.
* More info see OJB doc.
*
* @param obj Object with reference
* @param attributeName field name of the reference
* @param reference The referenced object
* @param insert flag signals insert operation
* @return true if the specified reference was found and linking was successful
*/
public boolean link(Object obj, String attributeName, Object reference, boolean insert)
{
ClassDescriptor cld = m_broker.getDescriptorRepository().getDescriptorFor(ProxyHelper.getRealClass(obj));
ObjectReferenceDescriptor ord;
boolean match = false;
// first look for reference then for collection
ord = cld.getObjectReferenceDescriptorByName(attributeName);
if (ord != null)
{
linkOrUnlinkOneToOne(true, obj, ord, insert);
match = true;
}
else
{
CollectionDescriptor cod = cld.getCollectionDescriptorByName(attributeName);
if (cod != null)
{
linkOrUnlinkXToMany(true, obj, cod, insert);
match = true;
}
}
return match;
}
开发者ID:KualiCo,项目名称:ojb,代码行数:37,代码来源:BrokerHelper.java
示例17: linkOrUnlink
import org.apache.ojb.broker.core.proxy.ProxyHelper; //导入依赖的package包/类
private boolean linkOrUnlink(boolean doLink, Object obj, String attributeName, boolean insert)
{
boolean match = false;
ClassDescriptor cld = m_broker.getDescriptorRepository().getDescriptorFor(ProxyHelper.getRealClass(obj));
ObjectReferenceDescriptor ord;
// first look for reference then for collection
ord = cld.getObjectReferenceDescriptorByName(attributeName);
if (ord != null)
{
linkOrUnlinkOneToOne(doLink, obj, ord, insert);
match = true;
}
else
{
CollectionDescriptor cod = cld.getCollectionDescriptorByName(attributeName);
if (cod != null)
{
linkOrUnlinkXToMany(doLink, obj, cod, insert);
match = true;
}
}
return match;
}
开发者ID:KualiCo,项目名称:ojb,代码行数:26,代码来源:BrokerHelper.java
示例18: linkOrUnlinkOneToOne
import org.apache.ojb.broker.core.proxy.ProxyHelper; //导入依赖的package包/类
private void linkOrUnlinkOneToOne(boolean doLink, Object obj, ObjectReferenceDescriptor ord, boolean insert)
{
/*
arminw: we need the class-descriptor where the reference is declared, thus we ask the
reference-descriptor for this, instead of using the class-descriptor of the specified
object. If the reference was declared within an interface (should never happen) we
only can use the descriptor of the real class.
*/
ClassDescriptor cld = ord.getClassDescriptor();
if(cld.isInterface())
{
cld = m_broker.getDescriptorRepository().getDescriptorFor(ProxyHelper.getRealClass(obj));
}
if (doLink)
{
m_broker.linkOneToOne(obj, cld, ord, insert);
}
else
{
m_broker.unlinkFK(obj, cld, ord);
// in 1:1 relation we have to set relation to null
ord.getPersistentField().set(obj, null);
}
}
开发者ID:KualiCo,项目名称:ojb,代码行数:26,代码来源:BrokerHelper.java
示例19: materializeUpdateableCollections
import org.apache.ojb.broker.core.proxy.ProxyHelper; //导入依赖的package包/类
/**
* This method checks for updateable collections on the business object provided and materializes the corresponding
* collection proxies
*
* @param bo The business object for which you want unpdateable, proxied collections materialized
* @throws FormatException
* @throws IllegalAccessException
* @throws InvocationTargetException
* @throws NoSuchMethodException
*/
public static void materializeUpdateableCollections(
Object bo) throws FormatException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {
if (isNotNull(bo)) {
PropertyDescriptor[] propertyDescriptors = PropertyUtils.getPropertyDescriptors(bo.getClass());
for (int i = 0; i < propertyDescriptors.length; i++) {
if (KRADServiceLocator.getPersistenceStructureService().hasCollection(bo.getClass(),
propertyDescriptors[i].getName()) && KRADServiceLocator.getPersistenceStructureService()
.isCollectionUpdatable(bo.getClass(), propertyDescriptors[i].getName())) {
Collection updateableCollection = (Collection) getPropertyValue(bo,
propertyDescriptors[i].getName());
if ((updateableCollection != null) && ProxyHelper.isCollectionProxy(updateableCollection)) {
materializeObjects(updateableCollection);
}
}
}
}
}
开发者ID:aapotts,项目名称:kuali_rice,代码行数:28,代码来源:ObjectUtils.java
示例20: materializeClassForProxiedObject
import org.apache.ojb.broker.core.proxy.ProxyHelper; //导入依赖的package包/类
/**
* Attempts to find the Class for the given potentially proxied object
*
* @param object the potentially proxied object to find the Class of
* @return the best Class which could be found for the given object
*/
public static Class materializeClassForProxiedObject(Object object) {
if (object == null) {
return null;
}
if (object instanceof HibernateProxy) {
final Class realClass = ((HibernateProxy) object).getHibernateLazyInitializer().getPersistentClass();
return realClass;
}
if (ProxyHelper.isProxy(object) || ProxyHelper.isCollectionProxy(object)) {
return ProxyHelper.getRealClass(object);
}
return object.getClass();
}
开发者ID:aapotts,项目名称:kuali_rice,代码行数:23,代码来源:ObjectUtils.java
注:本文中的org.apache.ojb.broker.core.proxy.ProxyHelper类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论