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

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

?? statefulrulesessionimpl.java

?? drools 一個開放源碼的規則引擎
?? JAVA
字號:
package org.drools.jsr94.rules;

/*
 * $Id: StatefulRuleSessionImpl.java,v 1.18 2006/01/16 01:31:22 michaelneale Exp $
 *
 * Copyright 2002-2004 (C) The Werken Company. All Rights Reserved.
 *
 * Redistribution and use of this software and associated documentation
 * ("Software"), with or without modification, are permitted provided that the
 * following conditions are met:
 *
 * 1. Redistributions of source code must retain copyright statements and
 * notices. Redistributions must also contain a copy of this document.
 *
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 * this list of conditions and the following disclaimer in the documentation
 * and/or other materials provided with the distribution.
 *
 * 3. The name "drools" must not be used to endorse or promote products derived
 * from this Software without prior written permission of The Werken Company.
 * For written permission, please contact bob@werken.com.
 *
 * 4. Products derived from this Software may not be called "drools" nor may
 * "drools" appear in their names without prior written permission of The Werken
 * Company. "drools" is a registered trademark of The Werken Company.
 *
 * 5. Due credit should be given to The Werken Company.
 * (http://drools.werken.com/).
 *
 * THIS SOFTWARE IS PROVIDED BY THE WERKEN COMPANY AND CONTRIBUTORS ``AS IS''
 * AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE WERKEN COMPANY OR ITS CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 *
 */

import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import javax.rules.Handle;
import javax.rules.InvalidHandleException;
import javax.rules.InvalidRuleSessionException;
import javax.rules.ObjectFilter;
import javax.rules.RuleExecutionSetNotFoundException;
import javax.rules.StatefulRuleSession;

import org.drools.DroolsException;
import org.drools.FactException;
import org.drools.FactHandle;
import org.drools.NoSuchFactObjectException;
import org.drools.jsr94.rules.admin.RuleExecutionSetImpl;
import org.drools.jsr94.rules.admin.RuleExecutionSetRepository;

/**
 * The Drools implementation of the <code>StatefulRuleSession</code> interface
 * which is a representation of a stateful rules engine session. A stateful
 * rules engine session exposes a stateful rule execution API to an underlying
 * rules engine. The session allows arbitrary objects to be added and removed to
 * and from the rule session state. Additionally, objects currently part of the
 * rule session state may be updated. <p/> There are inherently side-effects to
 * adding objects to the rule session state. The execution of a RuleExecutionSet
 * can add, remove and update objects in the rule session state. The objects in
 * the rule session state are therefore dependent on the rules within the
 * <code>RuleExecutionSet</code> as well as the rule engine vendor's specific
 * rule engine behavior. <p/> <code>Handle</code> instances are used by the
 * rule engine vendor to track <code>Object</code>s added to the rule session
 * state. This allows multiple instances of equivalent <code>Object</code>s
 * to be added to the session state and identified, even after serialization.
 * 
 * @see StatefulRuleSession
 * 
 * @author N. Alex Rupp (n_alex <at>codehaus.org)
 * @author <a href="mailto:thomas.diesler@softcon-itec.de">thomas diesler </a>
 */
