自动导入Static配置数据,能识别 DisconfFileItem 或 DisconfFileItem 的标识

@Description: auto ware
336823
private static void autowareStaticConfig(Class<?> cls, Properties prop) throws Exception {

        if (null == prop) {
            throw new Exception("cannot autowareConfig null");
        }

        try {

            Field[] fields = cls.getDeclaredFields();

            for (Field field : fields) {

                if (field.isAnnotationPresent(DisconfFileItem.class)) {

                    if (!Modifier.isStatic(field.getModifiers())) {
                        continue;
                    }

                    field.setAccessible(true);

                    String name = field.getName();
                    Object value = prop.getProperty(name, null);
                    if (value != null) {
                        ClassUtils.setFieldValeByType(field, null, String.valueOf(value));
                    }
                }
            }
        } catch (Exception e) {

            throw new Exception("error while autowire config file", e);
        }
    }
576073
function ()
    {
        if (typeof this._idleTimeout == "number") {
            clearTimeout(this._idleTimeout);
        }

        // Cancel Disconnect Timeout
        if (this._disconnectTimeout !== null) {
            this.deleteTimedHandler(this._disconnectTimeout);
            this._disconnectTimeout = null;
        }

        Strophe.info("_doDisconnect was called");
        this._proto._doDisconnect();

        this.authenticated = false;
        this.disconnecting = false;

        // delete handlers
        this.handlers = [];
        this.timedHandlers = [];
        this.removeTimeds = [];
        this.removeHandlers = [];
        this.addTimeds = [];
        this.addHandlers = [];

        // tell the parent we disconnected
        this._changeConnectStatus(Strophe.Status.DISCONNECTED, null);
        this.connected = false;
    }
1231697
protected final void registStaticScript(Class<? extends T> scriptClass)
	{
		try {
			boolean isAbstractOrInterface = Modifier.isAbstract(scriptClass.getModifiers())
					|| Modifier.isInterface(scriptClass.getModifiers());// 是否是抽象类
			if(isAbstractOrInterface)
			{
				throw new UnsupportedOperationException(scriptClass +"can not newInstance");
			}
			T script = scriptClass.newInstance();
			K key=script.getScriptKey();
			Class<? extends T> old=staticCodeMap.get(key);
			staticCodeMap.put(key,scriptClass);
			if(old==null)
			{
				_log.info("regist Static Script,key="+key+",class="+scriptClass);
			}else
			{
				_log.info("regist Static Script,key="+key+",class="+scriptClass+",Override script="+old);
			}
		} catch (Exception e) {
			_log.error(e.getMessage(),e);
		}
	}
785630
public static void releaseTransport(ClientTransport clientTransport, int disconnectTimeout) {
        if (clientTransport == null) {
            return;
        }
        boolean needDestroy = CLIENT_TRANSPORT_HOLDER.removeClientTransport(clientTransport);
        // 执行销毁动作
        if (needDestroy) {
            if (disconnectTimeout > 0) { // 需要等待结束时间
                int count = clientTransport.currentRequests();
                if (count > 0) { // 有正在调用的请求
                    long start = RpcRuntimeContext.now();
                    if (LOGGER.isInfoEnabled()) {
                        LOGGER.info("There are {} outstanding call in transport, wait {}ms to end",
                            count, disconnectTimeout);
                    }
                    while (clientTransport.currentRequests() > 0
                        && RpcRuntimeContext.now() - start < disconnectTimeout) { // 等待返回结果
                        try {
                            Thread.sleep(10);
                        } catch (InterruptedException ignore) {
                        }
                    }
                } // 关闭前检查已有请求？
            }
            // disconnectTimeout已过
            int count = clientTransport.currentRequests();
            if (count > 0) { // 还有正在调用的请求
                if (LOGGER.isWarnEnabled()) {
                    LOGGER.warn("There are {} outstanding call in client transport, but shutdown now.", count);
                }
            }
            // 反向的也删一下
            if (REVERSE_CLIENT_TRANSPORT_MAP != null) {
                String key = NetUtils.channelToString(clientTransport.remoteAddress(), clientTransport.localAddress());
                REVERSE_CLIENT_TRANSPORT_MAP.remove(key);
            }
            clientTransport.destroy();
        }
    }
