Examples of IExclusiveDataAccessSession


Examples of net.sf.joafip.service.IExclusiveDataAccessSession

    builder.setMaxInMemoryThreshold(1000);
    builder.setMaintenedInMemory(false);
    // builder.setMaintenedInMemoryQuota(100);
    final IFilePersistence filePersistence = builder.build();
    filePersistence.setAutoSaveEventListener(this);
    final IExclusiveDataAccessSession session = filePersistence
        .createExclusiveDataAccessSession();
    final IInstanceFactory instanceFactory = session.getInstanceFactory();

    session.open();
    final Tree<String> tree = Tree.newInstance(instanceFactory);
    appendLoop(tree);
    session.close();
    filePersistence.close();
  }
View Full Code Here

Examples of net.sf.joafip.service.IExclusiveDataAccessSession

    // final int maxObjectState = 1000 * 5;
    // win seven
    final int maxObjectState = 100 * 1000;
    saveCount = 0;
    final int max = 100000;
    final IExclusiveDataAccessSession session = filePersistence
        .createExclusiveDataAccessSession();
    session.open();

    List<Integer> bigList;
    final IInstanceFactory instanceFactory = session.getInstanceFactory();
    bigList = PLinkedList.newInstance(instanceFactory);

    assertTrue("must be a proxy", ProxyManager2.isProxyOrEnhanced(bigList));
    // instance, proxy attached to persistence
    int count;
    for (count = 0; count < 5; count++) {
      final int value = aValue(count);
      saveDone = false;
      bigList.add(value); // this not make bigList growing in memory
      // because of auto save
      assertTrue("must save", saveDone);
    }
    filePersistence.autoSaveSetup(1000);
    for (; count < max; count++) {
      final int value = aValue(count);
      saveDone = false;
      bigList.add(value); // this not make bigList growing in memory
      if (saveDone) {
        assertTrue("must be unloaded, count=" + count,
            ProxyManager2.isUnloaded(bigList));
        if (LOGGER.debugEnabled) {
          final String stateMessage = HelperTestHugeList
              .objectState(filePersistence);
          LOGGER.debug(stateMessage);
        }
        final int numberOfObjectState = filePersistence
            .getNumberOfObjectState();
        assertTrue("too much object state " + numberOfObjectState
            + ", count #" + count,
            numberOfObjectState < maxObjectState);
      }
    }
    session.save();
    assertFalse("must not be loaded",
        ProxyManager2.proxiedObjectIsLoaded(bigList));
    LOGGER.debug("--- save count " + saveCount);// NOPMD
    LOGGER.debug("--- set object ---");// NOPMD
    session.setObject("myBigList", bigList);
    LOGGER.debug("--- save ---");// NOPMD
    bigList = null; // NOPMD no more reference the big list
    session.save(); // after this the garbage collector can free memory
    // of
    // the big list
    LOGGER.debug("--- iterate ---");// NOPMD
    bigList = (List<Integer>) session.getObject("myBigList"); // witchery
    // of
    // lazy load
    // : all the
    // big list
    // is not
    // loaded in
    // memory
    count = 0;
    for (final int value : bigList) {
      doSomething(value);
      count++;
    }
    LOGGER.debug("--- clone ---");// NOPMD
    final Object bigListClone = ((PLinkedList<Integer>) bigList).clone();
    session.setObject("myClone", bigListClone);
    session.close();
    assertTrue("object state map never cleaned", decreaseCount > 0);
    LOGGER.debug("object state map decrease count=" + decreaseCount);
  }
View Full Code Here

Examples of net.sf.joafip.service.IExclusiveDataAccessSession

    builder.setProxyMode(true);
    final IFilePersistence filePersistence = builder.build();
    filePersistence.setAutoSaveEnabled(true);
    // 0 for immediate saving
    filePersistence.autoSaveSetup(0);
    final IExclusiveDataAccessSession session = filePersistence
        .createExclusiveDataAccessSession();
    session.open();
    final IInstanceFactory instanceFactory = session.getInstanceFactory();

    final Element element = Element.newInstance(instanceFactory);
    element.addNameSpace(HELLO);
    final Element clone = element.clone();
    List<String> list = clone.getAdditionalNamespaces();
    assertEquals(BAD_CONTENT, HELLO, list.get(0));
    list = clone.getAdditionalNamespacesList();
    assertEquals(BAD_CONTENT, HELLO, list.get(0));

    session.close();
    filePersistence.close();
  }
View Full Code Here

