Package net.helipilot50.stocktrade.framework

Examples of net.helipilot50.stocktrade.framework.AppContextHolder


    public static AppContextHolder performServerCall(Anchorable wrappedObject, String methodName, Method invokedMethod, Object[] args, Map<String, Object>appContext) throws Throwable {

        _log.debug("Invoking: " + methodName);
       
        String txnId = (String)appContext.get(TXN_ID);
        AppContextHolder response;
        if (txnId != null) {
          appContext.remove(TXN_ID);
         
          // We need to see if there's a transaction id, and if there is then get the thread that owns this id and then set up the transaction data.
          ManagedThread thread = getThreadForTxn(txnId);

          // This is in a distributed transaction, we must use the other thread (which must be waiting)
          thread.initialiseForCall(appContext, methodName, invokedMethod, args, wrappedObject, txnId);
          thread.executeCall();
        if (thread.exception != null) {
          response = new AppContextHolder(new AttributedException(thread.exception, thread.wasAborted));
        }
        else {
          response = thread.response;
        }
            response.setParameter(WAS_ABORTED, Boolean.valueOf(thread.wasAborted));
        }
        else {
            FrameworkUtils.setAppContextValues(appContext);
          Object result = invokedMethod.invoke(wrappedObject, args);

            response = new AppContextHolder(result);
            postProcessParameters(response, invokedMethod, args);
        }

      return response;
    }
View Full Code Here


            else {
              // This must be using a service proxy
                    FrameworkUtils.setAppContextValues(appContext);
                      if (proxyMethodName.equals(COMMIT_TXN)) {
                    TransactionMgr.commitTransaction();
                    response = new AppContextHolder("Commit successful");
                    terminateThread = true;
                  }
                  else if (proxyMethodName.equals(ROLLBACK_TXN)) {
                    TransactionMgr.rollbackTransaction();
                    response = new AppContextHolder("Rollback successful");
                    terminateThread = true;
                  }
                  else if (proxyMethodName.equals(ABORT_TXN)) {
                    TransactionMgr.abort();
                    response = new AppContextHolder("Abort successful");
                    terminateThread = true;
                  }
                  else {
                      response = new AppContextHolder(invokedMethod.invoke(wrappedObject, args));
                      postProcessParameters(response, invokedMethod, args);
                  }
                      wasAborted = TransactionMgr.isAborted();
            }
              }
View Full Code Here

        Method invokedMethod = MethodMapper.getMethod(this.wrappedObject.getClass(), methodId);
        _log.debug("Invoking method " + invokedMethod + " on server");
       
        FrameworkUtils.setAppContextValues(appContext);
      Object result = invokedMethod.invoke(this.wrappedObject, args);
        AppContextHolder response = new AppContextHolder(result);

        // Now, for any input, output, etc annotated parameters, copy their values back
      Set<Integer> parameterIndicies = MethodMapper.getOutputParameters(invokedMethod);
      for (Integer parameterIndex : parameterIndicies) {
            response.setParameter("arg" + parameterIndex, args[parameterIndex]);
      }

        return response;
    }
View Full Code Here

    private Object invoke(String methodName, Method method, Object...args) {
        try {
            _log.debug("Beginning invocation of: " + methodName + " on " + delegate);
            Map<String, Object> appContextValues = FrameworkUtils.getAppContextValues();
            TransactionMgr.beginRemoteCall(this, appContextValues);
            AppContextHolder result = delegate.invoke(this.objectName, methodName, args, appContextValues);

            TransactionMgr.endRemoteCall(result);
           
            _log.debug("Ending invocation of: " + methodName + " on " + delegate);
            /*
             * Now unpack any parameters
             */
            if (method != null) {
              Set<Integer> parameterIndicies = MethodMapper.getOutputParameters(method);
              for (Integer parameterIndex : parameterIndicies) {
                    Object outputParam = result.getParameter("arg" + parameterIndex);
                    if (outputParam instanceof ParameterHolder) {
                        ((ParameterHolder)outputParam).duplicateIntoTarget(((ParameterHolder)args[parameterIndex]), false);
                    } else {
                        CloneHelper.duplicateIntoTarget(outputParam, args[parameterIndex], false);
                    }
              }
            }
            return result.get();
        }
        catch (SocketException se) {
          throw new RemoteAccessException(se);
        }
        catch (RemoteException re) {
View Full Code Here

              cachedRowSet.updateBoolean(pColOrdinal, value.getBooleanValue());
            } else if (pValue instanceof DateTimeData) {
              DateTimeData value = (DateTimeData) pValue;
              cachedRowSet.updateDate(pColOrdinal, new Date(value.asDate().getTime()));
            } else if (pValue instanceof BinaryData) {
              BinaryData value = (BinaryData) pValue;
              cachedRowSet.updateBinaryStream(pColOrdinal, new ByteArrayInputStream(value.getValue()), value.getActualSize());
            }
          } catch (SQLException e) {
            UsageException errorVar = new UsageException(e.getMessage(), net.helipilot50.stocktrade.framework.Constants.SP_ER_USER, net.helipilot50.stocktrade.framework.Constants.SP_ER_PARAMETERERROR, e);
            ErrorMgr.addError(errorVar);
            throw errorVar;
View Full Code Here

    // We're already closed, just discard the result set if any
    resultSet = null;
  }
 
  public boolean execute() throws SQLException {
    final BooleanData result = new BooleanData();
    useRealStatement(new StatementWorker() {
      public void doWork(PreparedStatement ps) throws SQLException {
        result.setValue(ps.execute());
       
        // Now get the results sets and remember them
        populateResults(ps, result.getValue());
      }
    });
    return result.getValue();
  }
