Пример #1
0
 public void init(YMP owner) throws Exception {
   if (!__inited) {
     //
     _LOG.info("Initializing ymate-platform-log-" + VERSION);
     //
     __owner = owner;
     __moduleCfg = new DefaultModuleCfg(__owner);
     // 设置全局变量,便于配置文件内引用
     System.getProperties().put("LOG_OUT_DIR", __moduleCfg.getOutputDir().getPath());
     //
     if (__moduleCfg.getLoggerClass() != null) {
       __currentLogger = ClassUtils.impl(__moduleCfg.getLoggerClass(), ILogger.class);
     }
     if (__currentLogger == null) {
       __currentLogger = new DefaultLogger();
     }
     __LOGGER_CACHE.put(__moduleCfg.getLoggerName(), __currentLogger);
     //
     __currentLogger.init(this, __moduleCfg.getLoggerName());
     __currentLogger.console(__moduleCfg.allowOutputConsole());
     //
     __inited = true;
     // 注册日志记录器事件
     __owner.getEvents().registerEvent(LogEvent.class);
   }
 }
Пример #2
0
 /** @return 返回默认日志记录器模块管理器实例对象 */
 public static ILog get() {
   if (__instance == null) {
     synchronized (VERSION) {
       if (__instance == null) {
         __instance = YMP.get().getModule(Logs.class);
       }
     }
   }
   return __instance;
 }
  public DefaultModuleCfg(YMP owner) throws Exception {
    Map<String, String> _moduleCfgs = owner.getConfig().getModuleConfigs(ICaches.MODULE_NAME);
    //
    String _providerClassStr =
        StringUtils.defaultIfBlank(_moduleCfgs.get("provider_class"), "default");
    __cacheProvider =
        ClassUtils.impl(
            StringUtils.defaultIfBlank(Caches.PROVIDERS.get(_providerClassStr), _providerClassStr),
            ICacheProvider.class,
            this.getClass());
    if (__cacheProvider == null) {
      __cacheProvider = new DefaultCacheProvider();
    }
    //
    __cacheEventListener =
        ClassUtils.impl(
            _moduleCfgs.get("event_listener_class"), ICacheEventListener.class, this.getClass());
    //
    __cacheScopeProcessor =
        ClassUtils.impl(
            _moduleCfgs.get("scope_processor_class"), ICacheScopeProcessor.class, this.getClass());
    //
    __serializer =
        ClassUtils.impl(_moduleCfgs.get("serializer_class"), ISerializer.class, this.getClass());
    if (__serializer == null) {
      __serializer = new DefaultSerializer();
    }
    //
    __keyGenerator =
        ClassUtils.impl(
            _moduleCfgs.get("key_generator_class"), IKeyGenerator.class, this.getClass());
    if (__keyGenerator == null) {
      __keyGenerator = new DefaultKeyGenerator();
    }
    __keyGenerator.init(__serializer);
    //
    __defaultCacheName =
        StringUtils.defaultIfBlank(_moduleCfgs.get("default_cache_name"), "default");

    __defaultCacheTimeout =
        BlurObject.bind(StringUtils.defaultIfBlank(_moduleCfgs.get("default_cache_timeout"), "0"))
            .toIntValue();
    if (__defaultCacheTimeout <= 0) {
      __defaultCacheTimeout = 300;
    }
  }
Пример #4
0
 /**
  * @param owner YMP框架管理器实例
  * @return 返回指定YMP框架管理器容器内的日志记录器模块实例
  */
 public static ILog get(YMP owner) {
   return owner.getModule(Logs.class);
 }