Search in sources :

Example 51 with Promise

use of io.joynr.provider.Promise in project joynr by bmwcarit.

the class IltProvider method methodWithStringsAndSpecifiedStringOutLength.

/*
     * methodWithStringsAndSpecifiedStringOutLength
     */
@Override
public Promise<MethodWithStringsAndSpecifiedStringOutLengthDeferred> methodWithStringsAndSpecifiedStringOutLength(String stringArg, Integer int32StringLengthArg) {
    logger.warn("*****************************************************************");
    logger.warn("* IltProvider.methodWithStringsAndSpecifiedStringOutLength called");
    logger.warn("*****************************************************************");
    MethodWithStringsAndSpecifiedStringOutLengthDeferred deferred = new MethodWithStringsAndSpecifiedStringOutLengthDeferred();
    StringBuilder s = new StringBuilder();
    if (int32StringLengthArg > 1024 * 1024) {
        deferred.reject(new ProviderRuntimeException("methodWithStringsAndSpecifiedStringOutLength: Maximum length exceeded"));
        return new Promise<MethodWithStringsAndSpecifiedStringOutLengthDeferred>(deferred);
    }
    for (int i = 0; i < int32StringLengthArg; i++) {
        s.append("A");
    }
    deferred.resolve(s.toString());
    return new Promise<MethodWithStringsAndSpecifiedStringOutLengthDeferred>(deferred);
}
Also used : Promise(io.joynr.provider.Promise) ProviderRuntimeException(joynr.exceptions.ProviderRuntimeException)

Example 52 with Promise

use of io.joynr.provider.Promise in project joynr by bmwcarit.

the class IltProvider method methodToFireBroadcastWithMultipleEnumerationParameters.

/*
     * methodToFireBroadcastWithMultipleEnumerationParameters
     */
@Override
public Promise<DeferredVoid> methodToFireBroadcastWithMultipleEnumerationParameters(String[] partitions) {
    logger.warn("***************************************************************************");
    logger.warn("* IltProvider.methodToFireBroadcastWithMultipleEnumerationParameters called");
    logger.warn("***************************************************************************");
    DeferredVoid deferred = new DeferredVoid();
    deferred.resolve();
    ExtendedEnumerationWithPartlyDefinedValues extendedEnumerationOut = ExtendedEnumerationWithPartlyDefinedValues.ENUM_2_VALUE_EXTENSION_FOR_ENUM_WITHOUT_DEFINED_VALUES;
    Enumeration enumerationOut = Enumeration.ENUM_0_VALUE_1;
    fireBroadcastWithMultipleEnumerationParameters(extendedEnumerationOut, enumerationOut, partitions);
    return new Promise<DeferredVoid>(deferred);
}
Also used : Promise(io.joynr.provider.Promise) Enumeration(joynr.interlanguagetest.Enumeration) ExtendedExtendedEnumeration(joynr.interlanguagetest.namedTypeCollection2.ExtendedExtendedEnumeration) ExtendedEnumerationWithPartlyDefinedValues(joynr.interlanguagetest.namedTypeCollection2.ExtendedEnumerationWithPartlyDefinedValues) DeferredVoid(io.joynr.provider.DeferredVoid)

Example 53 with Promise

use of io.joynr.provider.Promise in project joynr by bmwcarit.

the class IltProvider method methodWithMultiplePrimitiveParameters.

/*
     * methodWithMultiplePrimitiveParameters
     *
     * the 'float' of France is delivered as Double here, just return it as 'double'
     * and return the integer argument as string
     */
@Override
public Promise<MethodWithMultiplePrimitiveParametersDeferred> methodWithMultiplePrimitiveParameters(Integer int32Arg, Float floatArg, Boolean booleanArg) {
    logger.warn("**********************************************************");
    logger.warn("* IltProvider.methodWithMultiplePrimitiveParameters called");
    logger.warn("**********************************************************");
    MethodWithMultiplePrimitiveParametersDeferred deferred = new MethodWithMultiplePrimitiveParametersDeferred();
    // check input parameters
    if (int32Arg != 2147483647 || !IltUtil.cmpFloat(floatArg, 47.11f) || booleanArg != false) {
        logger.warn("methodWithMultiplePrimitiveParameters: invalid argument int32Arg, floatArg or booleanArg");
        deferred.reject(new ProviderRuntimeException("methodWithMultiplePrimitiveParameters: received wrong argument"));
        return new Promise<MethodWithMultiplePrimitiveParametersDeferred>(deferred);
    }
    // prepare output parameters
    Double doubleOut = (double) floatArg;
    String stringOut = int32Arg.toString();
    deferred.resolve(doubleOut, stringOut);
    return new Promise<MethodWithMultiplePrimitiveParametersDeferred>(deferred);
}
Also used : Promise(io.joynr.provider.Promise) MapStringString(joynr.interlanguagetest.namedTypeCollection2.MapStringString) ProviderRuntimeException(joynr.exceptions.ProviderRuntimeException)