Examples of net.sf.joafip.service.IExclusiveDataAccessSession

    builder.setProxyMode(true);
    final IFilePersistence filePersistence = builder.build();
    filePersistence.setAutoSaveEnabled(true);
    // 0 for immediate saving
    filePersistence.autoSaveSetup(0);
    final IExclusiveDataAccessSession session = filePersistence
        .createExclusiveDataAccessSession();
    session.open();
    final IInstanceFactory instanceFactory = session.getInstanceFactory();

    try {
      ElementKo.newInstance(instanceFactory);
      fail("must fail because of method ElementKo#setAdditionnalNamespaces");
    } catch (Exception exception) {
      Throwable current = exception;
      while (current != null
          && !EnhanceException.class.equals(current.getClass())) {
        current = current.getCause();
      }
      if (current == null) {
        fail("EnhanceException expected");
      }
    }

    // element.addNameSpace(HELLO);
    // final ElementKo clone = element.clone();
    //
    // List<String> list = clone.getAdditionalNamespaces();
    // assertEquals(BAD_CONTENT, HELLO, list.get(0));
    // list = clone.getAdditionalNamespacesList();
    // assertEquals(BAD_CONTENT, HELLO, list.get(0));

    session.close();
    filePersistence.close();
  }
View Full Code Here

Examples of net.sf.joafip.service.IExclusiveDataAccessSession

      FilePersistenceClassNotFoundException,
      FilePersistenceInvalidClassException,
      FilePersistenceDataCorruptedException,
      FilePersistenceNotSerializableException,
      FilePersistenceTooBigForSerializationException {
    final IExclusiveDataAccessSession session = filePersistence
        .createExclusiveDataAccessSession();

    final IInstanceFactory instanceFactory = session.getInstanceFactory();
    session.open();
    final Set<String> set = PTreeSet.newInstance(instanceFactory);
    set.add(ID_KEY_NAME);
    set.add(TYPE_KEY_NAME);
    final Iterator<String> iterator = set.iterator();
    assertTrue("must has first element", iterator.hasNext());
View Full Code Here

Examples of net.sf.joafip.service.IExclusiveDataAccessSession

      FilePersistenceClassNotFoundException,
      FilePersistenceInvalidClassException,
      FilePersistenceDataCorruptedException,
      FilePersistenceNotSerializableException,
      FilePersistenceTooBigForSerializationException {
    final IExclusiveDataAccessSession session = filePersistence
        .createExclusiveDataAccessSession();

    final IInstanceFactory instanceFactory = session.getInstanceFactory();
    session.open();
    final Map<String, String> map = PTreeMap.newInstance(instanceFactory);
    map.put(ID_KEY_NAME, ID_KEY_NAME);
    map.put(TYPE_KEY_NAME, TYPE_KEY_NAME);
    final Iterator<Entry<String, String>> iterator = map.entrySet()
        .iterator();
View Full Code Here

Examples of net.sf.joafip.service.IExclusiveDataAccessSession

    builder.setAutoSaveEnabled(true);
    builder.setMaxInMemoryThreshold(1000);
    builder.setMaintenedInMemory(false);
    // builder.setMaintenedInMemoryQuota(100);
    final IFilePersistence filePersistence = builder.build();
    final IExclusiveDataAccessSession session = filePersistence
        .createExclusiveDataAccessSession();
    final IInstanceFactory instanceFactory = session.getInstanceFactory();

    session.open();
    final Tree<String> tree = Tree.newInstance(instanceFactory);
    appendLoop(tree);
    session.close();
    filePersistence.close();
  }
View Full Code Here

Examples of net.sf.joafip.service.IExclusiveDataAccessSession

    builder.setAutoSaveEnabled(true);
    builder.setMaxInMemoryThreshold(1000);
    builder.setMaintenedInMemory(false);
    // builder.setMaintenedInMemoryQuota(100);
    final IFilePersistence filePersistence = builder.build();
    final IExclusiveDataAccessSession session = filePersistence
        .createExclusiveDataAccessSession();
    final IInstanceFactory instanceFactory = session.getInstanceFactory();

    session.open();
    final Tree<String> tree = Tree.newInstance(instanceFactory);
    appendLoop(tree);
    session.close();
    filePersistence.close();
  }
View Full Code Here

Examples of net.sf.joafip.service.IExclusiveDataAccessSession

    builder.setMaxInMemoryThreshold(1000);
    builder.setMaintenedInMemory(false);
    // builder.setMaintenedInMemoryQuota(100);
    final IFilePersistence filePersistence = builder.build();
    filePersistence.setAutoSaveEventListener(this);
    final IExclusiveDataAccessSession session = filePersistence
        .createExclusiveDataAccessSession();
    final IInstanceFactory instanceFactory = session.getInstanceFactory();

    session.open();
    final Tree<String> tree = Tree.newInstance(instanceFactory);
    appendLoop(tree);
    session.close();
    filePersistence.close();
  }
View Full Code Here

Examples of net.sf.joafip.service.IExclusiveDataAccessSession

    builder.setMaxInMemoryThreshold(1000);
    builder.setMaintenedInMemory(false);
    // builder.setMaintenedInMemoryQuota(100);
    final IFilePersistence filePersistence = builder.build();
    filePersistence.setAutoSaveEventListener(this);
    final IExclusiveDataAccessSession session = filePersistence
        .createExclusiveDataAccessSession();
    final IInstanceFactory instanceFactory = session.getInstanceFactory();

    session.open();
    final Tree<String> tree = Tree.newInstance(instanceFactory);
    appendLoop(tree);
    session.close();
    filePersistence.close();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.