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); } }
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; } }
public <T> T toObject(T valueObject) throws Exception { ClassUtils.BeanWrapper<?> _wrapper = ClassUtils.wrapper(valueObject); for (String _fieldName : _wrapper.getFieldNames()) { String _columnName = EntityMeta.fieldNameToPropertyName(_fieldName, 0); Object _value = this.getObject(_columnName); if (_value == null) { continue; } _wrapper.setValue( _fieldName, BlurObject.bind(_value).toObjectValue(_wrapper.getFieldType(_fieldName))); } return valueObject; }