You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(233) |
Sep
(199) |
Oct
(206) |
Nov
(185) |
Dec
(270) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(232) |
Feb
(426) |
Mar
(623) |
Apr
(592) |
May
(506) |
Jun
(389) |
Jul
(160) |
Aug
(3) |
Sep
(1) |
Oct
(1) |
Nov
(2) |
Dec
(5) |
2007 |
Jan
(1) |
Feb
(1) |
Mar
(2) |
Apr
(2) |
May
(4) |
Jun
(2) |
Jul
|
Aug
(3) |
Sep
(5) |
Oct
(9) |
Nov
(6) |
Dec
(6) |
2008 |
Jan
(3) |
Feb
|
Mar
(1) |
Apr
(3) |
May
(3) |
Jun
(5) |
Jul
(10) |
Aug
(2) |
Sep
(12) |
Oct
(10) |
Nov
(54) |
Dec
(49) |
2009 |
Jan
(19) |
Feb
(13) |
Mar
(20) |
Apr
(24) |
May
(44) |
Jun
(29) |
Jul
(32) |
Aug
(10) |
Sep
(7) |
Oct
(10) |
Nov
(4) |
Dec
(17) |
2010 |
Jan
(14) |
Feb
(5) |
Mar
(23) |
Apr
(50) |
May
(31) |
Jun
(9) |
Jul
(5) |
Aug
(4) |
Sep
(7) |
Oct
(5) |
Nov
(2) |
Dec
(3) |
2011 |
Jan
(12) |
Feb
(5) |
Mar
(5) |
Apr
(3) |
May
(4) |
Jun
(3) |
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
2012 |
Jan
(1) |
Feb
(2) |
Mar
|
Apr
(1) |
May
(1) |
Jun
(2) |
Jul
(4) |
Aug
(1) |
Sep
|
Oct
(1) |
Nov
|
Dec
|
2013 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(2) |
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(3) |
Sep
|
Oct
|
Nov
|
Dec
(1) |
2015 |
Jan
|
Feb
|
Mar
(2) |
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2016 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <jbo...@li...> - 2006-04-20 03:43:17
|
Author: mar...@jb... Date: 2006-04-19 23:42:56 -0400 (Wed, 19 Apr 2006) New Revision: 3826 Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/GroupElement.java Log: -comment out some transformation code, make it work in 3.1 Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/GroupElement.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/GroupElement.java 2006-04-20 03:30:44 UTC (rev 3825) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/GroupElement.java 2006-04-20 03:42:56 UTC (rev 3826) @@ -53,39 +53,42 @@ // } // } - if ( child instanceof GroupElement && ( child instanceof And || child instanceof Or ) ) { - GroupElement group = ( GroupElement ) child; - - // Removal single branch group elements - // If the child is a GroupElement iterate down until we either - // find a GroupElement that has more than one children, or its not a GroupElement - if ( group.getChildren().size() == 1 ) { - child = group.getChildren().get( 0 ); - } - } + //@todo make this work for 3.1 +// if ( child instanceof GroupElement && ( child instanceof And || child instanceof Or ) ) { +// GroupElement group = ( GroupElement ) child; +// +// // Removal single branch group elements +// // If the child is a GroupElement iterate down until we either +// // find a GroupElement that has more than one children, or its not a GroupElement +// if ( group.getChildren().size() == 1 ) { +// child = group.getChildren().get( 0 ); +// } +// } +// +// if ( child instanceof GroupElement && ( child instanceof And || child instanceof Or ) ) { +// GroupElement group = ( GroupElement ) child; +// +// // Remove nested Ands/Ors +// if ( group.getClass() == this.getClass() ) { +// +// GroupElement newGroup = null; +// if ( group instanceof And) { +// newGroup = new And(); +// } else { +// newGroup = new Or(); +// } +// +// for ( Iterator it = group.getChildren().iterator(); it.hasNext(); ) { +// this.children.add( it.next() ); +// } +// } else { +// this.children.add( child ); +// } +// } else { +// this.children.add( child ); +// } - if ( child instanceof GroupElement && ( child instanceof And || child instanceof Or ) ) { - GroupElement group = ( GroupElement ) child; - - // Remove nested Ands/Ors - if ( group.getClass() == this.getClass() ) { - - GroupElement newGroup = null; - if ( group instanceof And) { - newGroup = new And(); - } else { - newGroup = new Or(); - } - - for ( Iterator it = group.getChildren().iterator(); it.hasNext(); ) { - this.children.add( it.next() ); - } - } else { - this.children.add( child ); - } - } else { - this.children.add( child ); - } + this.children.add( child ); } |
From: <jbo...@li...> - 2006-04-20 03:30:57
|
Author: mic...@jb... Date: 2006-04-19 23:30:44 -0400 (Wed, 19 Apr 2006) New Revision: 3825 Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/semantics/java/FunctionFixer.java labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/semantics/java/FunctionFixerTest.java Log: JBRULES-228 Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/semantics/java/FunctionFixer.java =================================================================== --- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/semantics/java/FunctionFixer.java 2006-04-20 03:26:27 UTC (rev 3824) +++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/semantics/java/FunctionFixer.java 2006-04-20 03:30:44 UTC (rev 3825) @@ -15,15 +15,24 @@ * limitations under the License. */ - - +import java.util.HashSet; +import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; +/** + * This horrific utility adds in the function class name (which is the same as the functions method name) + * into the RHS guts of a rule. It has to tip toe around method calls, new declarations and other + * stuff like that. + * A better future solution is to use a static import as found in Java 5, then ALL THIS can + * disappear. Oh Happy day. + * @author Michael Neale (sadly..) + * + */ public class FunctionFixer { static Pattern FUNCTION = Pattern.compile("(\\S*\\s*|\\.\\s*)\\b([\\S&&[^\\.]]+)\\s*\\(([^)]*)\\)", Pattern.DOTALL); - + static final Set KEYWORDS = getJavaKeywords(); public String fix(String raw) { //return raw; return fix(raw, FUNCTION); @@ -46,13 +55,15 @@ } } String function = matcher.group(2).trim(); + //if we have a reserved work, DO NOT TOUCH ! + if (KEYWORDS.contains( function )) continue; String params = matcher.group(3).trim(); String target = ucFirst(function) + "." + function + "(" + params + ")"; buf.append( raw.substring( lastIndex, matcher.start( 2 ) ) ); - buf.append( KnowledgeHelperFixer.replace( target, "$", "\\$", 128 ) ); + buf.append( target ); lastIndex = matcher.end(); } buf.append( raw.substring( lastIndex ) ); @@ -62,4 +73,63 @@ private String ucFirst(String name) { return name.toUpperCase().charAt( 0 ) + name.substring( 1 ); } + + /** + * This list was obtained from http://java.sun.com/docs/books/tutorial/java/nutsandbolts/_keywords.html + */ + private static Set getJavaKeywords() { + Set keys = new HashSet(); + keys.add("abstract"); + keys.add("continue"); + keys.add("for"); + keys.add("new"); + keys.add("switch"); + keys.add("assert"); + keys.add("default"); + keys.add("goto"); + keys.add("package"); + keys.add("synchronized"); + keys.add("boolean"); + keys.add("do"); + keys.add("if"); + keys.add("private"); + keys.add("this"); + keys.add("break"); + keys.add("double"); + keys.add("implements"); + keys.add("protected"); + keys.add("throw"); + keys.add("byte"); + keys.add("else"); + keys.add("import"); + keys.add("public"); + keys.add("throws"); + keys.add("case"); + keys.add("enum"); + keys.add("instanceof"); + keys.add("return"); + keys.add("transient"); + keys.add("catch"); + keys.add("extends"); + keys.add("int"); + keys.add("short"); + keys.add("try"); + keys.add("char"); + keys.add("final"); + keys.add("interface"); + keys.add("static"); + keys.add("void"); + keys.add("class"); + keys.add("finally"); + keys.add("long"); + keys.add("strictfp"); + keys.add("volatile"); + keys.add("const"); + keys.add("float"); + keys.add("native"); + keys.add("super"); + keys.add("while"); + return keys; + } + } \ No newline at end of file Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/semantics/java/FunctionFixerTest.java =================================================================== --- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/semantics/java/FunctionFixerTest.java 2006-04-20 03:26:27 UTC (rev 3824) +++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/semantics/java/FunctionFixerTest.java 2006-04-20 03:30:44 UTC (rev 3825) @@ -64,5 +64,11 @@ assertEquals( "\nFoo.foo($list);", fixer.fix( "\nfoo($list);" ) ); } + + public void testReservedWordsInJava() { + FunctionFixer fixer = new FunctionFixer(); + assertEquals( "\nfor(int i=0; i < 2; i++) { /*do noithing*/ }", + fixer.fix( "\nfor(int i=0; i < 2; i++) { /*do noithing*/ }" ) ); + } } \ No newline at end of file |
From: <jbo...@li...> - 2006-04-20 03:26:33
|
Author: mar...@jb... Date: 2006-04-19 23:26:27 -0400 (Wed, 19 Apr 2006) New Revision: 3824 Removed: labs/jbossrules/trunk/repository/jci/jci/SNAPSHOT-378493+patch3/ Log: -removed old version of jci |
From: <jbo...@li...> - 2006-04-20 03:25:15
|
Author: mar...@jb... Date: 2006-04-19 23:25:09 -0400 (Wed, 19 Apr 2006) New Revision: 3823 Removed: labs/jbossrules/trunk/repository/eclipse/jdtcore/3.2.0.v_653/ Log: -delete old dependency |
From: <jbo...@li...> - 2006-04-20 03:04:39
|
Author: mar...@jb... Date: 2006-04-19 23:04:35 -0400 (Wed, 19 Apr 2006) New Revision: 3822 Removed: labs/jbossrules/trunk/repository/xpp/ Log: -remove jars as they are found else where |
From: <jbo...@li...> - 2006-04-20 03:04:20
|
Author: mar...@jb... Date: 2006-04-19 23:04:16 -0400 (Wed, 19 Apr 2006) New Revision: 3821 Removed: labs/jbossrules/trunk/repository/javax/ Log: -remove jars as they are found else where |
Author: mar...@jb... Date: 2006-04-19 22:55:11 -0400 (Wed, 19 Apr 2006) New Revision: 3820 Added: labs/jbossrules/trunk/repository/jci/jci/SNAPSHOT-378493+patch4/ labs/jbossrules/trunk/repository/jci/jci/SNAPSHOT-378493+patch4/jci-SNAPSHOT-378493+patch4.jar labs/jbossrules/trunk/repository/jci/jci/SNAPSHOT-378493+patch4/jci-SNAPSHOT-378493+patch4.pom Modified: labs/jbossrules/trunk/drools-compiler/.classpath labs/jbossrules/trunk/drools-compiler/pom.xml labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/PackageBuilderConfiguration.java labs/jbossrules/trunk/drools-examples/src/java/com/sample/StateExampleUsingAgendGroup.java labs/jbossrules/trunk/drools-examples/src/java/com/sample/TroubleTicketExample.java labs/jbossrules/trunk/drools-examples/src/rules/TroubleTicket.drl Log: -recompiled jci against janino 2.4.1 Modified: labs/jbossrules/trunk/drools-compiler/.classpath =================================================================== --- labs/jbossrules/trunk/drools-compiler/.classpath 2006-04-20 02:24:13 UTC (rev 3819) +++ labs/jbossrules/trunk/drools-compiler/.classpath 2006-04-20 02:55:11 UTC (rev 3820) @@ -1,25 +1,26 @@ -<classpath> - <classpathentry kind="src" path="src/main/java"/> - <classpathentry kind="src" path="src/main/resources"/> - <classpathentry kind="src" path="src/test/java" output="target/test-classes"/> - <classpathentry kind="src" path="src/test/resources" output="target/test-classes"/> - <classpathentry kind="output" path="target/classes"/> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> - <classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar"/> - <classpathentry kind="var" path="M2_REPO/concurrent/concurrent/1.3.4/concurrent-1.3.4.jar"/> - <classpathentry kind="var" path="M2_REPO/xerces/xercesImpl/2.6.2/xercesImpl-2.6.2.jar"/> - <classpathentry kind="var" path="M2_REPO/antlr/antlr/2.7.6/antlr-2.7.6.jar"/> - <classpathentry kind="var" path="M2_REPO/commons-lang/commons-lang/2.1/commons-lang-2.1.jar"/> - <classpathentry kind="var" path="M2_REPO/xstream/xstream/1.1.3/xstream-1.1.3.jar"/> - <classpathentry kind="var" path="M2_REPO/drools-asm/drools-asm/2.2.1/drools-asm-2.2.1.jar"/> - <classpathentry kind="var" path="M2_REPO/commons-collections/commons-collections/3.1/commons-collections-3.1.jar"/> - <classpathentry kind="var" path="M2_REPO/commons-logging/commons-logging-api/1.0.4/commons-logging-api-1.0.4.jar"/> - <classpathentry kind="var" path="M2_REPO/xpp/xpp/3-1.1.3.4.O/xpp-3-1.1.3.4.O.jar"/> - <classpathentry kind="var" path="M2_REPO/antlr/stringtemplate/2.3b6/stringtemplate-2.3b6.jar"/> - <classpathentry kind="src" path="/drools-core"/> - <classpathentry kind="var" path="M2_REPO/jci/jci/SNAPSHOT-378493+patch3/jci-SNAPSHOT-378493+patch3.jar"/> - <classpathentry kind="var" path="M2_REPO/colt/colt/1.2.0/colt-1.2.0.jar"/> - <classpathentry kind="var" path="M2_REPO/jung/jung/1.7.2/jung-1.7.2.jar"/> - <classpathentry kind="var" path="M2_REPO/antlr/antlr3/3.0ea8/antlr3-3.0ea8.jar"/> - <classpathentry kind="var" path="M2_REPO/eclipse/jdtcore/3.2.0.v_653/jdtcore-3.2.0.v_653.jar"/> -</classpath> \ No newline at end of file +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" path="src/main/java"/> + <classpathentry kind="src" path="src/main/resources"/> + <classpathentry output="target/test-classes" kind="src" path="src/test/java"/> + <classpathentry output="target/test-classes" kind="src" path="src/test/resources"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar"/> + <classpathentry kind="var" path="M2_REPO/concurrent/concurrent/1.3.4/concurrent-1.3.4.jar"/> + <classpathentry kind="var" path="M2_REPO/xerces/xercesImpl/2.6.2/xercesImpl-2.6.2.jar"/> + <classpathentry kind="var" path="M2_REPO/antlr/antlr/2.7.6/antlr-2.7.6.jar"/> + <classpathentry kind="var" path="M2_REPO/commons-lang/commons-lang/2.1/commons-lang-2.1.jar"/> + <classpathentry kind="var" path="M2_REPO/xstream/xstream/1.1.3/xstream-1.1.3.jar"/> + <classpathentry kind="var" path="M2_REPO/drools-asm/drools-asm/2.2.1/drools-asm-2.2.1.jar"/> + <classpathentry kind="var" path="M2_REPO/commons-collections/commons-collections/3.1/commons-collections-3.1.jar"/> + <classpathentry kind="var" path="M2_REPO/commons-logging/commons-logging-api/1.0.4/commons-logging-api-1.0.4.jar"/> + <classpathentry kind="var" path="M2_REPO/xpp/xpp/3-1.1.3.4.O/xpp-3-1.1.3.4.O.jar"/> + <classpathentry kind="var" path="M2_REPO/antlr/stringtemplate/2.3b6/stringtemplate-2.3b6.jar"/> + <classpathentry kind="src" path="/drools-core"/> + <classpathentry kind="var" path="M2_REPO/colt/colt/1.2.0/colt-1.2.0.jar"/> + <classpathentry kind="var" path="M2_REPO/jung/jung/1.7.2/jung-1.7.2.jar"/> + <classpathentry kind="var" path="M2_REPO/antlr/antlr3/3.0ea8/antlr3-3.0ea8.jar"/> + <classpathentry kind="var" path="M2_REPO/eclipse/jdtcore/3.2.0.v_653/jdtcore-3.2.0.v_653.jar"/> + <classpathentry combineaccessrules="false" kind="src" path="/commons-jci"/> + <classpathentry kind="output" path="target/classes"/> +</classpath> Modified: labs/jbossrules/trunk/drools-compiler/pom.xml =================================================================== --- labs/jbossrules/trunk/drools-compiler/pom.xml 2006-04-20 02:24:13 UTC (rev 3819) +++ labs/jbossrules/trunk/drools-compiler/pom.xml 2006-04-20 02:55:11 UTC (rev 3820) @@ -30,10 +30,16 @@ <dependency> <groupId>jci</groupId> <artifactId>jci</artifactId> - <version>SNAPSHOT-378493+patch3</version> + <version>SNAPSHOT-378493+patch4</version> </dependency> <dependency> + <groupId>janino</groupId> + <artifactId>janino</artifactId> + <version>2.4.1</version> + </dependency> + + <dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging-api</artifactId> <version>1.0.4</version> Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/PackageBuilderConfiguration.java =================================================================== --- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/PackageBuilderConfiguration.java 2006-04-20 02:24:13 UTC (rev 3819) +++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/PackageBuilderConfiguration.java 2006-04-20 02:55:11 UTC (rev 3820) @@ -24,7 +24,7 @@ public static final int ECLIPSE = 0; public static final int JANINO = 1; - private int compiler = JavaCompilerFactory.ECLIPSE; + private int compiler = JavaCompilerFactory.JANINO; private ClassLoader classLoader; Modified: labs/jbossrules/trunk/drools-examples/src/java/com/sample/StateExampleUsingAgendGroup.java =================================================================== --- labs/jbossrules/trunk/drools-examples/src/java/com/sample/StateExampleUsingAgendGroup.java 2006-04-20 02:24:13 UTC (rev 3819) +++ labs/jbossrules/trunk/drools-examples/src/java/com/sample/StateExampleUsingAgendGroup.java 2006-04-20 02:55:11 UTC (rev 3820) @@ -7,6 +7,8 @@ import org.drools.WorkingMemory; import org.drools.audit.WorkingMemoryFileLogger; import org.drools.compiler.PackageBuilder; +import org.drools.event.AfterActivationFiredEvent; +import org.drools.event.DefaultAgendaEventListener; public class StateExampleUsingAgendGroup { @@ -21,8 +23,15 @@ RuleBase ruleBase = RuleBaseFactory.newRuleBase(); ruleBase.addPackage( builder.getPackage() ); - WorkingMemory workingMemory = ruleBase.newWorkingMemory( ); + WorkingMemory workingMemory = ruleBase.newWorkingMemory( ); + workingMemory.addEventListener( new DefaultAgendaEventListener() { + public void afterActivationFired(AfterActivationFiredEvent arg0) { + super.afterActivationFired( arg0 ); + } + } + ); + WorkingMemoryFileLogger logger = new WorkingMemoryFileLogger(workingMemory); logger.setFileName("log/state"); Modified: labs/jbossrules/trunk/drools-examples/src/java/com/sample/TroubleTicketExample.java =================================================================== --- labs/jbossrules/trunk/drools-examples/src/java/com/sample/TroubleTicketExample.java 2006-04-20 02:24:13 UTC (rev 3819) +++ labs/jbossrules/trunk/drools-examples/src/java/com/sample/TroubleTicketExample.java 2006-04-20 02:55:11 UTC (rev 3820) @@ -25,7 +25,7 @@ WorkingMemory workingMemory = ruleBase.newWorkingMemory(); WorkingMemoryFileLogger logger = new WorkingMemoryFileLogger( workingMemory ); - logger.setFileName( "log/state" ); + logger.setFileName( "log/trouble_ticket" ); Customer a = new Customer( "A", "Gold" ); Customer b = new Customer( "B", "Platinum" ); @@ -61,8 +61,10 @@ catch ( InterruptedException e ) { e.printStackTrace( ); - } + } + System.err.println( "[[ awake ]]" ); + logger.writeToDisk(); } Modified: labs/jbossrules/trunk/drools-examples/src/rules/TroubleTicket.drl =================================================================== --- labs/jbossrules/trunk/drools-examples/src/rules/TroubleTicket.drl 2006-04-20 02:24:13 UTC (rev 3819) +++ labs/jbossrules/trunk/drools-examples/src/rules/TroubleTicket.drl 2006-04-20 02:55:11 UTC (rev 3820) @@ -1,5 +1,8 @@ package com.sample +import com.sample.TroubleTicketExample.Customer; +import com.sample.TroubleTicketExample.Ticket; + rule "New Ticket" salience 10 when @@ -38,8 +41,6 @@ modify( ticket ); end - - rule "Escalate" when customer : Customer( ) @@ -58,8 +59,4 @@ function void sendEscalationEmail( Customer customer, Ticket ticket ) { System.out.println( "Email : " + ticket ); -} - -import com.sample.TroubleTicketExample.Customer; -import com.sample.TroubleTicketExample.Ticket; - +} \ No newline at end of file Added: labs/jbossrules/trunk/repository/jci/jci/SNAPSHOT-378493+patch4/jci-SNAPSHOT-378493+patch4.jar =================================================================== (Binary files differ) Property changes on: labs/jbossrules/trunk/repository/jci/jci/SNAPSHOT-378493+patch4/jci-SNAPSHOT-378493+patch4.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: labs/jbossrules/trunk/repository/jci/jci/SNAPSHOT-378493+patch4/jci-SNAPSHOT-378493+patch4.pom =================================================================== --- labs/jbossrules/trunk/repository/jci/jci/SNAPSHOT-378493+patch4/jci-SNAPSHOT-378493+patch4.pom 2006-04-20 02:24:13 UTC (rev 3819) +++ labs/jbossrules/trunk/repository/jci/jci/SNAPSHOT-378493+patch4/jci-SNAPSHOT-378493+patch4.pom 2006-04-20 02:55:11 UTC (rev 3820) @@ -0,0 +1,7 @@ +<project> + <modelVersion>4.0.0</modelVersion> + <groupId>jci</groupId> + <artifactId>jci</artifactId> + <version>SNAPSHOT-378493+patch4</version> + <dependencies/> +</project> \ No newline at end of file |
From: <jbo...@li...> - 2006-04-20 02:24:18
|
Author: mar...@jb... Date: 2006-04-19 22:24:13 -0400 (Wed, 19 Apr 2006) New Revision: 3819 Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/GroupElement.java Log: -Fix broken test with GroupElement Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/GroupElement.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/GroupElement.java 2006-04-20 01:26:35 UTC (rev 3818) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/GroupElement.java 2006-04-20 02:24:13 UTC (rev 3819) @@ -53,41 +53,40 @@ // } // } -// if ( child instanceof GroupElement && ( child instanceof And || child instanceof Or ) ) { -// GroupElement group = ( GroupElement ) child; -// -// // Removal single branch group elements -// // If the child is a GroupElement iterate down until we either -// // find a GroupElement that has more than one children, or its not a GroupElement -// if ( group.getChildren().size() == 1 ) { -// child = group.getChildren().get( 0 ); -// } -// } -// -// if ( child instanceof GroupElement && ( child instanceof And || child instanceof Or ) ) { -// GroupElement group = ( GroupElement ) child; -// -// // Remove nested Ands/Ors -// if ( group.getClass() == this.getClass() ) { -// -// GroupElement newGroup = null; -// if ( group instanceof And) { -// newGroup = new And(); -// } else { -// newGroup = new Or(); -// } -// -// for ( Iterator it = group.getChildren().iterator(); it.hasNext(); ) { -// this.children.add( it.next() ); -// } -// } else { -// this.children.add( child ); -// } -// } else { -// this.children.add( child ); -// } + if ( child instanceof GroupElement && ( child instanceof And || child instanceof Or ) ) { + GroupElement group = ( GroupElement ) child; + + // Removal single branch group elements + // If the child is a GroupElement iterate down until we either + // find a GroupElement that has more than one children, or its not a GroupElement + if ( group.getChildren().size() == 1 ) { + child = group.getChildren().get( 0 ); + } + } - this.children.add( child ); + if ( child instanceof GroupElement && ( child instanceof And || child instanceof Or ) ) { + GroupElement group = ( GroupElement ) child; + + // Remove nested Ands/Ors + if ( group.getClass() == this.getClass() ) { + + GroupElement newGroup = null; + if ( group instanceof And) { + newGroup = new And(); + } else { + newGroup = new Or(); + } + + for ( Iterator it = group.getChildren().iterator(); it.hasNext(); ) { + this.children.add( it.next() ); + } + } else { + this.children.add( child ); + } + } else { + this.children.add( child ); + } + } public List getChildren() { |
From: <jbo...@li...> - 2006-04-20 01:26:40
|
Author: mar...@jb... Date: 2006-04-19 21:26:35 -0400 (Wed, 19 Apr 2006) New Revision: 3818 Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/IntegrationCases.java labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/LeapsTest.java Log: -test updates Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/IntegrationCases.java =================================================================== --- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/IntegrationCases.java 2006-04-20 01:25:02 UTC (rev 3817) +++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/IntegrationCases.java 2006-04-20 01:26:35 UTC (rev 3818) @@ -36,6 +36,7 @@ import org.drools.Cheesery; import org.drools.FactHandle; import org.drools.Person; +import org.drools.QueryResults; import org.drools.RuleBase; import org.drools.WorkingMemory; import org.drools.compiler.DrlParser; @@ -222,7 +223,7 @@ Cheese stilton = new Cheese( "stinky", 5 ); workingMemory.assertObject( stilton ); - List results = workingMemory.getQueryResults( "simple query" ); + QueryResults results = workingMemory.getQueryResults( "simple query" ); assertEquals( 1, results.size() ); } Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/LeapsTest.java =================================================================== --- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/LeapsTest.java 2006-04-20 01:25:02 UTC (rev 3817) +++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/LeapsTest.java 2006-04-20 01:26:35 UTC (rev 3818) @@ -22,6 +22,7 @@ import java.util.List; import org.drools.Cheese; +import org.drools.QueryResults; import org.drools.RuleBase; import org.drools.WorkingMemory; import org.drools.compiler.PackageBuilder; @@ -58,7 +59,7 @@ Cheese stilton = new Cheese("stinky", 5); workingMemory.assertObject(stilton); workingMemory.fireAllRules();// <=== the only difference from the base test case - List results = workingMemory.getQueryResults("simple query"); + QueryResults results = workingMemory.getQueryResults("simple query"); assertEquals(1, results.size()); } |
From: <jbo...@li...> - 2006-04-20 01:25:15
|
Author: mar...@jb... Date: 2006-04-19 21:25:02 -0400 (Wed, 19 Apr 2006) New Revision: 3817 Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/QueryResult.java labs/jbossrules/trunk/drools-core/src/main/java/org/drools/QueryResults.java Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/SynchronizedWorkingMemory.java labs/jbossrules/trunk/drools-core/src/main/java/org/drools/WorkingMemory.java labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/DefaultKnowledgeHelper.java labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/WorkingMemoryImpl.java labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/WorkingMemoryImpl.java labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/GroupElement.java labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/LogicTransformer.java labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/KnowledgeHelper.java labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/QueryTerminalNodeTest.java Log: JBRULES-225 QueryResults for handling the results of querries Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/QueryResult.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/QueryResult.java 2006-04-20 01:12:46 UTC (rev 3816) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/QueryResult.java 2006-04-20 01:25:02 UTC (rev 3817) @@ -0,0 +1,45 @@ +package org.drools; + +import java.util.Map; + +import org.drools.rule.Declaration; +import org.drools.spi.Tuple; + +public class QueryResult { + + private Tuple tuple; + private WorkingMemory workingMemory; + private QueryResults queryResults; + + public QueryResult( Tuple tuple, + WorkingMemory workingMemory, + QueryResults queryResults) { + this.tuple = tuple; + this.workingMemory = workingMemory; + this.queryResults = queryResults; + } + + public Map getDeclarations() { + return this.queryResults.getDeclarations(); + } + + public Object get(int i) { + return this.workingMemory.getObject( tuple.get( i ) ); + } + + public Object get(String declaration) { + return get( ( Declaration ) this.queryResults.getDeclarations().get( declaration ) ); + } + + public Object get(Declaration declaration) { + return declaration.getValue( this.workingMemory.getObject( this.tuple.get( declaration ) ) ); + } + + public FactHandle[] getFactHandles() { + return this.tuple.getFactHandles(); + } + + public int size() { + return tuple.getFactHandles().length; + } +} Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/QueryResults.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/QueryResults.java 2006-04-20 01:12:46 UTC (rev 3816) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/QueryResults.java 2006-04-20 01:25:02 UTC (rev 3817) @@ -0,0 +1,79 @@ +package org.drools; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.NoSuchElementException; + +import org.drools.rule.Declaration; +import org.drools.rule.Query; +import org.drools.spi.Tuple; + +public class QueryResults { + private Query query; + + private Map declarations; + + private List results; + private WorkingMemory workingMemory; + + public QueryResults(List results, + Query query, + WorkingMemory workingMemory) { + this.results = results; + this.query = query; + this.workingMemory = workingMemory; + } + + public QueryResult get(int i) { + if ( i > this.results.size() ) { + throw new NoSuchElementException(); + } + return new QueryResult( (Tuple) this.results.get( i ), + workingMemory, + this ); + } + + public Iterator iterator() { + return new QueryResultsIterator( this.results.iterator() ); + } + + public Map getDeclarations() { + + Declaration[] declarations = this.query.getDeclarations(); + Map map = new HashMap( declarations.length ); + for ( int i = 0, length = declarations.length; i < length; i++ ) { + map.put( declarations[i].getIdentifier(), + declarations ); + } + this.declarations = map; + + return this.declarations; + } + + public int size() { + return this.results.size(); + } + + class QueryResultsIterator implements Iterator { + private Iterator iterator; + + public QueryResultsIterator(Iterator iterator) { + this.iterator = iterator; + } + + public boolean hasNext() { + return this.iterator.hasNext(); + } + + public Object next() { + return new QueryResult( ( Tuple ) this.iterator.next(), QueryResults.this.workingMemory, QueryResults.this ); + } + + public void remove() { + this.iterator.remove(); + } + + } +} Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/SynchronizedWorkingMemory.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/SynchronizedWorkingMemory.java 2006-04-20 01:12:46 UTC (rev 3816) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/SynchronizedWorkingMemory.java 2006-04-20 01:25:02 UTC (rev 3817) @@ -152,7 +152,7 @@ return this.workingMemory.getGlobals(); } - public List getQueryResults(String query) { + public QueryResults getQueryResults(String query) { return this.workingMemory.getQueryResults( query ); } Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/WorkingMemory.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/WorkingMemory.java 2006-04-20 01:12:46 UTC (rev 3816) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/WorkingMemory.java 2006-04-20 01:25:02 UTC (rev 3817) @@ -219,7 +219,7 @@ */ FactHandle assertObject(Object object) throws FactException; - public List getQueryResults(String query); + public QueryResults getQueryResults(String query); /** * Assert a fact registering JavaBean <code>PropertyChangeListeners</code> Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/DefaultKnowledgeHelper.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/DefaultKnowledgeHelper.java 2006-04-20 01:12:46 UTC (rev 3816) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/DefaultKnowledgeHelper.java 2006-04-20 01:25:02 UTC (rev 3817) @@ -20,6 +20,7 @@ import org.drools.FactException; import org.drools.FactHandle; +import org.drools.QueryResults; import org.drools.WorkingMemory; import org.drools.common.InternalWorkingMemoryActions; import org.drools.rule.Declaration; @@ -121,7 +122,7 @@ return this.activation; } - public List getQueryResults(String query) { + public QueryResults getQueryResults(String query) { return this.workingMemory.getQueryResults( query ); } Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/WorkingMemoryImpl.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/WorkingMemoryImpl.java 2006-04-20 01:12:46 UTC (rev 3816) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/leaps/WorkingMemoryImpl.java 2006-04-20 01:25:02 UTC (rev 3817) @@ -32,6 +32,7 @@ import org.drools.FactException; import org.drools.FactHandle; +import org.drools.QueryResults; import org.drools.WorkingMemory; import org.drools.common.AbstractWorkingMemory; import org.drools.common.Agenda; @@ -42,6 +43,7 @@ import org.drools.common.ScheduledAgendaItem; import org.drools.leaps.conflict.DefaultConflictResolver; import org.drools.leaps.util.TableIterator; +import org.drools.rule.Query; import org.drools.rule.Rule; import org.drools.spi.Activation; import org.drools.spi.AgendaFilter; @@ -870,8 +872,16 @@ ((RuleBaseImpl) this.ruleBase).disposeWorkingMemory( this ); } - public List getQueryResults(String query) { - return (List) this.queryResults.remove( query ); + public QueryResults getQueryResults(String query) { + List list = ( List ) this.queryResults.remove( query ); + if ( list == null ) { + return null; + } + + // @todo we need to pass the Query itself + return new QueryResults( list, + ( Query ) null, + this); } void addToQueryResults(String query, Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/WorkingMemoryImpl.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/WorkingMemoryImpl.java 2006-04-20 01:12:46 UTC (rev 3816) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/WorkingMemoryImpl.java 2006-04-20 01:25:02 UTC (rev 3817) @@ -33,6 +33,7 @@ import org.drools.FactHandle; import org.drools.NoSuchFactHandleException; import org.drools.NoSuchFactObjectException; +import org.drools.QueryResults; import org.drools.RuleBase; import org.drools.WorkingMemory; import org.drools.base.DroolsQuery; @@ -45,6 +46,7 @@ import org.drools.event.AgendaEventSupport; import org.drools.event.WorkingMemoryEventListener; import org.drools.event.WorkingMemoryEventSupport; +import org.drools.rule.Query; import org.drools.rule.Rule; import org.drools.spi.Activation; import org.drools.spi.AgendaFilter; @@ -333,15 +335,21 @@ return matching; } - public List getQueryResults(String query) { + public QueryResults getQueryResults(String query) { FactHandle handle = assertObject( new DroolsQuery( query ) ); QueryTerminalNode node = (QueryTerminalNode) this.queryResults.remove( query ); - List list = null; - if ( node != null ) { - list = (List) this.nodeMemories.remove( node.getId() ); + if ( node == null ) { + retractObject( handle ); + return null; } + + List list = (List) this.nodeMemories.remove( node.getId() ); + retractObject( handle ); - return list; + if ( list == null ) { + list = Collections.EMPTY_LIST; + } + return new QueryResults( list, ( Query ) node.getRule(), this); } void setQueryResults(String query, Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/GroupElement.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/GroupElement.java 2006-04-20 01:12:46 UTC (rev 3816) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/GroupElement.java 2006-04-20 01:25:02 UTC (rev 3817) @@ -53,39 +53,41 @@ // } // } - if ( child instanceof GroupElement && ( child instanceof And || child instanceof Or ) ) { - GroupElement group = ( GroupElement ) child; - - // Removal single branch group elements - // If the child is a GroupElement iterate down until we either - // find a GroupElement that has more than one children, or its not a GroupElement - if ( group.getChildren().size() == 1 ) { - child = group.getChildren().get( 0 ); - } - } +// if ( child instanceof GroupElement && ( child instanceof And || child instanceof Or ) ) { +// GroupElement group = ( GroupElement ) child; +// +// // Removal single branch group elements +// // If the child is a GroupElement iterate down until we either +// // find a GroupElement that has more than one children, or its not a GroupElement +// if ( group.getChildren().size() == 1 ) { +// child = group.getChildren().get( 0 ); +// } +// } +// +// if ( child instanceof GroupElement && ( child instanceof And || child instanceof Or ) ) { +// GroupElement group = ( GroupElement ) child; +// +// // Remove nested Ands/Ors +// if ( group.getClass() == this.getClass() ) { +// +// GroupElement newGroup = null; +// if ( group instanceof And) { +// newGroup = new And(); +// } else { +// newGroup = new Or(); +// } +// +// for ( Iterator it = group.getChildren().iterator(); it.hasNext(); ) { +// this.children.add( it.next() ); +// } +// } else { +// this.children.add( child ); +// } +// } else { +// this.children.add( child ); +// } - if ( child instanceof GroupElement && ( child instanceof And || child instanceof Or ) ) { - GroupElement group = ( GroupElement ) child; - - // Remove nested Ands/Ors - if ( group.getClass() == this.getClass() ) { - - GroupElement newGroup = null; - if ( group instanceof And) { - newGroup = new And(); - } else { - newGroup = new Or(); - } - - for ( Iterator it = group.getChildren().iterator(); it.hasNext(); ) { - this.children.add( it.next() ); - } - } else { - this.children.add( child ); - } - } else { - this.children.add( child ); - } + this.children.add( child ); } public List getChildren() { Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/LogicTransformer.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/LogicTransformer.java 2006-04-20 01:12:46 UTC (rev 3816) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/LogicTransformer.java 2006-04-20 01:25:02 UTC (rev 3817) @@ -130,7 +130,15 @@ ands = new And[or.getChildren().size()]; int i = 0; for ( Iterator it = or.getChildren().iterator(); it.hasNext(); ) { - ands[i] = (And) it.next(); + Object object = it.next(); + if ( object.getClass() == And.class ) { + ands[i] = (And) object; + } else { + And newAnd = new And(); + newAnd.addChild( and ); + ands[i] = newAnd; + } + i++; } @@ -223,10 +231,6 @@ parent.getChildren().addAll( newChildren ); } - void checkForAndRemoveSingleBranch(GroupElement parent) { - - } - GroupElement applyOrTransformation(GroupElement parent, GroupElement child) throws InvalidPatternException { Transformation transformation = null; Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/KnowledgeHelper.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/KnowledgeHelper.java 2006-04-20 01:12:46 UTC (rev 3816) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/KnowledgeHelper.java 2006-04-20 01:25:02 UTC (rev 3817) @@ -23,6 +23,7 @@ import org.drools.FactException; import org.drools.FactHandle; +import org.drools.QueryResults; import org.drools.WorkingMemory; import org.drools.rule.Declaration; import org.drools.rule.Rule; @@ -103,7 +104,7 @@ */ List getObjects(Class objectClass); - List getQueryResults(String query); + QueryResults getQueryResults(String query); /** * Clears the agenda causing all existing Activations to fire Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/QueryTerminalNodeTest.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/QueryTerminalNodeTest.java 2006-04-20 01:12:46 UTC (rev 3816) +++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/QueryTerminalNodeTest.java 2006-04-20 01:25:02 UTC (rev 3817) @@ -17,11 +17,14 @@ +import java.util.Iterator; import java.util.List; import junit.framework.TestCase; import org.drools.FactHandle; +import org.drools.QueryResult; +import org.drools.QueryResults; import org.drools.WorkingMemory; import org.drools.base.ClassFieldExtractor; import org.drools.base.ClassObjectType; @@ -98,48 +101,70 @@ queryNode.attach(); WorkingMemory workingMemory = ruleBase.newWorkingMemory(); - List list = workingMemory.getQueryResults( "query-1" ); + QueryResults results = workingMemory.getQueryResults( "query-1" ); - assertNull( list ); + assertNull( results ); - Cheese stilton = new Cheese( "stilton", + Cheese stilton1 = new Cheese( "stilton", 100 ); - FactHandle handle1 = workingMemory.assertObject( stilton ); + FactHandle handle1 = workingMemory.assertObject( stilton1 ); - list = workingMemory.getQueryResults( "query-1" ); + results = workingMemory.getQueryResults( "query-1" ); assertEquals( 1, - list.size() ); + results.size() ); Cheese cheddar = new Cheese( "cheddar", 55 ); workingMemory.assertObject( cheddar ); - list = workingMemory.getQueryResults( "query-1" ); + results = workingMemory.getQueryResults( "query-1" ); assertEquals( 1, - list.size() ); + results.size() ); - stilton = new Cheese( "stilton", + Cheese stilton2 = new Cheese( "stilton", 5 ); - FactHandle handle2 = workingMemory.assertObject( stilton ); + FactHandle handle2 = workingMemory.assertObject( stilton2 ); - list = workingMemory.getQueryResults( "query-1" ); + results = workingMemory.getQueryResults( "query-1" ); assertEquals( 2, - list.size() ); + results.size() ); + + QueryResult result = results.get( 0 ); + assertTrue( result.get( 0 ) instanceof DroolsQuery ); + assertSame( stilton1, result.get( 1 ) ); + result = results.get( 1 ); + assertTrue( result.get( 0 ) instanceof DroolsQuery ); + assertSame( stilton2, result.get( 1 ) ); + + int i = 0; + for ( Iterator it = results.iterator(); it.hasNext(); ) { + result = ( QueryResult ) it.next(); + assertTrue( result.get( 0 ) instanceof DroolsQuery ); + if ( i == 0 ) { + assertSame( stilton1, result.get( 1 ) ); + } else { + assertSame( stilton2, result.get( 1 ) ); + } + i++; + } + + workingMemory.retractObject( handle1 ); - list = workingMemory.getQueryResults( "query-1" ); + results = workingMemory.getQueryResults( "query-1" ); + assertEquals( 1, - list.size() ); + results.size() ); workingMemory.retractObject( handle2 ); - list = workingMemory.getQueryResults( "query-1" ); + results = workingMemory.getQueryResults( "query-1" ); - assertNull( list ); + assertNull( results ); } @@ -161,6 +186,10 @@ public String getType() { return type; } + + public String toString() { + return "[Cheese type='" + this.type + "' price='" + this.price + "']"; + } } } \ No newline at end of file |
From: <jbo...@li...> - 2006-04-20 01:12:50
|
Author: mic...@jb... Date: 2006-04-19 21:12:46 -0400 (Wed, 19 Apr 2006) New Revision: 3816 Modified: labs/jbossrules/trunk/documentation/manual/en/Chapter-Rule_Language/Section-DSL.xml Log: Modified: labs/jbossrules/trunk/documentation/manual/en/Chapter-Rule_Language/Section-DSL.xml =================================================================== --- labs/jbossrules/trunk/documentation/manual/en/Chapter-Rule_Language/Section-DSL.xml 2006-04-19 23:15:15 UTC (rev 3815) +++ labs/jbossrules/trunk/documentation/manual/en/Chapter-Rule_Language/Section-DSL.xml 2006-04-20 01:12:46 UTC (rev 3816) @@ -25,8 +25,7 @@ <section> <title>Creating a DSL</title> - <para>A DSL's configuration like most things is stored in a plain text - file. If you use the IDE, you get a nice graphical editor, but the format + <para>A DSL's configuration like most things is stored in plain text. If you use the IDE, you get a nice graphical editor, but the format of the file is quite simple, and is basically a properties file.</para> <example> @@ -36,6 +35,15 @@ </example> </section> + <para> + Refering to the above example, the [when] refers to the scope of the expression: ie does it belong on the LHS or the RHS of a rule. + The part after the [scope] is the expression that you use in the rule (typically a natural language expression, but it doesn't have to be). + The part on the right of the "=" is the mapping into the rule language (of course the form of this depends on if you are talking about the RHS or the LHS). + </para> + <para> + The parser will take the expression you specify, and extract the values that match where the {something} appear in the input. The values are then interpolated with the corresponding {something} on the right hand side of the mapping. + </para> + <section> <title>Using a DSL in your rules</title> |
Author: mar...@jb... Date: 2006-04-19 19:15:15 -0400 (Wed, 19 Apr 2006) New Revision: 3815 Added: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/xml/ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/xml/PackageReaderTest.java labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/ labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/test_ParseGlobal.xml labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/test_ParseImport.xml labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/test_ParsePackageName.xml Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/xml/PackageHandler.java labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/xml/PackageReader.java Log: -Added unit tests for package, globals and imports Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/xml/PackageHandler.java =================================================================== --- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/xml/PackageHandler.java 2006-04-19 21:34:38 UTC (rev 3814) +++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/xml/PackageHandler.java 2006-04-19 23:15:15 UTC (rev 3815) @@ -18,6 +18,7 @@ import java.util.HashSet; +import java.util.List; import org.drools.lang.descr.PackageDescr; import org.xml.sax.Attributes; @@ -50,6 +51,7 @@ public Object start( String uri, String localName, Attributes attrs ) throws SAXException { + packageReader.startConfiguration( localName, attrs ); String ruleSetName = attrs.getValue( "name" ); @@ -68,6 +70,42 @@ public Object end( String uri, String localName ) throws SAXException { + PackageDescr packageDescr = this.packageReader.getPackageDescr(); + Configuration config = packageReader.endConfiguration( ); + + Configuration[] imports = config.getChildren("import"); + + for ( int i = 0, length = imports.length; i < length; i++ ) { + String importEntry = imports[i].getText(); + + if ( importEntry == null || importEntry.trim( ).equals( "" ) ) + { + throw new SAXParseException( + "<import> cannot be blank", packageReader.getLocator( ) ); + } + packageDescr.addImport( importEntry ); + } + + Configuration[] globals = config.getChildren("global"); + + for ( int i = 0, length = globals.length; i < length; i++ ) { + String identifier = globals[i].getAttribute( "identifier" ); + String type = globals[i].getText(); + + if ( identifier == null || identifier.trim( ).equals( "" ) ) + { + throw new SAXParseException( + "<global> must have an identifier", packageReader.getLocator( ) ); + } + + if ( type == null || type.trim( ).equals( "" ) ) + { + throw new SAXParseException( + "<global> must have specify a type", packageReader.getLocator( ) ); + } + packageDescr.addGlobal( identifier, type ); + } + return null; } @@ -75,4 +113,4 @@ { return PackageDescr.class; } -} \ No newline at end of file +} Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/xml/PackageReader.java =================================================================== --- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/xml/PackageReader.java 2006-04-19 21:34:38 UTC (rev 3814) +++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/xml/PackageReader.java 2006-04-19 23:15:15 UTC (rev 3815) @@ -126,39 +126,39 @@ this.parents = new LinkedList(); this.handlers = new HashMap(); - this.handlers.put( "PackageDescr", + this.handlers.put( "package", + new PackageHandler( this ) ); + this.handlers.put( "rule", null ); - this.handlers.put( "RuleDescr", + this.handlers.put( "query", null ); - this.handlers.put( "QueryDescr", + this.handlers.put( "attribute", null ); - this.handlers.put( "AttributeDescr", - null ); - this.handlers.put( "FunctionDescr", + this.handlers.put( "function", null ); // Conditional Elements - this.handlers.put( "AndDescr", + this.handlers.put( "and", null ); - this.handlers.put( "OrDescr", + this.handlers.put( "or", null ); - this.handlers.put( "NotDescr", + this.handlers.put( "not", null ); - this.handlers.put( "ExistsDescr", + this.handlers.put( "exists", null ); - this.handlers.put( "ColumnDescr", + this.handlers.put( "column", null ); // Field Constraints - this.handlers.put( "LiteralDescr", + this.handlers.put( "literal", null ); - this.handlers.put( "PredicateDescr", + this.handlers.put( "predicate", null ); - this.handlers.put( "ReturnValueDescr", + this.handlers.put( "return-value", null ); - this.handlers.put( "BoundVariableDescr", + this.handlers.put( "bound-variable", null ); initEntityResolver(); @@ -334,10 +334,10 @@ } if ( handler == null ) { - if ( ((this.inHandledRuleSubElement == false) && (this.parents.getLast() instanceof RuleDescr)) || (this.parents.getLast() instanceof PackageDescr) ) { - throw new SAXParseException( "unknown tag '" + localName + "' in namespace '" + uri + "'", - getLocator() ); - } +// if ( ((this.inHandledRuleSubElement == false) && (this.parents.getLast() instanceof RuleDescr)) || (this.parents.getLast() instanceof PackageDescr) ) { +// throw new SAXParseException( "unknown tag '" + localName + "' in namespace '" + uri + "'", +// getLocator() ); +// } // no handler so build up the configuration startConfiguration( localName, attrs ); Added: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/xml/PackageReaderTest.java =================================================================== --- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/xml/PackageReaderTest.java 2006-04-19 21:34:38 UTC (rev 3814) +++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/xml/PackageReaderTest.java 2006-04-19 23:15:15 UTC (rev 3815) @@ -0,0 +1,52 @@ +package org.drools.xml; + +import java.io.InputStreamReader; +import java.util.List; +import java.util.Map; + +import junit.framework.TestCase; + +import org.drools.lang.descr.PackageDescr; + +public class PackageReaderTest extends TestCase { + public void testParsePackageName() throws Exception { + PackageReader packageReader = new PackageReader( ); + packageReader.read( new InputStreamReader( getClass().getResourceAsStream( "test_ParsePackageName.xml" ) ) ); + PackageDescr packageDescr = packageReader.getPackageDescr(); + assertNotNull( packageDescr ); + assertEquals("com.sample", packageDescr.getName() ); + } + + + public void testParseImport() throws Exception { + PackageReader packageReader = new PackageReader( ); + packageReader.read( new InputStreamReader( getClass().getResourceAsStream( "test_ParseImport.xml" ) ) ); + PackageDescr packageDescr = packageReader.getPackageDescr(); + assertNotNull( packageDescr ); + assertEquals("com.sample", packageDescr.getName() ); + + List imports = packageDescr.getImports(); + assertEquals( 2, imports.size() ); + assertEquals("java.util.HashMap", imports.get( 0 ) ); + assertEquals("org.drools.*", imports.get( 1 ) ); + } + + public void testParseGlobal() throws Exception { + PackageReader packageReader = new PackageReader( ); + packageReader.read( new InputStreamReader( getClass().getResourceAsStream( "test_ParseGlobal.xml" ) ) ); + PackageDescr packageDescr = packageReader.getPackageDescr(); + assertNotNull( packageDescr ); + assertEquals("com.sample", packageDescr.getName() ); + + List imports = packageDescr.getImports(); + assertEquals( 2, imports.size() ); + assertEquals("java.util.HashMap", imports.get( 0 ) ); + assertEquals("org.drools.*", imports.get( 1 ) ); + + Map globals = packageDescr.getGlobals(); + assertEquals( 2, globals.size() ); + assertEquals("com.sample.X", globals.get( "x" ) ); + assertEquals("com.sample.Yada", globals.get( "yada" ) ); + } + +} Added: labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/test_ParseGlobal.xml =================================================================== --- labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/test_ParseGlobal.xml 2006-04-19 21:34:38 UTC (rev 3814) +++ labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/test_ParseGlobal.xml 2006-04-19 23:15:15 UTC (rev 3815) @@ -0,0 +1,7 @@ +<package name="com.sample"> + <import>java.util.HashMap</import> + <import>org.drools.*</import> + + <global identifier="x">com.sample.X</global> + <global identifier="yada">com.sample.Yada</global> +</package> \ No newline at end of file Added: labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/test_ParseImport.xml =================================================================== --- labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/test_ParseImport.xml 2006-04-19 21:34:38 UTC (rev 3814) +++ labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/test_ParseImport.xml 2006-04-19 23:15:15 UTC (rev 3815) @@ -0,0 +1,4 @@ +<package name="com.sample"> + <import>java.util.HashMap</import> + <import>org.drools.*</import> +</package> \ No newline at end of file Added: labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/test_ParsePackageName.xml =================================================================== --- labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/test_ParsePackageName.xml 2006-04-19 21:34:38 UTC (rev 3814) +++ labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/test_ParsePackageName.xml 2006-04-19 23:15:15 UTC (rev 3815) @@ -0,0 +1,3 @@ +<package name="com.sample"> + +</package> \ No newline at end of file |
Author: wrzep Date: 2006-04-19 17:34:38 -0400 (Wed, 19 Apr 2006) New Revision: 3814 Modified: labs/jbosslabs/trunk/portal-extensions/forge-status/maven.xml labs/jbosslabs/trunk/portal-extensions/forge-status/project.properties labs/jbosslabs/trunk/portal-extensions/forge-status/project.xml labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/Status.java labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/ScoresService.java labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/ScoresServiceImpl.java labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/ScoresServiceLocal.java labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/tools/PluginConf.java labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/tools/PluginValues.java labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/tools/Plugins.java labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/tools/ScoresManager.java Log: JBLAB-599 Pawel Modified: labs/jbosslabs/trunk/portal-extensions/forge-status/maven.xml =================================================================== --- labs/jbosslabs/trunk/portal-extensions/forge-status/maven.xml 2006-04-19 21:20:01 UTC (rev 3813) +++ labs/jbosslabs/trunk/portal-extensions/forge-status/maven.xml 2006-04-19 21:34:38 UTC (rev 3814) @@ -9,20 +9,20 @@ <goal name="all"> <attainGoal name="prj-all" /> <ant:copy tofile="${local.deploy.dir}/${forge.sar.name}/forge-status.ejb3" file="../${forge.sar.dir}/target/${forge.sar.name}/forge-status.ejb3" /> - <ant:copy tofile="${local.deploy.dir}/${forge.sar.name}/status-common.jar" file="../${forge.sar.dir}/target/${forge.sar.name}/status-common.jar" /> +<!-- <ant:copy tofile="${local.deploy.dir}/${forge.sar.name}/status-common.jar" file="../${forge.sar.dir}/target/${forge.sar.name}/status-common.jar" /> --> </goal> <goal name="build"> <attainGoal name="prj-war-build" /> <attainGoal name="ejb" /> - <ant:jar destfile="target/status-common.jar" basedir="target/classes" includes="${common.classes}" /> +<!-- <ant:jar destfile="target/status-common.jar" basedir="target/classes" excludes="${status.portlet.classes} ${status.ejb3.classes}" /> --> </goal> <goal name="deploy"> <attainGoal name="prj-war-deploy" /> <ant:copy tofile="../${forge.sar.dir}/target/${forge.sar.name}/forge-status.ejb3" file="target/forge-status-1.0.jar" /> - <ant:copy tofile="../${forge.sar.dir}/target/${forge.sar.name}/status-common.jar" file="target/status-common.jar" /> - <ant:copy tofile="${maven.repo.local}/jboss-forge/jars/status-common.jar" file="target/status-common.jar" /> +<!-- <ant:copy tofile="../${forge.sar.dir}/target/${forge.sar.name}/status-common.jar" file="target/status-common.jar" /> --> + <!-- <ant:copy tofile="${maven.repo.local}/jboss-forge/jars/status-common.jar" file="target/status-common.jar" /> --> </goal> <goal name="clean"> Modified: labs/jbosslabs/trunk/portal-extensions/forge-status/project.properties =================================================================== --- labs/jbosslabs/trunk/portal-extensions/forge-status/project.properties 2006-04-19 21:20:01 UTC (rev 3813) +++ labs/jbosslabs/trunk/portal-extensions/forge-status/project.properties 2006-04-19 21:34:38 UTC (rev 3814) @@ -1,6 +1,8 @@ maven.repo.remote=http://repository.atlassian.com,http://www.ibiblio.org/maven,http://dist.codehaus.org/ maven.junit.fork=yes maven.war.src=${basedir}/src/web -<!-- common.classes=**/PluginsValues.class,**/PluginValues.class,**/PluginConf.class -maven.war.classes.excludes=${common.classes} -maven.ejb.excludes=${common.classes} --> +status.portlet.classes=**/Status*.class +status.ejb3.classes=**/service/** +maven.war.classes.excludes= **/PluginConf.class **/PluginValues.class + +<!-- maven.ejb.includes=${status.ejb3.classes} **/PluginConf.class --> Modified: labs/jbosslabs/trunk/portal-extensions/forge-status/project.xml =================================================================== --- labs/jbosslabs/trunk/portal-extensions/forge-status/project.xml 2006-04-19 21:20:01 UTC (rev 3813) +++ labs/jbosslabs/trunk/portal-extensions/forge-status/project.xml 2006-04-19 21:34:38 UTC (rev 3814) @@ -26,18 +26,17 @@ <ejb.manifest.classpath>true</ejb.manifest.classpath> </properties> </dependency> - +<!-- <dependency> - <groupId>jboss</groupId> + <groupId>jboss-forge</groupId> <artifactId>status-common</artifactId> <jar>status-common.jar</jar> <properties> - <ejb.manifest.classpath>true</ejb.manifest.classpath> -<!-- <war.manifest.classpath>true</war.manifest.classpath> --> + <ejb.manifest.classpath>true</ejb.manifest.classpath> <war.bundle>true</war.bundle> </properties> </dependency> - +--> <dependency> <groupId>aslibs</groupId> <artifactId>javax.servlet</artifactId> Modified: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/Status.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/Status.java 2006-04-19 21:20:01 UTC (rev 3813) +++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/Status.java 2006-04-19 21:34:38 UTC (rev 3814) @@ -108,6 +108,9 @@ try { boolean b = ScoresManager.save(projects, pluginsConf, portalName); System.out.print("save: " + b); + System.out.println("** class: " + pluginsConf); + System.out.println("** item class: " + pluginsConf.get(0)); + System.out.println("** item x: " + pluginsConf.get(0).getFieldValue("x")); long v = ScoresManager.getValue("downloads", "jbosswiki", portalName, new Date(), new Date()); System.out.println("value = " + v); Modified: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/ScoresService.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/ScoresService.java 2006-04-19 21:20:01 UTC (rev 3813) +++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/ScoresService.java 2006-04-19 21:34:38 UTC (rev 3814) @@ -44,4 +44,6 @@ String portalName); public Object get(String portalName, Date date) throws PluginValueNotFoundException; + + public void fill(PluginValues x, String portalName, Date date) throws PluginValueNotFoundException; } \ No newline at end of file Modified: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/ScoresServiceImpl.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/ScoresServiceImpl.java 2006-04-19 21:20:01 UTC (rev 3813) +++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/ScoresServiceImpl.java 2006-04-19 21:34:38 UTC (rev 3814) @@ -337,5 +337,18 @@ public Object get(String portalName, Date date) throws PluginValueNotFoundException { return ((PluginsValues)getPluginsValues(portalName, date)).getPluginValues("downloads"); } + + public void fill(PluginValues x, String portalName, Date date) throws PluginValueNotFoundException { + + PluginValues y = ((PluginsValues)getPluginsValues(portalName, date)).getPluginValues("downloads"); + + if (y == null) { + log.info("null pluginValues"); + return; + } + + x.fill(y); + + } } Modified: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/ScoresServiceLocal.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/ScoresServiceLocal.java 2006-04-19 21:20:01 UTC (rev 3813) +++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/ScoresServiceLocal.java 2006-04-19 21:34:38 UTC (rev 3814) @@ -44,4 +44,6 @@ String portalName); public Object get(String portalName, Date date) throws PluginValueNotFoundException; + + public void fill(PluginValues x, String portalName, Date date) throws PluginValueNotFoundException; } \ No newline at end of file Modified: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/tools/PluginConf.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/tools/PluginConf.java 2006-04-19 21:20:01 UTC (rev 3813) +++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/tools/PluginConf.java 2006-04-19 21:34:38 UTC (rev 3814) @@ -109,4 +109,8 @@ } } } + + public void set(String x, String v) { //debug + fields.put(x,v); + } } \ No newline at end of file Modified: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/tools/PluginValues.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/tools/PluginValues.java 2006-04-19 21:20:01 UTC (rev 3813) +++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/tools/PluginValues.java 2006-04-19 21:34:38 UTC (rev 3814) @@ -46,6 +46,9 @@ private String pluginId; private String linkName; + public PluginValues() { + // TODO Auto-generated constructor stub + } public PluginValues(Plugin plugin, Set<String> projectIds) { @@ -81,4 +84,15 @@ public String getLinkName() { return linkName; } + + public void fill(PluginValues y) { + + pluginId = y.getId(); + linkName = y.getLinkName(); + /* + values = y.values; + rates = y.rates; + links = y.links; + */ + } } Modified: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/tools/Plugins.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/tools/Plugins.java 2006-04-19 21:20:01 UTC (rev 3813) +++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/tools/Plugins.java 2006-04-19 21:34:38 UTC (rev 3814) @@ -161,6 +161,9 @@ if (plugin != null) { plugins.put(plugin.getId(), plugin); } + + //debug + pluginConf.set("x", "added"); } } Modified: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/tools/ScoresManager.java =================================================================== --- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/tools/ScoresManager.java 2006-04-19 21:20:01 UTC (rev 3813) +++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/tools/ScoresManager.java 2006-04-19 21:34:38 UTC (rev 3814) @@ -64,14 +64,15 @@ ScoresService.class, Tools.STATUS_SERVICE_NAME, server); - /* - PluginValues x = service.get(portalName, date); + + PluginValues x = new PluginValues(); + service.fill(x, portalName, date); System.out.println("x ---> " + x); System.out.println("x.jbosswiki ---> " + x.getValue("jbosswiki")); - */ + /* Object vv = service.getPluginsValues(portalName, date); System.out.println("class: " + vv.getClass() + " / " + vv.toString()); - v = (PluginsValues) vv; + v = (PluginsValues) vv;*/ } catch (Exception e) { e.printStackTrace (); |
Author: adamw Date: 2006-04-19 17:20:01 -0400 (Wed, 19 Apr 2006) New Revision: 3813 Added: labs/shotoku/trunk/lib/taglibs/ labs/shotoku/trunk/lib/taglibs/jars/ labs/shotoku/trunk/lib/taglibs/jars/jstl.jar labs/shotoku/trunk/lib/taglibs/jars/standard.jar Removed: labs/shotoku/trunk/shotoku-svn/src/java/org/jboss/shotoku/test/ Modified: labs/shotoku/trunk/project.properties labs/shotoku/trunk/shotoku-admin/project.xml labs/shotoku/trunk/shotoku-admin/src/java/org/jboss/shotoku/web/admin/AdminServlet.java labs/shotoku/trunk/shotoku-admin/src/web/WEB-INF/web.xml labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/ContentManager.java labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/service/AdministratedService.java labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/service/AdministratedServiceGetter.java labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/service/AdministratedServiceImpl.java labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/service/ShotokuServiceImpl.java labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/Constants.java labs/shotoku/trunk/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnContentManager.java labs/shotoku/trunk/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnTools.java labs/shotoku/trunk/shotoku-svn/src/java/org/jboss/shotoku/svn/service/SvnRepository.java labs/shotoku/trunk/shotoku-svn/src/java/org/jboss/shotoku/svn/service/SvnServiceImpl.java labs/shotoku/trunk/shotoku-svn/src/java/org/jboss/shotoku/svn/service/SvnServiceTimer.java Log: http://jira.jboss.com/jira/browse/JBSHOTOKU-82 Added: labs/shotoku/trunk/lib/taglibs/jars/jstl.jar =================================================================== (Binary files differ) Property changes on: labs/shotoku/trunk/lib/taglibs/jars/jstl.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: labs/shotoku/trunk/lib/taglibs/jars/standard.jar =================================================================== (Binary files differ) Property changes on: labs/shotoku/trunk/lib/taglibs/jars/standard.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: labs/shotoku/trunk/project.properties =================================================================== --- labs/shotoku/trunk/project.properties 2006-04-19 21:14:44 UTC (rev 3812) +++ labs/shotoku/trunk/project.properties 2006-04-19 21:20:01 UTC (rev 3813) @@ -23,5 +23,8 @@ maven.jar.jboss-system=${shotoku.root.dir}lib/jboss/jars/jboss-system.jar maven.jar.jboss-common=${shotoku.root.dir}lib/jboss/jars/jboss-common.jar +maven.jar.standard=${shotoku.root.dir}lib/taglibs/jars/standard.jar +maven.jar.jstl=${shotoku.root.dir}lib/taglibs/jars/jstl.jar + maven.jar.shotoku-base=${shotoku.root.dir}shotoku-base/target/shotoku-base.jar maven.jar.shotoku-aop=${shotoku.root.dir}shotoku-aop/target/shotoku-aop.jar Modified: labs/shotoku/trunk/shotoku-admin/project.xml =================================================================== --- labs/shotoku/trunk/shotoku-admin/project.xml 2006-04-19 21:14:44 UTC (rev 3812) +++ labs/shotoku/trunk/shotoku-admin/project.xml 2006-04-19 21:20:01 UTC (rev 3813) @@ -25,11 +25,22 @@ <version>1.0</version> <jar>javax.servlet.jsp.jar</jar> </dependency> + + <dependency> + <groupId>taglibs</groupId> + <artifactId>jstl</artifactId> + <version>1.0</version> + <jar>jstl.jar</jar> + <properties> + <war.bundle>true</war.bundle> + </properties> + </dependency> <dependency> - <groupId>myfaces</groupId> - <artifactId>myfaces-all</artifactId> - <version>1.1.1</version> + <groupId>taglibs</groupId> + <artifactId>standard</artifactId> + <version>1.0</version> + <jar>standard.jar</jar> <properties> <war.bundle>true</war.bundle> </properties> Modified: labs/shotoku/trunk/shotoku-admin/src/java/org/jboss/shotoku/web/admin/AdminServlet.java =================================================================== --- labs/shotoku/trunk/shotoku-admin/src/java/org/jboss/shotoku/web/admin/AdminServlet.java 2006-04-19 21:14:44 UTC (rev 3812) +++ labs/shotoku/trunk/shotoku-admin/src/java/org/jboss/shotoku/web/admin/AdminServlet.java 2006-04-19 21:20:01 UTC (rev 3813) @@ -15,15 +15,14 @@ * @author Adam Warski (ad...@as...) */ public class AdminServlet extends HttpServlet { - protected void service(HttpServletRequest httpServletRequest, - HttpServletResponse httpServletResponse) + protected void service(HttpServletRequest request, + HttpServletResponse response) throws ServletException, IOException { - httpServletRequest.setAttribute("now", Calendar.getInstance().getTimeInMillis()); + response.setContentType("text/html"); + request.setAttribute("now", Calendar.getInstance().getTimeInMillis()); + request.setAttribute("asgs", Tools.getService().getAdministratedServices()); - for (AdministratedServiceGetter asg : Tools.getService().getAdministratedServices()) { - httpServletRequest.setAttribute("service", asg.get()); - httpServletRequest.getRequestDispatcher("repo-access/services.jsp").include( - httpServletRequest, httpServletResponse); - } + request.getRequestDispatcher("/repo-access/services.jsp").forward( + request, response); } } Modified: labs/shotoku/trunk/shotoku-admin/src/web/WEB-INF/web.xml =================================================================== --- labs/shotoku/trunk/shotoku-admin/src/web/WEB-INF/web.xml 2006-04-19 21:14:44 UTC (rev 3812) +++ labs/shotoku/trunk/shotoku-admin/src/web/WEB-INF/web.xml 2006-04-19 21:20:01 UTC (rev 3813) @@ -1,20 +1,12 @@ <?xml version="1.0"?> -<!DOCTYPE web-app PUBLIC - "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" - "http://java.sun.com/dtd/web-app_2_3.dtd"> -<web-app> - <servlet> - <servlet-name>Admin Servlet</servlet-name> - <servlet-class>org.jboss.shotoku.web.admin</servlet-class> - </servlet> - <servlet-mapping> - <servlet-name>Admin Servlet</servlet-name> - <url-pattern>/*</url-pattern> - </servlet-mapping> - +<web-app xmlns="http://java.sun.com/xml/ns/j2ee" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee + http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" + version="2.4"> <filter> - <filter-name>filesFromRepoFilter</filter-name> - <filter-class>org.jboss.shotoku.web.FilesFromRepoFilter</filter-class> + <filter-name>filesFromRepoFilter</filter-name> + <filter-class>org.jboss.shotoku.web.FilesFromRepoFilter</filter-class> <init-param> <param-name>repoAccessDir</param-name> <param-value>repo-access</param-value> @@ -25,9 +17,20 @@ </init-param> </filter> - <filter-mapping> - <filter-name>filesFromRepoFilter</filter-name> - <url-pattern>/repo-access/*</url-pattern> - <dispatcher>INCLUDE</dispatcher> - </filter-mapping> + <filter-mapping> + <filter-name>filesFromRepoFilter</filter-name> + <url-pattern>/repo-access/*</url-pattern> + <dispatcher>INCLUDE</dispatcher> + <dispatcher>FORWARD</dispatcher> + </filter-mapping> + + <servlet> + <servlet-name>Admin Servlet</servlet-name> + <servlet-class>org.jboss.shotoku.web.admin.AdminServlet</servlet-class> + </servlet> + + <servlet-mapping> + <servlet-name>Admin Servlet</servlet-name> + <url-pattern>/admin/*</url-pattern> + </servlet-mapping> </web-app> Modified: labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/ContentManager.java =================================================================== --- labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/ContentManager.java 2006-04-19 21:14:44 UTC (rev 3812) +++ labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/ContentManager.java 2006-04-19 21:20:01 UTC (rev 3813) @@ -23,13 +23,7 @@ import java.lang.reflect.Constructor; import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Properties; +import java.util.*; import org.apache.commons.configuration.Configuration; import org.apache.commons.configuration.PropertiesConfiguration; @@ -53,674 +47,756 @@ * @author Damon Sicore (da...@si...) */ public abstract class ContentManager { - /** - * Prefix of this content manager. - */ - private String prefix; + /** + * Prefix of this content manager. + */ + private String prefix; - /** - * Id of a corresponding repository. - */ - private String id; + /** + * Id of a corresponding repository. + */ + private String id; - /** - * A map of initialized velocity engines, The key is a string representation - * of parameters with which an engine was initialized. - */ - private static Map<String, VelocityEngine> engines; + /** + * A map of initialized velocity engines, The key is a string representation + * of parameters with which an engine was initialized. + */ + private static Map<String, VelocityEngine> engines; - /** - * Gets a root directory that is represented by this content manager. - * - * @return A directory that is the root directory of this content manager. - * @throws RepositoryException - */ - public abstract Directory getRootDirectory() throws RepositoryException; + /** + * Gets a root directory that is represented by this content manager. + * + * @return A directory that is the root directory of this content manager. + * @throws RepositoryException + */ + public abstract Directory getRootDirectory() throws RepositoryException; - /** - * Gets the most recent version of a node which can be found under the given - * path (to get nodes from subdirectories, use <code>/</code> to separate - * them). - * - * @param path - * Path for which to get the node. - * @return A node corresponding to the given path. - * @throws ResourceDoesNotExist - * @throws RepositoryException - */ - public abstract Node getNode(String path) throws ResourceDoesNotExist, - RepositoryException; + /** + * Gets the most recent version of a node which can be found under the given + * path (to get nodes from subdirectories, use <code>/</code> to separate + * them). + * + * @param path + * Path for which to get the node. + * @return A node corresponding to the given path. + * @throws ResourceDoesNotExist + * @throws RepositoryException + */ + public abstract Node getNode(String path) throws ResourceDoesNotExist, + RepositoryException; - /** - * Gets a directory which can be found under the given path (to get nodes - * from subdirectories, use <code>/</code> to separate them). - * - * @param path - * Path for which to get the directory. - * @return A directory corresponding to the given path. - * @throws ResourceDoesNotExist - * @throws RepositoryException - */ - public abstract Directory getDirectory(String path) - throws ResourceDoesNotExist, RepositoryException; + /** + * Gets a directory which can be found under the given path (to get nodes + * from subdirectories, use <code>/</code> to separate them). + * + * @param path + * Path for which to get the directory. + * @return A directory corresponding to the given path. + * @throws ResourceDoesNotExist + * @throws RepositoryException + */ + public abstract Directory getDirectory(String path) + throws ResourceDoesNotExist, RepositoryException; - /** - * Performs the given search in this content manager. - * - * @param search - * Search to perform. - * @return A node list that is the result of the search. - */ - public NodeList search(Search search) throws ResourceDoesNotExist { - return search.perform(this); - } + /** + * Performs the given search in this content manager. + * + * @param search + * Search to perform. + * @return A node list that is the result of the search. + */ + public NodeList search(Search search) throws ResourceDoesNotExist { + return search.perform(this); + } - /** - * Gets the id of this repository. - * - * @return Id of this repository. - */ - public String getId() { - return id; - } + /** + * Gets the id of this repository. + * + * @return Id of this repository. + */ + public String getId() { + return id; + } - /** - * Gets the prefix of this content manager. - * - * @return Prefix of this content manager. - */ - public String getPrefix() { - return prefix; - } + /** + * Gets the prefix of this content manager. + * + * @return Prefix of this content manager. + */ + public String getPrefix() { + return prefix; + } - /** - * Saves the given resources at one time. Recommended if you have multiple - * resources to save. - * - * @param resources - * Resources to save. - * @param logMessage - * Log message to save with. - * @throws SaveException - * @throws RepositoryException - */ - public abstract void save(Collection<Resource> resources, String logMessage) - throws SaveException, RepositoryException; + /** + * Saves the given resources at one time. Recommended if you have multiple + * resources to save. + * + * @param resources + * Resources to save. + * @param logMessage + * Log message to save with. + * @throws SaveException + * @throws RepositoryException + */ + public abstract void save(Collection<Resource> resources, String logMessage) + throws SaveException, RepositoryException; - /** - * Deletes the given resources at one time. Recommended if you have multiple - * resources to delete. - * - * @param resources - * Resources to delete. - * @throws DeleteException - * @throws RepositoryException - */ - public abstract void delete(Collection<Resource> resources) - throws DeleteException, RepositoryException; + /** + * Deletes the given resources at one time. Recommended if you have multiple + * resources to delete. + * + * @param resources + * Resources to delete. + * @throws DeleteException + * @throws RepositoryException + */ + public abstract void delete(Collection<Resource> resources) + throws DeleteException, RepositoryException; - /** - * Deletes the given resource. Equivalent to resource.delete(). - * - * @param resource - * Resources to delete. - * @throws DeleteException - * @throws RepositoryException - */ - public void delete(Resource resource) throws DeleteException, - RepositoryException { - List<Resource> toDelete = new ArrayList<Resource>(); - toDelete.add(resource); - delete(toDelete); - } + /** + * Deletes the given resource. Equivalent to resource.delete(). + * + * @param resource + * Resources to delete. + * @throws DeleteException + * @throws RepositoryException + */ + public void delete(Resource resource) throws DeleteException, + RepositoryException { + List<Resource> toDelete = new ArrayList<Resource>(); + toDelete.add(resource); + delete(toDelete); + } - /** - * Saves the given resource. Equivalent to <code>res.save(String)</code>. - * - * @param res - * First resource to save. - * @param logMessage - * Log message to save with. - * @throws SaveException - * @throws RepositoryException - */ - public void save(Resource res, String logMessage) throws SaveException, - RepositoryException { - List<Resource> toSave = new ArrayList<Resource>(); - toSave.add(res); - save(toSave, logMessage); - } + /** + * Saves the given resource. Equivalent to <code>res.save(String)</code>. + * + * @param res + * First resource to save. + * @param logMessage + * Log message to save with. + * @throws SaveException + * @throws RepositoryException + */ + public void save(Resource res, String logMessage) throws SaveException, + RepositoryException { + List<Resource> toSave = new ArrayList<Resource>(); + toSave.add(res); + save(toSave, logMessage); + } - /** - * Saves the given resources at one time. Recommended if you have multiple - * resources to save. - * - * @param logMessage - * Log message to save with. - * @param resources - * Any number of resources - * @throws RepositoryException - * @throws SaveException - */ - public void save(String logMessage, Resource... resources) - throws RepositoryException, SaveException { - List<Resource> toSave = new ArrayList<Resource>(); + /** + * Saves the given resources at one time. Recommended if you have multiple + * resources to save. + * + * @param logMessage + * Log message to save with. + * @param resources + * Any number of resources + * @throws RepositoryException + * @throws SaveException + */ + public void save(String logMessage, Resource... resources) + throws RepositoryException, SaveException { + List<Resource> toSave = new ArrayList<Resource>(); - for (Resource resource : resources) { - toSave.add(resource); - } + for (Resource resource : resources) { + toSave.add(resource); + } - save(toSave, logMessage); - } + save(toSave, logMessage); + } - /** - * Deletes the given resources at one time. Recommended if you have multiple - * resources to delete. - * - * @param resources - * Any number of resources to delete - * @throws DeleteException - * @throws RepositoryException - */ - public void delete(Resource... resources) throws DeleteException, - RepositoryException { - List<Resource> toDelete = new ArrayList<Resource>(); + /** + * Deletes the given resources at one time. Recommended if you have multiple + * resources to delete. + * + * @param resources + * Any number of resources to delete + * @throws DeleteException + * @throws RepositoryException + */ + public void delete(Resource... resources) throws DeleteException, + RepositoryException { + List<Resource> toDelete = new ArrayList<Resource>(); - for (Resource resource : resources) { - toDelete.add(resource); - } + for (Resource resource : resources) { + toDelete.add(resource); + } - delete(toDelete); - } + delete(toDelete); + } - /** - * Saves the given resources at one time. Equivalent to - * <code>save(Collection, String)</code>, where the collection is filled - * with the two given resources. - * - * @param res1 - * First resource to save. - * @param res2 - * Second resource to save. - * @param logMessage - * Log message to save with. - * @throws SaveException - * @throws RepositoryException - */ - public void save(Resource res1, Resource res2, String logMessage) - throws SaveException, RepositoryException { - List<Resource> toSave = new ArrayList<Resource>(); - toSave.add(res1); - toSave.add(res2); - save(toSave, logMessage); - } + /** + * Saves the given resources at one time. Equivalent to + * <code>save(Collection, String)</code>, where the collection is filled + * with the two given resources. + * + * @param res1 + * First resource to save. + * @param res2 + * Second resource to save. + * @param logMessage + * Log message to save with. + * @throws SaveException + * @throws RepositoryException + */ + public void save(Resource res1, Resource res2, String logMessage) + throws SaveException, RepositoryException { + List<Resource> toSave = new ArrayList<Resource>(); + toSave.add(res1); + toSave.add(res2); + save(toSave, logMessage); + } - /** - * Saves the given resources at one time. Equivalent to - * <code>save(Collection, String)</code>, where the collection is filled - * with the three given resources. - * - * @param res1 - * First resource to save. - * @param res2 - * Second resource to save. - * @param res3 - * Third resource to save. - * @param logMessage - * Log message to save with. - * @throws SaveException - * @throws RepositoryException - */ - public void save(Resource res1, Resource res2, Resource res3, - String logMessage) throws SaveException, RepositoryException { - List<Resource> toSave = new ArrayList<Resource>(); - toSave.add(res1); - toSave.add(res2); - toSave.add(res3); - save(toSave, logMessage); - } + /** + * Saves the given resources at one time. Equivalent to + * <code>save(Collection, String)</code>, where the collection is filled + * with the three given resources. + * + * @param res1 + * First resource to save. + * @param res2 + * Second resource to save. + * @param res3 + * Third resource to save. + * @param logMessage + * Log message to save with. + * @throws SaveException + * @throws RepositoryException + */ + public void save(Resource res1, Resource res2, Resource res3, + String logMessage) throws SaveException, RepositoryException { + List<Resource> toSave = new ArrayList<Resource>(); + toSave.add(res1); + toSave.add(res2); + toSave.add(res3); + save(toSave, logMessage); + } - /** - * Saves the given resources at one time. Equivalent to - * <code>save(Collection, String)</code>, where the collection is filled - * with the four given resources. - * - * @param res1 - * First resource to save. - * @param res2 - * Second resource to save. - * @param res3 - * Third resource to save. - * @param res4 - * Fourth resource to save. - * @param logMessage - * Log message to save with. - * @throws SaveException - * @throws RepositoryException - */ - public void save(Resource res1, Resource res2, Resource res3, - Resource res4, String logMessage) throws SaveException, - RepositoryException { - List<Resource> toSave = new ArrayList<Resource>(); - toSave.add(res1); - toSave.add(res2); - toSave.add(res3); - toSave.add(res4); - save(toSave, logMessage); - } + /** + * Saves the given resources at one time. Equivalent to + * <code>save(Collection, String)</code>, where the collection is filled + * with the four given resources. + * + * @param res1 + * First resource to save. + * @param res2 + * Second resource to save. + * @param res3 + * Third resource to save. + * @param res4 + * Fourth resource to save. + * @param logMessage + * Log message to save with. + * @throws SaveException + * @throws RepositoryException + */ + public void save(Resource res1, Resource res2, Resource res3, + Resource res4, String logMessage) throws SaveException, + RepositoryException { + List<Resource> toSave = new ArrayList<Resource>(); + toSave.add(res1); + toSave.add(res2); + toSave.add(res3); + toSave.add(res4); + save(toSave, logMessage); + } - /** - * Saves the given resources at one time. Equivalent to - * <code>save(Collection, String)</code>, where the collection is filled - * with the five given resources. - * - * @param res1 - * First resource to save. - * @param res2 - * Second resource to save. - * @param res3 - * Third resource to save. - * @param res4 - * Fourth resource to save. - * @param res5 - * Fifth resource to save. - * @param logMessage - * Log message to save with. - * @throws SaveException - * @throws RepositoryException - */ - public void save(Resource res1, Resource res2, Resource res3, - Resource res4, Resource res5, String logMessage) - throws SaveException, RepositoryException { - List<Resource> toSave = new ArrayList<Resource>(); - toSave.add(res1); - toSave.add(res2); - toSave.add(res3); - toSave.add(res4); - toSave.add(res5); - save(toSave, logMessage); - } + /** + * Saves the given resources at one time. Equivalent to + * <code>save(Collection, String)</code>, where the collection is filled + * with the five given resources. + * + * @param res1 + * First resource to save. + * @param res2 + * Second resource to save. + * @param res3 + * Third resource to save. + * @param res4 + * Fourth resource to save. + * @param res5 + * Fifth resource to save. + * @param logMessage + * Log message to save with. + * @throws SaveException + * @throws RepositoryException + */ + public void save(Resource res1, Resource res2, Resource res3, + Resource res4, Resource res5, String logMessage) + throws SaveException, RepositoryException { + List<Resource> toSave = new ArrayList<Resource>(); + toSave.add(res1); + toSave.add(res2); + toSave.add(res3); + toSave.add(res4); + toSave.add(res5); + save(toSave, logMessage); + } - /** - * Gets a velocity engine, initialized with default properties, as defined - * in velocity.properties in the shotoku-base jar. Additionaly, the shotoku - * resource loader will be set to read templates from this content manager - * (if shotoku resource loader is defined to be used). - * - * @return A velocity engine initialized with default properties. - * @throws Exception - * In case of a velocity exception/ properties reading - * exception. - */ - public VelocityEngine getVelocityEngine() throws Exception { - return getVelocityEngine(true); - } + /** + * Gets a velocity engine, initialized with default properties, as defined + * in velocity.properties in the shotoku-base jar. Additionaly, the shotoku + * resource loader will be set to read templates from this content manager + * (if shotoku resource loader is defined to be used). + * + * @return A velocity engine initialized with default properties. + * @throws Exception + * In case of a velocity exception/ properties reading + * exception. + */ + public VelocityEngine getVelocityEngine() throws Exception { + return getVelocityEngine(true); + } - /** - * Gets a velocity engine, initialized with default properties, as defined - * in velocity.properties in the shotoku-base jar. - * - * @param addIdPrefix - * True iff id/ prefix properties should be added to the - * properties. - * @return A velocity engine initialized with default properties. - * @throws Exception - * In case of a velocity exception/ properties reading - * exception. - */ - public VelocityEngine getVelocityEngine(boolean addIdPrefix) - throws Exception { - return getVelocityEngine(new HashMap<Object, Object>(), addIdPrefix); - } + /** + * Gets a velocity engine, initialized with default properties, as defined + * in velocity.properties in the shotoku-base jar. + * + * @param addIdPrefix + * True iff id/ prefix properties should be added to the + * properties. + * @return A velocity engine initialized with default properties. + * @throws Exception + * In case of a velocity exception/ properties reading + * exception. + */ + public VelocityEngine getVelocityEngine(boolean addIdPrefix) + throws Exception { + return getVelocityEngine(new HashMap<Object, Object>(), addIdPrefix); + } - /** - * Gets a velocity engine, initialized with default properties, overwritten - * by the given propeties. - * - * @param overProps - * Properties which will be added to velocity configuration. - * @return An initialized velocity engine. - * @throws Exception - * In case of a velocity exception/ properties reading - * exception. - */ - public VelocityEngine getVelocityEngine( - Map<? extends Object, ? extends Object> overProps, - boolean addIdPrefix) throws Exception { - String representation = ""; - for (Object key : overProps.keySet()) { - representation += key + "=" + overProps.get(key) + ","; - } + /** + * Gets a velocity engine, initialized with default properties, overwritten + * by the given propeties. + * + * @param overProps + * Properties which will be added to velocity configuration. + * @return An initialized velocity engine. + * @throws Exception + * In case of a velocity exception/ properties reading + * exception. + */ + public VelocityEngine getVelocityEngine( + Map<? extends Object, ? extends Object> overProps, + boolean addIdPrefix) throws Exception { + String representation = ""; + for (Object key : overProps.keySet()) { + representation += key + "=" + overProps.get(key) + ","; + } - representation += ";" + prefix + ";" + id + ";"; - representation += addIdPrefix; + representation += ";" + prefix + ";" + id + ";"; + representation += addIdPrefix; - VelocityEngine ve = engines.get(representation); - if (ve == null) { - ve = new VelocityEngine(); - Properties props = new Properties(); - props.load(ContentManager.class - .getResourceAsStream(Constants.VELOCITY_PROPERTIES_FILE)); - props.putAll(overProps); + VelocityEngine ve = engines.get(representation); + if (ve == null) { + ve = new VelocityEngine(); + Properties props = new Properties(); + props.load(ContentManager.class + .getResourceAsStream(Constants.VELOCITY_PROPERTIES_FILE)); + props.putAll(overProps); - if (addIdPrefix) { - props.put(Constants.VELOCITY_RL_PREFIX, prefix); - props.put(Constants.VELOCITY_RL_ID, id); - } + if (addIdPrefix) { + props.put(Constants.VELOCITY_RL_PREFIX, prefix); + props.put(Constants.VELOCITY_RL_ID, id); + } - ve.init(props); + ve.init(props); - engines.put(representation, ve); - } + engines.put(representation, ve); + } - return ve; - } + return ve; + } - /** - * Standard constructor. - * - * @param id - * Id of this content manager. - * @param prefix - * Prefix of this content manager, as stated in properties. - * @throws RepositoryException - */ - protected ContentManager(String id, String prefix) - throws RepositoryException { - this.id = id; - this.prefix = Tools.normalizeSlashes(prefix, true); - } + /** + * Standard constructor. + * + * @param id + * Id of this content manager. + * @param prefix + * Prefix of this content manager, as stated in properties. + * @throws RepositoryException + */ + protected ContentManager(String id, String prefix) + throws RepositoryException { + this.id = id; + this.prefix = Tools.normalizeSlashes(prefix, true); + } - /* - * Content manager loading. - */ + /* + * Content manager loading. + */ - private static final Logger log; + private static final Logger log; - /** - * Id of the default content manager. May be overriden by a setting in the - * xml configuration file. - */ - private static String defaultId; + /** + * Id of the default content manager. May be overriden by a setting in the + * xml configuration file. + */ + private static String defaultId; - /** - * Size of the transfer buffer. - */ - private static int transferBufferSize; + /** + * Size of the transfer buffer. + */ + private static int transferBufferSize; - /** - * Default interval of the Shotoku service. - */ - private static int defaultServiceInterval; + /** + * Default interval of the Shotoku service. + */ + private static int defaultServiceInterval; - /** - * <code>contentManagers</code> - map (content manager id -> content - * manager constructor). - */ - private static Map<String, Pair<Constructor, Configuration>> contentManagers; + /** + * <code>contentManagers</code> - map (content manager id -> content + * manager constructor). + */ + private static Map<String, Pair<Constructor, Configuration>> contentManagers; - /** - * <code>props</code> - Shotoku properties, as read from the configuration - * file. - */ - private static PropertiesConfiguration props; + /** + * A set of content manager implementation classes names, which are + * already initialized. + */ + private static Set<String> initializedContentManagers; - /** - * <code>setupDone</code> - a marker to execute setup only once, even if - * the user does it many times by mistake. - */ - private static boolean setupDone; + /** + * A set of content manager ids, which are already initialized. + */ + private static Set<String> initializedIds; - static { - // Setup was not yet executed for sure. - setupDone = false; + /** + * A map content manager implementation class name -> a set of + * ids which use the given implementation. + */ + private static Map<String, Set<String>> implementationsIds; - // When this class is loaded, always reading configuration first. - try { - props = new PropertiesConfiguration(); + /** + * <code>props</code> - Shotoku properties, as read from the configuration + * file. + */ + private static PropertiesConfiguration props; - props.load(ContentManager.class - .getResourceAsStream(Constants.PROPERTIES_FILE)); - } catch (Exception e) { - throw new RuntimeException( - "Error while loading content manager configuration: ", e); - } + /** + * <code>setupDone</code> - a marker to execute setup only once, even if + * the user does it many times by mistake. + */ + private static boolean setupDone; - // Setuping the logger. - if (isEmbedded()) { - BasicConfigurator.configure(); - } + static { + // Setup was not yet executed for sure. + setupDone = false; - log = Logger.getLogger(ContentManager.class); - } + // When this class is loaded, always reading configuration first. + try { + props = new PropertiesConfiguration(); - /** - * Checks if Shotoku is configured to run in embedded mode or not. - * - * @return True iff Shotoku is configured to run in embedded mode. - */ - public static boolean isEmbedded() { - return Tools.isTrue(getProperty(Constants.PROPERTIES_EMBEDDED)); - } + props.load(ContentManager.class + .getResourceAsStream(Constants.PROPERTIES_FILE)); + } catch (Exception e) { + throw new RuntimeException( + "Error while loading content manager configuration: ", e); + } - /** - * Setups the content managers before first used. In embedded mode, should - * be always called once, before any usage of Shotoku classes. In app server - * mode, should be never called by the user. - */ - public static void setup() { - synchronized (ContentManager.class) { - if (setupDone) - return; + // Setuping the logger. + if (isEmbedded()) { + BasicConfigurator.configure(); + } - // Preventing setup to be executed twice. - setupDone = true; - } + log = Logger.getLogger(ContentManager.class); + } - engines = Collections - .synchronizedMap(new HashMap<String, VelocityEngine>()); + /** + * Checks if Shotoku is configured to run in embedded mode or not. + * + * @return True iff Shotoku is configured to run in embedded mode. + */ + public static boolean isEmbedded() { + return Tools.isTrue(getProperty(Constants.PROPERTIES_EMBEDDED)); + } - contentManagers = new HashMap<String, Pair<Constructor, Configuration>>(); + /** + * Setups the content managers before first used. In embedded mode, should + * be always called once, before any usage of Shotoku classes. In app server + * mode, should be never called by the user. + */ + public static void setup() { + synchronized (ContentManager.class) { + if (setupDone) + return; - // Reading the default properties. - defaultId = props.getString(Constants.PROPERTIES_ID_DEFAULT, - Constants.DEFAULT_ID); - transferBufferSize = props.getInt( - Constants.PROPERTIES_TRANSFER_BUF_SIZE, - Constants.DEFAULT_TRANSFER_BUF_SIZE); - defaultServiceInterval = props.getInt( - Constants.PROPERTIES_SERVICE_INTERVAL, - Constants.DEFAULT_SERVICE_INTERVAL); + // Preventing setup to be executed twice. + setupDone = true; + } - // Getting ids of defined content managers. - String[] ids = props.getStringArray(Constants.PROPERTIES_IDS); + engines = Collections + .synchronizedMap(new HashMap<String, VelocityEngine>()); - for (String id : ids) { - try { - Configuration conf = props.subset(Tools.concatenateProperties( - Constants.PROPERTIES_PREFIX, id)); + contentManagers = new HashMap<String, Pair<Constructor, Configuration>>(); + initializedContentManagers = new HashSet<String>(); + initializedIds = new HashSet<String>(); + implementationsIds = new HashMap<String, Set<String>>(); - String implementation = conf - .getString(Constants.PROPERTIES_IMPL_SUFFIX); - Class implClass = Class.forName(implementation); + // Reading the default properties. + defaultId = props.getString(Constants.PROPERTIES_ID_DEFAULT, + Constants.DEFAULT_ID); + transferBufferSize = props.getInt( + Constants.PROPERTIES_TRANSFER_BUF_SIZE, + Constants.DEFAULT_TRANSFER_BUF_SIZE); + defaultServiceInterval = props.getInt( + Constants.PROPERTIES_SERVICE_INTERVAL, + Constants.DEFAULT_SERVICE_INTERVAL); - contentManagers.put(id, new Pair<Constructor, Configuration>( - implClass.getConstructor(String.class, String.class, - Configuration.class), conf)); + // Getting ids of defined content managers. + String[] ids = props.getStringArray(Constants.PROPERTIES_IDS); - // Executing the setup function. - try { - Method setupMethod = implClass.getMethod( - Constants.SETUP_FUNCTION, String.class, - Configuration.class); + for (String id : ids) { + try { + Configuration conf = props.subset(Tools.concatenateProperties( + Constants.PROPERTIES_PREFIX, id)); - setupMethod.invoke(implClass, id, conf); - } catch (NoSuchMethodException e) { - // No setup - doing nothing. - } + String implementation = conf + .getString(Constants.PROPERTIES_IMPL_SUFFIX); + Class implClass = Class.forName(implementation); - log - .info("Added content manager: " + id + ", " - + implementation); - } catch (Exception e) { - e.printStackTrace(); - log.warn("Error setting up content manager " + id + ".", e); - } - } + contentManagers.put(id, new Pair<Constructor, Configuration>( + implClass.getConstructor(String.class, String.class, + Configuration.class), conf)); - } + Set<String> implIds = implementationsIds.get(id); + if (implIds == null) { + implIds = new HashSet<String>(); + implementationsIds.put(id, implIds); + } - /** - * Gets a content manager with a default id and an empty prefix. - * - * @return A ""-prefixed, default content manager, or null, if a default - * content manager is not registered. - */ - public static ContentManager getContentManager() { - return getContentManager(""); - } + implIds.add(id); - /** - * Gets a content manager with a default id and the given prefix. - * - * @param prefix - * Prefix for the new content manager (all paths will have this - * prepended). - * @return A prefixed, default content manager, or null, if a default - * content manager is not registered. - */ - public static ContentManager getContentManager(String prefix) { - return getContentManager(defaultId, prefix); - } + log.info("Added content manager: " + id + ", " + + implementation); + } catch (Exception e) { + e.printStackTrace(); + log.warn("Error setting up content manager " + id + ".", e); + } + } - /** - * Gets a content manager with the given id and prefix. - * - * @param id - * Id of the content manager. - * @param prefix - * Prefix for the new content manager (all paths will have this - * prepended). - * @return A prefixed content manager with the given id or null, if a - * content manager with the given id registers. - */ - public static ContentManager getContentManager(String id, String prefix) { - if (isEmbedded()) { - // Calling setup - in case this is the first use. - setup(); - } + } - if (id == null) - id = defaultId; - if (prefix == null) - prefix = ""; - else - prefix = Tools.normalizeSlashes(prefix, true); + private synchronized static void initializeId(String id) { + if (!initializedIds.contains(id)) { + try { + Pair<Constructor, Configuration> cc = contentManagers.get(id); + Class implClass = cc.getFirst().getDeclaringClass(); - Pair<Constructor, Configuration> cmData = contentManagers.get(id); + // First initializing the whole implementation, if it hasn't + // been done yet. + initializeContentManager(implClass.getName()); - if (cmData == null) - return null; + // Executing the setup function. + try { + Method setupMethod = implClass.getMethod( + Constants.SETUP_FUNCTION, String.class, + Configuration.class); - try { - return (ContentManager) cmData.getFirst().newInstance(id, prefix, - cmData.getSecond()); - } catch (Throwable e) { - log.warn("Unable to get a content manager: (" + id + ", " + prefix - + ").", e); - return null; - } - } + setupMethod.invoke(implClass, id, cc.getSecond()); + } catch (NoSuchMethodException e) { + // No setup - doing nothing. + } - /* - * Properties accessors. - */ + log.info("Initialized content manager: " + id + ", " + + implClass.getName()); - /** - * Gets a property of this content manager, as it is written in the - * configuration file (helper method). - * - * @param name - * Name of the property to get. - * @return Value of the given property or null, if no such property exists. - */ - private static String getProperty(String name) { - return props.getString(name); - } + initializedIds.add(id); + } catch (Exception e) { + log.warn("Error initializing content manager: " + id + ".", e); + } + } + } - /** - * Gets a property of this content manager, as it is written in the - * configuration file (helper method for implementations). Only internal - * properties! (long parameter value). - * - * @param name - * Name of the property to get. - * @param defaultValue - * Value to return in case the given property is not set. - * @return Value of the given property or null, if no such property exists. - */ - public static long getProperty(String name, long defaultValue) { - if (name.startsWith(Constants.PROPERTIES_INTERNAL)) { - return props.getLong(name, defaultValue); - } else { - return defaultValue; - } - } + public synchronized static void initializeContentManager(String implementation) { + if (!initializedContentManagers.contains(implementation)) { + try { + Class implClass = Class.forName(implementation); - /** - * Gets a property of this content manager, as it is written in the - * configuration file (helper method for implementations). Only internal - * properties! (long parameter value). - * - * @param name - * Name of the property to get. - * @param defaultValue - * Value to return in case the given property is not set. - * @return Value of the given property or null, if no such property exists. - */ - public static int getProperty(String name, int defaultValue) { - if (name.startsWith(Constants.PROPERTIES_INTERNAL)) { - return props.getInt(name, defaultValue); - } else { - return defaultValue; - } - } + // Executing the setup function. + try { + Method setupMethod = implClass.getMethod(Constants.SETUP_FUNCTION); - /** - * Gets a property of this content manager, as it is written in the - * configuration file (helper method for implementations). Only internal - * properties! - * - * @param name - * Name of the property to get. - * @param defaultValue - * Value to return in case the given property is not set. - * @return Value of the given property or null, if no such property exists. - */ - public static String getProperty(String name, String defaultValue) { - if (name.startsWith(Constants.PROPERTIES_INTERNAL)) { - String ret = props.getString(name); - return ((ret == null) ? defaultValue : ret); - } else { - return defaultValue; - } - } + setupMethod.invoke(implClass); + } catch (NoSuchMethodException e) { + // No setup - doing nothing. + } - /** - * Gets the transfer buffer size. - * - * @return Transfer buffer size. - */ - public static int getTransferBufferSize() { - return transferBufferSize; - } + log.info("Initialized content manager implementation: " + implementation); - /** - * Gets the default Shotoku service interval. - * - * @return Default Shotoku service interval. - */ - public static int getDefaultServiceInterval() { - return defaultServiceInterval; - } + initializedContentManagers.add(implementation); + + // Initializing all ids. + Set<String> implIds = implementationsIds.get(implementation); + if (implIds != null) { + for (String id : implIds) { + initializeId(id); + } + } + } catch (Exception e) { + log.warn("Error initializing content manager implementation: " + + implementation + ".", e); + } + } + } + + + /** + * Gets a content manager with a default id and an empty prefix. + * + * @return A ""-prefixed, default content manager, or null, if a default + * content manager is not registered. + */ + public static ContentManager getContentManager() { + return getContentManager(""); + } + + /** + * Gets a content manager with a default id and the given prefix. + * + * @param prefix + * Prefix for the new content manager (all paths will have this + * prepended). + * @return A prefixed, default content manager, or null, if a default + * content manager is not registered. + */ + public static ContentManager getContentManager(String prefix) { + return getContentManager(defaultId, prefix); + } + + /** + * Gets a content manager with the given id and prefix. + * + * @param id + * Id of the content manager. + * @param prefix + * Prefix for the new content manager (all paths will have this + * prepended). + * @return A prefixed content manager with the given id or null, if a + * content manager with the given id registers. + */ + public static ContentManager getContentManager(String id, String prefix) { + if (isEmbedded()) { + // Calling setup - in case this is the first use. + setup(); + } + + if (id == null) + id = defaultId; + if (prefix == null) + prefix = ""; + else + prefix = Tools.normalizeSlashes(prefix, true); + + Pair<Constructor, Configuration> cmData = contentManagers.get(id); + + if (cmData == null) + return null; + + initializeId(id); + + try { + return (ContentManager) cmData.getFirst().newInstance(id, prefix, + cmData.getSecond()); + } catch (Throwable e) { + log.warn("Unable to get a content manager: (" + id + ", " + prefix + + ").", e); + return null; + } + } + + /* + * Properties accessors. + */ + + /** + * Gets a property of this content manager, as it is written in the + * configuration file (helper method). + * + * @param name + * Name of the property to get. + * @return Value of the given property or null, if no such property exists. + */ + private static String getProperty(String name) { + return props.getString(name); + } + + /** + * Gets a property of this content manager, as it is written in the + * configuration file (helper method for implementations). Only internal + * properties! (long parameter value). + * + * @param name + * Name of the property to get. + * @param defaultValue + * Value to return in case the given property is not set. + * @return Value of the given property or null, if no such property exists. + */ + public static long getProperty(String name, long defaultValue) { + if (name.startsWith(Constants.PROPERTIES_INTERNAL)) { + return props.getLong(name, defaultValue); + } else { + return defaultValue; + } + } + + /** + * Gets a property of this content manager, as it is written in the + * configuration file (helper method for implementations). Only internal + * properties! (long parameter value). + * + * @param name + * Name of the property to get. + * @param defaultValue + * Value to return in case the given property is not set. + * @return Value of the given property or null, if no such property exists. + */ + public static int getProperty(String name, int defaultValue) { + if (name.startsWith(Constants.PROPERTIES_INTERNAL)) { + return props.getInt(name, defaultValue); + } else { + return defaultValue; + } + } + + /** + * Gets a property of this content manager, as it is written in the + * configuration file (helper method for implementations). Only internal + * properties! + * + * @param name + * Name of the property to get. + * @param defaultValue + * Value to return in case the given property is not set. + * @return Value of the given property or null, if no such property exists. + */ + public static String getProperty(String name, String defaultValue) { + if (name.startsWith(Constants.PROPERTIES_INTERNAL)) { + String ret = props.getString(name); + return ((ret == null) ? defaultValue : ret); + } else { + return defaultValue; + } + } + + /** + * Gets the transfer buffer size. + * + * @return Transfer buffer size. + */ + public static int getTransferBufferSize() { + return transferBufferSize; + } + + /** + * Gets the default Shotoku service interval. + * + * @return Default Shotoku service interval. + */ + public static int getDefaultServiceInterval() { + return defaultServiceInterval; + } } Modified: labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/service/AdministratedService.java =================================================================== --- labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/service/AdministratedService.java 2006-04-19 21:14:44 UTC (rev 3812) +++ labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/service/AdministratedService.java 2006-04-19 21:20:01 UTC (rev 3813) @@ -1,10 +1,13 @@ package org.jboss.shotoku.service; +import java.util.Date; + /** * @author Adam Warski (ad...@as...) */ public interface AdministratedService { public long getLastUpdate(); + public Date getLastUpdateDate(); public void setLastUpdate(long lastUpdate); public boolean getServiceRunnable(); Modified: labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/service/AdministratedServiceGetter.java =================================================================== --- labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/service/AdministratedServiceGetter.java 2006-04-19 21:14:44 UTC (rev 3812) +++ labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/service/AdministratedServiceGetter.java 2006-04-19 21:20:01 UTC (rev 3813) @@ -4,5 +4,5 @@ * @author Adam Warski (ad...@as...) */ public interface AdministratedServiceGetter { - public AdministratedService get(); + public AdministratedService getService(); } Modified: labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/service/AdministratedServiceImpl.java =================================================================== --- labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/service/AdministratedServiceImpl.java 2006-04-19 21:14:44 UTC (rev 3812) +++ labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/service/AdministratedServiceImpl.java 2006-04-19 21:20:01 UTC (rev 3813) @@ -2,6 +2,8 @@ import org.apache.log4j.Logger; +import java.util.Date; + /** * @author Adam Warski (ad...@as...) */ @@ -16,6 +18,10 @@ return lastUpdate; } + public Date getLastUpdateDate() { + return new Date(getLastUpdate()); + } + public void setLastUpdate(long lastUpdate) { this.lastUpdate = lastUpdate; } Modified: labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/service/ShotokuServiceImpl.java =================================================================== --- labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/service/ShotokuServiceImpl.java 2006-04-19 21:14:44 UTC (rev 3812) +++ labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/service/ShotokuServiceImpl.java 2006-04-19 21:20:01 UTC (rev 3813) @@ -23,7 +23,6 @@ import javax.ejb.Local; -import org.jboss.annotation.ejb.Depends; import org.jboss.annotation.ejb.Management; import org.jboss.annotation.ejb.Service; import org.jboss.shotoku.ContentManager; @@ -46,34 +45,35 @@ @Service(objectName=Constants.SHOTOKU_SERVICE_NAME) @Local(ShotokuServiceLocal.class) @Management(ShotokuService.class) -@Depends(Constants.SVN_SERVICE_NAME) -public class ShotokuServiceImpl extends AdministratedServiceImpl implements ShotokuService, ShotokuServiceLocal { +public class ShotokuServiceImpl extends AdministratedServiceImpl + implements ShotokuService, ShotokuServiceLocal { Logger log = Logger.getLogger(ShotokuServiceImpl.class); /* - * Service-handling functions. - */ + * Service-handling functions. + */ public void create() throws Exception { super.create(); // Enabling administration for this service. - Tools.getService().addAdministratedService(new AdministratedServiceGetter() { - public AdministratedService get() { + addAdministratedService(new AdministratedServiceGetter() { + public AdministratedService getService() { return Tools.getService(); } }); + /* + * Setting up content managers. + */ + ContentManager.setup(); + log.info("Shotoku service created."); } public void start() throws Exception { super.start(); - /* - * Setting up content managers. - */ - ContentManager.setup(); log.info("ContentManager setup completed. Getting the default service timer interval..."); // Setting the default timer interval. Modified: labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/Constants.java =================================================================== --- labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/Constants.java 2006-04-19 21:14:44 UTC (rev 3812) +++ labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/Constants.java 2006-04-19 21:20:01 UTC (rev 3813) @@ -44,12 +44,6 @@ public static final String SETUP_FUNCTION = "setup"; - /** - * <code>SVN_SERVICE_NAME</code> - name under which the svn service is - * registered (if svn implementation is used). - */ - public final static String SVN_SERVICE_NAME = "shotoku:service=svn"; - /* * Default values */ Modified: labs/shotoku/trunk/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnContentManager.java =================================================================== --- labs/shotoku/trunk/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnContentManager.java 2006-04-19 21:14:44 UTC (rev 3812) +++ labs/shotoku/trunk/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnContentManager.java 2006-04-19 21:20:01 UTC (rev 3813) @@ -65,7 +65,7 @@ service.registerRepository(id, conf); } - static { + public static void setup() { service = SvnTools.getService(); service.setTimerInterval(ContentManager.getProperty( SvnTools.PROPERTY_INTERVAL, SvnTools.DEFAULT_TIMER_INTERVAL)); Modified: labs/shotoku/trunk/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnTools.java =================================================================== --- labs/shotoku/trunk/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnTools.java 2006-04-19 21:14:44 UTC (rev 3812) +++ labs/shotoku/trunk/shotoku-svn/src/java/org/jboss/shotoku/svn/SvnTools.java 2006-04-19 21:20:01 UTC (rev 3813) @@ -67,6 +67,12 @@ public static final String INTERNAL_PROP_CREATED = INTERNAL_PROP_PREFIX + "created"; /** + * <code>SVN_SERVICE_NAME</code> - name under which the svn service is + * registered. + */ + public final static String SVN_SERVICE_NAME = "shotoku:service=svn"; + + /** * Default interval length of the * timer. */ @@ -92,7 +98,7 @@ // Application server mode - creating a proxy to a mbean. instance = (SvnService) MBeanProxyExt.create( SvnService.class, - Constants.SVN_SERVICE_NAME, + SVN_SERVICE_NAME, MBeanServerLocator.locate()); } } Modified: labs/shotoku/trunk/shotoku-svn/src/java/org/jboss/shotoku/svn/service/SvnR... [truncated message content] |
Author: arvinder Date: 2006-04-19 17:14:44 -0400 (Wed, 19 Apr 2006) New Revision: 3812 Added: labs/jbossesb/branches/JBESB-13/ESBCore/etc/ labs/jbossesb/branches/JBESB-13/ESBCore/etc/server/ labs/jbossesb/branches/JBESB-13/ESBCore/etc/server/default/ labs/jbossesb/branches/JBESB-13/ESBCore/etc/server/default/config/ labs/jbossesb/branches/JBESB-13/ESBCore/etc/server/default/config/jboss-esb-core.xml labs/jbossesb/branches/JBESB-13/ESBCore/etc/server/default/config/jboss-esb-services.xml labs/jbossesb/branches/JBESB-13/ESBCore/etc/server/default/deploy/ labs/jbossesb/branches/JBESB-13/ESBCore/etc/server/default/deploy/jboss-service.xml labs/jbossesb/branches/JBESB-13/ESBCore/etc/xmdesc/ labs/jbossesb/branches/JBESB-13/ESBCore/etc/xmdesc/JBossESBServiceMBean-xmbean.xml Log: Initial version Added: labs/jbossesb/branches/JBESB-13/ESBCore/etc/server/default/config/jboss-esb-core.xml =================================================================== --- labs/jbossesb/branches/JBESB-13/ESBCore/etc/server/default/config/jboss-esb-core.xml 2006-04-19 21:13:40 UTC (rev 3811) +++ labs/jbossesb/branches/JBESB-13/ESBCore/etc/server/default/config/jboss-esb-core.xml 2006-04-19 21:14:44 UTC (rev 3812) @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd" + xmlns="urn:jboss:bean-deployer"> + + <!-- ================================================================== --> + <!-- R E G I S T R Y --> + <!-- ================================================================== --> + <!-- + <bean name="serviceRegistry" class="org.jboss.esb.core.registry.LocalServiceRegistry"> + <constructor factoryClass="org.jboss.esb.core.registry.ServiceRegistryFactory" factoryMethod="createLocal"/> + </bean> + --> + +</deployment> \ No newline at end of file Added: labs/jbossesb/branches/JBESB-13/ESBCore/etc/server/default/config/jboss-esb-services.xml =================================================================== --- labs/jbossesb/branches/JBESB-13/ESBCore/etc/server/default/config/jboss-esb-services.xml 2006-04-19 21:13:40 UTC (rev 3811) +++ labs/jbossesb/branches/JBESB-13/ESBCore/etc/server/default/config/jboss-esb-services.xml 2006-04-19 21:14:44 UTC (rev 3812) @@ -0,0 +1,69 @@ +<?xml version="1.0" encoding="UTF-8"?> +<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd" + xmlns="urn:jboss:bean-deployer"> + + <!-- ================================================================== --> + <!-- E S B S E R V I C E S / C O N T A I N E R S --> + <!-- ================================================================== --> + + <!-- ================================================================== --> + <!-- J B I Container --> + <!-- ================================================================== --> + + <!-- ================================================================== --> + <!-- S C A Container --> + <!-- ================================================================== --> + + <!-- ================================================================== --> + <!-- S E R V I C E Container --> + <!-- Bus (MoM) Service + A validation service + A transformation service + An enrichment service e.g Id generation + An Operate service e.g invoke and ejb, or jbpm + .. + See David Chappells Book on ESB ie VETRO / VETO Pattern + --> + <!-- ================================================================== --> + + <!-- ================================================================== --> + <!-- E X A M P L E B U S / C H A N N E L S --> + <!-- Depending on the different adapter implementations, set different + configuration. Perhaps this should be part of a service container + that starts up various buss adapters, the adapters in part are + endpoints, so if we want to dynamically deploy endpoints/adapters, + we need to start a deployer etc, etc, unless the microkernel does + this automatically etc. + --> + <!-- ================================================================== --> + <!-- + <bean name="asynchronousRequestBus" class="org.jboss.esb.core.service.bus.adapter.jms.JMSBusAdapter"> + <constructor factoryClass="org.jboss.esb.core.service.bus.BusServiceFactory" factoryMethod="createBusService"/> + <property name="jndiBinding">A</property> + </bean> + + <bean name="asynchronousResponseBus" class="org.jboss.esb.core.service.bus.adapter.jms.JMSBusAdapter"> + <constructor factoryClass="org.jboss.esb.core.service.bus.BusServiceFactory" factoryMethod="createBusService"/> + <property name="jndiBinding">B</property> + </bean> + + <bean name="ControlBus" class="org.jboss.esb.core.service.bus.adapter.jms.JMSBusAdapter"> + <constructor factoryClass="org.jboss.esb.core.service.bus.BusServiceFactory" factoryMethod="createBusService"/> + <property name="jndiBinding">C</property> + </bean> + + <bean name="ServiceEventBus" class="org.jboss.esb.core.service.bus.adapter.jms.JMSBusAdapter"> + <constructor factoryClass="org.jboss.esb.core.service.bus.BusServiceFactory" factoryMethod="createBusService"/> + <property name="jndiBinding">D</property> + </bean> + + <bean name="productOrdering" class="org.jboss.esb.core.service.bus.adapter.jms.JMSBusAdapter"> + <constructor factoryClass="org.jboss.esb.core.service.bus.BusServiceFactory" factoryMethod="createBusService"/> + <property name="jndiBinding">E</property> + </bean> + --> + + + +</deployment> \ No newline at end of file Added: labs/jbossesb/branches/JBESB-13/ESBCore/etc/server/default/deploy/jboss-service.xml =================================================================== --- labs/jbossesb/branches/JBESB-13/ESBCore/etc/server/default/deploy/jboss-service.xml 2006-04-19 21:13:40 UTC (rev 3811) +++ labs/jbossesb/branches/JBESB-13/ESBCore/etc/server/default/deploy/jboss-service.xml 2006-04-19 21:14:44 UTC (rev 3812) @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- + This current jboss-esb is simply an mbean wrapper onto our esb kernel which inturn + is built ontop of the new microkernel. Once the sar is removed, the bootstrap + will be done from the esb kernel directly. + $Id$ + --> + +<server> + + <mbean code="org.jboss.soa.esbcore.deploy.bootstrap.container.JBossESBServiceMBean" + name="jboss.esb:service=JBossESBServiceMBean" + xmbean-dd="xmdesc/JBossESBServiceMBean-xmbean.xml"> + </mbean> + +</server> \ No newline at end of file Added: labs/jbossesb/branches/JBESB-13/ESBCore/etc/xmdesc/JBossESBServiceMBean-xmbean.xml =================================================================== --- labs/jbossesb/branches/JBESB-13/ESBCore/etc/xmdesc/JBossESBServiceMBean-xmbean.xml 2006-04-19 21:13:40 UTC (rev 3811) +++ labs/jbossesb/branches/JBESB-13/ESBCore/etc/xmdesc/JBossESBServiceMBean-xmbean.xml 2006-04-19 21:14:44 UTC (rev 3812) @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="UTF-8"?> + <!DOCTYPE mbean PUBLIC + "-//JBoss//DTD JBOSS XMBEAN 1.2//EN" + "http://www.jboss.org/j2ee/dtd/jboss_xmbean_1_2.dtd"> + +<!-- $Id$ --> + +<mbean> + <description>A microcontainer kernel wrapper for JBoss ESB</description> + <class>org.jboss.soa.esbcore.deploy.bootstrap.container.JBossESBServiceMBean</class> + + <!-- Managed constructors --> + <constructor> + <name>JBossESBServiceMBean</name> + </constructor> + + <!-- Managed operations --> + <operation> + <description>JBoss Service lifecycle operation</description> + <name>start</name> + </operation> + + <operation> + <description>JBoss Service lifecycle operation</description> + <name>stop</name> + </operation> + + +</mbean> |
From: <jbo...@li...> - 2006-04-19 21:13:44
|
Author: arvinder Date: 2006-04-19 17:13:40 -0400 (Wed, 19 Apr 2006) New Revision: 3811 Added: labs/jbossesb/branches/JBESB-13/ESBCore/classes/org/jboss/soa/esbcore/deploy/bootstrap/container/JBossESBKernel.java labs/jbossesb/branches/JBESB-13/ESBCore/classes/org/jboss/soa/esbcore/deploy/bootstrap/container/JBossESBKernelConstants.java labs/jbossesb/branches/JBESB-13/ESBCore/classes/org/jboss/soa/esbcore/deploy/bootstrap/container/JBossESBServiceMBean.java Log: Initial version Added: labs/jbossesb/branches/JBESB-13/ESBCore/classes/org/jboss/soa/esbcore/deploy/bootstrap/container/JBossESBKernel.java =================================================================== --- labs/jbossesb/branches/JBESB-13/ESBCore/classes/org/jboss/soa/esbcore/deploy/bootstrap/container/JBossESBKernel.java 2006-04-19 21:08:57 UTC (rev 3810) +++ labs/jbossesb/branches/JBESB-13/ESBCore/classes/org/jboss/soa/esbcore/deploy/bootstrap/container/JBossESBKernel.java 2006-04-19 21:13:40 UTC (rev 3811) @@ -0,0 +1,202 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2006, JBoss Inc., and others contributors as indicated + * by the @authors tag. All rights reserved. + * See the copyright.txt in the distribution for a + * full listing of individual contributors. + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU Lesser General Public License, v. 2.1. + * This program is distributed in the hope that it will be useful, but WITHOUT A + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License, + * v.2.1 along with this distribution; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * (C) 2005-2006, + */ +package org.jboss.soa.esbcore.deploy.bootstrap.container; + +import org.jboss.kernel.plugins.deployment.xml.BeanXMLDeployer; +import org.jboss.kernel.plugins.bootstrap.basic.BasicBootstrap; +import org.jboss.kernel.spi.deployment.KernelDeployment; +import org.jboss.util.CollectionsFactory; + +import java.util.List; +import java.util.Enumeration; +import java.util.ListIterator; +import java.net.URL; + +/** + * This class follows a standard bootstrapping mechanism of the microkernel + * by first looking for the core configuration file called jboss-esb-core.xml + * and then jboss-esb-services.xml, both contain pojo deployments. + * + * @see org.jboss.kernel.plugins.bootstrap.standalone.StandaloneBootstrap + * + * @version <tt>$Revision$</tt> + * @author <a href="mailto:asi...@ho...">Arvinder Singh</a>. + */ +public class JBossESBKernel extends BasicBootstrap +{ + /** The deployer */ + protected BeanXMLDeployer deployer; + + /** The core deployments, ideally we want to separate + * this into core & services */ + protected List deployments = CollectionsFactory.createCopyOnWriteList(); + + /** The arguments */ + protected String[] args; + + /** + * Bootstrap the kernel from the command line + * + * @param args the command line arguments + * @throws Exception for any error + */ + public static void main(String[] args) throws Exception + { + JBossESBKernel bootstrap = new JBossESBKernel(args); + bootstrap.run(); + } + + /** + * Default class constructor. + * @throws Exception + */ + public JBossESBKernel() throws Exception + { + super(); + } + + /** + * Create a new bootstrap + * + * @param args the arguments + * @throws Exception for any error + */ + public JBossESBKernel(String[] args) throws Exception + { + super(); + this.args = args; + } + + /** + * Start the bootstrap process. + * @throws Throwable + */ + public void bootstrap() throws Throwable + { + super.bootstrap(); + + deployer = new BeanXMLDeployer(getKernel()); + + Runtime.getRuntime().addShutdownHook(new Shutdown(this)); + + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + + // + // Core + // + for (Enumeration e = cl.getResources(JBossESBKernelConstants.ESB_CORE_CONFIGURATION_DEPLOYMENT); e.hasMoreElements(); ) + { + URL url = (URL) e.nextElement(); + deploy(url); + } + // + // Core Services + // + for (Enumeration e = cl.getResources(JBossESBKernelConstants.ESB_SERVICE_CONFIGURATION_DEPLOYMENT); e.hasMoreElements(); ) + { + URL url = (URL) e.nextElement(); + deploy(url); + } + + // Validate that everything is ok + deployer.validate(); + } + + + /** + * Deploy a url, this may later separate into a deploy core then + * deploy services. + * + * @param url the deployment url + * @throws Throwable for any error + */ + protected void deploy(URL url) throws Throwable + { + log.info("Deploying " + url); + KernelDeployment deployment = deployer.deploy(url); + if(log.isTraceEnabled()) { + log.trace("KernelDeployment:BeanFactories=" + deployment.getBeanFactories()); + log.trace("KernelDeployment:Bean =" + deployment.getBeans()); + log.trace("KernelDeployment:ClassLoader =" + deployment.getClassLoader()); + log.trace("KernelDeployment:InstalledCtxs=" + deployment.getInstalledContexts()); + log.trace("KernelDeployment:Name =" + deployment.getName()); + } + deployments.add(deployment); + log.info("Deployed " + url); + } + + /** + * Undeploy a deployment + * + * @param deployment the deployment + */ + protected void undeploy(KernelDeployment deployment) + { + log.info("Undeploying " + deployment.getName()); + deployments.remove(deployment); + try + { + deployer.undeploy(deployment); + log.info("Undeployed " + deployment.getName()); + } + catch (Throwable t) + { + log.warn("Error during undeployment: " + deployment.getName(), t); + } + } + + /** + * Utility method used to undeploy and shutdown the kernel. + */ + protected void shutdown() { + log.info("Shutting down"); + // We should actually shut down services first so first deregister + // them from the registry and then shutdown core services like the + // registry. + ListIterator iterator = deployments.listIterator(deployments.size()); + while (iterator.hasPrevious()) + { + KernelDeployment deployment = (KernelDeployment) iterator.previous(); + undeploy(deployment); + } + } + + /** + * Bind this Hook into the runtime + */ + protected class Shutdown extends Thread + { + /** + * The kernel we are watching, ie us. + */ + private JBossESBKernel kernel = null; + + public Shutdown(JBossESBKernel watch) + { + this.kernel = watch; + } + + public void run() + { + log.info("Shutdown hook running"); + kernel.shutdown(); + } + } +} Added: labs/jbossesb/branches/JBESB-13/ESBCore/classes/org/jboss/soa/esbcore/deploy/bootstrap/container/JBossESBKernelConstants.java =================================================================== --- labs/jbossesb/branches/JBESB-13/ESBCore/classes/org/jboss/soa/esbcore/deploy/bootstrap/container/JBossESBKernelConstants.java 2006-04-19 21:08:57 UTC (rev 3810) +++ labs/jbossesb/branches/JBESB-13/ESBCore/classes/org/jboss/soa/esbcore/deploy/bootstrap/container/JBossESBKernelConstants.java 2006-04-19 21:13:40 UTC (rev 3811) @@ -0,0 +1,35 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2006, JBoss Inc., and others contributors as indicated + * by the @authors tag. All rights reserved. + * See the copyright.txt in the distribution for a + * full listing of individual contributors. + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU Lesser General Public License, v. 2.1. + * This program is distributed in the hope that it will be useful, but WITHOUT A + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License, + * v.2.1 along with this distribution; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * (C) 2005-2006, + */ +package org.jboss.soa.esbcore.deploy.bootstrap.container; + +/** + * An interface defining kernel level constants for the esb. + * + * @version <tt>$Revision$</tt> + * @author <a href="mailto:asi...@ho...">Arvinder Singh</a>. + */ +public interface JBossESBKernelConstants +{ + /** The core xml configuration file name */ + static final String ESB_CORE_CONFIGURATION_DEPLOYMENT = "jboss-esb-core.xml"; + + /** The services xml configuration file name */ + static final String ESB_SERVICE_CONFIGURATION_DEPLOYMENT = "jboss-esb-services.xml"; +} Added: labs/jbossesb/branches/JBESB-13/ESBCore/classes/org/jboss/soa/esbcore/deploy/bootstrap/container/JBossESBServiceMBean.java =================================================================== --- labs/jbossesb/branches/JBESB-13/ESBCore/classes/org/jboss/soa/esbcore/deploy/bootstrap/container/JBossESBServiceMBean.java 2006-04-19 21:08:57 UTC (rev 3810) +++ labs/jbossesb/branches/JBESB-13/ESBCore/classes/org/jboss/soa/esbcore/deploy/bootstrap/container/JBossESBServiceMBean.java 2006-04-19 21:13:40 UTC (rev 3811) @@ -0,0 +1,80 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2006, JBoss Inc., and others contributors as indicated + * by the @authors tag. All rights reserved. + * See the copyright.txt in the distribution for a + * full listing of individual contributors. + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU Lesser General Public License, v. 2.1. + * This program is distributed in the hope that it will be useful, but WITHOUT A + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License, + * v.2.1 along with this distribution; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * (C) 2005-2006, + */ +package org.jboss.soa.esbcore.deploy.bootstrap.container; + +import org.jboss.system.ServiceMBeanSupport; + +/** + * A JBoss ServiceMBean wrapper for the kernel bootstrap class. This will + * enable sar deployment for now, until a move to the pure pojo microkernel. + * See the <a href="http://wiki.jboss.org/wiki/Wiki.jsp?page=ServiceMBeanSupport"> + * wiki for more details</href> + * + * @see org.jboss.system.ServiceMBeanSupport + * + * @version <tt>$Revision$</tt> + * @author <a href="mailto:asi...@ho...">Arvinder Singh</a>. + */ +public class JBossESBServiceMBean extends ServiceMBeanSupport +{ + + /** The kernel we are wrapping **/ + private JBossESBKernel bootstrap = null; + + /** + * Default class constructor. + */ + public JBossESBServiceMBean() + { + super(); + } + + /** + * Override to start our kernel + * @throws Exception + */ + public synchronized void startService() throws Exception + { + log.info("Starting JBossESB."); + bootstrap = new JBossESBKernel(); + bootstrap.run(); + } + + /** + * Override to stop our kernel + * @throws Exception + */ + public void stopService() throws Exception + { + log.info("Stopping JBossESB."); + // undeploy all, deregister all services nicely. + bootstrap.shutdown(); + } + + /** + * Override to return our service name. + * @return String The name of this service. + */ + public String getName() + { + return "JBossESB Kernel MBean Service Wrapper"; + } + +} |
From: <jbo...@li...> - 2006-04-19 21:09:07
|
Author: mar...@jb... Date: 2006-04-19 17:08:57 -0400 (Wed, 19 Apr 2006) New Revision: 3810 Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/semantics/java/RuleBuilder.java Log: -conditional elements now build up from bottom upwards Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/semantics/java/RuleBuilder.java =================================================================== --- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/semantics/java/RuleBuilder.java 2006-04-19 21:00:50 UTC (rev 3809) +++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/semantics/java/RuleBuilder.java 2006-04-19 21:08:57 UTC (rev 3810) @@ -294,36 +294,36 @@ if ( object instanceof ConditionalElementDescr ) { if ( object instanceof AndDescr ) { And and = new And(); - ce.addChild( and ); build( rule, (ConditionalElementDescr) object, and, false, false); + ce.addChild( and ); } else if ( object instanceof OrDescr ) { Or or = new Or(); - ce.addChild( or ); build( rule, (ConditionalElementDescr) object, or, true, false); + ce.addChild( or ); } else if ( object instanceof NotDescr ) { Not not = new Not(); - ce.addChild( not ); build( rule, (ConditionalElementDescr) object, not, true, true); + ce.addChild( not ); } else if ( object instanceof ExistsDescr ) { Exists exists = new Exists(); - ce.addChild( exists ); build( rule, (ConditionalElementDescr) object, exists, true, true); + ce.addChild( exists ); } else if ( object instanceof EvalDescr ) { EvalCondition eval = build( (EvalDescr) object ); if ( eval != null ) { |
From: <jbo...@li...> - 2006-04-19 21:00:57
|
Author: tirelli Date: 2006-04-19 17:00:50 -0400 (Wed, 19 Apr 2006) New Revision: 3809 Modified: labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/test_FunctionInConsequence.drl Log: Adding test case for ticket JBRULES-226 Modified: labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/test_FunctionInConsequence.drl =================================================================== --- labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/test_FunctionInConsequence.drl 2006-04-19 20:58:25 UTC (rev 3808) +++ labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/test_FunctionInConsequence.drl 2006-04-19 21:00:50 UTC (rev 3809) @@ -15,4 +15,6 @@ Cheese( ) then addFive( list ); + // Calling methods does not mess with function calls + String tmp = list.toString(); end \ No newline at end of file |
From: <jbo...@li...> - 2006-04-19 20:58:28
|
Author: mar...@jb... Date: 2006-04-19 16:58:25 -0400 (Wed, 19 Apr 2006) New Revision: 3808 Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/ReteooMannersTest.java Log: -Left in the comments that help with debugging. Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/ReteooMannersTest.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/ReteooMannersTest.java 2006-04-19 20:58:16 UTC (rev 3807) +++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/examples/manners/ReteooMannersTest.java 2006-04-19 20:58:25 UTC (rev 3808) @@ -53,30 +53,30 @@ ruleBase.addPackage( this.pkg ); WorkingMemory workingMemory = ruleBase.newWorkingMemory(); - workingMemory.addEventListener( new DefaultAgendaEventListener() { - public void activationCreated(ActivationCreatedEvent event) { - super.activationCreated( event ); - System.out.println( event ); - } - - public void activationCancelled(ActivationCancelledEvent event) { - super.activationCancelled( event ); - System.out.println( event ); - } - - public void beforeActivationFired(BeforeActivationFiredEvent event) { - super.beforeActivationFired( event ); - System.out.println( event ); - } - - public void afterActivationFired(AfterActivationFiredEvent event) { - super.afterActivationFired( event ); - System.out.println( event ); - } - - }); +// workingMemory.addEventListener( new DefaultAgendaEventListener() { +// public void activationCreated(ActivationCreatedEvent event) { +// super.activationCreated( event ); +// System.out.println( event ); +// } +// +// public void activationCancelled(ActivationCancelledEvent event) { +// super.activationCancelled( event ); +// System.out.println( event ); +// } +// +// public void beforeActivationFired(BeforeActivationFiredEvent event) { +// super.beforeActivationFired( event ); +// System.out.println( event ); +// } +// +// public void afterActivationFired(AfterActivationFiredEvent event) { +// super.afterActivationFired( event ); +// System.out.println( event ); +// } +// +// }); - InputStream is = getClass().getResourceAsStream( "/manners5.dat" ); + InputStream is = getClass().getResourceAsStream( "/manners64.dat" ); List list = getInputObjects( is ); for ( Iterator it = list.iterator(); it.hasNext(); ) { Object object = it.next(); |
From: <jbo...@li...> - 2006-04-19 20:58:22
|
Author: tirelli Date: 2006-04-19 16:58:16 -0400 (Wed, 19 Apr 2006) New Revision: 3807 Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/semantics/java/FunctionFixer.java Log: JBRULES-226: fixing ticket Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/semantics/java/FunctionFixer.java =================================================================== --- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/semantics/java/FunctionFixer.java 2006-04-19 20:52:43 UTC (rev 3806) +++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/semantics/java/FunctionFixer.java 2006-04-19 20:58:16 UTC (rev 3807) @@ -22,7 +22,7 @@ public class FunctionFixer { - static Pattern FUNCTION = Pattern.compile("(.*)\\b([^.][\\S]+)\\s*\\(([^)]*)\\)(.*)", Pattern.DOTALL); + static Pattern FUNCTION = Pattern.compile("(\\S*\\s*|\\.\\s*)\\b([\\S&&[^\\.]]+)\\s*\\(([^)]*)\\)", Pattern.DOTALL); public String fix(String raw) { //return raw; @@ -31,34 +31,32 @@ public String fix(String raw, Pattern pattern) { if (raw == null) return null; + StringBuffer buf = new StringBuffer(); + int lastIndex = 0; + Matcher matcher = pattern.matcher(raw); - if (matcher.matches()) { + while(matcher.find()) { String pre = matcher.group(1); if (matcher.group(1) != null) { String trimmedPre = pre.trim(); if (trimmedPre.endsWith( "." ) || trimmedPre.endsWith( "new" )) { //leave alone - return raw; - } else { - //recurse - pre = fix(pre, pattern); - } - //pre = fix(pre, pattern); + continue; + } } - String function = matcher.group(2).trim(); String params = matcher.group(3).trim(); - String post = matcher.group(4); - if (post != null) { - post = fix(post); - } String target = ucFirst(function) + "." + function + "(" + params + ")"; - return pre + matcher.replaceAll( KnowledgeHelperFixer.replace( target, "$", "\\$", 128 )) + post; + + buf.append( raw.substring( lastIndex, matcher.start( 2 ) ) ); + buf.append( KnowledgeHelperFixer.replace( target, "$", "\\$", 128 ) ); + lastIndex = matcher.end(); } - return raw; + buf.append( raw.substring( lastIndex ) ); + return buf.toString(); } private String ucFirst(String name) { |
From: <jbo...@li...> - 2006-04-19 20:52:50
|
Author: mar...@jb... Date: 2006-04-19 16:52:43 -0400 (Wed, 19 Apr 2006) New Revision: 3806 Removed: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/rule/InstrumentedRule.java Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/GroupElement.java labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/LogicTransformer.java Log: -GroupElement now removes redundant conditional elements, this is part of the rework work that will take place in 3.1 Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/GroupElement.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/GroupElement.java 2006-04-19 20:36:39 UTC (rev 3805) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/GroupElement.java 2006-04-19 20:52:43 UTC (rev 3806) @@ -35,6 +35,24 @@ * @param child */ public void addChild(Object child) { + // @todo : I've commented this out for 3.0, but we want this working for 3.1 +// if ( child instanceof Not ) { +// Not not = ( Not ) child; +// Object notChild = not.getChild(); +// if ( notChild instanceof Or ) { +// Or or = (Or) notChild; +// And and = new And(); +// for ( Iterator it = or.getChildren().iterator(); it.hasNext(); ) { +// Not newNot = new Not(); +// newNot.addChild( it.next() ); +// and.addChild( newNot ); +// } +// child = and; +// } else if ( notChild instanceof And ) { +// +// } +// } + if ( child instanceof GroupElement && ( child instanceof And || child instanceof Or ) ) { GroupElement group = ( GroupElement ) child; Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/LogicTransformer.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/LogicTransformer.java 2006-04-19 20:36:39 UTC (rev 3805) +++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/LogicTransformer.java 2006-04-19 20:52:43 UTC (rev 3806) @@ -1,4 +1,5 @@ package org.drools.rule; + /* * Copyright 2005 JBoss Inc * @@ -15,8 +16,6 @@ * limitations under the License. */ - - import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -224,12 +223,16 @@ parent.getChildren().addAll( newChildren ); } + void checkForAndRemoveSingleBranch(GroupElement parent) { + + } + GroupElement applyOrTransformation(GroupElement parent, GroupElement child) throws InvalidPatternException { - OrTransformation transformation = null; + Transformation transformation = null; Map map = (HashMap) this.orTransformations.get( parent.getClass() ); if ( map != null ) { - transformation = (OrTransformation) map.get( child.getClass() ); + transformation = (Transformation) map.get( child.getClass() ); } if ( transformation == null ) { @@ -239,7 +242,7 @@ return transformation.transform( parent ); } - interface OrTransformation { + interface Transformation { GroupElement transform(GroupElement element) throws InvalidPatternException; } @@ -272,7 +275,7 @@ */ class AndOrTransformation implements - OrTransformation { + Transformation { public GroupElement transform(GroupElement and) throws InvalidPatternException { Or or = new Or(); @@ -388,25 +391,26 @@ */ class ExistOrTransformation implements - OrTransformation { + Transformation { public GroupElement transform(GroupElement exist) throws InvalidPatternException { - if ( !(exist.getChildren().get( 0 ) instanceof Or) ) { - throw new RuntimeException( "ExistOrTransformation expected '" + Or.class.getName() + "' but instead found '" + exist.getChildren().get( 0 ).getClass().getName() + "'" ); - } - - /* - * we know a Not only ever has one child, and the previous algorithm - * has confirmed the child is an OR - */ - Or or = (Or) exist.getChildren().get( 0 ); - And and = new And(); - for ( Iterator it = or.getChildren().iterator(); it.hasNext(); ) { - Exists newExist = new Exists(); - newExist.addChild( it.next() ); - and.addChild( newExist ); - } - return and; + throw new InvalidPatternException( "You cannot nest an OR within an Exists" ); +// if ( !(exist.getChildren().get( 0 ) instanceof Or) ) { +// throw new RuntimeException( "ExistOrTransformation expected '" + Or.class.getName() + "' but instead found '" + exist.getChildren().get( 0 ).getClass().getName() + "'" ); +// } +// +// /* +// * we know a Not only ever has one child, and the previous algorithm +// * has confirmed the child is an OR +// */ +// Or or = (Or) exist.getChildren().get( 0 ); +// And and = new And(); +// for ( Iterator it = or.getChildren().iterator(); it.hasNext(); ) { +// Exists newExist = new Exists(); +// newExist.addChild( it.next() ); +// and.addChild( newExist ); +// } +// return and; } } @@ -433,26 +437,62 @@ */ public class NotOrTransformation implements - OrTransformation { + Transformation { public GroupElement transform(GroupElement not) throws InvalidPatternException { - if ( !(not.getChildren().get( 0 ) instanceof Or) ) { - throw new RuntimeException( "NotOrTransformation expected '" + Or.class.getName() + "' but instead found '" + not.getChildren().get( 0 ).getClass().getName() + "'" ); - } - /* - * we know a Not only ever has one child, and the previous algorithm - * has confirmed the child is an OR - */ - Or or = (Or) not.getChildren().get( 0 ); - And and = new And(); - for ( Iterator it = or.getChildren().iterator(); it.hasNext(); ) { - Not newNot = new Not(); - newNot.addChild( it.next() ); - and.addChild( newNot ); - } - return and; + throw new InvalidPatternException( "You cannot nest an OR within an Not" ); + // @todo for 3.1 +// if ( !(not.getChildren().get( 0 ) instanceof Or) ) { +// throw new RuntimeException( "NotOrTransformation expected '" + Or.class.getName() + "' but instead found '" + not.getChildren().get( 0 ).getClass().getName() + "'" ); +// } +// +// /* +// * we know a Not only ever has one child, and the previous algorithm +// * has confirmed the child is an OR +// */ +// Or or = (Or) not.getChildren().get( 0 ); +// And and = new And(); +// for ( Iterator it = or.getChildren().iterator(); it.hasNext(); ) { +// Not newNot = new Not(); +// newNot.addChild( it.next() ); +// and.addChild( newNot ); +// } +// return and; } } + //@todo for 3.1 +// public class NotAndTransformation +// implements +// Transformation { +// +// public GroupElement transform(GroupElement not) throws InvalidPatternException { +// if ( !(not.getChildren().get( 0 ) instanceof And) ) { +// throw new RuntimeException( "NotAndTransformation expected '" + And.class.getName() + "' but instead found '" + not.getChildren().get( 0 ).getClass().getName() + "'" ); +// } +// +// /* +// * we know a Not only ever has one child, and the previous algorithm +// * has confirmed the child is an And +// */ +// And and = (And) not.getChildren().get( 0 ); +// for ( Iterator it = and.getChildren().iterator(); it.hasNext(); ) { +// Object object1 = it.next(); +// +// for ( Iterator it2 = and.getChildren().iterator(); it.hasNext(); ) { +// Object object2 = it.next(); +// if ( object2 != object1 ) { +// +// } +// } +// +// Not newNot = new Not(); +// newNot.addChild( it.next() ); +// and.addChild( newNot ); +// } +// +// return and; +// } +// } } \ No newline at end of file Deleted: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/rule/InstrumentedRule.java =================================================================== --- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/rule/InstrumentedRule.java 2006-04-19 20:36:39 UTC (rev 3805) +++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/rule/InstrumentedRule.java 2006-04-19 20:52:43 UTC (rev 3806) @@ -1,45 +0,0 @@ -package org.drools.rule; -/* - * Copyright 2005 JBoss Inc - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - - - - -public class InstrumentedRule extends Rule { - public Boolean isValid; - - public InstrumentedRule(String name) { - super( name ); - } - - public void isValid(boolean isValid) { - if ( isValid ) { - this.isValid = Boolean.TRUE; - } else { - this.isValid = Boolean.FALSE; - } - } - - public boolean isValid() { - if ( this.isValid == null ) { - return super.isValid(); - } - - return this.isValid.booleanValue(); - } - -} \ No newline at end of file |
From: <jbo...@li...> - 2006-04-19 20:36:47
|
Author: arvinder Date: 2006-04-19 16:36:39 -0400 (Wed, 19 Apr 2006) New Revision: 3805 Added: labs/jbossesb/branches/JBESB-13/ Log: Created branch for jira task ref JBESB-13 Copied: labs/jbossesb/branches/JBESB-13 (from rev 3803, labs/jbossesb/trunk) |
From: <jbo...@li...> - 2006-04-19 20:24:27
|
Author: dam...@jb... Date: 2006-04-19 16:24:23 -0400 (Wed, 19 Apr 2006) New Revision: 3804 Removed: labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/FeedsPortlet.java Modified: labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/FeedsCache.java labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/FeedsDescriptor.java Log: Removed portal and forge dependencies. Modified: labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/FeedsCache.java =================================================================== --- labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/FeedsCache.java 2006-04-19 19:45:21 UTC (rev 3803) +++ labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/FeedsCache.java 2006-04-19 20:24:23 UTC (rev 3804) @@ -25,8 +25,8 @@ import org.jboss.shotoku.cache.ShotokuCacheItem; public class FeedsCache extends ShotokuCacheItem<Pair<String, String>, FeedsDescriptor> { - private FeedsDescriptor getDesc(String portalName, String baseServerAddress) { - return new FeedsDescriptor(portalName, baseServerAddress); + private FeedsDescriptor getDesc(String baseServerAddress) { + return new FeedsDescriptor(baseServerAddress); } public void update(Pair<String, String> key, FeedsDescriptor currentObject) { Modified: labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/FeedsDescriptor.java =================================================================== --- labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/FeedsDescriptor.java 2006-04-19 19:45:21 UTC (rev 3803) +++ labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/FeedsDescriptor.java 2006-04-19 20:24:23 UTC (rev 3804) @@ -42,12 +42,10 @@ import org.apache.velocity.VelocityContext; import org.apache.xerces.parsers.DOMParser; -import org.jboss.forge.common.ForgeHelper; -import org.jboss.forge.common.XmlTools; -import org.jboss.forge.common.projects.ProjectsHelper; -import org.jboss.forge.common.projects.permissions.NullPermissionsChecker; +import org.jboss.shotoku.feeds.FeedsHelper; +import org.jboss.shotoku.tools.XmlTools; +import org.jboss.shotoku.feeds.SiteHelper; import org.jboss.logging.Logger; -import org.jboss.portal.common.context.DelegateContext; import org.jboss.shotoku.ContentManager; import org.jboss.shotoku.tools.Pair; import org.jboss.shotoku.aop.CacheItem; @@ -63,6 +61,7 @@ * provides access to them. * * @author adamw + * @author da...@si... */ public class FeedsDescriptor { private static final Logger log = Logger.getLogger(FeedsDescriptor.class); @@ -71,7 +70,7 @@ * <code>FEEDS_DIRECTORY</code> - shotoku directory in which feed * definitions are stored. */ - protected final static String FEEDS_DIRECTORY = "feeds"; + protected final static String FEEDS_DIRECTORY = "descriptors"; /** * <code>FEEDS_NODE_ENDING</code> - node with names ending with this @@ -93,18 +92,19 @@ private final static String TYPE_PARAM = "${type}"; - private final static String PROJECT_PARAM = "${project}"; + private final static String SITE_PARAM = "${site}"; - private final static String PROJECT_NAME_PARAM = "${project-name}"; + private final static String SITE_NAME_PARAM = "${site-name}"; + + private final static String FEEDS_BASEDIR = "shotoku.feeds.basedir"; - protected final static String FEEDS_FILE_PREFIX = "forge-feeds"; + protected final static String FEEDS_FILE_PREFIX = "shotoku-feeds"; @CacheItem private static FeedsCache feedsCache; - static synchronized FeedsDescriptor getInstance(final String portalName, - final String baseServerAddress) { - return feedsCache.get(new Pair<String, String>(portalName, baseServerAddress)); + static synchronized FeedsDescriptor getInstance(final String baseServerAddress) { + return feedsCache.get(baseServerAddress); } /** @@ -128,10 +128,17 @@ private String baseServerAddress; - public FeedsDescriptor(String portalName, String baseServerAddress) { + public FeedsDescriptor(String baseServerAddress) { this.baseServerAddress = baseServerAddress; + String feedsBaseDir = ContentManager.getProperty(FEEDS_BASEDIR); - ContentManager cm = ContentManager.getContentManager(portalName + "/" + if (feedsBaseDir == null) + throw new RuntimeException(FEEDS_BASEDIR" property missing from "+ + "shotoku.properties. Shotoku feeds needs"+ + " this to know where to load the feeds "+ + "descriptor files."); + + ContentManager cm = ContentManager.getContentManager(feedsBaseDir+"/" + FEEDS_DIRECTORY); // Creating the maps that will hold the feeds. @@ -156,7 +163,7 @@ .toList()) { if (feedNode.getName().endsWith(FEEDS_NODE_ENDING)) { try { - addFeedDefinitions(portalName, allFeedDefs, feedNode); + addFeedDefinitions(allFeedDefs, feedNode); } catch (Exception e) { // We just don't add the feeds ... but log a warning. log.warn("Can't add feed definitions.", e); @@ -165,7 +172,7 @@ } // Firstly - the remote feeds. - generateRemoteFeeds(portalName, remoteFeedDefs); + generateRemoteFeeds(remoteFeedDefs); // Then, shotoku feeds - first loading the properties - directive classes. Properties props = new Properties(); @@ -175,10 +182,10 @@ log.warn("Error loading shotoku feeds configuration.", e); } - generateShotokuFeeds(portalName, shotokuFeedDefs, props); + generateShotokuFeeds(shotokuFeedDefs, props); // After that, we can create the aggregated feeds. - generateAggregatedFeeds(portalName, aggregatedFeedDefs); + generateAggregatedFeeds(aggregatedFeedDefs); // Finally, filling the context. fillContext(); @@ -201,30 +208,22 @@ } /** - * Gets an array of ids of projects basing on the given project level attribute - * (the level can be a *). - * @param portalName - * @param projectLevelAttr - * @return An array of project ids that are on the specified level. + * Gets an array of ids of Sites + * @return An array of site ids for this shotoku feeds instance. */ - private String[] getProjectsIds(String portalName, String projectLevelAttr) { - if (projectLevelAttr != null) { - return ProjectsHelper.getProjects(portalName).getProjectIds( - new NullPermissionsChecker(), - ALL_TOKENS.equals(projectLevelAttr) ? null - : projectLevelAttr).toArray(new String[0]); - } else { + private String[] getSiteIds() { + if (FeedsHelper.getSiteIds() != null) { + return FeedsHelper.getSiteIds(); + else return new String[] { "" }; - } } /** - * @param portalName - * @param projectId - * @return Name of a project with the given id. + * @param siteId + * @return Name of a site with the given id. */ - private String getProjectName(String portalName, String projectId) { - return ProjectsHelper.getProjects(portalName).getProjectName(projectId); + private String getSiteName(String siteId) { + return FeedsHelper.getSiteName(siteId); } /** @@ -264,8 +263,6 @@ * @param props Properties with directives classes. * @param parametrized Set of directive names that accept a parameter map * in their constructor. - * @param portalName - * @param projectId * @return A search parameter that is described in the given node. * @throws IllegalArgumentException * @throws SecurityException @@ -276,7 +273,7 @@ * @throws ClassNotFoundException */ private SearchParameter generateSearchParameter(Node n, Properties props, - Set<String> parametrized, String portalName, String projectId) + Set<String> parametrized, String siteId) throws IllegalArgumentException, SecurityException, InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, @@ -294,13 +291,13 @@ if (parametrized.contains(paramName)) { // Instatiating the class, it should have a constructor accepting a // map. We take the map from node attributes, and replace - // ${project} and ${project-name} in them. + // ${site} and ${site-name} in them. param = (SearchParameter) Class.forName(paramClass).getConstructor( new Class[] { Map.class }).newInstance( new Object[] { replaceInMapValues(replaceInMapValues( XmlTools.getMapFromNodeAttributes(n), - PROJECT_PARAM, projectId), PROJECT_NAME_PARAM, - getProjectName(portalName, projectId)) }); + SITE_PARAM, siteId), SITE_NAME_PARAM, + getSiteName(siteId)) }); } else { param = (SearchParameter) Class.forName(paramClass).newInstance(); } @@ -315,7 +312,7 @@ // Invoking the function recursively and adding the // resulting parameter. SearchParameter childParam = generateSearchParameter(child, - props, parametrized, portalName, projectId); + props, parametrized, siteId); Method[] methods = param.getClass().getMethods(); for (Method method : methods) { @@ -332,8 +329,8 @@ private final static String RFC_822_DATE = "EEE, d MMM yyyy HH:mm:ss Z"; - private void generateShotokuFeeds(String portalName, - Map<String, Node> feedDefs, Properties props) { + private void generateShotokuFeeds(Map<String, Node> feedDefs, + Properties props) { Set<String> parametrized = new HashSet<String>(Arrays.asList(props.getProperty( "parametrized").split("[,]"))); @@ -344,8 +341,6 @@ String prefixAttr = XmlTools.getAttributeValue(feedNode, "prefix"); String idAttr = XmlTools.getAttributeValue(feedNode, "id"); String typesAttr = XmlTools.getAttributeValue(feedNode, "type"); - String projectLevelAttr = XmlTools.getAttributeValue(feedNode, - "project-level"); String displayNameAttr = XmlTools.getAttributeValue(feedNode, "display-name"); @@ -355,9 +350,9 @@ // Generating the type of feeds that have been requested. String[] types = getTypes(typesAttr); - // Generating the projects for which the feeds have been requested, + // Generating the sites for which the feeds have been requested, // if any. - String[] projects = getProjectsIds(portalName, projectLevelAttr); + String[] siteIds = getSiteIds(); Map<String, String> attributes = XmlTools .getMapFromNodeAttributes(feedNode); @@ -375,9 +370,9 @@ vc.put("baseServerAddress", baseServerAddress); vc.put("escape", new TextEscaping()); - for (String project : projects) { - String feedNameReplaced = feedName.replace(PROJECT_PARAM, - project); + for (String site : siteIds) { + String feedNameReplaced = feedName.replace(SITE_PARAM, + site); NodeList feedNodeChildren = feedNode.getChildNodes(); for (int i = 0; i < feedNodeChildren.getLength(); i++) { @@ -388,8 +383,7 @@ if ("search".equals(searchNode.getNodeName())) { try { Search search = (Search) generateSearchParameter( - searchNode, props, parametrized, - portalName, project); + searchNode, props, parametrized, site); org.jboss.shotoku.NodeList list = cm.search(search); @@ -415,7 +409,7 @@ vc.put("link", generateFeedLink(true, feedNameReplaced, type)); - // Now that we have type and project, we can render the + // Now that we have type and site, we can render the // template. Writer w = newFeed.getWriter(); cm.getVelocityEngine().mergeTemplate(template, vc, w); @@ -431,17 +425,16 @@ } } - // Finally, adding a feed name. We have to replace ${project} - // and ${project-name} in it. + // Finally, adding a feed name. We have to replace ${site} + // and ${site-name} in it. feedDisplayNames.put(feedNameReplaced, displayNameAttr.replace( - PROJECT_PARAM, project).replace(PROJECT_NAME_PARAM, - getProjectName(portalName, project))); + SITE_PARAM, site).replace(SITE_NAME_PARAM, + getSiteName(site))); } } } - private void generateRemoteFeeds(String portalName, - Map<String, Node> feedDefs) { + private void generateRemoteFeeds(Map<String, Node> feedDefs) { for (String feedName : feedDefs.keySet()) { Node feedNode = feedDefs.get(feedName); String addressAttr = XmlTools @@ -449,25 +442,23 @@ String typesAttr = XmlTools.getAttributeValue(feedNode, "type"); String displayNameAttr = XmlTools.getAttributeValue(feedNode, "display-name"); - String projectLevelAttr = XmlTools.getAttributeValue(feedNode, - "project-level"); // Generating the type of feeds that have been requested. String[] types = getTypes(typesAttr); - // Generating the projects for which the feeds have been requested, + // Generating the sites for which the feeds have been requested, // if any. - String[] projects = getProjectsIds(portalName, projectLevelAttr); + String[] sites = getSiteIds(); - // For each type, project pair, generating a feed and storing it in + // For each type, site pair generating a feed and storing it in // the feeds map. - for (String project : projects) { - String feedNameReplaced = feedName.replace(PROJECT_PARAM, - project); + for (String siteId : siteIds) { + String feedNameReplaced = feedName.replace(SITE_PARAM, + siteId); for (String type : types) { String address = addressAttr.replace(TYPE_PARAM, type) - .replace(PROJECT_PARAM, project); + .replace(SITE_PARAM, siteId); try { Feed newFeed = FeedFactory.getNewFeed(type); @@ -479,17 +470,16 @@ } } - // Adding a feed name. We have to replace ${project} - // and ${project-name} in it. + // Adding a feed name. We have to replace ${site} + // and ${site-name} in it. feedDisplayNames.put(feedNameReplaced, displayNameAttr.replace( - PROJECT_PARAM, project).replace(PROJECT_NAME_PARAM, - getProjectName(portalName, project))); + SITE_PARAM, siteId).replace(SITE_NAME_PARAM, + getSiteName(siteId))); } } } - private void generateAggregatedFeeds(String portalName, - Map<String, Node> feedDefs) { + private void generateAggregatedFeeds(Map<String, Node> feedDefs) { // First building requirements of each feed - that is, whit which // feeds each aggregated feed is built. Map<String, Set<String>> requirements = @@ -517,15 +507,12 @@ n = nodes.item(i); if ("include".equals(n.getNodeName())) { String nameAttr = XmlTools.getAttributeValue(n, "name"); - String projectLevelAttr = XmlTools.getAttributeValue(n, - "project-level"); - String[] projects = getProjectsIds(portalName, - projectLevelAttr); + String[] siteIds = getSiteIds(); - for (String project : projects) { - feedRequirements.add(nameAttr.replace(PROJECT_PARAM, - project)); + for (String siteId : siteIds) { + feedRequirements.add(nameAttr.replace(SITE_PARAM, + siteId)); } } } @@ -657,35 +644,30 @@ /** * To the given feed group, adds feeds names that are defined by the given * node and feed name (this can be more then one, as we can have iteration - * over many projects). - * @param portalName + * over many sites). * @param feedGroup * @param feedName * @param node */ - private void addFeedNamesToGroup(String portalName, Set<String> feedGroup, + private void addFeedNamesToGroup(Set<String> feedGroup, String feedName, Node node) { - String projectLevelAttr = XmlTools.getAttributeValue(node, - "project-level"); - String[] projects = getProjectsIds(portalName, projectLevelAttr); + String[] siteIds = getSiteIds(); - for (String project : projects) { - feedGroup.add(feedName.replace(PROJECT_PARAM, project)); + for (String siteId : siteIds) { + feedGroup.add(feedName.replace(SITE_PARAM, siteId)); } } /** * Adds definitions of feeds to the given map, placing child nodes of * the given node in the appropriate map. - * @param portalName * @param feedDefinitions * @param node * @throws SAXException * @throws IOException */ - private void addFeedDefinitions(String portalName, - Map<String, Map<String, Node>> feedDefinitions, + private void addFeedDefinitions(Map<String, Map<String, Node>> feedDefinitions, org.jboss.shotoku.Node node) throws SAXException, IOException { DOMParser parser = new DOMParser(); parser.parse(new InputSource(node.getContentInputStream())); @@ -702,7 +684,7 @@ n = nodes.item(i); if (feedDefinitions.get(n.getNodeName()) != null) { String feedName = XmlTools.getAttributeValue(n, "name"); - addFeedNamesToGroup(portalName, feedGroup, feedName, n); + addFeedNamesToGroup(feedGroup, feedName, n); feedDefinitions.get(n.getNodeName()).put(feedName, n); } } Deleted: labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/FeedsPortlet.java =================================================================== --- labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/FeedsPortlet.java 2006-04-19 19:45:21 UTC (rev 3803) +++ labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/FeedsPortlet.java 2006-04-19 20:24:23 UTC (rev 3804) @@ -1,63 +0,0 @@ -/* - * JBoss, Home of Professional Open Source - * Copyright 2005, JBoss Inc., and individual contributors as indicated - * by the @authors tag. See the copyright.txt in the distribution for a - * full listing of individual contributors. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.jboss.shotoku.feeds; - -import java.io.IOException; - -import javax.portlet.PortletException; -import javax.portlet.PortletRequestDispatcher; -import javax.portlet.PortletSecurityException; - -import org.jboss.forge.common.ForgeHelper; -import org.jboss.forge.common.projects.ProjectsHelper; -import org.jboss.portal.common.context.DelegateContext; -import org.jboss.portal.core.servlet.jsp.PortalJsp; -import org.jboss.portlet.JBossPortlet; -import org.jboss.portlet.JBossRenderRequest; -import org.jboss.portlet.JBossRenderResponse; - -public class FeedsPortlet extends JBossPortlet { - private final static String FEEDS_JSP = "feeds.jsp"; - - @Override - protected void doView(JBossRenderRequest request, JBossRenderResponse response) - throws PortletException, PortletSecurityException, IOException { - response.setContentType("text/html"); - - String portalName = ForgeHelper.getPortalName(request); - ProjectsHelper.prepareRequest(request); - - // Getting the feeds context. - DelegateContext feedsContext = FeedsDescriptor.getInstance(portalName, - ForgeHelper.getBaseServerAddress(request)) - .getContext(); - - // Displaying. - request.setAttribute(PortalJsp.CTX_REQUEST, feedsContext); - - PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher( - ForgeHelper.createRepoAccessPath(portalName, - FeedsDescriptor.FEEDS_DIRECTORY + '/' + FEEDS_JSP)); - rd.include(request, response); - } - -} |
From: <jbo...@li...> - 2006-04-19 19:45:25
|
Author: dam...@jb... Date: 2006-04-19 15:45:21 -0400 (Wed, 19 Apr 2006) New Revision: 3803 Modified: labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/DomToXmlTransformer.java labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/PropertiesMap.java labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/XmlTools.java Log: Changing package names to shotoku.tools. Modified: labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/DomToXmlTransformer.java =================================================================== --- labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/DomToXmlTransformer.java 2006-04-19 19:42:56 UTC (rev 3802) +++ labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/DomToXmlTransformer.java 2006-04-19 19:45:21 UTC (rev 3803) @@ -19,7 +19,7 @@ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ -package org.jboss.forge.common.projects; +package org.jboss.shotoku.tools; import java.io.ByteArrayOutputStream; Modified: labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/PropertiesMap.java =================================================================== --- labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/PropertiesMap.java 2006-04-19 19:42:56 UTC (rev 3802) +++ labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/PropertiesMap.java 2006-04-19 19:45:21 UTC (rev 3803) @@ -19,7 +19,7 @@ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ -package org.jboss.forge.common.projects.elements; +package org.jboss.shotoku.tools; import java.util.Map; import java.util.HashMap; Modified: labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/XmlTools.java =================================================================== --- labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/XmlTools.java 2006-04-19 19:42:56 UTC (rev 3802) +++ labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/XmlTools.java 2006-04-19 19:45:21 UTC (rev 3803) @@ -19,7 +19,7 @@ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ -package org.jboss.forge.common; +package org.jboss.shotoku.tools; import java.util.HashMap; import java.util.Map; |
From: <jbo...@li...> - 2006-04-19 19:43:03
|
Author: dam...@jb... Date: 2006-04-19 15:42:56 -0400 (Wed, 19 Apr 2006) New Revision: 3802 Added: labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/PropertiesMap.java Log: Exracting Shotoku. Copied: labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/PropertiesMap.java (from rev 3801, labs/jbosslabs/branches/qa/jbosslabs/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/elements/PropertiesMap.java) |