예제 #1
0
  /** {@inheritDoc} */
  public void init(String id, NamespaceResolver resolver) throws JournalException {

    super.init(id, resolver);

    init();

    try {
      conHelper = createConnectionHelper(getDataSource());

      // make sure schemaObjectPrefix consists of legal name characters only
      schemaObjectPrefix = conHelper.prepareDbIdentifier(schemaObjectPrefix);

      // check if schema objects exist and create them if necessary
      if (isSchemaCheckEnabled()) {
        createCheckSchemaOperation().run();
      }

      // Make sure that the LOCAL_REVISIONS table exists (see JCR-1087)
      if (isSchemaCheckEnabled()) {
        checkLocalRevisionSchema();
      }

      buildSQLStatements();
      initInstanceRevisionAndJanitor();
    } catch (Exception e) {
      String msg = "Unable to create connection.";
      throw new JournalException(msg, e);
    }
    log.info("DatabaseJournal initialized.");
  }
예제 #2
0
  /**
   * Write the current root block to the Journal and return its address to be stored in the
   * CommitRecord.
   */
  public long handleCommit(final long commitTime) {
    final IRootBlockView view = journal.getRootBlockView();

    final ByteBuffer rbv = view.asReadOnlyBuffer();
    /*
     * FIXME There is an API issue with the RWStore which does not allow
     * us to pass in a read-only buffer.  Write unit tests for this on
     * the core IRawStore test suite and fix the RWStore.  Also write
     * unit tests when the array backing the ByteBuffer can be accessed
     * but has a non-zero array offset (a mutable slice of a ByteBuffer).
     */
    //		return journal.write(rbv);
    final ByteBuffer bb = ByteBuffer.allocate(rbv.capacity());
    for (int i = 0; i < rbv.capacity(); i++) {
      bb.put(rbv.get());
    }
    bb.flip();

    return journal.write(bb);
  }