Search in sources :

Example 16 with Biz

use of com.alipay.sofa.ark.spi.model.Biz in project sofa-ark by alipay.

the class BizManagerServiceImpl method isActiveBiz.

@Override
public boolean isActiveBiz(String bizName, String bizVersion) {
    AssertUtils.isFalse(StringUtils.isEmpty(bizName), "Biz name must not be empty.");
    AssertUtils.isFalse(StringUtils.isEmpty(bizVersion), "Biz version must not be empty.");
    Map<String, Biz> bizCache = bizRegistration.get(bizName);
    if (bizCache != null) {
        Biz biz = bizCache.get(bizVersion);
        return biz != null && (biz.getBizState() == BizState.ACTIVATED);
    }
    return false;
}
Also used : Biz(com.alipay.sofa.ark.spi.model.Biz)

Example 17 with Biz

use of com.alipay.sofa.ark.spi.model.Biz in project sofa-ark by alipay.

the class BizManagerServiceImpl method getBizState.

@Override
public BizState getBizState(String bizName, String bizVersion) {
    AssertUtils.isFalse(StringUtils.isEmpty(bizName), "Biz name must not be empty.");
    AssertUtils.isFalse(StringUtils.isEmpty(bizVersion), "Biz version must not be empty.");
    Map<String, Biz> bizCache = bizRegistration.get(bizName);
    if (bizCache != null) {
        Biz biz = bizCache.get(bizVersion);
        return biz != null ? biz.getBizState() : BizState.UNRESOLVED;
    }
    return BizState.UNRESOLVED;
}
Also used : Biz(com.alipay.sofa.ark.spi.model.Biz)

Example 18 with Biz

use of com.alipay.sofa.ark.spi.model.Biz in project sofa-ark by alipay.

the class BizManagerServiceImpl method activeBiz.

@Override
public void activeBiz(String bizName, String bizVersion) {
    AssertUtils.isFalse(StringUtils.isEmpty(bizName), "Biz name must not be empty.");
    AssertUtils.isFalse(StringUtils.isEmpty(bizVersion), "Biz version must not be empty.");
    Biz biz = getBiz(bizName, bizVersion);
    Biz activeBiz = getActiveBiz(bizName);
    if (biz != null && biz.getBizState() == BizState.DEACTIVATED) {
        if (activeBiz != null) {
            ((BizModel) activeBiz).setBizState(BizState.DEACTIVATED);
        }
        ((BizModel) biz).setBizState(BizState.ACTIVATED);
    }
}
Also used : Biz(com.alipay.sofa.ark.spi.model.Biz) BizModel(com.alipay.sofa.ark.container.model.BizModel)

Example 19 with Biz

use of com.alipay.sofa.ark.spi.model.Biz in project sofa-ark by alipay.

the class ExtensionLoaderServiceImpl method getExtensionContributorFromArkBiz.

@Override
public <T> T getExtensionContributorFromArkBiz(Class<T> interfaceType, String extensionName, String bizIdentity) {
    AssertUtils.assertNotNull(interfaceType, "interfaceType can't be null.");
    AssertUtils.assertNotNull(extensionName, "extensionName can't be null.");
    AssertUtils.assertNotNull(bizIdentity, "bizIdentity can't be null.");
    Biz biz = bizManagerService.getBizByIdentity(bizIdentity);
    AssertUtils.assertNotNull(biz, "biz: " + bizIdentity + " is null");
    return getExtensionContributor(interfaceType, extensionName, biz, biz.getBizClassLoader());
}
Also used : Biz(com.alipay.sofa.ark.spi.model.Biz)

Example 20 with Biz

use of com.alipay.sofa.ark.spi.model.Biz in project sofa-ark by alipay.

the class EventTest method testEvent.

