/** {@inheritDoc} */
 @Override
 protected void writeActiveResource(IActiveResource resource, OutputStream outputStream)
     throws IOException {
   IBackendController backendController = BackendControllerHolder.getCurrentBackendController();
   AbstractBackendController slaveBackendController =
       (AbstractBackendController) backendController.createBackendController();
   AsyncActionExecutor executor =
       new AsyncActionExecutor(
           new AsyncExportAction(resource, outputStream),
           new HashMap<String, Object>(),
           null,
           slaveBackendController);
   // execute synchronously in the thread
   try {
     executor.run();
   } catch (RuntimeException ex) {
     if (ex.getCause() instanceof IOException) {
       throw (IOException) ex.getCause();
     } else {
       throw ex;
     }
   }
   // Do not cleanup the session backend controller since it can be used by a GUI thread. See bug
   // #75.
   // backendController.cleanupRequestResources();
 }
Ejemplo n.º 2
0
  /**
   * Saves the object(s) provided by the action context in a transaction.
   *
   * <p>{@inheritDoc}
   */
  @Override
  public boolean execute(IActionHandler actionHandler, final Map<String, Object> context) {

    List<IEntity> entitiesToSave = getEntitiesToSave(context);
    if (entitiesToSave != null) {
      IBackendController bc = getController(context);
      if (bc.isUnitOfWorkActive()) {
        entitiesToSave = bc.cloneInUnitOfWork(entitiesToSave);
      }
      for (IEntity entityToSave : entitiesToSave) {
        getController(context).registerForUpdate(entityToSave);
      }
    }

    getTransactionTemplate(context)
        .execute(
            new TransactionCallbackWithoutResult() {

              @Override
              protected void doInTransactionWithoutResult(TransactionStatus status) {
                try {
                  getController(context).performPendingOperations();
                } catch (RuntimeException ex) {
                  getController(context).clearPendingOperations();
                  throw ex;
                }
              }
            });
    return super.execute(actionHandler, context);
  }
Ejemplo n.º 3
0
 /** {@inheritDoc} */
 @Override
 protected boolean isLocallyDirty(IBackendController backendController) {
   boolean locallyDirty =
       backendController.isAnyDirtyInDepth(Collections.singleton(getModuleObject()));
   return locallyDirty;
 }