当前位置: 首页>>代码示例>>Java>>正文


Java ProxyHelper.isCollectionProxy方法代码示例

本文整理汇总了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);
                }
            }
        }
    }
}
 
开发者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: 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

示例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();
}
 
开发者ID:aapotts,项目名称:kuali_rice,代码行数:23,代码来源:ObjectUtils.java

示例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());
            }
        }
    }
}
 
开发者ID:KualiCo,项目名称:ojb,代码行数:66,代码来源:ObjectEnvelopeOrdering.java


注:本文中的org.apache.ojb.broker.core.proxy.ProxyHelper.isCollectionProxy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。