Search in sources :

Example 21 with BizModel

use of com.alipay.sofa.ark.container.model.BizModel 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;
}
Also used : Biz(com.alipay.sofa.ark.spi.model.Biz) BizModel(com.alipay.sofa.ark.container.model.BizModel) BizManagerService(com.alipay.sofa.ark.spi.service.biz.BizManagerService) ArkRuntimeException(com.alipay.sofa.ark.exception.ArkRuntimeException)

Example 22 with BizModel

use of com.alipay.sofa.ark.container.model.BizModel in project sofa-ark by alipay.

the class BaseTest method registerMockBiz.

protected void registerMockBiz() {
    if (arkContainer == null) {
        String[] args = new String[] { "-Ajar=" + jarURL.toExternalForm() };
        arkContainer = (ArkContainer) ArkContainer.main(args);
    }
    BizManagerService bizManagerService = ArkServiceContainerHolder.getContainer().getService(BizManagerService.class);
    Biz biz = new BizModel().setBizName("mock").setBizVersion("1.0").setClassLoader(this.getClass().getClassLoader()).setDenyImportPackages("").setDenyImportClasses("").setDenyImportResources("").setBizState(BizState.RESOLVED);
    bizManagerService.registerBiz(biz);
    ((BizModel) biz).setBizState(BizState.ACTIVATED);
}
Also used : Biz(com.alipay.sofa.ark.spi.model.Biz) BizModel(com.alipay.sofa.ark.container.model.BizModel) BizManagerService(com.alipay.sofa.ark.spi.service.biz.BizManagerService)

Example 23 with BizModel

use of com.alipay.sofa.ark.container.model.BizModel in project sofa-ark by alipay.

the class TestClassLoader 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;
}
Also used : Biz(com.alipay.sofa.ark.spi.model.Biz) BizModel(com.alipay.sofa.ark.container.model.BizModel) BizManagerService(com.alipay.sofa.ark.spi.service.biz.BizManagerService) ArkRuntimeException(com.alipay.sofa.ark.exception.ArkRuntimeException)

Example 24 with BizModel

use of com.alipay.sofa.ark.container.model.BizModel in project sofa-ark by alipay.

the class BizManagerServiceTest method testRemovingAndAddBiz.

@Test
public void testRemovingAndAddBiz() {
    Biz adding = new BizModel().setBizName("test-biz-adding").setBizVersion("1.0.0").setBizState(BizState.ACTIVATED);
    Biz removing = new BizModel().setBizName("test-biz-removing").setBizVersion("1.0.0").setBizState(BizState.RESOLVED);
    bizManagerService.registerBiz(removing);
    ((BizModel) removing).setBizState(BizState.ACTIVATED);
    bizManagerService.removeAndAddBiz(adding, removing);
    List<Biz> biz = bizManagerService.getBiz("test-biz-adding");
    Assert.assertTrue(biz.size() == 1);
    biz = bizManagerService.getBiz("test-biz-removing");
    Assert.assertTrue(biz.size() == 0);
    bizManagerService.unRegisterBiz(adding.getBizName(), adding.getBizVersion());
}
Also used : Biz(com.alipay.sofa.ark.spi.model.Biz) BizModel(com.alipay.sofa.ark.container.model.BizModel) BaseTest(com.alipay.sofa.ark.container.BaseTest) Test(org.junit.Test)

Example 25 with BizModel

use of com.alipay.sofa.ark.container.model.BizModel in project sofa-ark by alipay.

the class BizManagerServiceTest method before.

@Before
public void before() {
    super.before();
    Biz biz = new BizModel().setBizName("test-biz").setBizVersion("1.0.0").setBizState(BizState.RESOLVED);
    bizManagerService.registerBiz(biz);
}
Also used : Biz(com.alipay.sofa.ark.spi.model.Biz) BizModel(com.alipay.sofa.ark.container.model.BizModel) Before(org.junit.Before)

Aggregations

BizModel (com.alipay.sofa.ark.container.model.BizModel)31 Test (org.junit.Test)22 BaseTest (com.alipay.sofa.ark.container.BaseTest)18 Biz (com.alipay.sofa.ark.spi.model.Biz)12 ITest (com.alipay.sofa.ark.container.testdata.ITest)11 URL (java.net.URL)11 PluginModel (com.alipay.sofa.ark.container.model.PluginModel)8 HandleArchiveStage (com.alipay.sofa.ark.container.pipeline.HandleArchiveStage)4 BizManagerService (com.alipay.sofa.ark.spi.service.biz.BizManagerService)3 URLClassLoader (java.net.URLClassLoader)3 HashSet (java.util.HashSet)3 BizClassLoader (com.alipay.sofa.ark.container.service.classloader.BizClassLoader)2 ArkRuntimeException (com.alipay.sofa.ark.exception.ArkRuntimeException)2 ExplodedBizArchive (com.alipay.sofa.ark.loader.ExplodedBizArchive)2 AfterBizStartupEvent (com.alipay.sofa.ark.spi.event.biz.AfterBizStartupEvent)2 BeforePluginStartupEvent (com.alipay.sofa.ark.spi.event.plugin.BeforePluginStartupEvent)2 Plugin (com.alipay.sofa.ark.spi.model.Plugin)2 Attributes (java.util.jar.Attributes)2 ArkClient (com.alipay.sofa.ark.api.ArkClient)1 JarBizArchive (com.alipay.sofa.ark.loader.JarBizArchive)1