public class StatefulRuleSessionImpl extends AbstractRuleSessionImpl implements
		StatefulRuleSession {
	// ----------------------------------------------------------------------
	// Constructors
	// ----------------------------------------------------------------------

	/**
	 * Gets the <code>RuleExecutionSet</code> for this URI and associates it
	 * with a RuleBase.
	 * 
	 * @param bindUri
	 *            the URI the <code>RuleExecutionSet</code> has been bound to
	 * @param properties
	 *            additional properties used to create the
	 *            <code>RuleSession</code> implementation.
	 * 
	 * @throws RuleExecutionSetNotFoundException
	 *             if there is no rule set under the given URI
	 */
	StatefulRuleSessionImpl(String bindUri, Map properties,
			RuleExecutionSetRepository repository)
			throws RuleExecutionSetNotFoundException {
		super(repository);
		this.setProperties(properties);

		RuleExecutionSetImpl ruleSet = (RuleExecutionSetImpl) repository
				.getRuleExecutionSet(bindUri);

		if (ruleSet == null) {
			throw new RuleExecutionSetNotFoundException(
					"no execution set bound to: " + bindUri);
		}

		this.setRuleExecutionSet(ruleSet);

		this.initWorkingMemory();
	}

	// ----------------------------------------------------------------------
	// Instance methods
	// ----------------------------------------------------------------------

	/**
	 * Returns <code>true</code> if the given object is contained within
	 * rulesession state of this rule session.
	 * 
	 * @param objectHandle
	 *            the handle to the target object.
	 * 
	 * @return <code>true</code> if the given object is contained within the
	 *         rule session state of this rule session.
	 */
	public boolean containsObject(Handle objectHandle) {
		if (objectHandle instanceof FactHandle) {
			return this.getWorkingMemory().containsObject(
					(FactHandle) objectHandle);
		}

		return false;
	}

	/**
	 * Adds a given object to the rule session state of this rule session. The
	 * argument to this method is Object because in the non-managed env. not all
	 * objects should have to implement Serializable. If the
	 * <code>RuleSession</code> is <code>Serializable</code> and it contains
	 * non-serializable fields a runtime exception will be thrown.
	 * 
	 * @param object
	 *            the object to be added.
	 * 
	 * @return the Handle for the newly added Object
	 * 
	 * @throws InvalidRuleSessionException
	 *             on illegal rule session state.
	 */
	public Handle addObject(Object object) throws InvalidRuleSessionException {
		this.checkRuleSessionValidity();

		try {
			return (Handle) this.getWorkingMemory().assertObject(object);
		} catch (FactException e) {
			throw new InvalidRuleSessionException("cannot assert object", e);
		}
	}

	/**
	 * Adds a <code>List</code> of <code>Object</code>s to the rule session
	 * state of this rule session.
	 * 
	 * @param objList
	 *            the objects to be added.
	 * 
	 * @return a <code>List</code> of <code>Handle</code>s, one for each
	 *         added <code>Object</code>. The <code>List</code> must be
	 *         ordered in the same order as the input <code>objList</code>.
	 * 
	 * @throws InvalidRuleSessionException
	 *             on illegal rule session state.
	 */
	public List addObjects(List objList) throws InvalidRuleSessionException {
		this.checkRuleSessionValidity();

		List handles = new ArrayList();

		for (Iterator objectIter = objList.iterator(); objectIter.hasNext();) {
			handles.add(this.addObject(objectIter.next()));
		}
		return handles;
	}

	/**
	 * Notifies the rules engine that a given object in the rule session state
	 * has changed. <p/> The semantics of this call are equivalent to calling
	 * <code>removeObject</code> followed by <code>addObject</code>. The
	 * original <code>Handle</code> is rebound to the new value for the
	 * <code>Object</code> however.
	 * 
	 * @param objectHandle
	 *            the handle to the original object.
	 * @param newObject
	 *            the new object to bind to the handle.
	 * 
	 * @throws InvalidRuleSessionException
	 *             on illegal rule session state.
	 * @throws InvalidHandleException
	 *             if the input <code>Handle</code> is no longer valid
	 */
	public void updateObject(Handle objectHandle, Object newObject)
			throws InvalidRuleSessionException, InvalidHandleException {
		this.checkRuleSessionValidity();

		if (objectHandle instanceof FactHandle) {
			try {
				this.getWorkingMemory().modifyObject((FactHandle) objectHandle,
						newObject);
			} catch (FactException e) {
				throw new InvalidRuleSessionException("cannot update object", e);
			}
		} else {
			throw new InvalidHandleException("invalid handle");

		}
	}

	/**
	 * Removes a given object from the rule session state of this rule session.
	 * 
	 * @param handleObject
	 *            the handle to the object to be removed from the rule session
	 *            state.
	 * 
	 * @throws InvalidRuleSessionException
	 *             on illegal rule session state.
	 * @throws InvalidHandleException
	 *             if the input <code>Handle</code> is no longer valid
	 */
	public void removeObject(Handle handleObject)
			throws InvalidRuleSessionException, InvalidHandleException {
		this.checkRuleSessionValidity();

		if (handleObject instanceof FactHandle) {
			try {
				this.getWorkingMemory()
						.retractObject((FactHandle) handleObject);
			} catch (FactException e) {
				throw new InvalidRuleSessionException("cannot remove object", e);
			}
		} else {
			throw new InvalidHandleException("invalid handle");
		}
	}

	/**
	 * Returns a List of all objects in the rule session state of this rule
	 * session. The objects should pass the default filter test of the default
	 * <code>RuleExecutionSet</code> filter (if present). <p/> This may not
	 * neccessarily include all objects added by calls to <code>addObject</code>,
	 * and may include <code>Object</code>s created by side-effects. The
	 * execution of a <code>RuleExecutionSet</code> can add, remove and update
	 * objects as part of the rule session state. Therefore the rule session
	 * state is dependent on the rules that are part of the executed
	 * <code>RuleExecutionSet</code> as well as the rule vendor's specific
	 * rule engine behavior.
	 * 
	 * @return a <code>List</code> of all objects part of the rule session
	 *         state.
	 * 
	 * @throws InvalidRuleSessionException
	 *             on illegal rule session state.
	 */
	public List getObjects() throws InvalidRuleSessionException {
		this.checkRuleSessionValidity();

		return this.getObjects(this.getRuleExecutionSet().getObjectFilter());
	}

	/**
	 * Returns a <code>List</code> over the objects in rule session state of
	 * this rule session. The objects should pass the filter test on the
	 * specified <code>ObjectFilter</code>. <p/> This may not neccessarily
	 * include all objects added by calls to <code>addObject</code>, and may
	 * include <code>Object</code>s created by side-effects. The execution of
	 * a <code>RuleExecutionSet</code> can add, remove and update objects as
	 * part of the rule session state. Therefore the rule session state is
	 * dependent on the rules that are part of the executed
	 * <code>RuleExecutionSet</code> as well as the rule vendor's specific
	 * rule engine behavior.
	 * 
	 * @param filter
	 *            the object filter.
	 * 
	 * @return a <code>List</code> of all the objects in the rule session
	 *         state of this rule session based upon the given object filter.
	 * 
	 * @throws InvalidRuleSessionException
	 *             on illegal rule session state.
	 */
	public List getObjects(ObjectFilter filter)
			throws InvalidRuleSessionException {
		this.checkRuleSessionValidity();

		List objects = new ArrayList();

		objects.addAll(this.getWorkingMemory().getObjects());

		this.applyFilter(objects, filter);

		return objects;
	}

	/**
	 * Executes the rules in the bound rule execution set using the objects
	 * present in the rule session state. This will typically modify the rule
	 * session state - and may add, remove or update <code>Object</code>s
	 * bound to <code>Handle</code>s.
	 * 
	 * @throws InvalidRuleSessionException
	 *             on illegal rule session state.
	 */
	public void executeRules() throws InvalidRuleSessionException {
		this.checkRuleSessionValidity();

		try {
			this.getWorkingMemory().fireAllRules();
		} catch (DroolsException e) {
			throw new InvalidRuleSessionException("cannot execute rules", e);
		}
	}

	/**
	 * @see StatefulRuleSessionImpl
	 */
	public Object getObject(Handle handle) throws InvalidRuleSessionException,
			InvalidHandleException {
		this.checkRuleSessionValidity();

		if (handle instanceof FactHandle) {
			try {
				return this.getWorkingMemory().getObject((FactHandle) handle);
			} catch (NoSuchFactObjectException e) {
				throw new InvalidHandleException("invalid handle", e);
			}
		} else {
			throw new InvalidHandleException("invalid handle");
		}
	}

	/**
	 * Returns a <code>List</code> of the <code>Handle</code>s being used
	 * for object identity.
	 * 
	 * @return a <code>List</code> of <code>Handle</code>s present in the
	 *         currect state of the rule session.
	 */
	public List getHandles() {
		List handles = new LinkedList();
		for (Iterator i = this.getWorkingMemory().getFactHandles().iterator(); i
				.hasNext();) {
			Object object = i.next();
			if (object instanceof Handle) {
				handles.add(object);
			}
		}
		return handles;
	}
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久色视频免费观看| 欧美男人的天堂一二区| 国产清纯白嫩初高生在线观看91 | 国产精品拍天天在线| 国产一区二区在线免费观看| 精品国产乱码久久久久久蜜臀 | 精品国产亚洲在线| 精品夜夜嗨av一区二区三区| 久久噜噜亚洲综合| av不卡免费电影| 亚洲综合视频网| 69久久99精品久久久久婷婷| 韩国三级中文字幕hd久久精品| 国产午夜精品美女毛片视频| 99久久精品国产精品久久 | 午夜精品免费在线观看| 91精品国产综合久久久久久| 韩国av一区二区三区四区| 中文字幕在线不卡一区二区三区| 色综合久久久久网| 亚洲成人tv网| 久久综合狠狠综合久久综合88| 91亚洲精品一区二区乱码| 亚洲主播在线播放| 精品国产乱码久久久久久牛牛| 成人精品小蝌蚪| 日韩一区欧美二区| 日本一区二区综合亚洲| 欧美日韩情趣电影| 国产永久精品大片wwwapp| 一区二区三区四区在线播放| 日韩欧美三级在线| 99精品国产99久久久久久白柏| 日本中文一区二区三区| 国产精品美女久久久久久久网站| 在线观看91av| 成人av免费观看| 免费在线一区观看| 综合久久久久久久| 日韩精品在线网站| 一本一本大道香蕉久在线精品 | 亚洲欧美日韩一区| 精品久久久久久最新网址| 色婷婷久久久久swag精品 | 福利一区福利二区| 石原莉奈一区二区三区在线观看| 国产精品久久久久aaaa| 日韩精品一区二区三区四区| 日本道在线观看一区二区| 国产永久精品大片wwwapp | 成人免费视频在线观看| 精品少妇一区二区| 欧美怡红院视频| 成人一道本在线| 国产一区日韩二区欧美三区| 午夜精品久久久久久久99水蜜桃 | 91在线国产福利| 国产精品小仙女| 老司机一区二区| 亚洲超碰97人人做人人爱| 亚洲天堂中文字幕| 亚洲国产成人在线| 国产亚洲1区2区3区| 精品国产乱码久久久久久老虎| 51精品秘密在线观看| 在线精品视频一区二区| av色综合久久天堂av综合| 国产激情91久久精品导航| 国内精品第一页| 狠狠色综合播放一区二区| 一级精品视频在线观看宜春院| 国产成人免费9x9x人网站视频| 日韩精品一二三四| 亚洲五月六月丁香激情| 亚洲在线一区二区三区| 亚洲人成小说网站色在线 | 中文字幕欧美日韩一区| 国产亚洲综合性久久久影院| 日韩精品一区二| 日韩亚洲欧美一区二区三区| 欧美一级二级三级蜜桃| 69久久夜色精品国产69蝌蚪网| 欧美精品v国产精品v日韩精品| 欧美日韩电影一区| 日韩三级.com| 2021国产精品久久精品| 国产亚洲午夜高清国产拍精品| 国产亚洲欧洲997久久综合| 久久精品人人做人人爽97| 国产精品网曝门| 亚洲欧洲三级电影| 亚洲国产一区二区在线播放| 五月天欧美精品| 麻豆高清免费国产一区| 精品一区二区三区免费观看| 国产成人综合精品三级| 99久久精品免费看| 欧美影视一区在线| 日韩一级片在线观看| 久久久国产精品不卡| 国产精品久久久久久户外露出 | 国产一区二区三区四区在线观看| 国产在线国偷精品免费看| 成人免费的视频| 色又黄又爽网站www久久| 欧美日韩午夜影院| 精品国内二区三区| 国产精品色婷婷| 亚洲大型综合色站| 国模少妇一区二区三区| 不卡视频免费播放| 欧美高清激情brazzers| 欧美精品一区二区三区蜜桃| 亚洲少妇中出一区| 午夜精品福利一区二区三区av| 美女视频一区在线观看| 成人avav影音| 这里只有精品99re| 国产精品萝li| 午夜精品福利一区二区三区av| 国产精品一区二区免费不卡| 一本色道久久加勒比精品| 欧美xxxx在线观看| 亚洲男人天堂一区| 国内精品伊人久久久久av影院| 色嗨嗨av一区二区三区| 欧美不卡视频一区| 亚洲国产精品麻豆| 国产成人在线电影| 欧美老肥妇做.爰bbww视频| 亚洲国产高清不卡| 麻豆精品视频在线| 在线观看日韩高清av| 久久精品人人做| 免费观看成人av| 在线日韩一区二区| 欧美国产日产图区| 久久se这里有精品| 欧美日韩国产精选| 玉足女爽爽91| www.色精品| 欧美精品一区二区三区很污很色的 | 精品中文av资源站在线观看| 欧美影院精品一区| 国产精品欧美一区喷水| 韩国v欧美v亚洲v日本v| 欧美二区乱c少妇| 亚洲激情av在线| 色综合中文综合网| 亚洲一线二线三线视频| 成人动漫在线一区| 久久久亚洲综合| 久国产精品韩国三级视频| 3d动漫精品啪啪一区二区竹菊| 亚洲免费三区一区二区| 国产成a人无v码亚洲福利| 日韩精品一区二| 免费高清在线一区| 在线成人小视频| 午夜精品在线看| 欧美色爱综合网| 亚洲香肠在线观看| 欧美亚洲自拍偷拍| 亚洲免费高清视频在线| 91麻豆.com| 亚洲日本电影在线| 色成人在线视频| 一区二区三区中文字幕精品精品| 一本色道**综合亚洲精品蜜桃冫| 1区2区3区国产精品| 99精品久久只有精品| 综合在线观看色| av成人老司机| 亚洲精品乱码久久久久久| 在线看国产一区二区| 亚洲丶国产丶欧美一区二区三区| 在线观看不卡视频| 亚洲国产日韩在线一区模特| 欧美无人高清视频在线观看| 亚洲一区二区视频| 337p亚洲精品色噜噜噜| 老司机免费视频一区二区| 欧美变态凌虐bdsm| 国产激情视频一区二区在线观看| 中文一区二区完整视频在线观看| eeuss鲁片一区二区三区在线看| 国产精品久久久久久久久动漫 | 一区二区三区高清在线| 欧美色涩在线第一页| 日韩国产欧美三级| 久久久久久电影| 成人ar影院免费观看视频| 亚洲综合av网| 日韩一二三四区| 成人性生交大合| 亚洲国产一区二区三区 | 欧美中文字幕久久| 日韩专区欧美专区| 久久久99精品久久| 欧美亚洲日本国产|