Search in sources :

Example 1 with OrderComparator

use of com.alipay.sofa.ark.common.util.OrderComparator in project sofa-ark by alipay.

the class BizManagerServiceImpl method getBizInOrder.

@Override
public List<Biz> getBizInOrder() {
    List<Biz> bizList = new ArrayList<>();
    for (String bizName : bizRegistration.keySet()) {
        bizList.addAll(bizRegistration.get(bizName).values());
    }
    Collections.sort(bizList, new OrderComparator());
    return bizList;
}
Also used : Biz(com.alipay.sofa.ark.spi.model.Biz) OrderComparator(com.alipay.sofa.ark.common.util.OrderComparator)

Example 2 with OrderComparator

use of com.alipay.sofa.ark.common.util.OrderComparator in project sofa-ark by alipay.

the class EventAdminServiceImpl method sendEvent.

@Override
public void sendEvent(ArkEvent event) {
    List<EventHandler> eventHandlers = new ArrayList<>();
    for (CopyOnWriteArraySet<EventHandler> values : SUBSCRIBER_MAP.values()) {
        eventHandlers.addAll(values);
    }
    for (ServiceReference<EventHandler> eventHandler : registryService.referenceServices(EventHandler.class, null)) {
        eventHandlers.add(eventHandler.getService());
    }
    Collections.sort(eventHandlers, new OrderComparator());
    for (EventHandler eventHandler : eventHandlers) {
        if (isSupportEventType(eventHandler, event)) {
            eventHandler.handleEvent(event);
        }
    }
}
Also used : ArrayList(java.util.ArrayList) EventHandler(com.alipay.sofa.ark.spi.service.event.EventHandler) OrderComparator(com.alipay.sofa.ark.common.util.OrderComparator)

Example 3 with OrderComparator

use of com.alipay.sofa.ark.common.util.OrderComparator in project sofa-ark by alipay.

the class ArkServiceContainer method start.

/**
 * Start Ark Service Container
 * @throws ArkRuntimeException
 * @since 0.1.0
 */
public void start() throws ArkRuntimeException {
    if (started.compareAndSet(false, true)) {
        ClassLoader oldClassLoader = ClassLoaderUtils.pushContextClassLoader(getClass().getClassLoader());
        try {
            LOGGER.info("Begin to start ArkServiceContainer");
            injector = Guice.createInjector(findServiceModules());
            for (Binding<ArkService> binding : injector.findBindingsByType(new TypeLiteral<ArkService>() {
            })) {
                arkServiceList.add(binding.getProvider().get());
            }
            Collections.sort(arkServiceList, new OrderComparator());
            for (ArkService arkService : arkServiceList) {
                LOGGER.info(String.format("Init Service: %s", arkService.getClass().getName()));
                arkService.init();
            }
            ArkServiceContainerHolder.setContainer(this);
            ArkClient.setBizFactoryService(getService(BizFactoryService.class));
            ArkClient.setBizManagerService(getService(BizManagerService.class));
            ArkClient.setInjectionService(getService(InjectionService.class));
            ArkClient.setEventAdminService(getService(EventAdminService.class));
            ArkClient.setArguments(arguments);
            LOGGER.info("Finish to start ArkServiceContainer");
        } finally {
            ClassLoaderUtils.popContextClassLoader(oldClassLoader);
        }
    }
}
Also used : ArkService(com.alipay.sofa.ark.spi.service.ArkService) BizFactoryService(com.alipay.sofa.ark.spi.service.biz.BizFactoryService) EventAdminService(com.alipay.sofa.ark.spi.service.event.EventAdminService) InjectionService(com.alipay.sofa.ark.spi.service.injection.InjectionService) OrderComparator(com.alipay.sofa.ark.common.util.OrderComparator) BizManagerService(com.alipay.sofa.ark.spi.service.biz.BizManagerService)

Example 4 with OrderComparator

use of com.alipay.sofa.ark.common.util.OrderComparator in project sofa-ark by alipay.

the class PluginManagerServiceImpl method getPluginsInOrder.

@Override
public List<Plugin> getPluginsInOrder() {
    List<Plugin> pluginList = new ArrayList<>(plugins.values());
    Collections.sort(pluginList, new OrderComparator());
    return pluginList;
}
Also used : ArrayList(java.util.ArrayList) OrderComparator(com.alipay.sofa.ark.common.util.OrderComparator) Plugin(com.alipay.sofa.ark.spi.model.Plugin)

Aggregations

OrderComparator (com.alipay.sofa.ark.common.util.OrderComparator)4 ArrayList (java.util.ArrayList)2 Biz (com.alipay.sofa.ark.spi.model.Biz)1 Plugin (com.alipay.sofa.ark.spi.model.Plugin)1 ArkService (com.alipay.sofa.ark.spi.service.ArkService)1 BizFactoryService (com.alipay.sofa.ark.spi.service.biz.BizFactoryService)1 BizManagerService (com.alipay.sofa.ark.spi.service.biz.BizManagerService)1 EventAdminService (com.alipay.sofa.ark.spi.service.event.EventAdminService)1 EventHandler (com.alipay.sofa.ark.spi.service.event.EventHandler)1 InjectionService (com.alipay.sofa.ark.spi.service.injection.InjectionService)1