-
Notifications
You must be signed in to change notification settings - Fork 222
Open
Description
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.
Lines 46 to 65 in 5d79606
public static MessagingAccessPoint getMessagingAccessPoint(String url, KeyValue attributes) { | |
AccessPointURI accessPointURI = new AccessPointURI(url); | |
String driverImpl = parseDriverImpl(accessPointURI.getDriverType(), attributes); | |
attributes.put(OMSBuiltinKeys.ACCESS_POINTS, accessPointURI.getHosts()); | |
attributes.put(OMSBuiltinKeys.DRIVER_IMPL, driverImpl); | |
attributes.put(OMSBuiltinKeys.REGION, accessPointURI.getRegion()); | |
attributes.put(OMSBuiltinKeys.ACCOUNT_ID, accessPointURI.getAccountId()); | |
try { | |
Class<?> driverImplClass = Class.forName(driverImpl); | |
Constructor constructor = driverImplClass.getConstructor(KeyValue.class); | |
MessagingAccessPoint vendorImpl = (MessagingAccessPoint) constructor.newInstance(attributes); | |
checkSpecVersion(OMS.specVersion, vendorImpl.version()); | |
return vendorImpl; | |
} catch (Throwable e) { | |
throw generateException(OMSResponseStatus.STATUS_10000, url); | |
} | |
} | |
Metadata
Metadata
Assignees
Labels
No labels