Examples of UnitOfWork


Examples of com.google.inject.persist.UnitOfWork

    Clusters fsm = mock(Clusters.class);
    Cluster oneClusterMock = mock(Cluster.class);
    Service serviceObj = mock(Service.class);
    ServiceComponent scomp = mock(ServiceComponent.class);
    ServiceComponentHost sch = mock(ServiceComponentHost.class);
    UnitOfWork unitOfWork = mock(UnitOfWork.class);
    when(fsm.getCluster(anyString())).thenReturn(oneClusterMock);
    when(oneClusterMock.getService(anyString())).thenReturn(serviceObj);
    when(serviceObj.getServiceComponent(anyString())).thenReturn(scomp);
    when(scomp.getServiceComponentHost(anyString())).thenReturn(sch);
    when(serviceObj.getCluster()).thenReturn(oneClusterMock);
View Full Code Here

Examples of com.vtence.tape.support.UnitOfWork

    @Test public void
    insertingANewRecord() throws Exception {
        final Product original = aProduct().withNumber("12345678").named("English Bulldog").describedAs("A muscular heavy dog").build();

        transactor.perform(new UnitOfWork() {
            public void execute() throws Exception {
                int inserted = Insert.into(products, original).execute(connection);
                assertThat("records inserted", inserted, is(1));
            }
        });
View Full Code Here

Examples of nexj.core.runtime.UnitOfWork

    * @see nexj.core.persistence.OIDGenerator#generateOID(Instance, nexj.core.persistence.PersistenceAdapter)
    */
   public OID generateOID(Instance instance, PersistenceAdapter adapter)
   {
      Table table = ((RelationalMapping)instance.getPersistenceMapping()).getPrimaryTable();
      UnitOfWork uow = instance.getUnitOfWork();
      Object key = new Pair(table, KEY);
      Object count = uow.getCachedLocal(key);

      if (count == null)
      {
         Column column = table.getPrimaryKey().getIndexColumn(0).getColumn();
         StringBuffer buf = new StringBuffer(128);

         buf.append("select max(");
         buf.append(column.getQuotedName());
         buf.append(") + 1 from ");
         buf.append(table.getQuotedName());

         SQLAdapter sqlAdapter = (SQLAdapter)adapter;
         SQLConnection connection = null;
         PreparedStatement stmt = null;
         ResultSet rs = null;

         try
         {
            connection = sqlAdapter.getConnection();
            stmt = connection.getConnection().prepareStatement(buf.toString());
            rs = sqlAdapter.executeQuery(stmt);
            rs.next();

            count = rs.getObject(1);

            if (count == null)
            {
               count = Primitive.ONE_INTEGER;
            }

            count = column.getType().convert(count);
         }
         catch (SQLException e)
         {
            throw sqlAdapter.getException(e, null, 0, 0);
         }
         finally
         {
            if (rs != null)
            {
               try
               {
                  rs.close();
               }
               catch (SQLException e)
               {
               }
            }

            if (stmt != null)
            {
               try
               {
                  stmt.close();
               }
               catch (SQLException e)
               {
               }
            }

            if (connection != null)
            {
               connection.decRef();
            }
         }
      }
      else
      {
         count = Primitive.add(count, Primitive.ONE_INTEGER);
      }

      uow.cacheLocal(key, count);

      return new OID(new Object[]{count});
   }
View Full Code Here

Examples of oracle.toplink.essentials.sessions.UnitOfWork

    super.beginTransaction(entityManager, definition);
    if (!definition.isReadOnly() && !this.lazyDatabaseTransaction) {
      // This is the magic bit. As with the existing Spring TopLink integration,
      // begin an early transaction to force TopLink to get a JDBC Connection
      // so that Spring can manage transactions with JDBC as well as TopLink.
      UnitOfWork uow = (UnitOfWork) getSession(entityManager);
      uow.beginEarlyTransaction();
    }
    // Could return the UOW, if there were any advantage in having it later.
    return null;
  }
View Full Code Here

