Codota Logo
Transaction.isActive
Code IndexAdd Codota to your IDE (free)

How to use
isActive
method
in
org.ldp4j.application.kernel.transaction.Transaction

Best Java code snippets using org.ldp4j.application.kernel.transaction.Transaction.isActive (Showing top 8 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
SimpleDateFormat s =
  • Codota IconString pattern;new SimpleDateFormat(pattern)
  • Codota IconString template;Locale locale;new SimpleDateFormat(template, locale)
  • Codota Iconnew SimpleDateFormat()
  • Smart code suggestions by Codota
}
origin: ldp4j/ldp4j

public void endTransaction(Transaction transaction) {
  if(transaction.isActive()) {
    transaction.rollback();
  }
  LOGGER.
    info("Completed transaction {}.{},",
      Thread.currentThread().getName(),
      transaction);
}
origin: ldp4j/ldp4j

/**
 * {@inheritDoc}
 */
@Override
public void close() throws SessionTerminationException {
  try {
    this.delegate.close();
  } finally {
    if(this.transaction.isActive()) {
      this.transaction.rollback();
    }
  }
}
origin: ldp4j/ldp4j

protected final void withinTransaction(Task<T> task) throws Exception{
  Transaction tx = txManager.currentTransaction();
  tx.begin();
  boolean failed=false;
  try {
    this.logger.info(">> Started '{}'...",task.title);
    task.execute(this.sut);
    tx.commit();
    this.logger.info(">> Completed '{}'.",task.title);
  } catch(Exception e) {
    this.logger.info(">> Failed '{}': {}.",task.title,e.getMessage());
    failed=true;
    throw e;
  } finally {
    if(failed) {
      this.logger.debug("Transaction failed [active: {}]",tx.isActive());
    }
    if(tx.isActive()) {
      this.logger.info("Attempting rollback...");
      try {
        tx.rollback();
      } catch (Exception e) {
        this.logger.error("Rollback failed",e);
      }
    }
  }
}
origin: ldp4j/ldp4j

public <T> T transactional(Callable<T> callable) throws Exception {
  Transaction transaction = RuntimeDelegate.getInstance().getTransactionManager().currentTransaction();
  transaction.begin();
  try {
    return callable.call();
  } catch(Exception e) {
    e.printStackTrace();
    throw e;
  } finally {
    try {
      assertThat(transaction.isActive(),equalTo(false));
    } catch (Exception e) {
      e.printStackTrace();
      transaction.rollback();
    }
  }
}
origin: ldp4j/ldp4j

private void commitSession(final Action action, final ResourceSnapshot resource) throws Exception {
  logAction(Stage.TERMINATION,action,resource);
  this.uow.accept(new UnitOfWorkInspector());
  this.sut.saveChanges();
  this.sut.close();
  assertThat(this.transaction.isActive(),equalTo(false));
}
origin: ldp4j/ldp4j

private void discardSession(final Action action, final ResourceSnapshot resource) throws Exception {
  logAction(Stage.TERMINATION,action,resource);
  this.uow.accept(new UnitOfWorkInspector());
  this.sut.discardChanges();
  this.sut.close();
  assertThat(this.transaction.isActive(),equalTo(false));
}
origin: ldp4j/ldp4j

private void initialize(Application<T> application) throws ApplicationConfigurationException {
  Transaction transaction=this.transactionManager.currentTransaction();
  transaction.begin();
  try {
    WriteSession session =
      writeSessionService().
        createSession(
          WriteSessionConfiguration.
            builder().
              build());
    Throwable failure=null;
    try {
      application.initialize(session);
    } catch (ApplicationInitializationException e) {
      failure=e;
    } finally {
      failure=closeQuietly(session, failure);
    }
    if(failure!=null) {
      throw new ApplicationConfigurationException(failure);
    }
  } finally {
    if(transaction.isActive()) {
      transaction.rollback();
    }
  }
}
origin: ldp4j/ldp4j

private Resource initialize(final String id, final String path) {
  final Transaction transaction=
    RuntimeDelegate.
      getInstance().
        getTransactionManager().
          currentTransaction();
  transaction.begin();
  try {
    this.uow = UnitOfWork.newCurrent();
    final Resource resource=
      this.modelFactory.createResource(
        this.templateManagementService.templateOfId("personTemplate"),
        name(id));
    final Endpoint endpoint=this.modelFactory.createEndpoint(path,resource,new Date(),EntityTag.createStrong(path));
    RuntimeDelegate.getInstance().getResourceRepository().add(resource);
    RuntimeDelegate.getInstance().getEndpointRepository().add(endpoint);
    UnitOfWork.setCurrent(null);
    transaction.commit();
    return resource;
  } finally {
    if(transaction.isActive()) {
      transaction.rollback();
    }
  }
}
org.ldp4j.application.kernel.transactionTransactionisActive

Javadoc

Check whether the transaction is active, that is, started and not completed.

Popular methods of Transaction

  • begin
    Start the transaction
  • commit
    Complete the transaction by commiting the changes
  • rollback
    Complete the transaction by discarding the changes

Popular in Java

  • Creating JSON documents from java classes using gson
  • onRequestPermissionsResult (Fragment)
  • getApplicationContext (Context)
  • getContentResolver (Context)
  • FlowLayout (java.awt)
    A flow layout arranges components in a left-to-right flow, much like lines of text in a paragraph. F
  • FileReader (java.io)
    A specialized Reader that reads from a file in the file system. All read requests made by calling me
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • Deque (java.util)
    A linear collection that supports element insertion and removal at both ends. The name deque is shor
  • Timer (java.util)
    A facility for threads to schedule tasks for future execution in a background thread. Tasks may be s
  • Option (scala)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now