View Full Code Here

    });
    return updateCount;
  }

  public boolean execute(final String sql) throws SQLException {
    final BooleanData result = new BooleanData();
    useRealStatement(new StatementWorker() {
      public void doWork(PreparedStatement ps) throws SQLException {
        result.setValue(ps.execute(sql));
       
        // Now get the results sets and remember them
        populateResults(ps, result.getValue());
      }
    });
    return result.getValue();
  }
View Full Code Here

    });
    return result.getValue();
  }

  public boolean execute(final String sql, final int autoGeneratedKeys) throws SQLException {
    final BooleanData result = new BooleanData();
    useRealStatement(new StatementWorker() {
      public void doWork(PreparedStatement ps) throws SQLException {
        result.setValue(ps.execute(sql, autoGeneratedKeys));
       
        // Now get the results sets and remember them
        populateResults(ps, result.getValue());
      }
    });
    return result.getValue();
  }
View Full Code Here

              cachedRowSet.updateDouble(pColOrdinal, doubleValue.getDoubleValue());
            } else if (pValue instanceof DecimalData) {
              DecimalData value = (DecimalData) pValue;
              cachedRowSet.updateBigDecimal(pColOrdinal, value.getBigDecimal());
            } else if (pValue instanceof BooleanData) {
              BooleanData value = (BooleanData) pValue;
              cachedRowSet.updateBoolean(pColOrdinal, value.getBooleanValue());
            } else if (pValue instanceof DateTimeData) {
              DateTimeData value = (DateTimeData) pValue;
              cachedRowSet.updateDate(pColOrdinal, new Date(value.asDate().getTime()));
            } else if (pValue instanceof BinaryData) {
              BinaryData value = (BinaryData) pValue;
              cachedRowSet.updateBinaryStream(pColOrdinal, new ByteArrayInputStream(value.getValue()), value.getActualSize());
            }
          } catch (SQLException e) {
            UsageException errorVar = new UsageException(e.getMessage(), net.helipilot50.stocktrade.framework.Constants.SP_ER_USER, net.helipilot50.stocktrade.framework.Constants.SP_ER_PARAMETERERROR, e);
            ErrorMgr.addError(errorVar);
            throw errorVar;
View Full Code Here

      lastCID = id;
    }
    //PM:04/09/2008:Adding modifiable config instruments as operations
    protected void addCommandForAttribute(Instrument inst){
      if (inst instanceof ConfigValueInst){
        CommandDesc desc = new CommandDesc();
            desc.setCmdName("set" + inst.Name.asString());
            desc.setArgDesc("s");
            desc.setCmdIndex((short) (getLastCID() + 1000 + inst.getInstrumentID()));
            desc.setHelpText("set the value of " + inst.Name.asString());
            desc.setCmdFlags((short)1);
            desc.setArgNames("set " + inst.getName());
            desc.setGroupName("");
            desc.setMenuString("Utility");
        processOneCommandDescriptor(desc);
      }
    }
View Full Code Here

TOP

Related Classes of net.helipilot50.stocktrade.framework.AppContextHolder

Copyright © 2018 www.massapicom. 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.