How do you mean it does not get the value? How do you set the property? In
blueprint? In spring xml or using the plain java via properties file?



On Wed, Nov 16, 2016 at 6:51 PM, shuston [via Camel] <
ml-node+s465427n5790193...@n5.nabble.com> wrote:

> Thank you for the responses thus far. I still have some confusion and an
> observation.
>
> First, I find it very confusing and non-intuitive that the "properties" in
> CamelContext are apparently not the "properties" in property placeholder.
> From my reading of the various doc pages it seemed like property
> placeholders are ways to get values from the properties substituted into
> routes. But it seems like maybe there are more than one set, or type, of
> properties. Is this true?
>
> My observation... in my test below I added @PropertyInject("datafile") on
> the line above "private String filename;" and that _did_ get the value set
> via useOverridePropertiesWithPropertiesComponent(). However, if I add the
> same @PropertyInject to a member in the MyRouteBuilder class, that _does
> not_ get the value.
>
> Can someone please help me understand what's going on here?
>
> Thanks,
> -Steve
>
> > -----Original Message-----
> > From: Claus Ibsen [mailto:[hidden email]
> <http:///user/SendEmail.jtp?type=node&node=5790193&i=0>]
> > Sent: Wednesday, November 16, 2016 9:59 AM
> > To: [hidden email]
> <http:///user/SendEmail.jtp?type=node&node=5790193&i=1>
> > Subject: Re: Seeking to understand properties
> >
> > Hi
> >
> > context().getProperty("dataFile");
> >
> > is not property placeholders. Its just generic key/value pairs on
> > CamelContext. See the javadoc of the API.
> >
> > For property placeholders take a look at http://camel.apache.org/using-
> > propertyplaceholder.html
> >
> > On Tue, Nov 15, 2016 at 11:58 PM, Steve Huston <[hidden email]
> <http:///user/SendEmail.jtp?type=node&node=5790193&i=2>>
> > wrote:
> > > I am struggling to understand something I fear is very basic, but I
> just don't
> > see it. Hoping someone can help me understand this.
> > >
> > > Properties... I can use them in route definitions, but I don't seem to
> be able
> > to obtain their values in regular Java code.
> > >
> > > Example (using Camel 2.16.3):
> > >
> > > I have a route builder:
> > >
> > > public class MyRouteBuilder extends RouteBuilder {
> > >     public void configure() {
> > >         from("file:{{dataFile}}?noop=true")
> > >          .to("file:target/messages/others");
> > >     }
> > > }
> > >
> > > And a unit test:
> > >
> > > @RunWith(JUnit4.class)
> > > public class UnitTest extends CamelTestSupport {
> > >
> > >         private String fileName;
> > >
> > >             @Override
> > >             protected RouteBuilder createRouteBuilder() {
> > >                 return new MyRouteBuilder();
> > >             }
> > >
> > >             @Override
> > >             public Boolean ignoreMissingLocationWithPropertiesComponent()
> {
> > >                 return true;
> > >             }
> > >
> > >             @Override
> > >             protected Properties
> > useOverridePropertiesWithPropertiesComponent() {
> > >                     Properties override = new Properties();
> > >                     override.put("dataFile", "overridden-file");
> > >                     return override;
> > >             }
> > >
> > >             @Test
> > >                 public void testPropertyGetting() throws Exception {
> > >                 fileName = context().getProperty("dataFile");
> > >                 assert(fileName != null);
> > >             }
> > > }
> > >
> > > When I run this test, the output includes:
> > >
> > > INFO  Route: route1 started and consuming from:
> > > Endpoint[file://overridden-file?noop=true]
> > >
> > > So the override property set above did get filled into the route
> definition.
> > > However, when I try to get the property in the testPropertyGetting()
> > > method, the value is null
> > >
> > > Why???
> > >
> > > -Steve
> > >
> >
> >
> >
> > --
> > Claus Ibsen
> > -----------------
> > http://davsclaus.com @davsclaus
> > Camel in Action 2: https://www.manning.com/ibsen2
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
> http://camel.465427.n5.nabble.com/Seeking-to-understand-
> properties-tp5790156p5790193.html
> To start a new topic under Camel - Users, email
> ml-node+s465427n465428...@n5.nabble.com
> To unsubscribe from Camel - Users, click here
> <http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=465428&code=c291Y2lhbmNlLmVxZGFtLnJhc2h0aUBnbWFpbC5jb218NDY1NDI4fDE1MzI5MTE2NTY=>
> .
> NAML
> <http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: 
http://camel.465427.n5.nabble.com/Seeking-to-understand-properties-tp5790156p5790194.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to