/*
 * JBoss, Home of Professional Open Source
 * Copyright 2005, JBoss Inc., and individual contributors as indicated
 * by the @authors tag. See the copyright.txt in the distribution for a
 * full listing of individual contributors.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */
package org.jboss.cache.loader;

import java.util.Map;
import java.util.Properties;
import java.util.Set;

import org.jboss.cache.TreeCache;
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;

/**
 * DelegatingCacheLoader implementation which delegates to a local (in the same VM) TreeCache. Sample code:
 * <pre>
 * TreeCache firstLevel=new TreeCache();
 * TreeCache secondLevel=new TreeCache();
 * DelegatingCacheLoader l=new DelegatingCacheLoader(secondLevel);
 * l.setCache(firstLevel);
 * firstLevel.setCacheLoader(l);
 * secondLevel.start();
 * firstLevel.start();
 * </pre>
 * @author Bela Ban
 * @author Daniel Gredler
 * @version $Id: LocalDelegatingCacheLoader.java,v 1.1.4.2 2005/12/01 19:48:41 dimitris Exp $
 */
public class LocalDelegatingCacheLoader extends DelegatingCacheLoader {

   TreeCache delegate=null;

   public LocalDelegatingCacheLoader(TreeCache delegate) {
      this.delegate=delegate;
   }

   public void setConfig(Properties props) {
      throw new UnsupportedOperationException();
   }

   public void setCache(TreeCache cache) {
      // Empty.
   }

   protected Set delegateGetChildrenNames(Fqn fqn) throws Exception {
      return delegate.getChildrenNames(fqn);
   }

   protected Object delegateGet(Fqn name, Object key) throws Exception {
      return delegate.get(name, key);
   }

   protected Node delegateGet(Fqn name) throws Exception {
      return delegate.get(name);
   }

   protected boolean delegateExists(Fqn name) throws Exception {
      return delegate.exists(name);
   }

   protected Object delegatePut(Fqn name, Object key, Object value) throws Exception {
      return delegate.put(name, key, value);
   }

   protected void delegatePut(Fqn name, Map attributes) throws Exception {
      delegate.put(name, attributes);
   }

   protected Object delegateRemove(Fqn name, Object key) throws Exception {
      return delegate.remove(name, key);
   }

   protected void delegateRemove(Fqn name) throws Exception {
      delegate.remove(name);
   }

   protected void delegateRemoveData(Fqn name) throws Exception {
      delegate.removeData(name);
   }

   protected byte[] delegateLoadEntireState() throws Exception {
      return delegate.getStateBytes();
   }

   protected void delegateStoreEntireState(byte[] state) throws Exception {
      delegate.setStateBytes(state);
   }

}
