Examples of InvocationContext


Examples of nexj.core.runtime.InvocationContext

   /**
    * @see nexj.core.tools.ContextREPL#initializeContext()
    */
   protected Context initializeContext()
   {
      InvocationContext context = (InvocationContext)Repository.getMetadata().getComponent("System.InvocationContext")
         .getInstance(null);

      context.setAudited(false);
      context.initialize((m_sUser == null) ? null : new SimplePrincipal(m_sUser));
      context.setLocale(Locale.getDefault());
      context.getUnitOfWork().commit();

      ThreadContextHolder.setContext(context);

      assert context.getMachine() != null;

      return context;
   }
View Full Code Here

Examples of org.apache.airavata.core.gfac.context.invocation.InvocationContext

                    EmbeddedGFacInvoker.this.configuration.getMyProxyUsername(),
                    EmbeddedGFacInvoker.this.configuration.getMyProxyPassphrase(), EmbeddedGFacInvoker.this.configuration.getMyProxyLifetime(),
                    EmbeddedGFacInvoker.this.airavataAPI, EmbeddedGFacInvoker.this.configuration.getTrustedCertLocation());

            GfacAPI gfacAPI1 = new GfacAPI();
            InvocationContext defaultInvocationContext = gfacAPI1.gridJobSubmit(jobContext,
                    gFacConfiguration, this.nodeID, this.notifier.getWorkflowID().toASCIIString());
            ParameterContextImpl outputParamContext = (ParameterContextImpl) defaultInvocationContext
                    .<ActualParameter>getMessageContext("output");
            if (outputParamContext.getNames().hasNext()) {
                /*
                * Process Output
                */
 
View Full Code Here

Examples of org.apache.airavata.workflow.tracking.common.InvocationContext

        WorkflowNotifier notifier = NotifierFactory.createWorkflowNotifier();
        WorkflowTrackingContext context = notifier.createTrackingContext(new Properties(), BROKER_URL, myWorkflowID,
                myServiceID, myNodeID, myTimestep);

        InvocationContext myInvocation = notifier.workflowInvoked(context, myInvoker,
                XmlObject.Factory.parse("<soapHeader/>"),
                XmlObject.Factory.parse("<soapBody>input1,input2</soapBody>"), "This is the start of this workflow");

        // BEGIN SERVICE1
        {
            // prepare to invoke service1
            InvocationEntity service1 = notifier.createEntity(myServiceID, SERVICE_1, "NODE1", 1);
            InvocationContext service1Invocation = notifier.invokingService(context, service1,
                    XmlObject.Factory.parse("<soapHeader/>"), XmlObject.Factory.parse("<soapBody>input1</soapBody>"),
                    "This workflow is invoking a service");

            Object result = null;
            try {
                // prepare to invoke service1
                result = runService1(service1, service1.getWorkflowID(), service1.getServiceID(),
                        service1.getWorkflowNodeID(), service1.getWorkflowTimestep());

                // If this were an async invocation, we would have finished
                // sending request.
                // we acknowledge the successful request.
                notifier.invokingServiceSucceeded(context, service1Invocation, "Invoked service1 successfully");

            } catch (Exception ex) {
                // If there had been a problem sending the request on the wire,
                // we acknowledge a failed request.
                notifier.invokingServiceFailed(context, service1Invocation, ex, "Failed to invoke service1");
            }

            // At this point, we would have waited for response from service1 if
            // it were an async call.
            // assume we received response at this point and continue.
            if (result instanceof Success) {
                notifier.receivedResult(context, service1Invocation, ((Success) result).header,
                        ((Success) result).body, "got success response from service1");
            } else if (result instanceof Failure) {
                notifier.receivedFault(context, service1Invocation, ((Failure) result).header, ((Failure) result).body,
                        "got fault response from service1");
            }

        }

        // BEGIN SERVICE2
        {
            // prepare to invoke service1
            InvocationEntity service2 = notifier.createEntity(myServiceID, SERVICE_2, "NODE2", 2);
            InvocationContext service1Invocation = notifier.invokingService(context, service2,
                    XmlObject.Factory.parse("<soapHeader/>"),
                    XmlObject.Factory.parse("<soapBody>input2,input3</soapBody>"),
                    "This workflow is invoking another service");

            Object result = null;
View Full Code Here

Examples of org.apache.axis2.jaxws.core.InvocationContext

        OperationDescription operationDesc =
                endpointDesc.getEndpointInterfaceDescription().getOperation(method);

        // Create and configure the request MessageContext
        InvocationContext requestIC = InvocationContextFactory.createInvocationContext(null);
        MessageContext request = createRequest(method, args);
        request.getAxisMessageContext().setProperty(BINDING_PROVIDER, this);
        request.setEndpointDescription(getEndpointDescription());
        request.setOperationDescription(operationDesc);

        // Enable MTOM on the Message if the property was set on the SOAPBinding.
        Binding bnd = (Binding) getBinding();
        if (bnd != null && bnd instanceof SOAPBinding) {
            if (((SOAPBinding)bnd).isMTOMEnabled()) {
                Message requestMsg = request.getMessage();
                requestMsg.setMTOMEnabled(true);
                int threshold = ((org.apache.axis2.jaxws.binding.SOAPBinding)bnd).getMTOMThreshold();
                request.setProperty(org.apache.axis2.Constants.Configuration.MTOM_THRESHOLD,
                        new Integer(threshold));
            }
            if (((org.apache.axis2.jaxws.binding.SOAPBinding)bnd).isRespectBindingEnabled()) {
                //lets invoke Utility to configure RespectBinding.
                EndpointDescription endpointDescription = getEndpointDescription();
                endpointDescription.setRespectBinding(true);
                WSDLExtensionUtils.processExtensions(endpointDescription);
                //We have build up set of extensions from wsdl
                //let go ahead and validate these extensions now.
                EndpointDescriptionValidator endpointValidator = new EndpointDescriptionValidator(endpointDescription);
                
                boolean isEndpointValid = endpointValidator.validate(true);
                //throw Exception if extensions are not understood by Engine.
                if (!isEndpointValid) {
                    String msg = Messages.getMessage("endpointDescriptionValidationErrors",
                                                     endpointValidator.toString());
                    throw ExceptionFactory.makeWebServiceException(msg);
                }
            }
        }
       
        /*
         * TODO: review: make sure the handlers are set on the InvocationContext
         * This implementation of the JAXWS runtime does not use Endpoint, which
         * would normally be the place to initialize and store the handler list.
         * In lieu of that, we will have to intialize and store them on the
         * InvocationContext.  also see the InvocationContextFactory.  On the client
         * side, the binding is not yet set when we call into that factory, so the
         * handler list doesn't get set on the InvocationContext object there.  Thus
         * we gotta do it here.
         */
       
        // be sure to use whatever handlerresolver is registered on the Service
        requestIC.setHandlers(bnd.getHandlerChain());

        requestIC.setRequestMessageContext(request);
        requestIC.setServiceClient(serviceDelegate.getServiceClient(endpointDesc.getPortQName()));
       
        /*
         * if SESSION_MAINTAIN_PROPERTY is true, and the client app has explicitly set a HEADER_COOKIE on the request context, assume the client
         * app is expecting the HEADER_COOKIE to be the session id.  If we were establishing a new session, no cookie would be sent, and the
         * server would reply with a "Set-Cookie" header, which is copied as a "Cookie"-keyed property to the service context during response.
         * In this case, if we succeed in using an existing server session, no "Set-Cookie" header will be returned, and therefore no
         * "Cookie"-keyed property would be set on the service context.  So, let's copy our request context HEADER_COOKIE key to the service
         * context now to prevent the "no cookie" exception in BindingProvider.setupSessionContext.  It is possible the server does not support
         * sessions, in which case no error occurs, but the client app would assume it is participating in a session.
         */
        if ((requestContext.containsKey(BindingProvider.SESSION_MAINTAIN_PROPERTY)) && ((Boolean)requestContext.get(BindingProvider.SESSION_MAINTAIN_PROPERTY))) {
            if ((requestContext.containsKey(HTTPConstants.HEADER_COOKIE)) && (requestContext.get(HTTPConstants.HEADER_COOKIE) != null)) {
                if (requestIC.getServiceClient().getServiceContext().getProperty(HTTPConstants.HEADER_COOKIE) == null) {
                    requestIC.getServiceClient().getServiceContext().setProperty(HTTPConstants.HEADER_COOKIE, requestContext.get(HTTPConstants.HEADER_COOKIE));
                    if (log.isDebugEnabled()) {
                        log.debug("Client-app defined Cookie property (assume to be session cookie) on request context copied to service context." +
                                "  Caution:  server may or may not support sessions, but client app will not be informed when not supported.");
                    }
                }
            }
        }
       
        // Migrate the properties from the client request context bag to
        // the request MessageContext.
        ApplicationContextMigratorUtil.performMigrationToMessageContext(
                Constants.APPLICATION_CONTEXT_MIGRATOR_LIST_ID,
                getRequestContext(), request);

        // Note that configuring the MessageContext for addressing based on the metadata and for any
        // WebService Features needs to be done after the application context migration since it will move properties
        // from the JAXWS RequestContext onto the Axis2 Message context, overwritting any that are already set.
        configureAddressing(request, this);
        // Perform the WebServiceFeature configuration requested by the user.
        bnd.configure(request, this);

        // We'll need an InvocationController instance to send the request.
        InvocationControllerFactory icf = (InvocationControllerFactory) FactoryRegistry.getFactory(InvocationControllerFactory.class);
        controller = icf.getInvocationController();
       
        if (controller == null) {
            throw new WebServiceException(Messages.getMessage("missingInvocationController"));
        }
       
        // Check if the call is OneWay, Async or Sync
        if (operationDesc.isOneWay()) {
            if (log.isDebugEnabled()) {
                log.debug("OneWay Call");
            }
            controller.invokeOneWay(requestIC);

            // Check to see if we need to maintain session state
            checkMaintainSessionState(request, requestIC);
        }

        if (method.getReturnType() == Future.class) {
            if (log.isDebugEnabled()) {
                log.debug("Async Callback");
            }

            //Get AsyncHandler from Objects and sent that to InvokeAsync
            AsyncHandler asyncHandler = null;
            for (Object obj : args) {
                if (obj != null && AsyncHandler.class.isAssignableFrom(obj.getClass())) {
                    asyncHandler = (AsyncHandler)obj;
                    break;
                }
            }

            // Don't allow the invocation to continue if the invocation requires a callback
            // object, but none was supplied.
            if (asyncHandler == null) {
                throw ExceptionFactory
                        .makeWebServiceException(Messages.getMessage("proxyNullCallback"));
            }
            AsyncResponse listener = createProxyListener(args, operationDesc);
            requestIC.setAsyncResponseListener(listener);

            if ((serviceDelegate.getExecutor() != null) &&
                    (serviceDelegate.getExecutor() instanceof ExecutorService)) {
                ExecutorService es = (ExecutorService)serviceDelegate.getExecutor();
                if (es.isShutdown()) {
                    // the executor service is shutdown and won't accept new tasks
                    // so return an error back to the client
                    throw ExceptionFactory
                            .makeWebServiceException(Messages.getMessage("ExecutorShutdown"));
                }
            }

            requestIC.setExecutor(serviceDelegate.getExecutor());

            Future<?> future = controller.invokeAsync(requestIC, asyncHandler);

            //Check to see if we need to maintain session state
            checkMaintainSessionState(request, requestIC);

            if (log.isDebugEnabled()) {
                log.debug("Exiting the method invokeSEIMethod() - Async Callback ");
            }

            return future;
        }

        if (method.getReturnType() == Response.class) {
            if (log.isDebugEnabled()) {
                log.debug("Async Polling");
            }
            AsyncResponse listener = createProxyListener(args, operationDesc);
            requestIC.setAsyncResponseListener(listener);
            requestIC.setExecutor(serviceDelegate.getExecutor());

            Response response = controller.invokeAsync(requestIC);

            //Check to see if we need to maintain session state
            checkMaintainSessionState(request, requestIC);
           
            if (log.isDebugEnabled()) {
                log.debug("Exiting the method invokeSEIMethod() - Async Polling ");
            }

            return response;
        }

        if (!operationDesc.isOneWay()) {
            InvocationContext responseIC = controller.invoke(requestIC);

            //Check to see if we need to maintain session state
            checkMaintainSessionState(request, requestIC);

            MessageContext responseContext = responseIC.getResponseMessageContext();
           
            // Migrate the properties from the response MessageContext back
            // to the client response context bag.
            ApplicationContextMigratorUtil.performMigrationFromMessageContext(
                    Constants.APPLICATION_CONTEXT_MIGRATOR_LIST_ID,
View Full Code Here

Examples of org.apache.tuscany.binding.axis2.Axis2Service.InvocationContext

    }

    public Object invokeTarget(final Object payload) throws InvocationTargetException {
        try {
            // Use current correlation id as index to retrieve inv context
            InvocationContext invCtx = service.retrieveMapping(this.currentCorrelationId);

            MessageContext outMC = Utils.createOutMessageContext(invCtx.inMessageContext);
            outMC.getOperationContext().addMessageContext(outMC);
           
            OMElement responseOM = null;
View Full Code Here

Examples of org.apache.tuscany.sca.binding.axis2.Axis2ServiceBindingProvider.InvocationContext

    }

    private Object invokeTarget(final Object payload, Object correlationId) throws InvocationTargetException {
        try {
            // Use current correlation id as index to retrieve inv context
            InvocationContext invCtx = service.retrieveMapping(correlationId);

            MessageContext outMC = Utils.createOutMessageContext(invCtx.inMessageContext);
            outMC.getOperationContext().addMessageContext(outMC);

            OMElement responseOM;
View Full Code Here

Examples of org.crsh.command.InvocationContext

  public LineRenderer renderer() {

    Object owner = closure.getOwner();

    //
    final InvocationContext ctx;
    Object cmd;
    while (true) {
      if (owner instanceof GroovyCommand) {
        cmd = owner;
        ctx = ((GroovyCommand)cmd).peekContext();
        break;
      } else if (owner instanceof GroovyScriptCommand) {
        cmd = owner;
        ctx = ((GroovyScriptCommand)cmd).peekContext();
        break;
      } else if (owner instanceof Closure) {
        owner = ((Closure)owner).getOwner();
      } else {
        throw new UnsupportedOperationException("Cannot resolver owner " + owner + " to command");
      }
    }

    //
    final LinkedList<LineRenderer> renderers = new LinkedList<LineRenderer>();

    //
    final InvocationContext nested = new AbstractInvocationContext() {

      /** . */
      private LinkedList<Object> buffer = new LinkedList<Object>();

      /** . */
      private Renderer renderable;

      public CommandInvoker<?, ?> resolve(String s) throws CommandException {
        return ctx.resolve(s);
      }

      public boolean takeAlternateBuffer() {
        return false;
      }

      public boolean releaseAlternateBuffer() {
        return false;
      }

      public RenderPrintWriter getWriter() {
        return ctx.getWriter();
      }

      public Map<String, Object> getSession() {
        return ctx.getSession();
      }

      public Map<String, Object> getAttributes() {
        return ctx.getAttributes();
      }

      public int getWidth() {
        return ctx.getWidth();
      }

      public int getHeight() {
        return ctx.getHeight();
      }

      public String getProperty(String propertyName) {
        return ctx.getProperty(propertyName);
      }

      public String readLine(String msg, boolean echo) {
        return null;
      }

      public Class getConsumedType() {
        return Object.class;
      }

      public Screenable append(CharSequence s) throws IOException {
        provide(s);
        return this;
      }

      @Override
      public Appendable append(char c) throws IOException {
        return append(Character.toString(c));
      }

      @Override
      public Appendable append(CharSequence csq, int start, int end) throws IOException {
        return append(csq.subSequence(start, end));
      }

      public Screenable append(Style style) throws IOException {
        provide(style);
        return this;
      }

      public Screenable cls() throws IOException {
        provide(CLS.INSTANCE);
        return this;
      }

      public void provide(Object element) throws IOException {
        Renderer current = Renderer.getRenderable(element.getClass());
        if (current == null) {
          current = Renderer.ANY;
        }
        if (current != null) {
          if (renderable != null && !current.equals(renderable)) {
            flush();
          }
          buffer.addLast(element);
          renderable = current;
        }
      }

      public void flush() throws IOException {
        // We don't really flush, we just compute renderables from the buffer
        if (buffer.size() > 0) {
          LineRenderer i = renderable.renderer(buffer.iterator());
          buffer.clear();
          renderers.add(i);
        }
      }

      public void close() throws IOException {
        // Nothing to do, except maybe release resources (and also prevent to do any other operation)
      }
    };

    if (cmd instanceof GroovyCommand) {
      ((GroovyCommand)cmd).pushContext(nested);
    } else {
      ((GroovyScriptCommand)cmd).pushContext(nested);
    }
    try {
      closure.call();
    }
    finally {
      if (cmd instanceof GroovyCommand) {
        ((GroovyCommand)cmd).popContext();
      } else {
        ((GroovyScriptCommand)cmd).popContext();
      }
    }

    // Be sure to flush
    try {
      nested.flush();
    }
    catch (Exception e) {
      e.printStackTrace();
    }

View Full Code Here

Examples of org.exoplatform.services.ext.action.InvocationContext

         conditions.put(SessionEventMatcher.EVENTTYPE_KEY, ExtendedEvent.ADD_MIXIN);
         conditions.put(SessionEventMatcher.PATH_KEY, node.getInternalPath());
         conditions.put(SessionEventMatcher.NODETYPES_KEY, new InternalQName[]{mixinType});
         conditions.put(SessionEventMatcher.WORKSPACE_KEY, workspaceName);

         InvocationContext ctx = new InvocationContext();
         ctx.put(InvocationContext.CURRENT_ITEM, node);
         ctx.put(InvocationContext.EVENT, ExtendedEvent.ADD_MIXIN);
         ctx.put(InvocationContext.EXO_CONTAINER, container);
         launch(conditions, ctx);
      }
      finally
      {
         activeItem = null;
View Full Code Here

Examples of org.infinispan.context.InvocationContext

      RemoveCommand command = commandsFactory.buildRemoveCommand(key, null);
      return wrapInFuture(invoker.invoke(ctx, command));
   }

   public final Future<Void> clearAsync(Flag... flags) {
      InvocationContext ctx = getInvocationContext();
      if (flags != null) ctx.setFlags(flags);
      ctx.setUseFutureReturnType(true);
      ClearCommand command = commandsFactory.buildClearCommand();
      return wrapInFuture(invoker.invoke(ctx, command));
   }
View Full Code Here

Examples of org.infinispan.context.InvocationContext

   public final Future<Boolean> replaceAsync(K k, V oV, V nV, Flag... flags) {
      return replaceAsync(k, oV, nV, MILLISECONDS.toMillis(defaultLifespan), MILLISECONDS, MILLISECONDS.toMillis(defaultMaxIdleTime), MILLISECONDS, flags);
   }

   public final Future<V> replaceAsync(K k, V v, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit, Flag... flags) {
      InvocationContext ctx = getInvocationContext();
      if (flags != null) ctx.setFlags(flags);
      ctx.setUseFutureReturnType(true);
      ReplaceCommand command = commandsFactory.buildReplaceCommand(k, null, v, lifespanUnit.toMillis(lifespan), maxIdleUnit.toMillis(maxIdle));
      return wrapInFuture(invoker.invoke(ctx, command));
   }
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.