user833970
user833970

Reputation: 2799

calling methods in Spring configurations

I am tying to migrate hard coded database dependencies into the spring framework

so

Mongo m = new Mongo("192.168.0.0.1");

DB db = m.getDB("db name");

db.authenticate("user", "pass".toCharArray());

would become:

<mongo:mongo host="192.168.0.0.1" port="27017" />

<bean id="mongoDatabase"
  factory-bean="mongo"
  factory-method="getDB">
  <constructor-arg value="db name" />
</bean>

But I am not sure how to call authenticate. It would be nice to know the best way to do this generally.

(Usernames and passwords have been changed to protect the innocent)

Upvotes: 0

Views: 182

Answers (1)

Eugene Kuleshov
Eugene Kuleshov

Reputation: 31795

You can use <mongo:db-factory>.

Upvotes: 3

Related Questions