001/**
002 * Copyright 2005-2016 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.kuali.rice.krad.dao.impl;
017
018import org.apache.ojb.broker.Identity;
019import org.apache.ojb.broker.core.IdentityFactoryImpl;
020import org.apache.ojb.broker.core.proxy.IndirectionHandlerCGLIBImpl;
021import org.apache.ojb.broker.core.proxy.ProxyHelper;
022import org.kuali.rice.core.framework.persistence.ojb.dao.PlatformAwareDaoBaseOjb;
023import org.kuali.rice.krad.dao.PersistenceDao;
024
025public class PersistenceDaoOjb extends PlatformAwareDaoBaseOjb implements PersistenceDao {
026
027    /**
028     * @see org.kuali.rice.krad.dao.PersistenceDao#clearCache()
029     */
030    public void clearCache() {
031        getPersistenceBroker(true).clearCache();
032    }
033
034    /**
035     * @see org.kuali.rice.krad.dao.PersistenceDao#resolveProxy(java.lang.Object)
036     */
037    public Object resolveProxy(Object o) {
038        Identity ident = new IdentityFactoryImpl(getPersistenceBroker(true)).buildIdentity(o);
039        IndirectionHandlerCGLIBImpl ih = new IndirectionHandlerCGLIBImpl(getPersistenceBroker(true).getPBKey(), ident);
040        return ih.getRealSubject();
041    }
042
043    /**
044     * @see org.kuali.rice.krad.dao.PersistenceDao#retrieveAllReferences(java.lang.Object)
045     */
046    public void retrieveAllReferences(Object o) {
047        getPersistenceBroker(true).retrieveAllReferences(o);
048    }
049
050    /**
051     * @see org.kuali.rice.krad.dao.PersistenceDao#retrieveReference(java.lang.Object, java.lang.String)
052     */
053    public void retrieveReference(Object o, String referenceName) {
054        getPersistenceBroker(true).retrieveReference(o, referenceName);
055    }
056
057        /**
058         * Asks ProxyHelper if the object is proxied
059         * 
060         * @see org.kuali.rice.krad.dao.PersistenceDao#isProxied(java.lang.Object)
061         */
062        public boolean isProxied(Object object) {
063                return ProxyHelper.isProxy(object);
064        }
065 
066}