Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Open
@ruanwenjun

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.

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /