TransactionState(final String ctx) {
   this.startTime = System.currentTimeMillis();
   this.txUuid = String.format("%s:%s", ctx, UUID.randomUUID().toString());
   this.stopWatch = new StopWatch();
   this.stopWatch.start();
   this.owner = Logs.isExtrrreeeme() ? Threads.currentStackString() : "n/a";
   try {
     this.eventLog(TxStep.BEGIN, TxEvent.CREATE);
     final EntityManagerFactory anemf =
         (EntityManagerFactoryImpl) PersistenceContexts.getEntityManagerFactory(ctx);
     checkParam(anemf, notNullValue());
     this.em = anemf.createEntityManager();
     checkParam(this.em, notNullValue());
     this.transaction = this.em.getTransaction();
     this.transaction.begin();
     this.session = new WeakReference<Session>((Session) this.em.getDelegate());
     this.eventLog(TxStep.END, TxEvent.CREATE);
   } catch (final Throwable ex) {
     Logs.exhaust().error(ex, ex);
     this.eventLog(TxStep.FAIL, TxEvent.CREATE);
     this.rollback();
     throw new RuntimeException(PersistenceExceptions.throwFiltered(ex));
   } finally {
     outstanding.put(this.txUuid, this);
   }
 }
 public String getMessage() {
   if (Logs.isExtrrreeeme()) {
     return Threads.currentStackString();
   } else {
     return "n.a";
   }
 }
Exemple #3
0
 public static WebServicesException notFound(String message, Throwable... t) {
   if (Logs.isExtrrreeeme() && t != null && t.length > 0) {
     return new ServiceDispatchException(message + "\n" + string(message, t[0]));
   } else {
     return new ServiceDispatchException(message);
   }
 }
Exemple #4
0
 /** * @param message * @return */
 public static RuntimeException noSuchElement(String message, Throwable... t) {
   if (Logs.isExtrrreeeme() && t != null && t.length > 0) {
     return new NoSuchElementException(message + "\n" + string(message, t[0]));
   } else {
     return new NoSuchElementException(message);
   }
 }
Exemple #5
0
 static FilteredPipeline find(final HttpRequest request)
     throws DuplicatePipelineException, NoAcceptingPipelineException {
   final FilteredPipeline candidate = findAccepting(request);
   if (candidate == null) {
     if (Logs.isExtrrreeeme()) {
       if (request instanceof MappingHttpMessage) {
         ((MappingHttpMessage) request).logMessage();
         for (final FilteredPipeline p : pipelines) {
           LOG.debug("PIPELINE: " + p);
         }
         for (final FilteredPipeline p : internalPipelines) {
           LOG.debug("PIPELINE: " + p);
         }
       }
     }
     throw new NoAcceptingPipelineException();
   }
   if (Logs.isExtrrreeeme()) {
     EventRecord.here(Pipelines.class, EventType.PIPELINE_UNROLL, candidate.toString()).extreme();
   }
   return candidate;
 }
 private final void eventLog(final TxStep txState, final TxEvent txAction) {
   if (Logs.isExtrrreeeme()) {
     final long oldSplit = this.splitTime;
     this.stopWatch.split();
     this.splitTime = this.stopWatch.getSplitTime();
     this.stopWatch.unsplit();
     final Long split = this.splitTime - oldSplit;
     Logs.exhaust()
         .debug(
             Joiner.on(":")
                 .join(
                     EventType.PERSISTENCE,
                     txState.event(txAction),
                     Long.toString(split),
                     this.getTxUuid()));
   }
 }
 @Override
 public String toString() {
   return String.format(
       "TxHandle:txUuid=%s:startTime=%s:splitTime=%s:owner=%s",
       this.txUuid, this.startTime, this.splitTime, Logs.isExtrrreeeme() ? this.owner : "n/a");
 }