??xml version="1.0" encoding="utf-8" standalone="yes"?>久久99国产成人小视频,四虎精品永久免费,亚洲国产视频在线http://www.aygfsteel.com/sshwsfc/category/11579.html阅读本Blog误备塑料袋一?/description>zh-cnThu, 20 Mar 2008 22:51:55 GMTThu, 20 Mar 2008 22:51:55 GMT60Android上的MSN初见成效~~Q!http://www.aygfsteel.com/sshwsfc/archive/2008/03/21/187605.html差沙差沙Thu, 20 Mar 2008 17:59:00 GMThttp://www.aygfsteel.com/sshwsfc/archive/2008/03/21/187605.htmlhttp://www.aygfsteel.com/sshwsfc/comments/187605.htmlhttp://www.aygfsteel.com/sshwsfc/archive/2008/03/21/187605.html#Feedback0http://www.aygfsteel.com/sshwsfc/comments/commentRss/187605.htmlhttp://www.aygfsteel.com/sshwsfc/services/trackbacks/187605.htmll过两天的努力,l于在Android上面跑v来MSN了。现在实C基本的聊天功能,打算陆箋的把其他功能完善Q万事开头难Q相信以后的工作?x)很利?/p>


Gtalk的功能由于有官方支持Q早弄了跟q个差不多的版本?/p>


另外Q这个Y件目前是以插件的形式开发,多一个协议就是多一个apkQ实C些intent卛_。官方的IM包里面有很多支持Q可惜文档没有提?qing)?/p>

 

Android中文论坛原帖



差沙 2008-03-21 01:59 发表评论
]]>
Android发布, Android中国|站正式成立, Ƣ迎讉Khttp://www.aygfsteel.com/sshwsfc/archive/2007/11/15/160736.html差沙差沙Thu, 15 Nov 2007 05:41:00 GMThttp://www.aygfsteel.com/sshwsfc/archive/2007/11/15/160736.htmlhttp://www.aygfsteel.com/sshwsfc/comments/160736.htmlhttp://www.aygfsteel.com/sshwsfc/archive/2007/11/15/160736.html#Feedback0http://www.aygfsteel.com/sshwsfc/comments/commentRss/160736.htmlhttp://www.aygfsteel.com/sshwsfc/services/trackbacks/160736.htmlAndroid是google为手机开发的操作pȝ, ZLinux2.6内核.


2007q?1?2?北美旉), Android的APP SDK公布, 开始了google手机?a class="external text" title="http://code.google.com/android" rel="nofollow">开发大?/a>. 我们致力于Android的开发文档翻? 开发技术交等工作, 希望为Androidq_在中国的推广贡献自己的力?


Andorid的SDK是完全针对java设计? 甚至提供eclipse的插? 作ؓ(f)一个javaer不研I实在可?

现在中文文档已经有了初步q展,  大家译的热情都很高? 论坛里的讨论也十分热? Ƣ迎(zhn)的讉K.

我们的网? http://www.androidcn.net

中文文档计划:

http://www.androidcn.net/wiki

PS: 理员?zhn)? 不知道这个符不符合首发布的规则, 要是不妥我会(x)撤下, 我们都想为Android中文化A(ch)献力?/span>

差沙 2007-11-15 13:41 发表评论
]]>
JBPM的Token路径问题http://www.aygfsteel.com/sshwsfc/archive/2007/04/24/113217.html差沙差沙Tue, 24 Apr 2007 08:04:00 GMThttp://www.aygfsteel.com/sshwsfc/archive/2007/04/24/113217.htmlhttp://www.aygfsteel.com/sshwsfc/comments/113217.htmlhttp://www.aygfsteel.com/sshwsfc/archive/2007/04/24/113217.html#Feedback1http://www.aygfsteel.com/sshwsfc/comments/commentRss/113217.htmlhttp://www.aygfsteel.com/sshwsfc/services/trackbacks/113217.htmlProcessInstance里面有一个findToken(String tokenPath)Ҏ(gu)。这里面写的是tokenPath?tokenPath跟文件系l的规则差不多。类?/fork1/fork2 q样的?br>
那么Q怎么到fork2下的一个分支token Q?br>
token自己也有findTokenq个Ҏ(gu)Q不同的是ProcessInstance的是以rootTokenv点,token自己的是以自׃ؓ(f)L(fng)。那么取到token2下面的分?br>
token2.findToken("token")
如果有返回tokenQ没有返回null


