亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? dbloglistener.java

?? pl/sql中記log的函數
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
	 * @param timeout seconds to wait for the next message if the pipe is empty. 
	 */
	DbLogListener(Connection conn, String key, Logger rootLogger, int timeout, String pipeName) throws SQLException {
		mapKey_ = key;
		
		setRootLoggerName( (rootLogger == null) ? "" : rootLogger.getName());
		
		pipeName_ = pipeName;

		stmt_ = getDbLogPipeReadStatement(conn, timeout, pipeName_);
	}
	
	/**
	 * If you want to ensure only one listener per user schema (connection) and pipe name combination, use the static
	 * getDblogListener() factory methods instead of the direct constructor call.
	 * 
	 * @param xmlNodeConfig XML configuration node, for connection properties and pipe name.
	 * @param dbLogger base logger to use.
	 */
	public DbLogListener(XMLNode xmlNodeConfig, Logger dbLogger) throws SQLException {
		XmlConfig lxmlConfig = new XmlConfig(xmlNodeConfig);
		
      String jdbcUrl = lxmlConfig.getXpathParam("database/source/connection/dburl/text()", "NotExiste");
      String user = lxmlConfig.getXpathParam("database/source/connection/username/text()", "NotExiste");
      String pwd = lxmlConfig.getXpathParam("database/source/connection/password/text()", "NotExiste");
      pipeName_ = lxmlConfig.getXpathParam("database/source/pipename/text()", "NotExiste");
		
    	OracleDataSource ods = new OracleDataSource();
    	ods.setURL(jdbcUrl);
    	ods.setUser(user);
    	ods.setPassword(pwd);
    	conn_ = ods.getConnection();
    	
    	setRootLoggerName(dbLogger.getName());
    	
    	stmt_ = getDbLogPipeReadStatement(conn_, DEFAULT_PIPE_TIMEOUT, pipeName_);
	}
	
	/**
	 * Populate this object with the next message from the Oracle pipe it is reading from.
	 * The PL/SQL function used to read the next log message has the following parameters and return value:
	 * <p>
	 * <pre>
	 * FUNCTION READ_MESSAGE(
	 *    pTIMEOUT    IN        NUMBER		-- seconds to wait for the next message.
	 *    pID         OUT       NUMBER		-- sequential ID of the log message
	 *    pLDATE      OUT       DATE			-- SYSDATE value for this message
	 *    pLHSECS     OUT       NUMBER		-- hundredths of seconds for the SYSDATE
	 *    pLLEVEL     OUT       NUMBER		-- Log4J log level for the message
	 *    pLSECTION   OUT       VARCHAR2	-- Log4Plsql section name, can be used as Log4J Logger name
	 *    pLUSER      OUT       VARCHAR2	-- database user sending the log message
	 * 	pCOMMAND    OUT       VARCHAR2   -- command name for future use, when multiple commands are possible
	 *    pLTEXTE     OUT       VARCHAR2	-- message text
	 * 	pMDC_KEYS	OUT		 VARCHAR2	-- delimited string of MDC keys
	 * 	pMDC_VALUES OUT		 VARCHAR2	-- delimited string of MDC values
	 * 	pMDC_SEPARATOR OUT	 VARCHAR2	-- MDC string delimiter
	 *    ) RETURN NUMBER -- DBMS_PIPE.RECEIVE_MESSAGE return value
	 * </pre>
	 * <p>
	 * <b>This method is only package visible for Unit Test purposes. Do not call it outside the Run Method.</b>
	 * <p>
	 * @return True if a message was read, False if the timeout period passed without a new message.
	 */
	boolean getNextMessage() throws SQLException {
		stmt_.execute();
		
		int retval = stmt_.getInt(1);
		
		/**
		 * Possible retval values:
		 * 0 = success, message received
		 * 1 = timeout, no message
		 * 2 = message in pipe too big for buffer (should not be possible)
		 * 3 = interrupt of some sort occurred
		 */
		if (retval == 0) {
			id_ = stmt_.getLong(3);
			Timestamp timestamp = stmt_.getTimestamp(4);
			// If the passed date is not null, add the hundredths of seconds passed as well by turning them into milliseconds.
			date_ = (timestamp != null) ? new Date(timestamp.getTime() + stmt_.getInt(5) * 10) : null;
			level_ = (Level) this.logLevels_.get(new Integer(stmt_.getInt(6)));
			section_ = stmt_.getString(7);
			user_ = stmt_.getString(8);
			command_ = stmt_.getString(9);
			message_ = stmt_.getString(10);
			mdcSeparator_ = stmt_.getString(13);
			
			mdcKeys_.clear();
			mdcValues_.clear();
			
			StringTokenizer keys = new StringTokenizer(stmt_.getString(11), mdcSeparator_);
			while (keys.hasMoreTokens()) mdcKeys_.add(keys.nextToken());
			
			StringTokenizer values = new StringTokenizer(stmt_.getString(12), mdcSeparator_);
			while (values.hasMoreTokens()) mdcValues_.add(values.nextToken());
			
			return true;
		}
		return false;
	}
	
	/**
	 * Log the current message. Default logging uses <code>section</code> as the Logger name, 
	 * <code>level</code> for the logging level, and puts the <code>date, ID,</code> and <code>User</code>
	 * in the Log4J MDC using the constants for these fields defined in this class.
	 * <p>
	 * The assumption is that Log4J has been configured previously to define this logger and attach some
	 * appender(s) to it.
	 * <p>
	 * All messages are logged.  The assumption is that Log4Plsql already determined it wanted these messages in
	 * the log output.  A new <code>LoggingEvent</code> is created and passed to Logger.callAppenders() directly,
	 * without evaluating the Log4Plsql level against the Logger level.
	 * <p>
	 * This also ensures that the database date stamp is the one used for the LoggingEvent, instead of the current
	 * Java system time, which will be later.  How much later depends on the pipe timeout, communication lag times,
	 * etc.
	 * <p>
	 * <b>This method is only package visible for Unit Test purposes. Do not call it outside the Run Method.</b>
	 * <p>
	 */
	void logMessage() {
		MDC.put(MDC_DATE, this.date_);
		MDC.put(MDC_USER, this.user_);
		MDC.put(MDC_ID, new Long(this.id_));
		for (int i=0; i < mdcKeys_.size(); i++) MDC.put((String) mdcKeys_.get(i), mdcValues_.get(i));
		getDbLogHelper().preLog();
		Logger logger = getDbLogHelper().getLogger();
		LoggingEvent logEvent = new LoggingEvent(logger.getClass().getName(), logger, getTimestamp(), this.level_, this.message_, null);
		logger.callAppenders(logEvent);
		getDbLogHelper().postLog();
		MDC.remove(MDC_DATE);
		MDC.remove(MDC_USER);
		MDC.remove(MDC_ID);
		for (int i=0; i < mdcKeys_.size(); i++) MDC.remove((String) mdcKeys_.get(i));
	}
	
	protected void close() {
		getDbLogHelper().close();
		if (stmt_ != null) try { stmt_.close(); } catch (SQLException e) {}
	}


	/**
	 * Starts the logging loop for this instance.
	 * If this instance is already looping on another thread, then the method exits immediately.
	 * When the looping is done (isStillWatching = false), this instance removes itself from the pool
	 * and performs any cleanup needed.
	 * 
	 */
	public void run() {
		
		synchronized (isRunningLock_) {
			if (isRunning_) return;
			else isRunning_ = true;
		}

		try {
			while (isStillWatching()) {
				
				if (getNextMessage()) {
					// Only need to log if there was a new message retrieved.
					logMessage();
				}
			}
		} catch (SQLException e) {
			Logger logger = null;
			if ("".equals(getRootLoggerName())) logger = Logger.getRootLogger();
			else logger = Logger.getLogger(getRootLoggerName());
			logger.error("Error getting next Oracle Pipe message on pipe '" + pipeName_ + "':", e);
		} finally {
			// unregister from map
			removeDbLogListener(mapKey_);
			close();
			synchronized (isRunningLock_) {
				isRunning_ = false;
			}
			// reset this in case the thread will be restarted at some point.
			setStillWatching(true);
		}
	}
	
	public boolean isStillWatching() {
		synchronized (stillWatchingLock_) {
			return this.stillWatching_;
		}
	}

	public boolean isRunning() {
		synchronized (isRunningLock_) {
			return this.isRunning_;
		}
	}

	public void setStillWatching(boolean keepWatching) {
		synchronized (stillWatchingLock_) {
			this.stillWatching_ = keepWatching;
		}
	}
	
	public String getRootLoggerName() { return rootLoggerName_; }
	private void setRootLoggerName(String rootLoggerName) { 
		this.rootLoggerName_ = rootLoggerName == null ? "": rootLoggerName.endsWith(".") ? rootLoggerName : rootLoggerName + ".";
	}
	
	/**
	 * Current Log command from the pipe.  Currently does nothing, as there is only one command.
	 */
	public String getCommand() {
		return this.command_;
	}
	/**
	 * Date stamp of the current log message.  Granularity to hundredths of seconds only.
	 */
	public Date getDate() {
		return this.date_;
	}
	/**
	 * Return 0 if the current message date is null, or Date.getTime() if not.
	 * @return
	 */
	public long getTimestamp() {
		return (this.date_ == null) ? 0 : this.date_.getTime();
	}
	/**
	 * Sequential identifier of the current log message - 0 = no current message.
	 */
	public long getId() {
		return this.id_;
	}
	/**
	 * Log message level - current value is looked up in the DB log level map.
	 */
	public Level getLevel() {
		return this.level_;
	}
	/**
	 * Text of the current log message.
	 */
	public String getMessage() {
		return this.message_;
	}
	/**
	 * Log4Plsql section for the current message, composed of period delimited strings.  
	 * This commonly maps to a Logger name.  The default implementation appends this to any
	 * root logger name given in the factory constructor to define the Logger name to use.
	 */
	public String getSection() {
		return this.section_;
	}
	/**
	 * Database user the current log message comes from.  May or may not be useful depending on the app architecture.
	 */
	public String getUser() {
		return this.user_;
	}
	/**
	 * Current Log command from the pipe.  Currently does nothing, as there is only one command.
	 */
	public void setCommand(String command) {
		this.command_ = command;
	}
	/**
	 * Date stamp of the current log message.  Granularity to hundredths of seconds only.
	 */
	public void setDate(Date date) {
		this.date_ = date;
	}
	/**
	 * Sequential identifier of the current log message - 0 = no current message.
	 */
	public void setId(long id) {
		this.id_ = id;
	}
	/**
	 * Log message level - current value is looked up in the DB log level map.
	 */
	public void setLevel(Level level) {
		this.level_ = level;
	}
	/**
	 * Text of the current log message.
	 */
	public void setMessage(String message) {
		this.message_ = message;
	}
	/**
	 * Log4Plsql section for the current message, composed of period delimited strings.  
	 * This commonly maps to a Logger name.  The default implementation appends this to any
	 * root logger name given in the factory constructor to define the Logger name to use.
	 */
	public void setSection(String section) {
		this.section_ = section;
	}
	/**
	 * Database user the current log message comes from.  May or may not be useful depending on the app architecture.
	 */
	public void setUser(String user) {
		this.user_ = user;
	}
	private DbLogHelper getDbLogHelper() {
		return this.dbLogHelper_;
	}
	/**
	 * Specify the instance of DbLogHelper or a sub-class to use when logging messages from this class.  Use subclasses to customize
	 * logic for deciding what Logger to use, re-configure Appenders, or modify Layouts for a given pipe message before it is logged
	 * and clean up anything needed after each message is logged.  The default case simply uses the base Logger name used when creating
	 * this instance concatenated with the current message section.  If this is sufficient, then no extra work is needed.
	 * <p>
	 * @param dbLogHelper
	 */
	public synchronized void setDbLogHelper(DbLogHelper dbLogHelper) {
		this.dbLogHelper_ = dbLogHelper;
	}
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲高清免费在线| 粉嫩嫩av羞羞动漫久久久| 亚洲综合视频网| 亚洲精品成人悠悠色影视| 中文字幕一区二区在线播放| 国产欧美日韩中文久久| 国产日韩精品视频一区| 精品国产一区二区三区不卡| 欧美一卡2卡3卡4卡| 91精品国产综合久久久久久久久久| 欧美图区在线视频| 欧美三区在线观看| 精品视频色一区| 欧美精品 日韩| 日韩女优毛片在线| 久久蜜桃av一区精品变态类天堂| 精品国产乱码久久久久久免费| 日韩限制级电影在线观看| 日韩精品一区二区三区在线| 精品免费99久久| 国产女同性恋一区二区| 国产精品久久久爽爽爽麻豆色哟哟 | 欧美怡红院视频| 精品视频一区 二区 三区| 这里只有精品免费| 26uuu精品一区二区三区四区在线 26uuu精品一区二区在线观看 | 美国av一区二区| 久久精工是国产品牌吗| 国产裸体歌舞团一区二区| 成人小视频在线观看| 91在线观看视频| 欧美日韩亚洲综合| 精品日本一线二线三线不卡| 国产午夜精品久久久久久久| 亚洲精品视频在线看| 亚洲成人动漫av| 国产自产高清不卡| 波多野洁衣一区| 国产亚洲精品aa| 国产精品三级av| 久久蜜桃av一区精品变态类天堂| 欧美肥妇bbw| 日韩视频永久免费| 国内久久精品视频| 不卡区在线中文字幕| 91国在线观看| 精品日韩欧美一区二区| 亚洲天堂精品在线观看| 日本va欧美va欧美va精品| 国产精品77777竹菊影视小说| 91蝌蚪国产九色| 91精品国产日韩91久久久久久| 久久一二三国产| 亚洲一区在线观看免费| 国产一区二区日韩精品| 色av综合在线| 精品国产一区二区三区忘忧草| 亚洲乱码国产乱码精品精可以看| 人人精品人人爱| 99精品偷自拍| 久久综合九色综合97婷婷| 亚洲免费观看高清完整版在线观看| 美腿丝袜亚洲色图| 日本电影亚洲天堂一区| 久久精品一区二区三区不卡牛牛 | 奇米色一区二区| 99精品久久免费看蜜臀剧情介绍| 欧美大片在线观看| 亚洲精品国产品国语在线app| 久久99久久99小草精品免视看| 色综合久久99| 欧美国产一区视频在线观看| 爽爽淫人综合网网站| 国产精品久久久久久户外露出| 日韩精品一区第一页| 色哟哟精品一区| 国产精品午夜在线| 国产在线视视频有精品| 88在线观看91蜜桃国自产| 亚洲精品你懂的| 豆国产96在线|亚洲| 欧美成人一区二区三区| 偷偷要91色婷婷| 欧洲亚洲精品在线| 亚洲欧美另类综合偷拍| 风间由美中文字幕在线看视频国产欧美 | 国产精品一区二区三区网站| 欧美女孩性生活视频| 一区二区不卡在线播放 | 亚洲精品在线网站| 午夜激情一区二区三区| 色94色欧美sute亚洲13| 亚洲视频免费在线| 成人h精品动漫一区二区三区| 久久久精品国产99久久精品芒果| 另类调教123区| 日韩三级.com| 蜜桃精品视频在线观看| 7777精品久久久大香线蕉| 亚洲成人自拍偷拍| 欧美日韩成人综合| 视频一区二区不卡| 欧美男人的天堂一二区| 亚洲18色成人| 欧美狂野另类xxxxoooo| 亚洲观看高清完整版在线观看| 一本一道波多野结衣一区二区| 亚洲手机成人高清视频| 91在线观看高清| 亚洲精品中文字幕在线观看| 色天使色偷偷av一区二区| 一区二区三区中文在线| 欧美日韩在线播放一区| 亚洲成在人线在线播放| 欧美一级艳片视频免费观看| 美女国产一区二区| 久久这里只有精品6| 国产一区视频在线看| 久久久久国产精品免费免费搜索| 国产精品一区免费在线观看| 国产精品成人免费| 色成年激情久久综合| 日韩av电影一区| 精品久久一区二区三区| 国产suv一区二区三区88区| 日本一区二区三区免费乱视频| 不卡av在线网| 亚洲国产精品久久人人爱| 777a∨成人精品桃花网| 国产中文字幕一区| 中文字幕av一区二区三区免费看| 成人黄色小视频在线观看| 亚洲欧美另类在线| 欧美一区二区福利在线| 国产精品一二三四区| 99re视频这里只有精品| 亚洲自拍偷拍麻豆| 777精品伊人久久久久大香线蕉| 日本成人在线电影网| 国产亚洲成aⅴ人片在线观看| 99久免费精品视频在线观看| 一二三区精品视频| 欧美www视频| 91网站在线播放| 日本中文字幕一区| 国产精品视频麻豆| 欧美日韩免费观看一区三区| 九九**精品视频免费播放| 亚洲视频一区在线观看| 欧美一区午夜视频在线观看| 国产精品99久久久久久似苏梦涵 | 日韩三级在线观看| 成人av免费在线观看| 亚洲国产综合色| 精品久久久影院| 色综合久久久久综合体| 美女视频黄 久久| 成人欧美一区二区三区黑人麻豆| 欧美精品色一区二区三区| 国产精品一区二区免费不卡| 亚洲国产精品一区二区www| 久久精品视频一区二区三区| 欧美在线不卡一区| 国产成人一级电影| 午夜天堂影视香蕉久久| 国产欧美一区在线| 欧美一区二区三区视频免费播放| 国产成人av电影在线观看| 亚洲自拍偷拍综合| 欧美韩国日本一区| 日韩一二在线观看| 在线观看国产91| 成人午夜在线免费| 激情小说欧美图片| 在线观看亚洲精品| 国产91色综合久久免费分享| 日韩精品福利网| 亚洲色图欧美偷拍| 久久精品夜色噜噜亚洲aⅴ| 欧美久久久久久久久久| 91老司机福利 在线| 国产精品一二三区| 毛片av一区二区三区| 午夜日韩在线电影| 亚洲免费毛片网站| 欧美国产日韩a欧美在线观看| 日韩欧美国产精品| 欧美精品一卡二卡| 91黄视频在线观看| 99久久婷婷国产综合精品电影| 国产乱人伦偷精品视频免下载 | 不卡一二三区首页| 国产精品69久久久久水密桃| 美女网站视频久久| 日韩综合一区二区| 亚洲国产成人av网| 亚洲综合自拍偷拍| 1区2区3区欧美| 国产精品国产三级国产三级人妇 | 午夜欧美大尺度福利影院在线看|