Package org.apache.sandesha2.storage.beans

Examples of org.apache.sandesha2.storage.beans.RMBean


        mgr.delete("Key1");
        assertNull(mgr.retrieve("Key1"));
    }

    public void testFind() throws SandeshaStorageException {
        mgr.insert(new InvokerBean("Key2", 1002, "SeqId2"));
        mgr.insert(new InvokerBean("Key3", 1003, "SeqId2"));

        InvokerBean bean = new InvokerBean();
        bean.setSequenceID("SeqId2");

        Iterator iter = mgr.find(bean).iterator();
        InvokerBean tmp = (InvokerBean) iter.next();

        if (tmp.getMessageContextRefKey().equals("Key2")) {
            tmp = (InvokerBean) iter.next();
            assertTrue(tmp.getMessageContextRefKey().equals("Key3"));
        } else {
            tmp = (InvokerBean) iter.next();
            assertTrue(tmp.getMessageContextRefKey().equals("Key2"));

        }
    }
View Full Code Here


        }
    }

    public void testInsert() throws SandeshaStorageException {
        mgr.insert(new InvokerBean("Key4", 1004, "SeqId4"));
        InvokerBean tmp = mgr.retrieve("Key4");
        assertTrue(tmp.getMessageContextRefKey().equals("Key4"));
    }
View Full Code Here

        assertTrue(tmp.getMessageContextRefKey().equals("Key4"));
    }

    public void testRetrieve() throws SandeshaStorageException {
        assertNull(mgr.retrieve("Key5"));
        mgr.insert(new InvokerBean("Key5", 1004, "SeqId5"));
        assertNotNull(mgr.retrieve("Key5"));
    }
View Full Code Here

        mgr.insert(new InvokerBean("Key5", 1004, "SeqId5"));
        assertNotNull(mgr.retrieve("Key5"));
    }

    public void testUpdate() throws SandeshaStorageException {
        InvokerBean bean = new InvokerBean("Key6", 1006, "SeqId6");
        mgr.insert(bean);
        bean.setMsgNo(1007);
        mgr.update(bean);
        InvokerBean tmp = mgr.retrieve("Key6");
        assertTrue(tmp.getMsgNo() == 1007);
    }
View Full Code Here

    }
    return true;
  }

  protected boolean delete(Object key) throws SandeshaStorageException {
    RMBean bean = null;
    synchronized (table) {
      bean = (RMBean) table.get(key);
    }
    if(bean != null) {
      mgr.enlistBean(bean);
View Full Code Here

    }
    return bean != null;
  }

  protected RMBean retrieve(Object key) throws SandeshaStorageException {
    RMBean bean = null;
    synchronized (table) {
      bean = (RMBean) table.get(key);
    }
    if(bean != null) {
      mgr.enlistBean(bean);
View Full Code Here

    return bean;
  }

  protected boolean update(Object key, RMBean bean) throws SandeshaStorageException {
    mgr.enlistBean(bean);
    RMBean oldBean = null;
    synchronized (table) {
      oldBean = (RMBean) table.get(key);
      table.put(key, bean);
    }
    if(oldBean == null) return false;
View Full Code Here

      if(matchInfo == null) {
        beans.addAll(table.values());
      } else {
        Iterator i = table.values().iterator();
        while(i.hasNext()) {
          RMBean candidate = (RMBean)i.next();
          if(candidate.match(matchInfo)) {
            beans.add(candidate);
          }
        }
      }
    }
   
    // Now we have a point-in-time view of the beans, lock them all
    Iterator i = beans.iterator();
    while(i.hasNext()) mgr.enlistBean((RMBean) i.next());
   
    // Finally remove any beans that are no longer in the table
    synchronized (table) {
      i = beans.iterator();
      while(i.hasNext()) {
        RMBean bean = (RMBean) i.next();
        if(!table.containsValue(bean)) {
          i.remove();
        }
      }
    }
View Full Code Here

    return beans;
  }

  protected RMBean findUnique (RMBean matchInfo) throws SandeshaException {
    RMBean result = null;
    synchronized (table) {
      Iterator i = table.values().iterator();
      while(i.hasNext()) {
        RMBean candidate = (RMBean)i.next();
        if(candidate.match(matchInfo)) {
          if(result == null) {
            result = candidate;
          } else {
            String message = SandeshaMessageHelper.getMessage(
                SandeshaMessageKeys.nonUniqueResult,
                result.toString(),
                candidate.toString());
            log.error(message);
            throw new SandeshaException (message);
          }
        }
      }
View Full Code Here

    if(log.isDebugEnabled()) log.debug("Entry: InMemoryTransaction::releaseLocks, " + this);
    manager.removeTransaction(this);

    Iterator beans = enlistedBeans.iterator();
    while(beans.hasNext()) {
      RMBean bean = (RMBean) beans.next();
      synchronized (bean) {
        bean.setTransaction(null);
        bean.notify();
      }
    }
    enlistedBeans.clear();
   
    if(log.isDebugEnabled()) log.debug("Exit: InMemoryTransaction::releaseLocks");
View Full Code Here

TOP

Related Classes of org.apache.sandesha2.storage.beans.RMBean

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.