@Test
public void testEvent() {
    Biz biz = new BizModel().setBizName("test-biz").setBizVersion("1.0.0").setBizState(BizState.RESOLVED);
    Plugin plugin = new PluginModel().setPluginName("test-plugin").setVersion("1.0.0");
    eventAdminService.sendEvent(new AfterBizStartupEvent(biz));
    Assert.assertTrue(result.get(0).equalsIgnoreCase(Constants.BIZ_EVENT_TOPIC_AFTER_INVOKE_BIZ_START));
    eventAdminService.sendEvent(new BeforeBizStartupEvent(biz));
    Assert.assertTrue(result.get(1).equalsIgnoreCase(Constants.BIZ_EVENT_TOPIC_BEFORE_INVOKE_BIZ_START));
    eventAdminService.sendEvent(new BeforeBizStopEvent(biz));
    Assert.assertTrue(result.get(2).equalsIgnoreCase(Constants.BIZ_EVENT_TOPIC_BEFORE_INVOKE_BIZ_STOP));
    eventAdminService.sendEvent(new AfterBizStopEvent(biz));
    Assert.assertTrue(result.get(3).equalsIgnoreCase(Constants.BIZ_EVENT_TOPIC_AFTER_INVOKE_BIZ_STOP));
    eventAdminService.sendEvent(new BeforeBizSwitchEvent(biz));
    Assert.assertTrue(result.get(4).equalsIgnoreCase(Constants.BIZ_EVENT_TOPIC_BEFORE_INVOKE_BIZ_SWITCH));
    eventAdminService.sendEvent(new AfterBizSwitchEvent(biz));
    Assert.assertTrue(result.get(5).equalsIgnoreCase(Constants.BIZ_EVENT_TOPIC_AFTER_INVOKE_BIZ_SWITCH));
    eventAdminService.sendEvent(new AfterPluginStartupEvent(plugin));
    Assert.assertTrue(result.get(6).equalsIgnoreCase(Constants.PLUGIN_EVENT_TOPIC_AFTER_INVOKE_PLUGIN_START));
    eventAdminService.sendEvent(new AfterPluginStopEvent(plugin));
    Assert.assertTrue(result.get(7).equalsIgnoreCase(Constants.PLUGIN_EVENT_TOPIC_AFTER_INVOKE_PLUGIN_STOP));
    eventAdminService.sendEvent(new BeforePluginStartupEvent(plugin));
    Assert.assertTrue(result.get(8).equalsIgnoreCase(Constants.PLUGIN_EVENT_TOPIC_BEFORE_INVOKE_PLUGIN_START));
    eventAdminService.sendEvent(new BeforePluginStopEvent(plugin));
    Assert.assertTrue(result.get(9).equalsIgnoreCase(Constants.PLUGIN_EVENT_TOPIC_BEFORE_INVOKE_PLUGIN_STOP));
    eventAdminService.sendEvent(new AfterFinishDeployEvent());
    Assert.assertTrue(result.get(10).equalsIgnoreCase(Constants.ARK_EVENT_TOPIC_AFTER_FINISH_DEPLOY_STAGE));
    eventAdminService.sendEvent(new AfterFinishStartupEvent());
    Assert.assertTrue(result.get(11).equalsIgnoreCase(Constants.ARK_EVENT_TOPIC_AFTER_FINISH_STARTUP_STAGE));
    eventAdminService.sendEvent(new TestArkEvent(""));
    Assert.assertTrue(result.get(12).equalsIgnoreCase("test-ark"));
    eventAdminService.sendEvent(new BeforeBizRecycleEvent(biz));
    Assert.assertTrue(result.get(13).equalsIgnoreCase(Constants.BIZ_EVENT_TOPIC_BEFORE_RECYCLE_BIZ));
}
Also used : BeforePluginStopEvent(com.alipay.sofa.ark.spi.event.plugin.BeforePluginStopEvent) AfterPluginStartupEvent(com.alipay.sofa.ark.spi.event.plugin.AfterPluginStartupEvent) AfterBizStartupEvent(com.alipay.sofa.ark.spi.event.biz.AfterBizStartupEvent) AfterFinishStartupEvent(com.alipay.sofa.ark.spi.event.AfterFinishStartupEvent) BeforeBizSwitchEvent(com.alipay.sofa.ark.spi.event.biz.BeforeBizSwitchEvent) BizModel(com.alipay.sofa.ark.container.model.BizModel) AfterBizStopEvent(com.alipay.sofa.ark.spi.event.biz.AfterBizStopEvent) BeforeBizRecycleEvent(com.alipay.sofa.ark.spi.event.biz.BeforeBizRecycleEvent) PluginModel(com.alipay.sofa.ark.container.model.PluginModel) BeforePluginStartupEvent(com.alipay.sofa.ark.spi.event.plugin.BeforePluginStartupEvent) Biz(com.alipay.sofa.ark.spi.model.Biz) BeforeBizStartupEvent(com.alipay.sofa.ark.spi.event.biz.BeforeBizStartupEvent) AfterFinishDeployEvent(com.alipay.sofa.ark.spi.event.AfterFinishDeployEvent) AfterBizSwitchEvent(com.alipay.sofa.ark.spi.event.biz.AfterBizSwitchEvent) BeforeBizStopEvent(com.alipay.sofa.ark.spi.event.biz.BeforeBizStopEvent) Plugin(com.alipay.sofa.ark.spi.model.Plugin) AfterPluginStopEvent(com.alipay.sofa.ark.spi.event.plugin.AfterPluginStopEvent) BaseTest(com.alipay.sofa.ark.container.BaseTest) Test(org.junit.Test)

Aggregations

Biz (com.alipay.sofa.ark.spi.model.Biz)38 Test (org.junit.Test)14 BaseTest (com.alipay.sofa.ark.container.BaseTest)13 BizModel (com.alipay.sofa.ark.container.model.BizModel)12 ArkRuntimeException (com.alipay.sofa.ark.exception.ArkRuntimeException)6 BizManagerService (com.alipay.sofa.ark.spi.service.biz.BizManagerService)6 Plugin (com.alipay.sofa.ark.spi.model.Plugin)5 AfterBizStartupEvent (com.alipay.sofa.ark.spi.event.biz.AfterBizStartupEvent)3 PluginModel (com.alipay.sofa.ark.container.model.PluginModel)2 ExecutableArchive (com.alipay.sofa.ark.spi.archive.ExecutableArchive)2 PluginArchive (com.alipay.sofa.ark.spi.archive.PluginArchive)2 AfterBizSwitchEvent (com.alipay.sofa.ark.spi.event.biz.AfterBizSwitchEvent)2 BeforeBizStartupEvent (com.alipay.sofa.ark.spi.event.biz.BeforeBizStartupEvent)2 BeforeBizSwitchEvent (com.alipay.sofa.ark.spi.event.biz.BeforeBizSwitchEvent)2 BeforePluginStartupEvent (com.alipay.sofa.ark.spi.event.plugin.BeforePluginStartupEvent)2 EventAdminService (com.alipay.sofa.ark.spi.service.event.EventAdminService)2 URL (java.net.URL)2 HashSet (java.util.HashSet)2 MainMethodRunner (com.alipay.sofa.ark.bootstrap.MainMethodRunner)1 OrderComparator (com.alipay.sofa.ark.common.util.OrderComparator)1