Examples of Callback


Examples of org.apache.airavata.workflow.tracking.client.Callback

    private boolean wait = true;

    public void testMessagePulling() throws Exception {
        Subscription subscription = null;

        Callback testCallback1 = new Callback() {
            public void deliverMessage(String topic, NotificationType type, XmlObject messageObj) {
                System.out.println("Notification Received, notification of type:" + type);
                // assertEquals(type, NotificationType.WorkflowInitialized);
                wait = false;
            }
        };

        subscription = LeadNotificationManager.createMessageBoxSubscription(MESSAGEBOX_URL, BROKER_URL, TEST_TOPIC,
                null, testCallback1);

        System.out.println(subscription.getMessageBoxEPR());
        System.out.println(subscription.getSubscriptionID());

        WseMsgBrokerClient client = new WseMsgBrokerClient();
        client.init(BROKER_URL);

        OMElement msg = WorkFlowUtils.reader2OMElement(new StringReader(CommonUtils.WORKFLOW_INITIALIZED_NOTIFICATION));

        client.publish(TEST_TOPIC, msg);

        EndpointReference MSG_BOX_EPR = subscription.getMessageBoxEPR();
        System.out.println(MSG_BOX_EPR);
        String subscriptionID = subscription.getSubscriptionID();
        Callback testCallback2 = new Callback() {

            public void deliverMessage(String topic, NotificationType type, XmlObject messageObj) {

                System.out.println("Notification Received, notification of type:" + type);
                // This assertion is wrong because type and NotificationType.WorkflowInitialized are two different types
View Full Code Here

Examples of org.apache.aries.blueprint.CallbackTracker.Callback

    public String getName() {
        return name;
    }
   
    public void init() {
        CallbackTracker.add(new Callback(Callback.INIT, this));
    }
View Full Code Here

Examples of org.apache.axis2.client.async.Callback

   
    clientOptions.setUseSeparateListener(true);
   
    serviceClient.setOptions(clientOptions);

    Callback callback1 = new TestCallback ("Callback 1");
    serviceClient.sendReceiveNonBlocking (getEchoOMBlock("echo1",sequenceKey),callback1);
   
    Callback callback2 = new TestCallback ("Callback 2");
    serviceClient.sendReceiveNonBlocking(getEchoOMBlock("echo2",sequenceKey),callback2);

    Callback callback3 = new TestCallback ("Callback 3");
    serviceClient.sendReceiveNonBlocking(getEchoOMBlock("echo3",sequenceKey),callback3);
   
    Callback callback4 = new TestCallback ("Callback 4");
    serviceClient.sendReceiveNonBlocking(getEchoOMBlock("echo4",sequenceKey),callback4);

    clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true");
    Callback callback5 = new TestCallback ("Callback 5");
    serviceClient.sendReceiveNonBlocking(getEchoOMBlock("echo5",sequenceKey),callback5);
   
        while (!callback5.isComplete()) {
            Thread.sleep(1000);
        }
       
        Thread.sleep(4000);
       
View Full Code Here

Examples of org.apache.axis2.clientapi.Callback

            call.setTransportInfo(Constants.TRANSPORT_HTTP,
                    Constants.TRANSPORT_HTTP,
                    false);

            //Callback to handle the response
            Callback callback = new Callback() {
                public void onComplete(AsyncResult result) {
                    try {
                        StringWriter writer = new StringWriter();
                        result.getResponseEnvelope().serializeWithCache(XMLOutputFactory.newInstance()
                                .createXMLStreamWriter(writer));
                        writer.flush();
                        System.out.println(writer.toString());


                    } catch (XMLStreamException e) {
                        reportError(e);
                    }
                }

                public void reportError(Exception e) {
                    e.printStackTrace();
                }
            };

            //Non-Blocking Invocation
            call.invokeNonBlocking("echo", payload, callback);

            //Wait till the callback receives the response.
            while (!callback.isComplete()) {
                Thread.sleep(1000);
            }

        } catch (AxisFault axisFault) {
            axisFault.printStackTrace();
View Full Code Here

Examples of org.apache.felix.ipojo.util.Callback

        MethodField method = m_configMap.getMethodFromName(operationName,
            signature);
        if (method != null) {
            MethodMetadata methodCall = method.getMethod();
            Callback mc = new Callback(methodCall, m_instanceManager);
            try {
                return mc.call(params);
            } catch (NoSuchMethodException e) {
                throw new ReflectionException(e);
            } catch (IllegalAccessException e) {
                throw new ReflectionException(e);
            } catch (InvocationTargetException e) {
View Full Code Here

Examples of org.apache.hadoop.ha.HealthMonitor.Callback

   * health monitor and thus change its state to FAILED
   * @throws Exception
   */
  @Test(timeout=15000)
  public void testCallbackThrowsRTE() throws Exception {
    hm.addCallback(new Callback() {
      @Override
      public void enteredState(State newState) {
        throw new RuntimeException("Injected RTE");
      }
    });
View Full Code Here

Examples of org.apache.kafka.clients.producer.Callback

        long sleepTime = NS_PER_SEC / throughput;
        long sleepDeficitNs = 0;
        Stats stats = new Stats(numRecords, 5000);
        for (int i = 0; i < numRecords; i++) {
            long sendStart = System.currentTimeMillis();
            Callback cb = stats.nextCompletion(sendStart, payload.length, stats);
            producer.send(record, cb);

            /*
             * Maybe sleep a little to control throughput. Sleep time can be a bit inaccurate for times < 1 ms so
             * instead of sleeping each time instead wait until a minimum sleep time accumulates (the "sleep deficit")
View Full Code Here

Examples of org.apache.sling.hc.core.impl.executor.HealthCheckFuture.Callback

        @Override
        public void run() {

            LOG.debug("Running job {}", this);
            HealthCheckFuture healthCheckFuture = new HealthCheckFuture(healthCheckDescriptor, bundleContext, new Callback() {

                @Override
                public void finished(HealthCheckExecutionResult result) {
                    // no action needed here
                   
View Full Code Here

Examples of org.apache.tuscany.sca.assembly.Callback

        ComponentProperty componentProperty = null;
        CompositeService compositeService = null;
        CompositeReference compositeReference = null;
        Contract contract = null;
        Wire wire = null;
        Callback callback = null;
        QName name = null;

        // Read the composite document
        while (reader.hasNext()) {
            int event = reader.getEventType();
            switch (event) {
                case START_ELEMENT:
                    name = reader.getName();

                    if (COMPOSITE_QNAME.equals(name)) {

                        // Read a <composite>
                        composite = assemblyFactory.createComposite();
                        composite.setName(new QName(getString(reader, TARGET_NAMESPACE), getString(reader, NAME)));
                        if(isSet(reader, AUTOWIRE)) {
                            composite.setAutowire(getBoolean(reader, AUTOWIRE));
                        }
                        composite.setLocal(getBoolean(reader, LOCAL));
                        composite.setConstrainingType(readConstrainingType(reader));
                        policyProcessor.readPolicies(composite, reader);

                    } else if (INCLUDE_QNAME.equals(name)) {

                        // Read an <include>
                        include = assemblyFactory.createComposite();
                        include.setName(getQName(reader, "name"));
                        include.setUnresolved(true);
                        composite.getIncludes().add(include);

                    } else if (SERVICE_QNAME.equals(name)) {
                        if (component != null) {

                            // Read a <component><service>
                            componentService = assemblyFactory.createComponentService();
                            contract = componentService;
                            componentService.setName(getString(reader, NAME));
                            component.getServices().add(componentService);
                            policyProcessor.readPolicies(contract, reader);
                        } else {

                            // Read a <composite><service>
                            compositeService = assemblyFactory.createCompositeService();
                            contract = compositeService;
                            compositeService.setName(getString(reader, NAME));

                            String promoted = getString(reader, PROMOTE);
                            String promotedComponentName;
                            String promotedServiceName;
                            int s = promoted.indexOf('/');
                            if (s == -1) {
                                promotedComponentName = promoted;
                                promotedServiceName = null;
                            } else {
                                promotedComponentName = promoted.substring(0, s);
                                promotedServiceName = promoted.substring(s + 1);
                            }

                            Component promotedComponent = assemblyFactory.createComponent();
                            promotedComponent.setUnresolved(true);
                            promotedComponent.setName(promotedComponentName);
                            compositeService.setPromotedComponent(promotedComponent);

                            ComponentService promotedService = assemblyFactory.createComponentService();
                            promotedService.setUnresolved(true);
                            promotedService.setName(promotedServiceName);
                            compositeService.setPromotedService(promotedService);

                            composite.getServices().add(compositeService);
                            policyProcessor.readPolicies(contract, reader);
                        }

                    } else if (REFERENCE_QNAME.equals(name)) {
                        if (component != null) {
                            // Read a <component><reference>
                            componentReference = assemblyFactory.createComponentReference();
                            contract = componentReference;
                            componentReference.setName(getString(reader, NAME));
                            readMultiplicity(componentReference, reader);
                            if (isSet(reader, AUTOWIRE)) {
                                componentReference.setAutowire(getBoolean(reader, AUTOWIRE));
                            }
                            readTargets(componentReference, reader);
                            componentReference.setWiredByImpl(getBoolean(reader, WIRED_BY_IMPL));
                            component.getReferences().add(componentReference);
                            policyProcessor.readPolicies(contract, reader);
                        } else {
                            // Read a <composite><reference>
                            compositeReference = assemblyFactory.createCompositeReference();
                            contract = compositeReference;
                            compositeReference.setName(getString(reader, NAME));
                            readMultiplicity(compositeReference, reader);
                            readTargets(compositeReference, reader);
                            String promote = reader.getAttributeValue(null, Constants.PROMOTE);
                            if (promote != null) {
                                for (StringTokenizer tokens = new StringTokenizer(promote); tokens.hasMoreTokens();) {
                                    ComponentReference promotedReference =
                                        assemblyFactory.createComponentReference();
                                    promotedReference.setUnresolved(true);
                                    promotedReference.setName(tokens.nextToken());
                                    compositeReference.getPromotedReferences().add(promotedReference);
                                }
                            }
                            compositeReference.setWiredByImpl(getBoolean(reader, WIRED_BY_IMPL));
                            composite.getReferences().add(compositeReference);
                            policyProcessor.readPolicies(contract, reader);
                        }

                    } else if (PROPERTY_QNAME.equals(name)) {
                        if (component != null) {

                            // Read a <component><property>
                            componentProperty = assemblyFactory.createComponentProperty();
                            property = componentProperty;
                            componentProperty.setSource(getString(reader, SOURCE));
                            componentProperty.setFile(getString(reader, FILE));
                            policyProcessor.readPolicies(property, reader);
                            readAbstractProperty(componentProperty, reader);
                           
                            // Read the property value
                            Document value = readPropertyValue(property.getXSDElement(), property.getXSDType(), reader);
                            property.setValue(value);
                           
                            component.getProperties().add(componentProperty);
                        } else {

                            // Read a <composite><property>
                            property = assemblyFactory.createProperty();
                            policyProcessor.readPolicies(property, reader);
                            readAbstractProperty(property, reader);
                           
                            // Read the property value
                            Document value = readPropertyValue(property.getXSDElement(), property.getXSDType(), reader);
                            property.setValue(value);
                           
                            composite.getProperties().add(property);
                        }

                    } else if (COMPONENT_QNAME.equals(name)) {

                        // Read a <component>
                        component = assemblyFactory.createComponent();
                        component.setName(getString(reader, NAME));
                        if (isSet(reader, AUTOWIRE)) {
                            component.setAutowire(getBoolean(reader, AUTOWIRE));
                        }
                        if (isSet(reader, URI)) {
                            component.setURI(getString(reader, URI));
                        }
                        component.setConstrainingType(readConstrainingType(reader));
                        composite.getComponents().add(component);
                        policyProcessor.readPolicies(component, reader);

                    } else if (WIRE_QNAME.equals(name)) {

                        // Read a <wire>
                        wire = assemblyFactory.createWire();
                        ComponentReference source = assemblyFactory.createComponentReference();
                        source.setUnresolved(true);
                        source.setName(getString(reader, SOURCE));
                        wire.setSource(source);

                        ComponentService target = assemblyFactory.createComponentService();
                        target.setUnresolved(true);
                        target.setName(getString(reader, TARGET));
                        wire.setTarget(target);

                        composite.getWires().add(wire);
                        policyProcessor.readPolicies(wire, reader);

                    } else if (CALLBACK_QNAME.equals(name)) {

                        // Read a <callback>
                        callback = assemblyFactory.createCallback();
                        contract.setCallback(callback);
                        policyProcessor.readPolicies(callback, reader);

                    } else if (OPERATION_QNAME.equals(name)) {

                        // Read an <operation>
                        ConfiguredOperation operation = assemblyFactory.createConfiguredOperation();
                        operation.setName(getString(reader, NAME));
                        operation.setUnresolved(true);
                        if (callback != null) {
                            policyProcessor.readPolicies(operation, reader);
                        } else {
                            policyProcessor.readPolicies(operation, reader);
                        }
                       
                        OperationsConfigurator opConfigurator = null;
                        if ( compositeService != null ) {
                            opConfigurator = compositeService;
                        } else if ( componentService != null ) {
                            opConfigurator = componentService;
                        } else if ( compositeReference != null ) {
                            opConfigurator = compositeReference;
                        } else if ( componentReference != null ) {
                            opConfigurator = componentReference;
                        }
                       
                        opConfigurator.getConfiguredOperations().add(operation);
                    } else if (IMPLEMENTATION_COMPOSITE_QNAME.equals(name)) {

                        // Read an implementation.composite
                        Composite implementation = assemblyFactory.createComposite();
                        implementation.setName(getQName(reader, NAME));
                        implementation.setUnresolved(true);
                        component.setImplementation(implementation);
                        policyProcessor.readPolicies(implementation, reader);
                    } else {

                        // Read an extension element
                        Object extension = extensionProcessor.read(reader);
                        if (extension != null) {
                            if (extension instanceof InterfaceContract) {

                                // <service><interface> and
                                // <reference><interface>
                                if (contract != null) {
                                    contract.setInterfaceContract((InterfaceContract)extension);
                                } else {
                                    if (name.getNamespaceURI().equals(SCA10_NS)) {
                                        throw new ContributionReadException(
                                                                            "Unexpected <interface> element found. It should appear inside a <service> or <reference> element");
                                    } else {
                                        composite.getExtensions().add(extension);
                                    }
                                }

                            } else if (extension instanceof Binding) {
                                // <service><binding> and
                                // <reference><binding>
                                if (callback != null) {
                                    callback.getBindings().add((Binding)extension);
                                } else {
                                    if (contract != null) {
                                        contract.getBindings().add((Binding)extension);
                                    } else {
                                        if (name.getNamespaceURI().equals(SCA10_NS)) {
                                            throw new ContributionReadException(
                                                                                "Unexpected <binding> element found. It should appear inside a <service> or <reference> element");
                                        } else {
                                            composite.getExtensions().add(extension);
                                        }
                                    }
                                }

                            } else if (extension instanceof Implementation) {

                                // <component><implementation>
                                if (component != null) {
                                    component.setImplementation((Implementation)extension);
                                } else {
                                    if (name.getNamespaceURI().equals(SCA10_NS)) {
                                        throw new ContributionReadException(
                                                                            "Unexpected <implementation> element found. It should appear inside a <component> element");
                                    } else {
                                        composite.getExtensions().add(extension);
                                    }
                                }
                            } else {

                                // Add the extension element to the current
                                // element
                                if (callback != null) {
                                    callback.getExtensions().add(extension);
                                } else if (contract != null) {
                                    contract.getExtensions().add(extension);
                                } else if (property != null) {
                                    property.getExtensions().add(extension);
                                } else if (component != null) {
View Full Code Here

Examples of org.asynchttpclient.providers.netty.Callback

        pipeline.addAfter(WS_DECODER_HANDLER, WS_FRAME_AGGREGATOR, new WebSocketFrameAggregator(nettyConfig.getWebSocketMaxBufferSize()));
    }

    public final Callback newDrainCallback(final NettyResponseFuture<?> future, final Channel channel, final boolean keepAlive, final String poolKey) {

        return new Callback(future) {
            public void call() {
                tryToOfferChannelToPool(channel, keepAlive, poolKey);
            }
        };
    }
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.