db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject cvs commit: db-ojb/src/test/org/apache/ojb/broker/cache LocalCacheTest.java ObjectCacheTest.java
Date Fri, 04 Jun 2004 16:03:37 GMT
arminw      2004/06/04 09:03:37

  Added:       src/test/org/apache/ojb/broker/cache LocalCacheTest.java
                        ObjectCacheTest.java
  Log:
  - separate cache tests in own package
  - add first version of a circular relationship cache test
  
  Revision  Changes    Path
  1.1                  db-ojb/src/test/org/apache/ojb/broker/cache/LocalCacheTest.java
  
  Index: LocalCacheTest.java
  ===================================================================
  package org.apache.ojb.broker.cache;
  
  /* Copyright 2002-2004 The Apache Software Foundation
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  import java.util.ArrayList;
  import java.util.Collection;
  import java.util.Iterator;
  import java.util.List;
  
  import org.apache.ojb.broker.Identity;
  import org.apache.ojb.broker.metadata.ClassDescriptor;
  import org.apache.ojb.broker.metadata.MetadataException;
  import org.apache.ojb.broker.metadata.ObjectReferenceDescriptor;
  import org.apache.ojb.broker.query.Criteria;
  import org.apache.ojb.broker.query.Query;
  import org.apache.ojb.broker.query.QueryFactory;
  import org.apache.ojb.junit.PBTestCase;
  
  /**
   * Tests both caching level (LocalCache + real OjbjectCache) using circular
   * relationship tests.
   *
   * @author <a href="mailto:arminw@apache.org">Armin Waibel</a>
   * @version $Id: LocalCacheTest.java,v 1.1 2004/06/04 16:03:37 arminw Exp $
   */
  public class LocalCacheTest extends PBTestCase
  {
      private static final int CASCADE_NONE = ObjectReferenceDescriptor.CASCADE_NONE;
      private static final int CASCADE_LINK = ObjectReferenceDescriptor.CASCADE_LINK;
      private static final int CASCADE_OBJECT = ObjectReferenceDescriptor.CASCADE_OBJECT;
  
      public static void main(String[] args)
      {
          String[] arr = {LocalCacheTest.class.getName()};
          junit.textui.TestRunner.main(arr);
      }
  
      public void tearDown()
      {
          setReferenceMetadata(Person.class, "father", true, CASCADE_NONE, CASCADE_NONE, false);
          setReferenceMetadata(Person.class, "grandfather", true, CASCADE_NONE, CASCADE_NONE,
false);
          setReferenceMetadata(Person.class, "childs", true, CASCADE_NONE, CASCADE_NONE, false);
          setReferenceMetadata(Person.class, "grandchilds", true, CASCADE_NONE, CASCADE_NONE,
false);
          super.tearDown();
      }
  
      public void testCircularStore()
      {
          // prepare test
          setReferenceMetadata(Person.class, "father", true, CASCADE_OBJECT, CASCADE_OBJECT,
false);
          setReferenceMetadata(Person.class, "grandfather", true, CASCADE_OBJECT, CASCADE_OBJECT,
false);
          setReferenceMetadata(Person.class, "childs", true, CASCADE_OBJECT, CASCADE_OBJECT,
false);
          setReferenceMetadata(Person.class, "grandchilds", true, CASCADE_OBJECT, CASCADE_OBJECT,
false);
  
          String postfix = "_testCircularStore_" + System.currentTimeMillis();
          Person junior = createComplexFamily(postfix);
          broker.beginTransaction();
          broker.store(junior);
          broker.commitTransaction();
          Identity oidJunior = new Identity(junior, broker);
          Identity oidSenior = new Identity(junior.getFather(), broker);
          broker.clearCache();
  
          Criteria crit = new Criteria();
          crit.addLike("name", "jeffChild_%" + postfix);
          Query q = QueryFactory.newQuery(Person.class, crit);
  
          Person newJunior = (Person) broker.getObjectByIdentity(oidJunior);
          assertNotNull(newJunior);
          assertNotNull(newJunior.getFather());
          assertNotNull(newJunior.getChilds());
          assertEquals(2, newJunior.getChilds().size());
  
          Person newSenior = (Person) broker.getObjectByIdentity(oidSenior);
          assertNotNull(newSenior);
          assertNotNull(newSenior.getChilds());
          assertEquals(1, newSenior.getChilds().size());
          assertNotNull(newSenior.getGrandchilds());
          assertEquals(2, newSenior.getGrandchilds().size());
  
          Collection result = broker.getCollectionByQuery(q);
          assertEquals(2, result.size());
          for (Iterator iterator = result.iterator(); iterator.hasNext();)
          {
              Person p =  (Person)iterator.next();
              assertNotNull(p.getFather());
              assertEquals("jeffJunior"+postfix, p.getFather().getName());
              assertNotNull(p.getGrandfather());
              assertEquals("jeffSenior"+postfix, p.getGrandfather().getName());
          }
      }
  
      private void setReferenceMetadata(Class clazz, String reference, boolean autoretrieve,
int autoupdate, int autodelete, boolean useProxy)
      {
          ClassDescriptor cld = broker.getClassDescriptor(clazz);
          ObjectReferenceDescriptor ord = cld.getObjectReferenceDescriptorByName(reference);
          if(ord == null)
          {
              ord = cld.getCollectionDescriptorByName(reference);
          }
          if(ord == null)
          {
              throw new MetadataException("Reference with name '" + reference + "' does not
exist in " + clazz.getName());
          }
          ord.setCascadeRetrieve(autoretrieve);
          ord.setCascadingStore(autoupdate);
          ord.setCascadingDelete(autodelete);
          ord.setLazy(useProxy);
      }
  
      /**
       * Creates an circular object hierarchy
       */
      private Person createComplexFamily(String postfix)
      {
          Person jeffJunior = new Person();
          jeffJunior.setName("jeffJunior" + postfix);
  
          Person jeffSenior = new Person();
          jeffSenior.setName("jeffSenior" + postfix);
  
          Person jeffChild_1 = new Person();
          jeffChild_1.setName("jeffChild_1" + postfix);
          jeffChild_1.setFather(jeffJunior);
          jeffChild_1.setGrandfather(jeffSenior);
  
          Person jeffChild_2 = new Person();
          jeffChild_2.setName("jeffChild_2" + postfix);
          jeffChild_2.setFather(jeffJunior);
          jeffChild_2.setGrandfather(jeffSenior);
  
          jeffJunior.setFather(jeffSenior);
          jeffJunior.addChild(jeffChild_1);
          jeffJunior.addChild(jeffChild_2);
  
          jeffSenior.addChild(jeffJunior);
          jeffSenior.addGranschild(jeffChild_1);
          jeffSenior.addGranschild(jeffChild_2);
  
          return jeffJunior;
      }
  
      public static class Person
      {
          private Integer id;
          private String name;
          private Person father;
          private Person grandfather;
          private List childs;
          private List grandchilds;
          private Integer fkChild;
          private Integer fkGrandchild;
  
          public Person()
          {
          }
  
          public Person(String name, Person father, Person grandfather, List childs)
          {
              this.name = name;
              this.father = father;
              this.grandfather = grandfather;
              this.childs = childs;
          }
  
          public Integer getId()
          {
              return id;
          }
  
          public void setId(Integer id)
          {
              this.id = id;
          }
  
          public String getName()
          {
              return name;
          }
  
          public void setName(String name)
          {
              this.name = name;
          }
  
          public Person getFather()
          {
              return father;
          }
  
          public void setFather(Person father)
          {
              this.father = father;
          }
  
          public Person getGrandfather()
          {
              return grandfather;
          }
  
          public void setGrandfather(Person grandfather)
          {
              this.grandfather = grandfather;
          }
  
          public List getChilds()
          {
              return childs;
          }
  
          public void setChilds(List childs)
          {
              this.childs = childs;
          }
  
          public void addChild(Person child)
          {
              if(childs == null)
              {
                  childs = new ArrayList();
              }
              childs.add(child);
          }
  
          public List getGrandchilds()
          {
              return grandchilds;
          }
  
          public void setGrandchilds(List grandchilds)
          {
              this.grandchilds = grandchilds;
          }
  
          public void addGranschild(Person child)
          {
              if(grandchilds == null)
              {
                  grandchilds = new ArrayList();
              }
              grandchilds.add(child);
          }
  
          public Integer getFkChild()
          {
              return fkChild;
          }
  
          public void setFkChild(Integer fkChild)
          {
              this.fkChild = fkChild;
          }
  
          public Integer getFkGrandchild()
          {
              return fkGrandchild;
          }
  
          public void setFkGrandchild(Integer fkGrandchild)
          {
              this.fkGrandchild = fkGrandchild;
          }
      }
  }
  
  
  
  1.1                  db-ojb/src/test/org/apache/ojb/broker/cache/ObjectCacheTest.java
  
  Index: ObjectCacheTest.java
  ===================================================================
  package org.apache.ojb.broker.cache;
  
  import java.io.Serializable;
  import java.util.Properties;
  
  import junit.framework.TestCase;
  import org.apache.ojb.broker.Article;
  import org.apache.ojb.broker.Identity;
  import org.apache.ojb.broker.InterfaceArticle;
  import org.apache.ojb.broker.PBKey;
  import org.apache.ojb.broker.PersistenceBroker;
  import org.apache.ojb.broker.PersistenceBrokerFactory;
  import org.apache.ojb.broker.TestHelper;
  import org.apache.ojb.broker.metadata.ConnectionRepository;
  import org.apache.ojb.broker.metadata.MetadataManager;
  import org.apache.ojb.broker.metadata.MetadataTest;
  import org.apache.ojb.broker.query.QueryByIdentity;
  import org.apache.ojb.broker.sequence.Repository;
  import org.apache.ojb.broker.util.ClassHelper;
  import org.apache.ojb.broker.util.GUID;
  import org.apache.ojb.broker.util.configuration.impl.OjbConfiguration;
  import org.apache.ojb.broker.util.configuration.impl.OjbConfigurator;
  
  /**
   * Do some basic tests using ObjectCache implementations.
   *
   * @author <a href="mailto:armin@codeAuLait.de">Armin Waibel</a>
   * @author <a href="mailto:thma@apache.org">Thomas Mahler</a>
   * @version $Id: ObjectCacheTest.java,v 1.1 2004/06/04 16:03:37 arminw Exp $
   */
  public class ObjectCacheTest extends TestCase
  {
      static final String EXCLUDE_PACKAGE = "org.apache.ojb.broker.sequence";
      static final String EXCLUDE_PACKAGE_NOT_EXIST = "org.apache.ojb.broker.sequence.xyz";
  
      Class[] objectCacheImpls = new Class[]{
          // ObjectCacheEmptyImpl.class,
          ObjectCacheDefaultImpl.class,
          ObjectCacheLocalDefaultImpl.class,
          ObjectCachePerBrokerImpl.class,
          ObjectCacheJCSImpl.class,
          ObjectCacheJCSPerClassImpl.class,
          ObjectCachePerClassImpl.class
      };
  
      String[] cacheFilter = new String[]{
          CacheFilterClassImpl.class.getName(),
          CacheFilterPackageImpl.class.getName()
      };
      Class old_ObjectCache;
      String[] old_CacheFilter;
  
      public ObjectCacheTest(String s)
      {
          super(s);
      }
  
      public static void main(String[] args)
      {
          String[] arr = {ObjectCacheTest.class.getName()};
          junit.textui.TestRunner.main(arr);
      }
  
      protected void setUp() throws Exception
      {
          super.setUp();
          old_CacheFilter = getConfig().getCacheFilters();
          old_ObjectCache = ObjectCacheFactory.getInstance().getClassToServe();
      }
  
      protected void tearDown() throws Exception
      {
          super.tearDown();
          getConfig().setCacheFilters(old_CacheFilter);
          ObjectCacheFactory.getInstance().setClassToServe(old_ObjectCache);
          MetadataManager.getInstance().getRepository().
                  addAttribute(CacheFilterPackageImpl.EXCLUDE_PACKAGES, null);
      }
  
      private OjbConfiguration getConfig()
      {
          return (OjbConfiguration) OjbConfigurator.getInstance().getConfigurationFor(null);
      }
  
      /**
       * Test the JCS cache implementation. In JCS config file the following
       * properties are set:
       * <br/>
       * jcs.region.org.apache.ojb.broker.cache.ObjectCacheTest$CacheObject.cacheattributes.MaxObjects=3
       * jcs.region.org.apache.ojb.broker.cache.ObjectCacheTest$CacheObject.cacheattributes.MaxMemoryIdleTimeSeconds=2
       * jcs.region.org.apache.ojb.broker.cache.ObjectCacheTest$CacheObject.cacheattributes.UseMemoryShrinker=true
       * jcs.region.org.apache.ojb.broker.cache.ObjectCacheTest$CacheObject.cacheattributes.ShrinkerIntervalSeconds=1
       */
      public void testJCSPerClassObjectCacheImplementation() throws Exception
      {
          PersistenceBroker broker = PersistenceBrokerFactory.defaultPersistenceBroker();
          try
          {
              ObjectCache cache = new ObjectCacheJCSPerClassImpl(broker, null);
  
              CacheObject obj_1 = new CacheObject(null, "testJCSPerClassObjectCacheImplementation_1");
              Identity oid_1 = new Identity(obj_1, broker);
              CacheObject obj_2 = new CacheObject(null, "testJCSPerClassObjectCacheImplementation_2");
              Identity oid_2 = new Identity(obj_2, broker);
              CacheObject obj_3 = new CacheObject(null, "testJCSPerClassObjectCacheImplementation_2");
              Identity oid_3 = new Identity(obj_3, broker);
  
              cache.cache(oid_1, obj_1);
              cache.cache(oid_2, obj_2);
  
              // two objects should be found
              assertNotNull(cache.lookup(oid_1));
              assertNotNull(cache.lookup(oid_2));
              cache.cache(oid_3, obj_3);
              // we only allow two objects in cache region
              boolean bool = cache.lookup(oid_1) != null;
              bool = bool && cache.lookup(oid_2) != null;
              bool = bool && cache.lookup(oid_3) != null;
              assertFalse("We should not found all cached objects", bool);
              // idle time is 2 sec
              Thread.sleep(3500);
              assertNull(cache.lookup(oid_1));
              assertNull(cache.lookup(oid_2));
              assertNull(cache.lookup(oid_3));
  
          }
          catch (Exception e)
          {
              e.printStackTrace();
              throw e;
          }
          finally
          {
              if(broker != null) broker.close();
          }
      }
  
      public void testObjectCacheDefaultImplTimeout() throws Exception
      {
          TestObjectDefaultCache obj = new TestObjectDefaultCache();
          PersistenceBroker broker = PersistenceBrokerFactory.defaultPersistenceBroker();
          try
          {
              broker.beginTransaction();
              broker.store(obj);
              broker.commitTransaction();
  
              Identity oid = new Identity(obj, broker);
              obj = (TestObjectDefaultCache) broker.serviceObjectCache().lookup(oid);
              assertNotNull(obj);
  
              Thread.sleep(5000);
              obj = (TestObjectDefaultCache) broker.serviceObjectCache().lookup(oid);
              assertNull(obj);
          }
          finally
          {
              if(broker != null) broker.close();
          }
      }
  
      public void testObjectCacheDefaultImpl() throws Exception
      {
          String name = "testObjectCacheDefaultImpl_"+System.currentTimeMillis();
          TestObjectDefaultCache obj = new TestObjectDefaultCache();
          obj.setName(name);
          PersistenceBroker broker = PersistenceBrokerFactory.defaultPersistenceBroker();
          try
          {
              broker.beginTransaction();
              broker.store(obj);
              broker.commitTransaction();
  
              Identity oid = new Identity(obj, broker);
              obj = (TestObjectDefaultCache) broker.serviceObjectCache().lookup(oid);
              assertNotNull(obj);
              assertEquals(name, obj.getName());
  
              // modify name
              String new_name = "modified_"+name;
              obj.setName(new_name);
              obj = (TestObjectDefaultCache) broker.getObjectByIdentity(oid);
              assertNotNull(obj);
              assertEquals("current version of cache should return the modified object", new_name,
obj.getName());
  
              broker.removeFromCache(oid);
              obj = (TestObjectDefaultCache) broker.serviceObjectCache().lookup(oid);
              assertNull("Should be removed from cache", obj);
              obj = (TestObjectDefaultCache) broker.getObjectByIdentity(oid);
              assertNotNull(obj);
              assertEquals("Should return the unmodified object", name, obj.getName());
          }
          finally
          {
              if(broker != null) broker.close();
          }
      }
  
      /**
       * This test check the CacheFilter feature and the two standard implementations
       * enable per class and per package out-filtering of objects.
       * @throws Exception
       */
      public void testCacheFilterFunctions() throws Exception
      {
          PersistenceBrokerFactory.releaseAllInstances();
  
          try
          {
              getConfig().setCacheFilters(cacheFilter);
              MetadataManager.getInstance().getRepository().
                      addAttribute(CacheFilterPackageImpl.EXCLUDE_PACKAGES, EXCLUDE_PACKAGE);
              MetadataManager.getInstance().connectionRepository().getDescriptor(TestHelper.DEF_KEY).
                      addAttribute(CacheFilterPackageImpl.EXCLUDE_PACKAGES, EXCLUDE_PACKAGE_NOT_EXIST);
  
              PersistenceBroker broker = PersistenceBrokerFactory.defaultPersistenceBroker();
              try
              {
                  ObjectCache cache = broker.serviceObjectCache();
                  CacheObject obj = new CacheObject(null, "CacheObject persistent obj");
                  Identity oid = new Identity(obj, broker);
  
                  CacheObject filterOutObject = new CacheFilterObject(null, "CacheFilterObject
persistent obj");
                  Identity filterOutOid = new Identity(filterOutObject, broker);
  
                  Repository.SMKey filterOutPackageObject = new Repository.SMKey();
                  filterOutPackageObject.setName("ObjectCacheTest: package filter");
                  Identity filterOutPackageOid = new Identity(filterOutPackageObject, broker);
  
                  Object result = null;
                  cache.clear();
                  result = cache.lookup(oid);
                  assertNull(result);
                  result = cache.lookup(filterOutOid);
                  assertNull(result);
                  result = cache.lookup(filterOutPackageOid);
                  assertNull(result);
  
                  // cache it
                  cache.cache(oid, obj);
                  cache.cache(filterOutPackageOid, filterOutPackageObject);
                  cache.cache(filterOutOid, filterOutObject);
  
                  // lookup things
                  result = cache.lookup(oid);
                  assertNotNull(result);
                  assertEquals(obj, result);
                  result = cache.lookup(filterOutOid);
                  assertNull(result);
                  result = cache.lookup(filterOutPackageOid);
                  assertNull(result);
              }
              finally
              {
                  if (broker != null) broker.close();
              }
          }
          finally
          {
              PersistenceBrokerFactory.releaseAllInstances();
          }
      }
  
      /**
       * Check base caching functions of some cache implementations.
       *
       * @throws Exception
       */
      public void testSimpleObjectCacheFunctions() throws Exception
      {
          for (int i = 0; i < objectCacheImpls.length; i++)
          {
              PersistenceBroker broker = PersistenceBrokerFactory.defaultPersistenceBroker();
              try
              {
                  ObjectCache cache = (ObjectCache) ClassHelper.newInstance(
                              objectCacheImpls[i],
                              new Class[] {PersistenceBroker.class,Properties.class},
                              new Object[] {broker, null});
                  checkBaseFunctions(broker, cache);
              }
              finally
              {
                  if (broker != null) broker.close();
              }
          }
      }
  
  
      /**
       * Checks the base functions of the current ObjectCache implementation.
       *
       * @throws Exception
       */
      private void checkBaseFunctions(PersistenceBroker broker, ObjectCache cache) throws
Exception
      {
          CacheObject obj = new CacheObject(null, "ObjectCache test");
          Identity oid = new Identity(obj, broker);
          CacheObject obj2 = new CacheObject(null, "ObjectCache test 2");
          Identity oid2 = new Identity(obj2, broker);
          cache.clear();
          Object result = cache.lookup(oid);
          assertNull(result);
  
          cache.cache(oid, obj);
          cache.cache(oid2, obj2);
          result = cache.lookup(oid);
          assertNotNull(result);
          assertEquals(obj, result);
          assertNotSame(obj2, result);
  
          cache.remove(oid);
          result = cache.lookup(oid);
          Object result2 = cache.lookup(oid2);
          assertNull(result);
          assertNotNull(result2);
  
          cache.clear();
          result = cache.lookup(oid);
          assertNull(result);
          result = cache.lookup(oid2);
          assertNull(result);
          // cache.clear();
      }
  
      /**
       * Test per class ObjectCache declaration. 'TestObjectEmptyCache'
       * class metadata declare an 'empty ObjectCache' implementation
       * as cache, CacheObject use the default ObjectCache implementation.
       * Thus we should found 'CacheObject' instance in cache, but NOT found
       * 'TestObjectEmptyCache' instance.
       */
      public void testPerClassCache() throws Exception
      {
          String name = "testPerClassCache_" + System.currentTimeMillis();
  
          TestObjectEmptyCache obj = new TestObjectEmptyCache();
          obj.setName(name);
          CacheObject dummy = new CacheObject();
          dummy.setName(name);
  
          PersistenceBroker broker = PersistenceBrokerFactory.defaultPersistenceBroker();
          try
          {
              broker.beginTransaction();
              broker.store(obj);
              broker.store(dummy);
              broker.commitTransaction();
  
              Identity obj_oid = new Identity(obj, broker);
              Identity dummy_oid = new Identity(dummy, broker);
              ObjectCache cache = broker.serviceObjectCache();
              Object ret_obj = cache.lookup(obj_oid);
              Object ret_dummy = cache.lookup(dummy_oid);
              assertNotNull(ret_dummy);
              assertNull(ret_obj);
          }
          finally
          {
              if (broker != null && broker.isInTransaction()) broker.abortTransaction();
              if (broker != null) broker.close();
          }
      }
  
      /**
       * Read a specific jdbc-connction-descriptor at runtime, merge it with current
       * ConnectionRepository, lookup a specific PersistenceBroker instance, get ObjectCache.
       * This should be ObjectCacheEmptyImpl, because this is declared at jdbc-connection-descriptor
       * level.
       */
      public void testPerDatabaseCache()
      {
          ConnectionRepository cr = MetadataManager.getInstance()
                  .readConnectionRepository(MetadataTest.TEST_REPOSITORY);
          MetadataManager.getInstance().mergeConnectionRepository(cr);
  
          PersistenceBroker pb = PersistenceBrokerFactory.createPersistenceBroker(new PBKey("runtime_2"));
          try
          {
              ObjectCache oc = pb.serviceObjectCache();
              CacheObject testObj = new CacheObject(null, "testPerDatabaseCache");
              Identity oid = new Identity(testObj, pb);
              oc.cache(oid, testObj);
              Object result = oc.lookup(oid);
              assertNull("We should not found this object in cache", result);
          }
          finally
          {
              if (pb != null && !pb.isClosed()) pb.close();
              MetadataManager.getInstance().connectionRepository().removeDescriptor(cr.getAllDescriptor().get(0));
          }
      }
  
      /**
       * This test checks if the caches of two different brokers are properly isolated.
       * changes made to an object in tx1 should not be visible in tx2 !
       * TODO: once we work without global cache only (e.g. intern temporary cache), this
test should pass!
       */
      public void YYYtestCacheIsolation() throws Exception
      {
          Object[] pk = new Object[]{new Long(42)};
          Identity oid = new Identity(Article.class, InterfaceArticle.class, pk);
  
          GUID guid = new GUID();
  
          PersistenceBroker broker1 = PersistenceBrokerFactory.defaultPersistenceBroker();
          broker1.beginTransaction();
  
          Article a1 = (Article) broker1.getObjectByQuery(new QueryByIdentity(oid));
          String originalName = a1.getArticleName();
          a1.setArticleName(guid.toString());
  
  // start a second transaction
          PersistenceBroker broker2 = PersistenceBrokerFactory.defaultPersistenceBroker();
          broker2.beginTransaction();
  
          Article a2 = (Article) broker2.getObjectByQuery(new QueryByIdentity(oid));
  
          assertEquals(guid.toString(), a1.getArticleName());
          assertEquals(originalName, a2.getArticleName());
          assertNotSame(a1, a2);
  
  
          broker1.commitTransaction();
          broker1.close();
  
          broker2.commitTransaction();
          broker2.close();
      }
  
  
  
      // **********************************************************************
      // inner class
      // **********************************************************************
      public static class CacheObject implements Serializable
      {
          private Integer objId;
          private String name;
  
          public CacheObject(Integer objId, String name)
          {
              this.objId = objId;
              this.name = name;
          }
  
          public CacheObject()
          {
          }
  
          public Integer getObjId()
          {
              return objId;
          }
  
          public void setObjId(Integer objId)
          {
              this.objId = objId;
          }
  
          public String getName()
          {
              return name;
          }
  
          public void setName(String name)
          {
              this.name = name;
          }
      }
  
      /**
       * in class-descriptor CacheFilter attribute 'cacheable=false'
       * is declared
       */
      public static class CacheFilterObject extends CacheObject
      {
          public CacheFilterObject(Integer objId, String name)
          {
              super(objId, name);
          }
  
          public CacheFilterObject()
          {
          }
      }
  
      /**
       * in class-descriptor ObjectCacheEmptyImpl class is declared
       * as cache implementation.
       */
      public static class TestObjectEmptyCache
      {
          private Integer id;
          private String name;
  
          public TestObjectEmptyCache()
          {
          }
  
          public Integer getId()
          {
              return id;
          }
  
          public void setId(Integer id)
          {
              this.id = id;
          }
  
          public String getName()
          {
              return name;
          }
  
          public void setName(String name)
          {
              this.name = name;
          }
      }
  
      public static class TestObjectDefaultCache extends TestObjectEmptyCache
      {
      }
  }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message