0

I am using SwithcYard 2.0.0.Beta1. Application server is WildFly 8.1. I want to load properties from modules. As example I have a module /wildfly/modules/system/layers/base/org/study/configuration/test my module.xml

<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.3" name="org.study.configuration" slot="test">  
    <resources>  
        <resource-root path="."/>  
    </resources>  
</module>  

This is properties file:

user=foo
password=bar
provider=CryptoProvider
directory=domain;login:pwd@host/dir?password=pwd&preMove=backup&move=processed&moveFailed=error&charset=UTF-8

This is how I include that module in wildfly profile:

    <subsystem xmlns="urn:jboss:domain:ee:2.0">
        <global-modules>
            <module name="org.study.configuration" slot="test"/>
        </global-modules>

And now I want to load that properties in my camel route:

.to("smb://{{directory}}")

or in bean

KeyStore ks = KeyStore.getInstance("PKCS12", {{provider}});

Is it possible? how to do this?

Maciavelli
  • 101
  • 1
  • 14

1 Answers1

0

It is possible, but as long as your properties are in the file you have to load it first.

What you define in the module - it is just a class path for your application.

If you use Java DSL:

Properties myProps = new Properties();

Stream is = this.getClass().getClassLoader().getResourceAsStream("MyAppProp.properties");
myProps.load(is);       
System.getProperties().putAll(myProps); 

If you use Spring DSL just define regular Spring properties.

a. with Spring bean namespace

<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="location">
        <value>MyAppProp.properties</value>
    </property>
</bean>

b. with Spring context namespace

<context:property-placeholder location="MyAppProp.properties"/>

Then you can use them inside Camel route as you said:

.to("smb://{{directory}}") 

PS. you have an ability to define properties directly in the module.xml as well

<module xmlns="urn:jboss:module:1.3" name="org.study.configuration" slot="test">
  <properties>
    <property name="directory" value="myTestDirectory"/>
  </properties>
  ...
Vadim
  • 4,027
  • 2
  • 10
  • 26