Examples of ScriptTask


Examples of io.apigee.trireme.core.ScriptTask

            if (log.isDebugEnabled()) {
                log.debug("Received HTTP onRequest: {} self contained = {}", request, request.isSelfContained());
            }

            // Queue up a task to process the request
            runner.enqueueTask(new ScriptTask()
            {
                @Override
                public void execute(Context cx, Scriptable scope)
                {
                    RequestAdapter reqAdapter =
                        (RequestAdapter)cx.newObject(ServerContainer.this, RequestAdapter.CLASS_NAME);
                    reqAdapter.init(request);

                    ResponseAdapter respAdapter =
                        (ResponseAdapter)cx.newObject(ServerContainer.this, ResponseAdapter.CLASS_NAME);
                    respAdapter.init(response, ServerContainer.this);

                    Scriptable socketInfo = makeSocketInfo(cx, request);

                    Scriptable socketObj = (Scriptable)makeSocket.call(cx, makeSocket, null,
                                                                       new Object[] { socketInfo });
                    Scriptable requestObj = (Scriptable)makeRequest.call(cx, makeRequest, null,
                                                                         new Object[] { reqAdapter, socketObj });
                    Scriptable responseObj = (Scriptable)makeResponse.call(cx, makeResponse, null,
                                                                           new Object[] { respAdapter, socketObj, timeoutOpts });

                    request.setScriptObject(requestObj);
                    response.setScriptObject(responseObj);

                    onHeaders.call(cx, onHeaders, ServerContainer.this, new Object[] { requestObj, responseObj });
                }
            });

            if (request.isSelfContained()) {
                final ByteBuffer requestData =
                    (request.hasData() ? request.getData() : null);
                // Queue up another task for the data. Noderunner guarantees that this will run after
                // the previous task. However, do this in a separate tick because it's highly likely that
                // the revious request to call "onHeaders" will register more event handlers
                runner.enqueueTask(new ScriptTask()
                {
                    @Override
                    public void execute(Context cx, Scriptable scope)
                    {
                        callOnData(cx, scope, request, requestData);
                    }
                });
                runner.enqueueTask(new ScriptTask()
                {
                    @Override
                    public void execute(Context cx, Scriptable scope)
                    {
                        callOnComplete(cx, request);
View Full Code Here

Examples of io.apigee.trireme.core.ScriptTask

            if (log.isDebugEnabled()) {
                log.debug("Received HTTP onData for {} with {}", request, data);
            }
            final ByteBuffer requestData =
                    (data.hasData() ? data.getData() : null);
            runner.enqueueTask(new ScriptTask()
            {
                @Override
                public void execute(Context cx, Scriptable scope)
                {
                    callOnData(cx, scope, request, requestData);
                }
            });
            if (data.isLastChunk()) {
                runner.enqueueTask(new ScriptTask()
                {
                    @Override
                    public void execute(Context cx, Scriptable scope)
                    {
                        callOnComplete(cx, request);
View Full Code Here

Examples of io.apigee.trireme.core.ScriptTask

        @Override
        public void onClose(final HttpRequestAdapter request, final HttpResponseAdapter response)
        {
            if (request != null) {
                runner.enqueueTask(new ScriptTask() {
                    @Override
                    public void execute(Context cx, Scriptable scope) {
                        Scriptable reqObject = request.getScriptObject();
                        Object respObject;
                        if (response != null) {
View Full Code Here

Examples of io.apigee.trireme.core.ScriptTask

                {
                    if (log.isDebugEnabled()) {
                        log.debug("Write complete: success = {} closed = {} cause = {}", success, closed, cause);
                    }
                    Scriptable domain = server.getRunner().getDomain();
                    server.getRunner().enqueueTask(new ScriptTask()
                    {
                        @Override
                        public void execute(Context cx, Scriptable scope)
                        {
                            Scriptable err = null;
View Full Code Here

Examples of io.apigee.trireme.core.ScriptTask

        // We are in the thread pool, and we need to run the callback in the script thread. So we will
        // call "enqueueTask" to get back there.
        // All the JS and Java code written for Node.js assumes that it is running in this thread,
        // and it is not synchronized, so it's very important that we call this to get back to
        // the right thread -- otherwise we will corrupt all sorts of state.
        runtime.enqueueTask(new ScriptTask() {
            @Override
            public void execute(Context cx, Scriptable scope)
            {
                // The callback just expects an Error as the first parameter, or nothing if
                // we succeeded, so set that up here
View Full Code Here

Examples of io.apigee.trireme.core.ScriptTask

        // We are in the thread pool, and we need to run the callback in the script thread. So we will
        // call "enqueueTask" to get back there.
        // All the JS and Java code written for Node.js assumes that it is running in this thread,
        // and it is not synchronized, so it's very important that we call this to get back to
        // the right thread -- otherwise we will corrupt all sorts of state.
        runtime.enqueueTask(new ScriptTask() {
            @Override
            public void execute(Context cx, Scriptable scope)
            {
                // Rather than throw an error, we need to pass an Error object as the first parameter
                // to the callback. This will construct it in a convenient way.
View Full Code Here

Examples of io.apigee.trireme.core.ScriptTask

    }

    private void deliverResult(final byte[] buf, final int length, final Function cb, Object domain)
    {
        // Again, get back to the script thread.
        runtime.enqueueTask(new ScriptTask() {
            @Override
            public void execute(Context cx, Scriptable scope)
            {
                if (length >= 0) {
                    // Create a Node.js Buffer object from the data that we just read.
View Full Code Here

Examples of io.apigee.trireme.core.ScriptTask

        final Object reallyDeliver = toDeliver;
        final String fevent = event;
        if (child == null) {
            // We are called on child's script runtime, so enqueue a task here
            enqueueTask(new ScriptTask() {
                @Override
                public void execute(Context cx, Scriptable scope)
                {
                    if ("disconnect".equals(fevent)) {
                        // Special handling for a disconnect from the parent
                        if (process.isConnected()) {
                            process.setConnected(false);
                            process.getEmit().call(cx, scope, process, new Object[] { fevent });
                        }
                    } else {
                        process.getEmit().call(cx, scope, process,
                                               new Object[] { fevent, reallyDeliver });
                    }
                }
            });

        } else {
            // We are the child's script runtime. Enqueue task that sends to the parent
            // "child" here actually refers to the "child_process" object inside the parent!
            assert(child.getRuntime() != this);
            child.getRuntime().enqueueTask(new ScriptTask()
            {
                @Override
                public void execute(Context cx, Scriptable scope)
                {
                    // Now we should be running inside the script thread of the other script
View Full Code Here

Examples of org.activiti.bpmn.model.ScriptTask

  private void validateModel(BpmnModel model) {
    FlowElement flowElement = model.getFlowElement("_5");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof ScriptTask);
    assertEquals("_5", flowElement.getId());
    ScriptTask scriptTask = (ScriptTask) flowElement;
    assertEquals("_5", scriptTask.getId());
    assertEquals("Send Hello Message", scriptTask.getName());
  }
View Full Code Here

Examples of org.activiti.bpmn.model.ScriptTask

  }

  @Override
  protected ScriptTask createProcessArtifact(ScriptStepDefinition stepDefinition, WorkflowDefinitionConversion conversion) {
   
    ScriptTask scriptTask = new ScriptTask();
    scriptTask.setId(conversion.getUniqueNumberedId(ConversionConstants.SCRIPT_TASK_ID_PREFIX));
    scriptTask.setName(stepDefinition.getName());
    scriptTask.setScript(stepDefinition.getScript());
   
    if (stepDefinition.getScriptLanguage() != null) {
      scriptTask.setScriptFormat(stepDefinition.getScriptLanguage());
    } else {
      scriptTask.setScriptFormat("JavaScript");
    }
   
    addFlowElement(conversion, scriptTask, true);
   
    return scriptTask;
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.