Question

Here is a snippet from our context:

   <bean id="dataSource" class="com.jolbox.bonecp.BoneCPDataSource" destroy-method="close">
    <property name="driverClass" value="oracle.jdbc.OracleDriver"/>
    <property name="jdbcUrl" value="jdbc:oracle:thin:@localhost:1521:ORA11G"/>
    <property name="username" value="USER"/>
    <property name="password" value="PASSWORD"/>
    <property name="maxConnectionsPerPartition" value="30"/>
    <property name="minConnectionsPerPartition" value="10"/>
    <property name="partitionCount" value="3"/>
    <property name="acquireIncrement" value="5"/>
    <property name="statementsCacheSize" value="100"/>
    <property name="connectionTestStatement" value="SELECT 1 FROM DUAL"/>
</bean>

I have an existing Java class that can decrypt a proprietary encrypted binary file that contains username/password/Port/Instance information. It is desirable to re-use this because it's currently exists, and it's one less configuration item to keep track of/mess-up. Not to mention the storing of user/password information in plain text.

Is there a way to override these SQL property values for use downstream in the route?

Was it helpful?

Solution

You don't mention what version of Spring you're using, but in any case you can set those properties using either a bean post processor or using Spring Expression Language (Spring-EL). Here is one example (there are probably others).

You would then leverage your binary-file-reading class either as a bean directly or, if it doesn't have the requisite methods (for example getters) that you need, indirectly (e.g. by composition inside some other bean, i.e. an instance of a class you write that leverages that binary-file-reading class).

OTHER TIPS

It seems inefficient to create a datasource with one set of properties then overwrite them with another. Why not do it all on one go?

You could implement your own datasource class to read your binary file! The datasource would have an instance of your special decryption object that would read a file. The file location can be passed to your datasource as a property when you define the datasource bean.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top