camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Muhzin <rmuh...@gmail.com>
Subject Re: Property Wiring in camel-Blueprint
Date Wed, 22 Jan 2014 11:40:57 GMT
Hi,
How can i refer to a value in an enum in the blueprint, for eg, in this
case We need to specify the member of  Regions enum given below to Region
bean.


/*
 * Copyright 2013-2013 Amazon Technologies, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at:
 *
 *    http://aws.amazon.com/apache2.0
 *
 * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
 * OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and
 * limitations under the License.
 */
package com.amazonaws.regions;

/**
 * Enumeration of region names
 */
public enum Regions {

    GovCloud("us-gov-west-1"),
    US_EAST_1("us-east-1"),
    US_WEST_1("us-west-1"),
    US_WEST_2("us-west-2"),
    EU_WEST_1("eu-west-1"),
    AP_SOUTHEAST_1("ap-southeast-1"),
    AP_SOUTHEAST_2("ap-southeast-2"),
    AP_NORTHEAST_1("ap-northeast-1"),
    SA_EAST_1("sa-east-1");

    /**
     * The default region that new customers in the US are encouraged to use
     * when using AWS services for the first time.
     */
    public static final Regions DEFAULT_REGION = US_WEST_2;

    private final String name;

    private Regions(String name) {
        this.name = name;
    }

    /**
     * The name of this region, used in the regions.xml file to identify it.
     */
    public String getName() {
        return name;
    }
}



On Wed, Jan 22, 2014 at 4:55 PM, Muhzin <rmuhzin@gmail.com> wrote:

> HI,
> Thanks. tried it and saw that AmazonWebServiceClient setRegion needed a
> value of  Region class
> so I modified it. Still getting error.
> modified blueprint :
>
> bean id="credentialProvider"
> class="com.amazonaws.auth.ClasspathPropertiesFileCredentialsProvider"/>
>
>     <bean id="awsRegion" class="com.amazonaws.regions.Region">
>         <argument type="java.lang.String" value="ap-southeast-1"/>
>     </bean>
>     <bean id="sqsClient"
> class="com.amazonaws.services.sqs.AmazonSQSClient">
>         <argument ref="credentialProvider" />
>         <property name="region" ref="awsRegion"/>
>     </bean>
>
>  ERROR Unable to start blueprint container for bundle cael-osgi
> org.osgi.service.blueprint.container.ComponentDefinitionException: Unable
> to find a matching constructor on class com.amazonaws.regions.Region for
> arguments [ap-southeast-1] when instanciating bean awsRegion
>
>
> There is a constructor in Region class that takes a String argument.
>
>
>
>
>
> On Wed, Jan 22, 2014 at 4:41 PM, Claus Ibsen <claus.ibsen@gmail.com>wrote:
>
>> Hi
>>
>> Try without the set, eg
>>
>>  <property name="region" value="ap-southeast-1"/>
>>
>> On Wed, Jan 22, 2014 at 12:09 PM, Muhzin <rmuhzin@gmail.com> wrote:
>> > Hi all,
>> >
>> > While trying to wire the a property in my blueprint.xml i got the
>> following
>> > error.
>> >
>> >
>> > blueprint.xml
>> >
>> > <bean id="credentialProvider"
>> > class="com.amazonaws.auth.ClasspathPropertiesFileCredentialsProvider"/>
>> >
>> >     <bean id="sqsClient"
>> class="com.amazonaws.services.sqs.AmazonSQSClient">
>> >         <argument ref="credentialProvider" />
>> >         <property name="setRegion" value="ap-southeast-1"/>
>> >     </bean>
>> >
>> > Error :
>> >
>> > Caused by:
>> > org.osgi.service.blueprint.container.ComponentDefinitionException:
>> Unable
>> > to find property descriptor setRegion on class
>> > com.amazonaws.services.sqs.AmazonSQSClient
>> >     at
>> >
>> org.apache.aries.blueprint.container.BeanRecipe.getPropertyDescriptor(BeanRecipe.java:954)
>> >     at
>> >
>> org.apache.aries.blueprint.container.BeanRecipe.setProperty(BeanRecipe.java:936)
>> >     at
>> >
>> org.apache.aries.blueprint.container.BeanRecipe.setProperties(BeanRecipe.java:907)
>> >     at
>> >
>> org.apache.aries.blueprint.container.BeanRecipe.setProperties(BeanRecipe.java:888)
>> >     at
>> >
>> org.apache.aries.blueprint.container.BeanRecipe.internalCreate2(BeanRecipe.java:820)
>> >     at
>> >
>> org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:787)
>> >     at
>> >
>> org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:79)
>> >     at java.util.concurrent.FutureTask.run(FutureTask.java:262)
>> >     at
>> >
>> org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:88)
>> >     at
>> >
>> org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintRepository.java:245)
>> >     at
>> >
>> org.apache.aries.blueprint.container.BlueprintRepository.createAll(BlueprintRepository.java:183)
>> >     at
>> >
>> org.apache.aries.blueprint.container.BlueprintContainerImpl.instantiateEagerComponents(BlueprintContainerImpl.java:668)
>> >     at
>> >
>> org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:370)
>> >     at
>> >
>> org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:261)
>> >     at
>> > java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
>> >     at java.util.concurrent.FutureTask.run(FutureTask.java:262)
>> >     at
>> >
>> org.apache.aries.blueprint.container.ExecutorServiceWrapper.run(ExecutorServiceWrapper.java:106)
>> >     at
>> >
>> org.apache.aries.blueprint.utils.threading.impl.DiscardableRunnable.run(DiscardableRunnable.java:48)
>> >     at
>> > java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
>> >     at java.util.concurrent.FutureTask.run(FutureTask.java:262)
>> >     at
>> >
>> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)
>> >     at
>> >
>> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)
>> >     at
>> >
>> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
>> >     at
>> >
>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
>> >     at java.lang.Thread.run(Thread.java:744)
>> >
>> >
>> > There a method  setRegion in AmazonWebServiceClient which
>> > the AmazonSQSClient class extends.
>> >
>> > Can anyone help me give some pointers.
>> > Thanks
>> > --
>> > BR
>> > Muhsin
>>
>>
>>
>> --
>> Claus Ibsen
>> -----------------
>> Red Hat, Inc.
>> Email: cibsen@redhat.com
>> Twitter: davsclaus
>> Blog: http://davsclaus.com
>> Author of Camel in Action: http://www.manning.com/ibsen
>> Make your Camel applications look hawt, try: http://hawt.io
>>
>
>
>
> --
> BR
> Muhsin
>



-- 
BR
Muhsin

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message