Galadriel
Galadriel

Reputation: 369

Using different classpaths for a type at runtime in java class

I am working on a legacy/ migration project. Therefore both, the new and the old way should be possible. That means, that some classes/services should be used with old imports as well as with new ones. For example those two imports should be used dependent on a property in in application.properties and if possible at runtime exchanged.

org.apache.activemq.artemis.jms.client.ActiveMQDestination
org.apache.activemq.command.ActiveMQDestination

I have read of a maven shade plugin, but I don't get it completely and I am not sure, if it is the right thing, that I need.

Can anyone help here?

Upvotes: 0

Views: 118

Answers (1)

Santosh b
Santosh b

Reputation: 798

Based on env variable use 

if(condition1){
 Class.forName("org.apache.activemq.artemis.jms.client.ActiveMQDestination")
}
if(condition2){
  Class.forName("org.apache.activemq.command.ActiveMQDestination")
}

Upvotes: 1

Related Questions