openmessaging / openmessaging-java

OpenMessaging Runtime Interface for Java
http://openmessaging.cloud/
Apache License 2.0
723 stars 220 forks source link

Use Class.forName(String name, boolean initialize,ClassLoader loader) to get the MessagingAccessPoint.class #92

Open ruanwenjun opened 3 years ago

ruanwenjun commented 3 years ago

Sometimes we use OMS.builder().build(properties) to create the MessagingAccessPoint, it can work well in most scenarios. But sometimes there are existed problem.

If we load the openmessaging-api in moduleA, and we use a customized ClassLoader to load the driver class, then we cannot get the driver class by Class.forName(driverImpl)

It is better to use Class.forName(String name, boolean initialize,ClassLoader loader) to get the driver class in line 50.

https://github.com/openmessaging/openmessaging-java/blob/5d79606316033de21cf784232c27d2fd65d31d44/openmessaging-api/src/main/java/io/openmessaging/internal/MessagingAccessPointAdapter.java#L46-L65