Search in sources :

Example 1 with IRouteRoot

use of com.alibaba.android.arouter.facade.template.IRouteRoot in project ARouter by alibaba.

the class LogisticsCenter method init.

/**
     * LogisticsCenter init, load all metas in memory. Demand initialization
     */
public static synchronized void init(Context context, ThreadPoolExecutor tpe) throws HandlerException {
    mContext = context;
    executor = tpe;
    try {
        // These class was generate by arouter-compiler.
        List<String> classFileNames = ClassUtils.getFileNameByPackageName(mContext, ROUTE_ROOT_PAKCAGE);
        //
        for (String className : classFileNames) {
            if (className.startsWith(ROUTE_ROOT_PAKCAGE + DOT + SDK_NAME + SEPARATOR + SUFFIX_ROOT)) {
                // This one of root elements, load root.
                ((IRouteRoot) (Class.forName(className).getConstructor().newInstance())).loadInto(Warehouse.groupsIndex);
            } else if (className.startsWith(ROUTE_ROOT_PAKCAGE + DOT + SDK_NAME + SEPARATOR + SUFFIX_INTERCEPTORS)) {
                // Load interceptorMeta
                ((IInterceptorGroup) (Class.forName(className).getConstructor().newInstance())).loadInto(Warehouse.interceptorsIndex);
            } else if (className.startsWith(ROUTE_ROOT_PAKCAGE + DOT + SDK_NAME + SEPARATOR + SUFFIX_PROVIDERS)) {
                // Load providerIndex
                ((IProviderGroup) (Class.forName(className).getConstructor().newInstance())).loadInto(Warehouse.providersIndex);
            }
        }
        if (Warehouse.groupsIndex.size() == 0) {
            logger.error(TAG, "No mapping files were found, check your configuration please!");
        }
        if (ARouter.debuggable()) {
            logger.debug(TAG, String.format(Locale.getDefault(), "LogisticsCenter has already been loaded, GroupIndex[%d], InterceptorIndex[%d], ProviderIndex[%d]", Warehouse.groupsIndex.size(), Warehouse.interceptorsIndex.size(), Warehouse.providersIndex.size()));
        }
    } catch (Exception e) {
        throw new HandlerException(TAG + "ARouter init logistics center exception! [" + e.getMessage() + "]");
    }
}
Also used : IRouteRoot(com.alibaba.android.arouter.facade.template.IRouteRoot) HandlerException(com.alibaba.android.arouter.exception.HandlerException) IProviderGroup(com.alibaba.android.arouter.facade.template.IProviderGroup) HandlerException(com.alibaba.android.arouter.exception.HandlerException) NoRouteFoundException(com.alibaba.android.arouter.exception.NoRouteFoundException)

Aggregations

HandlerException (com.alibaba.android.arouter.exception.HandlerException)1 NoRouteFoundException (com.alibaba.android.arouter.exception.NoRouteFoundException)1 IProviderGroup (com.alibaba.android.arouter.facade.template.IProviderGroup)1 IRouteRoot (com.alibaba.android.arouter.facade.template.IRouteRoot)1