yew1eb commented on issue #1602:
URL: https://github.com/apache/auron/issues/1602#issuecomment-3514779293
@Tartarus0zm
I've successfully fixed the issue using JDK SPI — it now works perfectly.
Here’s the working pseudo-code:
```
// auron-core
public interface AuronAdaptorProvider {
AuronAdaptor create();
}
public abstract class AuronAdaptor {
public static AuronAdaptor getInstance() {
if (INSTANCE == null) {
synchronized (AuronAdaptor.class) {
if (INSTANCE == null) {
ServiceLoader<AuronAdaptorProvider> loader =
ServiceLoader.load(AuronAdaptorProvider.class);
for (AuronAdaptorProvider p : loader) {
INSTANCE = p.create();
break;
}
if (INSTANCE == null) {
throw new IllegalStateException("No
AuronAdaptorProvider found");
}
}
}
}
}
}
return INSTANCE;
}
// spark-extension
public class SparkAuronAdaptorProvider implements AuronAdaptorProvider {
@Override
public AuronAdaptor create() {
return new SparkAuronAdaptor();
}
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]