Example 54 with Promise

use of io.joynr.provider.Promise in project joynr by bmwcarit.

the class IltProvider method methodToFireBroadcastWithSingleArrayParameter.

/*
     * methodToFireBroadcastWithSingleArrayParameter
     */
@Override
public Promise<DeferredVoid> methodToFireBroadcastWithSingleArrayParameter(String[] partitions) {
    logger.warn("******************************************************************");
    logger.warn("* IltProvider.methodToFireBroadcastWithSingleArrayParameter called");
    logger.warn("******************************************************************");
    DeferredVoid deferred = new DeferredVoid();
    String[] stringArrayOut = IltUtil.createStringArray();
    fireBroadcastWithSingleArrayParameter(stringArrayOut, partitions);
    deferred.resolve();
    return new Promise<DeferredVoid>(deferred);
}
Also used : Promise(io.joynr.provider.Promise) MapStringString(joynr.interlanguagetest.namedTypeCollection2.MapStringString) DeferredVoid(io.joynr.provider.DeferredVoid)

Example 55 with Promise

use of io.joynr.provider.Promise in project joynr by bmwcarit.

the class IltProvider method methodWithExtendedErrorEnum.

/*
     * methodWithExtendedErrorEnum
     */
@Override
public Promise<MethodWithExtendedErrorEnumDeferred> methodWithExtendedErrorEnum(String wantedExceptionArg) {
    logger.warn("************************************************");
    logger.warn("* IltProvider.methodWithExtendedErrorEnum called");
    logger.warn("************************************************");
    MethodWithExtendedErrorEnumDeferred deferred = new MethodWithExtendedErrorEnumDeferred();
    if (wantedExceptionArg.equals("ProviderRuntimeException")) {
        deferred.reject(new ProviderRuntimeException("Exception from methodWithExtendedErrorEnum"));
    } else if (wantedExceptionArg.equals("ApplicationException_1")) {
        deferred.reject(MethodWithExtendedErrorEnumErrorEnum.ERROR_3_3_NTC);
    } else if (wantedExceptionArg.equals("ApplicationException_2")) {
        deferred.reject(MethodWithExtendedErrorEnumErrorEnum.ERROR_2_1_TC2);
    } else {
        deferred.resolve();
    }
    return new Promise<MethodWithExtendedErrorEnumDeferred>(deferred);
}
Also used : Promise(io.joynr.provider.Promise) ProviderRuntimeException(joynr.exceptions.ProviderRuntimeException)

Aggregations

Promise (io.joynr.provider.Promise)79 DeferredVoid (io.joynr.provider.DeferredVoid)36 ProviderRuntimeException (joynr.exceptions.ProviderRuntimeException)27 MapStringString (joynr.interlanguagetest.namedTypeCollection2.MapStringString)13 Method (java.lang.reflect.Method)9 ProviderWrapper (io.joynr.jeeintegration.ProviderWrapper)6 JoynrProvider (io.joynr.provider.JoynrProvider)6 Test (org.junit.Test)6 JoynrException (io.joynr.exceptions.JoynrException)5 Deferred (io.joynr.provider.Deferred)4 PromiseListener (io.joynr.provider.PromiseListener)4 ExtendedExtendedBaseStruct (joynr.interlanguagetest.namedTypeCollection2.ExtendedExtendedBaseStruct)4 GlobalDiscoveryEntry (joynr.types.GlobalDiscoveryEntry)4 StructWithStringArray (joynr.interlanguagetest.namedTypeCollection1.StructWithStringArray)3 ExtendedTypeCollectionEnumerationInTypeCollection (joynr.interlanguagetest.namedTypeCollection2.ExtendedTypeCollectionEnumerationInTypeCollection)3 DiscoveryEntry (joynr.types.DiscoveryEntry)3 DiscoveryEntryWithMetaInfo (joynr.types.DiscoveryEntryWithMetaInfo)3 DiscoveryQos (io.joynr.arbitration.DiscoveryQos)2 DiscoveryScope (io.joynr.arbitration.DiscoveryScope)2 ProviderContainer (io.joynr.provider.ProviderContainer)2