ofbiz实体引擎(二) delegator实例化具体方式

本文深入探讨了OFBiz实体引擎中的Delegator实例化过程,通过具体的代码示例,详细解析了如何在应用程序中创建和使用Delegator对象。这对于理解和操作OFBiz的数据层至关重要。
摘要由CSDN通过智能技术生成
/**
     * @author 郑小康
     * 采用spi创建对应实例DelegatorFactoryImpl
     * */
    public static <A, R> R getObjectFromFactory(Class<? extends Factory<R, A>> factoryInterface, A obj) throws ClassNotFoundException {
        Iterator<? extends Factory<R, A>> it = ServiceLoader.load(factoryInterface).iterator();
        while (it.hasNext()) {
            Factory<R, A> factory = it.next();
            R instance = factory.getInstance(obj);
            if (instance != null) {
                return instance;
            }
        }
        throw new ClassNotFoundException(factoryInterface.getClass().getName());
    }


      注:上下代码不是在一个类

/**
 * @author 郑小康
 * 根据delegatorName创建一个GenericDelegator
 * 所以实际delegator引用的是一个GenericDelegator实例
 * */
public class DelegatorFactoryImpl extends Delega
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值