1130990
public static void blockUntilReady() {
        Set<String> notReady = new HashSet<String>() {{
            addAll(EnvUtil.getDependencies());
        }};
        while (!notReady.isEmpty()) {
            LOG.info("等待被依赖组件'" + notReady + "'...");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e1) {
                LOG.error(e1);
            }
            for (String dependentApplication : EnvUtil.getDependencies()) {
                LOG.debug("这里每次均检查所有被依赖节点，而不是检查notReady集合");
                try {
                    ApplicationRouter.singleton.allInstances(dependentApplication);
                    notReady.remove(dependentApplication);
                } catch (ApplicationOfflineException | ApplicationUndefinedException e) {
                    LOG.info("受依赖组件未启动：" + dependentApplication);
                }
            }
        }
    }
415898
def closed(self, reason):
        '''
        
        '''
        # 拷贝封面&报头图片文件
        utils.mkdirp(os.path.join(self.build_source_dir, 'images'))
        self._logger.info(self.options)
        shutil.copy(
            self.options.get('img_cover'),
            os.path.join(self.build_source_dir, 'images', 'cover.jpg'))
        shutil.copy(
            self.options.get('img_masthead'),
            os.path.join(self.build_source_dir, 'images', 'masthead.gif'))

        # 拷贝css文件
        css_base_path = self.options.get('css_base')
        css_package_path = self.options.get('css_package')
        css_extra = self.options.get('extra_css', '')
        css_output_dir = os.path.join(self.build_source_dir, 'css')
        utils.mkdirp(css_output_dir)
        if css_base_path:
            shutil.copy(
                css_base_path,
                os.path.join(css_output_dir, 'base.css'))
        if css_package_path:
            shutil.copy(
                css_package_path,
                os.path.join(css_output_dir, 'package.css'))
        if css_extra:
            with codecs.open(
                    os.path.join(css_output_dir, 'custom.css'),
                    'wb', 'utf-8') as fh:
                fh.write(css_extra)

        # 拷贝icons路径文件
        icons_path = self.options.get('icons_path')
        icons_output_dir = os.path.join(self.build_source_dir, 'icons')
        shutil.rmtree(icons_output_dir, ignore_errors=True)
        if icons_path:
            shutil.copytree(icons_path, icons_output_dir)

        # 获取content模板对象
        template_content_path = os.path.join(
            self.template_dir, 'OEBPS', 'content.opf')
        with open(template_content_path, 'r') as fh:
            template_content = Template(fh.read())

        # 渲染content目标文件
        content_path = os.path.join(self.build_source_dir, 'moear.opf')
        with codecs.open(content_path, 'wb', 'utf-8') as fh:
            fh.write(template_content.render(
                data=self.data,
                spider=self.spider,
                options=self.options))

        # 获取toc.ncx模板对象
        template_toc_path = os.path.join(
            self.template_dir, 'OEBPS', 'toc.ncx')
        with open(template_toc_path, 'r') as fh:
            template_toc = Template(fh.read())

        # 渲染toc.ncx目标文件
        toc_path = os.path.join(self.build_source_dir, 'misc', 'toc.ncx')
        utils.mkdirp(os.path.dirname(toc_path))
        with codecs.open(toc_path, 'wb', 'utf-8') as fh:
            fh.write(template_toc.render(
                data=self.data,
                spider=self.spider,
                options=self.options))

        # 获取toc.html模板对象
        template_toc_path = os.path.join(
            self.template_dir, 'OEBPS', 'toc.html')
        with open(template_toc_path, 'r') as fh:
            template_toc = Template(fh.read())

        # 渲染toc.html目标文件
        toc_path = os.path.join(self.build_source_dir, 'html', 'toc.html')
        utils.mkdirp(os.path.dirname(toc_path))
        with codecs.open(toc_path, 'wb', 'utf-8') as fh:
            fh.write(template_toc.render(
                data=self.data,
                options=self.options))

        # 生成mobi文件到mobi_dir
        self.generate_mobi_file()
660553
private BeanDesc init() {
		for (Field field : ReflectUtil.getFields(this.beanClass)) {
			if(false == ModifierUtil.isStatic(field)) {
				//只针对非static属性
				this.propMap.put(field.getName(), createProp(field));
			}
		}
		return this;
	}
