0

I'm attempting to convert the following Java object initalization with dynamic class casting to camel spring bean syntax. I'm adding my broken spring bean sample as well. I dont have much familiarity with spring beans, so would very much appreciate some input. The Java syntax is:

import com.amazonaws.auth.STSAssumeRoleSessionCredentialsProvider;
STSAssumeRoleSessionCredentialsProvider credentials = new STSAssumeRoleSessionCredentialsProvider.Builder(
        "arn:aws:iam::***:role/myRole-QA", "sessionName").build();

and broken spring bean:

    <spring:bean id="sqsCredentials" class="com.amazonaws.auth.STSAssumeRoleSessionCredentialsProvider.Builder" >
    <spring:constructor-arg index="0" value="arn:aws:iam:***:role/myRole-QA" />
    <spring:constructor-arg index="1" value="sessionName" />
    <spring:property name="targetMethod">
        <spring:value>build</spring:value>
    </spring:property>        
</spring:bean>

I'm not sure if what I have for method build is correct, but there are two classes at play: .Builder and just STSAssumeRoleSessionCredentialsProvider. So Builder class returns STSAssumeRoleSessionCredentialsProvider. Most likely i have more then one issue to solve here, but the error I think is related to class mismatch ... much appreciate your time:

Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'targetMethod' of bean class 
[com.amazonaws.auth.STSAssumeRoleSessionCredentialsProvider$Builder]: Bean property 'targetMethod' is not writable 
or has an invalid setter method. Does the parameter type of the setter match the return type of the getter? 
user2917629
  • 883
  • 2
  • 15
  • 30
  • 1
    Read this https://stackoverflow.com/questions/3236850/spring-using-builder-pattern-to-create-a-bean . All your issues are described in answers ($ instead of dot, factory-bean, factory-method, ) – Bedla Feb 12 '19 at 18:26
  • yes, the notation helped + the 2nd reference for build seems to be working. – user2917629 Feb 13 '19 at 00:48
  • Just a note - This is not a Camel spring bean syntax, its plain Spring bean syntax. – Claus Ibsen Feb 13 '19 at 05:45
  • @ClausIbsen Yes... I though I'll point out that it is for camel so that noone will be telling me I could use something else instead of the Spring syntax. – user2917629 Feb 14 '19 at 00:43

0 Answers0