I have following JavaAWS
class in Groovy (it is using Java AWS SDK), but now I don't know how to re-use database connection in stage1 and stage2. Basically I'd like to use the same database connection everywhere and now I am not sure what is the way to achieve it.
My ReplicateInstanceStatus
and ReplicateMetricStatistics
classes are empty for the moment so I haven't pasted it there.
public class JavaAWS {
Object database = null
public static void main(String[] args) {
def obj = new JavaAWS()
obj.run()
}
public JavaAWS() {
database = new MongoClient()
}
public void run() {
println "Running stage 1 ReplicateInstanceStatus"
def stage1 = new ReplicateInstanceStatus()
def ret1 = stage1.run()
println "Running stage 2 ReplicateMetricStatistics"
def stage2 = new ReplicateMetricStatistics()
def ret2 = stage2.run()
}
}
Aucun commentaire:
Enregistrer un commentaire