98378
private T onBeforeUpdate(T entity) {
		// TODO 更新前的操作
		Class<?> cls = entity.getClass();
		String entityName = cls.getName();
		String idFieldName = getIdFieldName(cls);
		ID id = entity.getId();
		
		String indexName = DaoHelper.getExtendFieldName(cls, ExtendField.Index);
		String pathName = DaoHelper.getExtendFieldName(cls, ExtendField.Path);
		String parentName = DaoHelper.getExtendFieldName(cls, ExtendField.Parent);
		
		System.out.println(indexName + "," + pathName + "," + parentName);
		
		// 可记录时间的
		if (Dateable.class.isAssignableFrom(cls)) {
			((Dateable) entity).setLastModifiedDate(Calendar.getInstance().getTime());
		}
		
		// 可树形结构化的
		if (Treeable.class.isAssignableFrom(cls)) {
			// 判断自身位置有没有发生变化
			Treeable currObject = (Treeable) entity;
			Serializable newParentId = currObject.getParent();
			Treeable dbObject = (Treeable) getCurrentSession().get(cls, id);
			Serializable oldParentId = dbObject.getParent();
			
			System.out.println("newParentId:" + newParentId + " --> oldParentId:" + oldParentId);
			
			// 跨层级移动
			if( notNull(newParentId) && ( !newParentId.equals( oldParentId ) ) ){
				String oldPath = dbObject.getPath();
				Treeable newParent = (Treeable) getCurrentSession().get(cls, newParentId);
				String newPath =  newParent.getPath() + id.toString() + "/";
				currObject.setPath(newPath);
				
				System.out.println( "newPath:" + newPath + " --> oldPath:" + oldPath );
				
				//1.修改自身的排位
				Object maxVal = createCriteria(cls).add(Restrictions.eq(parentName, currObject.getParent())).setProjection(Projections.max(indexName)).uniqueResult();
				currObject.setIndex( isNull(maxVal) ? 1 : (Integer.valueOf(maxVal.toString()) + 1) );
				//2.如果自身的下级节点路劲：截取dbObject的path 换成	currentObject的path
				int subStart = oldPath.length() + 1;
				String hql = "update " + entityName + " set "+pathName+" = Concat(?, Substring( "+pathName+", "+subStart+", Length("+pathName+") )) where "+pathName+" like ?";
				getCurrentSession().createQuery(hql)
					.setParameter(0, newPath)
					.setParameter(1, oldPath +"_%")
					.executeUpdate();
			}
			// 同级之间移动
			else if( ! dbObject.getIndex().equals(currObject.getIndex()) ){
				// 更新目标节点的位置
				String hql = "update " + entityName + " set "+indexName+"=? where "+parentName+"=? and "+indexName+"=?";
				createQuery(hql)
					.setParameter(0, dbObject.getIndex())
					.setParameter(1, dbObject.getParent())
					.setParameter(2, currObject.getIndex())
					.executeUpdate();
			}
			
		}
		// 可移动的
		else if (Movable.class.isAssignableFrom(cls)) {
			Movable currObject = (Movable) entity;
			Movable dbObject = (Movable) getCurrentSession().get(cls, entity.getId());
			if( ! dbObject.getIndex().equals(currObject.getIndex()) ){
				String hql = "update " + entityName + " set "+indexName+"=? where "+indexName+"=? ";
				createQuery(hql)
					.setParameter(0, currObject.getIndex())
					.setParameter(1, dbObject.getIndex())
					.executeUpdate();
			}
		}
		
		return entity;
	}
728956
function addListener(resolver, status, callback) {
        if (resolver.status === status) {
            // 设置延迟
            // 为了让then函数先返回再执行回调
            // see #2.2.4
            Resolver.nextTick(
                function () {
                    callback(resolver.data);
                }
            );
        }
        else if (status === STATUS.FULFILLED) {
            resolver.fulfillList.push(callback);
        }
        else if (status === STATUS.REJECTED) {
            resolver.rejectList.push(callback);
        }
    }
686014
void deactivate() {

        final String methodName = "deactivate";
        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.entry(this, TRACE, methodName);
        }

        super.deactivate();

        synchronized(this) {

          if (_remoteConnection != null) {

              _remoteConnection.close();

          }

        }

        _timer.cancel();    //PK54585

        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.exit(this, TRACE, methodName);
        }

    }
1316627
private void onDelayModify(WatchEvent<?> event, Path currentPath) {
		Path eventPath = Paths.get(currentPath.toString(), event.context().toString());
		if(eventSet.contains(eventPath)) {
			//此事件已经被触发过，后续事件忽略，等待统一处理。
			return;
		}
		
		//事件第一次触发，此时标记事件，并启动处理线程延迟处理，处理结束后会删除标记
		eventSet.add(eventPath);
		startHandleModifyThread(event, currentPath);
	}