Examples of oracle.toplink.publicinterface.UnitOfWork

    public MockClientSessionBroker() {
    }

    public UnitOfWork acquireUnitOfWork() {
      return new UnitOfWork(this);
    }
View Full Code Here

Examples of oracle.toplink.sessions.UnitOfWork

   * temporarily acquired UnitOfWork) and delegates to <code>doInUnitOfWork</code>.
   * @see #doInUnitOfWork(oracle.toplink.sessions.UnitOfWork)
   */
  public final Object doInTopLink(Session session) throws TopLinkException {
    // Fetch active UnitOfWork or acquire temporary UnitOfWork.
    UnitOfWork unitOfWork = session.getActiveUnitOfWork();
    boolean newUnitOfWork = false;
    if (unitOfWork == null) {
      unitOfWork = session.acquireUnitOfWork();
      newUnitOfWork = true;
    }

    // Perform callback operation, committing the UnitOfWork unless
    // it is the active UnitOfWork of an externally managed transaction.
    try {
      Object result = doInUnitOfWork(unitOfWork);
      if (newUnitOfWork) {
        unitOfWork.commit();
      }
      return result;
    }
    finally {
      if (newUnitOfWork) {
        unitOfWork.release();
      }
    }
  }
View Full Code Here

Examples of org.apache.camel.spi.UnitOfWork

     */
    public static Expression routeIdExpression() {
        return new ExpressionAdapter() {
            public Object evaluate(Exchange exchange) {
                String answer = null;
                UnitOfWork uow = exchange.getUnitOfWork();
                RouteContext rc = uow != null ? uow.getRouteContext() : null;
                if (rc != null) {
                    answer = rc.getRoute().getId();
                }
                if (answer == null) {
                    // fallback and get from route id on the exchange
View Full Code Here

Examples of org.apache.camel.spi.UnitOfWork

        if (exhausted) {
            Processor target = null;
            boolean deliver = true;

            // the unit of work may have an optional callback associated we need to leverage
            UnitOfWork uow = exchange.getUnitOfWork();
            if (uow != null) {
                SubUnitOfWorkCallback uowCallback = uow.getSubUnitOfWorkCallback();
                if (uowCallback != null) {
                    // signal to the callback we are exhausted
                    uowCallback.onExhausted(exchange);
                    // do not deliver to the failure processor as its been handled by the callback instead
                    deliver = false;
View Full Code Here

Examples of org.apache.camel.spi.UnitOfWork

            data.retryWhilePredicate = exceptionPolicy.getRetryWhilePolicy();
            data.useOriginalInMessage = exceptionPolicy.isUseOriginalMessage();

            // route specific failure handler?
            Processor processor = null;
            UnitOfWork uow = exchange.getUnitOfWork();
            if (uow != null && uow.getRouteContext() != null) {
                String routeId = uow.getRouteContext().getRoute().getId();
                processor = exceptionPolicy.getErrorHandler(routeId);
            } else if (!exceptionPolicy.getErrorHandlers().isEmpty()) {
                // note this should really not happen, but we have this code as a fail safe
                // to be backwards compatible with the old behavior
                log.warn("Cannot determine current route from Exchange with id: {}, will fallback and use first error handler.", exchange.getExchangeId());
View Full Code Here

Examples of org.apache.camel.spi.UnitOfWork

            log.trace("Failure processor {} is processing Exchange: {}", processor, exchange);

            // store the last to endpoint as the failure endpoint
            exchange.setProperty(Exchange.FAILURE_ENDPOINT, exchange.getProperty(Exchange.TO_ENDPOINT));
            // and store the route id so we know in which route we failed
            UnitOfWork uow = exchange.getUnitOfWork();
            if (uow != null && uow.getRouteContext() != null) {
                exchange.setProperty(Exchange.FAILURE_ROUTE_ID, uow.getRouteContext().getRoute().getId());
            }

            // the failure processor could also be asynchronous
            AsyncProcessor afp = AsyncProcessorConverterHelper.convert(processor);
            sync = afp.process(exchange, new AsyncCallback() {
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.