至于token的名字,我刚才查源码才发玎ͼ只有在Fork节点才会(x)ltoken赋予名字。。?

那么token2.findToken("token") q里"token"那里?

命名的规则,如下。?nbsp;

    String tokenName = null;
    
if ( transitionName != null ) {
      
if ( ! parent.hasChild( transitionName ) ) {
        tokenName 
= transitionName;
      }
 else {
        
int i = 2;
        tokenName 
= transitionName + Integer.toString( i );
        
while ( parent.hasChild( tokenName ) ) {
          i
++;
          tokenName 
= transitionName + Integer.toString( i );
        }

      }

    }
 else // no transition name
      int size = ( parent.getChildren()!=null ? parent.getChildren().size()+1 : 1 );
      tokenName 
= Integer.toString(size);
    }

    
return tokenName; 



q里"token"那里来?q个token名字Q你自己可以Ҏ(gu)命名规则得到 。看到这里应该很明了?

token的命名规则;首先Ҏ(gu)transitionName的名字命名,q个transitionName的名字是你自q写的你不可能不知道?如果transitionName的名字重名了Q加自然数区?当然Q如果transitionName没有名字Q用分支的个?1作ؓ(f)名字?

应该比较清楚了?

PSQ这个是qq聊天记录的整理版Q所以说话比较诡异。ؓ(f)的是记录下来避免忘记Q也感谢里的朋友。发C相解决问题是提高水^的一个捷径。?/p>

差沙 2007-04-24 16:04 发表评论
]]>
U逗的JBPMhttp://www.aygfsteel.com/sshwsfc/archive/2006/08/24/65446.html差沙差沙Thu, 24 Aug 2006 03:07:00 GMThttp://www.aygfsteel.com/sshwsfc/archive/2006/08/24/65446.htmlhttp://www.aygfsteel.com/sshwsfc/comments/65446.htmlhttp://www.aygfsteel.com/sshwsfc/archive/2006/08/24/65446.html#Feedback5http://www.aygfsteel.com/sshwsfc/comments/commentRss/65446.htmlhttp://www.aygfsteel.com/sshwsfc/services/trackbacks/65446.html
U?。无中生?/strong>