1121956
public function start() {
        #设置DEBUG引导程序
        (new This7Debug())->bootstrap();
        #设置配置文件
        This7Config::defineConst();
        #获取驱动列表
        $this->drives = $this->getDeviceList(VENDOR_DIR . DS . 'this7');
        #自动加载类
        spl_autoload_register(array($this, 'autoload'));
        #设置静态化
        staticize::setApplication($this);
        #绑定核心驱动
        $this->bindDrives();
        #启动路由
        routes::start();
    }
468271
def closed(self, reason):
        '''
        
        '''
        self.logger.debug('结果列表: {}'.format(self.item_list))

        output_strings = json.dumps(self.item_list, ensure_ascii=False)
        with open(self.output_file, 'w') as fh:
            fh.write(output_strings)
1086075
@Override
    public void onConnectionFailed(ConnectionResult result) {
        timeoutHandler.removeMessages(APICLIENT_TIMEOUT_HANDLE_MSG);

        if (result == null) {
            HMSAgentLog.e("result is null");
            onConnectEnd(HMSAgent.AgentResultCode.RESULT_IS_NULL);
            return;
        }

        int errCode = result.getErrorCode();
        HMSAgentLog.d("errCode=" + errCode + " allowResolve=" + allowResolveConnectError);

        if(HuaweiApiAvailability.getInstance().isUserResolvableError(errCode) && allowResolveConnectError) {
            Activity activity = ActivityMgr.INST.getLastActivity();
            if (activity != null) {
                try {
                    timeoutHandler.sendEmptyMessageDelayed(APICLIENT_STARTACTIVITY_TIMEOUT_HANDLE_MSG, APICLIENT_STARTACTIVITY_TIMEOUT);
                    Intent intent = new Intent(activity, HMSAgentActivity.class);
                    intent.putExtra(HMSAgentActivity.CONN_ERR_CODE_TAG, errCode);
                    intent.putExtra(BaseAgentActivity.EXTRA_IS_FULLSCREEN, UIUtils.isActivityFullscreen(activity));
                    activity.startActivity(intent);
                    return;
                } catch (Exception e) {
                    HMSAgentLog.e("start HMSAgentActivity exception:" + e.getMessage());
                    timeoutHandler.removeMessages(APICLIENT_STARTACTIVITY_TIMEOUT_HANDLE_MSG);
                    onConnectEnd(HMSAgent.AgentResultCode.START_ACTIVITY_ERROR);
                    return;
                }
            } else {
                // 当前没有界面处理不了错误
                HMSAgentLog.d("no activity");
                onConnectEnd(HMSAgent.AgentResultCode.NO_ACTIVITY_FOR_USE);
                return;
            }
        } else {
            //其他错误码直接透传
        }

        onConnectEnd(errCode);
    }
663623
public synchronized void initRunning() {
        if (!isStart()) {
            return;
        }

        String path = ZookeeperPathUtils.getDestinationClientRunning(this.destination, clientData.getClientId());
        // 序列化
        byte[] bytes = JsonUtils.marshalToByte(clientData);
        try {
            mutex.set(false);
            zkClient.create(path, bytes, CreateMode.EPHEMERAL);
            processActiveEnter();// 触发一下事件
            activeData = clientData;
            mutex.set(true);
        } catch (ZkNodeExistsException e) {
            bytes = zkClient.readData(path, true);
            if (bytes == null) {// 如果不存在节点，立即尝试一次
                initRunning();
            } else {
                activeData = JsonUtils.unmarshalFromByte(bytes, ClientRunningData.class);
                // 如果发现已经存在,判断一下是否自己,避免活锁
                if (activeData.getAddress().contains(":") && isMine(activeData.getAddress())) {
                    mutex.set(true);
                }
            }
        } catch (ZkNoNodeException e) {
            zkClient.createPersistent(ZookeeperPathUtils.getClientIdNodePath(this.destination, clientData.getClientId()),
                true); // 尝试创建父节点
            initRunning();
        } catch (Throwable t) {
            logger.error(MessageFormat.format("There is an error when execute initRunning method, with destination [{0}].",
                destination),
                t);

            // fixed issue 1220, 针对server节点不工作避免死循环
            if (t instanceof ServerNotFoundException) {
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                }
            }

            // 出现任何异常尝试release
            releaseRunning();
            throw new CanalClientException("something goes wrong in initRunning method. ", t);
        }
    }
