-
1. Re: Loading environment properties from file
igarashitm Apr 16, 2014 10:06 AM (in response to jorgemoralespou_2)1 of 1 people found this helpfulHi Jorge,
We don't support loading environment properties from file right now, but it looks good to have. Could you raise a enhancement JIRA?
For now, you can use system environment variables to separate the property definition from switchyard.xml.
https://docs.jboss.org/author/display/SWITCHYARD/Properties
You can have properties file like this (say ftp.properties)
export ftp_server.host=localhost
export ftp_server.port=22
...
load above file from standalone.sh
. path/to/ftp.properties
and specify it from switchyard.xml with env. prefix
<ftp:host>${env.ftp_server.host}</ftp:host>
<ftp:port>${env.ftp_server.port}</ftp:port>
Thanks,
Tomo
-
2. Re: Loading environment properties from file
dward Apr 16, 2014 10:10 AM (in response to jorgemoralespou_2)This is not currently possible. Please feel free to add a Feature Request in our jira issue tracker. Thanks!
-
3. Re: Re: Loading environment properties from file
jorgemoralespou_2 Apr 16, 2014 10:24 AM (in response to igarashitm)What is the difference in defining this property as environment property or using a module to define properties? Shouldn't the later also work?
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <module xmlns="urn:jboss:module:1.0" name="com.examples.switchyard.properties"> <properties> <property name="ftp_server.host" value="localhost"/> <property name="ftp_server.port" value="22"/> <property name="ftp_server.username" value="user"/> <property name="ftp_server.password" value="xxxxx"/> <property name="ftp_server.default_share" value="/opt/tmp"/> </properties> </module>
Right now, I'm getting an exception, and per the documentation this should be possible.
ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC000001: Failed to start service jboss.deployment.unit."order-management-sim-stock.jar".SwitchYardService: org.jboss.msc.service.StartException in service jboss.deployment.unit."order-management-sim-stock.jar".SwitchYardService: java.lang.NumberFormatException: For input string: "${ftp_server.port}" at org.switchyard.as7.extension.services.SwitchYardService.start(SwitchYardService.java:81) at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.4.GA-redhat-1.jar:1.0.4.GA-redhat-1] at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.4.GA-redhat-1.jar:1.0.4.GA-redhat-1] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_45] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_45] at java.lang.Thread.run(Thread.java:744) [rt.jar:1.7.0_45] Caused by: java.lang.NumberFormatException: For input string: "${ftp_server.port}" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) [rt.jar:1.7.0_45] at java.lang.Integer.parseInt(Integer.java:481) [rt.jar:1.7.0_45] at java.lang.Integer.parseInt(Integer.java:527) [rt.jar:1.7.0_45] at org.switchyard.component.camel.common.model.v1.V1BaseCamelBindingModel.getIntegerConfig(V1BaseCamelBindingModel.java:197) at org.switchyard.component.camel.common.model.remote.v1.V1CamelRemoteFileBindingModel.getPort(V1CamelRemoteFileBindingModel.java:159) at org.switchyard.component.camel.common.model.remote.v1.V1CamelRemoteFileBindingModel.getComponentURI(V1CamelRemoteFileBindingModel.java:332) at org.switchyard.component.camel.common.handler.OutboundHandler.<init>(OutboundHandler.java:91) at org.switchyard.component.camel.common.handler.OutboundHandler.<init>(OutboundHandler.java:71) at org.switchyard.component.camel.common.deploy.BaseBindingActivator.activateBinding(BaseBindingActivator.java:45) at org.switchyard.deploy.internal.Deployment.deployReferenceBindings(Deployment.java:300) at org.switchyard.deploy.internal.Deployment.start(Deployment.java:143) at org.switchyard.as7.extension.deployment.SwitchYardDeployment.start(SwitchYardDeployment.java:121) at org.switchyard.as7.extension.services.SwitchYardService.start(SwitchYardService.java:74) ... 5 more
I've raised the JIRA ([SWITCHYARD-2048] Loading environment properties from file - JBoss Issue Tracker), and it would be nice to have an advice on this other topic, as using environment properties is not very nice :-(
-
4. Re: Re: Loading environment properties from file
dward Apr 16, 2014 10:24 AM (in response to jorgemoralespou_2)I'm not very familiar with the module properties, but you don't have to use environment properties. You can pass system properties as a command line option when starting up jboss.
-
5. Re: Re: Loading environment properties from file
dward Apr 16, 2014 10:30 AM (in response to dward)1 of 1 people found this helpfulYou can pass in a file of properties at command line like so (see -P option 2.1.6):
-
6. Re: Loading environment properties from file
jorgemoralespou_2 Apr 16, 2014 11:04 AM (in response to dward)Hi David,
It seems that there is a way to define a custom PropertiesResolver, and register it within the Switchyard xml element:
Could you please give advice on how to declare a new PropertyResolver, so we can test it ourselves and if it works, provide with a patch, as would like to also provide PropertyResolvers that gets configruation from ISPN cache.
-
7. Re: Loading environment properties from file
dward Apr 16, 2014 11:21 AM (in response to jorgemoralespou_2)PropertyResolvers are only set programmatically. They cannot be set/registered in the switchyard.xml file.
The recommended way of adding the capability you seek is by extending the switchyard xml schema in the correct way, and have the back-end configuration handling add to the compound property resolution. I'm sorry I don't have the bandwidth right now to explain it in step-by-step detail.
-
8. Re: Loading environment properties from file
rcernich Apr 16, 2014 11:22 AM (in response to dward)Another option is to add these as system properties to your EAP configuration file (e.g. standalone.xml). These properties can be added through the EAP console and management layer. Documentation link (for AS7): JBoss AS7 System Properties
Hope that helps,
Rob
-
9. Re: Loading environment properties from file
jorgemoralespou_2 Apr 16, 2014 11:44 AM (in response to dward)Don't worry. It seems rather complex as to being a supported solution :-(
We'll have to wait until more extensibility is provided in this area.
Thanks, good point. Although not of any value for properties that are set at deployment time, can be of much value for those that are set per request.