本文整理汇总了Java中org.apache.ojb.broker.core.proxy.ProxyHelper.isCollectionProxy方法的典型用法代码示例。如果您正苦于以下问题:Java ProxyHelper.isCollectionProxy方法的具体用法?Java ProxyHelper.isCollectionProxy怎么用?Java ProxyHelper.isCollectionProxy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.ojb.broker.core.proxy.ProxyHelper
的用法示例。
在下文中一共展示了ProxyHelper.isCollectionProxy方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
}
}
}
示例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;
}
示例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();
}
示例4: 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);
}
}
}
}
}
示例5: 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();
}
示例6: addCollectionEdges
import org.apache.ojb.broker.core.proxy.ProxyHelper; //导入方法依赖的package包/类
/**
* Finds edges base on a specific collection descriptor (1:n and m:n)
* and adds them to the edge map.
* @param vertex the object envelope vertex holding the collection
* @param cds the collection descriptor
*/
private void addCollectionEdges(Vertex vertex, CollectionDescriptor cds)
{
ObjectEnvelope envelope = vertex.getEnvelope();
Object col = cds.getPersistentField().get(envelope.getRealObject());
Object[] refObjects;
if (col == null || (ProxyHelper.isCollectionProxy(col) && !ProxyHelper.getCollectionProxy(col).isLoaded()))
{
refObjects = EMPTY_OBJECT_ARRAY;
}
else
{
refObjects = BrokerHelper.getCollectionArray(col);
}
Class refClass = cds.getItemClass();
for (int i = 0; i < vertices.length; i++)
{
Edge edge = null;
Vertex refVertex = vertices[i];
ObjectEnvelope refEnvelope = refVertex.getEnvelope();
if (refClass.isInstance(refEnvelope.getRealObject()))
{
if (containsObject(refEnvelope.getRealObject(), refObjects))
{
if (cds.isMtoNRelation())
{
edge = buildConcreteMNEdge(vertex, refVertex);
}
else
{
edge = buildConcrete1NEdge(vertex, refVertex);
}
}
else
{
if (cds.isMtoNRelation())
{
edge = buildPotentialMNEdge(vertex, refVertex);
}
else
{
edge = buildPotential1NEdge(vertex, refVertex);
}
}
}
if (edge != null)
{
if (!edgeList.contains(edge))
{
edgeList.add(edge);
}
else
{
edge.increaseWeightTo(edge.getWeight());
}
}
}
}