1232399
function modTryDefine( module ) {
        var id = module.id;

        module.invokeFactory = invokeFactory;
        invokeFactory();

        /**
         * 检查依赖加载完成的状态
         *
         * @ignore
         * @return {number}
         */
        function checkInvokeReadyState() {
            var readyState = DEP_READY;

            // 先判断resource是否加载完成。如果resource未加载完成，则认为未准备好
            each(
                module.depRs,
                function ( dep ) {
                    if ( !( dep.absId && modIsDefined( dep.absId ) ) ) {
                        readyState = DEP_UNREADY;
                        return false;
                    }
                }
            );

            if ( readyState !== DEP_READY ) {
                return readyState;
            }

            // 检查所有依赖模块，根据以下因素处理readyState
            // 1. 是否定义完成
            // 2. 是否强依赖
            // 3. 是否循环依赖
            each(
                module.depMs,
                function ( dep ) {
                    if ( modIsDefined( dep.absId ) ) {
                        return;
                    }

                    // dep.circular相当于一层cache，尽量减少modHasCircularDependency多次调用的开销
                    if ( dep.circular === CIRCULAR_DEP_UNREADY ) {
                        dep.circular = modHasCircularDependency( id, dep.absId );
                    }

                    switch ( dep.circular ) {
                        case CIRCULAR_DEP_YES:
                            if ( dep.hard ) {
                                readyState = DEP_ANALYZED;
                            }
                            break;
                        case CIRCULAR_DEP_NO:
                            readyState = DEP_ANALYZED;
                            break;
                        case CIRCULAR_DEP_UNREADY:
                            readyState = DEP_UNREADY;
                            return false;
                    }
                }
            );

            return readyState;
        }

        /**
         * 初始化模块
         *
         * @ignore
         */
        function invokeFactory() {
            if ( module.state >= MODULE_DEFINED ) {
                return;
            }

            // 先尝试完成循环依赖模块的定义
            var invokeReadyState = checkInvokeReadyState();
            if ( invokeReadyState >= DEP_ANALYZED ) {
                tryCircularDependencies();
            }

            if ( invokeReadyState < DEP_READY ) {
                return;
            }

            // 拼接factory invoke所需的arguments
            var factoryDeps = [];
            each( module.factoryDeps, function ( dep ) {
                factoryDeps.push( dep.absId );
            } );
            var args = modGetModulesExports(
                factoryDeps,
                {
                    require : module.require,
                    exports : module.exports,
                    module  : module
                }
            );

            // 调用factory函数初始化module
            try {
                var factory = module.factory;
                var exports = typeof factory === 'function'
                    ? factory.apply( global, args )
                    : factory;

                if ( exports != null ) {
                    module.exports = exports;
                }
            }
            catch ( ex ) {
                if ( /^\[MODULE_MISS\]"([^"]+)/.test( ex.message ) ) {
                    // 出错，则说明在factory的运行中，该require的模块是需要的
                    // 所以把它加入强依赖中
                    var hardCirclurDep = module.depMsIndex[ RegExp.$1 ];
                    hardCirclurDep && (hardCirclurDep.hard = 1);
                    return;
                }

                throw ex;
            }

            // 只把factory call代码放在try里
            // 避免后续操作因为try而吞掉错误
            module.state = MODULE_DEFINED;
            module.invokeFactory = null;
            modFireDefined( id );
        }

        var circularDependenciesTried;

        /**
         * 尝试完成循环依赖模块的定义
         *
         * 尝试的前提条件是依赖模块链已经加载完成
         * 在该条件下如果循环依赖是活的，尝试一圈一定有解（依赖模块会调用同样的方法，递归尝试）
         * 所以只尝试一次，并且对标志变量的设置必须在执行之前，否则碰到死循环依赖将卡死
         *
         * @ignore
         */
        function tryCircularDependencies() {
            if ( !circularDependenciesTried ) {
                circularDependenciesTried = 1;
                each(
                    module.depMs,
                    function ( dep ) {
                        if ( dep.circular === CIRCULAR_DEP_YES ) {
                            modTryInvokeFactory( dep.absId );
                        }
                    }
                );
            }
        }
    }
1342205
private void quietSetAutoCommit(Connection conn, Boolean autoCommit) {
		if (null != autoCommit) {
			try {
				conn.setAutoCommit(autoCommit);
			} catch (Exception e) {
				StaticLog.error(e);
			}
		}
	}