use of com.alipay.sofa.ark.exception.ArkRuntimeException in project sofa-ark by alipay.
the class ExtensionServiceTest method testNoExtensionAnnotation.
@Test
public void testNoExtensionAnnotation() {
PluginManagerService pluginManagerService = ArkServiceContainerHolder.getContainer().getService(PluginManagerService.class);
PluginModel pluginModel = new PluginModel().setPluginClassLoader(this.getClass().getClassLoader()).setPluginName("mock-plugin");
pluginManagerService.registerPlugin(pluginModel);
try {
ArkServiceLoader.loadExtensionFromArkPlugin(ServiceD.class, "", "mock-plugin");
} catch (ArkRuntimeException ex) {
Assert.assertTrue(ex.getMessage().contains(String.format("is not annotated by %s.", Extension.class)));
}
}
use of com.alipay.sofa.ark.exception.ArkRuntimeException in project sofa-ark by alipay.
the class ZookeeperConfigActivator method subscribeIpConfig.
protected void subscribeIpConfig() {
ipNodeCache = new NodeCache(zkClient, ipResourcePath);
ipNodeCache.getListenable().addListener(new NodeCacheListener() {
private int version = -1;
@Override
public void nodeChanged() throws Exception {
if (ipNodeCache.getCurrentData() != null && ipNodeCache.getCurrentData().getStat().getVersion() > version) {
version = ipNodeCache.getCurrentData().getStat().getVersion();
String configData = new String(ipNodeCache.getCurrentData().getData());
ipConfigDeque.add(configData);
LOGGER.info("Receive ip config data: {}, version is {}.", configData, version);
}
}
});
try {
LOGGER.info("Subscribe ip config: {}.", ipResourcePath);
ipNodeCache.start(true);
} catch (Exception e) {
throw new ArkRuntimeException("Failed to subscribe ip resource path.", e);
}
}
use of com.alipay.sofa.ark.exception.ArkRuntimeException in project sofa-ark by alipay.
the class ZookeeperConfigActivator method subscribeBizConfig.
protected void subscribeBizConfig() {
bizNodeCache = new NodeCache(zkClient, bizResourcePath);
bizNodeCache.getListenable().addListener(new NodeCacheListener() {
private int version = -1;
@Override
public void nodeChanged() throws Exception {
if (bizNodeCache.getCurrentData() != null && bizNodeCache.getCurrentData().getStat().getVersion() > version) {
version = bizNodeCache.getCurrentData().getStat().getVersion();
String configData = new String(bizNodeCache.getCurrentData().getData());
bizConfigDeque.add(configData);
LOGGER.info("Receive app config data: {}, version is {}.", configData, version);
}
}
});
try {
bizNodeCache.start(true);
} catch (Exception e) {
throw new ArkRuntimeException("Failed to subscribe resource path.", e);
}
}
use of com.alipay.sofa.ark.exception.ArkRuntimeException in project sofa-ark by alipay.
the class ExtensionServiceTest method testNotExtensibleService.
@Test
public void testNotExtensibleService() {
PluginManagerService pluginManagerService = ArkServiceContainerHolder.getContainer().getService(PluginManagerService.class);
PluginModel pluginModel = new PluginModel().setPluginClassLoader(this.getClass().getClassLoader()).setPluginName("mock-plugin");
pluginManagerService.registerPlugin(pluginModel);
try {
ArkServiceLoader.loadExtensionFromArkPlugin(ServiceC.class, "", "mock-plugin");
} catch (ArkRuntimeException ex) {
Assert.assertTrue(ex.getMessage().contains(String.format("is not annotated by %s.", Extensible.class)));
}
}
use of com.alipay.sofa.ark.exception.ArkRuntimeException in project sofa-ark by alipay.
the class NoneDelegateTestClassLoader method createTestBiz.
private Biz createTestBiz(String bizIdentity) {
String[] bizNameAndVersion = bizIdentity.split(":");
if (bizNameAndVersion.length != 2) {
throw new ArkRuntimeException("error bizIdentity format.");
}
BizManagerService bizManagerService = ArkServiceContainerHolder.getContainer().getService(BizManagerService.class);
Biz testBiz = new BizModel().setBizName(bizNameAndVersion[0]).setBizVersion(bizNameAndVersion[1]).setClassLoader(this).setDenyImportPackages("").setDenyImportClasses("").setDenyImportResources("").setBizState(BizState.RESOLVED);
bizManagerService.registerBiz(testBiz);
return testBiz;
}
Aggregations