看到最核心的JpdlXmlReader代码真实Ʋ哭无泪Q如果好好精_Q至能t掉1/3的代码。而其中甚x些无中生有的代码Q?br />
if ( (actorId!=null)
           
|| (pooledActors!=null
         ) 
{
        assignmentDelegation.setProcessDefinition(processDefinition);
        assignmentDelegation.setClassName(
"org.jbpm.taskmgmt.assignment.ActorAssignmentHandler");
        String configuration 
= "";
我们看到Q如果符合之前的条gQ就用代理类来代?span style="COLOR: #000000">org.jbpm.taskmgmt.assignment.ActorAssignmentHandlerq个c,但是找了好半天也没有扑ֈq个cR。。?N是让用户在自q目中用q个cMQ还是ؓ(f)了兼容原来的E序Q,q是其中一U,但是Q可但是Q这个条件根本就不可能满I也就是说q是D废话,而且q无中生有的出来个ActorAssignmentHandler。?br />
U?。画蛇添?/strong>

应该是我的基本功不都扎实Q实在是高不明白下面的代码在q什么。。?br />
  public void setActorId(String actorId) {
    DefaultAuthenticationService authenticationService 
= (DefaultAuthenticationService) services.getAuthenticationService();
    DefaultAuthenticationService defaultAuthenticationService 
= (DefaultAuthenticationService) authenticationService;
    defaultAuthenticationService.setActorId(actorId);
  }
先强制{换成DefaultAuthenticationServiceQ然后再强制转换成DefaultAuthenticationService。。。?br />而且q里q么设计基本上就把DefaultAuthenticationService实现的AuthenticationService接口晑֜那里了,Ҏ(gu)是应该用AuthenticationServiceq个接口来说话才寏Vjbpm的service设计的扩展性很强,可自己配制。但如果q么用service的话Q再怎么扩展也没用?br />
U?。莫“名”其?/strong>

Jbpm中变量的名字真的莫名其妙Q很多明明是Map的类型他叫xxListQ而不是Map的类型,他却叫xxMap。这个地Ҏ(gu)怿应该是能体现出程序员~写E序的严谨性的地方Q而Jbpm作的q不够好?br />
U?。固若金?/strong>

Jbpm的扩展性诏I始l,但是在最重要的泳道的扩展上却家子气h。看看泳道类代理的扩展代码?br />
if (expression!=null){
        assignmentDelegation.setProcessDefinition(processDefinition);
        assignmentDelegation.setClassName(
"org.jbpm.identity.assignment.ExpressionAssignmentHandler");
        assignmentDelegation.setConfiguration(
"<expression>"+expression+"</expression>");
      
    }
写的很明,如果泳道使用表达式来表示的那么就用代理类来代理处理表辑ּ。。我本想Q太好了Q写我自q表达式,然后代理交给Acegi来根据表辑ּ分配ActorIdQ但是,可是Q但可是。他的代理类居然是写ȝQ写得就是自qjava.identity包里面的东西Q不是说java.identity设计的不好,但是一个综合系l的用户角色理pȝ是不可能跟着你的jbpm走的。强行要加入的java.identity的设计有点保护自我的意思,真的金汤Q让我结合acegi的想法又是难上加难。(不过q是有办法的。大家自己找扄Q?br />
U?。口径不一

口径不一是指两个程序部分的l合不一致。这U例子很多,我D一个程序和xsd的冲H的例子?br />Instantiator是jbpm代理里面一个比较不错的概念。代理功能之一是生成代理的cȝ实例Q而Instantiator则是负责生成实例的机Ӟq个Instantiator设计的不错,可以在配制文件中的config-type属性来扩展。看E序?br />
      // find the instantiator
      instantiator = (Instantiator) instantiatorCache.get(configType);
      
if (instantiator == null{
        
// load the instantiator class
        Class instantiatorClass = classLoader.loadClass(configType);
        
// instantiate the instantiator with the default constructor
        instantiator = (Instantiator) instantiatorClass.newInstance();
        instantiatorCache.put(configType, instantiator);
      }
q里的设计很人性化Q可以根据configType来用自己的构造器Q但是xsd却不q么惟?br />
      <xs:attribute name="config-type" default="field">
        
<xs:simpleType>
          
<xs:restriction base="xs:string">
            
<xs:enumeration value="field"/>
            
<xs:enumeration value="bean"/>
            
<xs:enumeration value="constructor"/>
            
<xs:enumeration value="configuration-property"/>
          
</xs:restriction>
        
</xs:simpleType>
      
</xs:attribute>
可以看到它限制了4U类型,别说使用自己的构造器了,p他自qXmlInstantiator都不再考虑范围之内Q真是大义灭亲呀。?br />
构造器来这里的作用很大Q我写了自己的spring构造器Q构造的时候用beanFactory来构造,q样q是存在数据库里面的class也能当作spring的bean来处理。但是如果用xsd的话׃(x)D交验错误Q所以烦(ch)性把xsdL了,q好一切正常,是感觉别扭炏V?br />
U逗N。。?能够看得出来Jbpm需要提高的地方q很多。但是这些问题应该是一些开发h员的疏忽,怿在以后的版本中可以改q。不再怎么U逗,Jbpm在工作流中仍然保有着强劲的地位,对BPM模型的实C作的最为全面。而jbpm的par热部|和IDE也是整个pȝ中的两大亮点Q这些优炚w是不可不提的Q所以我仍旧支持JbpmQ希望他能更加迅速的发展壮大h。。。?br />
PSQ文中错误之处还望大家指出,我希望有些“秀逗”是我自q逗了?img src ="http://www.aygfsteel.com/sshwsfc/aggbug/65446.html" width = "1" height = "1" />

差沙 2006-08-24 11:07 发表评论
]]>
在Acegi中用ACLhttp://www.aygfsteel.com/sshwsfc/archive/2006/06/17/53419.html差沙差沙Fri, 16 Jun 2006 16:20:00 GMThttp://www.aygfsteel.com/sshwsfc/archive/2006/06/17/53419.htmlhttp://www.aygfsteel.com/sshwsfc/comments/53419.htmlhttp://www.aygfsteel.com/sshwsfc/archive/2006/06/17/53419.html#Feedback4http://www.aygfsteel.com/sshwsfc/comments/commentRss/53419.htmlhttp://www.aygfsteel.com/sshwsfc/services/trackbacks/53419.html
首先要理解Acegi里面Voter的概念,ACL正是在一个Voter上扩展v来的。现来看一下AclVoter的配|?br />
    <bean id="aclBeanReadVoter" class="org.acegisecurity.vote.BasicAclEntryVoter">
        
<property name="processConfigAttribute">
            
<value>ACL_READ</value>
        
</property>
        
<property name="processDomainObjectClass">
            
<value>org.springside.modules.security.acl.domain.AclDomainAware</value>
        
</property>
        
<property name="aclManager">
            
<ref local="aclManager"/>
        
</property>
        
<property name="requirePermission">
            
<list>
                
<ref local="org.acegisecurity.acl.basic.SimpleAclEntry.ADMINISTRATION"/>
                
<ref local="org.acegisecurity.acl.basic.SimpleAclEntry.READ"/>
            
</list>
        
</property>
    
</bean>
  1. ACL_READ指的是这个Voter对哪些SecurityConfig起作用,我们可以?span style="COLOR: #000000">ACL_READ配置在想要拦截的Method上。比方说我们要拦截readOrderq个Ҏ(gu)Q以实现ACL控制Q可以这样配|?br />orderManager.readOrder=ACL_READ
  2. processDomainObjectClass指出哪些DomainObject是要q行ACL校验的?/font>
  3. aclManager是一个比较重要的概念Q主要负责在权限列表中根据用户和DomainObject取得acl列表?/font>
  4. requirePermission指出要进行这个操作必d备的acl权限Q比方说read操作必LADMINISTRATION或READ两个权限?/font>

其实整个q程看下来比较清晎ͼ下面来看一下AclManager如何配置?br />

    <!-- ========= ACCESS CONTROL LIST LOOKUP MANAGER DEFINITIONS ========= -->

    
<bean id="aclManager" class="org.acegisecurity.acl.AclProviderManager">
        
<property name="providers">
            
<list>
                
<ref local="basicAclProvider"/>
            
</list>
        
</property>
    
</bean>

    
<bean id="basicAclProvider" class="org.acegisecurity.acl.basic.BasicAclProvider">
        
<property name="basicAclDao">
            
<ref local="basicAclExtendedDao"/>
        
</property>
    
</bean>

    
<bean id="basicAclExtendedDao" class="org.acegisecurity.acl.basic.jdbc.JdbcExtendedDaoImpl">
        
<property name="dataSource">
            
<ref bean="dataSource"/>
        
</property>
    
</bean>

很明显ACLManagerl承了Acegi的一贯风|Provider可以提供多种取得ACL讉K列表的途径Q默认的是用basicAclProvider在数据库中取得。既然提C数据库,那我们就来看一下Acegi默认提供的ACL在数据库里的保存表结构:(x)

CREATE TABLE acl_object_identity (
id 
IDENTITY NOT NULL,
object_identity VARCHAR_IGNORECASE(
250NOT NULL,
parent_object 
INTEGER,
acl_class VARCHAR_IGNORECASE(
250NOT NULL,
CONSTRAINT unique_object_identity UNIQUE(object_identity),
FOREIGN KEY (parent_object) REFERENCES acl_object_identity(id)
);
CREATE TABLE acl_permission (
id 
IDENTITY NOT NULL,
acl_object_identity 
INTEGER NOT NULL,
recipient VARCHAR_IGNORECASE(
100NOT NULL,
mask 
INTEGER NOT NULL,
CONSTRAINT unique_recipient UNIQUE(acl_object_identity, recipient),
FOREIGN KEY (acl_object_identity) REFERENCES acl_object_identity(id)
);
  1. acl_object_identity表存放了所有受保护的domainObject的信息。其中object_identity字段保存了domainObject的class和idQ默认的保存格式是:(x)domainClass:domainObjectId?/li>
  2. acl_permission 是ACL权限列表了,recipient 是用h角色信息Qmask表示了这个用h角色对这个domainObject的访问权限。注意这些信息的保存格式都是可以Ҏ(gu)自己的需要改变的?/li>

q样d和删除的时候Acegip很好的完成拦截工作,但是d一个List的时候,如何才能把该用户不能操作的domainObject剔除掉呢Q这需要afterInvocationManager来完成这个工作。下面来看下配置Q?br />

    <!-- ============== "AFTER INTERCEPTION" AUTHORIZATION DEFINITIONS =========== -->

    
<bean id="afterInvocationManager" class="org.acegisecurity.afterinvocation.AfterInvocationProviderManager">
        
<property name="providers">
            
<list>
                
<ref local="afterAclCollectionRead"/>
            
</list>
        
</property>
    
</bean>
    
<!-- Processes AFTER_ACL_COLLECTION_READ configuration settings -->
    
<bean id="afterAclCollectionRead" class="org.acegisecurity.afterinvocation.BasicAclEntryAfterInvocationCollectionFilteringProvider">
        
<property name="aclManager">
            
<ref local="aclManager"/>
        
</property>
        
<property name="requirePermission">
            
<list>
                
<ref local="org.acegisecurity.acl.basic.SimpleAclEntry.ADMINISTRATION"/>
                
<ref local="org.acegisecurity.acl.basic.SimpleAclEntry.READ"/>
            
</list>
        
</property>
    
</bean>

afterAclCollectionRead?x)在拦截的方法执行结束的时候执行。主要的作用是在返回的List中挨个检查domainObject的操作权限,然后Ҏ(gu)requirePermission来剔除不W合的domainObject?/font>

差沙 2006-06-17 00:20 发表评论
]]>
关于Drools的初步,q醉状态认?/title><link>http://www.aygfsteel.com/sshwsfc/archive/2006/05/28/48622.html</link><dc:creator>差沙</dc:creator><author>差沙</author><pubDate>Sun, 28 May 2006 12:53:00 GMT</pubDate><guid>http://www.aygfsteel.com/sshwsfc/archive/2006/05/28/48622.html</guid><wfw:comment>http://www.aygfsteel.com/sshwsfc/comments/48622.html</wfw:comment><comments>http://www.aygfsteel.com/sshwsfc/archive/2006/05/28/48622.html#Feedback</comments><slash:comments>7</slash:comments><wfw:commentRss>http://www.aygfsteel.com/sshwsfc/comments/commentRss/48622.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/sshwsfc/services/trackbacks/48622.html</trackback:ping><description><![CDATA[q两天在<a class="" title="springside" href="/sshwsfc/admin/www.springside.org.cn" target="_blank">springside</a>受白衣的影响开始关注drools。说他是qx的脚本引擎一炚w不假Q用v来极为方便,本来以ؓ(f)|上应该有不的讲解了,但是发现几乎全是针对2.0版本讲解的。而drools加入jboss后有了质的变化,下面来看一下最新的3.0使用h有什么不同:(x)<br /><br />首先我们要取得ruleQ规则引擎、规则引擎,取得规则是必要的?br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img id="Codehighlighter1_52_1040_Open_Image" onclick="this.style.display='none'; Codehighlighter1_52_1040_Open_Text.style.display='none'; Codehighlighter1_52_1040_Closed_Image.style.display='inline'; Codehighlighter1_52_1040_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_52_1040_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_52_1040_Closed_Text.style.display='none'; Codehighlighter1_52_1040_Open_Image.style.display='inline'; Codehighlighter1_52_1040_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /><span style="COLOR: #0000ff">private</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">static</span><span style="COLOR: #000000"> RuleBase readRule() </span><span style="COLOR: #0000ff">throws</span><span style="COLOR: #000000"> Exception </span><span id="Codehighlighter1_52_1040_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.aygfsteel.com/images/dot.gif" /></span><span id="Codehighlighter1_52_1040_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">read in the source</span><span style="COLOR: #008000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" /></span><span style="COLOR: #000000">        Reader source </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> InputStreamReader( DroolsTest.</span><span style="COLOR: #0000ff">class</span><span style="COLOR: #000000">.getResourceAsStream( </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">/aclcreat.drl</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> ) );<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />        <br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">optionally read in the DSL (if you are using it).</span><span style="COLOR: #008000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" /></span><span style="COLOR: #000000">        Reader dsl </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> InputStreamReader( DroolsTest.</span><span style="COLOR: #0000ff">class</span><span style="COLOR: #000000">.getResourceAsStream( </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">/mylang.dsl</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> ) );<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">Use package builder to build up a rule package.<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">An alternative lower level class called "DrlParser" can also be used<img src="http://www.aygfsteel.com/images/dot.gif" /></span><span style="COLOR: #008000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" /></span><span style="COLOR: #000000">        <br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />        PackageBuilder builder </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> PackageBuilder();<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">this wil parse and compile in one step<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">NOTE: There are 2 methods here, the one argument one is for normal DRL.<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">builder.addPackageFromDrl( source );<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">Use the following instead of above if you are using a DSL:</span><span style="COLOR: #008000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" /></span><span style="COLOR: #000000">        builder.addPackageFromDrl( source, dsl );<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />        <br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">get the compiled package (which is serializable)</span><span style="COLOR: #008000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" /></span><span style="COLOR: #000000">        Package pkg </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> builder.getPackage();<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />        <br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">add the package to a rulebase (deploy the rule package).</span><span style="COLOR: #008000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" /></span><span style="COLOR: #000000">        RuleBase ruleBase </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> RuleBaseFactory.newRuleBase();<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />        ruleBase.addPackage( pkg );<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> ruleBase;<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />    }</span></span></div><br />q里在官方的例子基础上做了自q实现(其实什么都没改)?br /><br />可以看到Q第一步是取得文gIOQ这个文件就是我们要写得规则脚本Q这个等下再_(d)大家可以假象一下脚本是个什么样子,现在只说怎么在程序中取得Rule?br />接下来,是用Builder取得一个packageQ既然builder都上来了说明能输入的脚本不止一个了。用addPackageFromDrl向这个builder压羃机里面输入脚本,当然q有另外一个文件dslQ这个后面再说。利用builder取得package?br /><br />最后构造一个BaseRuleQ利用Factory取得的时候是有选择的,RuleBaseFactory.newRuleBase(int type)其中的type可以Z同的AlgorithmQ有RETE和Leaps 两种。对q两UAlgorithm的具体解释可以参?<a >http://citeseer.ist.psu.edu/context/505087/0</a> 或是 drools的文档,其实我也不太懂?br /><br />把刚才的packagedruleBase里面一个Rule大功告成了?br /><br />接下来看看怎么执行它:(x)<br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: #000000">            WorkingMemory workingMemory </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> ruleBase.newWorkingMemory();<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />            <br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />            </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">go !</span><span style="COLOR: #008000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #000000">            Order order </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> Order();<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />            order.setId(</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">);<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />            order.setName(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">testOrder</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />            order.setTotlePrice(</span><span style="COLOR: #000000">10</span><span style="COLOR: #000000">);<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />                        <br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />            User user </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> User();<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />            user.setName(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">testAdmin</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />            user.setAuth(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">USER_ADMIN</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />            List</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">String</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"> roles </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> ArrayList</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">String</span><span style="COLOR: #000000">></span><span style="COLOR: #000000">();<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />            roles.add(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">ADMIN</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />            user.setRoles(roles);<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />            <br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />            User user1 </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> User();<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />            user1.setName(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">testUser</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />            user1.setAuth(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">USER_USER</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />            List</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">String</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"> roles1 </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> ArrayList</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">String</span><span style="COLOR: #000000">></span><span style="COLOR: #000000">();<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />            roles1.add(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">USER</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />            user1.setRoles(roles1);<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />            <br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />            workingMemory.assertObject(order);<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />            workingMemory.assertObject(user);<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />            workingMemory.assertObject(user1);<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />            <br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />            workingMemory.fireAllRules();        <br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />            <br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />            List</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">AclEntry</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"> acls </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> workingMemory.getObjects(AclEntry.</span><span style="COLOR: #0000ff">class</span><span style="COLOR: #000000">);</span></div><br />用ruleBase生成一个WorkingMemoryQW(xu)orkingMemory是Rule的执行引擎,装蝲rule和事?很重要的概念)Qƈl一执行他们。接下来我就在写我的事实Q事实是什么,事实是今天是什么天Q订单Mh(hun)多少Q就是要告诉脚本的java对象。然后把事实一一压入WorkingMemoryq个大压~机。就瞧好吧?<br /><br />OK可以执行了,fireAllRules!Q真TMQCOOL的名字)(j)。当然有全部执行有部分执行。你可以把规则分l,然后按组执行Q或是指定rule的名字来执行(q里q是大家自己看看??br /><br />Q?Q究竟执行了什么。当然是执行了我们的脚本Q脚本在q里、看看它可不是xml了:(x)<br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: #000000">#created on: </span><span style="COLOR: #000000">2006</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">5</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">19</span><span style="COLOR: #000000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">package</span><span style="COLOR: #000000"> com.sample;<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />#list any </span><span style="COLOR: #0000ff">import</span><span style="COLOR: #000000"> classes here.<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">import</span><span style="COLOR: #000000"> com.sample.domain.Order;<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">import</span><span style="COLOR: #000000"> com.sample.domain.User;<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">import</span><span style="COLOR: #000000"> com.sample.AclEntry;<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />#expander mylang.dsl<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />#declare any global variables here<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />rule </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">Order TotlePrice more than $1000</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">    <br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />    when<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />        #conditions<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />        $order : Order( totlePrice </span><span style="COLOR: #000000">></span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">1000</span><span style="COLOR: #000000"> )<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />        $user : User( roles contains </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">ADMIN</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"> , $userName : name)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />    then <br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />        #actions<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />        System.out.println(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">More Than</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />        </span><span style="COLOR: #0000ff">assert</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> AclEntry($order, $user, </span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">));<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />end<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />rule </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">Order TotlePrice less or equl than $1000</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">    <br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />    when<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />        #conditions<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />        $order : Order( totlePrice </span><span style="COLOR: #000000"><=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">1000</span><span style="COLOR: #000000"> )<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />        $user : User( $userName : name )<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />    then <br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />        #actions<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />        System.out.println(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">Less Than</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />        </span><span style="COLOR: #0000ff">assert</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> AclEntry($order, $user, </span><span style="COLOR: #000000">2</span><span style="COLOR: #000000">));<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />end</span></div><br />每一个rule是一个规则,所有的事实要一一q一遍这些规则。when是规则提出的条gQ如果哪个事实符合这个条Ӟp入then的环节,q行相应的处理?br /><br />分析一下条Ӟ(x)$order : Order( totlePrice <span style="COLOR: #000000">></span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">1000</span><span style="COLOR: #000000"> )。一看就知道是Mh(hun)过1000的订单?order是把q个订单邦定Q后面可以用?br />分析一下thenQ System.out.println׃解释了?span style="COLOR: #0000ff">assert</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> AclEntry($order, $user, </span><span style="COLOR: #000000">2</span><span style="COLOR: #000000">)); q里的assert的意义就是告诉WorkingMemory一个事实,其实跟前面的加入事实一个道理。打个比方,如果有闪?sh),那么有雗?br /><br />q样走完一个rule后大家很Ҏ(gu)发现Q其实是Ҏ(gu)订单和用L(fng)角色不同产生了不同的aclQ然后我要拿到这些由事实得到的事实?br /><br /></span></span><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: #000000">List</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">AclEntry</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"> acls </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> workingMemory.getObjects(AclEntry.</span><span style="COLOR: #0000ff">class</span><span style="COLOR: #000000">);</span></div>q样p在workingMemory里面掏出我们需要的事实来,新鲜出炉的哦?br /><br />相当_略的讲了一下droolsQ目的是希望大家都来了解一下,共同学习(fn)?img src ="http://www.aygfsteel.com/sshwsfc/aggbug/48622.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/sshwsfc/" target="_blank">差沙</a> 2006-05-28 20:53 <a href="http://www.aygfsteel.com/sshwsfc/archive/2006/05/28/48622.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <a href="http://www.aygfsteel.com/" title="狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频">狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频</a> </div> </footer> վ֩ģ壺 <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">²</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ɽ</a>| <a href="http://" target="_blank">̴</a>| <a href="http://" target="_blank">Ϻӿ</a>| <a href="http://" target="_blank">ƽ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">³</a>| <a href="http://" target="_blank">ͳ</a>| <a href="http://" target="_blank">½</a>| <a href="http://" target="_blank">ݳ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">Ӧñر</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ػ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">̩</a>| <a href="http://" target="_blank">ǭ</a>| <a href="http://" target="_blank">̫ԭ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">Ϫ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ĺ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">౱</a>| <a href="http://" target="_blank">᰸</a>| <a href="http://" target="_blank">ׯ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">Ȫ</a>| <a href="http://" target="_blank">;</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>