jenkins-commons-jelly-1.1-jenkins-20110627/0000775000175000017500000000000011611310526016557 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/.classpath0000664000175000017500000000313511602216727020554 0ustar davedave jenkins-commons-jelly-1.1-jenkins-20110627/short-license.txt0000664000175000017500000000117211602216727022110 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */jenkins-commons-jelly-1.1-jenkins-20110627/doap_jelly.rdf0000664000175000017500000000336211602216727021412 0ustar davedave Apache Jakarta Commons Jelly Java Commons Jelly Jelly is a Java and XML based scripting engine. Jelly combines the best ideas from JSTL, Velocity, DVSL, Ant and Cocoon all together in a simple yet powerful scripting engine. commons-jelly 2005-06-16 1.0 jenkins-commons-jelly-1.1-jenkins-20110627/KEYS0000664000175000017500000000705111602216727017270 0ustar davedaveThis file contains the PGP keys of various developers. Please don't use them for email unless you have to. Their main purpose is code signing. Users: pgp < KEYS Developers: pgp -kxa and append it to this file. (pgpk -ll && pgpk -xa ) >> this file. (gpg --list-sigs && gpg --armor --export ) >> this file. Use gpg --armour --detach-sign --default-key=YOURNAME FILE pub 1024D/6883C846 2004-08-03 Dion Gillard sig 3 6883C846 2004-08-03 Dion Gillard sub 1024g/32E95995 2004-08-03 sig 6883C846 2004-08-03 Dion Gillard -----BEGIN PGP PUBLIC KEY BLOCK----- Version: GnuPG v1.2.4 (Cygwin) mQGiBEEPHzkRBACqqH+A9BFBQ3/NSOfj0Ds/8QXqG7D66lVxrvazWRpjh25Ov7Z0 36t4JN2gk/vMl8UCC+vpysUwofWJLzDOWIpYuA5ogTZRny315DbnTsHsdbkkOQ9y ESkhcQZifAMC2lrLTMilqy53YKd+RabLoj7WEaFXj59u3+Bx8Xf9iNOPYwCgzM++ pE3aFZMFi+SLzHFtJk55/VkD/AxIbLKouwjCuYflQSovPgmHJhP2pnVJMa1UgXv9 PYnpjrBBfkxDVUxEu74xZN7Ap/wssYrE5K7NMGv+PT3cutobOXVPpg3/zecm48Xb Y7b+Cvsk1PtsmntT2VGpLXnKUhGy6Ewrzi/Wuix4Z/zalwIyvb231wXsQc67gGQo DQQoA/9nbqYlVBbde4/ELRuxMOVXghkw17guzSZXs+0je0oOnHTACG5x4RIwh0CV sy0gn6D6BSV/ECMRw7R96QrdQnqOExjBUdenoIkmTD/phWKoqangifRtRflQ86gm V60zORF7h40gOs1+Pygo8TmkarQ+j5fgNf/0Heo8aNsh+0REerQeRGlvbiBHaWxs YXJkIDxkaW9uQGFwYWNoZS5vcmc+iF4EExECAB4FAkEPHzkCGwMGCwkIBwMCAxUC AwMWAgECHgECF4AACgkQqAM/2WiDyEbUAgCgu5e9P9oDJEbO9r7lw5Sqa9HBw70A nRuIZtgEKTQ4Z1Tpb10eI6k/IXx8uQENBEEPHz4QBADuu3MH0oB2sGRGhXEDa3EZ BdHljp4aFTSZK6MAMAliy7eRTSJcORbHr2x6Q0wFNBd6r+TSntWG5NWrhwcxCmQR H3hlbZsD7SY1OqClht/XSv/tiRDQ+oAVTVLqThE3bkcUYeoVHzgfqT86i1NmGcny IJj5r8yBA1sVDyp42ADiYwADBQP+Nq8InUWlienKgexPDFAuXXPr9lg6iUMRpEqe bpqSDhpeDTvkmvq1xaUT9Yt+FDX7db/1d1i3fJTIX7dydo/2Vw70f7UODNvWMtQT veaEXchXiH3y62w8nY3ZogMGjKH5DDXqev2SelDSvGcXEWsGZxPvuwh0cGuahyCi gYpWKa6ISQQYEQIACQUCQQ8fPgIbDAAKCRCoAz/ZaIPIRltTAJ4hZeSWTyds0CJd EN9z66UpdcZa+wCgyTaygSUChtQxApENteggXBYXm+4= =ShJX -----END PGP PUBLIC KEY BLOCK----- pub 1024D/084C9113 2004-05-20 Brett Porter sig 3 084C9113 2004-05-20 Brett Porter sub 1024g/58EEF239 2004-05-20 sig 084C9113 2004-05-20 Brett Porter -----BEGIN PGP PUBLIC KEY BLOCK----- Version: GnuPG v1.2.4 (Cygwin) mQGiBECsr7MRBACBCVPGmXWGV0P9fLySv6BGECNS7uapbcKgFCsxBrhe8Czb+5iY 0BOTH8lQriXCkKkG4rEKqt+wQH3mXTGL70stuT1//mgLd0kLQG8aYvoQmrW9jN81 8dPGUDOYFNnu3/2+eqVX5IBSc5puMmRL+msB0IH3Gt2pdOOQ2HbwNKWWnwCgxvug icw0Vw2xSEI+++pm4ETI+b0D/0cuPIqCwgvcOW0FyZqyH8B5JQTRcKVG81mVUZtP tSg14uL+UYLW4HtwCC6rINv561hPnMydodrs8ChQdRCoyKZQankUwAf3ugwDjKIW FVIakRCMYEJt7jU/LDJXpzvquDjjSlgyi7BS/b1E9ZvDMQukNV/IVieaJ3vGIok+ oArvA/9kjf7VB86/CTOIdO0465I9srhBLFcrViRsBn3+biZeoLni1EMhVFRyDz0Y uFVztwgTT9u21FHiSbmkwuLLR7SBJeUSDeZVwEOa+1oA06PaJz2qfHx9zBIrkpoF 49rmKea43ynJYL9EMvD8k4M8ypFgYNNbkT/fq8+fdfex9zaP9LQfQnJldHQgUG9y dGVyIDxicmV0dEBhcGFjaGUub3JnPoheBBMRAgAeBQJArK+zAhsDBgsJCAcDAgMV AgMDFgIBAh4BAheAAAoJEDm+UaEITJETFMYAn001PM5JYf9ae1r/rqnGuD3a4Q5z AKCyzir2OSPMPUOo/PGg1xs+S3vMtbkBDQRArK+2EAQAlNhcASHnoDpGRdqvM9lP DNBIU6mo2md0ixC8xdoT1mRLNEFCuDDpdZ23v3LNBigaJVApryaYwDw9EreqV1Cn KSxUZ5GafLofbtVAtBPhKD1Lcw7Aohc9cg68MtKOvA0Msog77ogM5mmpgYGEzNUC SHYRLS6hy2sRksq8tbbEWMsAAwUEAIgLh2HQaH9D0gX0J8hE6X80JKUW0kdBz8px S8ky6f/ySEcimmhnVqz5Fd0xjD5zGXZJtVNd5g2djIt7f873nmNEBCaPrZS44OjL YMVwpfPnQEwG1rb3+OvErjxFsQ3FNRJGlcc/korz1LVKv7HQUKeoYoYaSnJYHF9y Em97W0CXiEkEGBECAAkFAkCsr7YCGwwACgkQOb5RoQhMkRMVfgCgj+kz0ILPwP/X Kz1AvTMYJzWthjAAoL2r8Jp8ZnwVUIXrrL9Wq8DkdVAd =W22p -----END PGP PUBLIC KEY BLOCK----- jenkins-commons-jelly-1.1-jenkins-20110627/.hgignore0000664000175000017500000000022711602216727020373 0ustar davedavetarget commons-jelly.iml commons-jelly.ipr commons-jelly.iws commons-jelly-tags-define.iml commons-jelly-tags-define.ipr commons-jelly-tags-define.iws jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/0000775000175000017500000000000011602216727020642 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/quartz/0000775000175000017500000000000011602216727022170 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/quartz/project.properties0000664000175000017500000000144511602216727025760 0ustar davedave# # Copyright 2002,2004 The Apache Software Foundation. # # 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. # # ------------------------------------------------------------------- # P R O J E C T P R O P E R T I E S # ------------------------------------------------------------------- jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/quartz/project.xml0000664000175000017500000000370611602216727024366 0ustar davedave ${basedir}/../tag-project.xml commons-jelly-tags-quartz commons-jelly-tags-quartz 1.0.1-SNAPSHOT org.apache.commons.jelly.tags.quartz This is a Jelly interface for the Quartz Scheduler. Commons Jelly Quartz Tag Library 1.0 1.0 COMMONS-JELLY-QUARTZ-1_0 quartz quartz 1.0.2 commons-cli commons-cli 1.0 log4j log4j 1.2.5 logging-log4j jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/quartz/build.xml0000664000175000017500000002027111602216727024013 0ustar davedave jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/quartz/src/0000775000175000017500000000000011602216727022757 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/quartz/src/conf/0000775000175000017500000000000011602216727023704 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/quartz/src/conf/log4j.properties0000664000175000017500000000164711602216727027051 0ustar davedave# # Copyright 2002,2004 The Apache Software Foundation. # # 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. # log4j.rootLogger=DEBUG, A1 log4j.rootCategory=INFO, A1 log4j.appender.A1=org.apache.log4j.ConsoleAppender log4j.appender.A1.layout=org.apache.log4j.PatternLayout log4j.logger.scheduler=INFO log4j.logger.org=INFO log4j.category.scheduler=INFO log4j.category.org.apache.commons.jelly.parser=INFO jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/quartz/src/test/0000775000175000017500000000000011602216727023736 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/quartz/src/test/org/0000775000175000017500000000000011602216727024525 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/quartz/src/test/org/apache/0000775000175000017500000000000011602216727025746 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/quartz/src/test/org/apache/commons/0000775000175000017500000000000011602216727027421 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/quartz/src/test/org/apache/commons/jelly/0000775000175000017500000000000011602216727030540 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/quartz/src/test/org/apache/commons/jelly/tags/0000775000175000017500000000000011602216727031476 5ustar davedave././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/quartz/src/test/org/apache/commons/jelly/tags/quartz/jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/quartz/src/test/org/apache/commons/jelly/tags/0000775000175000017500000000000011602216727031476 5ustar davedave././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/quartz/src/test/org/apache/commons/jelly/tags/quartz/example.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/quartz/src/test/org/apache/commons/jelly/tags/0000664000175000017500000000172711602216727031507 0ustar davedave I like cheese jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/quartz/src/java/0000775000175000017500000000000011602216727023700 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/quartz/src/java/org/0000775000175000017500000000000011602216727024467 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/quartz/src/java/org/apache/0000775000175000017500000000000011602216727025710 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/quartz/src/java/org/apache/commons/0000775000175000017500000000000011602216727027363 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/quartz/src/java/org/apache/commons/jelly/0000775000175000017500000000000011602216727030502 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/quartz/src/java/org/apache/commons/jelly/tags/0000775000175000017500000000000011602216727031440 5ustar davedave././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/quartz/src/java/org/apache/commons/jelly/tags/quartz/jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/quartz/src/java/org/apache/commons/jelly/tags/0000775000175000017500000000000011602216727031440 5ustar davedave././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/quartz/src/java/org/apache/commons/jelly/tags/quartz/WaitForSchedulerTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/quartz/src/java/org/apache/commons/jelly/tags/0000664000175000017500000000447411602216727031453 0ustar davedavepackage org.apache.commons.jelly.tags.quartz; /* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ import org.apache.commons.jelly.XMLOutput; import org.apache.commons.jelly.JellyTagException; import org.quartz.Scheduler; import org.quartz.SchedulerException; /** Block and wait for the Quartz scheduler to shutdown. * * @author bob mcwhirter */ public class WaitForSchedulerTag extends QuartzTagSupport { // ------------------------------------------------------------ // Constructors // ------------------------------------------------------------ /** Construct. */ public WaitForSchedulerTag() { // intentionally left blank. } // ------------------------------------------------------------ // Instance methods // ------------------------------------------------------------ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // org.apache.commons.jelly.Tag // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /** Perform this tag. * * @param output Output sink. * * @throws Exception If an error occurs. */ public void doTag(XMLOutput output) throws JellyTagException { try { Scheduler sched = getScheduler(); while ( ! sched.isShutdown() ) { try { Thread.sleep( 500 ); } catch (InterruptedException e) { break; } } } catch (SchedulerException e) { throw new JellyTagException(e); } } } ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/quartz/src/java/org/apache/commons/jelly/tags/quartz/TriggerTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/quartz/src/java/org/apache/commons/jelly/tags/0000664000175000017500000000216211602216727031443 0ustar davedavepackage org.apache.commons.jelly.tags.quartz; /* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ /** Abstract base for all triggers. * * @author bob mcwhirter */ public abstract class TriggerTag extends QuartzTagSupport { // ------------------------------------------------------------ // Constructors // ------------------------------------------------------------ /** Construct. */ protected TriggerTag() { // intentionally left blank } } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/quartz/src/java/org/apache/commons/jelly/tags/quartz/package.htmljenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/quartz/src/java/org/apache/commons/jelly/tags/0000664000175000017500000000146311602216727031446 0ustar davedave

A tag library for scheduling tasks to be run using the Quartz library

././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/quartz/src/java/org/apache/commons/jelly/tags/quartz/QuartzTagLibrary.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/quartz/src/java/org/apache/commons/jelly/tags/0000664000175000017500000000247711602216727031454 0ustar davedavepackage org.apache.commons.jelly.tags.quartz; /* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ import org.apache.commons.jelly.TagLibrary; /** Tag library for the Quartz enterprise job scheduler. * *

* quartz @ sourceforge *

* * @author bob mcwhirter */ public class QuartzTagLibrary extends TagLibrary { /** Construct and register tags. */ public QuartzTagLibrary() { registerTag( "job", JobTag.class ); registerTag( "cron", CronTriggerTag.class ); registerTag( "wait-for-scheduler", WaitForSchedulerTag.class ); } } ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/quartz/src/java/org/apache/commons/jelly/tags/quartz/JobTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/quartz/src/java/org/apache/commons/jelly/tags/0000664000175000017500000000760011602216727031445 0ustar davedavepackage org.apache.commons.jelly.tags.quartz; /* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.jelly.MissingAttributeException; import org.quartz.Scheduler; import org.quartz.SchedulerException; import org.quartz.JobDetail; import org.quartz.JobDataMap; /** Defines a schedulable job. * * @author bob mcwhirter */ public class JobTag extends QuartzTagSupport { // ------------------------------------------------------------ // Instance members // ------------------------------------------------------------ /** Group of the job. */ private String group; /** Name of the job. */ private String name; // ------------------------------------------------------------ // Constructors // ------------------------------------------------------------ /** Construct. */ public JobTag() { // intentionally left blank. } // ------------------------------------------------------------ // Instance methods // ------------------------------------------------------------ /** Set the name of this job. * * @param name The name of this job. */ public void setName(String name) { this.name = name; } /** Retrieve the name of this job. * * @return The name of this job. */ public String getName() { return this.name; } /** Set the group of this job. * * @param group The group of this job. */ public void setGroup(String group) { this.group = group; } /** Retrieve the group of this job. * * @return The group of this job. */ public String getGroup() { return this.group; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // org.apache.commons.jelly.Tag // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /** Perform this tag. * * @param output Output sink. * * @throws Exception If an error occurs. */ public void doTag(XMLOutput output) throws MissingAttributeException, JellyTagException { if ( getName() == null ) { throw new MissingAttributeException( "name" ); } if ( getGroup() == null ) { throw new MissingAttributeException( "group" ); } JobDetail detail = new JobDetail( getName(), getGroup(), JellyJob.class ); detail.setDurability( true ); JobDataMap data = new JobDataMap(); data.put( "jelly.output", output ); data.put( "jelly.context", getContext() ); data.put( "jelly.script", getBody() ); detail.setJobDataMap( data ); try { Scheduler sched = getScheduler(); sched.addJob( detail, true ); } catch (SchedulerException e) { throw new JellyTagException(e); } } } ././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/quartz/src/java/org/apache/commons/jelly/tags/quartz/QuartzTagSupport.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/quartz/src/java/org/apache/commons/jelly/tags/0000664000175000017500000000557511602216727031456 0ustar davedavepackage org.apache.commons.jelly.tags.quartz; /* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ import org.apache.commons.jelly.TagSupport; import org.quartz.Scheduler; import org.quartz.SchedulerException; import org.quartz.impl.StdSchedulerFactory; /** Basic support for all tags requiring a Quartz scheduler. * * @author bob mcwhirter */ public abstract class QuartzTagSupport extends TagSupport { /** The scheduler variable name in the JellyContext. */ public static final String SCHED_VAR_NAME = "org.apache.commons.jelly.quartz.Scheduler"; /** Retrieve or create a scheduler. * *

* If a scheduler has already been created an installed * in the variable {@link #SCHED_VAR_NAME}, then that scheduler * will be returned. Otherwise, a new StdScheduler will be * created, started, and installed. Additionally, a runtime * shutdown hook will be added to cleanly shutdown the scheduler. * * @return The scheduler. * * @throws SchedulerException If there is an error creating the * scheduler. */ public Scheduler getScheduler() throws SchedulerException { Scheduler sched = (Scheduler) getContext().getVariable( SCHED_VAR_NAME ); if ( sched == null ) { StdSchedulerFactory factory = new StdSchedulerFactory(); final Scheduler newSched = factory.getScheduler(); sched = newSched; getContext().setVariable( SCHED_VAR_NAME, newSched ); Runtime.getRuntime().addShutdownHook( new Thread() { public void run() { try { if ( ! newSched.isShutdown() ) { newSched.shutdown(); } } catch (SchedulerException e) { e.printStackTrace(); } } } ); newSched.start(); } return sched; } } ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/quartz/src/java/org/apache/commons/jelly/tags/quartz/JellyJob.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/quartz/src/java/org/apache/commons/jelly/tags/0000664000175000017500000000525411602216727031450 0ustar davedavepackage org.apache.commons.jelly.tags.quartz; /* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ import org.apache.commons.jelly.JellyContext; import org.apache.commons.jelly.Script; import org.apache.commons.jelly.XMLOutput; import org.quartz.Job; import org.quartz.JobDetail; import org.quartz.JobDataMap; import org.quartz.JobExecutionContext; import org.quartz.JobExecutionException; /** Implementation of a quart Job to execute jellyscript. * * @author bob mcwhirter */ public class JellyJob implements Job { // ------------------------------------------------------------ // Constructors // ------------------------------------------------------------ /** Construct. */ public JellyJob() { // intentionally left blank. } // ------------------------------------------------------------ // Instance methods // ------------------------------------------------------------ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // org.quartz.Job // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /** Execute this job. * * @param jobContext Job context data. * * @throws JobExecutionException If an error occurs during job execution. */ public void execute(JobExecutionContext jobContext) throws JobExecutionException { JobDetail detail = jobContext.getJobDetail(); JobDataMap data = detail.getJobDataMap(); Script script = (Script) data.get( "jelly.script" ); JellyContext jellyContext = (JellyContext) data.get( "jelly.context" ); XMLOutput output = (XMLOutput) data.get( "jelly.output" ); try { script.run( jellyContext, output ); output.flush(); } catch (Exception e) { e.printStackTrace(); throw new JobExecutionException( e, false ); } } } ././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/quartz/src/java/org/apache/commons/jelly/tags/quartz/CronTriggerTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/quartz/src/java/org/apache/commons/jelly/tags/0000664000175000017500000001232311602216727031443 0ustar davedavepackage org.apache.commons.jelly.tags.quartz; /* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ import java.text.ParseException; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.jelly.MissingAttributeException; import org.quartz.CronTrigger; import org.quartz.Scheduler; import org.quartz.SchedulerException; import java.util.Date; /** Define a trigger using a cron time spec. * * @author bob mcwhirter */ public class CronTriggerTag extends QuartzTagSupport { // ------------------------------------------------------------ // Instance members // ------------------------------------------------------------ /** Cron time spec. */ private String spec; /** Trigger name. */ private String name; /** Trigger group. */ private String group; /** Job name. */ private String jobName; /** Job group. */ private String jobGroup; // ------------------------------------------------------------ // COnstructors // ------------------------------------------------------------ /** Construct. */ public CronTriggerTag() { // intentionally left blank. } // ------------------------------------------------------------ // ------------------------------------------------------------ /** Set the name. * * @param name. */ public void setName(String name) { this.name = name; } /** Retrieve the name. * * @return The name. */ public String getName() { return this.name; } /** Set the group * * @param group The group */ public void setGroup(String group) { this.group = group; } /** Retrieve the group. * * @return The group. */ public String getGroup() { return this.group; } /** Set the cron time spec. * * @param spec The cron time spec. */ public void setSpec(String spec) { this.spec = spec; } /** Retrieve the cron time spec. * * @param spec The cron time spec. */ public String getSpec() { return this.spec; } /** Set the job name. * * @param jobName The job name. */ public void setJobName(String jobName) { this.jobName = jobName; } /** Retrieve the job name. * * @return The job name. */ public String getJobName() { return this.jobName; } /** Set the job group. * * @param jobGroup The job group. */ public void setJobGroup(String jobGroup) { this.jobGroup = jobGroup; } /** Retrieve the job group. * * @return The job group. */ public String getJobGroup() { return this.jobGroup; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // org.apache.commons.jelly.Tag // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /** Perform this tag. * * @param output Output sink. * * @throws Exception If an error occurs. */ public void doTag(XMLOutput output) throws MissingAttributeException, JellyTagException { if ( getSpec() == null ) { throw new MissingAttributeException( "spec" ); } if ( getName() == null ) { throw new MissingAttributeException( "name" ); } if ( getGroup() == null ) { throw new MissingAttributeException( "group" ); } if ( getJobName() == null ) { throw new MissingAttributeException( "jobName" ); } if ( getJobGroup() == null ) { throw new MissingAttributeException( "jobGroup" ); } CronTrigger trigger = new CronTrigger( getName(), getGroup() ); try { trigger.setCronExpression( getSpec() ); } catch (ParseException e) { throw new JellyTagException(e); } trigger.setJobName( getJobName() ); trigger.setJobGroup( getJobGroup() ); trigger.setStartTime( new Date() ); try { Scheduler sched = getScheduler(); sched.scheduleJob( trigger ); } catch (SchedulerException e) { throw new JellyTagException(e); } } } jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/quartz/xdocs/0000775000175000017500000000000011602216727023310 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/quartz/xdocs/index.xml0000664000175000017500000000211411602216727025137 0ustar davedave Quartz Tag Library dIon Gillard

A tag library for scheduling tasks to be run using the Quartz library. See the tags for more information.

jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/quartz/xdocs/changes.xml0000664000175000017500000000163511602216727025447 0ustar davedave Changes dIon Gillard jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/quartz/xdocs/navigation.xml0000664000175000017500000000167611602216727026203 0ustar davedave Quartz Tag Library jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/quartz/maven.xml0000664000175000017500000000303711602216727024023 0ustar davedave jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/tag-navigation.xml0000664000175000017500000000225711602216727024302 0ustar davedave @pom.name@ Jakarta jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/html/0000775000175000017500000000000011602216727021606 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/html/project.properties0000664000175000017500000000144511602216727025376 0ustar davedave# # Copyright 2002,2004 The Apache Software Foundation. # # 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. # # ------------------------------------------------------------------- # P R O J E C T P R O P E R T I E S # ------------------------------------------------------------------- jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/html/project.xml0000664000175000017500000000475411602216727024010 0ustar davedave ${basedir}/../tag-project.xml commons-jelly-tags-html commons-jelly-tags-html 1.0.1-SNAPSHOT org.apache.commons.jelly.tags.html These Jelly tags can scrub commons errors in HTML syntax. Commons Jelly HTML Tag Library 1.0 1.0 COMMONS-JELLY-HTML-1_0 nekohtml nekohtml 0.9.5 commons-cli commons-cli 1.0 commons-jelly commons-jelly-tags-log 1.0 commons-jelly commons-jelly-tags-jsl 1.0 commons-jelly commons-jelly-tags-xml 1.0 commons-jelly commons-jelly-tags-junit 1.0 http://jakarta.apache.org/commons/jelly/tags/junit/ test jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/html/build.xml0000664000175000017500000005254511602216727023442 0ustar davedave ================================= WARNING ================================ Junit isn't present in your ${ANT_HOME}/lib directory. Tests not executed. ========================================================================== Proxy used : Proxy host [${proxy.host}] Proxy port [${proxy.port}] Proxy user [${proxy.username}] Proxy not used. jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/html/src/0000775000175000017500000000000011602216727022375 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/html/src/test/0000775000175000017500000000000011602216727023354 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/html/src/test/org/0000775000175000017500000000000011602216727024143 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/html/src/test/org/apache/0000775000175000017500000000000011602216727025364 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/html/src/test/org/apache/commons/0000775000175000017500000000000011602216727027037 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/html/src/test/org/apache/commons/jelly/0000775000175000017500000000000011602216727030156 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/html/src/test/org/apache/commons/jelly/html/0000775000175000017500000000000011602216727031122 5ustar davedave././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/html/src/test/org/apache/commons/jelly/html/example.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/html/src/test/org/apache/commons/jelly/html/ex0000664000175000017500000000171711602216727031467 0ustar davedave The title is: The XML of the document is ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/html/src/test/org/apache/commons/jelly/html/textScript.txtjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/html/src/test/org/apache/commons/jelly/html/te0000664000175000017500000000027111602216727031455 0ustar davedavethis is some text this is some more text do something ${12 + 12} end of the page... ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/html/src/test/org/apache/commons/jelly/html/TestJelly.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/html/src/test/org/apache/commons/jelly/html/Te0000664000175000017500000000237211602216727031421 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.html; import junit.framework.TestSuite; import junit.textui.TestRunner; import org.apache.commons.jelly.tags.junit.JellyTestSuite; /** * A helper class to run jelly test cases as part of Ant's JUnit tests * * @author James Strachan * @version 1.1 */ public class TestJelly extends JellyTestSuite { public static void main( String[] args ) throws Exception { TestRunner.run( suite() ); } public static TestSuite suite() throws Exception { return createTestSuite(TestJelly.class, "suite.jelly"); } } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/html/src/test/org/apache/commons/jelly/html/suite.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/html/src/test/org/apache/commons/jelly/html/su0000664000175000017500000000624511602216727031503 0ustar davedave Jelly - Jelly : Java and XML based processing engine Jelly - Jelly : Java and XML based processing engine ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/html/src/test/org/apache/commons/jelly/html/radioToPDA.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/html/src/test/org/apache/commons/jelly/html/ra0000664000175000017500000000446211602216727031455 0ustar davedave About to generate file ${outputFile}
././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/html/src/test/org/apache/commons/jelly/html/index.htmljenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/html/src/test/org/apache/commons/jelly/html/in0000664000175000017500000000242211602216727031453 0ustar davedave Jelly - Jelly : Java and XML based processing engine

Some text

some unmatched tags here...

and here...


././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/html/src/test/org/apache/commons/jelly/html/example2.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/html/src/test/org/apache/commons/jelly/html/ex0000664000175000017500000000162011602216727031460 0ustar davedave The XML of the document is jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/html/src/java/0000775000175000017500000000000011602216727023316 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/html/src/java/org/0000775000175000017500000000000011602216727024105 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/html/src/java/org/apache/0000775000175000017500000000000011602216727025326 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/html/src/java/org/apache/commons/0000775000175000017500000000000011602216727027001 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/html/src/java/org/apache/commons/jelly/0000775000175000017500000000000011602216727030120 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/html/src/java/org/apache/commons/jelly/tags/0000775000175000017500000000000011602216727031056 5ustar davedave././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/html/src/java/org/apache/commons/jelly/tags/html/jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/html/src/java/org/apache/commons/jelly/tags/ht0000775000175000017500000000000011602216727031412 5ustar davedave././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/html/src/java/org/apache/commons/jelly/tags/html/package.htmljenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/html/src/java/org/apache/commons/jelly/tags/ht0000664000175000017500000000152211602216727031414 0ustar davedave

Tags for parsing HTML so that it can be processed by Jelly using Andy Clark's NekoHTML

././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/html/src/java/org/apache/commons/jelly/tags/html/HTMLTagLibrary.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/html/src/java/org/apache/commons/jelly/tags/ht0000664000175000017500000000236111602216727031416 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.html; import org.apache.commons.jelly.TagLibrary; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** Describes the Taglib. This class could be generated by XDoclet * * @author James Strachan * @version $Revision: 155420 $ */ public class HTMLTagLibrary extends TagLibrary { /** The Log to which logging calls will be made. */ private Log log = LogFactory.getLog(HTMLTagLibrary.class); public HTMLTagLibrary() { registerTag("parse", ParseTag.class); } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/html/src/java/org/apache/commons/jelly/tags/html/ParseTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/html/src/java/org/apache/commons/jelly/tags/ht0000664000175000017500000000773311602216727031426 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.html; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.jelly.tags.xml.ParseTagSupport; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.cyberneko.html.parsers.SAXParser; import org.dom4j.Document; import org.dom4j.io.SAXReader; import org.xml.sax.SAXException; /** A tag which parses some HTML and defines a variable with the parsed Document. * The HTML can either be specified as its body or can be passed in via the * html property which can be a Reader, InputStream, URL or String URI. * * @author James Strachan * @version $Revision: 155420 $ */ public class ParseTag extends ParseTagSupport { /** The Log to which logging calls will be made. */ private static final Log log = LogFactory.getLog(ParseTag.class); /** The HTML to parse, either a String URI, a Reader or InputStream */ private Object html; private String element = "match"; private String attribute = "no-change"; public ParseTag() { } // Tag interface //------------------------------------------------------------------------- public void doTag(XMLOutput output) throws JellyTagException { if (getVar() == null) { throw new IllegalArgumentException("The var attribute cannot be null"); } Document document = null; if (html == null) { String text = getText(); if (text != null) { document = parseText(text); } else { document = parseBody(output); } } else { document = parse(html); } context.setVariable(getVar(), document); } // Properties //------------------------------------------------------------------------- /** Sets the source of the HTML which is either a String URI, Reader or InputStream */ public void setHtml(Object html) { this.html = html; } /** * Sets whether attributes should be converted to a different case. * Possible values are "upper", "lower" or "no-change" * * @param attribute The processing mode of attributes */ public void setAttribute(String attribute) { this.attribute = attribute; } /** * Sets whether elements should be converted to a different case * Possible values are "upper", "lower" or "match" * * @param element The processing mode of elements */ public void setElement(String element) { this.element = element; } // Implementation methods //------------------------------------------------------------------------- /** * Factory method to create a new SAXReader */ protected SAXReader createSAXReader() throws SAXException { // installs the NeckHTML parser SAXParser parser = new SAXParser(); parser.setProperty( "http://cyberneko.org/html/properties/names/elems", element ); parser.setProperty( "http://cyberneko.org/html/properties/names/attrs", attribute ); return new SAXReader( parser ); } } jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/html/xdocs/0000775000175000017500000000000011602216727022726 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/html/xdocs/index.xml0000664000175000017500000000216011602216727024556 0ustar davedave HTML Tag Library dIon Gillard

Tags for parsing HTML so that it can be processed by Jelly using Andy Clark's NekoHTML. See the tags for more information.

jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/html/xdocs/changes.xml0000664000175000017500000000215111602216727025057 0ustar davedave Changes dIon Gillard Move nekohtml to 0.9.5 Initial Release jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/html/xdocs/navigation.xml0000664000175000017500000000167011602216727025613 0ustar davedave HTML Tag Library jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/html/maven.xml0000664000175000017500000000426011602216727023440 0ustar davedave jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/0000775000175000017500000000000011602216727021442 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/project.properties0000664000175000017500000000143411602216727025230 0ustar davedave # Copyright 2002-2004 The Apache Software Foundation # # 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. # ------------------------------------------------------------------- # P R O J E C T P R O P E R T I E S # ------------------------------------------------------------------- jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/project.xml0000664000175000017500000000372311602216727023637 0ustar davedave ${basedir}/../tag-project.xml commons-jelly-tags-xml commons-jelly-tags-xml 1.2-SNAPSHOT org.apache.commons.jelly.tags.xml The Jelly XML Tag Library Commons Jelly XML Tag Library 1.0 1.0 COMMONS_JELLY_XML-1_0 1.1 1.1 commons-jelly-tags-xml-1.1 commons-jelly commons-jelly SNAPSHOT xalan xalan 2.3.1 commons-jelly commons-jelly-tags-junit 1.0 http://jakarta.apache.org/commons/jelly/libs/junit/ test jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/build.xml0000664000175000017500000002005011602216727023260 0ustar davedave jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/0000775000175000017500000000000011602216727022231 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/0000775000175000017500000000000011602216727023210 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/0000775000175000017500000000000011602216727023777 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/0000775000175000017500000000000011602216727025220 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/0000775000175000017500000000000011602216727026673 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/0000775000175000017500000000000011602216727030012 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/0000775000175000017500000000000011602216727030750 5ustar davedave././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml/jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml0000775000175000017500000000000011602216727031471 5ustar davedave././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml/schematron/jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml0000775000175000017500000000000011602216727031471 5ustar davedave././@LongLink0000000000000000000000000000020700000000000011564 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml/schematron/schematron-wrapper.xsljenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml0000664000175000017500000000777011602216727031506 0ustar davedave Validation Report For: ././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml/schematron/test-schematron.xmljenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml0000664000175000017500000001206011602216727031472 0ustar davedave This is an example schema for the Building Projects XML language. completed admin Constraints which are applied during construction A house should have 4 walls The house is incomplete, it still needs a roof An incomplete house must have a builder assigned to it An incomplete house cannot have an owner Constraints which are applied after construction A house should have 4 walls The house is incomplete, it still needs a roof An incomplete house must have an owner An incomplete house doesn't need a builder Adminstrative constraints which are always applied A house must have an address An address may only include street, town and postcode elements. An address must include the street details An address must identify the town An address must have a postcode A element must have a first name A element must have a last name A must be certified An must have a telephone Certification numbers must be recorded in the number attribute Its an odd house which has more or less than four walls! Consult your architect... Its an odd house which has no roof! Consult your architect... ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml/schematron/source.xmljenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml0000664000175000017500000000205611602216727031476 0ustar davedave
1 The High Street New Town NT1
Bob Builder
././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml/schematron/skeleton1-5.xsljenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml0000664000175000017500000005274011602216727031503 0ustar davedave #ALL key Warning: must not contain any child elements / @ [ ] Markup Error: no pattern attribute in <active> Reference Error: the pattern "" has been activated but is not declared Markup Error: no test attribute in <assert> Markup Error: no test attribute in <report> Markup Error: no id attribute in <diagnostic> Markup Error: no rule attribute in <extends> Reference Error: the abstract rule "" has been referenced but is not declared Markup Error: no name attribute in <key> Markup Error: no match attribute on <key> outside <rule> Markup Error: no path attribute in <key> Markup Error: no uri attribute in <ns> Markup Error: no prefix attribute in <ns> Markup Error: no id attribute in <phase> Markup Error: no context attribute in <rule> Markup Error: no id attribute on abstract <rule> Markup Error: (2) context attribute on abstract <rule> Markup Error: context attribute on abstract <rule> Markup Error: no select attribute in <value-of> Warning: must not contain any child elements Reference error: A diagnostic "" has been referenced but is not declared Warning: unrecognized element Warning: unrecognized element ././@LongLink0000000000000000000000000000022100000000000011560 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml/schematron/transformSchematronExample.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml0000664000175000017500000000177711602216727031507 0ustar davedave Report count=:assert count= ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml/transformExample3.xsljenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml0000664000175000017500000000172011602216727031473 0ustar davedave ././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml/transformParamExample2.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml0000664000175000017500000000252711602216727031501 0ustar davedave Hello works! ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml/testThread.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml0000664000175000017500000000360511602216727031477 0ustar davedave About to spawn another thread... snoop SnoopServlet file ViewFile initial 1000 The initial value for the counter snoop /foo/snoop name: class: There are servlet(s) The thread should have started now! ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml/transformExample1.xsljenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml0000664000175000017500000000171711602216727031501 0ustar davedave ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml/transformExample2.xsljenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml0000664000175000017500000000172011602216727031473 0ustar davedave ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml/entity.xmljenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml0000664000175000017500000000010611602216727031470 0ustar davedave ]> &x; ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml/example.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml0000664000175000017500000000155611602216727031502 0ustar davedave It works! ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml/betwixt/jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml0000775000175000017500000000000011602216727031471 5ustar davedave././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml/betwixt/input.xmljenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml0000664000175000017500000000156011602216727031475 0ustar davedave ././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml/betwixt/makeBetwixt.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml0000664000175000017500000000223111602216727031471 0ustar davedave ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml/TestParser.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml0000664000175000017500000000642011602216727031475 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.xml; import java.io.FileInputStream; import java.io.InputStream; import java.util.Iterator; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import junit.textui.TestRunner; import org.apache.commons.jelly.Script; import org.apache.commons.jelly.Tag; import org.apache.commons.jelly.JellyContext; import org.apache.commons.jelly.impl.ScriptBlock; import org.apache.commons.jelly.impl.TagScript; import org.apache.commons.jelly.parser.XMLParser; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** Tests the core tags * * @author James Strachan * @version $Revision: 155420 $ */ public class TestParser extends TestCase { /** The Log to which logging calls will be made. */ private static final Log log = LogFactory.getLog(TestParser.class); public static void main(String[] args) { TestRunner.run(suite()); } public static Test suite() { return new TestSuite(TestParser.class); } public TestParser(String testName) { super(testName); } /** * Tests that parsing an example script correctly creates the parent * relationships */ public void testParser() throws Exception { InputStream in = new FileInputStream("src/test/org/apache/commons/jelly/tags/xml/example2.jelly"); XMLParser parser = new XMLParser(); Script script = parser.parse(in); script = script.compile(); log.debug("Found: " + script); assertTagsHaveParent( script, null, null ); } /** * Tests that the Tag in the TagScript has the given parent and then * recurse to check its children has the correct parent and so forth. */ protected void assertTagsHaveParent(Script script, Tag parent, JellyContext context) throws Exception { if ( context == null ) context = new JellyContext(); if ( script instanceof TagScript ) { TagScript tagScript = (TagScript) script; Tag tag = tagScript.getTag(context); assertEquals( "Tag: " + tag + " has the incorrect parent", parent, tag.getParent() ); assertTagsHaveParent( tag.getBody(), tag, context ); } else if ( script instanceof ScriptBlock ) { ScriptBlock block = (ScriptBlock) script; for ( Iterator iter = block.getScriptList().iterator(); iter.hasNext(); ) { assertTagsHaveParent( (Script) iter.next(), parent, context ); } } } }././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml/testExpressions.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml0000664000175000017500000000243411602216727031476 0ustar davedave cheese deep pan attribute test failed. Found and expected 'pizza has cheese on top' pizza has ${topping} on top element test failed. Found and expected 'pizza has cheese on top' ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml/TestXMLTags.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml0000664000175000017500000003553611602216727031507 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.xml; import java.io.File; import java.io.FileInputStream; import java.io.InputStream; import java.io.StringWriter; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; import junit.framework.Assert; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import junit.textui.TestRunner; import org.apache.commons.jelly.JellyContext; import org.apache.commons.jelly.JellyException; import org.apache.commons.jelly.Script; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.jelly.parser.XMLParser; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.dom4j.Document; import org.dom4j.DocumentHelper; import org.dom4j.Node; import org.dom4j.io.SAXContentHandler; import org.dom4j.io.XMLWriter; /** Tests the parser, the engine and the XML tags * * @author James Strachan * @version $Revision: 219726 $ */ public class TestXMLTags extends TestCase { /** The Log to which logging calls will be made. */ private static final Log log = LogFactory.getLog(TestXMLTags.class); /** basedir for test source */ private static final String testBaseDir ="src/test/org/apache/commons/jelly/tags/xml"; public static void main(String[] args) { TestRunner.run(suite()); } public static Test suite() { return new TestSuite(TestXMLTags.class); } public TestXMLTags(String testName) { super(testName); } public void testUnitTests() throws Exception { runUnitTest( testBaseDir + "/testForEach.jelly" ); } public void testExpressions() throws Exception { runUnitTest( testBaseDir + "/testExpressions.jelly"); } public void testParse() throws Exception { InputStream in = new FileInputStream(testBaseDir + "/example.jelly"); XMLParser parser = new XMLParser(); Script script = parser.parse(in); script = script.compile(); log.debug("Found: " + script); assertTrue("Parsed a Script", script instanceof Script); StringWriter buffer = new StringWriter(); script.run(parser.getContext(), XMLOutput.createXMLOutput(buffer)); String text = buffer.toString().trim(); if (log.isDebugEnabled()) { log.debug("Evaluated script as..."); log.debug(text); } assertEquals("Should produce the correct output", "It works!", text); } public void testElementWithNameSpace() throws Exception { String text = evaluteScriptAsText(testBaseDir + "/elementWithNameSpace.jelly"); assertEquals("Should produce the correct output", ""+ "", text); } public void testElementWithNameSpaceError() throws Exception { try { evaluteScriptAsText(testBaseDir + "/elementWithNameSpaceError.jelly"); Assert.fail("We should have bailed out with an JellyException"); } catch (JellyException jex) { assertTrue(jex.getReason().startsWith("Cannot set same prefix to diferent URI in same node")); } } public void testNamespaceReplace() throws Exception { // For this test when we not set "ns" var with expected namespace, it // is expected to repeat the same two times String text = evaluteScriptAsText(testBaseDir + "/namespaceReplace.jelly"); String repeatingText = ""; assertEquals("Should produce the correct output", ""+ repeatingText + repeatingText + "", text); Map ctxVars = new HashMap(); ctxVars.put("ns", "http://java/ns"); text = evaluteScriptAsText(testBaseDir + "/namespaceReplace.jelly", ctxVars); String firstTrunk = "" + "" + "" + "" + "" + ""; String secondTrunk = "" + "" + "" + "" + "" + ""; System.out.println("TestXMLTags.testNamespaceReplace() text="+text); assertEquals("Should produce the correct output", ""+ firstTrunk + secondTrunk + "", text); } public void testAttributeNameSpaceDuplicatedNS() throws Exception { try { evaluteScriptAsText(testBaseDir + "/attributeNameSpaceDuplicatedNS.jelly"); Assert.fail("We should have bailed out with an JellyException"); } catch (JellyException jex) { assertTrue(jex.getReason().startsWith("Cannot set same prefix to diferent URI in same node")); } } public void testAttributeNameSpace() throws Exception { String text = evaluteScriptAsText(testBaseDir + "/attributeNameSpace.jelly"); System.out.println(text); assertEquals("Should produce the correct output", ""+ ""+ ""+ ""+ ""+ ""+ "", text); } public void testAttributeNameSpaceDefaultNS() throws Exception { String text = evaluteScriptAsText(testBaseDir + "/attributeNameSpaceDefaultNS.jelly"); System.out.println(text); assertEquals("Should produce the correct output", ""+ ""+ ""+ ""+ ""+ ""+ "", text); } public void testAttributeNameSpaceWithInnerElements() throws Exception { String text = evaluteScriptAsText(testBaseDir + "/attributeNameSpaceWithInnerElements.jelly"); assertEquals("Should produce the correct output", ""+ ""+ ""+ "" , text); } public void testTransform() throws Exception { String text = evaluteScriptAsText(testBaseDir + "/transformExample.jelly"); assertEquals("Should produce the correct output", "It works!", text); } public void testTransformAllInLine() throws Exception { String text = evaluteScriptAsText(testBaseDir + "/transformExampleAllInLine.jelly"); assertEquals("Should produce the correct output", "It works!", text); } public void testTransformParams() throws Exception { String text = evaluteScriptAsText(testBaseDir + "/transformParamExample.jelly"); assertEquals("Should produce the correct output", "It works!", text); } public void testTransformParamsInLine() throws Exception { String text = evaluteScriptAsText(testBaseDir + "/transformParamExample2.jelly"); assertEquals("Should produce the correct output", "It works!", text); } public void testTransformSAXOutput() throws Exception { String text = evaluteScriptAsText(testBaseDir + "/transformExampleSAXOutput.jelly"); assertEquals("Should produce the correct output", "It works!", text); } public void testTransformSAXOutputNestedTransforms() throws Exception { String text = evaluteScriptAsText(testBaseDir + "/transformExampleSAXOutputNestedTransforms.jelly"); assertEquals("Should produce the correct output", "It works!", text); } public void testTransformSchematron() throws Exception { String text = evaluteScriptAsText(testBaseDir + "/schematron/transformSchematronExample.jelly"); assertEquals("Should produce the correct output", "Report count=1:assert count=2", text); } public void testTransformXmlVar() throws Exception { String text = evaluteScriptAsText(testBaseDir + "/transformExampleXmlVar.jelly"); assertEquals("Should produce the correct output", "It works!", text); } public void testDoctype() throws Exception { String text = evaluteScriptAsText(testBaseDir + "/testDoctype.jelly"); assertEquals("Should produce the correct output", "\n", text); } public void runUnitTest(String name) throws Exception { Document document = parseUnitTest(name); List failures = document.selectNodes( "/*/fail" ); for ( Iterator iter = failures.iterator(); iter.hasNext(); ) { Node node = (Node) iter.next(); fail( node.getStringValue() ); } } public Document parseUnitTest(String name) throws Exception { // parse script InputStream in = new FileInputStream(name); XMLParser parser = new XMLParser(); Script script = parser.parse(in); script = script.compile(); assertTrue("Parsed a Script", script instanceof Script); StringWriter buffer = new StringWriter(); script.run(parser.getContext(), XMLOutput.createXMLOutput(buffer)); String text = buffer.toString().trim(); if (log.isDebugEnabled()) { log.debug("Evaluated script as..."); log.debug(text); } // now lets parse the output return DocumentHelper.parseText( text ); } /** * Evaluates the script by the given file name and * returns the whitespace trimmed output as text */ protected String evaluteScriptAsText(String fileName) throws Exception { return evaluteScriptAsText(fileName, null); } /** * Evaluates the script by the given file name and * returns the whitespace trimmed output as text */ protected String evaluteScriptAsText(String fileName, Map ctxVars) throws Exception { JellyContext context = new JellyContext(); if (ctxVars != null) { Set keys = ctxVars.keySet(); for (Iterator iterator = keys.iterator(); iterator.hasNext();) { String key = (String) iterator.next(); Object value = ctxVars.get(key); context.setVariable(key, value); } } // allow scripts to refer to any resource inside this project // using an absolute URI like /src/test/org/apache/foo.xml context.setRootURL(new File(".").toURL()); // cature the output StringWriter buffer = new StringWriter(); XMLOutput output = XMLOutput.createXMLOutput(buffer); context.runScript( new File(fileName), output ); String text = buffer.toString().trim(); if (log.isDebugEnabled()) { log.debug("Evaluated script as..."); log.debug(text); } return text; } protected String evaluteScriptAsTextUsingSaxContentHandler(String fileName, Map ctxVars) throws Exception { org.dom4j.io.OutputFormat outputFormat = new org.dom4j.io.OutputFormat(); outputFormat.setSuppressDeclaration(true); outputFormat.setNewlines(false); outputFormat.setIndent(false); outputFormat.setExpandEmptyElements(true); //outputFormat.setIndentSize(4); StringWriter buffer = new StringWriter(); XMLWriter xmlWriter = new XMLWriter(buffer, outputFormat); // xmlWriter.setEscapeText(false); SAXContentHandler saxHandler = new SAXContentHandler(); XMLOutput output = new XMLOutput(saxHandler); // now run a script using a URL JellyContext context = new JellyContext(); if (ctxVars != null) { Set keys = ctxVars.keySet(); for (Iterator iterator = keys.iterator(); iterator.hasNext();) { String key = (String) iterator.next(); Object value = ctxVars.get(key); context.setVariable(key, value); } } // allow scripts to refer to any resource inside this project // using an absolute URI like /src/test/org/apache/foo.xml context.setRootURL(new File(".").toURL()); output.startDocument(); context.runScript(new File(fileName), output); output.endDocument(); xmlWriter.write(saxHandler.getDocument()); xmlWriter.flush(); String text = buffer.toString().trim(); if (log.isDebugEnabled()) { log.debug("Evaluated script as..."); log.debug(text); } return text; } } ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml/TestJelly.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml0000664000175000017500000000241611602216727031476 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.xml; import junit.framework.TestSuite; import junit.textui.TestRunner; import org.apache.commons.jelly.tags.junit.JellyTestSuite; /** * A helper class to run jelly test cases as part of Ant's JUnit tests * * @author James Strachan * @version $Revision: 155420 $ */ public class TestJelly extends JellyTestSuite { public static void main( String[] args ) throws Exception { TestRunner.run( suite() ); } public static TestSuite suite() throws Exception { return createTestSuite(TestJelly.class, "suite.jelly"); } } ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml/transformExample4.xsljenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml0000664000175000017500000000172011602216727031473 0ustar davedave ././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml/filesetExample.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml0000664000175000017500000000262311602216727031476 0ustar davedave About to process file ${file} and generate file name ${fileName}.html ././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml/transformExample.xsljenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml0000664000175000017500000000167511602216727031504 0ustar davedave <xsl:apply-templates/> ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml/suite.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml0000664000175000017500000003256011602216727031501 0ustar davedave 1234 ABC hello some text 1234 We should have created an exception as some text is output before the attributes cheese This should never fail This should never fail This should always fail We should have created an exception The exception was: ${ex.message} cheese This should never fail This should never fail This should always fail We should have created an exception This should always fail, since foo is not in the empty namespace We should have created an exception 31 211 1 11 exists = ${theSuite.exists()}, readable = ${theSuite.canRead()}, class=${theSuite.class.name} blop1 blop0 blurp=${blurp}, blurpAndX=${blurpAndX} blop1 blop0 ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml/TestImport.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml0000664000175000017500000000630311602216727031475 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.xml; import java.io.IOException; import java.io.StringWriter; import java.io.UnsupportedEncodingException; import java.net.URL; import org.apache.commons.jelly.JellyContext; import org.apache.commons.jelly.JellyException; import org.apache.commons.jelly.Script; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.jelly.parser.XMLParser; import org.xml.sax.SAXException; import junit.framework.TestCase; /** * Test that compiled scripts can access resources */ public class TestImport extends TestCase { private String expected = "\n" + "" + "Expense Report Summary" + "

Total Amount: 12

"; public TestImport(String name) { super(name); } public void testImportResources() throws JellyException, UnsupportedEncodingException, IOException { JellyContext context = new JellyContext(); URL url = TestImport.class.getResource("/resources/import.jelly"); StringWriter writer = new StringWriter(); XMLOutput out = XMLOutput.createXMLOutput(writer); // this works because of the created child context that has knowledge // of the URL context.runScript(url, out); out.close(); assertEquals(expected, writer.toString()); } public void testImportResourcesCompiled() throws JellyException, UnsupportedEncodingException, IOException { JellyContext context = new JellyContext(); URL url = TestImport.class.getResource("/resources/import.jelly"); StringWriter writer = new StringWriter(); XMLOutput out = XMLOutput.createXMLOutput(writer); Script script = context.compileScript(url); script.run(context, out); out.close(); assertEquals(expected, writer.toString()); } public void testImportResourcesFromUncompiledScript() throws JellyException, UnsupportedEncodingException, IOException, SAXException { JellyContext context = new JellyContext(); URL url = TestImport.class.getResource("/resources/import.jelly"); StringWriter writer = new StringWriter(); XMLOutput out = XMLOutput.createXMLOutput(writer); Script script = new XMLParser().parse(url); script.run(context, out); out.close(); assertEquals(expected, writer.toString()); } }././@LongLink0000000000000000000000000000021700000000000011565 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml/attributeNameSpaceWithInnerElements.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml0000664000175000017500000000156111602216727031476 0ustar davedave testValue testValue testValue testValue testValue testValue ././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml/transformExampleXmlVar.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml0000664000175000017500000000151611602216727031476 0ustar davedave ././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml/transformParamExample.xsljenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml0000664000175000017500000000160211602216727031472 0ustar davedave ././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml/transformParamExample.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml0000664000175000017500000000161211602216727031473 0ustar davedave ././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml/namespaceReplace.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml0000664000175000017500000000166611602216727031504 0ustar davedave testValue testValue testValue ././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml/transformExampleXmlVar.xmljenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml0000664000175000017500000000131011602216727031466 0ustar davedave It works! ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml/testForEach.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml0000664000175000017500000000264511602216727031502 0ustar davedave The i2 should be 6! but the value is The i should be 6! but the value is ././@LongLink0000000000000000000000000000020700000000000011564 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml/attributeNameSpaceDefaultNS.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml0000664000175000017500000000132311602216727031472 0ustar davedave testValue testValue testValue ././@LongLink0000000000000000000000000000021200000000000011560 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml/attributeNameSpaceDuplicatedNS.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml0000664000175000017500000000055411602216727031477 0ustar davedave testValue testValue ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml/dummy.xmljenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml0000664000175000017500000000137611602216727031502 0ustar davedave This is some sample XML And some more XML ././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml/transformExampleAllInLine.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml0000664000175000017500000000245511602216727031501 0ustar davedave <xsl:apply-templates/> It works! ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml/example2.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml0000664000175000017500000000332311602216727031474 0ustar davedave snoop SnoopServlet file ViewFile initial 1000 The initial value for the counter snoop /foo/snoop name: class: There are servlet(s) ././@LongLink0000000000000000000000000000022500000000000011564 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml/transformExampleSAXOutputNestedTransforms.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml0000664000175000017500000000237511602216727031502 0ustar davedave It works! ././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml/xpathSortExample.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml0000664000175000017500000000604111602216727031474 0ustar davedave 31 211 1 11 ${result} ${result} ${result} ${result} ${result} ${result} ${result} ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml/transformExample5.xsljenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml0000664000175000017500000000172011602216727031473 0ustar davedave ././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml/transformParamExample.xmljenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml0000664000175000017500000000122711602216727031475 0ustar davedave Hello ././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml/attributeNameSpace.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml0000664000175000017500000000133711602216727031477 0ustar davedave testValue testValue testValue ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml/testDoctype.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml0000664000175000017500000000143611602216727031477 0ustar davedave ././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml/elementWithNameSpace.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml0000664000175000017500000000064311602216727031476 0ustar davedave http://schemas.xmlsoap.org/soap/encoding/ ././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml/transformExampleSAXOutput.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml0000664000175000017500000000331511602216727031475 0ustar davedave <xsl:apply-templates/> It works! ././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml/transformExample.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml0000664000175000017500000000160211602216727031472 0ustar davedave It works! ././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml/elementWithNameSpaceError.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/org/apache/commons/jelly/tags/xml0000664000175000017500000000053411602216727031475 0ustar davedave http://schemas.xmlsoap.org/soap/encoding/ jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/resources/0000775000175000017500000000000011602216727025222 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/resources/import.xsl0000664000175000017500000000175511602216727027274 0ustar davedave Expense Report Summary

Total Amount: 12

jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/test/resources/import.jelly0000664000175000017500000000147311602216727027602 0ustar davedave jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/java/0000775000175000017500000000000011602216727023152 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/java/org/0000775000175000017500000000000011602216727023741 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/java/org/apache/0000775000175000017500000000000011602216727025162 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/java/org/apache/commons/0000775000175000017500000000000011602216727026635 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/java/org/apache/commons/jelly/0000775000175000017500000000000011602216727027754 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/java/org/apache/commons/jelly/tags/0000775000175000017500000000000011602216727030712 5ustar davedave././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/java/org/apache/commons/jelly/tags/xml/jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/java/org/apache/commons/jelly/tags/xml0000775000175000017500000000000011602216727031433 5ustar davedave././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/java/org/apache/commons/jelly/tags/xml/ReplaceNamespaceTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/java/org/apache/commons/jelly/tags/xml0000664000175000017500000001034711602216727031442 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.xml; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.MissingAttributeException; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.XMLOutput; import org.xml.sax.Attributes; import org.xml.sax.SAXException; import org.xml.sax.helpers.AttributesImpl; /** * Replace namespace is a filter to change the namespace of any * elemement attribute passing through it. * * @author Diogo Quintela */ public class ReplaceNamespaceTag extends TagSupport { private String fromNamespace; private String toNamespace; public ReplaceNamespaceTag() { } // Tag interface //------------------------------------------------------------------------- public void doTag(XMLOutput output) throws MissingAttributeException, JellyTagException { final String fromURI = (fromNamespace != null) ? fromNamespace : ""; final String toURI = (toNamespace != null) ? toNamespace : ""; XMLOutput newOutput = output; if (!toURI.equals(fromURI)) { newOutput = new XMLOutput(output) { public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException { super.startElement(replaceURI(uri), localName, qName, replaceURI(atts)); } public void endElement(String uri, String localName, String qName) throws SAXException { super.endElement(replaceURI(uri), localName, qName); } public void startPrefixMapping(String prefix, String uri) throws SAXException { super.startPrefixMapping(prefix, replaceURI(uri)); } private String replaceURI(String uri) { String newUri = uri; if (fromURI.equals((uri != null) ? uri : "")) { newUri = toURI; } return newUri; } private Attributes replaceURI(Attributes atts) { AttributesImpl newAttsImpl = new AttributesImpl(); for (int i = 0; i < atts.getLength(); i++) { // Normally attributes don't have namespaces // But may have (only if on form prefix:attr) ? // So, we'll only replace if needed String QName = atts.getQName(i); String newUri = atts.getURI(i); int idx = QName.indexOf(':'); if (idx >= 0) { newUri = replaceURI(newUri); } newAttsImpl.addAttribute(newUri, atts.getLocalName(i), atts.getQName(i), atts.getType(i), atts.getValue(i)); } return newAttsImpl; } }; } invokeBody(newOutput); } /** * @return the source namespace URI to replace */ public String getFromURI() { return fromNamespace; } /** * Sets the source namespace URI to replace. */ public void setFromURI(String namespace) { this.fromNamespace = namespace; } /** * @return the destination namespace URI to replace */ public String getToURI() { return toNamespace; } /** * Sets the destination namespace URI to replace. */ public void setToURI(String namespace) { this.toNamespace = namespace; } }././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/java/org/apache/commons/jelly/tags/xml/IfTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/java/org/apache/commons/jelly/tags/xml0000664000175000017500000000471111602216727031440 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.xml; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.MissingAttributeException; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.jelly.xpath.XPathTagSupport; import org.jaxen.JaxenException; import org.jaxen.XPath; /** * Evaluates the XPath expression to be a boolean and only evaluates the body * if the expression is true. * @author James Strachan * @version $Revision: 155420 $ */ public class IfTag extends XPathTagSupport { /** The XPath expression to evaluate. */ private XPath select; public IfTag() { } // Tag interface //------------------------------------------------------------------------- public void doTag(XMLOutput output) throws MissingAttributeException, JellyTagException { if (select == null) { throw new MissingAttributeException( "select" ); } Object xpathContext = getXPathContext(); try { if ( select.booleanValueOf(xpathContext) ) { invokeBody(output); } } catch (JaxenException e) { throw new JellyTagException(e); } } // Properties //------------------------------------------------------------------------- /** Sets the XPath expression to evaluate. */ public void setSelect(XPath select) { this.select = select; } // Implementation methods //------------------------------------------------------------------------- protected Object getXPathContext() { ForEachTag tag = (ForEachTag) findAncestorWithClass( ForEachTag.class ); if ( tag != null ) { return tag.getXPathContext(); } return null; } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/java/org/apache/commons/jelly/tags/xml/ForEachTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/java/org/apache/commons/jelly/tags/xml0000664000175000017500000000775311602216727031451 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.xml; import java.util.Iterator; import java.util.List; import java.util.Collections; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.jelly.xpath.XPathComparator; import org.apache.commons.jelly.xpath.XPathSource; import org.apache.commons.jelly.xpath.XPathTagSupport; import org.jaxen.XPath; import org.jaxen.JaxenException; /** A tag which performs an iteration over the results of an XPath expression * * @author James Strachan * @version $Revision: 155420 $ */ public class ForEachTag extends XPathTagSupport implements XPathSource { /** Holds the XPath selector. */ private XPath select; /** Xpath comparator for sorting */ private XPathComparator xpCmp = null; /** If specified then the current item iterated through will be defined * as the given variable name. */ private String var; /** The current iteration value */ private Object iterationValue; public ForEachTag() { } // Tag interface //------------------------------------------------------------------------- public void doTag(XMLOutput output) throws JellyTagException { if (select != null) { List nodes = null; try { nodes = select.selectNodes( getXPathContext() ); } catch (JaxenException e) { throw new JellyTagException(e); } // sort the list if xpCmp is set. if (xpCmp != null && (xpCmp.getXpath() != null)) { Collections.sort(nodes, xpCmp); } Iterator iter = nodes.iterator(); while (iter.hasNext()) { iterationValue = iter.next(); if (var != null) { context.setVariable(var, iterationValue); } invokeBody(output); } } } // XPathSource interface //------------------------------------------------------------------------- /** * @return the current XPath iteration value * so that any other XPath aware child tags to use */ public Object getXPathSource() { return iterationValue; } // Properties //------------------------------------------------------------------------- /** Sets the XPath selection expression */ public void setSelect(XPath select) { this.select = select; } /** Sets the variable name to export for the item being iterated over */ public void setVar(String var) { this.var = var; } /** Sets the xpath expression to use to sort selected nodes. */ public void setSort(XPath sortXPath) throws JaxenException { if (xpCmp == null) xpCmp = new XPathComparator(); xpCmp.setXpath(sortXPath); } /** * Set whether to sort ascending or descending. */ public void setDescending(boolean descending) { if (xpCmp == null) xpCmp = new XPathComparator(); xpCmp.setDescending(descending); } /* * Override superclass so method can be access by IfTag */ protected Object getXPathContext() { return super.getXPathContext(); } } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/java/org/apache/commons/jelly/tags/xml/XMLTagLibrary.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/java/org/apache/commons/jelly/tags/xml0000664000175000017500000000716211602216727031443 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.xml; import org.apache.commons.jelly.JellyException; import org.apache.commons.jelly.TagLibrary; import org.apache.commons.jelly.expression.Expression; import org.apache.commons.jelly.expression.ExpressionFactory; import org.apache.commons.jelly.expression.CompositeExpression; import org.apache.commons.jelly.expression.jexl.JexlExpressionFactory; import org.apache.commons.jelly.expression.xpath.XPathExpression; import org.apache.commons.jelly.impl.TagScript; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** Describes the Taglib. This class could be generated by XDoclet * * @author James Strachan * @version $Revision: 219726 $ */ public class XMLTagLibrary extends TagLibrary { /** The Log to which logging calls will be made. */ private Log log = LogFactory.getLog(XMLTagLibrary.class); private JexlExpressionFactory jexlFactory; public XMLTagLibrary() { registerTag("out", ExprTag.class); registerTag("if", IfTag.class); registerTag("forEach", ForEachTag.class); registerTag("parse", ParseTag.class); registerTag("set", SetTag.class); registerTag("transform", TransformTag.class); registerTag("param", ParamTag.class); // extensions to JSTL registerTag("expr", ExprTag.class); registerTag("element", ElementTag.class); registerTag("attribute", AttributeTag.class); registerTag("replaceNamespace", ReplaceNamespaceTag.class); registerTag("copy", CopyTag.class); registerTag("copyOf", CopyOfTag.class); registerTag("comment", CommentTag.class); registerTag("doctype", DoctypeTag.class); registerTag("sort", SortTag.class); this.jexlFactory = new JexlExpressionFactory(); } public Expression createExpression( ExpressionFactory factory, TagScript tagScript, String attributeName, String attributeValue) throws JellyException { // #### may need to include some namespace URI information in the XPath instance? if (attributeName.equals("select") || attributeName.equals("sort")) { if ( log.isDebugEnabled() ) { log.debug( "Parsing XPath expression: " + attributeValue ); } Expression xpathExpr = createXPathTextExpression( attributeValue ); return new XPathExpression(attributeValue, xpathExpr, tagScript); } // will use the default expression instead return super.createExpression(factory, tagScript, attributeName, attributeValue); } protected Expression createXPathTextExpression(String exprText) throws JellyException { return CompositeExpression.parse( exprText, this.jexlFactory ); } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/java/org/apache/commons/jelly/tags/xml/DoctypeTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/java/org/apache/commons/jelly/tags/xml0000664000175000017500000000561711602216727031446 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.xml; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.MissingAttributeException; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.jelly.xpath.XPathTagSupport; import org.xml.sax.SAXException; /** * A tag which outputs a DOCTYPE declaration to the current XML output pipe. * Note that there should only be a single DOCTYPE declaration in any XML stream and * it should occur before any element content. * * @author James Strachan * @version $Revision: 155420 $ */ public class DoctypeTag extends XPathTagSupport { private String name; private String publicId; private String systemId; public DoctypeTag() { } // Tag interface //------------------------------------------------------------------------- public void doTag(XMLOutput output) throws MissingAttributeException, JellyTagException { if (name == null) { throw new MissingAttributeException( "name" ); } try { output.startDTD(name, publicId, systemId); invokeBody(output); output.endDTD(); } catch (SAXException e) { throw new JellyTagException(e); } } // Properties //------------------------------------------------------------------------- /** * Returns the name. * @return String */ public String getName() { return name; } /** * Returns the publicId. * @return String */ public String getPublicId() { return publicId; } /** * Returns the systemId. * @return String */ public String getSystemId() { return systemId; } /** * Sets the document type name of the DOCTYPE */ public void setName(String name) { this.name = name; } /** * Sets the declared public identifier for DTD */ public void setPublicId(String publicId) { this.publicId = publicId; } /** * Sets the declared system identifier for the DTD */ public void setSystemId(String systemId) { this.systemId = systemId; } } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/java/org/apache/commons/jelly/tags/xml/SortTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/java/org/apache/commons/jelly/tags/xml0000664000175000017500000000456411602216727031446 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.xml; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.jelly.MissingAttributeException; import org.apache.commons.jelly.xpath.XPathComparator; import org.apache.commons.jelly.xpath.XPathTagSupport; import org.jaxen.XPath; import org.jaxen.JaxenException; import java.util.List; import java.util.Collections; /** A tag that can sort a list of xml nodes via an xpath expression. * * @author Jason Horman * @version $Id: SortTag.java 155420 2005-02-26 13:06:03Z dirkv $ */ public class SortTag extends XPathTagSupport { /** The list to sort */ private List list = null; /** Xpath comparator for sorting */ private XPathComparator xpCmp = null; public void doTag(XMLOutput output) throws MissingAttributeException, JellyTagException { if (xpCmp == null) { throw new MissingAttributeException( "xpCmp" ); } if (list == null) { throw new MissingAttributeException( "list" ); } Collections.sort(list, xpCmp); } /** Set the list to sort. */ public void setList(List list) { this.list = list; } /** Sets the xpath expression to use to sort selected nodes. */ public void setSort(XPath sortXPath) throws JaxenException { if (xpCmp == null) xpCmp = new XPathComparator(); xpCmp.setXpath(sortXPath); } /** * Set whether to sort ascending or descending. */ public void setDescending(boolean descending) { if (xpCmp == null) xpCmp = new XPathComparator(); xpCmp.setDescending(descending); } } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/java/org/apache/commons/jelly/tags/xml/package.htmljenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/java/org/apache/commons/jelly/tags/xml0000664000175000017500000000013611602216727031435 0ustar davedave

The XML Tags from the JSTL

././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/java/org/apache/commons/jelly/tags/xml/ElementTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/java/org/apache/commons/jelly/tags/xml0000664000175000017500000001445411602216727031445 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.xml; import org.apache.commons.jelly.JellyException; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.XMLOutput; import org.xml.sax.Attributes; import org.xml.sax.SAXException; import org.xml.sax.helpers.AttributesImpl; /** A tag to produce an XML element which can contain other attributes * or elements like the <xsl:element> tag. * * @author James Strachan * @version $Revision: 219726 $ */ public class ElementTag extends TagSupport { /** The namespace URI. */ private String namespace; /** The qualified name. */ private String name; /** The XML Attributes. */ private AttributesImpl attributes = new AttributesImpl(); /** flag set if attributes are output. */ private boolean outputAttributes; public ElementTag() { } /** * Sets the attribute of the given name to the specified value. * * @param name of the attribute * @param value of the attribute * @param uri namespace of the attribute * @throws JellyTagException if the start element has already been output. * Attributes must be set on the outer element before any content * (child elements or text) is output */ public void setAttributeValue(String name, String value, String uri) throws JellyTagException { if (outputAttributes) { throw new JellyTagException( "Cannot set the value of attribute: " + name + " as we have already output the startElement() SAX event" ); } // ### we'll assume that all attributes are in no namespace! // ### this is severely limiting! // ### we should be namespace aware // NAMESPACE FIXED: int idx = name.indexOf(':'); final String localName = (idx >= 0) ? name.substring(idx + 1) : name; final String nsUri = (uri != null) ? uri : ""; int index = attributes.getIndex(nsUri, localName); if (index >= 0) { attributes.removeAttribute(index); } // treat null values as no attribute if (value != null) { attributes.addAttribute(nsUri, localName, name, "CDATA", value); } } // Tag interface //------------------------------------------------------------------------- public void doTag(XMLOutput output) throws JellyTagException { int idx = name.indexOf(':'); final String localName = (idx >= 0) ? name.substring(idx + 1) : name; outputAttributes = false; XMLOutput newOutput = new XMLOutput(output) { // add an initialize hook to the core content-generating methods public void startElement( String uri, String localName, String qName, Attributes atts) throws SAXException { initialize(); super.startElement(uri, localName, qName, atts); } public void endElement(String uri, String localName, String qName) throws SAXException { initialize(); super.endElement(uri, localName, qName); } public void characters(char[] ch, int start, int length) throws SAXException { initialize(); super.characters(ch, start, length); } public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException { initialize(); super.ignorableWhitespace(ch, start, length); } public void objectData(Object object) throws SAXException { initialize(); super.objectData(object); } public void processingInstruction(String target, String data) throws SAXException { initialize(); super.processingInstruction(target, data); } /** * Ensure that the outer start element is generated * before any content is output. */ protected void initialize() throws SAXException { if (!outputAttributes) { super.startElement(namespace, localName, name, attributes); outputAttributes = true; } } }; invokeBody(newOutput); try { if (!outputAttributes) { output.startElement(namespace, localName, name, attributes); outputAttributes = true; } output.endElement(namespace, localName, name); attributes.clear(); } catch (SAXException e) { throw new JellyTagException(e); } } // Properties //------------------------------------------------------------------------- /** * @return the qualified name of the element */ public String getName() { return name; } /** * Sets the qualified name of the element */ public void setName(String name) { this.name = name; } /** * @return the namespace URI of the element */ public String getURI() { return namespace; } /** * Sets the namespace URI of the element */ public void setURI(String namespace) { this.namespace = namespace; } } ././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/java/org/apache/commons/jelly/tags/xml/ParseTagSupport.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/java/org/apache/commons/jelly/tags/xml0000664000175000017500000001362311602216727031442 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.xml; import java.io.File; import java.io.InputStream; import java.io.Reader; import java.io.StringReader; import java.net.MalformedURLException; import java.net.URL; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.dom4j.Document; import org.dom4j.DocumentException; import org.dom4j.io.SAXContentHandler; import org.dom4j.io.SAXReader; import org.xml.sax.SAXException; /** * An abstract base class for any tag which parsers its body as XML. * * @author James Strachan * @version $Revision: 155420 $ */ public abstract class ParseTagSupport extends TagSupport { /** The Log to which logging calls will be made. */ private static final Log log = LogFactory.getLog(ParseTagSupport.class); /** The variable that will be generated for the document */ private String var; /** The markup text to be parsed */ private String text; /** The SAXReader used to parser the document */ private SAXReader saxReader; public ParseTagSupport() { } // Properties //------------------------------------------------------------------------- /** The variable name that will be used for the Document variable created */ public String getVar() { return var; } /** Sets the variable name that will be used for the Document variable created */ public void setVar(String var) { this.var = var; } /** * Returns the text to be parsed * @return String */ public String getText() { return text; } /** * Sets the text to be parsed by this parser * @param text The text to be parsed by this parser */ public void setText(String text) { this.text = text; } /** @return the SAXReader used for parsing, creating one lazily if need be */ public SAXReader getSAXReader() throws SAXException { if (saxReader == null) { saxReader = createSAXReader(); } return saxReader; } /** Sets the SAXReader used for parsing */ public void setSAXReader(SAXReader saxReader) { this.saxReader = saxReader; } // Implementation methods //------------------------------------------------------------------------- /** * Factory method to create a new SAXReader */ protected abstract SAXReader createSAXReader() throws SAXException; /** * Parses the body of this tag and returns the parsed document */ protected Document parseBody(XMLOutput output) throws JellyTagException { SAXContentHandler handler = new SAXContentHandler(); XMLOutput newOutput = new XMLOutput(handler); try { handler.startDocument(); invokeBody( newOutput); handler.endDocument(); return handler.getDocument(); } catch (SAXException e) { throw new JellyTagException(e); } } /** * Parses the give piece of text as being markup */ protected Document parseText(String text) throws JellyTagException { if ( log.isDebugEnabled() ) { log.debug( "About to parse: " + text ); } try { return getSAXReader().read( new StringReader( text ) ); } catch (DocumentException e) { throw new JellyTagException(e); } catch (SAXException e) { throw new JellyTagException(e); } } /** * Parses the given source */ protected Document parse(Object source) throws JellyTagException { // #### we should allow parsing to output XML events to // the output if no var is specified try { if (source instanceof String) { String uri = (String) source; source = context.getResource(uri); } if (source instanceof URL) { return getSAXReader().read((URL) source); } else if (source instanceof File) { return getSAXReader().read((File) source); } else if (source instanceof Reader) { return getSAXReader().read((Reader) source); } else if (source instanceof InputStream) { return getSAXReader().read((InputStream) source); } else { throw new IllegalArgumentException( "Invalid source argument. Must be a String, Reader, InputStream or URL." + " Was type; " + source.getClass().getName() + " with value: " + source); } } catch (DocumentException e) { throw new JellyTagException(e); } catch (SAXException e) { throw new JellyTagException(e); } catch (MalformedURLException e) { throw new JellyTagException(e); } } } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/java/org/apache/commons/jelly/tags/xml/ExprTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/java/org/apache/commons/jelly/tags/xml0000664000175000017500000000441611602216727031442 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.xml; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.MissingAttributeException; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.jelly.xpath.XPathTagSupport; import org.jaxen.JaxenException; import org.jaxen.XPath; import org.xml.sax.SAXException; /** A tag which performs a string XPath expression; similar to <xsl:value-of> * in XSLT * * @author James Strachan * @version $Revision: 155420 $ */ public class ExprTag extends XPathTagSupport { /** The XPath expression to evaluate. */ private XPath select; public ExprTag() { } // Tag interface //------------------------------------------------------------------------- public void doTag(XMLOutput output) throws MissingAttributeException, JellyTagException { Object xpathContext = getXPathContext(); if (select == null) { throw new MissingAttributeException( "select" ); } try { String text = select.stringValueOf(xpathContext); if ( text != null ) { output.write(text); } } catch (SAXException e) { throw new JellyTagException(e); } catch (JaxenException e) { throw new JellyTagException(e); } } // Properties //------------------------------------------------------------------------- /** Sets the XPath expression to evaluate. */ public void setSelect(XPath select) { this.select = select; } } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/java/org/apache/commons/jelly/tags/xml/SetTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/java/org/apache/commons/jelly/tags/xml0000664000175000017500000002447011602216727031444 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.xml; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.MissingAttributeException; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.jelly.xpath.XPathComparator; import org.apache.commons.jelly.xpath.XPathTagSupport; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.dom4j.Node; import org.jaxen.XPath; import org.jaxen.JaxenException; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.ListIterator; /** A tag which defines a variable from an XPath expression. * This function creates a variable of type {@link List} or {@link org.dom4j.Node} * (for example {@link org.dom4j.Element} or {@link org.dom4j.Attribute}). * Thus, the variable created from xml:set can be * used from the other xml library functions. * * @author James Strachan * @version $Revision: 155420 $ */ public class SetTag extends XPathTagSupport { private static final int RETURN_NODE_LIST = 0; private static final int RETURN_FIRST_NODE = 1; private static final int RETURN_STRING_LIST = 2; private static final int RETURN_DELIMITED_STRING_LIST = 3; private static final int RETURN_FIRST_AS_STRING = 4; /** The Log to which logging calls will be made. */ private Log log = LogFactory.getLog(SetTag.class); /** The variable name to export. */ private String var; /** The XPath expression to evaluate. */ private XPath select; /** Xpath comparator for sorting */ private XPathComparator xpCmp = null; private Boolean single = null; private Boolean asString = null; private String delimiter = null; private String delim = null; public SetTag() { } // Tag interface //------------------------------------------------------------------------- public void doTag(XMLOutput output) throws MissingAttributeException, JellyTagException { if (var == null) { throw new MissingAttributeException( "var" ); } if (select == null) { throw new MissingAttributeException( "select" ); } Object xpathContext = getXPathContext(); Object value = null; try { if( single != null && single.booleanValue() == true ) { value = select.selectSingleNode(xpathContext); } else { value = select.evaluate(xpathContext); } } catch (JaxenException e) { throw new JellyTagException(e); } if (value instanceof List) { List list = (List) value; // sort the list if xpCmp is set. if (xpCmp != null && (xpCmp.getXpath() != null)) { Collections.sort(list, xpCmp); } if(list.isEmpty()) { value = null; } } // handle single if (single!=null) { if (single.booleanValue() == true) { if(value instanceof List) { List l = (List) value; if (l.size() == 0) value=null; else value=l.get(0); } } else { // single == false if(! (value instanceof List) ) { List l = null; if (value==null) { l = new ArrayList(0); } else { l = new ArrayList(1); l.add(value); } value = l; } } } // now convert the result(s) to string if need if(asString != null && asString.booleanValue()) { if(value instanceof Node) { value = ((Node) value).getStringValue(); } else if(value instanceof List) { for(ListIterator it = ((List) value).listIterator(); it.hasNext(); ) { Object v = it.next(); if(v instanceof Node) { v = ((Node) v).getStringValue(); it.set(v); } } } } // finally convert the result to a concatenated string if delimiter is defined if(delimiter != null && value instanceof List) { StringBuffer buff = new StringBuffer(); for(Iterator it = ((List) value).iterator(); it.hasNext(); ) { Object v = it.next(); if (v instanceof Node) { buff.append( ((Node) v).getStringValue()); } else { buff.append(v.toString()); } if(it.hasNext()) { buff.append(delimiter); } } buff.setLength(buff.length()); value = buff.toString(); } //log.info( "Evaluated xpath: " + select + " as: " + value + " of type: " + value.getClass().getName() ); context.setVariable(var, value); } private List valueAsList( final Object value ) { if (value instanceof List) { return (List)value; } else { if (value == null) { return Collections.EMPTY_LIST; } else { return Collections.singletonList(value); } } } private Object valueAsSingle( final Object value ) { if (value instanceof List) { List l = (List) value; if (l.isEmpty()) return null; else return l.get(0); } else { return value; } } private String singleValueAsString( final Object value ) { if (value instanceof Node) { return ((Node) value).getStringValue(); } else { return null; } } private List nodeListToStringList( final List values ) { List l = new ArrayList(values.size()); for (Iterator it = values.iterator(); it.hasNext(); ) { Object v = it.next(); String s = singleValueAsString(v); if (s != null) { l.add(s); } } return l; } private String joinDelimitedElements( final List values ) { StringBuffer sb = new StringBuffer(); int sz = values.size(); for (int i = 0; i < sz; i++) { String s = (String)values.get(i); sb.append(s); if (i < sz - 1) sb.append(delim); } return sb.toString(); } private int determineReturnType() { int resultType; if (single != null && single.booleanValue()) { // first node if (asString != null && asString.booleanValue()) { resultType = RETURN_FIRST_AS_STRING; } else { resultType = RETURN_FIRST_NODE; } } else { // all nodes if (asString != null && asString.booleanValue()) { if (delim != null) { resultType = RETURN_DELIMITED_STRING_LIST; } else { resultType = RETURN_STRING_LIST; } } else { resultType = RETURN_NODE_LIST; } } return resultType; } // Properties //------------------------------------------------------------------------- /** Sets the variable name to define for this expression */ public void setVar(String var) { this.var = var; } /** Sets the XPath expression to evaluate. */ public void setSelect(XPath select) { this.select = select; } /** If set to true will only take the first element matching. It then guarantees that the result is of type {@link org.dom4j.Node} thereby making sure that, for example, when an element is selected, one can directly call such methods as setAttribute.
If set to false, guarantees that a list is returned. If set to false, guarantees that a list is returned. */ public void setSingle(boolean single) { this.single = new Boolean(single); } /** If set to true, will ensure that the (XPath) text-value * of the selected node is taken instead of the node * itself. * This ensures that, thereafter, string manipulations * can be performed on the result. */ public void setAsString(boolean asString) { this.asString = new Boolean(asString); } /** If set, returns a string delimited by this delimiter. * Implies asString to be true. */ public void setDelim(String delim) { this.delimiter = delim; if( delim!=null ) { this.asString = Boolean.TRUE; } } /** Sets the xpath expression to use to sort selected nodes. * Ignored if single is true. */ public void setSort(XPath sortXPath) throws JaxenException { if (xpCmp == null) xpCmp = new XPathComparator(); xpCmp.setXpath(sortXPath); } /** * Set whether to sort ascending or descending. */ public void setDescending(boolean descending) { if (xpCmp == null) xpCmp = new XPathComparator(); xpCmp.setDescending(descending); } } ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/java/org/apache/commons/jelly/tags/xml/TransformTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/java/org/apache/commons/jelly/tags/xml0000664000175000017500000006176011602216727031447 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.xml; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.Reader; import java.io.StringReader; import java.io.StringWriter; import java.net.MalformedURLException; import java.net.URL; import java.util.Iterator; import java.util.List; import javax.xml.transform.Result; import javax.xml.transform.Source; import javax.xml.transform.TransformerConfigurationException; import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; import javax.xml.transform.URIResolver; import javax.xml.transform.sax.SAXResult; import javax.xml.transform.sax.SAXSource; import javax.xml.transform.sax.SAXTransformerFactory; import javax.xml.transform.sax.TransformerHandler; import javax.xml.transform.stream.StreamSource; import org.apache.commons.jelly.JellyContext; import org.apache.commons.jelly.JellyException; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.MissingAttributeException; import org.apache.commons.jelly.Script; import org.apache.commons.jelly.Tag; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.jelly.impl.ScriptBlock; import org.apache.commons.jelly.impl.StaticTagScript; import org.apache.commons.jelly.impl.TagScript; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.dom4j.Document; import org.dom4j.io.DocumentResult; import org.dom4j.io.DocumentSource; import org.xml.sax.ContentHandler; import org.xml.sax.DTDHandler; import org.xml.sax.EntityResolver; import org.xml.sax.ErrorHandler; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.SAXNotRecognizedException; import org.xml.sax.SAXNotSupportedException; import org.xml.sax.XMLReader; import org.xml.sax.ext.LexicalHandler; import org.xml.sax.helpers.XMLReaderFactory; /** A tag which parses some XML, applies an xslt transform to it * and defines a variable with the transformed Document. * The XML can either be specified as its body or can be passed in via the * xml property which can be a Reader, InputStream, URL or String URI. * * The XSL can be passed in via the * xslt property which can be a Reader, InputStream, URL or String URI. * * @author Robert Leftwich * @version $Revision: 155420 $ */ public class TransformTag extends ParseTag { /** The Log to which logging calls will be made. */ private static final Log log = LogFactory.getLog(TransformTag.class); /** Propert name for lexical handler */ private static final String LEXICAL_HANDLER_PROPERTY = "http://xml.org/sax/properties/lexical-handler"; /** The xslt to parse, either a String URI, a Reader or InputStream */ private Object xslt; /** The xsl transformer factory */ private SAXTransformerFactory tf; /** the transformer handler, doing the real work */ private TransformerHandler transformerHandler; /** * Constructor for TransformTag. */ public TransformTag() { super(); this.tf = (SAXTransformerFactory) TransformerFactory.newInstance(); } // Tag interface //------------------------------------------------------------------------- /** * Process this tag instance * * @param output The pipeline for xml events * @throws Exception - when required attributes are missing */ public void doTag(XMLOutput output) throws MissingAttributeException, JellyTagException { if (null == this.getXslt()) { throw new MissingAttributeException("The xslt attribute cannot be null"); } // set a resolver to locate uri this.tf.setURIResolver(createURIResolver()); try { this.transformerHandler = this.tf.newTransformerHandler(this.getObjAsSAXSource(this.getXslt())); } catch (TransformerConfigurationException e) { throw new JellyTagException(e); } // run any nested param tags this.doNestedParamTag(output); try { // get a reader to provide SAX events to transformer XMLReader xmlReader = this.createXMLReader(); xmlReader.setContentHandler(this.transformerHandler); xmlReader.setProperty(LEXICAL_HANDLER_PROPERTY, this.transformerHandler); // handle result differently, depending on if var is specified String varName = this.getVar(); if (null == varName) { // pass the result of the transform out as SAX events this.transformerHandler.setResult(this.createSAXResult(output)); xmlReader.parse(this.getXMLInputSource()); } else { // pass the result of the transform out as a document DocumentResult result = new DocumentResult(); this.transformerHandler.setResult(result); xmlReader.parse(this.getXMLInputSource()); // output the result as a variable Document transformedDoc = result.getDocument(); this.context.setVariable(varName, transformedDoc); } } catch (SAXException e) { throw new JellyTagException(e); } catch (IOException e) { throw new JellyTagException(e); } } // Properties //------------------------------------------------------------------------- /** * Gets the source of the XSL which is either a String URI, Reader or * InputStream * * @returns xslt The source of the xslt */ public Object getXslt() { return this.xslt; } /** * Sets the source of the XSL which is either a String URI, Reader or * InputStream * * @param xslt The source of the xslt */ public void setXslt(Object xslt) { this.xslt = xslt; } public void setParameterValue(String name, Object value) { this.transformerHandler.getTransformer().setParameter(name, value); } // Implementation methods //------------------------------------------------------------------------- /** * Creates a new URI Resolver so that URIs inside the XSLT document can be * resolved using the JellyContext * * @return a URI Resolver for the JellyContext */ protected URIResolver createURIResolver() { return new URIResolver() { public Source resolve(String href, String base) throws TransformerException { if (log.isDebugEnabled() ) { log.debug( "base: " + base + " href: " + href ); } // pass if we don't have a systemId if (null == href) return null; // @todo // #### this is a pretty simplistic implementation. // #### we should really handle this better such that if // #### base is specified as an absolute URL // #### we trim the end off it and append href return new StreamSource(context.getResourceAsStream(href)); } }; } /** * Factory method to create a new SAXResult for the given * XMLOutput so that the output of an XSLT transform will go * directly into the XMLOutput that we are given. * * @param output The destination of the transform output * @return A SAXResult for the transfrom output */ protected Result createSAXResult(XMLOutput output) { SAXResult result = new SAXResult(output); result.setLexicalHandler(output); return result; } /** * Factory method to create a new XMLReader for this tag * so that the input of the XSLT transform comes from * either the xml var, the nested tag or the tag body. * * @return XMLReader for the transform input * @throws SAXException * If the value of the "org.xml.sax.driver" system property * is null, or if the class cannot be loaded and instantiated. */ protected XMLReader createXMLReader() throws SAXException { XMLReader xmlReader = null; Object xmlReaderSourceObj = this.getXml(); // if no xml source specified then get from body // otherwise convert it to a SAX source if (null == xmlReaderSourceObj) { xmlReader = new TagBodyXMLReader(this); } else { xmlReader = XMLReaderFactory.createXMLReader(); } return xmlReader; } /** * Helper method to get the appropriate xml input source * so that the input of the XSLT transform comes from * either the xml var, the nested tag or the tag body. * * @return InputSource for the transform input */ protected InputSource getXMLInputSource() { InputSource xmlInputSource = null; Object xmlInputSourceObj = this.getXml(); // if no xml source specified then get from tag body // otherwise convert it to an input source if (null == xmlInputSourceObj) { xmlInputSource = new TagBodyInputSource(); } else { xmlInputSource = this.getInputSourceFromObj(xmlInputSourceObj); } return xmlInputSource; } /** * Helper method to convert the specified object to a SAX source * * @return SAXSource from the source object or null */ protected SAXSource getObjAsSAXSource(Object saxSourceObj) { SAXSource saxSource = null; if (null != saxSourceObj) { if (saxSourceObj instanceof Document) { saxSource = new DocumentSource((Document) saxSourceObj); } else { InputSource xmlInputSource = this.getInputSourceFromObj(saxSourceObj); saxSource = new SAXSource(xmlInputSource); } } return saxSource; } /** * Helper method to get an xml input source for the supplied object * * @return InputSource for the object or null */ protected InputSource getInputSourceFromObj(Object sourceObj ) { InputSource xmlInputSource = null; if (sourceObj instanceof Document) { SAXSource saxSource = new DocumentSource((Document) sourceObj); xmlInputSource = saxSource.getInputSource(); } else { if (sourceObj instanceof String) { String uri = (String) sourceObj; xmlInputSource = new InputSource(context.getResourceAsStream(uri)); } else if (sourceObj instanceof Reader) { xmlInputSource = new InputSource((Reader) sourceObj); } else if (sourceObj instanceof InputStream) { xmlInputSource = new InputSource((InputStream) sourceObj); } else if (sourceObj instanceof URL) { String uri = ((URL) sourceObj).toString(); xmlInputSource = new InputSource(context.getResourceAsStream(uri)); } else if (sourceObj instanceof File) { try { String uri = ((File) sourceObj).toURL().toString(); xmlInputSource = new InputSource(context.getResourceAsStream(uri)); } catch (MalformedURLException e) { throw new IllegalArgumentException( "This should never occur. We should always be able to convert a File to a URL" + e ); } } else { throw new IllegalArgumentException( "Invalid source argument. Must be a String, Reader, InputStream or URL." + " Was type; " + sourceObj.getClass().getName() + " with value: " + sourceObj); } } return xmlInputSource; } /** * Helper method to run any nested param tags * * @param output The destination for any SAX output (not actually used) */ private void doNestedParamTag(XMLOutput output) throws JellyTagException { // find any nested param tags and run them Script bodyScript = this.getBody(); if (bodyScript instanceof ScriptBlock) { ScriptBlock scriptBlock = (ScriptBlock) bodyScript; List scriptList = scriptBlock.getScriptList(); for (Iterator iter = scriptList.iterator(); iter.hasNext(); ) { Script script = (Script) iter.next(); if (script instanceof TagScript) { Tag tag = null; try { tag = ((TagScript) script).getTag(getContext()); } catch (JellyException e) { throw new JellyTagException(e); } if (tag instanceof ParamTag) { script.run(context, output); } } } } } /** A helper class that converts a transform tag body to an XMLReader * to hide the details of where the input for the transform is obtained * * @author Robert Leftwich * @version $Revision: 155420 $ */ private class TagBodyXMLReader implements XMLReader { /** The tag whose body is to be read. */ private Tag tag; /** The destination for the sax events generated by the reader. */ private XMLOutput xmlOutput; /** Storage for a DTDHandler if set by the user of the reader. */ private DTDHandler dtdHandler; /** Storage for a ErrorHandler if set by the user of the reader. */ private ErrorHandler errorHandler; /** Storage for a EntityResolver if set by the user of the reader. */ private EntityResolver entityResolver; /** * Construct an XMLReader for the specified Tag * * @param tag The Tag to convert to an XMLReader */ public TagBodyXMLReader(Tag tag) { this.tag = tag; this.xmlOutput = new XMLOutput(); } // Methods //------------------------------------------------------------------------- /** * Parse an XML source. * * @param input The source of the xml * @throws SAXException - * Any SAX exception, possibly wrapping another exception. * @throws IOException - * An IO exception from the parser, possibly from a byte stream or character stream supplied by the application. */ public void parse(InputSource input) throws IOException, SAXException { // safety check that we are being used correctly if (input instanceof TagBodyInputSource) { this.doInvokeBody(); } else { throw new SAXException("Invalid input source"); } } /** * Parse an XML source specified by a system id * * @param input The system identifier (URI) * @throws SAXException - * Any SAX exception, possibly wrapping another exception. * @throws IOException - * An IO exception from the parser, possibly from a byte stream or character stream supplied by the application. */ public void parse(String systemId) throws IOException, SAXException { this.doInvokeBody(); } // Helper methods //------------------------------------------------------------------------- /** * Actually invoke the tag body to generate the SAX events * * @throws SAXException - * Any SAX exception, possibly wrapping another exception. */ private void doInvokeBody() throws SAXException { try { if (this.shouldParseBody()) { XMLReader anXMLReader = XMLReaderFactory.createXMLReader(); anXMLReader.setContentHandler(this.xmlOutput); anXMLReader.setProperty(LEXICAL_HANDLER_PROPERTY,this.xmlOutput); StringWriter writer = new StringWriter(); this.tag.invokeBody(XMLOutput.createXMLOutput(writer)); Reader reader = new StringReader(writer.toString()); anXMLReader.parse(new InputSource(reader)); } else { this.tag.invokeBody(this.xmlOutput); } } catch (Exception ex) { throw new SAXException(ex); } } /** * Helper method to determin if nested body needs to be parsed by (an * xml parser, i.e. its only text) to generate SAX events or not * * @return True if tag body should be parsed or false if invoked only * @throws JellyTagException */ private boolean shouldParseBody() throws JellyTagException { boolean result = false; // check to see if we need to parse the body or just invoke it Script bodyScript = this.tag.getBody(); if (bodyScript instanceof ScriptBlock) { ScriptBlock scriptBlock = (ScriptBlock) bodyScript; List scriptList = scriptBlock.getScriptList(); for (Iterator iter = scriptList.iterator(); iter.hasNext(); ) { Script script = (Script) iter.next(); if (script instanceof StaticTagScript) { result = true; break; } } } return result; } // Properties //------------------------------------------------------------------------- /** * Gets the SAX ContentHandler to feed SAX events into * * @return the SAX ContentHandler to use to feed SAX events into */ public ContentHandler getContentHandler() { return this.xmlOutput.getContentHandler(); } /** * Sets the SAX ContentHandler to feed SAX events into * * @param contentHandler is the ContentHandler to use. * This value cannot be null. */ public void setContentHandler(ContentHandler contentHandler) { this.xmlOutput.setContentHandler(contentHandler); // often classes will implement LexicalHandler as well if (contentHandler instanceof LexicalHandler) { this.xmlOutput.setLexicalHandler((LexicalHandler) contentHandler); } } /** * Gets the DTD Handler to feed SAX events into * * @return the DTD Handler to use to feed SAX events into */ public DTDHandler getDTDHandler() { return this.dtdHandler; } /** * Sets the DTD Handler to feed SAX events into * * @param the DTD Handler to use to feed SAX events into */ public void setDTDHandler(DTDHandler dtdHandler) { this.dtdHandler = dtdHandler; } /** * Gets the Error Handler to feed SAX events into * * @return the Error Handler to use to feed SAX events into */ public ErrorHandler getErrorHandler() { return this.errorHandler; } /** * Sets the Error Handler to feed SAX events into * * @param the Error Handler to use to feed SAX events into */ public void setErrorHandler(ErrorHandler errorHandler) { // save the error handler this.errorHandler = errorHandler; } /** * Gets the Entity Resolver to feed SAX events into * * @return the Entity Resolver to use to feed SAX events into */ public EntityResolver getEntityResolver() { return this.entityResolver; } /** * Sets the Entity Resolver to feed SAX events into * * @param the Entity Resolver to use to feed SAX events into */ public void setEntityResolver(EntityResolver entityResolver) { this.entityResolver = entityResolver; } /** * Lookup the value of a property * * @param name - The property name, which is a fully-qualified URI. * @return - The current value of the property. * @throws SAXNotRecognizedException - * When the XMLReader does not recognize the property name. * @throws SAXNotSupportedException - * When the XMLReader recognizes the property name but * cannot determine its value at this time. */ public Object getProperty(String name) throws SAXNotRecognizedException, SAXNotSupportedException { // respond to the lexical handler request if (name.equalsIgnoreCase(LEXICAL_HANDLER_PROPERTY)) { return this.xmlOutput.getLexicalHandler(); } else { // do nothing return null; } } /** * Set the value of a property * * @param name - The property name, which is a fully-qualified URI. * @param value - The property value * @throws SAXNotRecognizedException - * When the XMLReader does not recognize the property name. * @throws SAXNotSupportedException - * When the XMLReader recognizes the property name but * cannot determine its value at this time. */ public void setProperty(String name, Object value) throws SAXNotRecognizedException, SAXNotSupportedException { // respond to the lexical handler setting if (name.equalsIgnoreCase(LEXICAL_HANDLER_PROPERTY)) { this.xmlOutput.setLexicalHandler((LexicalHandler) value); } } /** * Lookup the value of a feature * * @param name - The feature name, which is a fully-qualified URI. * @return - The current state of the feature (true or false) * @throws SAXNotRecognizedException - * When the XMLReader does not recognize the feature name. * @throws SAXNotSupportedException - * When the XMLReader recognizes the feature name but * cannot determine its value at this time. */ public boolean getFeature(String name) throws SAXNotRecognizedException, SAXNotSupportedException { // do nothing return false; } /** * Set the value of a feature * * @param name - The feature name, which is a fully-qualified URI. * @param value - The current state of the feature (true or false) * @throws SAXNotRecognizedException - * When the XMLReader does not recognize the feature name. * @throws SAXNotSupportedException - * When the XMLReader recognizes the feature name but * cannot determine its value at this time. */ public void setFeature(String name, boolean value) throws SAXNotRecognizedException, SAXNotSupportedException { // do nothing } } /** A marker class used by the TagBodyXMLReader as a sanity check * (i.e. The source is not actually used) * */ private class TagBodyInputSource extends InputSource { /** * Construct an instance of this marker class */ public TagBodyInputSource() { } } } ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/java/org/apache/commons/jelly/tags/xml/CopyOfTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/java/org/apache/commons/jelly/tags/xml0000664000175000017500000000651711602216727031446 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.xml; import java.util.Iterator; import java.util.List; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.MissingAttributeException; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.jelly.xpath.XPathTagSupport; import org.dom4j.Node; import org.dom4j.io.SAXWriter; import org.jaxen.JaxenException; import org.jaxen.XPath; import org.xml.sax.SAXException; /** A tag which performs a copy-of operation like the XSLT tag * * @author James Strachan */ public class CopyOfTag extends XPathTagSupport { /** The XPath expression to evaluate. */ private XPath select; /** Should we output lexical XML data like comments * or entity names? */ private boolean lexical; public CopyOfTag() { } // Tag interface //------------------------------------------------------------------------- public void doTag(XMLOutput output) throws MissingAttributeException, JellyTagException { Object xpathContext = getXPathContext(); if (select == null) { throw new MissingAttributeException( "select" ); } SAXWriter saxWriter; if (lexical) { saxWriter = new SAXWriter(output, output); } else { saxWriter = new SAXWriter(output); } Object obj; try { obj = select.evaluate(xpathContext); } catch (JaxenException e) { throw new JellyTagException("Failed to evaluate XPath expression", e); } try { if (obj instanceof List) { List nodes = (List) obj; for (Iterator iter = nodes.iterator(); iter.hasNext(); ) { Object object = iter.next(); if ( object instanceof Node ) { saxWriter.write( (Node) object ); } else if (object != null ) { saxWriter.write( object.toString() ); } } } else if (obj instanceof Node) { saxWriter.write( (Node) obj ); } else { saxWriter.write( obj.toString() ); } } catch (SAXException e) { throw new JellyTagException("Failed to write XML output.", e); } } // Properties //------------------------------------------------------------------------- /** Sets the XPath expression to evaluate. */ public void setSelect(XPath select) { this.select = select; } public void setLexical(boolean lexical) { this.lexical = lexical; } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/java/org/apache/commons/jelly/tags/xml/CommentTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/java/org/apache/commons/jelly/tags/xml0000664000175000017500000000420011602216727031431 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.xml; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.jelly.xpath.XPathTagSupport; import org.xml.sax.SAXException; /** * A tag which outputs a comment to the underlying XMLOutput based on the * contents of its body. * * @author James Strachan * @version $Revision: 155420 $ */ public class CommentTag extends XPathTagSupport { private String text; public CommentTag() { } // Tag interface //------------------------------------------------------------------------- public void doTag(XMLOutput output) throws JellyTagException { String text = getText(); if (text == null) { text = getBodyText(false); } char[] ch = text.toCharArray(); try { output.comment(ch, 0, ch.length); } catch (SAXException e) { throw new JellyTagException(e); } } // Properties //------------------------------------------------------------------------- /** * Returns the text. * @return String */ public String getText() { return text; } /** * Sets the comment text. If no text is specified then the body of the tag * is used instead. * * @param text The comment text to use */ public void setText(String text) { this.text = text; } }././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/java/org/apache/commons/jelly/tags/xml/ParseTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/java/org/apache/commons/jelly/tags/xml0000664000175000017500000000725011602216727031441 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.xml; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.MissingAttributeException; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.dom4j.Document; import org.dom4j.io.SAXReader; /** A tag which parses some XML and defines a variable with the parsed Document. * The XML can either be specified as its body or can be passed in via the * xml property which can be a Reader, InputStream, URL or String URI. * * @author James Strachan * @version $Revision: 155420 $ */ public class ParseTag extends ParseTagSupport { /** The Log to which logging calls will be made. */ private static final Log log = LogFactory.getLog(ParseTag.class); /** The xml to parse, either a String URI, a Reader or InputStream */ private Object xml; // Optional properties not defined in JSTL /** whether XML validation is enabled or disabled */ private boolean validate; public ParseTag() { } // Tag interface //------------------------------------------------------------------------- public void doTag(XMLOutput output) throws MissingAttributeException, JellyTagException { if (getVar() == null) { throw new MissingAttributeException("The var attribute cannot be null"); } Document document = getXmlDocument(output); context.setVariable(getVar(), document); } // Properties //------------------------------------------------------------------------- /** Gets the source of the XML which is either a String URI, Reader or InputStream */ public Object getXml() { return this.xml; } /** Sets the source of the XML which is either a String URI, a File, Reader or InputStream */ public void setXml(Object xml) { this.xml = xml; } /** @return whether XML validation is enabled or disabled */ public boolean getValidate() { return validate; } /** Sets whether XML validation is enabled or disabled */ public void setValidate(boolean validate) { this.validate = validate; } // Implementation methods //------------------------------------------------------------------------- /** * Factory method to create a new SAXReader */ protected SAXReader createSAXReader() { return new SAXReader(validate); } protected Document getXmlDocument(XMLOutput output) throws JellyTagException { Document document = null; Object xmlObj = this.getXml(); if (xmlObj == null) { String text = getText(); if (text != null) { document = parseText(text); } else { document = parseBody(output); } } else { document = parse(xmlObj); } return document; } } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/java/org/apache/commons/jelly/tags/xml/CopyTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/java/org/apache/commons/jelly/tags/xml0000664000175000017500000000553011602216727031440 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.xml; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.jelly.xpath.XPathTagSupport; import org.dom4j.Element; import org.dom4j.io.SAXWriter; import org.jaxen.JaxenException; import org.jaxen.XPath; import org.xml.sax.SAXException; /** * A tag which performs a copy operation like the XSLT tag, * performing a shallow copy of the element and its attributes but no content. * * @author James Strachan */ public class CopyTag extends XPathTagSupport { /** The XPath expression to evaluate. */ private XPath select; /** Should we output lexical XML data like entity names? */ private boolean lexical; public CopyTag() { } // Tag interface //------------------------------------------------------------------------- public void doTag(XMLOutput output) throws JellyTagException { Object xpathContext = getXPathContext(); Object node = xpathContext; try { if (select != null) { node = select.selectSingleNode(xpathContext); } if ( node instanceof Element ) { Element element = (Element) node; SAXWriter saxWriter; if (lexical) { saxWriter = new SAXWriter(output, output); } else { saxWriter = new SAXWriter(output); } saxWriter.writeOpen(element); invokeBody(output); saxWriter.writeClose(element); } else { invokeBody(output); } } catch (SAXException e) { throw new JellyTagException(e); } catch (JaxenException e) { throw new JellyTagException(e); } } // Properties //------------------------------------------------------------------------- /** Sets the XPath expression to evaluate. */ public void setSelect(XPath select) { this.select = select; } public void setLexical(boolean lexical) { this.lexical = lexical; } } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/java/org/apache/commons/jelly/tags/xml/ParamTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/java/org/apache/commons/jelly/tags/xml0000664000175000017500000000450511602216727031441 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.xml; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.XMLOutput; /** Sets a parameter in the parent transform tag * * @author Robert Leftwich * @version $Revision: 155420 $ */ public class ParamTag extends TagSupport { /** the name of the attribute. */ private String name; /** the value of the attribute. */ private Object value; public ParamTag() { } // Tag interface //------------------------------------------------------------------------- public void doTag(XMLOutput output) throws JellyTagException { TransformTag tag = (TransformTag) this.findAncestorWithClass( TransformTag.class ); if ( tag == null ) { throw new JellyTagException( " tag must be enclosed inside a tag" ); } Object value = this.getValue(); if (value == null) { value = getBodyText(); } tag.setParameterValue( getName(), value ); } // Properties //------------------------------------------------------------------------- /** * @return the name of the attribute. */ public String getName() { return name; } /** * Sets the name of the attribute */ public void setName(String name) { this.name = name; } /** * @return the value of the attribute. */ public Object getValue() { return value; } /** * Sets the value of the attribute */ public void setValue(Object value) { this.value = value; } } ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/java/org/apache/commons/jelly/tags/xml/AttributeTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/src/java/org/apache/commons/jelly/tags/xml0000664000175000017500000000450311602216727031437 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.xml; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.XMLOutput; /** Adds an XML attribute to the parent element tag like * the <xsl:attribute> tag. * * @author James Strachan * @version $Revision: 219726 $ */ public class AttributeTag extends TagSupport { /** The namespace URI. */ private String namespace; /** the name of the attribute. */ private String name; public AttributeTag() { } // Tag interface //------------------------------------------------------------------------- public void doTag(XMLOutput output) throws JellyTagException { ElementTag tag = (ElementTag) findAncestorWithClass( ElementTag.class ); if (tag == null) { throw new JellyTagException( " tag must be enclosed inside an tag" ); } tag.setAttributeValue(getName(), getBodyText(false), getURI()); } // Properties //------------------------------------------------------------------------- /** * @return the name of the attribute. */ public String getName() { return name; } /** * Sets the name of the attribute. */ public void setName(String name) { this.name = name; } /** * @return the namespace URI of the element */ public String getURI() { return namespace; } /** * Sets the namespace URI of the element */ public void setURI(String namespace) { this.namespace = namespace; } } jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/xdocs/0000775000175000017500000000000011602216727022562 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/xdocs/index.xml0000664000175000017500000000175011602216727024416 0ustar davedave XML Tag Library dIon Gillard

The XML Tags from the JSTL. See the tags for more information.

jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/xdocs/changes.xml0000664000175000017500000000226511602216727024721 0ustar davedave Changes dIon Gillard xml:set can now return XPath strings and comma-separated strings Initial release jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/xdocs/navigation.xml0000664000175000017500000000166511602216727025453 0ustar davedave XML Tag Library jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/xml/maven.xml0000664000175000017500000000130011602216727023264 0ustar davedave jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/0000775000175000017500000000000011602216727021441 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/project.properties0000664000175000017500000000143411602216727025227 0ustar davedave # Copyright 2002-2004 The Apache Software Foundation # # 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. # ------------------------------------------------------------------- # P R O J E C T P R O P E R T I E S # ------------------------------------------------------------------- jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/project.xml0000664000175000017500000000433511602216727023636 0ustar davedave ${basedir}/../tag-project.xml commons-jelly-tags-sql commons-jelly-tags-sql 1.0.1-SNAPSHOT org.apache.commons.jelly.tags.sql This is a Jelly interface for SQL. Commons Jelly SQL Tag Library 1.0 1.0 COMMONS-JELLY-SQL-1_0 jdbc jdbc 2.0 commons-jelly commons-jelly-tags-junit 1.0 http://jakarta.apache.org/commons/jelly/tags/junit/ commons-cli commons-cli 1.0 hsqldb hsqldb 1.7.1 jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/build.xml0000664000175000017500000002034111602216727023262 0ustar davedave jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/0000775000175000017500000000000011602216727022230 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/test/0000775000175000017500000000000011602216727023207 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/test/org/0000775000175000017500000000000011602216727023776 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/test/org/apache/0000775000175000017500000000000011602216727025217 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/test/org/apache/commons/0000775000175000017500000000000011602216727026672 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/test/org/apache/commons/jelly/0000775000175000017500000000000011602216727030011 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/test/org/apache/commons/jelly/tags/0000775000175000017500000000000011602216727030747 5ustar davedave././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/test/org/apache/commons/jelly/tags/sql/jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/test/org/apache/commons/jelly/tags/sql0000775000175000017500000000000011602216727031467 5ustar davedave././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/test/org/apache/commons/jelly/tags/sql/example3.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/test/org/apache/commons/jelly/tags/sql0000664000175000017500000000414611602216727031476 0ustar davedave Dropping and recreating the table ${databaseTable}... drop table ${databaseTable} create table ${databaseTable} ( id integer, name varchar(255) ) Inserting some data... insert into ${databaseTable} (id, name) values (?, ?) Now performing a query... select * from ${databaseTable} ${row[i]} ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/test/org/apache/commons/jelly/tags/sql/example.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/test/org/apache/commons/jelly/tags/sql0000664000175000017500000000242611602216727031475 0ustar davedave select * from ${databaseTable} ${row[i]} ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/test/org/apache/commons/jelly/tags/sql/testSql.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/test/org/apache/commons/jelly/tags/sql0000664000175000017500000000203511602216727031471 0ustar davedave select * from ${databaseTable} ${results.rowCount} ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/test/org/apache/commons/jelly/tags/sql/TestJUnit.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/test/org/apache/commons/jelly/tags/sql0000664000175000017500000000241611602216727031474 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.sql; import junit.framework.TestSuite; import junit.textui.TestRunner; import org.apache.commons.jelly.tags.junit.JellyTestSuite; /** * A helper class to run jelly test cases as part of Ant's JUnit tests * * @author James Strachan * @version $Revision: 155420 $ */ public class TestJUnit extends JellyTestSuite { public static void main( String[] args ) throws Exception { TestRunner.run( suite() ); } public static TestSuite suite() throws Exception { return createTestSuite(TestJUnit.class, "suite.jelly"); } } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/test/org/apache/commons/jelly/tags/sql/suite.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/test/org/apache/commons/jelly/tags/sql0000664000175000017500000000270411602216727031474 0ustar davedave created a results object contains 2 rows ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/test/org/apache/commons/jelly/tags/sql/example2.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/test/org/apache/commons/jelly/tags/sql0000664000175000017500000000264511602216727031500 0ustar davedave select * from ${databaseTable} ${columnName} ${field} jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/java/0000775000175000017500000000000011602216727023151 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/java/javax/0000775000175000017500000000000011602216727024262 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/java/javax/servlet/0000775000175000017500000000000011602216727025746 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/java/javax/servlet/jsp/0000775000175000017500000000000011602216727026542 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/java/javax/servlet/jsp/jstl/0000775000175000017500000000000011602216727027516 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/java/javax/servlet/jsp/jstl/sql/0000775000175000017500000000000011602216727030315 5ustar davedave././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/java/javax/servlet/jsp/jstl/sql/Result.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/java/javax/servlet/jsp/jstl/sql/Result0000664000175000017500000000470111602216727031520 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package javax.servlet.jsp.jstl.sql; import java.util.SortedMap; /** *

This interface represents the result of a <sql:query> * action. It provides access to the following information in the * query result:

* *
    *
  • result rows *
  • result rows using an index *
  • number of rows in the result *
  • result meta data *
  • indication whether result returned is a complete set or * a subset limited by a maximum row setting *
* * @author Justyna Horwat * */ public interface Result { /** * Returns an array of SortedMap objects. Column name is used as the key * for the column value. SortedMap must use the CASE_INSENSITIVE_ORDER * Comparator so that the key is the case insensitive representation * of the column name. * * @return the result rows as an array of SortedMap objects */ public SortedMap[] getRows(); /** * Returns an array of Objects[]. The first index * designates the Row, the second the Column. The array * stores the value at the specified row and column. * * @return the result rows as an array of Object[] objects */ public Object[][] getRowsByIndex(); /** * Returns an array of column names. * * @return the column names as an array of String objects */ public String[] getColumnNames(); /** * Returns the number of rows in the cached ResultSet * * @return the number of rows in the result */ public int getRowCount(); /** * Returns true of the query was limited by a maximum row setting * * @return true if the query was limited by a maximum * row setting */ public boolean isLimitedByMaxRows(); } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/java/javax/servlet/jsp/jstl/sql/SQLExecutionTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/java/javax/servlet/jsp/jstl/sql/SQLExe0000664000175000017500000000410211602216727031336 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package javax.servlet.jsp.jstl.sql; /** *

This interface allows tag handlers implementing it to receive * values for parameter markers ("?") in their SQL statements.

* *

This interface is implemented by both <sql:query> and * <sql:update>. Its addSQLParameter() method * is called by nested parameter actions (such as <sql:param>) * to substitue PreparedStatement parameter values for * "?" parameter markers in the SQL statement of the enclosing * SQLExecutionTag action.

* *

The given parameter values are converted to their corresponding * SQL type (following the rules in the JDBC specification) before * they are sent to the database.

* *

Keeing track of the index of the parameter values being added * is the responsibility of the tag handler implementing this * interface

* *

The SQLExcecutionTag interface is exposed in order * to support custom parameter actions which may retrieve their * parameters from any source and process them before substituting * them for a parameter marker in the sQL statement of the * enclosing SQLExecutionTag action

* * @author Justyna Horwat */ public interface SQLExecutionTag { /** * Adds a PreparedStatement parameter value * * @param the PreparedStatement parameter value */ public void addSQLParameter(Object value); } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/java/javax/servlet/jsp/jstl/sql/ResultSupport.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/java/javax/servlet/jsp/jstl/sql/Result0000664000175000017500000000340011602216727031513 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package javax.servlet.jsp.jstl.sql; import java.sql.ResultSet; import java.sql.SQLException; /** *

This class represents the conversion of a ResultSet to * a Result object.

* * * @author Justyna Horwat * */ public class ResultSupport { /** * Returns an array of Row objects. * * @param ResultSet the ResultSet object * * @return the Result object of the result */ public static Result toResult(ResultSet rs) { try { return new ResultImpl(rs, -1, -1); } catch (SQLException ex) { return null; } } /** * Returns the Result object of the cached ResultSet limited by maxRows * * @param ResultSet the ResultSet object * @param maxRows the maximum number of rows * * @return the Result object of the result limited by maxRows */ public static Result toResult(ResultSet rs, int maxRows) { try { return new ResultImpl(rs, -1, maxRows); } catch (SQLException ex) { return null; } } } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/java/javax/servlet/jsp/jstl/sql/ResultImpl.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/java/javax/servlet/jsp/jstl/sql/Result0000664000175000017500000001217111602216727031520 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package javax.servlet.jsp.jstl.sql; import java.sql.*; import java.util.*; /** *

This class creates a cached version of a ResultSet. * It's represented as a Result implementation, capable of * returing an array of Row objects containing a Column * instance for each column in the row. It is not part of the JSTL * API; it serves merely as a back-end to ResultSupport's static methods. * Thus, we scope its access to the package. * * @author Hans Bergsten * @author Justyna Horwat */ class ResultImpl implements Result { private List rowMap; private List rowByIndex; private String[] columnNames; private boolean isLimited; /** * This constructor reads the ResultSet and saves a cached * copy. * * @param rs an open ResultSet, positioned before the first * row * @param startRow, beginning row to be cached * @param maxRows, query maximum rows limit * @exception if a database error occurs */ public ResultImpl(ResultSet rs, int startRow, int maxRows) throws SQLException { rowMap = new ArrayList(); rowByIndex = new ArrayList(); ResultSetMetaData rsmd = rs.getMetaData(); int noOfColumns = rsmd.getColumnCount(); // Create the column name array columnNames = new String[noOfColumns]; for (int i = 1; i <= noOfColumns; i++) { columnNames[i-1] = rsmd.getColumnName(i); } // Throw away all rows upto startRow for (int i = 0; i < startRow; i++) { rs.next(); } // Process the remaining rows upto maxRows int processedRows = 0; while (rs.next()) { if ((maxRows != -1) && (processedRows == maxRows)) { isLimited = true; break; } Object[] columns = new Object[noOfColumns]; SortedMap columnMap = new TreeMap(String.CASE_INSENSITIVE_ORDER); // JDBC uses 1 as the lowest index! for (int i = 1; i <= noOfColumns; i++) { Object value = rs.getObject(i); if (rs.wasNull()) { value = null; } columns[i-1] = value; columnMap.put(columnNames[i-1], value); } rowMap.add(columnMap); rowByIndex.add(columns); processedRows++; } } /** * Returns an array of SortedMap objects. The SortedMap * object key is the ColumnName and the value is the ColumnValue. * SortedMap was created using the CASE_INSENSITIVE_ORDER * Comparator so the key is the case insensitive representation * of the ColumnName. * * @return an array of Map, or null if there are no rows */ public SortedMap[] getRows() { if (rowMap == null) { return null; } //should just be able to return SortedMap[] object return (SortedMap []) rowMap.toArray(new SortedMap[0]); } /** * Returns an array of Object[] objects. The first index * designates the Row, the second the Column. The array * stores the value at the specified row and column. * * @return an array of Object[], or null if there are no rows */ public Object[][] getRowsByIndex() { if (rowByIndex == null) { return null; } //should just be able to return Object[][] object return (Object [][])rowByIndex.toArray(new Object[0][0]); } /** * Returns an array of String objects. The array represents * the names of the columns arranged in the same order as in * the getRowsByIndex() method. * * @return an array of String[] */ public String[] getColumnNames() { return columnNames; } /** * Returns the number of rows in the cached ResultSet * * @return the number of cached rows, or -1 if the Result could * not be initialized due to SQLExceptions */ public int getRowCount() { if (rowMap == null) { return -1; } return rowMap.size(); } /** * Returns true of the query was limited by a maximum row setting * * @return true if the query was limited by a MaxRows attribute */ public boolean isLimitedByMaxRows() { return isLimited; } } jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/java/org/0000775000175000017500000000000011602216727023740 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/java/org/apache/0000775000175000017500000000000011602216727025161 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/java/org/apache/commons/0000775000175000017500000000000011602216727026634 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/java/org/apache/commons/jelly/0000775000175000017500000000000011602216727027753 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/java/org/apache/commons/jelly/tags/0000775000175000017500000000000011602216727030711 5ustar davedave././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/java/org/apache/commons/jelly/tags/sql/jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/java/org/apache/commons/jelly/tags/sql0000775000175000017500000000000011602216727031431 5ustar davedave././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/java/org/apache/commons/jelly/tags/sql/DateParamTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/java/org/apache/commons/jelly/tags/sql0000664000175000017500000000661411602216727031442 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.sql; import java.sql.Date; import javax.servlet.jsp.jstl.sql.SQLExecutionTag; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.jelly.tags.Resources; /** *

Tag handler for <Param> in JSTL, used to set * parameter values for a SQL statement.

* * @author Justyna Horwat */ public class DateParamTag extends TagSupport { //********************************************************************* // Private constants private static final String TIMESTAMP_TYPE = "timestamp"; private static final String TIME_TYPE = "time"; private static final String DATE_TYPE = "date"; //********************************************************************* // Protected state protected String type; protected java.util.Date value; //********************************************************************* // Constructor public DateParamTag() { } //********************************************************************* // Properties public void setValue(Date value) { this.value = value; } public void setType(String type) { this.type = type; } //********************************************************************* // Tag logic public void doTag(XMLOutput output) throws JellyTagException { SQLExecutionTag parent = (SQLExecutionTag) findAncestorWithClass(this, SQLExecutionTag.class); if (parent == null) { throw new JellyTagException(Resources.getMessage("SQL_PARAM_OUTSIDE_PARENT")); } if (value != null) { convertValue(); } parent.addSQLParameter(value); } //********************************************************************* // Private utility methods private void convertValue() throws JellyTagException { if ((type == null) || (type.equalsIgnoreCase(TIMESTAMP_TYPE))) { if (!(value instanceof java.sql.Timestamp)) { value = new java.sql.Timestamp(value.getTime()); } } else if (type.equalsIgnoreCase(TIME_TYPE)) { if (!(value instanceof java.sql.Time)) { value = new java.sql.Time(value.getTime()); } } else if (type.equalsIgnoreCase(DATE_TYPE)) { if (!(value instanceof java.sql.Date)) { value = new java.sql.Date(value.getTime()); } } else { throw new JellyTagException( Resources.getMessage("SQL_DATE_PARAM_INVALID_TYPE", type)); } } } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/java/org/apache/commons/jelly/tags/sql/RowTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/java/org/apache/commons/jelly/tags/sql0000664000175000017500000000272411602216727031440 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.sql; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.MapTagSupport; import org.apache.commons.jelly.XMLOutput; /** * Adds a new row to a parent <resultSet> Tag. * This tag is useful for unit testing with Mock Tags to simulate the results returned by databases. * */ public class RowTag extends MapTagSupport { // Tag interface //------------------------------------------------------------------------- public void doTag(XMLOutput output) throws JellyTagException { ResultSetTag tag = (ResultSetTag) findAncestorWithClass( ResultSetTag.class ); if ( tag == null ) { throw new JellyTagException( "This tag must be nested with in a tag" ); } tag.addRow( getAttributes() ); } } ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/java/org/apache/commons/jelly/tags/sql/TransactionTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/java/org/apache/commons/jelly/tags/sql0000664000175000017500000001425211602216727031437 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.sql; import java.sql.Connection; import java.sql.SQLException; import javax.sql.DataSource; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.jelly.tags.Resources; /** *

Tag handler for <Transaction> in JSTL. * * @author Hans Bergsten */ public class TransactionTag extends TagSupport { //********************************************************************* // Private constants private static final String TRANSACTION_READ_COMMITTED = "read_committed"; private static final String TRANSACTION_READ_UNCOMMITTED = "read_uncommitted"; private static final String TRANSACTION_REPEATABLE_READ = "repeatable_read"; private static final String TRANSACTION_SERIALIZABLE = "serializable"; //********************************************************************* // Protected state protected Object rawDataSource; protected boolean dataSourceSpecified; //********************************************************************* // Private state private Connection conn; private int isolation = Connection.TRANSACTION_NONE; private int origIsolation; //********************************************************************* // Constructor and initialization public TransactionTag() { } /** * Sets the SQL DataSource. DataSource can be * a String or a DataSource object. */ public void setDataSource(Object dataSource) { this.rawDataSource = dataSource; this.dataSourceSpecified = true; } //********************************************************************* // Tag logic /** * Prepares for execution by setting the initial state, such as * getting the Connection and preparing it for * the transaction. */ public void doTag(XMLOutput output) throws JellyTagException { if ((rawDataSource == null) && dataSourceSpecified) { throw new JellyTagException(Resources.getMessage("SQL_DATASOURCE_NULL")); } DataSource dataSource = DataSourceUtil.getDataSource(rawDataSource, context); try { conn = dataSource.getConnection(); origIsolation = conn.getTransactionIsolation(); if (origIsolation == Connection.TRANSACTION_NONE) { throw new JellyTagException(Resources.getMessage("TRANSACTION_NO_SUPPORT")); } if ((isolation != Connection.TRANSACTION_NONE) && (isolation != origIsolation)) { conn.setTransactionIsolation(isolation); } conn.setAutoCommit(false); } catch (SQLException e) { throw new JellyTagException( Resources.getMessage("ERROR_GET_CONNECTION", e.getMessage())); } boolean finished = false; try { invokeBody(output); finished = true; } catch (Exception e) { if (conn != null) { try { conn.rollback(); } catch (SQLException s) { // Ignore to not hide orignal exception } doFinally(); } throw new JellyTagException(e); } // lets commit try { conn.commit(); } catch (SQLException e) { throw new JellyTagException( Resources.getMessage("TRANSACTION_COMMIT_ERROR", e.getMessage())); } finally { doFinally(); } } //********************************************************************* // Public utility methods /** * Sets the transaction isolation level. */ public void setIsolation(String iso) throws JellyTagException { if (TRANSACTION_READ_COMMITTED.equals(iso)) { isolation = Connection.TRANSACTION_READ_COMMITTED; } else if (TRANSACTION_READ_UNCOMMITTED.equals(iso)) { isolation = Connection.TRANSACTION_READ_UNCOMMITTED; } else if (TRANSACTION_REPEATABLE_READ.equals(iso)) { isolation = Connection.TRANSACTION_REPEATABLE_READ; } else if (TRANSACTION_SERIALIZABLE.equals(iso)) { isolation = Connection.TRANSACTION_SERIALIZABLE; } else { throw new JellyTagException(Resources.getMessage("TRANSACTION_INVALID_ISOLATION")); } } /** * Called by nested parameter elements to get a reference to * the Connection. */ public Connection getSharedConnection() { return conn; } //********************************************************************* // Implementation methods methods /** * Restores the Connection to its initial state and * closes it. */ protected void doFinally() { if (conn != null) { try { if ((isolation != Connection.TRANSACTION_NONE) && (isolation != origIsolation)) { conn.setTransactionIsolation(origIsolation); } conn.setAutoCommit(true); conn.close(); } catch (SQLException e) { // Not much we can do } } conn = null; } } ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/java/org/apache/commons/jelly/tags/sql/ResultSetTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/java/org/apache/commons/jelly/tags/sql0000664000175000017500000000422111602216727031432 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.sql; import java.util.ArrayList; import java.util.List; import java.util.Map; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.MissingAttributeException; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.XMLOutput; /** * This Tag creates a result set object based on its body content via child row tags. * This tag is useful for unit testing with Mock Tags to simulate the results returned by databases. * */ public class ResultSetTag extends TagSupport { private List rows; private String var; /** * Adds the given row to the list of rows */ public void addRow(Map row) { rows.add(row); } // Tag interface //------------------------------------------------------------------------- public void doTag(XMLOutput output) throws MissingAttributeException, JellyTagException { if (var == null) { throw new MissingAttributeException( "var" ); } rows = new ArrayList(); invokeBody(output); // now lets create a new Result implementation ResultImpl results = new ResultImpl( rows ); context.setVariable(var, results); rows = null; } // Properties //------------------------------------------------------------------------- /** * Sets the variable to export the result set to. */ public void setVar(String var) { this.var = var; } } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/java/org/apache/commons/jelly/tags/sql/package.htmljenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/java/org/apache/commons/jelly/tags/sql0000664000175000017500000000045211602216727031434 0ustar davedave

The SQL Tags from the JSTL

There are some examples of these tags in action here

././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/java/org/apache/commons/jelly/tags/sql/DataSourceWrapper.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/java/org/apache/commons/jelly/tags/sql0000664000175000017500000001025111602216727031432 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.sql; import java.io.PrintWriter; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import javax.sql.DataSource; import org.apache.commons.jelly.tags.Resources; import org.apache.commons.jelly.util.ClassLoaderUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** *

A simple DataSource wrapper for the standard * DriverManager class. * * @author Hans Bergsten */ public class DataSourceWrapper implements DataSource { /** The Log to which logging calls will be made. */ private static final Log log = LogFactory.getLog(DataSourceWrapper.class); private String driverClassName; private String jdbcURL; private String userName; private String password; public void setDriverClassName(String driverClassName) throws ClassNotFoundException, InstantiationException, IllegalAccessException { if (log.isDebugEnabled()) { log.debug("Loading JDBC driver: [" + driverClassName + "]"); } this.driverClassName = driverClassName; ClassLoaderUtils.getClassLoader(getClass()).loadClass(driverClassName).newInstance(); } public void setJdbcURL(String jdbcURL) { this.jdbcURL = jdbcURL; } public void setUserName(String userName) { this.userName = userName; } public void setPassword(String password) { this.password = password; } /** * Returns a Connection using the DriverManager and all * set properties. */ public Connection getConnection() throws SQLException { Connection conn = null; if (userName != null) { if (log.isDebugEnabled()) { log.debug( "Creating connection from url: " + jdbcURL + " userName: " + userName); } conn = DriverManager.getConnection(jdbcURL, userName, password); } else { if (log.isDebugEnabled()) { log.debug("Creating connection from url: " + jdbcURL); } conn = DriverManager.getConnection(jdbcURL); } if (log.isDebugEnabled()) { log.debug( "Created connection: " + conn ); } return conn; } /** * Always throws a SQLException. Username and password are set * in the constructor and can not be changed. */ public Connection getConnection(String username, String password) throws SQLException { throw new SQLException(Resources.getMessage("NOT_SUPPORTED")); } /** * Always throws a SQLException. Not supported. */ public int getLoginTimeout() throws SQLException { throw new SQLException(Resources.getMessage("NOT_SUPPORTED")); } /** * Always throws a SQLException. Not supported. */ public PrintWriter getLogWriter() throws SQLException { throw new SQLException(Resources.getMessage("NOT_SUPPORTED")); } /** * Always throws a SQLException. Not supported. */ public void setLoginTimeout(int seconds) throws SQLException { throw new SQLException(Resources.getMessage("NOT_SUPPORTED")); } /** * Always throws a SQLException. Not supported. */ public synchronized void setLogWriter(PrintWriter out) throws SQLException { throw new SQLException(Resources.getMessage("NOT_SUPPORTED")); } } ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/java/org/apache/commons/jelly/tags/sql/DriverTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/java/org/apache/commons/jelly/tags/sql0000664000175000017500000000677411602216727031451 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.sql; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.XMLOutput; /** *

Tag handler for <Driver> in JSTL, used to create * a simple DataSource for prototyping.

* * @author Hans Bergsten */ public class DriverTag extends TagSupport { private static final String DRIVER_CLASS_NAME = "javax.servlet.jsp.jstl.sql.driver"; private static final String JDBC_URL = "javax.servlet.jsp.jstl.sql.jdbcURL"; private static final String USER_NAME = "javax.servlet.jsp.jstl.sql.userName"; private static final String PASSWORD = "javax.servlet.jsp.jstl.sql.password"; private String driverClassName; private String jdbcURL; private String scope = "page"; private String userName; private String var; //********************************************************************* // Accessor methods public void setDriver(String driverClassName) { this.driverClassName = driverClassName; } public void setJdbcURL(String jdbcURL) { this.jdbcURL = jdbcURL; } /** * Sets the scope of the variable to hold the * result. * */ public void setScope(String scopeName) { this.scope = scopeName; } public void setUserName(String userName) { this.userName = userName; } public void setVar(String var) { this.var = var; } //********************************************************************* // Tag logic public void doTag(XMLOutput output) throws JellyTagException { DataSourceWrapper ds = new DataSourceWrapper(); try { ds.setDriverClassName(getDriverClassName()); } catch (Exception e) { throw new JellyTagException("Invalid driver class name: " + e.getMessage()); } ds.setJdbcURL(getJdbcURL()); ds.setUserName(getUserName()); ds.setPassword(getPassword()); context.setVariable(var, ds); } //********************************************************************* // Private utility methods private String getDriverClassName() { if (driverClassName != null) { return driverClassName; } return getInitParameter(DRIVER_CLASS_NAME); } private String getJdbcURL() { if (jdbcURL != null) { return jdbcURL; } return getInitParameter(JDBC_URL); } private String getUserName() { if (userName != null) { return userName; } return getInitParameter(USER_NAME); } private String getPassword() { return getInitParameter(PASSWORD); } protected String getInitParameter(String key) { return ""; } } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/java/org/apache/commons/jelly/tags/sql/SqlTagSupport.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/java/org/apache/commons/jelly/tags/sql0000664000175000017500000001225711602216727031442 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.sql; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import javax.servlet.jsp.jstl.sql.SQLExecutionTag; import javax.sql.DataSource; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.tags.Resources; /** *

Abstract base class for any SQL related tag in JSTL. * * @author Hans Bergsten * @author Justyna Horwat * @author James Strachan */ public abstract class SqlTagSupport extends TagSupport implements SQLExecutionTag { protected String var; protected String scope = "page"; /* * The following properties take expression values, so the * setter methods are implemented by the expression type * specific subclasses. */ protected Object rawDataSource; protected boolean dataSourceSpecified; protected String sql; /* * Instance variables that are not for attributes */ private List parameters; protected boolean isPartOfTransaction; //********************************************************************* // Constructor and initialization public SqlTagSupport() { super.setEscapeText(false); } //********************************************************************* // Accessor methods /** * Sets the name of the variable to hold the * result. */ public void setVar(String var) { this.var = var; } /** * Sets the scope of the variable to hold the * result. */ public void setScope(String scopeName) { this.scope = scopeName; } /** * Sets the SQL DataSource. DataSource can be * a String or a DataSource object. */ public void setDataSource(Object dataSource) { this.rawDataSource = dataSource; this.dataSourceSpecified = true; } /** * Sets the SQL statement to use for the * query. The statement may contain parameter markers * (question marks, ?). If so, the parameter values must * be set using nested value elements. */ public void setSql(String sql) { this.sql = sql; } //********************************************************************* // Public utility methods /** * Called by nested parameter elements to add PreparedStatement * parameter values. */ public void addSQLParameter(Object o) { if (parameters == null) { parameters = new ArrayList(); } parameters.add(o); } //********************************************************************* // Protected utility methods /** * @return true if there are SQL parameters */ protected boolean hasParameters() { return parameters != null && parameters.size() > 0; } protected void clearParameters() { parameters = null; } protected Connection getConnection() throws JellyTagException, SQLException { // Fix: Add all other mechanisms Connection conn = null; isPartOfTransaction = false; TransactionTag parent = (TransactionTag) findAncestorWithClass(TransactionTag.class); if (parent != null) { if (dataSourceSpecified) { throw new JellyTagException(Resources.getMessage("ERROR_NESTED_DATASOURCE")); } conn = parent.getSharedConnection(); isPartOfTransaction = true; } else { if ((rawDataSource == null) && dataSourceSpecified) { throw new JellyTagException(Resources.getMessage("SQL_DATASOURCE_NULL")); } DataSource dataSource = DataSourceUtil.getDataSource(rawDataSource, context); try { conn = dataSource.getConnection(); } catch (Exception ex) { throw new JellyTagException( Resources.getMessage("DATASOURCE_INVALID", ex.getMessage())); } } return conn; } protected void setParameters(PreparedStatement ps) throws SQLException { if (parameters != null) { for (int i = 0; i < parameters.size(); i++) { // The first parameter has index 1 ps.setObject(i + 1, parameters.get(i)); } } } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/java/org/apache/commons/jelly/tags/sql/ResultImpl.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/java/org/apache/commons/jelly/tags/sql0000664000175000017500000001547111602216727031443 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.sql; import java.sql.*; import java.util.*; import javax.servlet.jsp.jstl.sql.Result; /** *

This class creates a cached version of a ResultSet. * It's represented as a Result implementation, capable of * returing an array of Row objects containing a Column * instance for each column in the row.

* *

Note -- this is a private copy for the RI to avoid making the * corresponding class in javax.servlet.* public.

* * @author Hans Bergsten * @author Justyna Horwat */ public class ResultImpl implements Result { private List rowMap; private List rowByIndex; private String[] columnNames; private boolean isLimited; /** * This constructor reads the ResultSet and saves a cached * copy. * * @param rs an open ResultSet, positioned before the first * row * @param startRow, beginning row to be cached * @param maxRows, query maximum rows limit * @exception if a database error occurs */ public ResultImpl(ResultSet rs, int startRow, int maxRows) throws SQLException { rowMap = new ArrayList(); rowByIndex = new ArrayList(); ResultSetMetaData rsmd = rs.getMetaData(); int noOfColumns = rsmd.getColumnCount(); // Create the column name array columnNames = new String[noOfColumns]; for (int i = 1; i <= noOfColumns; i++) { columnNames[i-1] = rsmd.getColumnName(i); } // Throw away all rows upto startRow for (int i = 0; i < startRow; i++) { rs.next(); } // Process the remaining rows upto maxRows int processedRows = 0; while (rs.next()) { if ((maxRows != -1) && (processedRows == maxRows)) { isLimited = true; break; } Object[] columns = new Object[noOfColumns]; SortedMap columnMap = new TreeMap(String.CASE_INSENSITIVE_ORDER); // JDBC uses 1 as the lowest index! for (int i = 1; i <= noOfColumns; i++) { Object value = rs.getObject(i); if (rs.wasNull()) { value = null; } columns[i-1] = value; columnMap.put(columnNames[i-1], value); } rowMap.add(columnMap); rowByIndex.add(columns); processedRows++; } } /** * This constructor is given a List of Maps where each Map represents a Row of data. * This constructor is typically used to create a Mock Object representing a result set. * * @param listOfMaps is a list of Maps where a Map represents a Row keyed by the column name */ public ResultImpl(List listOfMaps) { rowMap = new ArrayList(); rowByIndex = new ArrayList(); isLimited = false; // lets build up a Set of all the unique column names HashSet keySet = new HashSet(); for (Iterator iter = listOfMaps.iterator(); iter.hasNext(); ) { Map row = (Map) iter.next(); keySet.addAll( row.keySet() ); } // Create the column name array int noOfColumns = keySet.size(); columnNames = new String[noOfColumns]; int i = 0; for (Iterator iter = keySet.iterator(); iter.hasNext(); i++ ) { columnNames[i] = (String) iter.next(); } // Now add each row to the result set for (Iterator iter = listOfMaps.iterator(); iter.hasNext(); ) { Map row = (Map) iter.next(); Object[] columns = new Object[noOfColumns]; SortedMap columnMap = new TreeMap(String.CASE_INSENSITIVE_ORDER); for (i = 0; i < noOfColumns; i++) { String columnName = columnNames[i]; Object value = row.get(columnName); columns[i] = value; columnMap.put(columnName, value); } rowMap.add(columnMap); rowByIndex.add(columns); } } /** * Returns an array of SortedMap objects. The SortedMap * object key is the ColumnName and the value is the ColumnValue. * SortedMap was created using the CASE_INSENSITIVE_ORDER * Comparator so the key is the case insensitive representation * of the ColumnName. * * @return an array of Map, or null if there are no rows */ public SortedMap[] getRows() { if (rowMap == null) { return null; } //should just be able to return SortedMap[] object return (SortedMap []) rowMap.toArray(new SortedMap[0]); } /** * Returns an array of Object[] objects. The first index * designates the Row, the second the Column. The array * stores the value at the specified row and column. * * @return an array of Object[], or null if there are no rows */ public Object[][] getRowsByIndex() { if (rowByIndex == null) { return null; } //should just be able to return Object[][] object return (Object [][])rowByIndex.toArray(new Object[0][0]); } /** * Returns an array of String objects. The array represents * the names of the columns arranged in the same order as in * the getRowsByIndex() method. * * @return an array of String[] */ public String[] getColumnNames() { return columnNames; } /** * Returns the number of rows in the cached ResultSet * * @return the number of cached rows, or -1 if the Result could * not be initialized due to SQLExceptions */ public int getRowCount() { if (rowMap == null) { return -1; } return rowMap.size(); } /** * Returns true of the query was limited by a maximum row setting * * @return true if the query was limited by a MaxRows attribute */ public boolean isLimitedByMaxRows() { return isLimited; } } ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/java/org/apache/commons/jelly/tags/sql/UpdateTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/java/org/apache/commons/jelly/tags/sql0000664000175000017500000001122011602216727031427 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.sql; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; import java.sql.Statement; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.jelly.tags.Resources; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** *

Tag handler for <Update> in JSTL. * * @author Hans Bergsten * @author Justyna Horwat */ public class UpdateTag extends SqlTagSupport { /** The Log to which logging calls will be made. */ private static final Log log = LogFactory.getLog(UpdateTag.class); /* * Instance variables that are not for attributes */ private Connection conn; //********************************************************************* // Constructor and initialization public UpdateTag() { } //********************************************************************* // Tag logic /** *

Execute the SQL statement, set either through the sql * attribute or as the body, and save the result as a variable * named by the var attribute in the scope specified * by the scope attribute, as an object that implements * the Result interface. * *

The connection used to execute the statement comes either * from the DataSource specified by the * dataSource attribute, provided by a parent action * element, or is retrieved from a JSP scope attribute * named javax.servlet.jsp.jstl.sql.dataSource. */ public void doTag(XMLOutput output) throws JellyTagException { try { conn = getConnection(); } catch (SQLException e) { throw new JellyTagException(sql + ": " + e.getMessage(), e); } /* * Use the SQL statement specified by the sql attribute, if any, * otherwise use the body as the statement. */ String sqlStatement = null; if (sql != null) { sqlStatement = sql; } else { sqlStatement = getBodyText(); } if (sqlStatement == null || sqlStatement.trim().length() == 0) { throw new JellyTagException(Resources.getMessage("SQL_NO_STATEMENT")); } Statement statement = null; int result = 0; try { if ( hasParameters() ) { PreparedStatement ps = conn.prepareStatement(sqlStatement); statement = ps; setParameters(ps); result = ps.executeUpdate(); } else { statement = conn.createStatement(); result = statement.executeUpdate(sqlStatement); } if (var != null) { context.setVariable(var, new Integer(result)); } // lets nullify before we close in case we get exceptions // while closing, we don't want to try to close again Statement tempStatement = statement; statement = null; tempStatement.close(); } catch (SQLException e) { throw new JellyTagException(sqlStatement + ": " + e.getMessage(), e); } finally { if (statement != null) { try { statement.close(); } catch (SQLException e) { log.error("Caught exception while closing statement: " + e, e); } } if (conn != null && !isPartOfTransaction) { try { conn.close(); } catch (SQLException e) { log.error("Caught exception while closing connection: " + e, e); } } clearParameters(); } } } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/java/org/apache/commons/jelly/tags/sql/SqlTagLibrary.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/java/org/apache/commons/jelly/tags/sql0000664000175000017500000000272211602216727031436 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.sql; import org.apache.commons.jelly.tags.core.CoreTagLibrary; /** Describes the Taglib. This class could be generated by XDoclet * * @author James Strachan * @version $Revision: 155420 $ */ public class SqlTagLibrary extends CoreTagLibrary { public SqlTagLibrary() { registerTag("driver", DriverTag.class); registerTag("param", ParamTag.class); registerTag("query", QueryTag.class); registerTag("setDataSource", SetDataSourceTag.class); registerTag("transaction", TransactionTag.class); registerTag("update", UpdateTag.class); // extension tags for Mock Tags support registerTag("resultSet", ResultSetTag.class); registerTag("row", RowTag.class); } } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/java/org/apache/commons/jelly/tags/sql/QueryTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/java/org/apache/commons/jelly/tags/sql0000664000175000017500000001714011602216727031436 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.sql; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import javax.servlet.jsp.jstl.sql.Result; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.jelly.tags.Resources; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** *

Tag handler for <Query> in JSTL. * * @author Hans Bergsten * @author Justyna Horwat */ public class QueryTag extends SqlTagSupport { /** The Log to which logging calls will be made. */ private static final Log log = LogFactory.getLog(QueryTag.class); /* * The following properties take expression values, so the * setter methods are implemented by the expression type * specific subclasses. */ protected int maxRows = -1; protected boolean maxRowsSpecified; protected int startRow; /* * Instance variables that are not for attributes */ private Connection conn; //********************************************************************* // Constructor and initialization public QueryTag() { } //********************************************************************* // Accessor methods /** * The index of the first row returned can be * specified using startRow. */ public void setStartRow(int startRow) { this.startRow = startRow; } /** * Query result can be limited by specifying * the maximum number of rows returned. */ public void setMaxRows(int maxRows) { this.maxRows = maxRows; this.maxRowsSpecified = true; } //********************************************************************* // Tag logic /** *

Execute the SQL statement, set either through the sql * attribute or as the body, and save the result as a variable * named by the var attribute in the scope specified * by the scope attribute, as an object that implements * the Result interface. * *

The connection used to execute the statement comes either * from the DataSource specified by the * dataSource attribute, provided by a parent action * element, or is retrieved from a JSP scope attribute * named javax.servlet.jstl.sql.dataSource. */ public void doTag(XMLOutput output) throws JellyTagException { if (!maxRowsSpecified) { Object obj = context.getVariable("org.apache.commons.jelly.sql.maxRows"); if (obj != null) { if (obj instanceof Integer) { maxRows = ((Integer) obj).intValue(); } else if (obj instanceof String) { try { maxRows = Integer.parseInt((String) obj); } catch (NumberFormatException nfe) { throw new JellyTagException( Resources.getMessage("SQL_MAXROWS_PARSE_ERROR", (String) obj), nfe); } } else { throw new JellyTagException(Resources.getMessage("SQL_MAXROWS_INVALID")); } } } Result result = null; String sqlStatement = null; log.debug( "About to lookup connection" ); ResultSet rs = null; Statement statement = null; try { conn = getConnection(); /* * Use the SQL statement specified by the sql attribute, if any, * otherwise use the body as the statement. */ if (sql != null) { sqlStatement = sql; } else { sqlStatement = getBodyText(); } if (sqlStatement == null || sqlStatement.trim().length() == 0) { throw new JellyTagException(Resources.getMessage("SQL_NO_STATEMENT")); } /* * We shouldn't have a negative startRow or illegal maxrows */ if ((startRow < 0) || (maxRows < -1)) { throw new JellyTagException(Resources.getMessage("PARAM_BAD_VALUE")); } /* * Note! We must not use the setMaxRows() method on the * the statement to limit the number of rows, since the * Result factory must be able to figure out the correct * value for isLimitedByMaxRows(); there's no way to check * if it was from the ResultSet. */ if ( log.isDebugEnabled() ) { log.debug( "About to execute query: " + sqlStatement ); } if ( hasParameters() ) { PreparedStatement ps = conn.prepareStatement(sqlStatement); statement = ps; setParameters(ps); rs = ps.executeQuery(); } else { statement = conn.createStatement(); rs = statement.executeQuery(sqlStatement); } result = new ResultImpl(rs, startRow, maxRows); context.setVariable(var, result); // always close the result set first since it may be closed by // JDBC 3 when closing statements // lets nullify before we close in case we get exceptions // while closing, we don't want to try to close again ResultSet tempRs = rs; rs = null; tempRs.close(); Statement tempStatement = statement; statement = null; tempStatement.close(); } catch (SQLException e) { throw new JellyTagException(sqlStatement + ": " + e.getMessage(), e); } finally { if (rs != null) { try { rs.close(); } catch (SQLException e) { log.error("Caught exception while closing result set: " + e, e); } } if (statement != null) { try { statement.close(); } catch (SQLException e) { log.error("Caught exception while closing statement: " + e, e); } } if (conn != null && !isPartOfTransaction) { try { conn.close(); } catch (SQLException e) { log.error("Caught exception while closing connection: " + e, e); } conn = null; } clearParameters(); } } } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/java/org/apache/commons/jelly/tags/sql/ParamTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/java/org/apache/commons/jelly/tags/sql0000664000175000017500000000410111602216727031427 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.sql; import javax.servlet.jsp.jstl.sql.SQLExecutionTag; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.jelly.tags.Resources; /** *

Tag handler for <Param> in JSTL, used to set * parameter values for a SQL statement.

* * @author Hans Bergsten */ public class ParamTag extends TagSupport { protected Object value; public void setValue(Object value) { this.value = value; } //********************************************************************* // Tag logic public void doTag(XMLOutput output) throws JellyTagException { SQLExecutionTag parent = (SQLExecutionTag) findAncestorWithClass(this, SQLExecutionTag.class); if (parent == null) { throw new JellyTagException(Resources.getMessage("SQL_PARAM_OUTSIDE_PARENT")); } Object paramValue = value; if (value != null) { paramValue = value; } else { String bodyContent = getBodyText(); if (bodyContent != null) { bodyContent = bodyContent.trim(); if (bodyContent.length() > 0) { paramValue = bodyContent; } } } parent.addSQLParameter(paramValue); } } ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/java/org/apache/commons/jelly/tags/sql/SetDataSourceTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/java/org/apache/commons/jelly/tags/sql0000664000175000017500000000772311602216727031444 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.sql; import javax.sql.DataSource; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.jelly.tags.Resources; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** *

Tag handler for <SetDataSource> in JSTL, used to create * a simple DataSource for prototyping.

* * @author Hans Bergsten * @author Justyna Horwat */ public class SetDataSourceTag extends TagSupport { /** The Log to which logging calls will be made. */ private static final Log log = LogFactory.getLog(SetDataSourceTag.class); protected Object dataSource; protected boolean dataSourceSpecified; protected String jdbcURL; protected String driverClassName; protected String userName; protected String password; private String scope = "page"; private String var; //********************************************************************* // Constructor and initialization public SetDataSourceTag() { } //********************************************************************* // Accessor methods /** * Sets the scope of the variable to hold the * result. * */ public void setScope(String scope) { this.scope = scope; } public void setVar(String var) { this.var = var; } public void setDataSource(Object dataSource) { this.dataSource = dataSource; this.dataSourceSpecified = true; } public void setDriver(String driverClassName) { this.driverClassName = driverClassName; } public void setUrl(String jdbcURL) { this.jdbcURL = jdbcURL; } public void setUser(String userName) { this.userName = userName; } public void setPassword(String password) { this.password = password; } //********************************************************************* // Tag logic public void doTag(XMLOutput output) throws JellyTagException { DataSource ds = null; if (dataSource != null) { ds = DataSourceUtil.getDataSource(dataSource, context); } else { if (dataSourceSpecified) { throw new JellyTagException(Resources.getMessage("SQL_DATASOURCE_NULL")); } DataSourceWrapper dsw = new DataSourceWrapper(); try { // set driver class iff provided by the tag if (driverClassName != null) { dsw.setDriverClassName(driverClassName); } } catch (Exception e) { log.error( "Could not load driver class: " + e, e ); throw new JellyTagException( Resources.getMessage("DRIVER_INVALID_CLASS", e.getMessage())); } dsw.setJdbcURL(jdbcURL); dsw.setUserName(userName); dsw.setPassword(password); ds = (DataSource) dsw; } if (var != null) { context.setVariable(var, ds); } else { context.setVariable("org.apache.commons.jelly.sql.DataSource", ds); } } } ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/java/org/apache/commons/jelly/tags/sql/DataSourceUtil.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/src/java/org/apache/commons/jelly/tags/sql0000664000175000017500000001137311602216727031440 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.sql; import javax.sql.DataSource; import javax.naming.InitialContext; import javax.naming.Context; import javax.naming.NamingException; import org.apache.commons.jelly.JellyContext; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.tags.Resources; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** *

A simple DataSource utility for the standard * DriverManager class. * * TO DO: need to cache DataSource * * @author Justyna Horwat */ public class DataSourceUtil { private static final String ESCAPE = "\\"; private static final String TOKEN = ","; /** The Log to which logging calls will be made. */ private static final Log log = LogFactory.getLog(DataSourceUtil.class); /** * If dataSource is a String first do JNDI lookup. * If lookup fails parse String like it was a set of JDBC parameters * Otherwise check to see if dataSource is a DataSource object and use as * is */ static DataSource getDataSource(Object rawDataSource, JellyContext pc) throws JellyTagException { DataSource dataSource = null; if (rawDataSource == null) { rawDataSource = pc.getVariable("org.apache.commons.jelly.sql.DataSource"); } if (rawDataSource == null) { return null; } /* * If the 'dataSource' attribute's value resolves to a String * after rtexpr/EL evaluation, use the string as JNDI path to * a DataSource */ if (rawDataSource instanceof String) { try { Context ctx = new InitialContext(); // relative to standard JNDI root for J2EE app Context envCtx = (Context) ctx.lookup("java:comp/env"); dataSource = (DataSource) envCtx.lookup((String) rawDataSource); } catch (NamingException ex) { dataSource = getDataSource((String) rawDataSource); } } else if (rawDataSource instanceof DataSource) { dataSource = (DataSource) rawDataSource; } else { throw new JellyTagException(Resources.getMessage("SQL_DATASOURCE_INVALID_TYPE")); } return dataSource; } /** * Parse JDBC parameters and setup dataSource appropriately */ private static DataSource getDataSource(String params) throws JellyTagException { DataSourceWrapper dataSource = new DataSourceWrapper(); String[] paramString = new String[4]; int escCount = 0; int aryCount = 0; int begin = 0; for (int index = 0; index < params.length(); index++) { char nextChar = params.charAt(index); if (TOKEN.indexOf(nextChar) != -1) { if (escCount == 0) { paramString[aryCount] = params.substring(begin, index); begin = index + 1; if (++aryCount > 4) { throw new JellyTagException(Resources.getMessage("JDBC_PARAM_COUNT")); } } } if (ESCAPE.indexOf(nextChar) != -1) { escCount++; } else { escCount = 0; } } paramString[aryCount] = params.substring(begin); // use the JDBC URL from the parameter string dataSource.setJdbcURL(paramString[0]); // try to load a driver if it's present if (paramString[1] != null) { try { dataSource.setDriverClassName(paramString[1]); } catch (Exception ex) { throw new JellyTagException( Resources.getMessage("DRIVER_INVALID_CLASS", ex.getMessage())); } } // set the username and password dataSource.setUserName(paramString[2]); dataSource.setPassword(paramString[3]); return dataSource; } } jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/xdocs/0000775000175000017500000000000011602216727022561 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/xdocs/index.xml0000664000175000017500000000227411602216727024417 0ustar davedave SQL Tag Library dIon Gillard

The SQL Tags from the JSTL

There are some examples of these tags in action here

See the tags for more information.

jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/xdocs/changes.xml0000664000175000017500000000163511602216727024720 0ustar davedave Changes dIon Gillard jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/xdocs/navigation.xml0000664000175000017500000000166511602216727025452 0ustar davedave SQL Tag Library jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/sql/maven.xml0000664000175000017500000000412211602216727023270 0ustar davedave jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/tag-project.xml0000664000175000017500000002651611602216727023615 0ustar davedave ../parent-project.xml 3 commons-jelly Apache Software Foundation http://jakarta.apache.org/ http://jakarta.apache.org/images/jakarta-logo.gif 2002 org.apache.commons.jelly.tags.ant /images/logo.gif jakarta This is a Jelly tag. Commons Jelly Tag Library http://jakarta.apache.org/commons/jelly/libs/${pom.id.substring(33)}/index.html http://issues.apache.org/jira/browse/JELLY cvs.apache.org /www/jakarta.apache.org/commons/jelly/libs/${pom.id.substring(33)}/ /www/jakarta.apache.org/builds/jakarta-commons/jelly/jelly-tags/${pom.id.substring(33)}/ scm:svn:http://svn.apache.org/repos/asf/jakarta/commons/proper/jelly/trunk/jelly-tags/${pom.artifactId.substring(19)} scm:svn:https://svn.apache.org/repos/asf/jakarta/commons/proper/jelly/trunk/jelly-tags/${pom.artifactId.substring(19)} http://svn.apache.org/viewcvs.cgi/jakarta/commons/proper/jelly/trunk/jelly-tags/${pom.artifactId.substring(19)} Commons Dev List commons-dev-subscribe@jakarta.apache.org commons-dev-unsubscribe@jakarta.apache.org http://mail-archives.apache.org/eyebrowse/SummarizeList?listName=commons-dev@jakarta.apache.org Commons User List commons-user-subscribe@jakarta.apache.org commons-user-unsubscribe@jakarta.apache.org http://mail-archives.apache.org/eyebrowse/SummarizeList?listName=commons-user@jakarta.apache.org James Strachan jstrachan jstrachan@apache.org SpiritSoft, Inc. Geir Magnusson Jr. geirm geirm@adeptra.com Adeptra, Inc. Bob McWhirter werken bob@eng.werken.com The Werken Company dIon Gillard dion dion@multitask.com.au Multitask Consulting Interested party Morgan Delagrange morgand morgand@apache.org Rodney Waldhoff rwaldhoff rwaldhoff@apache.org Robert Burrell Donkin rdonkin rdonkin@apache.org Felipe Leme felipeal jelly@felipeal.net Falcon Informatica -3 itch-scratcher Jakarta PMC Paul Libbrecht paul@activemath.org Developer Martin van dem Bemt mvdb@mvdb.com Erik Fransen erik167@xs4all.nl Logo designer Calvin Yu Stephen Haberman stephenh@chase3000.com Vinay Chandran sahilvinay@yahoo.com Developer Theo Niemeijer Joe Walnes joew@thoughtworks.com ThoughtWorks, Inc. Inventor of Mock Tags Otto von Wachter vonwao@yahoo.com Author of the tutorials Developer Robert Leftwich robert@leftwich.info Developer Jim Birchfield jim.birchfield@genscape.com Genscape, Inc. Developer Jason Horman jhorman@musicmatch.com Developer Tim Anderson tima@intalio.com Intalio, Inc. Developer Theo Niemeijer theo.niemeijer@getthere.nl Developer J. Matthew Pryor matthew_pryor@versata.com Developer Knut Wannheden Developer Kelvin Tan Developer Todd Jonker Developer xml-apis xml-apis 1.0.b2 commons-beanutils commons-beanutils 1.6 commons-collections commons-collections 2.1 commons-jexl commons-jexl 1.1 commons-jelly commons-jelly 1.0 commons-logging commons-logging 1.0.3 dom4j dom4j 1.6.1 jaxen jaxen 1.1-beta-8 xerces xerces 2.2.1 xml-xerces commons-dev@jakarta.apache.org src/java src/test **/Test*.java src/test **/*.jelly **/*.xml **/*.xsl **/*.rng **/*.dtd **/*.properties **/*.html src/java **/*.properties ${basedir}/.. META-INF NOTICE.txt maven-changes-plugin maven-checkstyle-plugin maven-developer-activity-plugin maven-file-activity-plugin maven-javadoc-plugin maven-jcoverage-plugin maven-jdepend-plugin maven-jellydoc-plugin maven-junit-report-plugin maven-jxr-plugin maven-license-plugin maven-pmd-plugin maven-tasklist-plugin jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/0000775000175000017500000000000011602216727022074 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/project.properties0000664000175000017500000000144511602216727025664 0ustar davedave# # Copyright 2002,2004 The Apache Software Foundation. # # 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. # # ------------------------------------------------------------------- # P R O J E C T P R O P E R T I E S # ------------------------------------------------------------------- jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/project.xml0000664000175000017500000000543411602216727024272 0ustar davedave ${basedir}/../tag-project.xml commons-jelly-tags-define commons-jelly-tags-define 1.0.1-hudson-20061106 org.apache.commons.jelly.tags.define The Jelly Define Tag Library Commons Jelly Define Tag Library 1.0 1.0 COMMONS_JELLY_DEFINE-1_0 commons-jelly commons-jelly-tags-dynabean 1.0 http://jakarta.apache.org/commons/jelly/tags/dynabean/ test commons-jelly commons-jelly-tags-junit 1.0 http://jakarta.apache.org/commons/jelly/tags/junit/ test commons-jelly commons-jelly-tags-log 1.0 http://jakarta.apache.org/commons/jelly/tags/log/ test commons-jelly commons-jelly-tags-xml 1.0 http://jakarta.apache.org/commons/jelly/tags/xml/ test commons-cli commons-cli 1.0 jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/build.xml0000664000175000017500000002130011602216727023711 0ustar davedave jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/pom.xml0000664000175000017500000000432111602216727023411 0ustar davedave 4.0.0 org.jvnet.hudson commons-jelly-tags-define commons-jelly-tags-define 1.0.1-hudson-20071021 The Jelly Define Tag Library ${groupId} commons-jelly 1.1-hudson-20071021 dom4j dom4j 1.6.1 commons-jelly commons-jelly-tags-dynabean 1.0 test commons-jelly commons-jelly-tags-junit 1.0 test commons-jelly commons-jelly-tags-log 1.0 test commons-jelly commons-jelly-tags-xml 1.0 test commons-cli commons-cli 1.0 junit junit 3.8.2 test ${basedir}/src/java ${basedir}/src/test ${basedir} **/*.properties false local-repository file:${path-to-m2-repo.java.net} jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/0000775000175000017500000000000011602216727022663 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/test/0000775000175000017500000000000011602216727023642 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/test/org/0000775000175000017500000000000011602216727024431 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/test/org/apache/0000775000175000017500000000000011602216727025652 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/test/org/apache/commons/0000775000175000017500000000000011602216727027325 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/test/org/apache/commons/jelly/0000775000175000017500000000000011602216727030444 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/test/org/apache/commons/jelly/tags/0000775000175000017500000000000011602216727031402 5ustar davedave././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/test/org/apache/commons/jelly/tags/mock/jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/test/org/apache/commons/jelly/tags/0000775000175000017500000000000011602216727031402 5ustar davedave././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/test/org/apache/commons/jelly/tags/mock/TestJUnit.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/test/org/apache/commons/jelly/tags/0000664000175000017500000000241711602216727031410 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.mock; import junit.framework.TestSuite; import junit.textui.TestRunner; import org.apache.commons.jelly.tags.junit.JellyTestSuite; /** * A helper class to run jelly test cases as part of Ant's JUnit tests * * @author James Strachan * @version $Revision: 155420 $ */ public class TestJUnit extends JellyTestSuite { public static void main( String[] args ) throws Exception { TestRunner.run( suite() ); } public static TestSuite suite() throws Exception { return createTestSuite(TestJUnit.class, "suite.jelly"); } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/test/org/apache/commons/jelly/tags/mock/suite.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/test/org/apache/commons/jelly/tags/0000664000175000017500000000644211602216727031412 0ustar davedave Invoking the eat web service with ${cheese} Invoked eat web service too many times! Should have invoked the eat web service twice ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/test/org/apache/commons/jelly/tags/mock/service.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/test/org/apache/commons/jelly/tags/0000664000175000017500000000301311602216727031401 0ustar davedave ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/test/org/apache/commons/jelly/tags/define/jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/test/org/apache/commons/jelly/tags/0000775000175000017500000000000011602216727031402 5ustar davedave././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/test/org/apache/commons/jelly/tags/define/example.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/test/org/apache/commons/jelly/tags/0000664000175000017500000000173711602216727031414 0ustar davedave This example should output a web service call... Jelly is cool stuff! ... OK did that work? ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/test/org/apache/commons/jelly/tags/define/DynamicTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/test/org/apache/commons/jelly/tags/0000664000175000017500000000243311602216727031406 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.define; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.XMLOutput; import org.xml.sax.SAXException; /** * @author stephen * @version $Revision: 155420 $ */ public class DynamicTag extends TagSupport { /** * @see org.apache.commons.jelly.Tag#doTag(XMLOutput) */ public void doTag(XMLOutput output) throws JellyTagException { try { output.write("output - ignored body"); } catch (SAXException e) { throw new JellyTagException(e); } } } ././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/test/org/apache/commons/jelly/tags/define/TestJelly.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/test/org/apache/commons/jelly/tags/0000664000175000017500000000242111602216727031403 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.define; import junit.framework.TestSuite; import junit.textui.TestRunner; import org.apache.commons.jelly.tags.junit.JellyTestSuite; /** * A helper class to run jelly test cases as part of Ant's JUnit tests * * @author James Strachan * @version $Revision: 155420 $ */ public class TestJelly extends JellyTestSuite { public static void main( String[] args ) throws Exception { TestRunner.run( suite() ); } public static TestSuite suite() throws Exception { return createTestSuite(TestJelly.class, "suite.jelly"); } } ././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/test/org/apache/commons/jelly/tags/define/TestDynamicTags.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/test/org/apache/commons/jelly/tags/0000664000175000017500000000516411602216727031412 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.define; import java.io.File; import java.io.StringWriter; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import junit.textui.TestRunner; import org.apache.commons.jelly.JellyContext; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** Tests dynamic tags * * @author James Strachan * @version $Revision: 155420 $ */ public class TestDynamicTags extends TestCase { JellyContext context = new JellyContext(); XMLOutput output; /** The Log to which logging calls will be made. */ private static final Log log = LogFactory.getLog(TestDynamicTags.class); public static void main(String[] args) { TestRunner.run(suite()); } public static Test suite() { return new TestSuite(TestDynamicTags.class); } public TestDynamicTags(String testName) { super(testName); } public void testParse() throws Exception { StringWriter buffer = new StringWriter(); output = XMLOutput.createXMLOutput(buffer); //runScript("src/test/org/apache/commons/jelly/define/babelfishTaglib.jelly"); runScript("src/test/org/apache/commons/jelly/tags/define/example.jelly"); log.info("The output was as follows"); log.info(buffer.toString()); } public void testJellyBean() throws Exception { StringWriter buffer = new StringWriter(); output = XMLOutput.createXMLOutput(buffer); log.warn("commented out test, need to rewrite without ant"); //runScript("src/test/org/apache/commons/jelly/define/jellyBeanSample.jelly"); log.info("The output was as follows"); log.info(buffer.toString()); } protected void runScript(String name) throws Exception { context.runScript(new File(name), output); } } ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/test/org/apache/commons/jelly/tags/define/suite.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/test/org/apache/commons/jelly/tags/0000664000175000017500000001264111602216727031410 0ustar davedave Generating some XML some XML About to invoke the script! ignored output to make sure doTag is being called Created a customer DynaBean bar bar2 foo bar foo bar bar ${varA} obtained is ${obtained} ././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/test/org/apache/commons/jelly/tags/define/jellyBeanSample.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/test/org/apache/commons/jelly/tags/0000664000175000017500000000440511602216727031407 0ustar davedave Lets define a new tag library Now lets invoke the new Jelly bean tag Did that work? ././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/test/org/apache/commons/jelly/tags/define/beanSample.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/test/org/apache/commons/jelly/tags/0000664000175000017500000000405211602216727031405 0ustar davedave Lets define a new tag library Now lets invoke the new Jelly bean tag Created a customer with name ${c1.name} and location ${c1.location} Created a customer with name ${c2.name} and location ${c2.location} Caught exception ${exception} with reason: ${exception.reason} Failed! I should have an exception since I didn't specify a 'name' attribute ././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/test/org/apache/commons/jelly/tags/define/babelfishTaglib.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/test/org/apache/commons/jelly/tags/0000664000175000017500000000367611602216727031420 0ustar davedave ${from}_${to} ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/test/org/apache/commons/jelly/tags/define/MyRunnable.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/test/org/apache/commons/jelly/tags/0000664000175000017500000000436311602216727031412 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.define; import java.util.ArrayList; import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; //import org.apache.tools.ant.types.FileSet; /** * An example Runnable bean that is framework neutral and just performs * some useful function. * * @author James Strachan * @version $Revision: 155420 $ */ public class MyRunnable implements Runnable { /** The Log to which logging calls will be made. */ private static final Log log = LogFactory.getLog(MyRunnable.class); private int x; private String y; private List fileSets = new ArrayList(); public MyRunnable() { } // Adder methods //------------------------------------------------------------------------- /* Commented out method to remove test-only dependency on ant public void addFileset(FileSet fileSet) { fileSets.add(fileSet); } */ // Runnable interface //------------------------------------------------------------------------- public void run() { log.info( "About to do something where x = " + getX() + " y = " + getY() ); log.info( "FileSets are: " + fileSets ); } // Properties //------------------------------------------------------------------------- public int getX() { return x; } public void setX(int x) { this.x = x; } public String getY() { return y; } public void setY(String y) { this.y = y; } } jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/java/0000775000175000017500000000000011602216727023604 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/java/org/0000775000175000017500000000000011602216727024373 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/java/org/apache/0000775000175000017500000000000011602216727025614 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/java/org/apache/commons/0000775000175000017500000000000011602216727027267 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/java/org/apache/commons/jelly/0000775000175000017500000000000011602216727030406 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/java/org/apache/commons/jelly/tags/0000775000175000017500000000000011602216727031344 5ustar davedave././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/java/org/apache/commons/jelly/tags/define/jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/java/org/apache/commons/jelly/tags/0000775000175000017500000000000011602216727031344 5ustar davedave././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/java/org/apache/commons/jelly/tags/define/TaglibTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/java/org/apache/commons/jelly/tags/0000664000175000017500000000650111602216727031350 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.define; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.jelly.impl.DynamicTagLibrary; /** * The <taglib> tag is used to define a new tag library * using a Jelly script. The tag library is identified by its * {@link #getURI() URI}. * * The tags for a taglib are declared using the {@link TagTag}. * * You can 'inherit' tags from a previously defined taglib, as well, * allowing runtime extension of tag libraries * * @author James Strachan * @version $Revision: 155420 $ */ public class TaglibTag extends TagSupport { /** The namespace URI */ private String uri; /** The new tags being added */ private DynamicTagLibrary tagLibrary; /** Whether or not inheritence is enabled */ private boolean inherit = true; public TaglibTag() { } public TaglibTag(String uri) { this.uri = uri; } // Tag interface //------------------------------------------------------------------------- public void doTag(XMLOutput output) throws JellyTagException { String uri = getUri(); tagLibrary = new DynamicTagLibrary( uri ); // inherit tags from an existing tag library if ( isInherit() ) { tagLibrary.setParent( context.getTagLibrary( uri ) ); } context.registerTagLibrary( uri, tagLibrary ); invokeBody(output); tagLibrary = null; } // Properties //------------------------------------------------------------------------- public String getUri() { return uri; } /** * Sets the namespace URI to register this new dynamic tag library with */ public void setUri(String uri) { this.uri = uri; } public DynamicTagLibrary getTagLibrary() { return tagLibrary; } /** * Returns the inherit. * @return boolean */ public boolean isInherit() { return inherit; } /** * Sets whether this dynamic tag should inherit from the current existing tag library * of the same URI. This feature is enabled by default so that tags can easily be * some tags can be overridden in an existing library, such as when making Mock Tags. * * You can disable this option if you want to disable any tags in the base library, * turning them into just normal static XML. * * @param inherit The inherit to set */ public void setInherit(boolean inherit) { this.inherit = inherit; } } ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/java/org/apache/commons/jelly/tags/define/SuperTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/java/org/apache/commons/jelly/tags/0000664000175000017500000000312311602216727031345 0ustar davedave/* * Copyright 1999-2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.define; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.XMLOutput; /** * <super> tag is used to invoke a parent tag implementation, when * a tag extends an existing tag * * @author Tim Anderson * @version $Revision: 155420 $ * @see ExtendTag */ public class SuperTag extends TagSupport { public SuperTag() { } // Tag interface //------------------------------------------------------------------------- public void doTag(XMLOutput output) throws JellyTagException { ExtendTag tag = (ExtendTag) findAncestorWithClass(ExtendTag.class); if (tag == null) { throw new JellyTagException( " must be inside a "); } tag.getSuperScript().run(getContext(), output); } } ././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/java/org/apache/commons/jelly/tags/define/ExtendTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/java/org/apache/commons/jelly/tags/0000664000175000017500000000552511602216727031355 0ustar davedave/* * Copyright 1999-2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.define; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.Script; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.jelly.impl.DynamicTagLibrary; /** * <extend> is used to extend a dynamic tag defined in an inherited * dynamic tag library *

* * @author Tim Anderson * @version $Revision: 155420 $ * @see SuperTag */ public class ExtendTag extends DefineTagSupport { private String name; private Script superScript; public ExtendTag() { } // Tag interface //------------------------------------------------------------------------- public void doTag(XMLOutput output) throws JellyTagException { DynamicTagLibrary library = getTagLibrary(); DynamicTagLibrary owner = library.find(getName()); if (owner == null) { throw new JellyTagException( "Cannot extend " + getName() + ": dynamic tag not defined"); } if (owner == library) { // disallow extension of tags defined within the same tag // library throw new JellyTagException("Cannot extend " + getName() + ": dynamic tag defined locally"); } superScript = owner.getDynamicTag(name); if (superScript == null) { // tag doesn't define a script - disallow this for the moment. throw new JellyTagException("Cannot extend " + getName() + ": tag is not a dynamic tag"); } owner.registerDynamicTag(getName() , getBody()); } // Properties //------------------------------------------------------------------------- /** * @return the name of the tag to create */ public String getName() { return name; } /** * Sets the name of the tag to create */ public void setName(String name) { this.name = name; } /** * Returns the parent implementation of this tag */ public Script getSuperScript() { return superScript; } } ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/java/org/apache/commons/jelly/tags/define/TagTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/java/org/apache/commons/jelly/tags/0000664000175000017500000000355111602216727031352 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.define; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.XMLOutput; /** * <tag> is used to define a new tag * using a Jelly script to implement the behaviour of the tag. * Parameters can be passed into the new tag using normal XML attribute * notations. Inside the body of the tag definition, the attributes can * be accessed as normal Jelly variables.

* * @author James Strachan * @version $Revision: 155420 $ */ public class TagTag extends DefineTagSupport { private String name; public TagTag() { } // Tag interface //------------------------------------------------------------------------- public void doTag(XMLOutput output) throws JellyTagException { getTagLibrary().registerDynamicTag( getName(), getBody() ); } // Properties //------------------------------------------------------------------------- /** @return the name of the tag to create */ public String getName() { return name; } /** Sets the name of the tag to create */ public void setName(String name) { this.name = name; } } ././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/java/org/apache/commons/jelly/tags/define/JellyBeanTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/java/org/apache/commons/jelly/tags/0000664000175000017500000000521611602216727031352 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.define; import java.lang.reflect.Method; import org.apache.commons.beanutils.MethodUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** * Binds a Java bean to the given named Jelly tag so that the attributes of * the tag set the bean properties. After the body of this tag is invoked * then the beans invoke() method will be called, if the bean has one. * * @author James Strachan * @version $Revision: 155420 $ */ public class JellyBeanTag extends BeanTag { /** The Log to which logging calls will be made. */ private static final Log log = LogFactory.getLog(JellyBeanTag.class); /** Empty parameter types for Method lookup */ private static final Class[] emptyParamTypes = {}; /** the name of the method to invoke on the bean */ private String method; // Properties //------------------------------------------------------------------------- /** * @return the method name to use, which defaults to 'run' for Runnable * objects */ public String getMethod() { if ( method == null ) { return "run"; } return method; } /** * Sets the name of the method to invoke on the bean. * This defaults to "run" so that Runnable objects can be * invoked, but this property can be set to whatever is required, * such as "execute" or "invoke" */ public void setMethod(String method) { this.method = method; } // Implementation methods //------------------------------------------------------------------------- protected Method getInvokeMethod( Class theClass ) { Method invokeMethod = MethodUtils.getAccessibleMethod( theClass, getMethod(), emptyParamTypes); if ( invokeMethod == null ) { } return invokeMethod; } } ././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/java/org/apache/commons/jelly/tags/define/DefineTagSupport.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/java/org/apache/commons/jelly/tags/0000664000175000017500000000322311602216727031346 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.define; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.impl.DynamicTagLibrary; /** * An abstract base class useful for implementation inheritence. * * @author James Strachan * @version $Revision: 155420 $ */ public abstract class DefineTagSupport extends TagSupport { // Implementation methods //------------------------------------------------------------------------- /** * @return the current dynamic tag library instance or throws a JellyException * if one is not available */ protected DynamicTagLibrary getTagLibrary() throws JellyTagException { TaglibTag tag = (TaglibTag) findAncestorWithClass(TaglibTag.class); if ( tag == null ) { throw new JellyTagException( " must be inside " ); } return tag.getTagLibrary(); } } ././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/java/org/apache/commons/jelly/tags/define/DynaBeanTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/java/org/apache/commons/jelly/tags/0000664000175000017500000001050211602216727031344 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.define; import java.util.HashMap; import java.util.Map; import org.apache.commons.beanutils.DynaClass; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.MissingAttributeException; import org.apache.commons.jelly.Tag; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.jelly.impl.Attribute; import org.apache.commons.jelly.impl.DynamicDynaBeanTag; import org.apache.commons.jelly.impl.TagFactory; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.xml.sax.Attributes; /** * Binds a Java bean to the given named Jelly tag so that the attributes of * the tag set the bean properties.. * * @author James Strachan * @version $Revision: 155420 $ */ public class DynaBeanTag extends DefineTagSupport { /** The Log to which logging calls will be made. */ private static final Log log = LogFactory.getLog(DynaBeanTag.class); /** An empty Map as I think Collections.EMPTY_MAP is only JDK 1.3 onwards */ private static final Map EMPTY_MAP = new HashMap(); /** the name of the tag to create */ private String name; /** the DyanClass to bind to the tag */ private DynaClass dynaClass; /** the name of the attribute used for the variable name */ private String varAttribute = "var"; /** the attribute definitions for this dynamic tag */ private Map attributes; /** * Adds a new attribute definition to this dynamic tag */ public void addAttribute(Attribute attribute) { if ( attributes == null ) { attributes = new HashMap(); } attributes.put( attribute.getName(), attribute ); } // Tag interface //------------------------------------------------------------------------- public void doTag(XMLOutput output) throws MissingAttributeException, JellyTagException { invokeBody(output); if (name == null) { throw new MissingAttributeException("name"); } if (dynaClass == null) { throw new MissingAttributeException("dynaClass"); } final DynaClass theDynaClass = dynaClass; final Map beanAttributes = (attributes != null) ? attributes : EMPTY_MAP; TagFactory factory = new TagFactory() { public Tag createTag(String name, Attributes attributes) { return new DynamicDynaBeanTag(theDynaClass, beanAttributes, varAttribute); } }; getTagLibrary().registerBeanTag(name, factory); // now lets clear the attributes for next invocation and help the GC attributes = null; } // Properties //------------------------------------------------------------------------- /** * Sets the name of the tag to create */ public void setName(String name) { this.name = name; } /** * Sets the name of the attribute used to define the bean variable that this dynamic * tag will output its results as. This defaults to 'var' though this property * can be used to change this if it conflicts with a bean property called 'var'. */ public void setVarAttribute(String varAttribute) { this.varAttribute = varAttribute; } /** * Returns the dynaClass. * @return DynaClass */ public DynaClass getDynaClass() { return dynaClass; } /** * Sets the {@link DynaClass} which will be bound to this dynamic tag. */ public void setDynaClass(DynaClass dynaClass) { this.dynaClass = dynaClass; } } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/java/org/apache/commons/jelly/tags/define/package.htmljenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/java/org/apache/commons/jelly/tags/0000664000175000017500000000140411602216727031345 0ustar davedave

Tag library which allows the creation of new tags using Jelly script itself.

././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/java/org/apache/commons/jelly/tags/define/DefineTagLibrary.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/java/org/apache/commons/jelly/tags/0000664000175000017500000000355711602216727031360 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.define; import org.apache.commons.jelly.TagLibrary; /** * This is a tag library that allows you to define new tag libraries at run time. * Thus tag libraries and tags can be easily implemented in Jelly rather than * in Java code. * * Please see the individual tag classes for more information, particularly * {@link TaglibTag Taglib tag} and {@link TagTag Tag tag}. * * @author James Strachan * @version $Revision: 155420 $ */ public class DefineTagLibrary extends TagLibrary { public DefineTagLibrary() { registerTag( "taglib", TaglibTag.class ); registerTag( "tag", TagTag.class ); registerTag( "bean", BeanTag.class ); registerTag( "dynaBean", DynaBeanTag.class ); registerTag( "jellybean", JellyBeanTag.class ); registerTag( "attribute", AttributeTag.class ); registerTag( "invokeBody", InvokeBodyTag.class ); registerTag( "script", ScriptTag.class ); registerTag( "invoke", InvokeTag.class ); registerTag( "classLoader", ClassLoaderTag.class ); registerTag( "extend", ExtendTag.class ); registerTag( "super", SuperTag.class ); } } ././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/java/org/apache/commons/jelly/tags/define/InvokeTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/java/org/apache/commons/jelly/tags/0000664000175000017500000000417611602216727031356 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.define; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.MissingAttributeException; import org.apache.commons.jelly.Script; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** * The <invoke> tag will invoke a given Script instance. * It can be used with the <script> tag which defines scripts * as variables that can later be invoked by this <invoke> tag. * * @author James Strachan * @version $Revision: 155420 $ */ public class InvokeTag extends TagSupport { /** The Log to which logging calls will be made. */ private static final Log log = LogFactory.getLog(InvokeTag.class); private Script script; public InvokeTag() { } /** * Sets the Script to be invoked by this tag, which typically has been previously * defined by the use of the <script> tag. */ public void setScript(Script script) { this.script = script; } // Tag interface //------------------------------------------------------------------------- public void doTag(XMLOutput output) throws MissingAttributeException, JellyTagException { if ( script == null ) { throw new MissingAttributeException("script"); } script.run(context, output); } } ././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/java/org/apache/commons/jelly/tags/define/InvokeBodyTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/java/org/apache/commons/jelly/tags/0000664000175000017500000000757411602216727031363 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.define; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.Script; import org.apache.commons.jelly.Tag; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.jelly.JellyContext; import org.apache.commons.jelly.impl.DynamicTag; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** * <invokeBody> tag is used inside a <tag> tag * (i.e. the definition of a dynamic tag) to invoke the tags body when * the tag is invoked. * * @author James Strachan * @version $Revision: 155420 $ */ public class InvokeBodyTag extends TagSupport { /** The Log to which logging calls will be made. */ private static final Log log = LogFactory.getLog(InvokeBodyTag.class); public InvokeBodyTag() { } // Tag interface //------------------------------------------------------------------------- public void doTag(XMLOutput output) throws JellyTagException { /* Try find find the body from the reserved 'org.apache.commons.jelly.body' variable. But while doing os, Consider a doubly nested invocations like the following sequence, where tag A and B are DynamicTag: where A is defined as ... where B is defined as ... For this to correctly expands to , We need to find the as the body when we are executing inside tag. To do this, body Tags (to be invoked) need to be maintained as a stack, and when is invoked inside , we need to 'pop' the body so that the proper body () will become visible. */ JellyContext c = context; Script script = null; while (c!=null) { script = (Script) c.getVariables().get("org.apache.commons.jelly.body"); if(script!=null) break; c = c.getParent(); } if (script != null) { // pop the top most body from the virtual ' stack' // this is necessary to make tha nested invocations work. see above. c.removeVariable("org.apache.commons.jelly.body"); try { script.run(context, output); } finally { c.setVariable("org.apache.commons.jelly.body",script); } } else { // note this mechanism does not work properly for arbitrarily // nested dynamic tags. A better way is required. Tag tag = findAncestorWithClass(this, DynamicTag.class); if (tag == null) { throw new JellyTagException("Cannot invoke body, no dynamic tag is defined in this block"); } else { tag.invokeBody(output); } } } } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/java/org/apache/commons/jelly/tags/define/BeanTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/java/org/apache/commons/jelly/tags/0000664000175000017500000001350011602216727031345 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.define; import java.lang.reflect.Method; import java.util.HashMap; import java.util.Map; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.MissingAttributeException; import org.apache.commons.jelly.Tag; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.jelly.impl.Attribute; import org.apache.commons.jelly.impl.DynamicBeanTag; import org.apache.commons.jelly.impl.TagFactory; import org.apache.commons.jelly.util.ClassLoaderUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.xml.sax.Attributes; /** * Binds a Java bean to the given named Jelly tag so that the attributes of * the tag set the bean properties.. * * @author James Strachan * @version $Revision: 155420 $ */ public class BeanTag extends DefineTagSupport { /** The Log to which logging calls will be made. */ private static final Log log = LogFactory.getLog(BeanTag.class); /** An empty Map as I think Collections.EMPTY_MAP is only JDK 1.3 onwards */ private static final Map EMPTY_MAP = new HashMap(); /** the name of the tag to create */ private String name; /** the Java class name to use for the tag */ private String className; /** the ClassLoader used to load beans */ private ClassLoader classLoader; /** the name of the attribute used for the variable name */ private String varAttribute = "var"; /** the attribute definitions for this dynamic tag */ private Map attributes; /** * Adds a new attribute definition to this dynamic tag */ public void addAttribute(Attribute attribute) { if ( attributes == null ) { attributes = new HashMap(); } attributes.put( attribute.getName(), attribute ); } // Tag interface //------------------------------------------------------------------------- public void doTag(XMLOutput output) throws MissingAttributeException, JellyTagException { invokeBody(output); if (name == null) { throw new MissingAttributeException("name"); } if (className == null) { throw new MissingAttributeException("className"); } Class theClass = null; try { ClassLoader classLoader = getClassLoader(); theClass = ClassLoaderUtils.loadClass(className, getClassLoader(), getContext().getUseContextClassLoader(), getClass()); } catch (ClassNotFoundException e) { log.error( "Could not load class: " + className + " exception: " + e, e ); throw new JellyTagException( "Could not find class: " + className + " using ClassLoader: " + classLoader); } final Class beanClass = theClass; final Method invokeMethod = getInvokeMethod( theClass ); final Map beanAttributes = (attributes != null) ? attributes : EMPTY_MAP; TagFactory factory = new TagFactory() { public Tag createTag(String name, Attributes attributes) { return new DynamicBeanTag(beanClass, beanAttributes, varAttribute, invokeMethod); } }; getTagLibrary().registerBeanTag(name, factory); // now lets clear the attributes for next invocation and help the GC attributes = null; } // Properties //------------------------------------------------------------------------- /** * Sets the name of the tag to create */ public void setName(String name) { this.name = name; } /** * Sets the Java class name to use for the tag */ public void setClassName(String className) { this.className = className; } /** * Sets the ClassLoader to use to load the class. * If no value is set then the current threads context class * loader is used. */ public void setClassLoader(ClassLoader classLoader) { this.classLoader = classLoader; } /** * @return the ClassLoader to use to load classes specified by this object, * the thread context loader if the context flag is set, or the class used to load this class. */ public ClassLoader getClassLoader() { return ClassLoaderUtils.getClassLoader(classLoader, getContext().getUseContextClassLoader(), getClass()); } /** * Sets the name of the attribute used to define the bean variable that this dynamic * tag will output its results as. This defaults to 'var' though this property * can be used to change this if it conflicts with a bean property called 'var'. */ public void setVarAttribute(String varAttribute) { this.varAttribute = varAttribute; } // Implementation methods //------------------------------------------------------------------------- /** * Extracts the invoke method for the class if one is used. */ protected Method getInvokeMethod( Class theClass ) { return null; } } ././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/java/org/apache/commons/jelly/tags/define/ScriptTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/java/org/apache/commons/jelly/tags/0000664000175000017500000000367511602216727031361 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.define; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.XMLOutput; /** * <script> tag is used to assign a Script object * to a variable. The script can then be called whenever the user wishes * maybe from inside an expression or more typically via the <invoke> tag.

* * @author James Strachan * @version $Revision: 155420 $ */ public class ScriptTag extends TagSupport { private String var; public ScriptTag() { } // Tag interface //------------------------------------------------------------------------- public void doTag(XMLOutput output) throws JellyTagException { if ( var == null ) { throw new JellyTagException( " must have a var attribute" ); } context.setVariable( var, getBody() ); } // Properties //------------------------------------------------------------------------- /** @return the variable name of the script to create */ public String getVar() { return var; } /** Sets the variable name of the tag to create */ public void setVar(String var) { this.var = var; } } ././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/java/org/apache/commons/jelly/tags/define/ClassLoaderTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/java/org/apache/commons/jelly/tags/0000664000175000017500000000636211602216727031355 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.define; import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.MissingAttributeException; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.jelly.util.ClassLoaderUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** * Creates a new URLClassLoader to dynamically * load tags froms. * * @author Stephen Haberman * @version $Revision: 155420 $ */ public class ClassLoaderTag extends BeanTag { /** The Log to which logging calls will be made. */ private static final Log log = LogFactory.getLog(ClassLoaderTag.class); /** The name to export the classloader to. */ private String var; /** The URL to load the classes from. */ private String url; // Properties //------------------------------------------------------------------------- /** * @return the variable to store the class loader in */ public String getVar() { return this.var; } /** * @param var the variable to store the class loader in */ public void setVar(String var) { this.var = var; } /** * @return the url to load the classes from */ public String getUrl() { return this.url; } /** * @param url the url to load the classes from */ public void setUrl(String url) { this.url = url; } // Implementation methods //------------------------------------------------------------------------- public void doTag(XMLOutput output) throws MissingAttributeException, JellyTagException { if ( getVar() == null ) { throw new MissingAttributeException( "var" ); } if ( getUrl() == null ) { throw new MissingAttributeException( "url" ); } ClassLoader parent = Thread.currentThread().getContextClassLoader(); if (parent == null) { parent = ClassLoaderUtils.getClassLoader(getClass()); } URLClassLoader newClassLoader = null; try { newClassLoader = new URLClassLoader( new URL[] { new URL(getUrl()) }, parent ); } catch (MalformedURLException e) { throw new JellyTagException(e); } log.debug("Storing the new classloader in " + getVar()); context.setVariable(getVar(), newClassLoader); } } ././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/java/org/apache/commons/jelly/tags/define/AttributeTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/src/java/org/apache/commons/jelly/tags/0000664000175000017500000000564311602216727031356 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.define; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.jelly.expression.Expression; import org.apache.commons.jelly.impl.Attribute; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** * This tag is bound onto a Java Bean class. When the tag is invoked a bean will be created * using the tags attributes. * The bean may also have an invoke method called invoke(), run(), execute() or some such method * which will be invoked after the bean has been configured.

* * @author James Strachan * @author Jason van Zyl * @version $Revision: 155420 $ */ public class AttributeTag extends TagSupport { /** The Log to which logging calls will be made. */ private static final Log log = LogFactory.getLog(AttributeTag.class); /** the attribute definition */ private Attribute attribute; public AttributeTag() { attribute = new Attribute(); } public AttributeTag(Attribute attribute) { this.attribute = attribute; } // Tag interface //------------------------------------------------------------------------- public void doTag(XMLOutput output) throws JellyTagException { BeanTag tag = (BeanTag) findAncestorWithClass( BeanTag.class ); if ( tag == null ) { throw new JellyTagException( "This tag should be nested inside a or tag" ); } tag.addAttribute( attribute ); } // Properties //------------------------------------------------------------------------- /** * Sets the name of the attribute */ public void setName(String name) { attribute.setName(name); } /** * Sets whether this attribute is mandatory or not */ public void setRequired(boolean required) { attribute.setRequired(required); } /** * Sets the default value of this attribute */ public void setDefaultValue(Expression defaultValue) { attribute.setDefaultValue(defaultValue); } } jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/xdocs/0000775000175000017500000000000011602216727023214 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/xdocs/index.xml0000664000175000017500000000203211602216727025042 0ustar davedave Define Tag Library dIon Gillard

Tag library which allows the creation of new tags using Jelly script itself. See the tags for more information.

jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/xdocs/changes.xml0000664000175000017500000000173311602216727025352 0ustar davedave Changes dIon Gillard Initial Release jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/xdocs/navigation.xml0000664000175000017500000000167611602216727026107 0ustar davedave Define Tag Library jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/define/maven.xml0000664000175000017500000000341611602216727023730 0ustar davedave jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/betwixt/0000775000175000017500000000000011602216727022330 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/betwixt/project.properties0000664000175000017500000000144511602216727026120 0ustar davedave# # Copyright 2002,2004 The Apache Software Foundation. # # 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. # # ------------------------------------------------------------------- # P R O J E C T P R O P E R T I E S # ------------------------------------------------------------------- jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/betwixt/project.xml0000664000175000017500000000471111602216727024523 0ustar davedave ${basedir}/../tag-project.xml commons-jelly-tags-betwixt commons-jelly-tags-betwixt 1.1-SNAPSHOT org.apache.commons.jelly.tags.betwixt This is a Jelly interface for Betwixt. Commons Jelly Betwixt Tag Library 1.0 1.0 COMMONS_JELLY_BETWIXT-1_0 commons-betwixt commons-betwixt 0.6 http://jakarta.apache.org/commons/betwixt/ commons-digester commons-digester 1.6 http://jakarta.apache.org/commons/digester/ commons-jelly commons-jelly-tags-log 1.0 http://jakarta.apache.org/commons/jelly/tags/log/ test commons-jelly commons-jelly-tags-junit 1.0 http://jakarta.apache.org/commons/jelly/tags/junit/ test jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/betwixt/build.xml0000664000175000017500000002075711602216727024164 0ustar davedave jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/betwixt/src/0000775000175000017500000000000011602216727023117 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/betwixt/src/test/0000775000175000017500000000000011602216727024076 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/betwixt/src/test/org/0000775000175000017500000000000011602216727024665 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/betwixt/src/test/org/apache/0000775000175000017500000000000011602216727026106 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/betwixt/src/test/org/apache/commons/0000775000175000017500000000000011602216727027561 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/betwixt/src/test/org/apache/commons/digester/0000775000175000017500000000000011602216727031367 5ustar davedave././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/betwixt/src/test/org/apache/commons/digester/rss/jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/betwixt/src/test/org/apache/commons/digester/r0000775000175000017500000000000011602216727031551 5ustar davedave././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/betwixt/src/test/org/apache/commons/digester/rss/rss-example.xmljenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/betwixt/src/test/org/apache/commons/digester/r0000664000175000017500000000474711602216727031567 0ustar davedave Apache http://www.apache.org The Apache Software Foundation en-US (PICS-1.1 "http://www.rsac.org/ratingsv01.html" 2 gen true comment "RSACi North America Server" for "http://www.rsac.org" on "1996.04.16T08:15-0500" r (n 0 s 0 v 0 l 0)) Apache http://jakarta.apache.org/images/jakarta-logo.gif http://jakarta.apache.org 505 480 The Jakarta project. Open source, serverside java. Commons Attributes 2.1 Released http://jakarta.apache.org/site/news/news-2004-2ndHalf.html#20040815.1 The Jakarta Commons team is happy to announce the release of Commons Attributes 2.1. This is the first release of the new Commons-Attributes code. Cloudscape Becomes Apache Derby http://jakarta.apache.org/site/news/elsewhere-2004-2ndHalf.html#20040803.1 IBM has submitted a proposal to the Apache DB project for a Java-based package to be called 'Derby'. Commons BeanUtils 1.7 Released http://jakarta.apache.org/site/news/news-2004-2ndHalf.html#20040802.1 Commons JXPath 1.2 Released http://jakarta.apache.org/site/news/news-2004-2ndHalf.html#20040801.2 ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/betwixt/src/test/org/apache/commons/digester/rss/package.htmljenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/betwixt/src/test/org/apache/commons/digester/r0000664000175000017500000000043511602216727031555 0ustar davedave Package Documentation for org.apache.commons.digester.rss Package

Example usage of Digester to parse XML documents compatible with the Rich Site Summary format used by many newsfeeds.

././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/betwixt/src/test/org/apache/commons/digester/rss/RSSDigester.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/betwixt/src/test/org/apache/commons/digester/r0000664000175000017500000002556311602216727031566 0ustar davedave/* * Copyright 2001-2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.digester.rss; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.net.URL; import org.apache.commons.digester.Digester; import org.apache.commons.logging.LogFactory; import org.xml.sax.InputSource; import org.xml.sax.SAXException; /** *

Implementation of org.apache.commons.digester.Digester * designed to process input streams that conform to the Rich Site * Summary DTD, version 0.91. For more information about this format, * see the My Netscape site.

* *

The default implementation object returned by calling * parse() (an instance of * org.apache.commons.digester.rss.Channel) * knows how to render itself in XML format via the render() * method. See the test main() method below for an * example of using these classes.

*/ public class RSSDigester extends Digester { // ----------------------------------------------------------- Constructors // ----------------------------------------------------- Instance Variables /** * Have we been configured yet? */ protected boolean configured = false; /** * The set of public identifiers, and corresponding resource names, * for the versions of the DTDs that we know about. */ protected static final String registrations[] = { "-//Netscape Communications//DTD RSS 0.9//EN", "/org/apache/commons/digester/rss/rss-0.9.dtd", "-//Netscape Communications//DTD RSS 0.91//EN", "/org/apache/commons/digester/rss/rss-0.91.dtd", }; // ------------------------------------------------------------- Properties /** * The fully qualified class name of the Channel * implementation class. */ protected String channelClass = "org.apache.commons.digester.rss.Channel"; public String getChannelClass() { return (this.channelClass); } public void setChannelClass(String channelClass) { this.channelClass = channelClass; } /** * The fully qualified class name of the Image * implementation class. */ protected String imageClass = "org.apache.commons.digester.rss.Image"; public String getImageClass() { return (this.imageClass); } public void setImageClass(String imageClass) { this.imageClass = imageClass; } /** * The fully qualified class name of the Item * implementation class. */ protected String itemClass = "org.apache.commons.digester.rss.Item"; public String getItemClass() { return (this.itemClass); } public void setItemClass(String itemClass) { this.itemClass = itemClass; } /** * The fully qualified class name of the TextInput * implementation class. */ protected String textInputClass = "org.apache.commons.digester.rss.TextInput"; public String getTextInputClass() { return (this.textInputClass); } public void setTextInputClass(String textInputClass) { this.textInputClass = textInputClass; } // --------------------------------------------------------- Public Methods /** * Parse the content of the specified file using this Digester. Returns * the root element from the object stack (which will be the Channel). * * @param file File containing the XML data to be parsed * * @exception IOException if an input/output error occurs * @exception SAXException if a parsing exception occurs */ public Object parse(File file) throws IOException, SAXException { configure(); return (super.parse(file)); } /** * Parse the content of the specified input source using this Digester. * Returns the root element from the object stack (which will be the * Channel). * * @param input Input source containing the XML data to be parsed * * @exception IOException if an input/output error occurs * @exception SAXException if a parsing exception occurs */ public Object parse(InputSource input) throws IOException, SAXException { configure(); return (super.parse(input)); } /** * Parse the content of the specified input stream using this Digester. * Returns the root element from the object stack (which will be * the Channel). * * @param input Input stream containing the XML data to be parsed * * @exception IOException if an input/output error occurs * @exception SAXException if a parsing exception occurs */ public Object parse(InputStream input) throws IOException, SAXException { configure(); return (super.parse(input)); } /** * Parse the content of the specified URI using this Digester. * Returns the root element from the object stack (which will be * the Channel). * * @param uri URI containing the XML data to be parsed * * @exception IOException if an input/output error occurs * @exception SAXException if a parsing exception occurs */ public Object parse(String uri) throws IOException, SAXException { configure(); return (super.parse(uri)); } // -------------------------------------------------------- Package Methods // ------------------------------------------------------ Protected Methods /** * Configure the parsing rules that will be used to process RSS input. */ protected void configure() { if (configured) { return; } // Register local copies of the DTDs we understand for (int i = 0; i < registrations.length; i += 2) { URL url = this.getClass().getResource(registrations[i + 1]); if (url != null) { register(registrations[i], url.toString()); } } // FIXME - validate the "version" attribute of the rss element? // Add the rules for the Channel object addObjectCreate("rss/channel", channelClass); addCallMethod("rss/channel/copyright", "setCopyright", 0); addCallMethod("rss/channel/description", "setDescription", 0); addCallMethod("rss/channel/docs", "setDocs", 0); addCallMethod("rss/channel/language", "setLanguage", 0); addCallMethod("rss/channel/lastBuildDate", "setLastBuildDate", 0); addCallMethod("rss/channel/link", "setLink", 0); addCallMethod("rss/channel/managingEditor", "setManagingEditor", 0); addCallMethod("rss/channel/pubDate", "setPubDate", 0); addCallMethod("rss/channel/rating", "setRating", 0); addCallMethod("rss/channel/skipDays/day", "addSkipDay", 0); addCallMethod("rss/channel/skipHours/hour", "addSkipHour", 0); addCallMethod("rss/channel/title", "setTitle", 0); addCallMethod("rss/channel/webMaster", "setWebMaster", 0); // Add the rules for the Image object addObjectCreate("rss/channel/image", imageClass); addSetNext("rss/channel/image", "setImage", "org.apache.commons.digester.rss.Image"); addCallMethod("rss/channel/image/description", "setDescription", 0); addCallMethod("rss/channel/image/height", "setHeight", 0, new Class[]{ Integer.TYPE }); addCallMethod("rss/channel/image/link", "setLink", 0); addCallMethod("rss/channel/image/title", "setTitle", 0); addCallMethod("rss/channel/image/url", "setURL", 0); addCallMethod("rss/channel/image/width", "setWidth", 0, new Class[]{ Integer.TYPE }); // Add the rules for the Item object addObjectCreate("rss/channel/item", itemClass); addSetNext("rss/channel/item", "addItem", "org.apache.commons.digester.rss.Item"); addCallMethod("rss/channel/item/description", "setDescription", 0); addCallMethod("rss/channel/item/link", "setLink", 0); addCallMethod("rss/channel/item/title", "setTitle", 0); // Add the rules for the TextInput object addObjectCreate("rss/channel/textinput", textInputClass); addSetNext("rss/channel/textinput", "setTextInput", "org.apache.commons.digester.rss.TextInput"); addCallMethod("rss/channel/textinput/description", "setDescription", 0); addCallMethod("rss/channel/textinput/link", "setLink", 0); addCallMethod("rss/channel/textinput/name", "setName", 0); addCallMethod("rss/channel/textinput/title", "setTitle", 0); // Mark this digester as having been configured configured = true; } // ------------------------------------------------------ Test Main Program /** * Test main program that parses the channel description included in this * package as a static resource. * * @param args The command line arguments (ignored) */ public static void main(String args[]) { try { System.out.println("RSSDigester Test Program"); System.out.println("Opening input stream ..."); InputStream is = RSSDigester.class.getResourceAsStream ("/org/apache/commons/digester/rss/rss-example.xml"); System.out.println("Creating new digester ..."); RSSDigester digester = new RSSDigester(); if ((args.length > 0) && (args[0].equals("-debug"))) { digester.setLogger(LogFactory.getLog("RSSDigester")); } System.out.println("Parsing input stream ..."); Channel channel = (Channel) digester.parse(is); System.out.println("Closing input stream ..."); is.close(); System.out.println("Dumping channel info ..."); channel.render(System.out); } catch (Exception e) { System.out.println("-->Exception"); e.printStackTrace(System.out); } } } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/betwixt/src/test/org/apache/commons/digester/rss/Item.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/betwixt/src/test/org/apache/commons/digester/r0000664000175000017500000000522011602216727031552 0ustar davedave/* * Copyright 2001-2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.digester.rss; import java.io.PrintWriter; import java.io.Serializable; /** *

Implementation object representing an item in the * Rich Site Summary DTD, version 0.91. This class may be subclassed * to further specialize its behavior.

*/ public class Item implements Serializable { // ------------------------------------------------------------- Properties /** * The item description (1-500 characters). */ protected String description = null; public String getDescription() { return (this.description); } public void setDescription(String description) { this.description = description; } /** * The item link (1-500 characters). */ protected String link = null; public String getLink() { return (this.link); } public void setLink(String link) { this.link = link; } /** * The item title (1-100 characters). */ protected String title = null; public String getTitle() { return (this.title); } public void setTitle(String title) { this.title = title; } // -------------------------------------------------------- Package Methods /** * Render this channel as XML conforming to the RSS 0.91 specification, * to the specified writer. * * @param writer The writer to render output to */ void render(PrintWriter writer) { writer.println(" "); writer.print(" "); writer.print(title); writer.println(""); writer.print(" "); writer.print(link); writer.println(""); if (description != null) { writer.print(" "); writer.print(description); writer.println(""); } writer.println(" "); } } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/betwixt/src/test/org/apache/commons/digester/rss/Image.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/betwixt/src/test/org/apache/commons/digester/r0000664000175000017500000000737011602216727031562 0ustar davedave/* * Copyright 2001-2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.digester.rss; import java.io.PrintWriter; import java.io.Serializable; /** *

Implementation object representing an image in the * Rich Site Summary DTD, version 0.91. This class may be subclassed * to further specialize its behavior.

*/ public class Image implements Serializable { // ------------------------------------------------------------- Properties /** * The image description (1-100 characters). */ protected String description = null; public String getDescription() { return (this.description); } public void setDescription(String description) { this.description = description; } /** * The image height in pixels (1-400). */ protected int height = 31; public int getHeight() { return (this.height); } public void setHeight(int height) { this.height = height; } /** * The image link (1-500 characters). */ protected String link = null; public String getLink() { return (this.link); } public void setLink(String link) { this.link = link; } /** * The image alternate text (1-100 characters). */ protected String title = null; public String getTitle() { return (this.title); } public void setTitle(String title) { this.title = title; } /** * The image location URL (1-500 characters). */ protected String url = null; public String getURL() { return (this.url); } public void setURL(String url) { this.url = url; } /** * The image width in pixels (1-400). */ protected int width = 31; public int getWidth() { return (this.width); } public void setWidth(int width) { this.width = width; } // -------------------------------------------------------- Package Methods /** * Render this channel as XML conforming to the RSS 0.91 specification, * to the specified writer. * * @param writer The writer to render output to */ void render(PrintWriter writer) { writer.println(" "); writer.print(" "); writer.print(title); writer.println(""); writer.print(" "); writer.print(url); writer.println(""); if (link != null) { writer.print(" "); writer.print(link); writer.println(""); } writer.print(" "); writer.print(width); writer.println(""); writer.print(" "); writer.print(height); writer.println(""); if (description != null) { writer.print(" "); writer.print(description); writer.println(""); } writer.println(" "); } } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/betwixt/src/test/org/apache/commons/digester/rss/TextInput.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/betwixt/src/test/org/apache/commons/digester/r0000664000175000017500000000576211602216727031565 0ustar davedave/* * Copyright 2001-2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.digester.rss; import java.io.PrintWriter; import java.io.Serializable; /** *

Implementation object representing a textinput in the * Rich Site Summary DTD, version 0.91. This class may be subclassed * to further specialize its behavior.

*/ public class TextInput implements Serializable { // ------------------------------------------------------------- Properties /** * The text input description (1-100 characters). */ protected String description = null; public String getDescription() { return (this.description); } public void setDescription(String description) { this.description = description; } /** * The text input link (1-500 characters). */ protected String link = null; public String getLink() { return (this.link); } public void setLink(String link) { this.link = link; } /** * The text input field name (1-100 characters). */ protected String name = null; public String getName() { return (this.name); } public void setName(String name) { this.name = name; } /** * The text input submit button label (1-100 characters). */ protected String title = null; public String getTitle() { return (this.title); } public void setTitle(String title) { this.title = title; } // -------------------------------------------------------- Package Methods /** * Render this channel as XML conforming to the RSS 0.91 specification, * to the specified writer. * * @param writer The writer to render output to */ void render(PrintWriter writer) { writer.println(" "); writer.print(" "); writer.print(title); writer.println(""); writer.print(" "); writer.print(description); writer.println(""); writer.print(" "); writer.print(name); writer.println(""); writer.print(" "); writer.print(link); writer.println(""); writer.println(" "); } } ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/betwixt/src/test/org/apache/commons/digester/rss/Channel.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/betwixt/src/test/org/apache/commons/digester/r0000664000175000017500000003545011602216727031562 0ustar davedave/* * Copyright 2001-2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.digester.rss; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.Serializable; import java.io.UnsupportedEncodingException; import java.io.Writer; import java.util.ArrayList; /** *

Implementation object representing a channel in the * Rich Site Summary DTD, version 0.91. This class may be subclassed * to further specialize its behavior.

*/ public class Channel implements Serializable { // ----------------------------------------------------- Instance Variables /** * The set of items associated with this Channel. */ protected ArrayList items = new ArrayList(); /** * The set of skip days for this channel. */ protected ArrayList skipDays = new ArrayList(); /** * The set of skip hours for this channel. */ protected ArrayList skipHours = new ArrayList(); // ------------------------------------------------------------- Properties /** * The channel copyright (1-100 characters). */ protected String copyright = null; public String getCopyright() { return (this.copyright); } public void setCopyright(String copyright) { this.copyright = copyright; } /** * The channel description (1-500 characters). */ protected String description = null; public String getDescription() { return (this.description); } public void setDescription(String description) { this.description = description; } /** * The channel description file URL (1-500 characters). */ protected String docs = null; public String getDocs() { return (this.docs); } public void setDocs(String docs) { this.docs = docs; } /** * The image describing this channel. */ protected Image image = null; public Image getImage() { return (this.image); } public void setImage(Image image) { this.image = image; } /** * The channel language (2-5 characters). */ protected String language = null; public String getLanguage() { return (this.language); } public void setLanguage(String language) { this.language = language; } /** * The channel last build date (1-100 characters). */ protected String lastBuildDate = null; public String getLastBuildDate() { return (this.lastBuildDate); } public void setLastBuildDate(String lastBuildDate) { this.lastBuildDate = lastBuildDate; } /** * The channel link (1-500 characters). */ protected String link = null; public String getLink() { return (this.link); } public void setLink(String link) { this.link = link; } /** * The managing editor (1-100 characters). */ protected String managingEditor = null; public String getManagingEditor() { return (this.managingEditor); } public void setManagingEditor(String managingEditor) { this.managingEditor = managingEditor; } /** * The channel publication date (1-100 characters). */ protected String pubDate = null; public String getPubDate() { return (this.pubDate); } public void setPubDate(String pubDate) { this.pubDate = pubDate; } /** * The channel rating (20-500 characters). */ protected String rating = null; public String getRating() { return (this.rating); } public void setRating(String rating) { this.rating = rating; } /** * The text input description for this channel. */ protected TextInput textInput = null; public TextInput getTextInput() { return (this.textInput); } public void setTextInput(TextInput textInput) { this.textInput = textInput; } /** * The channel title (1-100 characters). */ protected String title = null; public String getTitle() { return (this.title); } public void setTitle(String title) { this.title = title; } /** * The RSS specification version number used to create this Channel. */ protected double version = 0.91; public double getVersion() { return (this.version); } public void setVersion(double version) { this.version = version; } /** * The webmaster email address (1-100 characters). */ protected String webMaster = null; public String getWebMaster() { return (this.webMaster); } public void setWebMaster(String webMaster) { this.webMaster = webMaster; } // --------------------------------------------------------- Public Methods /** * Add an additional item. * * @param item The item to be added */ public void addItem(Item item) { synchronized (items) { items.add(item); } } /** * Add an additional skip day name. * * @param skipDay The skip day to be added */ public void addSkipDay(String skipDay) { synchronized (skipDays) { skipDays.add(skipDay); } } /** * Add an additional skip hour name. * * @param skipHour The skip hour to be added */ public void addSkipHour(String skipHour) { synchronized (skipHours) { skipHours.add(skipHour); } } /** * Return the items for this channel. */ public Item[] findItems() { synchronized (items) { Item items[] = new Item[this.items.size()]; return ((Item[]) this.items.toArray(items)); } } /** * Return the items for this channel. */ public Item[] getItems() { return findItems(); } /** * Return the skip days for this channel. */ public String[] findSkipDays() { synchronized (skipDays) { String skipDays[] = new String[this.skipDays.size()]; return ((String[]) this.skipDays.toArray(skipDays)); } } /** * Return the skip hours for this channel. */ public String[] getSkipHours() { return findSkipHours(); } /** * Return the skip hours for this channel. */ public String[] findSkipHours() { synchronized (skipHours) { String skipHours[] = new String[this.skipHours.size()]; return ((String[]) this.skipHours.toArray(skipHours)); } } /** * Return the skip days for this channel. */ public String[] getSkipDays() { return findSkipDays(); } /** * Remove an item for this channel. * * @param item The item to be removed */ public void removeItem(Item item) { synchronized (items) { items.remove(item); } } /** * Remove a skip day for this channel. * * @param skipDay The skip day to be removed */ public void removeSkipDay(String skipDay) { synchronized (skipDays) { skipDays.remove(skipDay); } } /** * Remove a skip hour for this channel. * * @param skipHour The skip hour to be removed */ public void removeSkipHour(String skipHour) { synchronized (skipHours) { skipHours.remove(skipHour); } } /** * Render this channel as XML conforming to the RSS 0.91 specification, * to the specified output stream, with no indication of character * encoding. * * @param stream The output stream to write to */ public void render(OutputStream stream) { try { render(stream, null); } catch (UnsupportedEncodingException e) { ; // Can not happen } } /** * Render this channel as XML conforming to the RSS 0.91 specification, * to the specified output stream, with the specified character encoding. * * @param stream The output stream to write to * @param encoding The character encoding to declare, or null * for no declaration * * @exception UnsupportedEncodingException if the named encoding * is not supported */ public void render(OutputStream stream, String encoding) throws UnsupportedEncodingException { PrintWriter pw = null; if (encoding == null) { pw = new PrintWriter(stream); } else { pw = new PrintWriter(new OutputStreamWriter(stream, encoding)); } render(pw, encoding); pw.flush(); } /** * Render this channel as XML conforming to the RSS 0.91 specification, * to the specified writer, with no indication of character encoding. * * @param writer The writer to render output to */ public void render(Writer writer) { render(writer, null); } /** * Render this channel as XML conforming to the RSS 0.91 specification, * to the specified writer, indicating the specified character encoding. * * @param writer The writer to render output to * @param encoding The character encoding to declare, or null * for no declaration */ public void render(Writer writer, String encoding) { PrintWriter pw = new PrintWriter(writer); render(pw, encoding); pw.flush(); } /** * Render this channel as XML conforming to the RSS 0.91 specification, * to the specified writer, with no indication of character encoding. * * @param writer The writer to render output to */ public void render(PrintWriter writer) { render(writer, null); } /** * Render this channel as XML conforming to the RSS 0.91 specification, * to the specified writer, indicating the specified character encoding. * * @param writer The writer to render output to * @param encoding The character encoding to declare, or null * for no declaration */ public void render(PrintWriter writer, String encoding) { writer.print(""); writer.println(); writer.println(""); writer.println(); writer.println(""); writer.println(); writer.println(" "); writer.println(); writer.print(" "); writer.print(title); writer.println(""); writer.print(" "); writer.print(description); writer.println(""); writer.print(" "); writer.print(link); writer.println(""); writer.print(" "); writer.print(language); writer.println(""); if (rating != null) { writer.print(" "); writer.print(rating); writer.println(""); } if (copyright != null) { writer.print(" "); writer.print(copyright); writer.print(""); } if (pubDate != null) { writer.print(" "); writer.print(pubDate); writer.println(""); } if (lastBuildDate != null) { writer.print(" "); writer.print(lastBuildDate); writer.println(""); } if (docs != null) { writer.print(" "); writer.print(docs); writer.println(""); } if (managingEditor != null) { writer.print(" "); writer.print(managingEditor); writer.println(""); } if (webMaster != null) { writer.print(" "); writer.print(webMaster); writer.println(""); } writer.println(); if (image != null) { image.render(writer); writer.println(); } if (textInput != null) { textInput.render(writer); writer.println(); } String skipDays[] = findSkipDays(); if (skipDays.length > 0) { writer.println(" "); for (int i = 0; i < skipDays.length; i++) { writer.print(" "); writer.print(skipDays[i]); writer.println(""); } writer.println(" "); } String skipHours[] = findSkipHours(); if (skipHours.length > 0) { writer.println(" "); for (int i = 0; i < skipHours.length; i++) { writer.print(" "); writer.print(skipHours[i]); writer.println(""); } writer.println(" "); writer.println(); } Item items[] = findItems(); for (int i = 0; i < items.length; i++) { items[i].render(writer); writer.println(); } writer.println(" "); writer.println(); writer.println(""); } } jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/betwixt/src/test/org/apache/commons/jelly/0000775000175000017500000000000011602216727030700 5ustar davedave././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/betwixt/src/test/org/apache/commons/jelly/betwixt/jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/betwixt/src/test/org/apache/commons/jelly/betw0000775000175000017500000000000011602216727031562 5ustar davedave././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/betwixt/src/test/org/apache/commons/jelly/betwixt/rss-example.xmljenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/betwixt/src/test/org/apache/commons/jelly/betw0000664000175000017500000000535211602216727031571 0ustar davedave MozillaZine http://www.mozillazine.org Your source for Mozilla news, advocacy, interviews, builds, and more! en-US (PICS-1.1 "http://www.rsac.org/ratingsv01.html" 2 gen true comment "RSACi North America Server" for "http://www.rsac.org" on "1996.04.16T08:15-0500" r (n 0 s 0 v 0 l 0)) MozillaZine http://www.mozillazine.org/image/mynetscape88.gif http://www.mozillazine.org 88 31 Articles, discussions, builds, and more... Java2 in Navigator 5? http://www.mozillazine.org/talkback.html?article=607 Will Java2 be an integrated part of Navigator 5? Read more about it in this discussion... Communicator 4.61 Out http://www.mozillazine.org/talkback.html?article=606 The latest version of Communicator is now available. It includes security enhancements and various bug fixes. Mozilla Dispenses with Old, Proprietary DOM http://www.mozillazine.org/talkback.html?article=604 The Animation Contest is Now Closed http://www.mozillazine.org/talkback.html?article=603 Send Comments about MozillaZine? responseText http://www.mozillazine.org/cgi-bin/sampleonly.cgi Tuesday ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/betwixt/src/test/org/apache/commons/jelly/betwixt/TestJelly.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/betwixt/src/test/org/apache/commons/jelly/betw0000664000175000017500000000241511602216727031566 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.betwixt; import junit.framework.TestSuite; import junit.textui.TestRunner; import org.apache.commons.jelly.tags.junit.JellyTestSuite; /** * A helper class to run jelly test cases as part of Ant's JUnit tests * * @author James Strachan * @version $Revision: 155420 $ */ public class TestJelly extends JellyTestSuite { public static void main( String[] args ) throws Exception { TestRunner.run( suite() ); } public static TestSuite suite() throws Exception { return createTestSuite(TestJelly.class, "suite.jelly"); } } ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/betwixt/src/test/org/apache/commons/jelly/betwixt/suite.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/betwixt/src/test/org/apache/commons/jelly/betw0000664000175000017500000000710011602216727031562 0ustar davedave MozillaZine http://www.mozillazine.org Your source for Mozilla news, advocacy, interviews, builds, and more! en-US (PICS-1.1 "http://www.rsac.org/ratingsv01.html" 2 gen true comment "RSACi North America Server" for "http://www.rsac.org" on "1996.04.16T08:15-0500" r (n 0 s 0 v 0 l 0)) MozillaZine http://www.mozillazine.org/image/mynetscape88.gif http://www.mozillazine.org 88 31 Articles, discussions, builds, and more... Java2 in Navigator 5? http://www.mozillazine.org/talkback.html?article=607 Will Java2 be an integrated part of Navigator 5? Read more about it in this discussion... Communicator 4.61 Out http://www.mozillazine.org/talkback.html?article=606 The latest version of Communicator is now available. It includes security enhancements and various bug fixes. Mozilla Dispenses with Old, Proprietary DOM http://www.mozillazine.org/talkback.html?article=604 The Animation Contest is Now Closed http://www.mozillazine.org/talkback.html?article=603 Send Comments about MozillaZine? responseText http://www.mozillazine.org/cgi-bin/sampleonly.cgi Tuesday ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/betwixt/src/test/org/apache/commons/jelly/betwixt/common.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/betwixt/src/test/org/apache/commons/jelly/betw0000664000175000017500000000203711602216727031566 0ustar davedave Parsed channel with title: ${channel.title} jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/betwixt/src/java/0000775000175000017500000000000011602216727024040 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/betwixt/src/java/org/0000775000175000017500000000000011602216727024627 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/betwixt/src/java/org/apache/0000775000175000017500000000000011602216727026050 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/betwixt/src/java/org/apache/commons/0000775000175000017500000000000011602216727027523 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/betwixt/src/java/org/apache/commons/jelly/0000775000175000017500000000000011602216727030642 5ustar davedave././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/betwixt/src/java/org/apache/commons/jelly/tags/jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/betwixt/src/java/org/apache/commons/jelly/tags0000775000175000017500000000000011602216727031521 5ustar davedave././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/betwixt/src/java/org/apache/commons/jelly/tags/betwixt/jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/betwixt/src/java/org/apache/commons/jelly/tags0000775000175000017500000000000011602216727031521 5ustar davedave././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/betwixt/src/java/org/apache/commons/jelly/tags/betwixt/BetwixtTagLibrary.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/betwixt/src/java/org/apache/commons/jelly/tags0000664000175000017500000000224011602216727031521 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.betwixt; import org.apache.commons.jelly.TagLibrary; /** * A Jelly custom tag library that uses the Betwixt project to parse XML and turn it into beans or * turn beans into XML * * @author James Strachan * @version $Revision: 155420 $ */ public class BetwixtTagLibrary extends TagLibrary { public BetwixtTagLibrary() { registerTag( "parse", ParseTag.class ); registerTag( "introspector", IntrospectorTag.class ); } } ././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/betwixt/src/java/org/apache/commons/jelly/tags/betwixt/package.htmljenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/betwixt/src/java/org/apache/commons/jelly/tags0000664000175000017500000000154011602216727031523 0ustar davedave

A tag library for turning XML into beans or beans into XML using the Betwixt library

././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/betwixt/src/java/org/apache/commons/jelly/tags/betwixt/ParseTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/betwixt/src/java/org/apache/commons/jelly/tags0000664000175000017500000001521711602216727031531 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.betwixt; import java.beans.IntrospectionException; import java.io.IOException; import java.net.URL; import org.apache.commons.betwixt.XMLIntrospector; import org.apache.commons.betwixt.io.BeanReader; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.MissingAttributeException; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.jelly.util.ClassLoaderUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.xml.sax.SAXException; /** * Parses some XML specified via the given URI (which can be relative or an absolute URL) and outputs the * parsed object. Typically this tag is customized by setting the introspector attribute or nesting a child * introspector tag inside it.

* * @author James Strachan * @version $Revision: 155420 $ */ public class ParseTag extends TagSupport { /** The Log to which logging calls will be made. */ private static final Log log = LogFactory.getLog(ParseTag.class); /** the BeanReader used to parse the XML */ private BeanReader reader = new BeanReader(); private String uri; private String var; private String rootClass; private String path; private XMLIntrospector introspector; private boolean useContextClassLoader; private ClassLoader classLoader; public ParseTag() { } // Tag interface //------------------------------------------------------------------------- public void doTag(final XMLOutput output) throws MissingAttributeException, JellyTagException { if ( var == null ) { throw new MissingAttributeException( "var" ); } if ( rootClass == null ) { throw new MissingAttributeException( "rootClass" ); } reader.setXMLIntrospector(getIntrospector()); Class theClass = null; try { theClass = getClassLoader().loadClass( rootClass ); } catch (Exception e) { throw new JellyTagException( "Could not load class called: " + rootClass, e ); } if ( theClass == null ) { throw new JellyTagException( "Could not load class called: " + rootClass ); } try { if ( path != null ) { reader.registerBeanClass( path, theClass ); } else { reader.registerBeanClass( theClass ); } } catch (IntrospectionException e) { throw new JellyTagException(e); } Object value = null; if ( uri != null ) { invokeBody(output); try { URL url = context.getResource( uri ); value = reader.parse( url.toString() ); } catch (IOException e) { throw new JellyTagException(e); } catch (SAXException e) { throw new JellyTagException(e); } } else { // invoke the body and pass that into the reader XMLOutput newOutput = new XMLOutput( reader ); invokeBody(newOutput); value = reader.getRoot(); } context.setVariable( var, value ); } // Properties //------------------------------------------------------------------------- /** * @return the introspector to be used, lazily creating one if required. */ public XMLIntrospector getIntrospector() { if (introspector == null) { introspector = new XMLIntrospector(); } return introspector; } /** * Sets the Betwixt XMLIntrospector instance used to define the metadata for how a * bean should appear as XML. */ public void setIntrospector(XMLIntrospector introspector) { this.introspector = introspector; } /** * Sets the URI from which XML is parsed. This can be relative to this Jelly script, use * an absolute URI or a full URL */ public void setUri(String uri) { this.uri = uri; } /** * Sets the variable name to output with the result of the XML parse. */ public void setVar(String var) { this.var = var; } /** * Sets the name of the root class to use for parsing the XML */ public void setRootClass(String rootClass) { this.rootClass = rootClass; } /** * Sets the path that the root class should be bound to. * This is optional and often unnecessary though can be used to ignore some wrapping * elements, such as the <rss> element in the RSS unit test. */ public void setPath(String path) { this.path = path; } /** * Sets whether or not the current threads's context class loader * should be used to load the bean classes or not. * This can be useful if running inside a web application or inside some * application server. */ public void setUseContextClassLoader(boolean useContextClassLoader) { this.useContextClassLoader = useContextClassLoader; } /** * Sets the ClassLoader to be used to load bean classes from. * If this is not specified then either the ClassLoader used to load this tag library * is used or, if the 'useContextClassLoader' property is true, then the * current threads context class loader is used instead. */ public void setClassLoader(ClassLoader classLoader) { this.classLoader = classLoader; } // Implementation methods //------------------------------------------------------------------------- /** * @return the ClassLoader to be used to load bean classes. */ protected ClassLoader getClassLoader() { return ClassLoaderUtils.getClassLoader(classLoader, useContextClassLoader, getClass()); } } ././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/betwixt/src/java/org/apache/commons/jelly/tags/betwixt/IntrospectorTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/betwixt/src/java/org/apache/commons/jelly/tags0000664000175000017500000001610511602216727031526 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.betwixt; import org.apache.commons.beanutils.ConversionException; import org.apache.commons.beanutils.ConvertUtils; import org.apache.commons.beanutils.Converter; import org.apache.commons.betwixt.XMLIntrospector; import org.apache.commons.betwixt.strategy.CapitalizeNameMapper; import org.apache.commons.betwixt.strategy.DecapitalizeNameMapper; import org.apache.commons.betwixt.strategy.HyphenatedNameMapper; import org.apache.commons.betwixt.strategy.NameMapper; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.MissingAttributeException; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** * Creates a Betwixt XMLIntrospector instance that can be used by the other Betwixt tags.

* * @author James Strachan * @version $Revision: 155420 $ */ public class IntrospectorTag extends TagSupport { /** The Log to which logging calls will be made. */ private static final Log log = LogFactory.getLog(IntrospectorTag.class); private XMLIntrospector introspector; private String var; static { // register converters to standard Strategies ConvertUtils.register( new Converter() { public Object convert(Class type, Object value) { if ( value instanceof String ) { return createNameMapper((String) value); } else if ( value == null ) { return null; } else { throw new ConversionException( "Don't know how to convert: " + value + " of type: " + value.getClass().getName() + " into a NameMapper" ); } } }, NameMapper.class ); } public IntrospectorTag() { } // Tag interface //------------------------------------------------------------------------- public void doTag(final XMLOutput output) throws MissingAttributeException, JellyTagException { if ( var == null ) { throw new MissingAttributeException( "var" ); } invokeBody(output); XMLIntrospector introspector = getIntrospector(); context.setVariable( var, introspector ); // now lets clear this introspector so that its recreated again next time this.introspector = null; } // Properties //------------------------------------------------------------------------- /** * @return the current XMLIntrospector, lazily creating one if required */ public XMLIntrospector getIntrospector() { if ( introspector == null ) { introspector = createIntrospector(); } return introspector; } /** * Sets whether attributes or elements should be used for primitive types. * The default is false. */ public void setAttributesForPrimitives(boolean attributesForPrimitives) { getIntrospector().setAttributesForPrimitives(attributesForPrimitives); } /** * Sets the name mapper used for element names. * You can also use the Strings 'lowercase', 'uppercase' or 'hyphenated' * as aliases to the common name mapping strategies or specify a class name String. */ public void setElementNameMapper(NameMapper nameMapper) { getIntrospector().setElementNameMapper(nameMapper); } /** * Sets the name mapper used for attribute names. * You can also use the Strings 'lowercase', 'uppercase' or 'hyphenated' * as aliases to the common name mapping strategies or specify a class name String. */ public void setAttributeNameMapper(NameMapper nameMapper) { getIntrospector().setAttributeNameMapper(nameMapper); } /** * Sets the variable name to output the new XMLIntrospector to. * If this attribute is not specified then this tag must be nested * inside an <parse> or <output> tag */ public void setVar(String var) { this.var = var; } // Implementation methods //------------------------------------------------------------------------- /** * Static helper method which will convert the given string into * standard named strategies such as 'lowercase', 'uppercase' or 'hyphenated' * or use the name as a class name and create a new instance. */ protected static NameMapper createNameMapper(String name) { if ( name.equalsIgnoreCase( "lowercase" ) ) { return new DecapitalizeNameMapper(); } else if ( name.equalsIgnoreCase( "uppercase" ) ) { return new CapitalizeNameMapper(); } else if ( name.equalsIgnoreCase( "hyphenated" ) ) { return new HyphenatedNameMapper(); } else { // lets try load the class of this name Class theClass = null; try { theClass = Thread.currentThread().getContextClassLoader().loadClass( name ); } catch (Exception e) { throw new ConversionException( "Could not load class called: " + name, e ); } Object object = null; try { object = theClass.newInstance(); } catch (Exception e) { throw new ConversionException( "Could not instantiate an instance of: " + name, e ); } if ( object instanceof NameMapper ) { return (NameMapper) object; } if ( object == null ) { throw new ConversionException( "No NameMapper created for type: " + name ); } else { throw new ConversionException( "Created object: " + object + " is not a NameMapper! Its type is: " + object.getClass().getName() ); } } } /** * Factory method to create a new XMLIntrospector */ protected XMLIntrospector createIntrospector() { return new XMLIntrospector(); } } jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/betwixt/xdocs/0000775000175000017500000000000011602216727023450 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/betwixt/xdocs/index.xml0000664000175000017500000000217211602216727025303 0ustar davedave Betwixt Tag Library dIon Gillard

A tag library for turning XML into beans or beans into XML using the Betwixt library. See the tags for more information.

jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/betwixt/xdocs/changes.xml0000664000175000017500000000227211602216727025605 0ustar davedave Changes dIon Gillard Move to betwixt 0.6 Move to betwixt 0.5 and digester 1.6 Initial Release jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/betwixt/xdocs/navigation.xml0000664000175000017500000000170111602216727026330 0ustar davedave Betwixt Tag Library jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/betwixt/maven.xml0000664000175000017500000000124011602216727024155 0ustar davedave jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/bsf/0000775000175000017500000000000011602216727021414 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/bsf/project.properties0000664000175000017500000000144511602216727025204 0ustar davedave# # Copyright 2002,2004 The Apache Software Foundation. # # 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. # # ------------------------------------------------------------------- # P R O J E C T P R O P E R T I E S # ------------------------------------------------------------------- jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/bsf/project.xml0000664000175000017500000000321611602216727023606 0ustar davedave ${basedir}/../tag-project.xml commons-jelly-tags-bsf commons-jelly-tags-bsf 1.0.1-SNAPSHOT org.apache.commons.jelly.tags.bsf This is a Jelly interface for the Bean Scripting Framework Commons Jelly BSF Tag Library 1.0 1.0 COMMONS_JELLY_BSF-1_0 bsf bsf 2.3.0 http://jakarta.apache.org/bsf jakarta-bsf jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/bsf/build.xml0000664000175000017500000001753011602216727023243 0ustar davedave jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/bsf/src/0000775000175000017500000000000011602216727022203 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/bsf/src/test/0000775000175000017500000000000011602216727023162 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/bsf/src/test/org/0000775000175000017500000000000011602216727023751 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/bsf/src/test/org/apache/0000775000175000017500000000000011602216727025172 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/bsf/src/test/org/apache/commons/0000775000175000017500000000000011602216727026645 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/bsf/src/test/org/apache/commons/jelly/0000775000175000017500000000000011602216727027764 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/bsf/src/test/org/apache/commons/jelly/tags/0000775000175000017500000000000011602216727030722 5ustar davedave././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/bsf/src/test/org/apache/commons/jelly/tags/bsf/jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/bsf/src/test/org/apache/commons/jelly/tags/bsf0000775000175000017500000000000011602216727031415 5ustar davedave././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/bsf/src/test/org/apache/commons/jelly/tags/bsf/example.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/bsf/src/test/org/apache/commons/jelly/tags/bsf0000664000175000017500000000137611602216727031426 0ustar davedave ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/bsf/src/test/org/apache/commons/jelly/tags/javascript/jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/bsf/src/test/org/apache/commons/jelly/tags/jav0000775000175000017500000000000011602216727031423 5ustar davedave././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/bsf/src/test/org/apache/commons/jelly/tags/javascript/example.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/bsf/src/test/org/apache/commons/jelly/tags/jav0000664000175000017500000000140311602216727031423 0ustar davedave jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/bsf/src/java/0000775000175000017500000000000011602216727023124 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/bsf/src/java/org/0000775000175000017500000000000011602216727023713 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/bsf/src/java/org/apache/0000775000175000017500000000000011602216727025134 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/bsf/src/java/org/apache/commons/0000775000175000017500000000000011602216727026607 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/bsf/src/java/org/apache/commons/jelly/0000775000175000017500000000000011602216727027726 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/bsf/src/java/org/apache/commons/jelly/tags/0000775000175000017500000000000011602216727030664 5ustar davedave././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/bsf/src/java/org/apache/commons/jelly/tags/bsf/jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/bsf/src/java/org/apache/commons/jelly/tags/bsf0000775000175000017500000000000011602216727031357 5ustar davedave././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/bsf/src/java/org/apache/commons/jelly/tags/bsf/BSFTagLibrary.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/bsf/src/java/org/apache/commons/jelly/tags/bsf0000664000175000017500000000544011602216727031364 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.bsf; import org.apache.commons.jelly.JellyException; import org.apache.commons.jelly.Tag; import org.apache.commons.jelly.expression.ExpressionFactory; import org.apache.commons.jelly.impl.TagFactory; import org.apache.commons.jelly.tags.core.CoreTagLibrary; import org.xml.sax.Attributes; import org.apache.bsf.BSFEngine; import org.apache.bsf.BSFException; /** Describes the Taglib. This class could be generated by XDoclet * * @author James Strachan * @version $Revision: 155420 $ */ public class BSFTagLibrary extends CoreTagLibrary { private BSFExpressionFactory expressionFactory = new BSFExpressionFactory(); public BSFTagLibrary() { registerTagFactory( "script", new TagFactory() { public Tag createTag(String name, Attributes attributes) throws JellyException { return createScriptTag(name, attributes); } } ); } public BSFTagLibrary(String language) { this(); setLanguage(language); } public void setLanguage(String language) { expressionFactory.setLanguage(language); } /** Allows derived tag libraries to use their own factory */ protected ExpressionFactory getExpressionFactory() { return expressionFactory; } protected BSFEngine getBSFEngine() throws BSFException { return expressionFactory.getBSFEngine(); } /** * Factory method to create a new ScriptTag with a BSFEngine * * @param name is the name of the tag (typically 'script') * @param attributes the attributes of the tag * @return Tag */ protected Tag createScriptTag(String name, Attributes attributes) throws JellyException { try { return new ScriptTag( expressionFactory.getBSFEngine(), expressionFactory.getBSFManager()); } catch (BSFException e) { throw new JellyException("Failed to create BSFEngine: " + e, e); } } } ././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/bsf/src/java/org/apache/commons/jelly/tags/bsf/JellyContextRegistry.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/bsf/src/java/org/apache/commons/jelly/tags/bsf0000664000175000017500000000364511602216727031371 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.bsf; import org.apache.bsf.util.ObjectRegistry; import org.apache.commons.jelly.JellyContext; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** A BSF ObjectRegistry which uses the Context to find and * register objects * * @author James Strachan * @version $Revision: 155420 $ */ public class JellyContextRegistry extends ObjectRegistry { /** The Log to which logging calls will be made. */ private static final Log log = LogFactory.getLog(JellyContextRegistry.class); /** The context */ private JellyContext context; public JellyContextRegistry() { } public JellyContext getJellyContext() { return context; } public void setJellyContext(JellyContext context) { this.context = context; } // ObjectRegistry interface //------------------------------------------------------------------------- public Object lookup(String name) { return context.getVariable(name); } public void register(String name, Object value) { context.setVariable(name, value); } public void unregister(String name) { context.removeVariable(name); } } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/bsf/src/java/org/apache/commons/jelly/tags/bsf/BSFExpression.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/bsf/src/java/org/apache/commons/jelly/tags/bsf0000664000175000017500000000607611602216727031372 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.bsf; import org.apache.bsf.BSFEngine; import org.apache.bsf.BSFManager; import java.util.Iterator; import org.apache.commons.jelly.JellyContext; import org.apache.commons.jelly.expression.ExpressionSupport; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** Represents a BSF expression * * @author James Strachan * @version $Revision: 155420 $ */ public class BSFExpression extends ExpressionSupport { /** The Log to which logging calls will be made. */ private static final Log log = LogFactory.getLog( BSFExpression.class ); /** The expression */ private String text; /** The BSF Engine to evaluate expressions */ private BSFEngine engine; /** The BSF Manager to evaluate expressions */ private BSFManager manager; /** The adapter to BSF's ObjectRegistry that uses the JellyContext */ private JellyContextRegistry registry; public BSFExpression(String text, BSFEngine engine, BSFManager manager, JellyContextRegistry registry) { this.text = text; this.engine = engine; this.manager = manager; this.registry = registry; } // Expression interface //------------------------------------------------------------------------- public String getExpressionText() { return "${" + text + "}"; } public Object evaluate(JellyContext context) { // XXXX: unfortunately we must sychronize evaluations // so that we can swizzle in the context. // maybe we could create an expression from a context // (and so create a BSFManager for a context) synchronized (registry) { registry.setJellyContext(context); try { // XXXX: hack - there must be a better way!!! for ( Iterator iter = context.getVariableNames(); iter.hasNext(); ) { String name = (String) iter.next(); Object value = context.getVariable( name ); manager.declareBean( name, value, value.getClass() ); } return engine.eval( text, -1, -1, text ); } catch (Exception e) { log.warn( "Caught exception evaluating: " + text + ". Reason: " + e, e ); return null; } } } } ././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/bsf/src/java/org/apache/commons/jelly/tags/bsf/BSFExpressionFactory.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/bsf/src/java/org/apache/commons/jelly/tags/bsf0000664000175000017500000000662311602216727031370 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.bsf; import org.apache.commons.jelly.JellyException; import org.apache.commons.jelly.expression.Expression; import org.apache.commons.jelly.expression.ExpressionFactory; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.bsf.BSFEngine; import org.apache.bsf.BSFException; import org.apache.bsf.BSFManager; /** Represents a factory of BSF expressions * * @author James Strachan * @version $Revision: 155420 $ */ public class BSFExpressionFactory implements ExpressionFactory { /** The logger of messages */ private Log log = LogFactory.getLog( getClass() ); private String language = "javascript"; private BSFManager manager; private BSFEngine engine; private JellyContextRegistry registry = new JellyContextRegistry(); public BSFExpressionFactory() { } // Properties //------------------------------------------------------------------------- /** @return the BSF language to be used */ public String getLanguage() { return language; } public void setLanguage(String language) { this.language = language; } /** @return the BSF Engine to be used by this expression factory */ public BSFEngine getBSFEngine() throws BSFException { if ( engine == null ) { engine = createBSFEngine(); } return engine; } public void setBSFEngine(BSFEngine engine) { this.engine = engine; } public BSFManager getBSFManager() { if ( manager == null ) { manager = createBSFManager(); manager.setObjectRegistry( registry ); } return manager; } public void setBSFManager(BSFManager manager) { this.manager = manager; manager.setObjectRegistry( registry ); } // ExpressionFactory interface //------------------------------------------------------------------------- public Expression createExpression(String text) throws JellyException { try { return new BSFExpression( text, getBSFEngine(), getBSFManager(), registry ); } catch (BSFException e) { throw new JellyException("Could not obtain BSF engine",e); } } // Implementation methods //------------------------------------------------------------------------- /** Factory method */ protected BSFEngine createBSFEngine() throws BSFException { return getBSFManager().loadScriptingEngine( getLanguage() ); } /** Factory method */ protected BSFManager createBSFManager() { BSFManager answer = new BSFManager(); return answer; } } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/bsf/src/java/org/apache/commons/jelly/tags/bsf/package.htmljenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/bsf/src/java/org/apache/commons/jelly/tags/bsf0000664000175000017500000000144611602216727031366 0ustar davedave

A collection of tag libraries for working with BSF based scripting languages like JavaScript, Jython and PNuts

././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/bsf/src/java/org/apache/commons/jelly/tags/bsf/PNutsTagLibrary.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/bsf/src/java/org/apache/commons/jelly/tags/bsf0000664000175000017500000000224511602216727031364 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.bsf; import org.apache.bsf.BSFManager; /** Describes the Taglib. This class could be generated by XDoclet * * @author James Strachan * @version $Revision: 155420 $ */ public class PNutsTagLibrary extends BSFTagLibrary { public PNutsTagLibrary() { BSFManager.registerScriptingEngine( "pnuts", "pnuts.ext.PnutsBSFEngine", new String[]{"pnut"} ); setLanguage( "pnuts" ); } } ././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/bsf/src/java/org/apache/commons/jelly/tags/bsf/JavaScriptTagLibrary.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/bsf/src/java/org/apache/commons/jelly/tags/bsf0000664000175000017500000000176311602216727031370 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.bsf; /** Describes the Taglib. This class could be generated by XDoclet * * @author James Strachan * @version $Revision: 155420 $ */ public class JavaScriptTagLibrary extends BSFTagLibrary { public JavaScriptTagLibrary() { setLanguage( "javascript" ); } } ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/bsf/src/java/org/apache/commons/jelly/tags/bsf/ScriptTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/bsf/src/java/org/apache/commons/jelly/tags/bsf0000664000175000017500000001141211602216727031360 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.bsf; import java.util.Iterator; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.LocationAware; import org.apache.commons.jelly.MissingAttributeException; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.bsf.BSFEngine; import org.apache.bsf.BSFManager; import org.apache.bsf.BSFException; /** * A tag which evaluates its body using the current scripting language * * @author James Strachan * @version $Revision: 155420 $ */ public class ScriptTag extends TagSupport implements LocationAware { /** The Log to which logging calls will be made. */ private static final Log log = LogFactory.getLog(ScriptTag.class.getName() + ".evaluating"); private BSFEngine engine; private BSFManager manager; private String elementName; private String fileName; private int columnNumber; private int lineNumber; public ScriptTag(BSFEngine engine, BSFManager manager) { this.engine = engine; this.manager = manager; } // Tag interface //------------------------------------------------------------------------- public void doTag(XMLOutput output) throws MissingAttributeException, JellyTagException { String text = getBodyText(); log.debug(text); // XXXX: unfortunately we must sychronize evaluations // so that we can swizzle in the context. // maybe we could create an expression from a context // (and so create a BSFManager for a context) synchronized (getRegistry()) { getRegistry().setJellyContext(context); try { // XXXX: hack - there must be a better way!!! for ( Iterator iter = context.getVariableNames(); iter.hasNext(); ) { String name = (String) iter.next(); Object value = context.getVariable( name ); manager.declareBean( name, value, value.getClass() ); } engine.exec(fileName, lineNumber, columnNumber, text); } catch (BSFException e) { throw new JellyTagException("Error occurred with script: " + e, e); } } } // Properties //------------------------------------------------------------------------- /** * @return int */ public int getColumnNumber() { return columnNumber; } /** * @return String */ public String getElementName() { return elementName; } /** * @return BSFEngine */ public BSFEngine getEngine() { return engine; } /** * @return String */ public String getFileName() { return fileName; } /** * @return int */ public int getLineNumber() { return lineNumber; } /** * Sets the columnNumber. * @param columnNumber The columnNumber to set */ public void setColumnNumber(int columnNumber) { this.columnNumber = columnNumber; } /** * Sets the elementName. * @param elementName The elementName to set */ public void setElementName(String elementName) { this.elementName = elementName; } /** * Sets the engine. * @param engine The engine to set */ public void setEngine(BSFEngine engine) { this.engine = engine; } /** * Sets the fileName. * @param fileName The fileName to set */ public void setFileName(String fileName) { this.fileName = fileName; } /** * Sets the lineNumber. * @param lineNumber The lineNumber to set */ public void setLineNumber(int lineNumber) { this.lineNumber = lineNumber; } private JellyContextRegistry getRegistry() { return (JellyContextRegistry) this.manager.getObjectRegistry(); } } ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/bsf/src/java/org/apache/commons/jelly/tags/bsf/JythonTagLibrary.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/bsf/src/java/org/apache/commons/jelly/tags/bsf0000664000175000017500000000174711602216727031372 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.bsf; /** Describes the Taglib. This class could be generated by XDoclet * * @author James Strachan * @version $Revision: 155420 $ */ public class JythonTagLibrary extends BSFTagLibrary { public JythonTagLibrary() { setLanguage( "jython" ); } } ././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/bsf/src/java/org/apache/commons/jelly/tags/bsf/JPythonTagLibrary.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/bsf/src/java/org/apache/commons/jelly/tags/bsf0000664000175000017500000000175211602216727031366 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.bsf; /** Describes the Taglib. This class could be generated by XDoclet * * @author James Strachan * @version $Revision: 155420 $ */ public class JPythonTagLibrary extends BSFTagLibrary { public JPythonTagLibrary() { setLanguage( "jpython" ); } } jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/bsf/xdocs/0000775000175000017500000000000011602216727022534 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/bsf/xdocs/index.xml0000664000175000017500000000210411602216727024362 0ustar davedave BSF Tag Library dIon Gillard

A collection of tag libraries for working with BSF based scripting languages like JavaScript, Jython and PNuts. See the tags for more information.

jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/bsf/xdocs/changes.xml0000664000175000017500000000173311602216727024672 0ustar davedave Changes dIon Gillard Initial Release jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/bsf/xdocs/navigation.xml0000664000175000017500000000166511602216727025425 0ustar davedave BSF Tag Library jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/bsf/maven.xml0000664000175000017500000000124011602216727023241 0ustar davedave jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/0000775000175000017500000000000011602216727021433 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/project.properties0000664000175000017500000000144511602216727025223 0ustar davedave# # Copyright 2002,2004 The Apache Software Foundation. # # 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. # # ------------------------------------------------------------------- # P R O J E C T P R O P E R T I E S # ------------------------------------------------------------------- jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/project.xml0000664000175000017500000000405111602216727023623 0ustar davedave ${basedir}/../tag-project.xml commons-jelly-tags-jms commons-jelly-tags-jms 1.0.1-SNAPSHOT org.apache.commons.jelly.tags.jms This is a Jelly interface for the Java Message Service. Commons Jelly JMS Tag Library 1.0 1.0 COMMONS-JELLY-JMS-1_0 commons-messenger commons-messenger 1.0-dev-8 geronimo-spec geronimo-spec-jms geronimo-spec-jms 1.0-M1 jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/build.xml0000664000175000017500000002003411602216727023253 0ustar davedave jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/0000775000175000017500000000000011602216727022222 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/test/0000775000175000017500000000000011602216727023201 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/test/org/0000775000175000017500000000000011602216727023770 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/test/org/apache/0000775000175000017500000000000011602216727025211 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/test/org/apache/commons/0000775000175000017500000000000011602216727026664 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/test/org/apache/commons/jelly/0000775000175000017500000000000011602216727030003 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/test/org/apache/commons/jelly/tags/0000775000175000017500000000000011602216727030741 5ustar davedave././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/test/org/apache/commons/jelly/tags/jms/jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/test/org/apache/commons/jelly/tags/jms0000775000175000017500000000000011602216727031453 5ustar davedave././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/test/org/apache/commons/jelly/tags/jms/sendMap.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/test/org/apache/commons/jelly/tags/jms0000664000175000017500000000272311602216727031461 0ustar davedave About to send a JMS map message cheese Sending map message with map: ${m} ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/test/org/apache/commons/jelly/tags/jms/sendObject.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/test/org/apache/commons/jelly/tags/jms0000664000175000017500000000176211602216727031463 0ustar davedave About to send a JMS Object message Message sent! ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/test/org/apache/commons/jelly/tags/jms/sendText.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/test/org/apache/commons/jelly/tags/jms0000664000175000017500000000215411602216727031457 0ustar davedave About to send a JMS text message myQueue This is some text via the tag body Messages sent! ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/test/org/apache/commons/jelly/tags/jms/receiveMap.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/test/org/apache/commons/jelly/tags/jms0000664000175000017500000000205611602216727031460 0ustar davedave Waiting until I receive a JMS message Found message: ${message.JMSMessageID}. Map values are: ${key} = ${message.getObject(key)} ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/test/org/apache/commons/jelly/tags/jms/sendMessage.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/test/org/apache/commons/jelly/tags/jms0000664000175000017500000000213611602216727031457 0ustar davedave About to send a JMS message cheese x ${2+2} Message sent! ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/test/org/apache/commons/jelly/tags/jms/receiveObject.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/test/org/apache/commons/jelly/tags/jms0000664000175000017500000000172611602216727031463 0ustar davedave Waiting until I receive a JMS message Found message: ${message} The object body is: ${message.getObject()} ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/test/org/apache/commons/jelly/tags/jms/flushQueue.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/test/org/apache/commons/jelly/tags/jms0000664000175000017500000000202511602216727031454 0ustar davedave Flushing the input queue Found message: ${message}. ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/test/org/apache/commons/jelly/tags/jms/receive.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/test/org/apache/commons/jelly/tags/jms0000664000175000017500000000212211602216727031452 0ustar davedave Waiting until I receive a JMS message Found message: ${message} Properties are: ${key} = ${message.getObjectProperty(key)} The text body is: ${message.text} jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/java/0000775000175000017500000000000011602216727023143 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/java/org/0000775000175000017500000000000011602216727023732 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/java/org/apache/0000775000175000017500000000000011602216727025153 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/java/org/apache/commons/0000775000175000017500000000000011602216727026626 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/java/org/apache/commons/jelly/0000775000175000017500000000000011602216727027745 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/0000775000175000017500000000000011602216727030703 5ustar davedave././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms/jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms0000775000175000017500000000000011602216727031415 5ustar davedave././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms/ObjectMessageTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms0000664000175000017500000000362211602216727031422 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.jms; import java.io.Serializable; import javax.jms.JMSException; import javax.jms.Message; import org.apache.commons.jelly.JellyTagException; /** Creates a JMS ObjectMessage * * @author James Strachan * @version $Revision: 155420 $ */ public class ObjectMessageTag extends MessageTag { private Serializable object; public ObjectMessageTag() { } // Properties //------------------------------------------------------------------------- /** * Sets the body of the message, a serializable java object. * If this value is not set or the value is null then the content * of the tag will be used instead. */ public void setObject(Serializable object) { this.object = object; } // Implementation methods //------------------------------------------------------------------------- protected Message createMessage() throws JellyTagException { Serializable value = (object != null) ? object : getBodyText(); try { return getConnection().createObjectMessage(value); } catch (JMSException e) { throw new JellyTagException(e); } } } ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms/TextMessageTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms0000664000175000017500000000345111602216727031422 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.jms; import javax.jms.Message; import javax.jms.JMSException; import org.apache.commons.jelly.JellyTagException; /** Creates a JMS TextMessage * * @author James Strachan * @version $Revision: 155420 $ */ public class TextMessageTag extends MessageTag { private String text; public TextMessageTag() { } // Properties //------------------------------------------------------------------------- /** * Sets the body of the message, a String. If this value is not set or * the value is null then the content of the tag will be used instead. */ public void setText(String text) { this.text = text; } // Implementation methods //------------------------------------------------------------------------- protected Message createMessage() throws JellyTagException { String value = (text != null) ? text : getBodyText(); try { return getConnection().createTextMessage(value); } catch (JMSException e) { throw new JellyTagException(e); } } } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms/ConsumerTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms0000664000175000017500000000242611602216727031423 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.jms; import javax.jms.MessageListener; /** * Represents an interface for a Tag which consumes JMS messages. * By default this is the <subscribe> tag but other tags could * implement this interface to enabled things like Message pipelining, * transactional message consumer tags, stopwatch wrappers etc. * * @author James Strachan * @version $Revision: 155420 $ */ public interface ConsumerTag { /** * Sets the JMS messageListener used to consume JMS messages */ public void setMessageListener(MessageListener messageListener); } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms/PropertyTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms0000664000175000017500000000450611602216727031424 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.jms; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.MissingAttributeException; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.XMLOutput; /** Defines a property on an outer JMS Message tag * * @author James Strachan * @version $Revision: 155420 $ */ public class PropertyTag extends TagSupport { /** Stores the name of the property */ private String name; /** Stores the value of the property */ private Object value; // Tag interface //------------------------------------------------------------------------- public void doTag(XMLOutput output) throws MissingAttributeException, JellyTagException { if ( name == null ) { throw new MissingAttributeException("name"); } MessageTag tag = (MessageTag) findAncestorWithClass( MessageTag.class ); if ( tag == null ) { throw new JellyTagException(" tag must be within a tag"); } if ( value != null ) { tag.addProperty(name, value); } else { tag.addProperty(name, getBodyText()); } } // Properties //------------------------------------------------------------------------- /** Sets the name of the JMS property */ public void setName(String name) { this.name = name; } /** Sets the value of the JMS property. * If no value is set then the body of the tag is used */ public void setValue(Object value) { this.value = value; } } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms/SendTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms0000664000175000017500000000464311602216727031426 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.jms; import javax.jms.Destination; import javax.jms.JMSException; import javax.jms.Message; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.XMLOutput; /** Sends a JMS message to some destination. * * @author James Strachan * @version $Revision: 155420 $ */ public class SendTag extends MessageOperationTag { /** The JMS Message to be sent */ private Message message; public SendTag() { } // Tag interface //------------------------------------------------------------------------- public void doTag(XMLOutput output) throws JellyTagException { // evaluate body as it may contain a or message tag invokeBody(output); Message message = getMessage(); if ( message == null ) { throw new JellyTagException( "No message specified. Either specify a 'message' attribute or use a nested tag" ); } try { Destination destination = getDestination(); if ( destination == null ) { throw new JellyTagException( "No destination specified. Either specify a 'destination' attribute or use a nested tag" ); } getConnection().send( destination, message ); } catch (JMSException e) { throw new JellyTagException(e); } } // Properties //------------------------------------------------------------------------- public Message getMessage() { return message; } /** * Sets the JMS message to be sent */ public void setMessage(Message message) { this.message = message; } } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms/package.htmljenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms0000664000175000017500000000147511602216727031426 0ustar davedave

A tag library for working with JMS using the Messenger project

././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms/MapMessageTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms0000664000175000017500000000472211602216727031424 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.jms; import java.util.Iterator; import java.util.Map; import javax.jms.Message; import javax.jms.MapMessage; import javax.jms.JMSException; import org.apache.commons.jelly.JellyTagException; /** Creates a JMS MapMessage * * @author James Strachan * @version $Revision: 155420 $ */ public class MapMessageTag extends MessageTag { public MapMessageTag() { } public void addEntry(String name, Object value) throws JellyTagException { MapMessage message = (MapMessage) getMessage(); try { message.setObject(name, value); } catch (JMSException e) { throw new JellyTagException(e); } } // Properties //------------------------------------------------------------------------- /** * Sets the Map of entries to be used for this Map Message */ public void setMap(Map map) throws JellyTagException { MapMessage message = (MapMessage) getMessage(); for (Iterator iter = map.entrySet().iterator(); iter.hasNext(); ) { Map.Entry entry = (Map.Entry) iter.next(); String name = entry.getKey().toString(); Object value = entry.getValue(); try { message.setObject(name, value); } catch (JMSException e) { throw new JellyTagException(e); } } } // Implementation methods //------------------------------------------------------------------------- protected Message createMessage() throws JellyTagException { try { return getConnection().createMapMessage(); } catch (JMSException e) { throw new JellyTagException(e); } } } ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms/SubscribeTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms0000664000175000017500000001011311602216727031413 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.jms; import javax.jms.Destination; import javax.jms.JMSException; import javax.jms.MessageListener; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** * Performs a subscription to some JMS connection to a destination maybe with a selector. * A JMS MessageListener can be specified, or a special child tag can explicitly set it on * its parent (so a special tag could construct a MessageListener object and register it with this tag). * * @author James Strachan * @version $Revision: 155420 $ */ public class SubscribeTag extends MessageOperationTag implements ConsumerTag { /** The Log to which logging calls will be made. */ private static final Log log = LogFactory.getLog(SubscribeTag.class); /** the JMS Selector for the subscription */ private String selector; /** The JMS MessageListener used to create the subscription */ private MessageListener messageListener; public SubscribeTag() { } // Tag interface //------------------------------------------------------------------------- public void doTag(XMLOutput output) throws JellyTagException { // evaluate body as it may contain child tags to register a MessageListener invokeBody(output); MessageListener listener = getMessageListener(); if (listener == null) { throw new JellyTagException( "No messageListener attribute is specified so could not subscribe" ); } // clear the listener for the next tag invocation, if caching is employed setMessageListener(null); Destination destination = null; try { destination = getDestination(); } catch (JMSException e) { throw new JellyTagException(e); } if ( destination == null ) { throw new JellyTagException( "No destination specified. Either specify a 'destination' attribute or use a nested tag" ); } if ( log.isDebugEnabled() ) { log.debug( "About to consume to: " + destination + " with listener: " + listener ); } log.info( "About to consume to: " + destination + " with listener: " + listener ); try { if (selector == null ) { getConnection().addListener( destination, listener ); } else { getConnection().addListener( destination, selector, listener ); } } catch (JMSException e) { throw new JellyTagException(e); } } // Properties //------------------------------------------------------------------------- /** * Sets the optional JMS Message selector for the subscription */ public void setSelector(String selector) { this.selector = selector; } /** * Returns the messageListener. * @return MessageListener */ public MessageListener getMessageListener() { return messageListener; } /** * Sets the JMS messageListener used ot consume JMS messages on the given destination */ public void setMessageListener(MessageListener messageListener) { this.messageListener = messageListener; } } ././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms/MessageOperationTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms0000664000175000017500000000713011602216727031420 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.jms; import javax.jms.Destination; import javax.jms.JMSException; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.TagSupport; import org.apache.commons.messenger.Messenger; /** An abstract base class for JMS Message operation tags such as send, receive or call. * * @author James Strachan * @version $Revision: 155420 $ */ public abstract class MessageOperationTag extends TagSupport implements ConnectionContext { /** The Messenger used to access the JMS connection */ private Messenger connection; /** The Destination */ private Destination destination; /** The String subject used to find a destination */ private String subject; public MessageOperationTag() { } // Properties //------------------------------------------------------------------------- public Messenger getConnection() throws JellyTagException, JMSException { if ( connection == null ) { return findConnection(); } return connection; } /** * Sets the Messenger (the JMS connection pool) that will be used to send the message */ public void setConnection(Messenger connection) { this.connection = connection; } public Destination getDestination() throws JellyTagException, JMSException { if (destination == null) { // if we have a subject defined, lets use it to find the destination if (subject != null) { destination = findDestination(subject); } } return destination; } /** * Sets the JMS Destination to be used by this tag */ public void setDestination(Destination destination) { this.destination = destination; } /** * Sets the subject as a String which is used to create the * JMS Destination to be used by this tag */ public void setSubject(String subject) { this.subject = subject; } // Implementation methods //------------------------------------------------------------------------- /** * Strategy Method allowing derived classes to change this behaviour */ protected Messenger findConnection() throws JellyTagException, JMSException { ConnectionContext messengerTag = (ConnectionContext) findAncestorWithClass( ConnectionContext.class ); if ( messengerTag == null ) { throw new JellyTagException("This tag must be within a tag or the 'connection' attribute should be specified"); } return messengerTag.getConnection(); } /** * Strategy Method allowing derived classes to change this behaviour */ protected Destination findDestination(String subject) throws JellyTagException, JMSException { return getConnection().getDestination(subject); } } ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms/StopwatchTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms0000664000175000017500000000737611602216727031434 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.jms; import javax.jms.MessageListener; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.commons.messenger.tool.StopWatchMessageListener; /** * This tag can be used to measure the amount of time it takes to process JMS messages. * This tag can be wrapped around any custom JMS tag which consumes JMS messages. * * @author James Strachan * @version $Revision: 155420 $ */ public class StopwatchTag extends MessageOperationTag implements ConsumerTag { /** the underlying MessageListener */ private MessageListener messageListener; /** The Log to which logging calls will be made. */ private Log log = LogFactory.getLog( StopwatchTag.class ); /** the message group size */ private int groupSize = 1000; public StopwatchTag() { } // Tag interface //------------------------------------------------------------------------- public void doTag(XMLOutput output) throws JellyTagException { // evaluate body as it may contain child tags to register a MessageListener invokeBody(output); MessageListener listener = getMessageListener(); ConsumerTag tag = (ConsumerTag) findAncestorWithClass(ConsumerTag.class); if (tag == null) { throw new JellyTagException("This tag must be nested within a ConsumerTag like the subscribe tag"); } // clear the listener for the next tag invocation, if caching is employed setMessageListener(null); StopWatchMessageListener stopWatch = new StopWatchMessageListener(listener); stopWatch.setGroupSize(groupSize); stopWatch.setLog(log); // perform the consumption tag.setMessageListener(stopWatch); } // Properties //------------------------------------------------------------------------- /** * @return the number of messages in the group before the performance statistics are logged */ public int getGroupSize() { return groupSize; } /** * Sets the number of messages in the group before the performance statistics are logged */ public void setGroupSize(int groupSize) { this.groupSize = groupSize; } /** * @return the logger to which statistic messages will be sent */ public Log getLog() { return log; } /** * Sets the logger to which statistic messages will be sent */ public void setLog(Log log) { this.log = log; } /** * @return the MessageListener which this listener delegates to */ public MessageListener getMessageListener() { return messageListener; } /** * Sets the JMS messageListener used to consume JMS messages on the given destination */ public void setMessageListener(MessageListener messageListener) { this.messageListener = messageListener; } } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms/ConnectionTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms0000664000175000017500000000514711602216727031426 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.jms; import javax.jms.JMSException; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.messenger.Messenger; import org.apache.commons.messenger.MessengerManager; /** Defines a JMS connection for use by other JMS tags. * * @author James Strachan * @version $Revision: 155420 $ */ public class ConnectionTag extends TagSupport implements ConnectionContext { /** The variable name to create */ private String var; /** Stores the name of the map entry */ private String name; /** The Messenger */ private Messenger connection; // ConnectionContext interface //------------------------------------------------------------------------- public Messenger getConnection() { return connection; } // Tag interface //------------------------------------------------------------------------- public void doTag(XMLOutput output) throws JellyTagException { try { connection = MessengerManager.get( name ); } catch (JMSException e) { throw new JellyTagException(e); } if (connection == null) { throw new JellyTagException( "Could not find a JMS connection called: " + name ); } if ( var != null ) { context.setVariable( var, connection ); } invokeBody(output); } // Properties //------------------------------------------------------------------------- /** Sets the name of the Messenger (JMS connection pool) to use */ public void setName(String name) { this.name = name; } /** Sets the variable name to use for the exported Messenger (JMS connection pool) */ public void setVar(String var) { this.var = var; } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms/MessageTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms0000664000175000017500000001216211602216727031421 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.jms; import javax.jms.Destination; import javax.jms.Message; import javax.jms.JMSException; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.messenger.Messenger; /** A tag which creates a JMS message * * @author James Strachan * @version $Revision: 155420 $ */ public class MessageTag extends TagSupport { /** The name of the Message variable that is created */ private String var; /** The JMS Message created */ private Message message; /** The Messenger used to access the JMS connection */ private Messenger connection; public MessageTag() { } /** Adds a JMS property to the message */ public void addProperty(String name, Object value) throws JellyTagException { Message message = getMessage(); try { message.setObjectProperty(name, value); } catch (JMSException e) { throw new JellyTagException(e); } } // Tag interface //------------------------------------------------------------------------- public void doTag(XMLOutput output) throws JellyTagException { if ( var == null ) { // expose message to parent message consumer SendTag tag = (SendTag) findAncestorWithClass( SendTag.class ); if ( tag == null ) { throw new JellyTagException(" tags must either have the 'var' attribute specified or be used inside a tag"); } tag.setMessage( getMessage() ); } else { context.setVariable( var, getMessage() ); } } // Properties //------------------------------------------------------------------------- /** Sets the name of the variable that the message will be exported to */ public void setVar(String var) { this.var = var; } public Messenger getConnection() throws JellyTagException { if ( connection == null ) { return findConnection(); } return connection; } /** * Sets the Messenger (the JMS connection pool) that will be used to send the message */ public void setConnection(Messenger connection) { this.connection = connection; } public Message getMessage() throws JellyTagException { if ( message == null ) { message = createMessage(); } return message; } // JMS related properties /** * Sets the JMS Correlation ID to be used on the message */ public void setCorrelationID(String correlationID) throws JellyTagException { try { getMessage().setJMSCorrelationID(correlationID); } catch (JMSException e) { throw new JellyTagException(e); } } /** * Sets the reply-to destination to add to the message */ public void setReplyTo(Destination destination) throws JellyTagException { try { getMessage().setJMSReplyTo(destination); } catch (JMSException e) { throw new JellyTagException(e); } } /** * Sets the type name of the message */ public void setType(String type) throws JellyTagException { try { getMessage().setJMSType(type); } catch (JMSException e) { throw new JellyTagException(e); } } // Implementation methods //------------------------------------------------------------------------- protected Messenger findConnection() throws JellyTagException { ConnectionContext messengerTag = (ConnectionContext) findAncestorWithClass( ConnectionContext.class ); if ( messengerTag == null ) { throw new JellyTagException("This tag must be within a tag or the 'connection' attribute should be specified"); } try { return messengerTag.getConnection(); } catch (JMSException e) { throw new JellyTagException(e); } } protected Message createMessage() throws JellyTagException { try { return getConnection().createMessage(); } catch (JMSException e) { throw new JellyTagException(e); } } } ././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms/ConnectionContext.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms0000664000175000017500000000215511602216727031422 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.jms; import javax.jms.JMSException; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.messenger.Messenger; /** Represents a context capable of providing a Messenger connection to use * * @author James Strachan * @version $Revision: 155420 $ */ public interface ConnectionContext { public Messenger getConnection() throws JellyTagException, JMSException; } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms/JMSTagLibrary.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms0000664000175000017500000000326411602216727031424 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.jms; import org.apache.commons.jelly.TagLibrary; /** Describes the Taglib. This class could be generated by XDoclet * * @author James Strachan * @version $Revision: 155420 $ */ public class JMSTagLibrary extends TagLibrary { public JMSTagLibrary() { registerTag("connection", ConnectionTag.class); registerTag("destination", DestinationTag.class); registerTag("mapEntry", MapEntryTag.class); registerTag("mapMessage", MapMessageTag.class); registerTag("message", MessageTag.class); registerTag("onMessage", OnMessageTag.class); registerTag("objectMessage", ObjectMessageTag.class); registerTag("property", PropertyTag.class); registerTag("receive", ReceiveTag.class); registerTag("send", SendTag.class); registerTag("stopwatch", StopwatchTag.class); registerTag("subscribe", SubscribeTag.class); registerTag("textMessage", TextMessageTag.class); } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms/ReceiveTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms0000664000175000017500000001012011602216727031411 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.jms; import javax.jms.Destination; import javax.jms.Message; import javax.jms.JMSException; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** Receives a JMS message. * * @author James Strachan * @version $Revision: 155420 $ */ public class ReceiveTag extends MessageOperationTag { /** The Log to which logging calls will be made. */ private static final Log log = LogFactory.getLog(ReceiveTag.class); private String var; private long timeout = -1L; public ReceiveTag() { } // Tag interface //------------------------------------------------------------------------- public void doTag(XMLOutput output) throws JellyTagException { // evaluate body as it may contain a tag invokeBody(output); Message message = null; try { Destination destination = getDestination(); if ( destination == null ) { throw new JellyTagException( "No destination specified. Either specify a 'destination' attribute or use a nested tag" ); } if ( timeout > 0 ) { if ( log.isDebugEnabled() ) { log.debug( "Receiving message on destination: " + destination + " with timeout: " + timeout ); } message = getConnection().receive( destination, timeout ); } else if ( timeout == 0 ) { if ( log.isDebugEnabled() ) { log.debug( "Receiving message on destination: " + destination + " with No Wait" ); } message = getConnection().receiveNoWait( destination ); } else { if ( log.isDebugEnabled() ) { log.debug( "Receiving message on destination: " + destination ); } message = getConnection().receive( destination ); } } catch (JMSException e) { throw new JellyTagException(e); } onMessage( message ); } // Properties //------------------------------------------------------------------------- public String getVar() { return var; } /** * Sets the variable name to create for the received message, which will be null if no * message could be returned in the given time period. */ public void setVar(String var) { this.var = var; } public long getTimeout() { return timeout; } /** * Sets the timeout period in milliseconds to wait for a message. A value * of -1 will wait forever for a message. */ public void setTimeout(long timeout) { this.timeout = timeout; } // Implementation methods //------------------------------------------------------------------------- /** * A strategy method which processes the incoming message, allowing derived classes * to implement different processing methods */ protected void onMessage( Message message ) { if ( message != null ) { context.setVariable( var, message ); } else { context.removeVariable( var ); } } } ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms/DestinationTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms0000664000175000017500000000610611602216727031422 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.jms; import javax.jms.Destination; import javax.jms.JMSException; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.messenger.Messenger; /** Creates a Destination object from a String name. * * @author James Strachan * @version $Revision: 155420 $ */ public class DestinationTag extends TagSupport { /** The variable name to create */ private String var; /** Stores the name of the map entry */ private String name; // Tag interface //------------------------------------------------------------------------- public void doTag(XMLOutput output) throws JellyTagException { ConnectionContext messengerTag = (ConnectionContext) findAncestorWithClass( ConnectionContext.class ); if ( messengerTag == null ) { throw new JellyTagException(" tag must be within a or or tag"); } Destination destination = null; try { Messenger messenger = messengerTag.getConnection(); if (messenger == null) { throw new JellyTagException("No JMS Connection could be found!" ); } String subject = (name != null) ? name : getBodyText(); destination = messenger.getDestination( subject ); } catch (JMSException e) { throw new JellyTagException(e); } if ( var != null ) { context.setVariable( var, destination ); } else { MessageOperationTag tag = (MessageOperationTag) findAncestorWithClass( MessageOperationTag.class ); if ( tag == null ) { throw new JellyTagException(" tag must be within a or tag or the 'var' attribute should be specified"); } tag.setDestination( destination ); } } // Properties //------------------------------------------------------------------------- /** Sets the name of the Destination */ public void setName(String name) { this.name = name; } /** Sets the variable name to use for the Destination */ public void setVar(String var) { this.var = var; } } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms/MapEntryTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms0000664000175000017500000000454311602216727031425 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.jms; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.MissingAttributeException; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.XMLOutput; /** Adds a map entry to the outer Map Message tag * * @author James Strachan * @version $Revision: 155420 $ */ public class MapEntryTag extends TagSupport { /** Stores the name of the map entry */ private String name; /** Stores the value of the map entry */ private Object value; // Tag interface //------------------------------------------------------------------------- public void doTag(XMLOutput output) throws MissingAttributeException, JellyTagException { if ( name == null ) { throw new MissingAttributeException("name"); } MapMessageTag tag = (MapMessageTag) findAncestorWithClass( MapMessageTag.class ); if ( tag == null ) { throw new JellyTagException(" tag must be within a tag"); } if (value != null) { tag.addEntry( name, value ); } else { tag.addEntry( name, getBodyText() ); } } // Properties //------------------------------------------------------------------------- /** Sets the name of the entry in the map message */ public void setName(String name) { this.name = name; } /** Sets the value of the entry in the map message. * If no value is set then the body of the tag is used */ public void setValue(Object value) { this.value = value; } } ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms/OnMessageTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/src/java/org/apache/commons/jelly/tags/jms0000664000175000017500000000613011602216727031417 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.jms; import javax.jms.Message; import javax.jms.MessageListener; import org.apache.commons.jelly.JellyContext; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.Script; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** * This tag creates a JMS MessageListener which will invoke this * tag's body whenever a JMS Message is received. The JMS Message * will be available via a variable, which defaults to the 'message' * variable name, but can be overloaded by the var attribute. * * @author James Strachan * @version $Revision: 155420 $ */ public class OnMessageTag extends TagSupport { /** The Log to which logging calls will be made. */ private static final Log log = LogFactory.getLog(OnMessageTag.class); private String var = "message"; public OnMessageTag() { } // Tag interface //------------------------------------------------------------------------- public void doTag(XMLOutput output) throws JellyTagException { ConsumerTag tag = (ConsumerTag) findAncestorWithClass(ConsumerTag.class); if (tag == null) { throw new JellyTagException("This tag must be nested within a ConsumerTag like the subscribe tag"); } final JellyContext childContext = context.newJellyContext(); final Script script = getBody(); final XMLOutput childOutput = output; MessageListener listener = new MessageListener() { public void onMessage(Message message) { childContext.setVariable(var, message); try { script.run(childContext, childOutput); } catch (Exception e) { log.error("Caught exception processing message: " + message + ". Exception: " + e, e); } } }; // perform the consumption tag.setMessageListener(listener); } // Properties //------------------------------------------------------------------------- /** * Sets the name of the variable used to make the JMS message available to this tags * body when a message is received. */ public void setVar(String var) { this.var = var; } } jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/xdocs/0000775000175000017500000000000011602216727022553 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/xdocs/index.xml0000664000175000017500000000213111602216727024401 0ustar davedave JMS Tag Library dIon Gillard

A tag library for working with JMS using the Messenger project. See the tags for more information.

jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/xdocs/changes.xml0000664000175000017500000000210211602216727024700 0ustar davedave Changes dIon Gillard Replaced a Sun (jms) for Geronimo's equivalent. jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/xdocs/navigation.xml0000664000175000017500000000166511602216727025444 0ustar davedave JMS Tag Library jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jms/maven.xml0000664000175000017500000000124011602216727023260 0ustar davedave jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/memory/0000775000175000017500000000000011602216727022152 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/memory/project.xml0000664000175000017500000000240611602216727024344 0ustar davedave ${basedir}/../tag-project.xml commons-jelly-tags-memory commons-jelly-tags-memory 1.0-SNAPSHOT org.apache.commons.jelly.tags.memory This is a Jelly interface for Runtime's memory functions. Commons Jelly Memory Tag Library jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/memory/src/0000775000175000017500000000000011602216727022741 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/memory/src/java/0000775000175000017500000000000011602216727023662 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/memory/src/java/org/0000775000175000017500000000000011602216727024451 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/memory/src/java/org/apache/0000775000175000017500000000000011602216727025672 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/memory/src/java/org/apache/commons/0000775000175000017500000000000011602216727027345 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/memory/src/java/org/apache/commons/jelly/0000775000175000017500000000000011602216727030464 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/memory/src/java/org/apache/commons/jelly/tags/0000775000175000017500000000000011602216727031422 5ustar davedave././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/memory/src/java/org/apache/commons/jelly/tags/memory/jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/memory/src/java/org/apache/commons/jelly/tags/0000775000175000017500000000000011602216727031422 5ustar davedave././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/memory/src/java/org/apache/commons/jelly/tags/memory/MemoryTagLibrary.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/memory/src/java/org/apache/commons/jelly/tags/0000664000175000017500000000211411602216727031422 0ustar davedave/* * Copyright 2002,2005 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.memory; import org.apache.commons.jelly.TagLibrary; /** * A Jelly custom tag library that performs memory related tasks. * * @author Brett Porter * @version $Revision: 155420 $ */ public class MemoryTagLibrary extends TagLibrary { public MemoryTagLibrary() { registerTag("gc", GcTag.class); registerTag("showFree", FreeMemoryTag.class); } } ././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/memory/src/java/org/apache/commons/jelly/tags/memory/FreeMemoryTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/memory/src/java/org/apache/commons/jelly/tags/0000664000175000017500000000413211602216727031424 0ustar davedave/* * Copyright 2002,2005 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.memory; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.XMLOutput; /** * Tag supporting displaying free memory. * * @author Brett Porter */ public class FreeMemoryTag extends TagSupport { private static final int MB = 1024 * 1024; private static final int KB = 1024; private String style = "mb"; public void setStyle(String style) { if (style == null) { style = "mb"; } this.style = style.toLowerCase(); } public String getStyle() { return this.style; } // Tag interface //------------------------------------------------------------------------- public void doTag(XMLOutput output) throws JellyTagException { Runtime r = Runtime.getRuntime(); try { long total = r.totalMemory(); long free = total - r.freeMemory(); if (style.equals("kb")) { free /= KB; total /= KB; } else if (style.equals("mb")) { free /= MB; total /= MB; } output.write( free + style + "/" + total + style ); } catch ( Exception e ) { throw new JellyTagException( "Error writing to output", e ); } } } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/memory/src/java/org/apache/commons/jelly/tags/memory/GcTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/memory/src/java/org/apache/commons/jelly/tags/0000664000175000017500000000232111602216727031422 0ustar davedave/* * Copyright 2002,2005 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.memory; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.XMLOutput; /** * Tag to invoke garbage collection. * * @author Brett Porter */ public class GcTag extends TagSupport { // Tag interface //------------------------------------------------------------------------- public void doTag(XMLOutput output) throws JellyTagException { Runtime r = Runtime.getRuntime(); r.gc(); } } jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/memory/xdocs/0000775000175000017500000000000011602216727023272 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/memory/xdocs/index.xml0000664000175000017500000000170611602216727025127 0ustar davedave Memory Tag Library Brett Porter

This is a Jelly interface for the Runtime memory functions.

jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/memory/xdocs/changes.xml0000664000175000017500000000174211602216727025430 0ustar davedave Changes Brett Porter Initial release jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/memory/xdocs/navigation.xml0000664000175000017500000000167611602216727026165 0ustar davedave Memory Tag Library jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/project.properties0000664000175000017500000000470211602216727024431 0ustar davedave# # Copyright 2002-2004 The Apache Software Foundation # # 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. # ------------------------------------------------------------------- # P R O J E C T P R O P E R T I E S # ------------------------------------------------------------------- maven.junit.fork=true maven.compile.deprecation = on maven.checkstyle.properties=${basedir}/../tag-checkstyle.xml maven.checkstyle.header.file=${basedir}/../../short-license.txt maven.changes.issue.template=http://issues.apache.org/jira/browse/%ISSUE% maven.license.licenseFile=${basedir}/../../LICENSE.txt maven.xdoc.date=left maven.xdoc.developmentProcessUrl=http://jakarta.apache.org/commons/charter.html maven.xdoc.poweredby.image=maven-feather.png maven.xdoc.jsl=file:${basedir}/../../../commons-build/commons-site.jsl maven.xdoc.distributionUrl=http://www.apache.org/dist/java-repository/commons-jelly/jars maven.linkcheck.enable=false maven.pmd.rulesetfiles=\ rulesets/basic.xml,\ rulesets/unusedcode.xml,\ rulesets/imports.xml,\ rulesets/codesize.xml,\ rulesets/coupling.xml,\ rulesets/design.xml,\ rulesets/strings.xml maven.changelog.factory=org.apache.maven.svnlib.SvnChangeLogFactory # Repositories to upload by default... snapshots maven.repo.list=apache.snapshots # Repository to deploy snapshots maven.repo.apache.snapshots=scp://people.apache.org maven.repo.apache.snapshots.directory=/www/people.apache.org/repository ## supposing these variables (*.releases.* are defined at the user-level) maven.repo.apache.snapshots.username=${maven.repo.apache.releases.username} maven.repo.apache.snapshots.privatekey=${maven.repo.apache.releases.privatekey} maven.repo.apache.snapshots.passphrase=${maven.repo.apache.releases.passphrase} # Repository to deploy releases, need manual addressing maven.repo.apache.releases=scp://people.apache.org maven.repo.apache.releases.directory=/www/www.apache.org/dist/java-repository jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/dynabean/0000775000175000017500000000000011602216727022423 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/dynabean/project.properties0000664000175000017500000000144511602216727026213 0ustar davedave# # Copyright 2002,2004 The Apache Software Foundation. # # 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. # # ------------------------------------------------------------------- # P R O J E C T P R O P E R T I E S # ------------------------------------------------------------------- jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/dynabean/project.xml0000664000175000017500000000320711602216727024615 0ustar davedave ${basedir}/../tag-project.xml commons-jelly-tags-dynabean commons-jelly-tags-dynabean 1.0.1-SNAPSHOT org.apache.commons.jelly.tags.dynabean The Jelly DynaBean Tag Library Commons Jelly Dyna Bean Tag Library 1.0 1.0 COMMONS_JELLY_DYNABEAN-1_0 commons-jelly commons-jelly-tags-junit 1.0 http://jakarta.apache.org/commons/jelly/tags/junit/ test jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/dynabean/build.xml0000664000175000017500000001763611602216727024261 0ustar davedave jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/dynabean/src/0000775000175000017500000000000011602216727023212 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/dynabean/src/test/0000775000175000017500000000000011602216727024171 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/dynabean/src/test/org/0000775000175000017500000000000011602216727024760 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/dynabean/src/test/org/apache/0000775000175000017500000000000011602216727026201 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/dynabean/src/test/org/apache/commons/0000775000175000017500000000000011602216727027654 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/dynabean/src/test/org/apache/commons/jelly/0000775000175000017500000000000011602216727030773 5ustar davedave././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/dynabean/src/test/org/apache/commons/jelly/tags/jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/dynabean/src/test/org/apache/commons/jelly/tag0000775000175000017500000000000011602216727031467 5ustar davedave././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/dynabean/src/test/org/apache/commons/jelly/tags/dynabean/jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/dynabean/src/test/org/apache/commons/jelly/tag0000775000175000017500000000000011602216727031467 5ustar davedave././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/dynabean/src/test/org/apache/commons/jelly/tags/dynabean/TestJelly.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/dynabean/src/test/org/apache/commons/jelly/tag0000664000175000017500000000242311602216727031472 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.dynabean; import junit.framework.TestSuite; import junit.textui.TestRunner; import org.apache.commons.jelly.tags.junit.JellyTestSuite; /** * A helper class to run jelly test cases as part of Ant's JUnit tests * * @author James Strachan * @version $Revision: 155420 $ */ public class TestJelly extends JellyTestSuite { public static void main( String[] args ) throws Exception { TestRunner.run( suite() ); } public static TestSuite suite() throws Exception { return createTestSuite(TestJelly.class, "suite.jelly"); } } ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/dynabean/src/test/org/apache/commons/jelly/tags/dynabean/suite.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/dynabean/src/test/org/apache/commons/jelly/tag0000664000175000017500000000576711602216727031510 0ustar davedave jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/dynabean/src/java/0000775000175000017500000000000011602216727024133 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/dynabean/src/java/org/0000775000175000017500000000000011602216727024722 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/dynabean/src/java/org/apache/0000775000175000017500000000000011602216727026143 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/dynabean/src/java/org/apache/commons/0000775000175000017500000000000011602216727027616 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/dynabean/src/java/org/apache/commons/jelly/0000775000175000017500000000000011602216727030735 5ustar davedave././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/dynabean/src/java/org/apache/commons/jelly/tags/jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/dynabean/src/java/org/apache/commons/jelly/tag0000775000175000017500000000000011602216727031431 5ustar davedave././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/dynabean/src/java/org/apache/commons/jelly/tags/dynabean/jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/dynabean/src/java/org/apache/commons/jelly/tag0000775000175000017500000000000011602216727031431 5ustar davedave././@LongLink0000000000000000000000000000020700000000000011564 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/dynabean/src/java/org/apache/commons/jelly/tags/dynabean/DynabeanTagLibrary.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/dynabean/src/java/org/apache/commons/jelly/tag0000664000175000017500000000223611602216727031436 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.dynabean; import org.apache.commons.jelly.TagLibrary; /** Describes the Taglib. This class could be generated by XDoclet * * @author Theo Niemeijer * @version $Revision: 155420 $ */ public class DynabeanTagLibrary extends TagLibrary { public DynabeanTagLibrary() { registerTag("dynaclass", DynaclassTag.class); registerTag("property", PropertyTag.class); registerTag("dynabean", DynabeanTag.class); registerTag("set", SetTag.class); } } ././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/dynabean/src/java/org/apache/commons/jelly/tags/dynabean/PropertyTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/dynabean/src/java/org/apache/commons/jelly/tag0000664000175000017500000001054511602216727031440 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.dynabean; import org.apache.commons.beanutils.DynaProperty; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.MissingAttributeException; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.XMLOutput; /** * DynaProperty tag defines a property of a DynaClass * It can only exist inside a DynaClass parent context * The properties are added to the properties array * of the parent context, and will be used to * create the DynaClass object * * @author Theo Niemeijer * @version 1.0 */ public class PropertyTag extends TagSupport { private String name; private String type; private Class propertyClass; private DynaProperty prop; public PropertyTag() { } // Tag interface //------------------------------------------------------------------------- public void doTag (XMLOutput output) throws MissingAttributeException, JellyTagException { // Check that this tag is used inside the body of // a DynaClass tag, so that it can access the // context of that tag DynaclassTag parentTag = (DynaclassTag) findAncestorWithClass( DynaclassTag.class ); if ( parentTag == null ) { throw new JellyTagException( "This tag must be enclosed inside a tag" ); } // Check property name if (name == null) { throw new MissingAttributeException( "name" ); } // Lookup appropriate property class Class propClass = propertyClass; if (propClass == null) { // Check property type if (type == null) { throw new MissingAttributeException( "type" ); } if (type.equals("String")) { propClass = String.class; } else if (type.equals("Integer")) { propClass = Integer.TYPE; } else if (type.equals("Short")) { propClass = Short.TYPE; } else if (type.equals("Long")) { propClass = Long.TYPE; } else if (type.equals("Float")) { propClass = Float.TYPE; } else if (type.equals("Double")) { propClass = Double.TYPE; } else if (type.equals("Long")) { propClass = Long.TYPE; } if (propClass == null) { try { propClass = Class.forName(type); } catch (Exception e) { throw new JellyTagException ("Class " + type + " not found by Class.forName"); } } } // Create dynaproperty object with given name and type prop = new DynaProperty (name, propClass); // Add new property to dynaclass context parentTag.addDynaProperty(prop); } // Properties //------------------------------------------------------------------------- /** * Sets the name of this property */ public void setName(String name) { this.name = name; } /** * Sets the type name of this property */ public void setType(String type) { this.type = type; } /** * Returns the Class for this property */ public Class getPropertyClass() { return propertyClass; } /** * Sets the Class instance for this property */ public void setPropertyClass(Class propertyClass) { this.propertyClass = propertyClass; } } ././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/dynabean/src/java/org/apache/commons/jelly/tags/dynabean/package.htmljenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/dynabean/src/java/org/apache/commons/jelly/tag0000664000175000017500000000152711602216727031440 0ustar davedave

A tag library for creating new DynaClass and DynaBean objects from the beanutils library

././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/dynabean/src/java/org/apache/commons/jelly/tags/dynabean/SetTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/dynabean/src/java/org/apache/commons/jelly/tag0000664000175000017500000001206511602216727031437 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.dynabean; import java.util.Map; import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.jelly.expression.Expression; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** A tag which sets a variable from the result of an expression * * @author Theo Niemeijer * @version 1.0 */ public class SetTag extends TagSupport { /** The Log to which logging calls will be made. */ private static final Log log = LogFactory.getLog(SetTag.class); /** The variable name to export. */ private String var; /** The variable scope to export */ private String scope; /** The expression to evaluate. */ private Expression value; /** The target object on which to set a property. */ private Object target; /** The name of the property to set on the target object. */ private String property; public SetTag() { } // Tag interface //------------------------------------------------------------------------- public void doTag(XMLOutput output) throws JellyTagException { Object answer = null; if ( value != null ) { answer = value.evaluate(context); } else { answer = getBodyText(); } // Assume that if a var name and a property is given then // var is the name of an object in the context if (( var != null ) && ( property != null) && ( target == null )) { // Get object from context if ( scope != null ) { target = context.getVariable(var, scope); } else { target = context.getVariable(var); } if (target != null) { var = null; } } if ( var != null ) { if ( scope != null ) { context.setVariable(var, scope, answer); } else { context.setVariable(var, answer); } } else { if ( target == null ) { throw new JellyTagException( "Either a 'var' or a 'target' attribute must be defined for this tag" ); } if ( property == null ) { throw new JellyTagException( "You must define a 'property' attribute if you specify a 'target'" ); } setPropertyValue( target, property, answer ); } } // Properties //------------------------------------------------------------------------- /** Sets the variable name to define for this expression */ public void setVar(String var) { this.var = var; } /** * Sets the variable scope for this variable. For example setting this value to 'parent' will * set this value in the parent scope. When Jelly is run from inside a Servlet environment * then other scopes will be available such as 'request', 'session' or 'application'. * * Other applications may implement their own custom scopes. */ public void setScope(String scope) { this.scope = scope; } /** Sets the expression to evaluate. */ public void setValue(Expression value) { this.value = value; } /** Sets the target object on which to set a property. */ public void setTarget(Object target) { this.target = target; } /** Sets the name of the property to set on the target object. */ public void setProperty(String property) { this.property = property; } // Implementation methods //------------------------------------------------------------------------- protected void setPropertyValue( Object target, String property, Object value ) { try { if ( target instanceof Map ) { Map map = (Map) target; map.put( property, value ); } else { BeanUtils.setProperty( target, property, value ); } } catch (Exception e) { log.error( "Failed to set the property: " + property + " on bean: " + target + " to value: " + value + " due to exception: " + e, e ); } } } ././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/dynabean/src/java/org/apache/commons/jelly/tags/dynabean/DynabeanTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/dynabean/src/java/org/apache/commons/jelly/tag0000664000175000017500000000513411602216727031436 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.dynabean; import org.apache.commons.beanutils.DynaBean; import org.apache.commons.beanutils.DynaClass; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.MissingAttributeException; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.XMLOutput; /** A tag which conditionally evaluates its body based on some condition * * @author Theo Niemeijer * @version $Revision: 155420 $ */ public class DynabeanTag extends TagSupport { private DynaClass dynaClass; private String var; public DynabeanTag() { } // Tag interface //------------------------------------------------------------------------- public void doTag(XMLOutput output) throws MissingAttributeException, JellyTagException { if (dynaClass == null) { throw new MissingAttributeException( "dynaclass" ); } if (var == null) { throw new MissingAttributeException( "var" ); } try { // Create dynabean instance for this dynaclass DynaBean dynaBean = dynaClass.newInstance(); // Place new dynabean in context as a variable context.setVariable(getVar(), dynaBean); } catch (IllegalAccessException e) { throw new JellyTagException(e); } catch (InstantiationException e) { throw new JellyTagException(e); } } // Properties //------------------------------------------------------------------------- /** * Sets the DynaClass of the new instance to create */ public void setDynaclass(DynaClass dynaClass) { this.dynaClass = dynaClass; } public String getVar() { return var; } /** * Sets the name of the variable to export the new DynaBean instance to */ public void setVar(String var) { this.var = var; } } ././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/dynabean/src/java/org/apache/commons/jelly/tags/dynabean/DynaclassTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/dynabean/src/java/org/apache/commons/jelly/tag0000664000175000017500000000625311602216727031441 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.dynabean; import java.util.ArrayList; import org.apache.commons.beanutils.BasicDynaClass; import org.apache.commons.beanutils.DynaClass; import org.apache.commons.beanutils.DynaProperty; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.MissingAttributeException; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.XMLOutput; /** * A tag which creates and defines and creates a DynaClass * The DynaClass object is placed by name in the context, * so that a DynaBean tag can use it by name to instantiate * a DynaBean object * * @author Theo Niemeijer * @version 1.0 */ public class DynaclassTag extends TagSupport { private ArrayList propList = new ArrayList(); private DynaProperty[] props = null; private DynaClass dynaClass = null; private String name; private String var; public DynaclassTag() { } // Tag interface //------------------------------------------------------------------------- public void doTag(XMLOutput output) throws MissingAttributeException, JellyTagException { if (name == null) { throw new MissingAttributeException("name"); } if (var == null) { var = name; } // Evaluate the body of the dynaclass definition invokeBody(output); // Convert the list of properties into array props = (DynaProperty[]) propList.toArray( new DynaProperty[propList.size()]); if (props == null) { throw new JellyTagException("No properties list"); } if (props.length == 0) { throw new JellyTagException("No properties"); } // Create the dynaclass with name and properties dynaClass = (DynaClass) new BasicDynaClass(name, null, props); // Place new dynaclass in context context.setVariable(getVar(), dynaClass); } // Properties //------------------------------------------------------------------------- /** * Sets the name of the new DynaClass */ public void setName(String name) { this.name = name; } public String getVar() { return var; } /** * Sets the name of the variable to export the DynaClass instance */ public void setVar(String var) { this.var = var; } protected void addDynaProperty(DynaProperty prop) { propList.add(prop); } } jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/dynabean/xdocs/0000775000175000017500000000000011602216727023543 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/dynabean/xdocs/index.xml0000664000175000017500000000217011602216727025374 0ustar davedave DynaBean Tag Library dIon Gillard

A tag library for creating new DynaClass and DynaBean objects from the beanutils library. See the tags for more information.

jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/dynabean/xdocs/changes.xml0000664000175000017500000000173311602216727025701 0ustar davedave Changes dIon Gillard Initial Release jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/dynabean/xdocs/navigation.xml0000664000175000017500000000170411602216727026426 0ustar davedave DynaBean Tag Library jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/dynabean/maven.xml0000664000175000017500000000124011602216727024250 0ustar davedave jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/0000775000175000017500000000000011602216727021424 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/project.properties0000664000175000017500000000144511602216727025214 0ustar davedave# # Copyright 2002,2004 The Apache Software Foundation. # # 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. # # ------------------------------------------------------------------- # P R O J E C T P R O P E R T I E S # ------------------------------------------------------------------- jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/project.xml0000664000175000017500000000542111602216727023616 0ustar davedave ${basedir}/../tag-project.xml commons-jelly-tags-ant commons-jelly-tags-ant 1.1.1-SNAPSHOT org.apache.commons.jelly.tags.ant This is a Jelly interface for Ant. Commons Jelly Ant Tag Library 1.0 1.0 COMMONS_JELLY_ANT-1_0 1.1 1.1 commons-jelly-tags-ant-1.1 ant ant 1.6.5 ant ant-launcher 1.6.5 ant ant-junit 1.6.5 commons-jelly commons-jelly-tags-junit 1.0 http://jakarta.apache.org/commons/jelly/libs/junit/ test commons-jelly commons-jelly-tags-util 1.1.1 test commons-cli commons-cli 1.0 jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/build.xml0000664000175000017500000005132211602216727023250 0ustar davedave ================================= WARNING ================================ Junit isn't present in your ${ANT_HOME}/lib directory. Tests not executed. ========================================================================== Proxy used : Proxy host [${proxy.host}] Proxy port [${proxy.port}] Proxy user [${proxy.username}] Proxy not used. jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/0000775000175000017500000000000011602216727022213 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/test/0000775000175000017500000000000011602216727023172 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/test/org/0000775000175000017500000000000011602216727023761 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/test/org/apache/0000775000175000017500000000000011602216727025202 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/test/org/apache/commons/0000775000175000017500000000000011602216727026655 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/test/org/apache/commons/jelly/0000775000175000017500000000000011602216727027774 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/test/org/apache/commons/jelly/ant/0000775000175000017500000000000011602216727030556 5ustar davedave././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/test/org/apache/commons/jelly/ant/example_jar.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/test/org/apache/commons/jelly/ant/exam0000664000175000017500000000325011602216727031433 0ustar davedave About to create jar: ${jarname}
././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/test/org/apache/commons/jelly/ant/typoTest.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/test/org/apache/commons/jelly/ant/typo0000664000175000017500000000254611602216727031503 0ustar davedave Lets start by calling the echo task Maven home is ${maven.home} We should be back to the Jelly script again now... ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/test/org/apache/commons/jelly/ant/build.xmljenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/test/org/apache/commons/jelly/ant/buil0000664000175000017500000000221511602216727031434 0ustar davedave ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/test/org/apache/commons/jelly/ant/TestJelly.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/test/org/apache/commons/jelly/ant/Test0000664000175000017500000000241111602216727031416 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.ant; import junit.framework.TestSuite; import junit.textui.TestRunner; import org.apache.commons.jelly.tags.junit.JellyTestSuite; /** * A helper class to run jelly test cases as part of Ant's JUnit tests * * @author James Strachan * @version $Revision: 155420 $ */ public class TestJelly extends JellyTestSuite { public static void main( String[] args ) throws Exception { TestRunner.run( suite() ); } public static TestSuite suite() throws Exception { return createTestSuite(TestJelly.class, "suite.jelly"); } } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/test/org/apache/commons/jelly/ant/suite.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/test/org/apache/commons/jelly/ant/suit0000664000175000017500000001322011602216727031463 0ustar davedave Performing copy in parallel Performing copy in parallel We should have created an exception ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/test/org/apache/commons/jelly/ant/show_properties.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/test/org/apache/commons/jelly/ant/show0000664000175000017500000000262411602216727031465 0ustar davedave

Ant properties

The project name is

Targets
Property Name Property Value
././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/test/org/apache/commons/jelly/ant/jellyunit.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/test/org/apache/commons/jelly/ant/jell0000664000175000017500000000276611602216727031442 0ustar davedave Running all JellyUnit tests and generating file ${outputfile} jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/test/org/apache/commons/jelly/ant/tag/0000775000175000017500000000000011602216727031331 5ustar davedave././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/test/org/apache/commons/jelly/ant/tag/TestJelly.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/test/org/apache/commons/jelly/ant/tag/0000664000175000017500000000241511602216727031335 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.ant.tag; import junit.framework.TestSuite; import junit.textui.TestRunner; import org.apache.commons.jelly.tags.junit.JellyTestSuite; /** * A helper class to run jelly test cases as part of Ant's JUnit tests * * @author James Strachan * @version $Revision: 155420 $ */ public class TestJelly extends JellyTestSuite { public static void main( String[] args ) throws Exception { TestRunner.run( suite() ); } public static TestSuite suite() throws Exception { return createTestSuite(TestJelly.class, "suite.jelly"); } } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/test/org/apache/commons/jelly/ant/tag/suite.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/test/org/apache/commons/jelly/ant/tag/0000664000175000017500000000230511602216727031333 0ustar davedave ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/test/org/apache/commons/jelly/ant/tag/DummyTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/test/org/apache/commons/jelly/ant/tag/0000664000175000017500000000674211602216727031344 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.ant.tag; import junit.framework.AssertionFailedError; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.jelly.impl.BeanSource; import org.apache.commons.jelly.tags.ant.AntTagLibrary; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.tools.ant.types.Path; /** * A mock tag which is used for testing the Ant nested properties behaviour * * @author James Strachan * @version $Revision: 155420 $ */ public class DummyTag extends TagSupport implements BeanSource { /** The Log to which logging calls will be made. */ private static Log log = LogFactory.getLog(DummyTag.class); private String var; private boolean calledCreatepath; private boolean calledSetClasspath; private boolean calledSetFlag; private Path classpath; private boolean flag; public DummyTag() { } // BeanSource interface //------------------------------------------------------------------------- public Object getBean() { return this; } // Tag interface //------------------------------------------------------------------------- public void doTag(XMLOutput output) throws JellyTagException { if (! calledSetFlag) { throw new AssertionFailedError("call to setFlag() was not made"); } calledCreatepath = false; calledSetClasspath = false; invokeBody(output); if (! calledCreatepath) { throw new AssertionFailedError("call to createClasspath() was not made"); } if (! calledSetClasspath) { throw new AssertionFailedError("call to setClasspath() was not made"); } log.info( "Called with classpath: " + classpath ); if (var != null) { context.setVariable(var, classpath); } } // Ant Task-like nested property methods //------------------------------------------------------------------------- public Path createClasspath() { log.info("called createClasspath()"); calledCreatepath = true; return new Path( AntTagLibrary.getProject(context) ); } public void setClasspath(Path classpath) { log.info("called setClasspath()"); calledSetClasspath = true; this.classpath = classpath; } public void setFlag(boolean flag) { log.info("called setFlag()"); calledSetFlag = true; this.flag = flag; } // Tag properties //------------------------------------------------------------------------- public void setVar(String var) { this.var = var; } } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/test/org/apache/commons/jelly/ant/tag/MyTagLibrary.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/test/org/apache/commons/jelly/ant/tag/0000664000175000017500000000224411602216727031335 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.ant.tag; import org.apache.commons.jelly.TagLibrary; /** * Describes the Taglib. * This could be created via Jelly script, or could load the mapping of * tag names to bean classes from properties file etc but is implemented in Java * code for simplicity * * @author James Strachan * @version $Revision: 155420 $ */ public class MyTagLibrary extends TagLibrary { public MyTagLibrary() { registerTag( "dummy", DummyTag.class ); } } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/test/org/apache/commons/jelly/ant/filescanner.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/test/org/apache/commons/jelly/ant/file0000664000175000017500000000300011602216727031411 0ustar davedave Iterating through build files Found ${file.absolutePath} Iterating through test directories Found ${dir.absolutePath} ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/test/org/apache/commons/jelly/ant/example_tasks.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/test/org/apache/commons/jelly/ant/exam0000664000175000017500000000257611602216727031445 0ustar davedave Lets start by calling the echo task Maven home is ${maven.home} classpath: ${project.getReference('test.classpath')} We should be back to the Jelly script again now... ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/test/org/apache/commons/jelly/ant/sample.txtjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/test/org/apache/commons/jelly/ant/samp0000664000175000017500000000003011602216727031432 0ustar davedavehello @foo@ how are you?././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/test/org/apache/commons/jelly/ant/task/jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/test/org/apache/commons/jelly/ant/task0000775000175000017500000000000011602216727031441 5ustar davedave././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/test/org/apache/commons/jelly/ant/task/example.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/test/org/apache/commons/jelly/ant/task0000664000175000017500000000200311602216727031436 0ustar davedave ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/test/org/apache/commons/jelly/ant/task/DummyTask.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/test/org/apache/commons/jelly/ant/task0000664000175000017500000000525311602216727031450 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.ant.task; import org.apache.tools.ant.Task; import org.apache.tools.ant.BuildException; /* Ant: [nested] a [nested] b [nested] c [nested] d [nested] e [nested] f [nested] g [nested] h [nested] i Maven/Jelly: a b c d e f g h i */ /** * A sample Task to test out the Ant introspection logic * * @author Aslak Hellesøy (aslak.hellesoy@bekk.no) * @version $Revision: 155420 $ */ public class DummyTask extends Task { private int i = 0; private String[] messages = { "a", "b", "c", "d", "e", "f", "g", "h", "i" }; private boolean force; public void execute() throws BuildException { if (!force) { throw new BuildException("Should have set force to be true!"); } } public Thingy createDing() { System.out.println("createDing: " + messages[i++]); return new Thingy(); } public void addDang(Thingy thingy) { System.out.println("addDang: " + messages[i++]); } public void addConfiguredDong(Thingy thingy) { System.out.println("addConfiguredDong: " + messages[i++]); } public Thingy createHipHop() { System.out.println("createHipHop: " + messages[i++]); return new Thingy(); } public void addWontStop(Thingy thingy) { System.out.println("addWontStop: " + messages[i++]); } public void addConfiguredTillYouDrop(Thingy thingy) { System.out.println("addConfiguredTillYouDrop: " + messages[i++]); } public boolean isForce() { return force; } public void setForce(boolean force) { this.force = force; } public static class Thingy { } }jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/java/0000775000175000017500000000000011602216727023134 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/java/org/0000775000175000017500000000000011602216727023723 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/java/org/apache/0000775000175000017500000000000011602216727025144 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/java/org/apache/commons/0000775000175000017500000000000011602216727026617 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/java/org/apache/commons/jelly/0000775000175000017500000000000011602216727027736 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/java/org/apache/commons/jelly/tags/0000775000175000017500000000000011602216727030674 5ustar davedave././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/java/org/apache/commons/jelly/tags/ant/jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/java/org/apache/commons/jelly/tags/ant0000775000175000017500000000000011602216727031377 5ustar davedave././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/java/org/apache/commons/jelly/tags/ant/TaskSource.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/java/org/apache/commons/jelly/tags/ant0000664000175000017500000000245011602216727031402 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.ant; import org.apache.commons.jelly.JellyTagException; /** * A tag which provides an Ant Task object on which to set Ant DataTypes or create nested types * * @author James Strachan * @version $Revision: 155420 $ */ public interface TaskSource { /** * @return the Ant object which may be an Ant Task or nested element */ public Object getTaskObject() throws JellyTagException; /** * Allows nested tags to set a property on the task object of this tag */ public void setTaskProperty(String name, Object value) throws JellyTagException; } ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/java/org/apache/commons/jelly/tags/ant/FileScannerTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/java/org/apache/commons/jelly/tags/ant0000664000175000017500000000613211602216727031403 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.ant; import java.lang.reflect.InvocationTargetException; import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.MissingAttributeException; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.XMLOutput; /** * A tag which creates a new FileScanner bean instance that can be used to * iterate over fileSets * * @author James Strachan * @version $Revision: 155420 $ */ public class FileScannerTag extends TagSupport implements TaskSource { /** The file walker that gets created */ private FileScanner fileScanner; /** the variable exported */ private String var; public FileScannerTag(FileScanner fileScanner) { this.fileScanner = fileScanner; } // Tag interface //------------------------------------------------------------------------- public void doTag(XMLOutput output) throws MissingAttributeException, JellyTagException { fileScanner.setProject(AntTagLibrary.getProject(context)); fileScanner.clear(); // run the body first to configure the task via nested invokeBody(output); // output the fileScanner if ( var == null ) { throw new MissingAttributeException( "var" ); } context.setVariable( var, fileScanner ); } // TaskSource interface //------------------------------------------------------------------------- public Object getTaskObject() { return fileScanner; } /** * Allows nested tags to set a property on the task object of this tag */ public void setTaskProperty(String name, Object value) throws JellyTagException { try { BeanUtils.setProperty( fileScanner, name, value ); } catch (IllegalAccessException ex) { throw new JellyTagException(ex); } catch (InvocationTargetException ex) { throw new JellyTagException(ex); } } // Properties //------------------------------------------------------------------------- /** * @return the Ant task */ public FileScanner getFileScanner() { return fileScanner; } /** Sets the name of the variable exported by this tag */ public void setVar(String var) { this.var = var; } } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/java/org/apache/commons/jelly/tags/ant/package.htmljenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/java/org/apache/commons/jelly/tags/ant0000664000175000017500000000202211602216727031375 0ustar davedave

A tag library for using Ant tasks within Jelly

Jelly can be invoked inside Ant and this tag library allows Ant tasks to be invoked from inside Jelly. This allows Jelly to be used for more 'scripting' style targets, such as parsing XML databases, working with custom java beans, doing SQL, the use of JSTL and so forth.

././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/java/org/apache/commons/jelly/tags/ant/PropsHandler.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/java/org/apache/commons/jelly/tags/ant0000664000175000017500000001047011602216727031403 0ustar davedavepackage org.apache.commons.jelly.tags.ant; /* * Copyright 1999-2001,2004 The Apache Software Foundation. * * 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. */ import java.util.Hashtable; import org.apache.tools.ant.Project; /** Interface for delegates supporting property management * for aGrantProject. * * @see org.apache.commons.jelly.tags.ant.GrantProject#setProperty * @see org.apache.commons.jelly.tags.ant.GrantProject#setNewProperty * @see org.apache.commons.jelly.tags.ant.GrantProject#setUserProperty * @see org.apache.commons.jelly.tags.ant.GrantProject#setInheritedProperty * @see org.apache.commons.jelly.tags.ant.GrantProject#getProperty * @see org.apache.commons.jelly.tags.ant.GrantProject#getUserProperty * @see org.apache.commons.jelly.tags.ant.GrantProject#getProperties * @see org.apache.commons.jelly.tags.ant.GrantProject#getUserProperties * @see org.apache.commons.jelly.tags.ant.GrantProject#copyUserProperties * @see org.apache.commons.jelly.tags.ant.GrantProject#copyInheritedProperties * @see org.apache.commons.jelly.tags.ant.GrantProject#setSystemProperties * @see org.apache.commons.jelly.tags.ant.GrantProject#setJavaVersionProperty * * @author Bob McWhirter * @author Stephen Haberman */ public interface PropsHandler { /** Set a property. * * @param key The property key. * @param value The value. */ void setProperty(String key, String value); /** Set a user property. * * @param key The user property key. * @param value The value. */ void setUserProperty(String key, String value); /** Set a new property. * * @param key The property key. * @param value The value. */ void setNewProperty(String key, String value); /** Sets an inherited property. * * @param key The user property key. * @param value The value. */ void setInheritedProperty(String key, String value); /** Sets a property that is not a user property. * * Acts as the replacement for ant's private * setPropertyInternal method. * * @param key The property key. * @param value The value. */ void setPropertyIfUndefinedByUser(String key, String value); /** Retrieve a property. * * @param key The property key. * * @return The value. */ String getProperty(String key); /** Retrieve a user property. * * @param key The user property key. * * @return The value. */ String getUserProperty(String key); /** Retrieve a Hashtable of all properties. * * @return A Hashtable of all properties. */ Hashtable getProperties(); /** Retrieve a Hashtable of all user properties. * * @return A Hashtable of all user properties. */ Hashtable getUserProperties(); /** Copy all of the user properties to the other Project. * * @param other The Project to copy the properties to. */ void copyUserProperties(Project other); /** Copy all of the inherited properties to the other Project. * * @param other The Project to copy the properties to. */ void copyInheritedProperties(Project other); /** Set the system variables for a Project that have * not already been assigned as user properties. */ void setSystemProperties(); /** Set the ant.java.version property. */ void setJavaVersionProperty(); } ././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/java/org/apache/commons/jelly/tags/ant/JellyPropsHandler.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/java/org/apache/commons/jelly/tags/ant0000664000175000017500000000543711602216727031412 0ustar davedavepackage org.apache.commons.jelly.tags.ant; /* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ import java.util.Hashtable; import java.util.Iterator; import org.apache.commons.jelly.JellyContext; import org.apache.commons.jelly.expression.Expression; /** Implementation of a Commons Grant propsHandler * to resolve through Jelly's context. * * @author Bob McWhirter * @author Stephen Haberman */ public class JellyPropsHandler extends DefaultPropsHandler { /** The JellyContext. */ private JellyContext context; /** Simple constructor with the context to be used. * * @param context The context to be used. */ public JellyPropsHandler(JellyContext context) { this.context = context; } /** Set an ant property. * * @param name The property name. * @param value The property value. */ public void setProperty(String name, String value) { this.context.setVariable(name, value); } /** Retrieve an ant property. * * @param name The property name. * * @return The property value. */ public String getProperty(String name) { if (name == null) { return null; } Object value = this.context.getVariable(name); if (value == null) { return null; } else { if ( value instanceof Expression ) { return ( ( Expression ) value ).evaluateAsString( context ); } else { return value.toString(); } } } /** Retrieve all ant properties. * * @return A Hashtable of all properties. */ public Hashtable getProperties() { Hashtable h = new Hashtable(); for (Iterator i = this.context.getVariableNames(); i.hasNext(); ) { String name = (String) i.next(); String value = getProperty( name ); if (value != null) { h.put(name, value); } } return h; } } ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/java/org/apache/commons/jelly/tags/ant/GrantProject.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/java/org/apache/commons/jelly/tags/ant0000664000175000017500000001541611602216727031410 0ustar davedavepackage org.apache.commons.jelly.tags.ant; /* * Copyright 1999-2001,2004 The Apache Software Foundation. * * 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. */ import java.io.File; import java.util.Hashtable; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; import org.apache.tools.ant.ProjectHelper; /** A subclass of an ant Project which allows * installation of delegators for particular functions. * *

* Current delegation points include: * *

    *
  • Properties
  • *
* * @author bob mcwhirter */ public class GrantProject extends Project { // ------------------------------------------------------------ // Instance members // ------------------------------------------------------------ /** Properties delegate. */ private PropsHandler propsHandler; // ------------------------------------------------------------ // Constructors // ------------------------------------------------------------ /** Construct a new, empty GrantProject. * *

* Immediately after initialization, a GrantProject * delegates all calls to the normal ant Project * super class. Only after installing delegators will custom * behavious be acheived. *

*/ public GrantProject() { this.propsHandler = null; } // ------------------------------------------------------------ // Instance methods // ------------------------------------------------------------ /** Install a PropsHandler delegate. * * @param propsHandler The PropsHandler to install, * or null to remove any currently installed * PropsHandler. */ public void setPropsHandler(PropsHandler propsHandler) { this.propsHandler = propsHandler; } /** Retrieve the currently installed PropsHandler. * * @return The currently installed PropsHandler, * or null if no PropsHandler * had yet to be installed. */ public PropsHandler getPropsHandler() { return this.propsHandler; } // ------------------------------------------------------------ // org.apache.tools.ant.Project implementation // ------------------------------------------------------------ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // properties delegators: // // If a PropsHandler is not installed, delegate // up the hierarchy to the ant.Project parent // class. Otherwise, delegate outwards using // the PropsHandler. // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - public String replaceProperties(String value) throws BuildException { return ProjectHelper.replaceProperties(this, value, getProperties()); } public synchronized void setProperty(String key, String value) { if (this.propsHandler == null) { super.setProperty(key, value); } else { this.propsHandler.setProperty(key, value); } } public synchronized void setUserProperty(String key, String value) { if (this.propsHandler == null) { super.setUserProperty(key, value); } else { this.propsHandler.setUserProperty(key, value); } } public synchronized void setNewProperty(String key, String value) { if (this.propsHandler == null) { super.setNewProperty(key, value); } else { this.propsHandler.setNewProperty(key, value); } } public void setInheritedProperty(String key, String value) { if (this.propsHandler == null) { super.setInheritedProperty(key, value); } else { this.propsHandler.setInheritedProperty(key, value); } } public String getProperty(String key) { if (this.propsHandler == null) { return super.getProperty(key); } return this.propsHandler.getProperty(key); } public String getUserProperty(String key) { if (this.propsHandler == null) { return super.getUserProperty(key); } return this.propsHandler.getUserProperty(key); } public Hashtable getUserProperties() { if (this.propsHandler == null) { return super.getUserProperties(); } return this.propsHandler.getUserProperties(); } public Hashtable getProperties() { if (this.propsHandler == null) { return super.getProperties(); } return this.propsHandler.getProperties(); } public void copyUserProperties(Project other) { if (this.propsHandler == null) { super.copyUserProperties(other); } else { this.propsHandler.copyUserProperties(other); } } public void copyInheritedProperties(Project other) { if (this.propsHandler == null) { super.copyInheritedProperties(other); } else { this.propsHandler.copyInheritedProperties(other); } } public void setSystemProperties() { if (this.propsHandler == null) { super.setSystemProperties(); } else { this.propsHandler.setSystemProperties(); } } public void setJavaVersionProperty() throws BuildException { // Always call the super, as they do some sanity checks super.setJavaVersionProperty(); if (this.propsHandler != null) { this.propsHandler.setJavaVersionProperty(); } } public void setBaseDir(File baseDir) throws BuildException { super.setBaseDir(baseDir); if (this.propsHandler != null) { this.propsHandler.setPropertyIfUndefinedByUser( "basedir", baseDir.getPath()); } } } ././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/java/org/apache/commons/jelly/tags/ant/DefaultPropsHandler.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/java/org/apache/commons/jelly/tags/ant0000664000175000017500000001421611602216727031405 0ustar davedavepackage org.apache.commons.jelly.tags.ant; /* * Copyright 1999-2001,2004 The Apache Software Foundation. * * 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. */ import org.apache.tools.ant.Project; import org.apache.tools.ant.util.JavaEnvUtils; import java.util.Enumeration; import java.util.HashMap; import java.util.Hashtable; import java.util.Map; import java.util.Properties; /** Implements the basic {@link org.apache.commons.jelly.tags.ant.PropsHandler} functionality * against an existing map. * *

* If extending DefaultPropsHandler, you can * implement setProperty, getProperty, * and getProperties to provide a complete * implementation of PropsHandler. * * @author Stephen Haberman * @version $Revision: 155983 $ */ public class DefaultPropsHandler implements PropsHandler { /** A map of all of the properties. */ protected Map properties; /** A history of the properties marked as user properties. */ protected Map userProperties = new HashMap(); /** A history of the properties makred as inherited properties. */ protected Map inheritedProperties = new HashMap(); /** Initializes hte object with a blank set of properties. */ public DefaultPropsHandler() { this.properties = new HashMap(); } /** Initializes the object with a given Map * implementation. * * @param properties The Map to use to store and retrieve properties. */ public DefaultPropsHandler(Map properties) { this.properties = properties; } /** * @see PropsHandler#setProperty(String, String) */ public void setProperty(String key, String value) { this.properties.put(key, value); } /** * @see PropsHandler#setUserProperty(String, String) */ public void setUserProperty(String key, String value) { this.userProperties.put(key, value); this.setProperty(key, value); } /** * @see PropsHandler#setNewProperty(String, String) */ public void setNewProperty(String key, String value) { if (this.getProperty(key) == null) { this.setProperty(key, value); } } /** * @see PropsHandler#setInheritedProperty(String, String) */ public void setInheritedProperty(String key, String value) { this.inheritedProperties.put(key, value); this.setUserProperty(key, value); } /** * @see PropsHandler#setPropertyIfUndefinedByUser(String, String) */ public void setPropertyIfUndefinedByUser(String key, String value) { if (!this.getUserProperties().contains(key)) { this.setProperty(key, value); } } /** * @see PropsHandler#getProperty(String) */ public String getProperty(String key) { if (key == null) { return null; } return (String) this.properties.get(key); } /** * @see PropsHandler#getUserProperty(String) */ public String getUserProperty(String key) { if (key == null) { return null; } return (String) this.userProperties.get(key); } /** * @see PropsHandler#getProperties() */ public Hashtable getProperties() { return new Hashtable(this.properties); } /** * @see PropsHandler#getUserProperties() */ public Hashtable getUserProperties() { return new Hashtable(this.userProperties); } public Hashtable getInheritedProperties() { return new Hashtable(this.inheritedProperties); } /** * @see PropsHandler#copyUserProperties(Project) */ public void copyUserProperties(Project other) { Hashtable userProps = this.getUserProperties(); Hashtable inheritedProps = this.getInheritedProperties(); Enumeration e = userProps.keys(); while (e.hasMoreElements()) { Object name = e.nextElement(); if (inheritedProps.contains(name)) { continue; } Object value = userProps.get(name); other.setUserProperty(name.toString(), value.toString()); } } /** * @see PropsHandler#copyInheritedProperties(Project) */ public void copyInheritedProperties(Project other) { Hashtable inheritedProps = this.getInheritedProperties(); Enumeration e = inheritedProps.keys(); while (e.hasMoreElements()) { String name = e.nextElement().toString(); if (other.getUserProperty(name) != null) { continue; } Object value = inheritedProps.get(name); other.setInheritedProperty(name, value.toString()); } } /** * @see PropsHandler#setSystemProperties */ public void setSystemProperties() { Properties systemProps = System.getProperties(); Enumeration e = systemProps.keys(); while (e.hasMoreElements()) { Object name = e.nextElement(); String value = systemProps.get(name).toString(); this.setPropertyIfUndefinedByUser(name.toString(), value); } } /** * @see PropsHandler#setJavaVersionProperty */ public void setJavaVersionProperty() { String javaVersion = JavaEnvUtils.getJavaVersion(); this.setPropertyIfUndefinedByUser("ant.java.version", javaVersion); } } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/java/org/apache/commons/jelly/tags/ant/FileScanner.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/java/org/apache/commons/jelly/tags/ant0000664000175000017500000000402211602216727031377 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.ant; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import org.apache.tools.ant.Project; import org.apache.tools.ant.types.FileSet; /** *

FileScanner is a bean which allows the iteration * over a number of files from a colleciton of FileSet instances. * * @author James Strachan * @version $Revision: 155420 $ */ public class FileScanner { /** FileSets */ private List filesets = new ArrayList(); /** The Ant project */ private Project project; public void setProject(Project project) { this.project = project; } public Iterator iterator() { return new FileIterator(project, filesets.iterator()); } public Iterator directories() { return new FileIterator(project, filesets.iterator(), true); } public boolean hasFiles() { return filesets.size() > 0; } /** * Clears any file sets that have been added to this scanner */ public void clear() { filesets.clear(); } // Properties //------------------------------------------------------------------------- /** * Adds a set of files (nested fileset attribute). */ public void addFileset(FileSet set) { filesets.add(set); } } ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/java/org/apache/commons/jelly/tags/ant/FileIterator.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/java/org/apache/commons/jelly/tags/ant0000664000175000017500000001072411602216727031405 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.ant; import java.io.File; import java.util.Iterator; import java.util.NoSuchElementException; import org.apache.tools.ant.DirectoryScanner; import org.apache.tools.ant.Project; import org.apache.tools.ant.types.FileSet; /** *

FileIterator is an iterator over a * over a number of files from a colleciton of FileSet instances. * * @author James Strachan * @version $Revision: 155420 $ */ public class FileIterator implements Iterator { /** The iterator over the FileSet objects */ private Iterator fileSetIterator; /** The Ant project */ private Project project; /** The directory scanner */ private DirectoryScanner ds; /** The file names in the current FileSet scan */ private String[] files; /** The current index into the file name array */ private int fileIndex = -1; /** The next File object we'll iterate over */ private File nextFile; /** Have we set a next object? */ private boolean nextObjectSet = false; /** Return only directories? */ private boolean iterateDirectories = false; public FileIterator(Project project, Iterator fileSetIterator) { this( project, fileSetIterator, false); } public FileIterator(Project project, Iterator fileSetIterator, boolean iterateDirectories) { this.project = project; this.fileSetIterator = fileSetIterator; this.iterateDirectories = iterateDirectories; } // Iterator interface //------------------------------------------------------------------------- /** @return true if there is another object that matches the given predicate */ public boolean hasNext() { if ( nextObjectSet ) { return true; } else { return setNextObject(); } } /** @return the next object which matches the given predicate */ public Object next() { if ( !nextObjectSet ) { if (!setNextObject()) { throw new NoSuchElementException(); } } nextObjectSet = false; return nextFile; } /** * throws UnsupportedOperationException */ public void remove() { throw new UnsupportedOperationException(); } // Implementation methods //------------------------------------------------------------------------- /** * Set nextObject to the next object. If there are no more * objects then return false. Otherwise, return true. */ private boolean setNextObject() { while (true) { while (ds == null) { if ( ! fileSetIterator.hasNext() ) { return false; } FileSet fs = (FileSet) fileSetIterator.next(); ds = fs.getDirectoryScanner(project); ds.scan(); if (iterateDirectories) { files = ds.getIncludedDirectories(); } else { files = ds.getIncludedFiles(); } if ( files.length > 0 ) { fileIndex = -1; break; } else { ds = null; } } if ( ds != null && files != null ) { if ( ++fileIndex < files.length ) { nextFile = new File( ds.getBasedir(), files[fileIndex] ); nextObjectSet = true; return true; } else { ds = null; } } } } } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/java/org/apache/commons/jelly/tags/ant/AntTagLibrary.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/java/org/apache/commons/jelly/tags/ant0000664000175000017500000001513511602216727031406 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.ant; import org.apache.commons.beanutils.ConvertUtils; import org.apache.commons.beanutils.Converter; import org.apache.commons.jelly.JellyContext; import org.apache.commons.jelly.JellyException; import org.apache.commons.jelly.Tag; import org.apache.commons.jelly.TagLibrary; import org.apache.commons.jelly.impl.TagFactory; import org.apache.commons.jelly.impl.TagScript; import org.apache.tools.ant.BuildLogger; import org.apache.tools.ant.NoBannerLogger; import org.apache.tools.ant.Project; import org.apache.tools.ant.taskdefs.optional.junit.FormatterElement; import org.apache.tools.ant.types.EnumeratedAttribute; import org.apache.tools.ant.types.Reference; import org.xml.sax.Attributes; /** * A Jelly custom tag library that allows Ant tasks to be called from inside Jelly. * * @author James Strachan * @author bob mcwhirter * @version $Revision: 155991 $ */ public class AntTagLibrary extends TagLibrary { public static final String PROJECT_CONTEXT_HANDLE = "org.apache.commons.jelly.ant.Project"; static { // register standard converters for Ant types ConvertUtils.register( new Converter() { public Object convert(Class type, Object value) { if ( value instanceof Reference ) { return (Reference) value; } else if ( value != null ) { String text = value.toString(); return new Reference( text ); } return null; } }, Reference.class ); ConvertUtils.register( new Converter() { public Object convert(Class type, Object value) { if ( value instanceof EnumeratedAttribute ) { return (EnumeratedAttribute) value; } else if ( value instanceof String ) { FormatterElement.TypeAttribute attr = new FormatterElement.TypeAttribute(); attr.setValue( (String) value ); return attr; } return null; } }, FormatterElement.TypeAttribute.class ); } /** * A helper method which will attempt to find a project in the current context * or install one if need be. * * #### this method could move to an AntUtils class. */ public static Project getProject(JellyContext context) { Project project = (Project) context.findVariable( PROJECT_CONTEXT_HANDLE ); if ( project == null ) { project = createProject(context); context.setVariable( PROJECT_CONTEXT_HANDLE , project ); } return project; } /** * Sets the Ant Project to be used for this JellyContext. * * #### this method could move to an AntUtils class. */ public static void setProject(JellyContext context, Project project) { context.setVariable( PROJECT_CONTEXT_HANDLE, project ); } /** * A helper method to create a new project * * #### this method could move to an AntUtils class. */ public static Project createProject(JellyContext context) { GrantProject project = new GrantProject(); project.setPropsHandler(new JellyPropsHandler(context)); BuildLogger logger = new NoBannerLogger(); logger.setMessageOutputLevel( org.apache.tools.ant.Project.MSG_INFO ); logger.setOutputPrintStream( System.out ); logger.setErrorPrintStream( System.err); project.addBuildListener( logger ); project.init(); project.getBaseDir(); if (context.getCurrentURL() != null) { project.setProperty("ant.file", context.getCurrentURL().toExternalForm()); } return project; } /** Creates a new script to execute the given tag name and attributes */ public TagScript createTagScript(String name, Attributes attributes) throws JellyException { TagScript answer = createCustomTagScript(name, attributes); if ( answer == null ) { answer = new TagScript( new TagFactory() { public Tag createTag(String name, Attributes attributes) throws JellyException { return AntTagLibrary.this.createTag(name, attributes); } } ); } return answer; } /** * @return a new TagScript for any custom, statically defined tags, like 'fileScanner' */ public TagScript createCustomTagScript(String name, Attributes attributes) { // custom Ant tags if ( name.equals("fileScanner") ) { return new TagScript( new TagFactory() { public Tag createTag(String name, Attributes attributes) { return new FileScannerTag(new FileScanner()); } } ); } if ( name.equals("setProperty") ) { return new TagScript( new TagFactory() { public Tag createTag(String name, Attributes attributes) { return new SetPropertyTag(); } } ); } return null; } /** * A helper method which creates an AntTag instance for the given element name */ public Tag createTag(String name, Attributes attributes) throws JellyException { AntTag tag = new AntTag( name ); if ( name.equals( "echo" ) ) { tag.setTrim(false); } return tag; } } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/java/org/apache/commons/jelly/tags/ant/AntTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/java/org/apache/commons/jelly/tags/ant0000664000175000017500000005017611602216727031412 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.ant; import java.io.PrintStream; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.Iterator; import java.util.Map; import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.beanutils.MethodUtils; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.MapTagSupport; import org.apache.commons.jelly.Tag; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.jelly.expression.Expression; import org.apache.commons.jelly.impl.BeanSource; import org.apache.commons.jelly.impl.StaticTag; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.DemuxOutputStream; import org.apache.tools.ant.IntrospectionHelper; import org.apache.tools.ant.Project; import org.apache.tools.ant.Task; import org.apache.tools.ant.TaskAdapter; import org.apache.tools.ant.TaskContainer; import org.apache.tools.ant.types.DataType; /** * Tag supporting ant's Tasks as well as * dynamic runtime behaviour for 'unknown' tags. * * @author bob mcwhirter * @author James Strachan */ public class AntTag extends MapTagSupport implements TaskSource { /** The Log to which logging calls will be made. */ private static final Log log = LogFactory.getLog(AntTag.class); private static final Class[] addTaskParamTypes = { String.class }; /** store the name of the manifest tag for special handling */ private static final String ANT_MANIFEST_TAG = "manifest"; /** The name of this tag. */ protected String tagName; /** The general object underlying this tag. */ protected Object object; /** Task, if this tag represents a task. */ protected Task task; /** Construct with a project and tag name. * * @param tagName The name on the tag. */ public AntTag(String tagName) { this.tagName = tagName; } public String toString() { return "[AntTag: name=" + getTagName() + "]"; } // TaskSource interface //------------------------------------------------------------------------- /** Retrieve the general object underlying this tag. * * @return The object underlying this tag. */ public Object getTaskObject() { return this.object; } /** * Allows nested tags to set a property on the task object of this tag */ public void setTaskProperty(String name, Object value) throws JellyTagException { Object object = getTaskObject(); if ( object != null ) { setBeanProperty( object, name, value ); } } // Tag interface //------------------------------------------------------------------------- public void doTag(XMLOutput output) throws JellyTagException { Project project = getAntProject(); String tagName = getTagName(); Object parentObject = findBeanAncestor(); Object parentTask = findParentTaskObject(); // lets assume that Task instances are not nested inside other Task instances // for example inside a should be a nested object, where as // if the parent is not a Task the should create a ManifestTask // // also its possible to have a root Ant tag which isn't a task, such as when // defining ... Object nested = null; if (parentObject != null && !( parentTask instanceof TaskContainer) ) { nested = createNestedObject( parentObject, tagName ); } if (nested == null) { task = createTask( tagName ); if (task != null) { if ( log.isDebugEnabled() ) { log.debug( "Creating an ant Task for name: " + tagName ); } // the following algorithm follows the lifetime of a tag // http://jakarta.apache.org/ant/manual/develop.html#writingowntask // kindly recommended by Stefan Bodewig // create and set its project reference if ( task instanceof TaskAdapter ) { setObject( ((TaskAdapter)task).getProxy() ); } else { setObject( task ); } // set the task ID if one is given Object id = getAttributes().remove( "id" ); if ( id != null ) { project.addReference( (String) id, task ); } // ### we might want to spoof a Target setting here // now lets initialize task.init(); // now lets invoke the body to call all the createXXX() or addXXX() methods String body = getBodyText(); // now lets set any attributes of this tag... setBeanProperties(); // now lets set the addText() of the body content, if its applicaable Method method = MethodUtils.getAccessibleMethod( task.getClass(), "addText", addTaskParamTypes ); if (method != null) { Object[] args = { body }; try { method.invoke(this.task, args); } catch (IllegalAccessException e) { throw new JellyTagException(e); } catch (InvocationTargetException e) { throw new JellyTagException(e); } } // now lets set all the attributes of the child elements // XXXX: to do! // now we're ready to invoke the task // XXX: should we call execute() or perform()? // according to org.apache.tools.ant.Main, redirect stdout and stderr PrintStream initialOut = System.out; PrintStream initialErr = System.err; PrintStream newOut = new PrintStream(new DemuxOutputStream(project, false)); PrintStream newErr = new PrintStream(new DemuxOutputStream(project, true)); try { System.setOut(newOut); System.setErr(newErr); task.perform(); } finally { System.setOut(initialOut); System.setErr(initialErr); } } } if (task == null) { if (nested == null) { if ( log.isDebugEnabled() ) { log.debug( "Trying to create a data type for tag: " + tagName ); } nested = createDataType( tagName ); } else { if ( log.isDebugEnabled() ) { log.debug( "Created nested property tag: " + tagName ); } } if ( nested != null ) { setObject( nested ); // set the task ID if one is given Object id = getAttributes().remove( "id" ); if ( id != null ) { project.addReference( (String) id, nested ); } // TODO: work out why we always set the name attribute. // See JELLY-105. // try{ // PropertyUtils.setProperty( nested, "name", tagName ); // } // catch (Exception e) { // log.warn( "Caught exception setting nested name: " + tagName, e ); // } // now lets invoke the body String body = getBodyText(); // now lets set any attributes of this tag... setBeanProperties(); // now lets add it to its parent if ( parentObject != null ) { IntrospectionHelper ih = IntrospectionHelper.getHelper( parentObject.getClass() ); try { if (log.isDebugEnabled()) { log.debug("About to set the: " + tagName + " property on: " + safeToString(parentObject) + " to value: " + nested + " with type: " + nested.getClass() ); } ih.storeElement( project, parentObject, nested, tagName.toLowerCase() ); } catch (Exception e) { log.warn( "Caught exception setting nested: " + tagName, e ); } // now try to set the property for good measure // as the storeElement() method does not // seem to call any setter methods of non-String types try { BeanUtils.setProperty( parentObject, tagName, nested ); } catch (Exception e) { log.debug("Caught exception trying to set property: " + tagName + " on: " + safeToString(parentObject)); } } } else { log.warn("Could not convert tag: " + tagName + " into an Ant task, data type or property"); // lets treat this tag as static XML... StaticTag tag = new StaticTag("", tagName, tagName); tag.setParent( getParent() ); tag.setBody( getBody() ); tag.setContext(context); for (Iterator iter = getAttributes().entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry) iter.next(); String name = (String) entry.getKey(); Object value = entry.getValue(); tag.setAttribute(name, value); } tag.doTag(output); } } } // Properties //------------------------------------------------------------------------- public String getTagName() { return this.tagName; } /** Set the object underlying this tag. * * @param object The object. */ public void setObject(Object object) { this.object = object; } public Project getAntProject() { Project project = AntTagLibrary.getProject(context); if (project == null) { throw new NullPointerException("No Ant Project object is available"); } return project; } // Implementation methods //------------------------------------------------------------------------- /** * Sets the properties on the Ant task */ public void setBeanProperties() throws JellyTagException { Object object = getTaskObject(); if ( object != null ) { Map map = getAttributes(); for ( Iterator iter = map.entrySet().iterator(); iter.hasNext(); ) { Map.Entry entry = (Map.Entry) iter.next(); String name = (String) entry.getKey(); Object value = entry.getValue(); setBeanProperty( object, name, value ); } } } public void setAttribute(String name, Object value) { if ( value == null ) { // should we send in null? super.setAttribute( name, "" ); } else { if ( value instanceof Expression ) { super.setAttribute( name, ((Expression) value).evaluateRecurse(context) ); } else { super.setAttribute( name, value.toString() ); } } } public void setBeanProperty(Object object, String name, Object value) throws JellyTagException { if ( log.isDebugEnabled() ) { log.debug( "Setting bean property on: "+ safeToString(object )+ " name: " + name + " value: " + safeToString(value)); } IntrospectionHelper ih = IntrospectionHelper.getHelper( object.getClass() ); if ( value instanceof String ) { try { ih.setAttribute( getAntProject(), object, name.toLowerCase(), (String) value ); return; } catch (Exception e) { // ignore: not a valid property } } try { ih.storeElement( getAntProject(), object, value, name ); } catch (Exception e) { try { // let any exceptions bubble up from here BeanUtils.setProperty( object, name, value ); } catch (IllegalAccessException ex) { throw new JellyTagException(ex); } catch (InvocationTargetException ex) { throw new JellyTagException(ex); } } } /** * Creates a nested object of the given object with the specified name */ public Object createNestedObject(Object object, String name) { Object dataType = null; if ( object != null ) { IntrospectionHelper ih = IntrospectionHelper.getHelper( object.getClass() ); if ( ih != null && ! (object instanceof AntTag)) { try { dataType = ih.createElement( getAntProject(), object, name.toLowerCase() ); } catch (BuildException be) { if (object instanceof Tag) { if (log.isDebugEnabled()) { log.debug("Failed attempt to create an ant datatype for a jelly tag", be); } } else { log.error(be); } } } } if ( dataType == null ) { dataType = createDataType( name ); } return dataType; } public Object createDataType(String name) { Object dataType = null; Class type = (Class) getAntProject().getDataTypeDefinitions().get(name); if ( type != null ) { Constructor ctor = null; boolean noArg = false; // DataType can have a "no arg" constructor or take a single // Project argument. try { ctor = type.getConstructor(new Class[0]); noArg = true; } catch (NoSuchMethodException nse) { try { ctor = type.getConstructor(new Class[] { Project.class }); noArg = false; } catch (NoSuchMethodException nsme) { log.info("datatype '" + name + "' didn't have a constructor with an Ant Project", nsme); } } if (noArg) { dataType = createDataType(ctor, new Object[0], name, "no-arg constructor"); } else { dataType = createDataType(ctor, new Object[] { getAntProject() }, name, "an Ant project"); } if (dataType != null && dataType instanceof DataType) { ((DataType)dataType).setProject( getAntProject() ); } } return dataType; } /** * @return an object create with the given constructor and args. * @param ctor a constructor to use creating the object * @param args the arguments to pass to the constructor * @param name the name of the data type being created * @param argDescription a human readable description of the args passed */ private Object createDataType(Constructor ctor, Object[] args, String name, String argDescription) { try { Object datatype = ctor.newInstance(args); return datatype; } catch (InstantiationException ie) { log.error("datatype '" + name + "' couldn't be created with " + argDescription, ie); } catch (IllegalAccessException iae) { log.error("datatype '" + name + "' couldn't be created with " + argDescription, iae); } catch (InvocationTargetException ite) { log.error("datatype '" + name + "' couldn't be created with " + argDescription, ite); } return null; } /** * @param taskName * @return * @throws JellyTagException */ public Task createTask(String taskName) throws JellyTagException { return createTask( taskName, (Class) getAntProject().getTaskDefinitions().get( taskName ) ); } public Task createTask(String taskName, Class taskType) throws JellyTagException { if (taskType == null) { return null; } Object o = null; try { o = taskType.newInstance(); } catch (InstantiationException e) { throw new JellyTagException(e); } catch (IllegalAccessException e) { throw new JellyTagException(e); } Task task = null; if ( o instanceof Task ) { task = (Task) o; } else { TaskAdapter taskA=new TaskAdapter(); taskA.setProxy( o ); task=taskA; } task.setProject(getAntProject()); task.setTaskName(taskName); return task; } /** * Attempts to look up in the parent hierarchy for a tag that implements the * TaskSource interface, which returns an Ant Task object or that implements * BeanSource interface which creates a bean, * or will return the parent tag, which is also a bean. */ protected Object findBeanAncestor() throws JellyTagException { Tag tag = getParent(); while (tag != null) { if (tag instanceof BeanSource) { BeanSource beanSource = (BeanSource) tag; return beanSource.getBean(); } if (tag instanceof TaskSource) { TaskSource taskSource = (TaskSource) tag; return taskSource.getTaskObject(); } tag = tag.getParent(); } return getParent(); } /** * Walks the hierarchy until it finds a parent TaskSource and returns its source or returns null */ protected Object findParentTaskObject() throws JellyTagException { Tag tag = getParent(); while (tag != null) { if (tag instanceof TaskSource) { TaskSource source = (TaskSource) tag; return source.getTaskObject(); } tag = tag.getParent(); } return null; } private String safeToString(Object o) { if(o==null) return "null"; String r = null; try { r = o.toString(); } catch(Exception ex) {} if(r == null) r = "(object of class " + o.getClass() + ")"; return r; } } ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/java/org/apache/commons/jelly/tags/ant/SetPropertyTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/java/org/apache/commons/jelly/tags/ant0000664000175000017500000000666111602216727031412 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.ant; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.MissingAttributeException; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** * Tag which sets an attribute on the parent Ant Task if the given value is not null. * This can be useful when setting parameters on Ant tasks, only if they have been specified * via some well defined property, otherwise allowing the inbuilt default to be used. * * @author James Strachan */ public class SetPropertyTag extends TagSupport { /** The Log to which logging calls will be made. */ private static final Log log = LogFactory.getLog(SetPropertyTag.class); private String name; private Object value; private Object defaultValue; public SetPropertyTag() { } // Tag interface //------------------------------------------------------------------------- public void doTag(XMLOutput output) throws MissingAttributeException, JellyTagException { if (name == null) { throw new MissingAttributeException("name"); } TaskSource tag = (TaskSource) findAncestorWithClass( TaskSource.class ); if ( tag == null ) { throw new JellyTagException( "This tag must be nested within an Ant task tag" ); } Object value = getValue(); if (value == null) { value = getDefault(); } if (value != null) { tag.setTaskProperty(name, value); } } // Properties //------------------------------------------------------------------------- /** * Returns the name. * @return String */ public String getName() { return name; } /** * Returns the value. * @return Object */ public Object getValue() { return value; } /** * Sets the name of the Ant task property to set. * @param name The name of the Ant task property to set */ public void setName(String name) { this.name = name; } /** * Sets the value of the Ant task property to set. * @param value The value of the Ant task property to set */ public void setValue(Object value) { this.value = value; } /** * Returns the defaultValue. * @return Object */ public Object getDefault() { return defaultValue; } /** * Sets the default value to be used if the specified value is empty. */ public void setDefault(Object defaultValue) { this.defaultValue = defaultValue; } } jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/java/org/apache/commons/jelly/task/0000775000175000017500000000000011602216727030700 5ustar davedave././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/java/org/apache/commons/jelly/task/AntJellyContext.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/java/org/apache/commons/jelly/task/Ant0000664000175000017500000001026611602216727031352 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.task; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import org.apache.commons.jelly.JellyContext; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.tools.ant.Project; /**

AntJellyContext represents the Jelly context from inside Ant.

* * @author James Strachan * @version $Revision: 417175 $ */ public class AntJellyContext extends JellyContext { /** The Ant project which contains the variables */ private Project project; /** The Log to which logging calls will be made. */ private Log log = LogFactory.getLog(AntJellyContext.class); public AntJellyContext(Project project, JellyContext parentJellyContext) { super( parentJellyContext ); this.project = project; } /** @return the value of the given variable name */ public Object getVariable(String name) { // look in parent first Object answer = super.getVariable(name); if (answer == null) { answer = project.getProperty(name); } if ( log.isDebugEnabled() ) { String answerString = null; try { answerString = answer.toString(); } catch(Exception ex) {} if(answerString==null && answer!=null) answerString = " of class " + answer.getClass(); log.debug( "Looking up variable: " + name + " answer: " + answerString ); } return answer; } /** Sets the value of the given variable name */ public void setVariable(String name, Object value) { if ( log.isDebugEnabled() ) { log.debug( "Setting variable: " + name + " to: " + value ); } super.setVariable( name, value ); // only export string values back to Ant? if ( value instanceof String ) { project.setProperty(name, (String) value); } } /** Removes the given variable */ public void removeVariable(String name) { super.removeVariable( name ); project.setProperty(name, null); } /** * @return an Iterator over the current variable names in this * context */ public Iterator getVariableNames() { return getVariables().keySet().iterator(); } /** * @return the Map of variables in this scope */ public Map getVariables() { // we should add all the Project's properties Map map = new HashMap( project.getProperties() ); // override any local properties map.putAll( super.getVariables() ); return map; } /** * Sets the Map of variables to use */ public void setVariables(Map variables) { super.setVariables(variables); // export any Ant properties for ( Iterator iter = variables.entrySet().iterator(); iter.hasNext(); ) { Map.Entry entry = (Map.Entry) iter.next(); String key = (String) entry.getKey(); Object value = entry.getValue(); if ( value instanceof String ) { project.setProperty(key, (String)value); } } } // Implementation methods //------------------------------------------------------------------------- /** * Factory method to create a new child of this context */ protected JellyContext createChildContext() { return new AntJellyContext(project, this); } } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/java/org/apache/commons/jelly/task/package.htmljenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/java/org/apache/commons/jelly/task/pac0000664000175000017500000000135111602216727031366 0ustar davedave

A collection of Ant tasks for working with Jelly.

././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/java/org/apache/commons/jelly/task/JellyTask.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/src/java/org/apache/commons/jelly/task/Jel0000664000175000017500000001424011602216727031336 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.task; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import org.apache.commons.jelly.Jelly; import org.apache.commons.jelly.JellyContext; import org.apache.commons.jelly.JellyException; import org.apache.commons.jelly.Script; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.jelly.parser.XMLParser; import org.apache.commons.jelly.tags.ant.AntTagLibrary; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Task; import org.xml.sax.SAXException; /** *

JellyTask is an Ant task which will * run a given Jelly script. * * @author James Strachan * @version $Revision: 155420 $ */ public class JellyTask extends Task { /** The Log to which logging calls will be made. */ private static final Log log = LogFactory.getLog(Jelly.class); /** The JellyContext to use */ private JellyContext context; /** The URL of the script to execute */ private URL url; /** The URL of the root context for other scripts */ private URL rootContext; /** The XML output */ private XMLOutput xmlOutput; /** The file where output is going */ private File output; // Task interface //------------------------------------------------------------------------- /** * Excutes the Jelly script */ public void execute() throws BuildException { try { log( "Running script: " + getUrl() ); if ( output != null ) { log( "Sending output to: " + output ); } Script script = compileScript(); JellyContext context = getJellyContext(); context.setVariable( "project", getProject() ); script.run( context, getXMLOutput() ); getXMLOutput().flush(); } catch (Exception e) { throw new BuildException(e, getLocation() ); } } // Properties //------------------------------------------------------------------------- /** * Sets the script URL to use as an absolute URL or a relative filename */ public void setScript(String script) throws MalformedURLException { setUrl(resolveURL(script)); } public URL getUrl() { return url; } /** * Sets the script URL to use */ public void setUrl(URL url) { this.url = url; } /** * Sets the script file to use */ public void setFile(File file) throws MalformedURLException { setUrl( file.toURL() ); } /** * Sets the output to generate */ public void setOutput(File output) throws IOException { this.output = output; xmlOutput = XMLOutput.createXMLOutput( new FileWriter( output ) ); } public XMLOutput getXMLOutput() throws IOException { if (xmlOutput == null) { xmlOutput = XMLOutput.createXMLOutput( System.out ); } return xmlOutput; } /** * Sets the XMLOutput used */ public void setXMLOutput(XMLOutput xmlOutput) { this.xmlOutput = xmlOutput; } /** * Gets the root context */ public URL getRootContext() throws MalformedURLException { if (rootContext == null) { rootContext = new File(System.getProperty("user.dir")).toURL(); } return rootContext; } /** * Sets the root context */ public void setRootContext(URL rootContext) { this.rootContext = rootContext; } /** * The context to use */ public JellyContext getJellyContext() throws MalformedURLException { if (context == null) { // take off the name off the URL String text = getUrl().toString(); int idx = text.lastIndexOf('/'); text = text.substring(0, idx + 1); JellyContext parentContext = new JellyContext(getRootContext(), new URL(text)); context = new AntJellyContext(getProject() , parentContext); // register the Ant tag library context.registerTagLibrary( "jelly:ant", new AntTagLibrary() ); } return context; } // Implementation methods //------------------------------------------------------------------------- /** * Compiles the script */ protected Script compileScript() throws JellyException { XMLParser parser = new XMLParser(); Script script = null; try { parser.setContext(getJellyContext()); script = parser.parse(getUrl().toString()); } catch (IOException e) { throw new JellyException(e); } catch (SAXException e) { throw new JellyException(e); } script = script.compile(); if (log.isDebugEnabled()) { log.debug("Compiled script: " + getUrl()); } return script; } /** * @return the URL for the relative file name or absolute URL */ protected URL resolveURL(String name) throws MalformedURLException { File file = getProject().resolveFile(name); if (file.exists()) { return file.toURL(); } return new URL(name); } } jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/xdocs/0000775000175000017500000000000011602216727022544 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/xdocs/index.xml0000664000175000017500000000212411602216727024374 0ustar davedave Ant Tag Library dIon Gillard

This is a Jelly interface for Ant. It allows any Ant task or datatype to be executed by Jelly. It also provides some extra tags to make working with Ant from Jelly easier.

jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/xdocs/changes.xml0000664000175000017500000000261611602216727024703 0ustar davedave Changes dIon Gillard Incorporate commons-grant Upgrade to Ant 1.6.5 Ant tags did not redirect stderr/out to project. Upgrade dependencies to stop failing tests Initial release jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/xdocs/navigation.xml0000664000175000017500000000166511602216727025435 0ustar davedave Ant Tag Library jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/ant/maven.xml0000664000175000017500000000340211602216727023253 0ustar davedave jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/0000775000175000017500000000000011602216727022001 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/project.properties0000664000175000017500000000144511602216727025571 0ustar davedave# # Copyright 2002,2004 The Apache Software Foundation. # # 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. # # ------------------------------------------------------------------- # P R O J E C T P R O P E R T I E S # ------------------------------------------------------------------- jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/project.xml0000664000175000017500000000671111602216727024176 0ustar davedave ${basedir}/../tag-project.xml commons-jelly-tags-jetty commons-jelly-tags-jetty 1.0.1-SNAPSHOT org.apache.commons.jelly.tags.jetty These are Jelly tags that can set up an in-process web server. Commons Jelly Jetty Tag Library 1.0 1.0 COMMONS-JELLY-JETTY-1_0 commons-httpclient commons-httpclient 3.0-rc4 jetty jetty 4.2.3 jetty4 commons-jelly commons-jelly-tags-http 1.0 test servletapi servletapi 2.2 http://jakarta.apache.org/tomcat/ jakarta-servletapi-5-servlet provided commons-codec commons-codec 1.3 commons-codec jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/build.xml0000664000175000017500000002064211602216727023626 0ustar davedave jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/0000775000175000017500000000000011602216727022570 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/test/0000775000175000017500000000000011602216727023547 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/test/org/0000775000175000017500000000000011602216727024336 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/test/org/apache/0000775000175000017500000000000011602216727025557 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/test/org/apache/commons/0000775000175000017500000000000011602216727027232 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/test/org/apache/commons/jelly/0000775000175000017500000000000011602216727030351 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/test/org/apache/commons/jelly/jetty/0000775000175000017500000000000011602216727031510 5ustar davedave././@LongLink0000000000000000000000000000020300000000000011560 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/test/org/apache/commons/jelly/jetty/securityHandlerForbidden.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/test/org/apache/commons/jelly/jetty/0000664000175000017500000000405311602216727031514 0ustar davedave Forbidden /* It works! Results for mtc url are: http return code = ${mtc.statusCode} http status text = '${mtc.statusText}' ${httpServerForbidden.stop(false)} ././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/test/org/apache/commons/jelly/jetty/resourceHandler.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/test/org/apache/commons/jelly/jetty/0000664000175000017500000000673011602216727031520 0ustar davedave It works! Results for mtc2 url are: http return code = ${mtc2.statusCode} http status text = '${mtc2.statusText}' size of result = ${mtc2.responseBodyAsString.length()} response time = ${mtc2.responseTime} header[${i}] = ${header} Results for mtc1 url are: http return code = ${mtc1.statusCode} http status text = '${mtc1.statusText}' size of result = ${mtc1.responseBodyAsString.length()} response time = ${mtc1.responseTime} header[${i}] = ${header} ${httpServerHeadOnly.stop(false)} ${httpServerDefault.stop(false)} ././@LongLink0000000000000000000000000000021200000000000011560 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/test/org/apache/commons/jelly/jetty/jellyResourceHandlerRequestBody.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/test/org/apache/commons/jelly/jetty/0000664000175000017500000000430411602216727031513 0ustar davedave ${requestBody} It works! ${mtc1.responseBodyAsString} Results for mtc1 url are: http return code = ${mtc1.statusCode} http status text = '${mtc1.statusText}' ${httpServer.stop(false)} ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/test/org/apache/commons/jelly/jetty/jettyLogFile.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/test/org/apache/commons/jelly/jetty/0000664000175000017500000000315311602216727031514 0ustar davedave ${mtc.responseBodyAsString} Results for mtc url are: http return code = ${mtc.statusCode} http status text = '${mtc.statusText}' size of result = ${mtc.responseBodyAsString.length()} response time = ${mtc.responseTime} header[${i}] = ${header} ${httpServer.stop()} ././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/test/org/apache/commons/jelly/jetty/jellyResourceHandler.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/test/org/apache/commons/jelly/jetty/0000664000175000017500000000605611602216727031521 0ustar davedave It works! It works! Results for mtc2 url are: http return code = ${mtc2.statusCode} http status text = '${mtc2.statusText}' Content-Type = ${mtc2.getResponseHeader("Content-Type")} Location = ${mtc2.getResponseHeader("Location")} Results for mtc1 url are: http return code = ${mtc1.statusCode} http status text = '${mtc1.statusText}' ${httpServerNoOp.stop(false)} ${httpServerOp.stop(false)} ././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/test/org/apache/commons/jelly/jetty/TestJettyHttpServerTags.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/test/org/apache/commons/jelly/jetty/0000664000175000017500000001225111602216727031513 0ustar davedave/* * Copyright 1999-2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.jetty; import java.io.File; import java.io.StringWriter; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import junit.textui.TestRunner; import org.apache.commons.jelly.JellyContext; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** Tests the parser, the engine and the XML tags * * @author James Strachan * @version $Revision: 155420 $ */ public class TestJettyHttpServerTags extends TestCase { /** The Log to which logging calls will be made. */ private static final Log log = LogFactory.getLog(TestJettyHttpServerTags.class); public static void main(String[] args) { TestRunner.run(suite()); } public static Test suite() { return new TestSuite(TestJettyHttpServerTags.class); } public TestJettyHttpServerTags(String testName) { super(testName); } public void testDefaultServer() throws Exception { String text = evaluteScriptAsText( "src/test/org/apache/commons/jelly/jetty/defaultServer.jelly" ); assertEquals("Produces the correct output", "It works!", text); } public void testJettyLogFile() throws Exception { File logFile = new File("src/test/org/apache/commons/jelly/jetty/JellyLogFileTest.log"); if (logFile.exists()) { logFile.delete(); } assertTrue("Logfile does not exist", !logFile.exists()); String text = evaluteScriptAsText( "src/test/org/apache/commons/jelly/jetty/jettyLogFile.jelly" ); assertEquals("Produces the correct output", "It works!", text); assertTrue("Logfile exists", logFile.exists()); } public void testSocketListener() throws Exception { String text = evaluteScriptAsText( "src/test/org/apache/commons/jelly/jetty/socketListener.jelly" ); assertEquals("Produces the correct output", "It works!", text); } public void testHttpContext() throws Exception { String text = evaluteScriptAsText( "src/test/org/apache/commons/jelly/jetty/httpContext.jelly" ); assertEquals("Produces the correct output", "It works!", text); } public void testResourceHandler() throws Exception { String text = evaluteScriptAsText( "src/test/org/apache/commons/jelly/jetty/resourceHandler.jelly" ); assertEquals("Produces the correct output", "It works!", text); } public void testSecurityHandler() throws Exception { String text = evaluteScriptAsText( "src/test/org/apache/commons/jelly/jetty/securityHandlerForbidden.jelly" ); assertEquals("Forbidden test produces the correct output", "It works!", text); text = evaluteScriptAsText( "src/test/org/apache/commons/jelly/jetty/securityHandlerUnauthorized.jelly" ); assertEquals("Unauthorized produces the correct output", "It works!", text); } public void testJellyResourceHandler() throws Exception { String text = evaluteScriptAsText( "src/test/org/apache/commons/jelly/jetty/jellyResourceHandler.jelly" ); assertEquals("jellyResourceHandler produces the correct output", "It works!", text); text = evaluteScriptAsText( "src/test/org/apache/commons/jelly/jetty/jellyResourceHandlerRequestBody.jelly" ); assertEquals("jellyResourceHandlerRequestBody produces the correct output", "It works!", text); } /** * Evaluates the script by the given file name and * returns the whitespace trimmed output as text */ protected String evaluteScriptAsText(String fileName) throws Exception { JellyContext context = new JellyContext(); // allow scripts to refer to any resource inside this project // using an absolute URI like /src/test/org/apache/foo.xml context.setRootURL(new File(".").toURL()); // cature the output StringWriter buffer = new StringWriter(); XMLOutput output = XMLOutput.createXMLOutput(buffer); context.runScript( new File(fileName), output ); String text = buffer.toString().trim(); if (log.isDebugEnabled()) { log.debug("Evaluated script as..."); log.debug(text); } return text; } } ././@LongLink0000000000000000000000000000020600000000000011563 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/test/org/apache/commons/jelly/jetty/securityHandlerUnauthorized.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/test/org/apache/commons/jelly/jetty/0000664000175000017500000000600511602216727031513 0ustar davedave Default / * BASIC Demo Realm It works! Results for mtc2 url are: http return code = ${mtc2.statusCode} http status text = '${mtc2.statusText}' Results for mtc1 url are: http return code = ${mtc1.statusCode} http status text = '${mtc1.statusText}' ${httpServerUnauthorized.stop(false)} ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/test/org/apache/commons/jelly/jetty/httpContext.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/test/org/apache/commons/jelly/jetty/0000664000175000017500000000337711602216727031524 0ustar davedave ${mtc.responseBodyAsString} Results for mtc url are: http return code = ${mtc.statusCode} http status text = '${mtc.statusText}' size of result = ${mtc.responseBodyAsString.length()} response time = ${mtc.responseTime} header[${i}] = ${header} ${httpServer.stop(false)} ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/test/org/apache/commons/jelly/jetty/defaultServer.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/test/org/apache/commons/jelly/jetty/0000664000175000017500000000311011602216727031505 0ustar davedave ${mtc.responseBodyAsString} Results for mtc url are: http return code = ${mtc.statusCode} http status text = '${mtc.statusText}' size of result = ${mtc.responseBodyAsString.length()} response time = ${mtc.responseTime} header[${i}] = ${header} ${httpServer.stop()} ././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/test/org/apache/commons/jelly/jetty/securityHandler.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/test/org/apache/commons/jelly/jetty/0000664000175000017500000001152411602216727031515 0ustar davedave Default / * BASIC Demo Realm Resource Handler Test /resourceHandlerTest/* GET HEAD Default / It works! Results for mtc3 url are: http return code = ${mtc3.statusCode} http status text = '${mtc3.statusText}' Results for mtc2 url are: http return code = ${mtc2.statusCode} http status text = '${mtc2.statusText}' Results for mtc1 url are: http return code = ${mtc1.statusCode} http status text = '${mtc1.statusText}' ${httpServerAllowAccess.stop(false)} ${httpServerNoAccess.stop(false)} ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/test/org/apache/commons/jelly/jetty/socketListener.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/test/org/apache/commons/jelly/jetty/0000664000175000017500000000510411602216727031512 0ustar davedave ${mtc2.responseBodyAsString} Results for mtc1 url are: http return code = ${mtc1.statusCode} http status text = '${mtc1.statusText}' size of result = ${mtc1.responseBodyAsString.length()} response time = ${mtc1.responseTime} header[${i}] = ${header} Results for mtc2 url are: http return code = ${mtc2.statusCode} http status text = '${mtc2.statusText}' size of result = ${mtc2.responseBodyAsString.length()} response time = ${mtc2.responseTime} header[${i}] = ${header} ${httpServer2.stop()} ${httpServer1.stop()} ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/test/org/apache/commons/jelly/jetty/docRoot/jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/test/org/apache/commons/jelly/jetty/0000775000175000017500000000000011602216727031510 5ustar davedave././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/test/org/apache/commons/jelly/jetty/docRoot/test1.txtjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/test/org/apache/commons/jelly/jetty/0000664000175000017500000000001311602216727031504 0ustar davedaveIt works! ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/test/org/apache/commons/jelly/jetty/docRoot/contextTest/jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/test/org/apache/commons/jelly/jetty/0000775000175000017500000000000011602216727031510 5ustar davedave././@LongLink0000000000000000000000000000021000000000000011556 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/test/org/apache/commons/jelly/jetty/docRoot/contextTest/contextTest.txtjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/test/org/apache/commons/jelly/jetty/0000664000175000017500000000001311602216727031504 0ustar davedaveIt works! ././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/test/org/apache/commons/jelly/jetty/docRoot/resourceHandlerTest/jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/test/org/apache/commons/jelly/jetty/0000775000175000017500000000000011602216727031510 5ustar davedave././@LongLink0000000000000000000000000000023000000000000011560 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/test/org/apache/commons/jelly/jetty/docRoot/resourceHandlerTest/resourceHandlerTest.txtjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/test/org/apache/commons/jelly/jetty/0000664000175000017500000000001311602216727031504 0ustar davedaveIt works! ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/test/org/apache/commons/jelly/jetty/setup/jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/test/org/apache/commons/jelly/jetty/0000775000175000017500000000000011602216727031510 5ustar davedave././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/test/org/apache/commons/jelly/jetty/setup/demoRealm.propertiesjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/test/org/apache/commons/jelly/jetty/0000664000175000017500000000207711602216727031520 0ustar davedave# # Copyright 2002,2004 The Apache Software Foundation. # # 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. # # # This file defines users passwords and roles for a HashUserRealm # # The format is # : [, ...] # # Passwords may be clear text, obfuscated or checksummed. The class # com.mortbay.Util.Password should be used to generate obfuscated # passwords or password checksums # # If DIGEST Authentication is used, the password must be in a recoverable # format, either plain text or OBF:. # test: test Aladdin: open sesamejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/java/0000775000175000017500000000000011602216727023511 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/java/org/0000775000175000017500000000000011602216727024300 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/java/org/apache/0000775000175000017500000000000011602216727025521 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/java/org/apache/commons/0000775000175000017500000000000011602216727027174 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/java/org/apache/commons/jelly/0000775000175000017500000000000011602216727030313 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/java/org/apache/commons/jelly/tags/0000775000175000017500000000000011602216727031251 5ustar davedave././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/java/org/apache/commons/jelly/tags/jetty/jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/java/org/apache/commons/jelly/tags/j0000775000175000017500000000000011602216727031423 5ustar davedave././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/java/org/apache/commons/jelly/tags/jetty/ResourceHandlerTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/java/org/apache/commons/jelly/tags/j0000664000175000017500000000632411602216727031432 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.jetty; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.XMLOutput; import org.mortbay.http.handler.ResourceHandler; import java.util.StringTokenizer; /** * Declare a static file resource handler for a Jetty http server * * @author rtl * @version $Id: ResourceHandlerTag.java 155420 2005-02-26 13:06:03Z dirkv $ */ public class ResourceHandlerTag extends TagSupport { /** parameter allowed methods */ private String _allowedMethods; /** Creates a new instance of ResourceHandlerTag */ public ResourceHandlerTag() { } /** * Perform the tag functionality. In this case, add a resource handler * to the parent context, setting the allowed methods if required * * @param xmlOutput where to send output * @throws Exception when an error occurs */ public void doTag(XMLOutput xmlOutput) throws JellyTagException { HttpContextTag httpContext = (HttpContextTag) findAncestorWithClass( HttpContextTag.class); if ( httpContext == null ) { throw new JellyTagException( " tag must be enclosed inside a tag" ); } ResourceHandler resourceHandler = new ResourceHandler(); if (getAllowedMethods() != null) { // split comma-separated list up into tokens and convert to an array StringTokenizer tokenizer = new StringTokenizer( getAllowedMethods(), " ," ); String[] allowedMethods = new String[tokenizer.countTokens()]; for (int i = 0; i < allowedMethods.length; i++) { allowedMethods[i] = tokenizer.nextToken(); } resourceHandler.setAllowedMethods(allowedMethods); } httpContext.addHandler(resourceHandler); invokeBody(xmlOutput); } //-------------------------------------------------------------------------- // Property accessors/mutators //-------------------------------------------------------------------------- /** * Getter for property allowedMethods. * * @return value of property allowedMethods. */ public String getAllowedMethods() { return _allowedMethods; } /** * Setter for property allowedMethods. * * @param allowedMethods Comma separated list of allowed methods. */ public void setAllowedMethods(String allowedMethods) { _allowedMethods = allowedMethods; } } ././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/java/org/apache/commons/jelly/tags/jetty/JettyTagLibrary.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/java/org/apache/commons/jelly/tags/j0000664000175000017500000000426711602216727031436 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.jetty; import java.util.Map; import org.apache.commons.jelly.TagLibrary; /** * A set of jelly tags for instantiating a Jetty HTTP server * * @author rtl * @version $Id: JettyTagLibrary.java 155420 2005-02-26 13:06:03Z dirkv $ */ public class JettyTagLibrary extends TagLibrary { /** * Creates a new instance of LatkaTagLibrary */ public JettyTagLibrary() { registerTag("jettyHttpServer", JettyHttpServerTag.class); registerTag("socketListener", SocketListenerTag.class); registerTag("realm", RealmTag.class); registerTag("httpContext", HttpContextTag.class); registerTag("resourceHandler", ResourceHandlerTag.class); registerTag("notFoundHandler", NotFoundHandlerTag.class); registerTag("securityHandler", SecurityHandlerTag.class); registerTag("jellyResourceHandler", JellyResourceHandlerTag.class); registerTag("getRequest", GetRequestTag.class); registerTag("postRequest", PostRequestTag.class); registerTag("putRequest", PutRequestTag.class); registerTag("deleteRequest", DeleteRequestTag.class); registerTag("responseHeader", ResponseHeaderTag.class); registerTag("responseBody", ResponseBodyTag.class); registerTag("responseCode", ResponseCodeTag.class); } /** * @see TagLibarary#getTagClasses() * * @return a Map of tag name to tag class */ public Map getTagClasses() { return super.getTagClasses(); } } ././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/java/org/apache/commons/jelly/tags/jetty/DeleteRequestTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/java/org/apache/commons/jelly/tags/j0000664000175000017500000000204711602216727031430 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.jetty; /** * Respond to a DELETE request to a Jetty http server * * @author rtl * @version $Id: DeleteRequestTag.java 155420 2005-02-26 13:06:03Z dirkv $ */ public class DeleteRequestTag extends AbstractMethodHandlerTag { /** return the name of the http method handled by this tag */ public String getMethodHandled() { return "DELETE"; } } ././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/java/org/apache/commons/jelly/tags/jetty/JettyHttpServerTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/java/org/apache/commons/jelly/tags/j0000664000175000017500000002004111602216727031422 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.jetty; import java.io.IOException; import java.net.UnknownHostException; import java.net.URL; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.logging.LogFactory; import org.mortbay.http.HttpContext; import org.mortbay.http.HttpListener; import org.mortbay.http.HttpServer; import org.mortbay.http.SocketListener; import org.mortbay.http.UserRealm; import org.mortbay.http.handler.NotFoundHandler; import org.mortbay.http.handler.ResourceHandler; import org.mortbay.util.Log; import org.mortbay.util.MultiException; import org.mortbay.util.OutputStreamLogSink; import org.mortbay.util.Resource; /** * Declare an instance of a Jetty http server * * @author rtl * @version $Id: JettyHttpServerTag.java 155420 2005-02-26 13:06:03Z dirkv $ */ public class JettyHttpServerTag extends TagSupport { /** default port to create listeners for */ public static final int DEFAULT_PORT = 8100; /** default host to create listeners/context for */ public static final String DEFAULT_HOST = "localhost"; /** default context to create context for */ public static final String DEFAULT_CONTEXT_PATH = "/"; /** default resource base to use for context */ public static final String DEFAULT_RESOURCE_BASE = "./docRoot"; /** default log file for Jetty */ public static final String DEFAULT_LOG_FILE = "jetty.log"; /** The Log to which logging calls will be made. */ private static final org.apache.commons.logging.Log log = LogFactory.getLog(JettyHttpServerTag.class); /** the log sink for the Jety server */ private static OutputStreamLogSink _logSink; // static initialisation { // setup a log for Jetty with a default filename try { _logSink = new OutputStreamLogSink(DEFAULT_LOG_FILE); //_logSink.start(); Log.instance().add(_logSink); } catch (Exception ex ) { log.error(ex.getLocalizedMessage()); } } /** unique identifier of the tag/ variable to store result in */ private String _var; /** the http server for this tag */ private HttpServer _server; /** filename of Jetty log file - with default */ private String _logFileName = DEFAULT_LOG_FILE; /** Creates a new instance of JettyHttpServerTag */ public JettyHttpServerTag() { // Create the server _server=new HttpServer(); // turn off alias checking in Jetty's FileResource, // so that we don't need exact case in resource names System.setProperty("org.mortbay.util.FileResource.checkAliases", "false"); } /** * Perform the tag functionality. In this case, create an http server after * making sure that it has at least one context and associated http handler, * creating defaults if it doesn't * * @param xmlOutput where to send output * @throws Exception when an error occurs */ public void doTag(XMLOutput xmlOutput) throws JellyTagException { try { URL logFileURL = getContext().getResource(getLogFileName()); _logSink.setFilename(logFileURL.getPath()); _logSink.start(); } catch (Exception ex ) { log.error(ex.getLocalizedMessage()); } // allow nested tags first, e.g body invokeBody(xmlOutput); try { // if no listeners create a default port listener if (_server.getListeners().length == 0) { SocketListener listener=new SocketListener(); listener.setPort(DEFAULT_PORT); listener.setHost(DEFAULT_HOST); _server.addListener(listener); } // if no context/s create a default context if (_server.getContexts().length == 0) { log.info("Creating a default context"); // Create a context HttpContext context = _server.getContext(DEFAULT_HOST, DEFAULT_CONTEXT_PATH); // Serve static content from the context URL baseResourceURL = getContext().getResource(DEFAULT_RESOURCE_BASE); Resource resource = Resource.newResource(baseResourceURL); context.setBaseResource(resource); _server.addContext(context); } } catch (UnknownHostException e) { throw new JellyTagException(e); } catch (IOException e) { throw new JellyTagException(e); } // check that all the contexts have at least one handler // if not then add a default resource handler and a not found handler HttpContext[] allContexts = _server.getContexts(); for (int i = 0; i < allContexts.length; i++) { HttpContext currContext = allContexts[i]; if (currContext.getHandlers().length == 0) { log.info("Adding resource and not found handlers to context:" + currContext.getContextPath()); currContext.addHandler(new ResourceHandler()); currContext.addHandler(new NotFoundHandler()); } } // Start the http server try { _server.start(); } catch (MultiException e) { throw new JellyTagException(e); } // set variable to value if required if (getVar() != null) { getContext().setVariable(getVar(), _server); } } /** * Add an http listener to the server instance * * @param listener the listener to add */ public void addListener(HttpListener listener) { _server.addListener(listener); } /** * Add an http context to the server instance * * @param context the context to add */ public void addContext(HttpContext context) { _server.addContext(context); } /* ------------------------------------------------------------ */ /** * Add a user authentication realm to the server instance * * @param realm the realm to add * @return the realm added */ public UserRealm addRealm(UserRealm realm) { return _server.addRealm(realm); } //-------------------------------------------------------------------------- // Property accessors/mutators //-------------------------------------------------------------------------- /** * Getter for property var. * * @return Value of property var. */ public String getVar() { return _var; } /** * Setter for property var. * * @param var New value of property var. */ public void setVar(String var) { _var = var; } /** * Getter for property logFileName. * * @return Value of property logFileName. */ public String getLogFileName() { return _logFileName; } /** * Setter for property logFileName. * * @param logFileName New value of property logFileName. */ public void setLogFileName(String logFileName) { _logFileName = logFileName; } } ././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/java/org/apache/commons/jelly/tags/jetty/SecurityHandlerTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/java/org/apache/commons/jelly/tags/j0000664000175000017500000002615311602216727031434 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.jetty; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.XMLOutput; import org.mortbay.http.BasicAuthenticator; import org.mortbay.http.ClientCertAuthenticator; import org.mortbay.http.DigestAuthenticator; import org.mortbay.http.SecurityConstraint.Authenticator; import org.mortbay.http.SecurityConstraint; import org.mortbay.http.handler.SecurityHandler; import org.mortbay.jetty.servlet.FormAuthenticator; import org.mortbay.util.Code; import org.mortbay.xml.XmlParser; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import java.io.IOException; import java.io.StringReader; import java.util.Iterator; /** * Declare a security handler for a Jetty http server * * @author rtl * @version $Id: SecurityHandlerTag.java 155420 2005-02-26 13:06:03Z dirkv $ */ public class SecurityHandlerTag extends TagSupport { /** a form authenticator used by this tag */ private transient FormAuthenticator _formAuthenticator; /** parameter authentication method, defaults to BASIC in Jetty */ private String _authenticationMethod; /** Creates a new instance of SecurityHandlerTag */ public SecurityHandlerTag() { } /** * Perform the tag functionality. In this case, add a security handler * to the parent context, setting the authentication method if required * The security constraints should be specified as the body of this tag * using the same format as a web.xml file wrapped in a single * tag to allow parsing of a well-formed snippet, e.g. * * * * * Default * / * * * * * * * /docRoot/resourceHandlerTest/* * GET * HEAD * * * * * * * * * BASIC * Jetty Demo Realm * * * * * @param xmlOutput where to send output * @throws Exception when an error occurs */ public void doTag(XMLOutput xmlOutput) throws JellyTagException { HttpContextTag httpContext = (HttpContextTag) findAncestorWithClass( HttpContextTag.class); if ( httpContext == null ) { throw new JellyTagException( " tag must be enclosed inside a tag" ); } SecurityHandler securityHandler = new SecurityHandler(); if (getauthenticationMethod() != null) { securityHandler.setAuthMethod(getauthenticationMethod()); } httpContext.addHandler(securityHandler); // get the security constraints from the body of this tag // by parsing the body of the parent (so it will be well formed) String bodyText = getBodyText(); StringReader reader = new StringReader(bodyText); InputSource inputSource = new InputSource(reader); // crate a non-validating parser XmlParser xmlParser = new XmlParser(false); XmlParser.Node node = null; try { node = xmlParser.parse(inputSource); } catch (IOException e) { throw new JellyTagException(e); } catch (SAXException e) { throw new JellyTagException(e); } Iterator iter=node.iterator(); XmlParser.Node currNode = null; while (iter.hasNext()) { Object o = iter.next(); if (!(o instanceof XmlParser.Node)) continue; currNode=(XmlParser.Node)o; String name=currNode.getTag(); if ("security-constraint".equals(name)) { initSecurityConstraint(currNode, httpContext); } else if ("login-config".equals(name)) { initLoginConfig(currNode, httpContext); } else { throw new JellyTagException("Invalid element in tag. Are you using the tag?: " + currNode); } } } /* ------------------------------------------------------------ * This is the code from Jetty's WebApplicationContext * with the HttpContextTag parameter added * * Process a parsed xml node to setup the security constraints * for an http server * * @param node the parsed xml starting node of the constraints * @param httpContext the tag to add the security constraint to */ protected void initSecurityConstraint(XmlParser.Node node, HttpContextTag httpContext) { SecurityConstraint scBase = new SecurityConstraint(); XmlParser.Node auths=node.get("auth-constraint"); if (auths!=null) { scBase.setAuthenticate(true); // auth-constraint Iterator iter= auths.iterator("role-name"); while(iter.hasNext()) { String role=((XmlParser.Node)iter.next()).toString(false,true); scBase.addRole(role); } } XmlParser.Node data=node.get("user-data-constraint"); if (data!=null) { data=data.get("transport-guarantee"); String guarantee = data.toString(false,true).toUpperCase(); if (guarantee==null || guarantee.length()==0 || "NONE".equals(guarantee)) scBase.setDataConstraint(SecurityConstraint.DC_NONE); else if ("INTEGRAL".equals(guarantee)) scBase.setDataConstraint(SecurityConstraint.DC_INTEGRAL); else if ("CONFIDENTIAL".equals(guarantee)) scBase.setDataConstraint(SecurityConstraint.DC_CONFIDENTIAL); else { Code.warning("Unknown user-data-constraint:"+guarantee); scBase.setDataConstraint(SecurityConstraint.DC_CONFIDENTIAL); } } Iterator iter= node.iterator("web-resource-collection"); while(iter.hasNext()) { XmlParser.Node collection=(XmlParser.Node)iter.next(); String name=collection.getString("web-resource-name",false,true); SecurityConstraint sc = (SecurityConstraint)scBase.clone(); sc.setName(name); Iterator iter2= collection.iterator("http-method"); while(iter2.hasNext()) sc.addMethod(((XmlParser.Node)iter2.next()) .toString(false,true)); iter2= collection.iterator("url-pattern"); while(iter2.hasNext()) { String url= ((XmlParser.Node)iter2.next()).toString(false,true); httpContext.addSecurityConstraint(url,sc); } } } /* ------------------------------------------------------------ * This is the code from Jetty's WebApplicationContext * with the HttpContextTag parameter added * * * Process a parsed xml node to setup the authenticator and realm * for an http server * * @param node the parsed xml starting node of the login configuration * @param httpContext the tag to add the authenticator and realm to */ protected void initLoginConfig(XmlParser.Node node, HttpContextTag httpContext) { XmlParser.Node method=node.get("auth-method"); if (method!=null) { Authenticator authenticator=null; String m=method.toString(false,true); if (SecurityConstraint.__FORM_AUTH.equals(m)) authenticator=_formAuthenticator=new FormAuthenticator(); else if (SecurityConstraint.__BASIC_AUTH.equals(m)) authenticator=new BasicAuthenticator(); else if (SecurityConstraint.__DIGEST_AUTH.equals(m)) authenticator=new DigestAuthenticator(); else if (SecurityConstraint.__CERT_AUTH.equals(m)) authenticator=new ClientCertAuthenticator(); else Code.warning("UNKNOWN AUTH METHOD: "+m); httpContext.setAuthenticator(authenticator); } XmlParser.Node name=node.get("realm-name"); if (name!=null) httpContext.setRealmName(name.toString(false,true)); XmlParser.Node formConfig = node.get("form-login-config"); if(formConfig != null) { if (_formAuthenticator==null) Code.warning("FORM Authentication miss-configured"); else { XmlParser.Node loginPage = formConfig.get("form-login-page"); if (loginPage != null) _formAuthenticator.setLoginPage(loginPage.toString(false,true)); XmlParser.Node errorPage = formConfig.get("form-error-page"); if (errorPage != null) _formAuthenticator.setErrorPage(errorPage.toString(false,true)); } } } //-------------------------------------------------------------------------- // Property accessors/mutators //-------------------------------------------------------------------------- /** * Getter for property authenticationMethod. * * @return value of property authenticationMethod. */ public String getauthenticationMethod() { return _authenticationMethod; } /** * Setter for property authenticationMethod. * * @param authenticationMethod Type of authentication (BASIC, FORM, DIGEST, CLIENT-CERT) * Note that only BASIC and CLIENT-CERT are supported by Jetty as of v4.1.1 */ public void setauthenticationMethod(String authenticationMethod) { _authenticationMethod = authenticationMethod; } } ././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/java/org/apache/commons/jelly/tags/jetty/GetRequestTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/java/org/apache/commons/jelly/tags/j0000664000175000017500000000203111602216727031421 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.jetty; /** * Respond to a GET request to a Jetty http server * * @author rtl * @version $Id: GetRequestTag.java 155420 2005-02-26 13:06:03Z dirkv $ */ public class GetRequestTag extends AbstractMethodHandlerTag { /** return the name of the http method handled by this tag */ public String getMethodHandled() { return "GET"; } } ././@LongLink0000000000000000000000000000020600000000000011563 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/java/org/apache/commons/jelly/tags/jetty/JellyResourceHandlerTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/java/org/apache/commons/jelly/tags/j0000664000175000017500000000475711602216727031442 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.jetty; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.XMLOutput; /** * A resource handler that uses Jelly scripts to provide resources * to a context in a Jetty http server * * @author rtl * @version $Id: JellyResourceHandlerTag.java 155420 2005-02-26 13:06:03Z dirkv $ */ public class JellyResourceHandlerTag extends TagSupport { /** The http handler that calls the body of the tag. */ private JellyResourceHttpHandler _jellyResourceHttpHandler; /** Creates a new instance of JellyResourceHandlerTag */ public JellyResourceHandlerTag() { } /** * Perform the tag functionality. In this case, add an http handler * to the parent context that runs the script in the body of this tag * * @param xmlOutput where to send output * @throws Exception when an error occurs */ public void doTag(XMLOutput xmlOutput) throws JellyTagException { HttpContextTag httpContext = (HttpContextTag) findAncestorWithClass( HttpContextTag.class); if ( httpContext == null ) { throw new JellyTagException( " tag must be enclosed inside a tag" ); } _jellyResourceHttpHandler = new JellyResourceHttpHandler(xmlOutput); httpContext.addHandler(_jellyResourceHttpHandler); // process any child method handlers invokeBody(xmlOutput); } //-------------------------------------------------------------------------- // Property accessors/mutators //-------------------------------------------------------------------------- protected JellyResourceHttpHandler getJellyResourceHttpHandler() { return _jellyResourceHttpHandler; } } ././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/java/org/apache/commons/jelly/tags/jetty/NotFoundHandlerTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/java/org/apache/commons/jelly/tags/j0000664000175000017500000000421111602216727031423 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.jetty; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.XMLOutput; import org.mortbay.http.handler.NotFoundHandler; /** * Declare a not found resource handler for a Jetty http server * * @author rtl * @version $Id: NotFoundHandlerTag.java 155420 2005-02-26 13:06:03Z dirkv $ */ public class NotFoundHandlerTag extends TagSupport { /** Creates a new instance of NotFoundHandlerTag */ public NotFoundHandlerTag() { } /** * Perform the tag functionality. In this case, add a resource handler * to the parent context, setting the allowed methods if required * * @param xmlOutput where to send output * @throws Exception when an error occurs */ public void doTag(XMLOutput xmlOutput) throws JellyTagException { HttpContextTag httpContext = (HttpContextTag) findAncestorWithClass( HttpContextTag.class); if ( httpContext == null ) { throw new JellyTagException( " tag must be enclosed inside a tag" ); } NotFoundHandler notFoundHandler = new NotFoundHandler(); httpContext.addHandler(notFoundHandler); invokeBody(xmlOutput); } //-------------------------------------------------------------------------- // Property accessors/mutators //-------------------------------------------------------------------------- } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/java/org/apache/commons/jelly/tags/jetty/package.htmljenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/java/org/apache/commons/jelly/tags/j0000664000175000017500000000141611602216727031427 0ustar davedave

Tags for starting Jetty HTTP servers and procesing HTTP requests using Jelly scripts

././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/java/org/apache/commons/jelly/tags/jetty/SocketListenerTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/java/org/apache/commons/jelly/tags/j0000664000175000017500000000623211602216727031430 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.jetty; import java.io.IOException; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.XMLOutput; import org.mortbay.http.SocketListener; import org.mortbay.util.InetAddrPort; /** * Declare a socket listener for a Jetty http server * * @author rtl * @version $Id: SocketListenerTag.java 155420 2005-02-26 13:06:03Z dirkv $ */ public class SocketListenerTag extends TagSupport { /** parameter port with default*/ private int _port = JettyHttpServerTag.DEFAULT_PORT; /** parameter host, with default */ private String _host = JettyHttpServerTag.DEFAULT_HOST; /** Creates a new instance of SocketListenerTag */ public SocketListenerTag() { } /** * Perform the tag functionality. In this case, add a socket listener * for the specified host and port to the parent server, * * @param xmlOutput where to send output * @throws Exception when an error occurs */ public void doTag(XMLOutput xmlOutput) throws JellyTagException { JettyHttpServerTag httpserver = (JettyHttpServerTag) findAncestorWithClass( JettyHttpServerTag.class); if ( httpserver == null ) { throw new JellyTagException( " tag must be enclosed inside a tag" ); } try { httpserver.addListener( new SocketListener(new InetAddrPort(getHost(), getPort()))); } catch (IOException e) { throw new JellyTagException(e); } invokeBody(xmlOutput); } //-------------------------------------------------------------------------- // Property accessors/mutators //-------------------------------------------------------------------------- /** * Getter for property port. * * @return value of property port. */ public int getPort() { return _port; } /** * Setter for property port. * * @param port New value of property port. */ public void setPort(int port) { _port = port; } /** * Getter for property host. * * @return value of property host. */ public String getHost() { return _host; } /** * Setter for property host. * * @param host New value of property host. */ public void setHost(String host) { _host = host; } } ././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/java/org/apache/commons/jelly/tags/jetty/PutRequestTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/java/org/apache/commons/jelly/tags/j0000664000175000017500000000207711602216727031433 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.jetty; /** * Respond to a PUT request to a Jetty http server * * @author rtl * @version $Id: PutRequestTag.java 155420 2005-02-26 13:06:03Z dirkv $ */ /** A tag for the http PUT method */ public class PutRequestTag extends AbstractMethodHandlerTag { /** return the name of the http method handled by this tag */ public String getMethodHandled() { return "PUT"; } } ././@LongLink0000000000000000000000000000020700000000000011564 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/java/org/apache/commons/jelly/tags/jetty/AbstractMethodHandlerTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/java/org/apache/commons/jelly/tags/j0000664000175000017500000000441111602216727031425 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.jetty; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.XMLOutput; /** * An abstract base tag to declare a handler for a particular request method * in an http context in an http server * * @author rtl * @version $Id: AbstractMethodHandlerTag.java 155420 2005-02-26 13:06:03Z dirkv $ */ abstract public class AbstractMethodHandlerTag extends TagSupport { /** Override this to return the name of the http method handled by this tag */ abstract public String getMethodHandled(); /** * Perform the tag functionality. In this case, add a http method handler * to the parent that invokes the script in the body of this tag when * processing an http request * * @param xmlOutput where to send output * @throws Exception when an error occurs */ public void doTag(XMLOutput xmlOutput) throws JellyTagException { JellyResourceHandlerTag parentTag = (JellyResourceHandlerTag) findAncestorWithClass( JellyResourceHandlerTag.class); if ( parentTag == null ) { throw new JellyTagException( "<" + getMethodHandled().toLowerCase() + "Request> tag must be enclosed inside a tag" ); } // register this tag with the http handler for the appropriate method parentTag.getJellyResourceHttpHandler().registerTag(this, getMethodHandled()); // NOTE - don't invokeBody here as we only want to do it during a request } } ././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/java/org/apache/commons/jelly/tags/jetty/PostRequestTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/java/org/apache/commons/jelly/tags/j0000664000175000017500000000203311602216727031423 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.jetty; /** * Respond to a POST request to a Jetty http server * * @author rtl * @version $Id: PostRequestTag.java 155420 2005-02-26 13:06:03Z dirkv $ */ public class PostRequestTag extends AbstractMethodHandlerTag { /** return the name of the http method handled by this tag */ public String getMethodHandled() { return "POST"; } } ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/java/org/apache/commons/jelly/tags/jetty/RealmTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/java/org/apache/commons/jelly/tags/j0000664000175000017500000000661411602216727031434 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.jetty; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.XMLOutput; import org.mortbay.http.HashUserRealm; import java.io.IOException; import java.net.URL; /** * Declare a user realm for a Jetty http server * * @author rtl * @version $Id: RealmTag.java 155420 2005-02-26 13:06:03Z dirkv $ */ public class RealmTag extends TagSupport { /** parameter name with default*/ private String _name; /** parameter config, with default */ private String _config; /** Creates a new instance of RealmTag */ public RealmTag() { } /** * Perform the tag functionality. In this case, add a realm with the * specified name using the specified config (preperties) file to the * parent server, * * @param xmlOutput where to send output * @throws Exception when an error occurs */ public void doTag(XMLOutput xmlOutput) throws JellyTagException { JettyHttpServerTag httpserver = (JettyHttpServerTag) findAncestorWithClass( JettyHttpServerTag.class); if ( httpserver == null ) { throw new JellyTagException( " tag must be enclosed inside a tag" ); } if (null == getName() || null == getConfig()) { throw new JellyTagException( " tag must have a name and a config" ); } // convert the config string to a URL // (this makes URL's relative to the location of the script try { URL configURL = getContext().getResource(getConfig()); httpserver.addRealm( new HashUserRealm(getName(), configURL.toString() ) ); } catch (IOException e) { throw new JellyTagException(e); } invokeBody(xmlOutput); } //-------------------------------------------------------------------------- // Property accessors/mutators //-------------------------------------------------------------------------- /** * Getter for property name. * * @return value of property name. */ public String getName() { return _name; } /** * Setter for property name. * * @param name New value of property name. */ public void setName(String name) { _name = name; } /** * Getter for property config. * * @return value of property config. */ public String getConfig() { return _config; } /** * Setter for property config. * * @param config New value of property config. */ public void setConfig(String config) { _config = config; } } ././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/java/org/apache/commons/jelly/tags/jetty/ResponseHeaderTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/java/org/apache/commons/jelly/tags/j0000664000175000017500000000577711602216727031445 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.jetty; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.XMLOutput; import org.mortbay.http.HttpResponse; /** * Set a response header in the request handler of a Jetty http server * * @author rtl */ public class ResponseHeaderTag extends TagSupport { /** parameter name */ private String _name; /** parameter value */ private String _value; /** * Perform the tag functionality. In this case, set a header in the * http response found in the jelly context * * @param xmlOutput where to send output * @throws Exception when an error occurs */ public void doTag(XMLOutput xmlOutput) throws JellyTagException { if (null == getName()) { throw new JellyTagException(" tag must have a name"); } // get the response from the context HttpResponse httpResponse = (HttpResponse) getContext().getVariable("response"); if (null == httpResponse) { throw new JellyTagException("HttpResponse variable not available in Jelly context"); } // if value is valid then set it // otherwise remove the field if (null != getValue()) { httpResponse.setField(getName(), getValue()); } else { httpResponse.removeField(getName()); } } //-------------------------------------------------------------------------- // Property accessors/mutators //-------------------------------------------------------------------------- /** * Getter for property context path. * * @return value of property context path. */ public String getName() { return _name; } /** * Setter for property context path. * * @param path New value of property context path. */ public void setName(String name) { _name = name; } /** * Getter for property value. * * @return value of property value. */ public String getValue() { return _value; } /** * Setter for property value. * * @param value New value of property value. */ public void setValue(String value) { _value = value; } } ././@LongLink0000000000000000000000000000020700000000000011564 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/java/org/apache/commons/jelly/tags/jetty/JellyResourceHttpHandler.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/java/org/apache/commons/jelly/tags/j0000664000175000017500000001250111602216727031424 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.jetty; import org.apache.commons.jelly.JellyContext; import org.apache.commons.jelly.Tag; import org.apache.commons.jelly.XMLOutput; import org.mortbay.http.HttpException; import org.mortbay.http.HttpRequest; import org.mortbay.http.HttpResponse; import org.mortbay.http.handler.AbstractHttpHandler; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.lang.StringBuffer; import java.util.HashMap; import java.util.Map; /** * The actual http handler implementation for an http context in an http server * * @author rtl * @version $Id: JellyResourceHttpHandler.java 155420 2005-02-26 13:06:03Z dirkv $ */ class JellyResourceHttpHandler extends AbstractHttpHandler { /** The Log to which logging calls will be made. */ private static final Log log = LogFactory.getLog(JellyResourceHttpHandler.class); /** The name of the var to check if setHandled should not be set to true . */ private static final String OVERRIDE_SET_HANDLED_VAR = "overrideSetHandled"; /** The list of tags registered to handle a request method */ private Map _tagMap; /** The place where to output the results of the tag body */ private XMLOutput _xmlOutput; /** Creates a new instance of JellyResourceHttpHandler */ public JellyResourceHttpHandler( XMLOutput xmlOutput ) { _tagMap = new HashMap(); _xmlOutput = xmlOutput; } /* * register this tag as the handler for the specified method * * @param tag the tag to be registered * @param method the name of the http method which this tag processes */ public void registerTag(Tag tag, String method){ _tagMap.put(method.toLowerCase(), tag); } /* * handle an http request * * @param pathInContext the path of the http request * @param pathParams the parameters (if any) of the http request * @param request the actual http request * @param response the place for any response * * @throws HttpException when an error occurs * @throws IOException when an error occurs */ public void handle(String pathInContext, String pathParams, HttpRequest request, HttpResponse response) throws HttpException, IOException { Tag handlerTag = (Tag) _tagMap.get(request.getMethod().toLowerCase()); if (null != handlerTag) { // setup the parameters in the jelly context JellyContext jellyContext = handlerTag.getContext(); jellyContext.setVariable( "pathInContext", pathInContext); jellyContext.setVariable( "pathParams", pathParams); jellyContext.setVariable( "request", request); jellyContext.setVariable( "requestBody", getRequestBody(request)); jellyContext.setVariable( "response", response); try { handlerTag.invokeBody(_xmlOutput); // only call set handled if tag has not requested an override // if it has requested an override then reset the request if (null == jellyContext.getVariable(OVERRIDE_SET_HANDLED_VAR)) { request.setHandled(true); response.commit(); } else { jellyContext.removeVariable(OVERRIDE_SET_HANDLED_VAR); } } catch (Exception ex ) { throw new HttpException(HttpResponse.__500_Internal_Server_Error, "Error invoking method handler tag: " + ex.getLocalizedMessage()); } } else { log.info("No handler for request:" + request.getMethod() + " path:" + response.getHttpContext().getContextPath() + pathInContext); } return; } public String getRequestBody(HttpRequest request) throws IOException { // read the body as a string from the input stream InputStream is = request.getInputStream(); InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedReader(isr); StringBuffer sb = new StringBuffer(); char[] buffer = new char[1024]; int len; while ((len = isr.read(buffer, 0, 1024)) != -1) sb.append(buffer, 0, len); if (sb.length() > 0) return sb.toString(); else return null; } } ././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/java/org/apache/commons/jelly/tags/jetty/ResponseCodeTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/java/org/apache/commons/jelly/tags/j0000664000175000017500000000465211602216727031434 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.jetty; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.XMLOutput; import org.mortbay.http.HttpResponse; /** * Set the response code in the request handler of a Jetty http server * * @author rtl */ public class ResponseCodeTag extends TagSupport { /** parameter value */ private int _value; /** * Perform the tag functionality. In this case, set the response code in the * http response found in the jelly context * * @param xmlOutput where to send output * @throws Exception when an error occurs */ public void doTag(XMLOutput xmlOutput) throws JellyTagException { if (getValue() <= 100) { throw new JellyTagException(" tag must have a value of at least 100"); } // get the response from the context HttpResponse httpResponse = (HttpResponse) getContext().getVariable("response"); if (null == httpResponse) { throw new JellyTagException("HttpResponse variable not available in Jelly context"); } // set response code httpResponse.setStatus(getValue()); } //-------------------------------------------------------------------------- // Property accessors/mutators //-------------------------------------------------------------------------- /** * Getter for property value. * * @return value of property value. */ public int getValue() { return _value; } /** * Setter for property value. * * @param value New value of property value. */ public void setValue(int value) { _value = value; } } ././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/java/org/apache/commons/jelly/tags/jetty/HttpContextTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/java/org/apache/commons/jelly/tags/j0000664000175000017500000001305311602216727031427 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.jetty; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.XMLOutput; import org.mortbay.http.HttpContext; import org.mortbay.http.HttpHandler; import org.mortbay.http.SecurityConstraint; import org.mortbay.http.SecurityConstraint.Authenticator; import org.mortbay.util.Resource; import java.io.IOException; import java.net.URL; import java.net.MalformedURLException; /** * Declare a context for a Jetty http server * * @author rtl * @version $Id: HttpContextTag.java 155420 2005-02-26 13:06:03Z dirkv $ */ public class HttpContextTag extends TagSupport { /** parameter path with default*/ private String _contextPath = JettyHttpServerTag.DEFAULT_CONTEXT_PATH; /** parameter resourceBase, with default */ private String _resourceBase = JettyHttpServerTag.DEFAULT_RESOURCE_BASE; /** parameter realmName*/ private String _realmName; /** the actual context this tag refers to */ private HttpContext _context; /** Creates a new instance of HttpContextTag */ public HttpContextTag() { // create an actual context for this tag _context = new HttpContext(); } /** * Perform the tag functionality. In this case, setup the context path * and resource base before adding the context to the parent server * * @param xmlOutput where to send output * @throws Exception when an error occurs */ public void doTag(XMLOutput xmlOutput) throws JellyTagException { JettyHttpServerTag httpserver = (JettyHttpServerTag) findAncestorWithClass( JettyHttpServerTag.class); if ( httpserver == null ) { throw new JellyTagException( " tag must be enclosed inside a tag" ); } // allow nested tags first, e.g body invokeBody(xmlOutput); _context.setContextPath(getContextPath()); // convert the resource string to a URL // (this makes URL's relative to the location of the script try { URL baseResourceURL = getContext().getResource(getResourceBase()); _context.setBaseResource(Resource.newResource(baseResourceURL)); } catch (MalformedURLException e) { throw new JellyTagException(e); } catch (IOException e) { throw new JellyTagException(e); } if (null != getRealmName()) { _context.setRealmName(getRealmName()); } httpserver.addContext(_context); } /** * Add an http handler to the context instance * * @param handler the handler to add */ public void addHandler(HttpHandler httHandler) { _context.addHandler(httHandler); } /** * Add a security constraint for the specified path specification * to the context instance * * @param pathSpec the path specification for the security constraint * @param sc the security constraint to add */ public void addSecurityConstraint(String pathSpec, SecurityConstraint sc) { _context.addSecurityConstraint(pathSpec, sc); } /** * Add an authenticator to the context instance * * @param authenticator the authenticator to add */ public void setAuthenticator(Authenticator authenticator) { _context.setAuthenticator(authenticator); } //-------------------------------------------------------------------------- // Property accessors/mutators //-------------------------------------------------------------------------- /** * Getter for property context path. * * @return value of property context path. */ public String getContextPath() { return _contextPath; } /** * Setter for property context path. * * @param path New resourceBase of property context path. */ public void setContextPath(String contextPath) { _contextPath = contextPath; } /** * Getter for property resourceBase. * * @return value of property resourceBase. */ public String getResourceBase() { return _resourceBase; } /** * Setter for property resourceBase. * * @param resourceBase New value of property resourceBase. */ public void setResourceBase(String resourceBase) { _resourceBase = resourceBase; } /** * Getter for property realm name. * * @return value of property realm name. */ public String getRealmName() { return _realmName; } /** * Setter for property context path. * * @param path New resourceBase of property context path. */ public void setRealmName(String realmName) { _realmName = realmName; } } ././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/java/org/apache/commons/jelly/tags/jetty/ResponseBodyTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/src/java/org/apache/commons/jelly/tags/j0000664000175000017500000000406311602216727031430 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.jetty; import java.io.IOException; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.XMLOutput; import org.mortbay.http.HttpResponse; import org.mortbay.util.ByteArrayISO8859Writer; /** * Set the response body in a response handler for a Jetty http server * * @author rtl */ public class ResponseBodyTag extends TagSupport { /** * Perform the tag functionality. In this case, set the body of a * http response found in the jelly context * * @param xmlOutput where to send output * @throws Exception when an error occurs */ public void doTag(XMLOutput xmlOutput) throws JellyTagException { // get the response from the context HttpResponse httpResponse = (HttpResponse) getContext().getVariable("response"); if (null == httpResponse) { throw new JellyTagException("HttpResponse variable not available in Jelly context"); } ByteArrayISO8859Writer writer = new ByteArrayISO8859Writer(1500); try { writer.write(getBodyText()); writer.flush(); httpResponse.setContentLength(writer.size()); writer.writeTo(httpResponse.getOutputStream()); } catch (IOException e) { throw new JellyTagException(e); } } } jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/xdocs/0000775000175000017500000000000011602216727023121 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/xdocs/index.xml0000664000175000017500000000204411602216727024752 0ustar davedave Jetty Tag Library dIon Gillard

Tags for starting Jetty HTTP servers and procesing HTTP requests using Jelly scripts. See the tags for more information.

jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/xdocs/changes.xml0000664000175000017500000000162711602216727025261 0ustar davedave Changes dIon Gillard jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/xdocs/navigation.xml0000664000175000017500000000167311602216727026011 0ustar davedave Jetty Tag Library jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jetty/maven.xml0000664000175000017500000000146211602216727023634 0ustar davedave Warning: This tag library requires JDK1.4 or JDK1.3 with JSSE installed to build. You are using version ${java.version} jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/project.xml0000664000175000017500000000650611602216727023041 0ustar davedave 3 commons-jelly commons-jelly-tags Jelly Library Master Maven POM 1.0.1-SNAPSHOT Apache Software Foundation http://www.apache.org http://jakarta.apache.org/commons/images/jakarta-logo-blue.gif /images/logo.jpg org.apache.commons.jelly.tags.* jakarta http://jakarta.apache.org/commons/jelly/libs/ http://issues.apache.org/ jakarta.apache.org /www/jakarta.apache.org/commons/jelly/jelly-tags /www/jakarta.apache.org/builds/jakarta-commons/jelly/jelly-tags scm:svn:http://svn.apache.org/repos/asf/jakarta/commons/proper/jelly/trunk/jelly-tags scm:svn:https://svn.apache.org/repos/asf/jakarta/commons/proper/jelly/trunk/jelly-tags http://svn.apache.org/viewcvs.cgi/jakarta/commons/proper/jelly/trunk/jelly-tags Commons Dev List commons-dev-subscribe@jakarta.apache.org commons-dev-unsubscribe@jakarta.apache.org http://mail-archives.apache.org/eyebrowse/SummarizeList?listName=commons-dev@jakarta.apache.org Commons User List commons-user-subscribe@jakarta.apache.org commons-user-unsubscribe@jakarta.apache.org http://mail-archives.apache.org/eyebrowse/SummarizeList?listName=commons-user@jakarta.apache.org commons-dev@jakarta.apache.org ${basedir}/src/java ${basedir}/src/test **/Test*.java ${basedir} **/*.properties jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/avalon/0000775000175000017500000000000011602216727022122 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/avalon/project.properties0000664000175000017500000000144511602216727025712 0ustar davedave# # Copyright 2002,2004 The Apache Software Foundation. # # 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. # # ------------------------------------------------------------------- # P R O J E C T P R O P E R T I E S # ------------------------------------------------------------------- jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/avalon/project.xml0000664000175000017500000000345211602216727024316 0ustar davedave ${basedir}/../tag-project.xml commons-jelly-tags-avalon commons-jelly-tags-avalon 1.0.1-SNAPSHOT org.apache.commons.jelly.avalon This is a Jelly library for Avalon This is a Jelly library for Avalon 1.0 1.0 COMMONS_JELLY_AVALON-1_0 avalon-framework avalon-framework 4.1.3 avalon-framework-api commons-cli commons-cli 1.0 jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/avalon/build.xml0000664000175000017500000002006411602216727023745 0ustar davedave jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/avalon/src/0000775000175000017500000000000011602216727022711 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/avalon/src/test/0000775000175000017500000000000011602216727023670 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/avalon/src/test/org/0000775000175000017500000000000011602216727024457 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/avalon/src/test/org/apache/0000775000175000017500000000000011602216727025700 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/avalon/src/test/org/apache/commons/0000775000175000017500000000000011602216727027353 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/avalon/src/test/org/apache/commons/jelly/0000775000175000017500000000000011602216727030472 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/avalon/src/test/org/apache/commons/jelly/tags/0000775000175000017500000000000011602216727031430 5ustar davedave././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/avalon/src/test/org/apache/commons/jelly/tags/avalon/jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/avalon/src/test/org/apache/commons/jelly/tags/0000775000175000017500000000000011602216727031430 5ustar davedave././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/avalon/src/test/org/apache/commons/jelly/tags/avalon/sample.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/avalon/src/test/org/apache/commons/jelly/tags/0000664000175000017500000000141411602216727031432 0ustar davedave jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/avalon/src/java/0000775000175000017500000000000011602216727023632 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/avalon/src/java/org/0000775000175000017500000000000011602216727024421 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/avalon/src/java/org/apache/0000775000175000017500000000000011602216727025642 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/avalon/src/java/org/apache/commons/0000775000175000017500000000000011602216727027315 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/avalon/src/java/org/apache/commons/jelly/0000775000175000017500000000000011602216727030434 5ustar davedave././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/avalon/src/java/org/apache/commons/jelly/avalon/jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/avalon/src/java/org/apache/commons/jelly/avalo0000775000175000017500000000000011602216727031457 5ustar davedave././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/avalon/src/java/org/apache/commons/jelly/avalon/JellyService.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/avalon/src/java/org/apache/commons/jelly/avalo0000664000175000017500000001063111602216727031462 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.avalon; import java.util.Map; import java.util.HashMap; import java.util.Iterator; import java.net.URL; import java.net.MalformedURLException; import java.io.File; import java.io.InputStream; import java.io.OutputStream; // Avalon import org.apache.avalon.framework.configuration.Configurable; import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.configuration.ConfigurationException; // Jelly import org.apache.commons.jelly.Jelly; import org.apache.commons.jelly.JellyContext; import org.apache.commons.jelly.JellyException; import org.apache.commons.jelly.Script; import org.apache.commons.jelly.XMLOutput; /** * An Avalon based service for executing Jelly scripts. The * service allows executing a script based on a name as well * as by a URL. * * @author Robert McIntosh * @version 1.1 */ public interface JellyService { /** * Executes a named script with the supplied * Map of parameters. * * @param params Parameters to be supplied to the script * @return All of the variables from the JellyContext * @exception Exception if the script raises some kind of exception while processing */ public Map runNamedScript( String name, Map params ) throws Exception; /** * Executes a named script with the supplied * Map of parameters. * * @param name is the name of the script to run * @param params Parameters to be supplied to the script * @param output is the XMLOutput for any output to be sent * @return All of the variables from the JellyContext * @exception Exception if the script raises some kind of exception while processing */ public Map runNamedScript( String name, Map params, XMLOutput output ) throws Exception; /** * Executes a named script with the supplied * Map of parameters and send the output of the script * to the supplied output stream. * * @param name is the name of the script to run * @param params Parameters to be supplied to the script * @param out is the outputStream for output to be sent * @return All of the variables from the JellyContext * @exception Exception if the script raises some kind of exception while processing */ public Map runNamedScript( String name, Map params, OutputStream out ) throws Exception; /** * Runs a script from the supplied url * * @param url The URL of the script * @param params Parameters to be supplied to the script * @param output is the XMLOutput where output of the script will go * @return All of the variables from the JellyContext */ public Map runScript( String url, Map params, XMLOutput output ) throws Exception; /** * Runs a script from the supplied url and sends the output of the script to * the supplied OutputStream. * * @param url The URL of the script * @param params Parameters to be supplied to the script * @param out The OutputStream to send the output of the script to * @return All of the variables from the JellyContext * @exception Exception if the script raises some kind of exception while processing */ public Map runScript( String url, Map params, OutputStream out ) throws Exception; /** * Runs a script from the supplied url * * @param url The URL of the script * @param params Parameters to be supplied to the script * @return All of the variables from the JellyContext * @exception Exception if the script raises some kind of exception while processing */ public Map runScript( String url, Map params ) throws Exception; } ././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/avalon/src/java/org/apache/commons/jelly/avalon/JellyServiceImpl.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/avalon/src/java/org/apache/commons/jelly/avalo0000664000175000017500000002005111602216727031457 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.avalon; import java.util.Map; import java.util.HashMap; import java.util.Iterator; import java.net.URL; import java.net.MalformedURLException; import java.io.File; import java.io.InputStream; import java.io.OutputStream; // Avalon import org.apache.avalon.framework.configuration.Configurable; import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.configuration.ConfigurationException; // Jelly import org.apache.commons.jelly.Jelly; import org.apache.commons.jelly.JellyContext; import org.apache.commons.jelly.JellyException; import org.apache.commons.jelly.Script; import org.apache.commons.jelly.XMLOutput; /** * An Avalon based service for executing Jelly scripts. The * service allows executing a script based on a name as well * as by a URL. * * @author Robert McIntosh * @version $Revision: 155420 $ */ public class JellyServiceImpl implements JellyService, Configurable { private boolean m_configured = false; private Map m_scripts = new HashMap(); /** * Constructor for JellyService. */ public JellyServiceImpl() { super(); } /** * @see org.apache.commons.jelly.avalon.JellyService.runNamedScript(String, Map) */ public Map runNamedScript( String name, Map params ) throws Exception { return runNamedScript(name, params, createXMLOutput()); } /** * @see org.apache.commons.jelly.avalon.JellyService.runNamedScript(String, Map, XMLOutput) */ public Map runNamedScript( String name, Map params, XMLOutput output ) throws Exception { if( !m_scripts.containsKey( name ) ) throw new JellyException( "No script exists for script name [" + name + "]" ); Script script = (Script)m_scripts.get( name ); JellyContext context = createJellyContext(); context.setVariables( params ); script.run( context, output ); return context.getVariables(); } /** * @see org.apache.commons.jelly.avalon.JellyService.runNamedScript(String, Map, OutputStream) */ public Map runNamedScript( String name, Map params, OutputStream out ) throws Exception { XMLOutput xmlOutput = XMLOutput.createXMLOutput( out ); Map answer = runNamedScript(name, params, xmlOutput); xmlOutput.flush(); return answer; } /** * @see org.apache.commons.jelly.avalon.JellyService.runScript(String, Map, XMLOutput) */ public Map runScript( String url, Map params, XMLOutput output ) throws Exception { URL actualUrl = null; try { actualUrl = new URL( url ); } catch( MalformedURLException x ) { throw new JellyException( "Could not find script at URL [" + url + "]: " + x.getMessage(), x ); } // Set up the context JellyContext context = createJellyContext(); context.setVariables( params ); // Run the script context.runScript(url, output); return context.getVariables(); } /** * @see org.apache.commons.jelly.avalon.JellyService.runScript(String, Map, OutputStream) */ public Map runScript( String url, Map params, OutputStream out ) throws Exception { XMLOutput xmlOutput = XMLOutput.createXMLOutput( out ); Map answer = runScript(url, params, xmlOutput); xmlOutput.flush(); return answer; } /** * @see org.apache.commons.jelly.avalon.JellyService.runScript(String, Map) */ public Map runScript( String url, Map params ) throws Exception { return runScript(url, params, createXMLOutput()); } // Configurable interface //------------------------------------------------------------------------- /** *

Configures the Jelly Service with named scripts.

* *

* The configuration looks like: *

*

* <jelly>
*   <script>
*     <name>script name</name>
*     <url validate="false">url to script file</url>
*   </script>
* </jelly>
*

*

* Where each <script> element defines a seperate script. The validate attribute * on the url tag is optional and defaults to false. *

* * @param config The configuration * @exception ConfigurationException */ public void configure( Configuration config ) throws ConfigurationException { if( m_configured ) throw new ConfigurationException( "configure may only be executed once" ); if( !"jelly".equals( config.getName() ) ) throw new ConfigurationException( "Expected but got " + config.getName() ); // Configure named scripts Configuration[] scripts = config.getChildren( "scripts" ); for (int i = 0; i < scripts.length; i++) { String name = config.getChild( "name" ).getValue(); // Try to load and compile the script try { String scriptName = config.getChild( "url" ).getValue(); // Try to load the script via file, then by URL, then by classloader URL url = null; File file = new File( scriptName ); if( file.exists() ) { url = file.toURL(); } else { try { url = new URL( scriptName ); } catch( MalformedURLException mfue ) { // Last try, via classloader url = getClass().getResource( scriptName ); } } // All atempts failed... if( url == null ) throw new ConfigurationException( "Could not find script [" + scriptName + "]" ); // Get the script and store it Jelly jelly = new Jelly(); jelly.setUrl( url ); boolean validate = config.getChild( "url" ).getAttributeAsBoolean( "validate", false ); jelly.setValidateXML( validate ); Script script = jelly.compileScript(); m_scripts.put( name, script ); } catch( Throwable t ) { throw new ConfigurationException( "Could not load script [" + name + "]: " + t.getMessage() ); } } } // Implementation methods //------------------------------------------------------------------------- /** * Factory method to create a new JellyContext instance. Derived classes * could overload this method to provide a custom JellyContext instance. */ protected JellyContext createJellyContext() { return new JellyContext(); } /** * Factory method to create a new XMLOutput to give to scripts as they run. * Derived classes could overload this method, such as to pipe output to * some log file etc. */ protected XMLOutput createXMLOutput() { // output will just be ignored return new XMLOutput(); } } jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/avalon/xdocs/0000775000175000017500000000000011602216727023242 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/avalon/xdocs/index.xml0000664000175000017500000000170611602216727025077 0ustar davedave Avalon Integration dIon Gillard

This provides an Avalon Service for executing Jelly scripts.

jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/avalon/xdocs/changes.xml0000664000175000017500000000173311602216727025400 0ustar davedave Changes dIon Gillard Initial release jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/avalon/xdocs/navigation.xml0000664000175000017500000000157611602216727026134 0ustar davedave Avalon Integration jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/avalon/maven.xml0000664000175000017500000000211411602216727023750 0ustar davedave jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/velocity/0000775000175000017500000000000011602216727022500 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/velocity/project.properties0000664000175000017500000000143411602216727026266 0ustar davedave # Copyright 2002-2004 The Apache Software Foundation # # 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. # ------------------------------------------------------------------- # P R O J E C T P R O P E R T I E S # ------------------------------------------------------------------- jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/velocity/project.xml0000664000175000017500000000325611602216727024676 0ustar davedave ${basedir}/../tag-project.xml commons-jelly-tags-velocity commons-jelly-tags-velocity 1.0.1-SNAPSHOT org.apache.commons.jelly.tags.velocity This is a Jelly interface for Velocity. Commons Jelly Velocity Tag Library 1.0 1.0 COMMONS_JELLY_VELOCITY-1_0 velocity velocity 1.3 http://jakarta.apache.org/velocity/ jakarta-velocity velocity jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/velocity/build.xml0000664000175000017500000001755711602216727024340 0ustar davedave jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/velocity/src/0000775000175000017500000000000011602216727023267 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/velocity/src/test/0000775000175000017500000000000011602216727024246 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/velocity/src/test/org/0000775000175000017500000000000011602216727025035 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/velocity/src/test/org/apache/0000775000175000017500000000000011602216727026256 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/velocity/src/test/org/apache/commons/0000775000175000017500000000000011602216727027731 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/velocity/src/test/org/apache/commons/jelly/0000775000175000017500000000000011602216727031050 5ustar davedave././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/velocity/src/test/org/apache/commons/jelly/tags/jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/velocity/src/test/org/apache/commons/jelly/tag0000775000175000017500000000000011602216727031544 5ustar davedave././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/velocity/src/test/org/apache/commons/jelly/tags/velocity/jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/velocity/src/test/org/apache/commons/jelly/tag0000775000175000017500000000000011602216727031544 5ustar davedave././@LongLink0000000000000000000000000000021400000000000011562 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/velocity/src/test/org/apache/commons/jelly/tags/velocity/JellyContextAdapterTest.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/velocity/src/test/org/apache/commons/jelly/tag0000664000175000017500000002176311602216727031557 0ustar davedavepackage org.apache.commons.jelly.tags.velocity; /* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ import java.util.Set; import java.util.HashSet; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.apache.commons.jelly.JellyContext; import org.apache.commons.collections.CollectionUtils; /** * Unit test for JellyContextAdapter. * * @author Pete Kazmier * @version $Id: JellyContextAdapterTest.java 155420 2005-02-26 13:06:03Z dirkv $ */ public class JellyContextAdapterTest extends TestCase { JellyContext jellyContext; JellyContextAdapter adapter; /** * Create the test case * * @param testName name of the test case */ public JellyContextAdapterTest( String testName ) { super( testName ); } /** * @return the suite of tests being tested */ public static Test suite() { return new TestSuite( JellyContextAdapterTest.class ); } public void setUp() { jellyContext = new JellyContext(); adapter = new JellyContextAdapter( jellyContext ); } /** * Test the behavior of null keys. */ public void testNullKey() { adapter.setReadOnly( false ); adapter.put( null, new Object() ); assertTrue( adapter.get( null ) == null ); } /** * Test the behavior of null values. */ public void testNullValue() { adapter.setReadOnly( false ); adapter.put( "key", null ); assertTrue( adapter.get( "key" ) == null ); } /** * Test that items can be added and retrieved from a read-write * adpater. Also verify the key/value pair was actually inserted * into the JellyContext. */ public void testReadWritePut() { Object value = new Object(); adapter.setReadOnly( false ); adapter.put( "key", value ); assertTrue( "adapter: did not return the original value", adapter.get( "key" ) == value ); assertTrue( "jellyContext: did not return the original value", jellyContext.getVariable( "key" ) == value ); } /** * Test that items can be added and retrieved from a read-only * adapter. Also verify the key/value pair was not inserted into * the JellyContext. */ public void testReadOnlyPut() { Object value = new Object(); adapter.setReadOnly( true ); adapter.put( "key", value ); assertTrue( "adapter: did not return the original value", adapter.get( "key" ) == value ); assertTrue( "jellyContext: must return null when adapter is readonly", jellyContext.getVariable( "key" ) == null ); } /** * Test that items can be removed from a read-write context. Also * verify that the item is removed from the JellyContext. */ public void testReadWriteRemove() { Object value = new Object(); adapter.setReadOnly( false ); adapter.put( "key", value ); Object oldValue = adapter.remove( "key" ); assertTrue( "Value returned from remove() is not the original", value == oldValue ); assertTrue( "adapter: after removal of key, value should be null", adapter.get( "key" ) == null ); assertTrue( "jellyContext: after removal of key, value should be null", jellyContext.getVariable( "key" ) == null ); assertTrue( "Removal of non-existent key should return null", adapter.remove( "non-existent key" ) == null ); } /** * Test that items can be removed from a read-only context. Also * verify that the JellyContext is not impacted by removal of keys. */ public void testReadOnlyRemove() { Object value = new Object(); adapter.setReadOnly( true ); adapter.put( "key", value ); Object oldValue = adapter.remove( "key" ); assertTrue( "Value returned from remove() is not the original", value == oldValue ); assertTrue( "adapter: after removal of key, value should be null", adapter.get( "key" ) == null ); assertTrue( "jellyContext: value should not be affected.", jellyContext.getVariable( "key" ) == null ); assertTrue( "Removal of non-existent key should return null", adapter.remove( "non-existent key" ) == null ); } /** * Test that items can shadow or hide items in the JellyContext. * Removal of a key in the private context will unveil the key in * the JellyContext if it exists. */ public void testReadOnlyShadowingRemove() { Object value1 = new Object(); Object value2 = new Object(); adapter.setReadOnly( true ); adapter.put( "key", value1 ); jellyContext.setVariable( "key", value2 ); assertTrue( "adapter: before removal of key, value should be 1", adapter.get( "key" ) == value1 ); adapter.remove( "key" ); assertTrue( "adapter: after removal of key, value should be 2", adapter.get( "key" ) == value2 ); assertTrue( "jellyContext: value should not be affected.", jellyContext.getVariable( "key" ) == value2 ); } /** * Test the containsKey method in a read-write adapter. */ public void testReadWriteContainsKey() { Object value1 = new Object(); Object value2 = new Object(); adapter.setReadOnly( false ); adapter.put( "key1", value1 ); jellyContext.setVariable( "key2", value2 ); assertTrue( "adapter: did not contain the key", adapter.containsKey( "key1" ) ); assertTrue( "adapter: should contain the key", adapter.containsKey( "key2" ) ); assertTrue( "jellyContext: did not contain the key", jellyContext.getVariable( "key1" ) != null ); } /** * Test the containsKey method in a read-only adapter. */ public void testReadOnlyContainsKey() { Object value1= new Object(); Object value2 = new Object(); adapter.setReadOnly( true ); adapter.put( "key1", value1 ); jellyContext.setVariable( "key2", value2 ); assertTrue( "adapter: did not contain the key", adapter.containsKey( "key1" ) ); assertTrue( "adapter: should not contain the key", adapter.containsKey( "key2" ) ); assertTrue( "jellyContext: should not contain the key", jellyContext.getVariable( "key1" ) == null ); } /** * Test the getKeys method of a read-write adapter. */ public void testReadWriteGetKeys() { Object value1 = new Object(); Object value2 = new Object(); Object value3 = new Object(); adapter.setReadOnly( false ); adapter.put( "key1", value1 ); adapter.put( "key2", value2 ); jellyContext.setVariable( "key3", value3 ); Set expectedKeys = new HashSet(); expectedKeys.add( "key1" ); expectedKeys.add( "key2" ); expectedKeys.add( "key3" ); Set actualKeys = new HashSet(); CollectionUtils.addAll(actualKeys, adapter.getKeys()); assertTrue( "adapter: does not contain the correct key set", actualKeys.containsAll( expectedKeys ) ); } /** * Test the getKeys method of a read-only adapter. */ public void testReadOnlyGetKeys() { Object value1 = new Object(); Object value2 = new Object(); Object value3 = new Object(); adapter.setReadOnly( true ); adapter.put( "key1", value1 ); adapter.put( "key2", value2 ); jellyContext.setVariable( "key3", value3 ); Set expectedKeys = new HashSet(); expectedKeys.add( "key1" ); expectedKeys.add( "key2" ); Set actualKeys = new HashSet(); CollectionUtils.addAll(actualKeys, adapter.getKeys()); assertTrue( "adapter: does not contain the correct key set", actualKeys.containsAll( expectedKeys ) ); } } jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/velocity/src/java/0000775000175000017500000000000011602216727024210 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/velocity/src/java/org/0000775000175000017500000000000011602216727024777 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/velocity/src/java/org/apache/0000775000175000017500000000000011602216727026220 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/velocity/src/java/org/apache/commons/0000775000175000017500000000000011602216727027673 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/velocity/src/java/org/apache/commons/jelly/0000775000175000017500000000000011602216727031012 5ustar davedave././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/velocity/src/java/org/apache/commons/jelly/tags/jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/velocity/src/java/org/apache/commons/jelly/tag0000775000175000017500000000000011602216727031506 5ustar davedave././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/velocity/src/java/org/apache/commons/jelly/tags/velocity/jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/velocity/src/java/org/apache/commons/jelly/tag0000775000175000017500000000000011602216727031506 5ustar davedave././@LongLink0000000000000000000000000000020700000000000011564 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/velocity/src/java/org/apache/commons/jelly/tags/velocity/VelocityTagLibrary.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/velocity/src/java/org/apache/commons/jelly/tag0000664000175000017500000000214311602216727031510 0ustar davedavepackage org.apache.commons.jelly.tags.velocity; /* * Copyright 2001,2004 The Apache Software Foundation. * * 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. */ import org.apache.commons.jelly.TagLibrary; /** * Describes the Taglib. This class could be generated by XDoclet * * @author Pete Kazmier * @version $Id: VelocityTagLibrary.java 155420 2005-02-26 13:06:03Z dirkv $ */ public class VelocityTagLibrary extends TagLibrary { public VelocityTagLibrary() { registerTag( "merge", MergeTag.class ); } } ././@LongLink0000000000000000000000000000021000000000000011556 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/velocity/src/java/org/apache/commons/jelly/tags/velocity/JellyContextAdapter.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/velocity/src/java/org/apache/commons/jelly/tag0000664000175000017500000001125511602216727031514 0ustar davedavepackage org.apache.commons.jelly.tags.velocity; /* * Copyright 2001,2004 The Apache Software Foundation. * * 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. */ import java.util.Set; import java.util.HashSet; import java.util.HashMap; import org.apache.commons.jelly.JellyContext; import org.apache.velocity.context.Context; /** * Adapts a JellyContext for use as a Velocity Context. This context * can be used in either read-only or read-write mode. When used as a * read-only adapter, items put or removeed from the * Velocity context are not permitted to propogate to the JellyContext, * which is the default behavior. The adapter can also be used in a * read-write mode. This permits changes made by Velocity to propogate * to the JellyContext. * * @author Pete Kazmier * @version $Id: JellyContextAdapter.java 155420 2005-02-26 13:06:03Z dirkv $ */ public class JellyContextAdapter implements Context { /** Flag to indicate read-only or read-write mode */ private boolean readOnly = true; /** The JellyContext being adapted */ private JellyContext jellyContext; /** The store for Velocity in the event the adpater is read-only */ private HashMap privateContext = new HashMap(); /** * Constructor. * * @param jellyContext The JellyContext to adapt */ public JellyContextAdapter( JellyContext jellyContext ) { this.jellyContext = jellyContext; } /** * Sets the read-only flag for this adapter. If the read-only flag * is set, changes to the Velocity Context will not be propogated to * the JellyContext. Turning the read-only flag off enables changes * to propogate. * * @param readOnly If this parameter is true, the adapter * becomes read-only. Setting the parameter to false the * adapter becomes read-write. */ public void setReadOnly(boolean readOnly) { this.readOnly = readOnly; } /** * Tests if the adapter is read-only. * * @return true if the adpater is read-only; otherwise * returns false. */ public boolean isReadOnly() { return readOnly; } public boolean containsKey( Object key ) { if ( key == null ) { return false; } if ( readOnly && privateContext.containsKey( key ) ) { return true; } return jellyContext.getVariable( key.toString() ) != null ? true : false; } public Object get( String key ) { if ( key == null ) { return null; } if ( readOnly && privateContext.containsKey( key ) ) { return privateContext.get( key ); } return jellyContext.getVariable( key ); } public Object[] getKeys() { Set keys = jellyContext.getVariables().keySet(); if ( readOnly ) { HashSet combinedKeys = new HashSet( keys ); combinedKeys.addAll( privateContext.keySet() ); keys = combinedKeys; } return keys.toArray(); } public Object put( String key, Object value ) { Object oldValue; if ( key == null || value == null ) { return null; } if ( readOnly ) { oldValue = privateContext.put( key, value ); } else { oldValue = jellyContext.getVariable( key ); jellyContext.setVariable( key, value ); } return oldValue; } public Object remove( Object key ) { Object oldValue; if ( key == null ) { return null; } if ( readOnly ) { oldValue = privateContext.remove( key ); } else { oldValue = jellyContext.getVariable( key.toString() ); jellyContext.removeVariable( key.toString() ); } return oldValue; } } ././@LongLink0000000000000000000000000000020700000000000011564 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/velocity/src/java/org/apache/commons/jelly/tags/velocity/VelocityTagSupport.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/velocity/src/java/org/apache/commons/jelly/tag0000664000175000017500000000611411602216727031512 0ustar davedavepackage org.apache.commons.jelly.tags.velocity; /* * Copyright 2001,2004 The Apache Software Foundation. * * 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. */ import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.TagSupport; import org.apache.velocity.app.VelocityEngine; /** * Support methods for the Velocity tag library. Currently this is only * used to get an instance of the VelocityEngine. For each unique base * directory specified, a new VelocityEngine instance is stored in the * context (as the author hasn't figured out how to change the resource * loader of an already init'd VelocityEngine). * * @author Pete Kazmier * @version $Id: VelocityTagSupport.java 155420 2005-02-26 13:06:03Z dirkv $ */ public abstract class VelocityTagSupport extends TagSupport { /** The VelocityEngine variable name in the JellyContext. */ public static final String VELOCITY_ENGINE_VAR_NAME = "org.apache.maven.jelly.tags.velocity.VelocityEngine"; /** * Gets or creates a VelocityEngine if one doesn't already exist for * the specified base directory. * * @return A VelocityEngine with a file resource loader configured * for the specified base directory. */ public VelocityEngine getVelocityEngine( String basedir ) throws JellyTagException { VelocityEngine ve = ( VelocityEngine ) getContext().getVariable( keyName( basedir ) ); if ( ve == null ) { ve = new VelocityEngine(); ve.setProperty( VelocityEngine.RUNTIME_LOG_LOGSYSTEM, this ); ve.setProperty( VelocityEngine.FILE_RESOURCE_LOADER_PATH, basedir ); try { ve.init(); } catch (Exception e) { throw new JellyTagException(e); } getContext().setVariable( keyName( basedir ), ve ); } return ve; } /** * Constructs the name of the key used to reference the * VelocityEngine for the specified base directory. * * @param basedir The base directory used by the VelocityEngine * @return The key used to reference the VelocityEngine that has * been initialized with the specified base directory. */ private String keyName( String basedir ) { return new StringBuffer() .append( VELOCITY_ENGINE_VAR_NAME ) .append( '.' ) .append( basedir ) .toString(); } } ././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/velocity/src/java/org/apache/commons/jelly/tags/velocity/MergeTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/velocity/src/java/org/apache/commons/jelly/tag0000664000175000017500000001442311602216727031514 0ustar davedavepackage org.apache.commons.jelly.tags.velocity; /* * Copyright 2001,2004 The Apache Software Foundation. * * 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. */ import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.XMLOutput; import org.apache.velocity.exception.MethodInvocationException; import org.apache.velocity.exception.ParseErrorException; import org.apache.velocity.exception.ResourceNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStreamWriter; import java.io.StringWriter; import java.io.Writer; /** * A tag that uses Velocity to render a specified template with the * JellyContext storing the results in either a variable in the * JellyContext or in a specified file. * * @author Pete Kazmier * @version $Id: MergeTag.java 155420 2005-02-26 13:06:03Z dirkv $ */ public class MergeTag extends VelocityTagSupport { private static final String ENCODING = "ISO-8859-1"; private String var; private String name; private String basedir; private String template; private String inputEncoding; private String outputEncoding; private boolean readOnly = true; // -- Tag interface ----------------------------------------------------- public void doTag( final XMLOutput output ) throws JellyTagException { if ( basedir == null || template == null ) { throw new JellyTagException( "This tag must define 'basedir' and 'template'" ); } if ( name != null ) { try { Writer writer = new OutputStreamWriter( new FileOutputStream( name ), outputEncoding == null ? ENCODING : outputEncoding ); mergeTemplate( writer ); writer.close(); } catch (IOException e) { throw new JellyTagException(e); } } else if ( var != null ) { StringWriter writer = new StringWriter(); mergeTemplate( writer ); context.setVariable( var, writer.toString() ); } else { throw new JellyTagException( "This tag must define either 'name' or 'var'" ); } } // -- Properties -------------------------------------------------------- /** * Sets the var used to store the results of the merge. * * @param var The var to set in the JellyContext with the results of * the merge. */ public void setVar( String var ) { this.var = var; } /** * Sets the file name for the merged output. * * @param name The name of the output file that is used to store the * results of the merge. */ public void setName( String name ) { this.name = name; } /** * Sets the base directory used for loading of templates by the * Velocity file resource loader. * * @param basedir The directory where templates can be located by * the Velocity file resource loader. */ public void setBasedir( String basedir ) { this.basedir = basedir; } /** * Sets the filename of the template used to merge with the * JellyContext. * * @param template The filename of the template to be merged. */ public void setTemplate( String template ) { this.template = template; } /** * Sets the read-only flag for this adapter which prevents * modifications in the Velocity context from propogating to the * JellyContext. * * @param readOnly true prevents modifications from * propogating (the default), or false which permits * modifications. */ public void setReadOnly( boolean readOnly ) { this.readOnly = readOnly; } /** * Sets the output encoding mode which defaults to ISO-8859-1 used * when storing the results of a merge in a file. * * @param encoding The file encoding to use when writing the * output. */ public void setOutputEncoding( String encoding ) { this.outputEncoding = encoding; } /** * Sets the input encoding used in the specified template which * defaults to ISO-8859-1. * * @param encoding The encoding used in the template. */ public void setInputEncoding( String encoding ) { this.inputEncoding = encoding; } // -- Implementation ---------------------------------------------------- /** * Merges the Velocity template with the Jelly context. * * @param writer The output writer used to write the merged results. * @throws Exception If an exception occurs during the merge. */ private void mergeTemplate( Writer writer ) throws JellyTagException { JellyContextAdapter adapter = new JellyContextAdapter( getContext() ); adapter.setReadOnly( readOnly ); try { getVelocityEngine( basedir ).mergeTemplate( template, inputEncoding == null ? ENCODING : inputEncoding, adapter, writer ); } catch (ResourceNotFoundException e) { throw new JellyTagException(e); } catch (ParseErrorException e) { throw new JellyTagException(e); } catch (MethodInvocationException e) { throw new JellyTagException(e); } catch (Exception e) { throw new JellyTagException(e); } } } jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/velocity/xdocs/0000775000175000017500000000000011602216727023620 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/velocity/xdocs/index.xml0000664000175000017500000000202011602216727025443 0ustar davedave Velocity Tag Library dIon Gillard

A library for processing Velocity templates from within Jelly. See the tags for more information.

jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/velocity/xdocs/changes.xml0000664000175000017500000000173311602216727025756 0ustar davedave Changes dIon Gillard Initial Release jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/velocity/xdocs/navigation.xml0000664000175000017500000000170411602216727026503 0ustar davedave Velocity Tag Library jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/velocity/maven.xml0000664000175000017500000000130011602216727024322 0ustar davedave jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/beanshell/0000775000175000017500000000000011602216727022577 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/beanshell/project.properties0000664000175000017500000000144511602216727026367 0ustar davedave# # Copyright 2002,2004 The Apache Software Foundation. # # 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. # # ------------------------------------------------------------------- # P R O J E C T P R O P E R T I E S # ------------------------------------------------------------------- jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/beanshell/project.xml0000664000175000017500000000353111602216727024771 0ustar davedave ${basedir}/../tag-project.xml commons-jelly-tags-beanshell commons-jelly-tags-beanshell 1.0.1-SNAPSHOT org.apache.commons.jelly.tags.beanshell This is a Jelly interface for BeanShell. Commons Jelly BeanShell Tag Library 1.0 1.0 COMMONS_JELLY_BEANSHELL-1_0 bsh bsh 2.0b1 commons-jelly commons-jelly-tags-junit 1.0 http://jakarta.apache.org/commons/jelly/libs/junit/ test jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/beanshell/build.xml0000664000175000017500000004257611602216727024436 0ustar davedave ================================= WARNING ================================ Junit isn't present in your ${ANT_HOME}/lib directory. Tests not executed. ========================================================================== Proxy used : Proxy host [${proxy.host}] Proxy port [${proxy.port}] Proxy user [${proxy.username}] Proxy not used. jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/beanshell/src/0000775000175000017500000000000011602216727023366 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/beanshell/src/test/0000775000175000017500000000000011602216727024345 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/beanshell/src/test/org/0000775000175000017500000000000011602216727025134 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/beanshell/src/test/org/apache/0000775000175000017500000000000011602216727026355 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/beanshell/src/test/org/apache/commons/0000775000175000017500000000000011602216727030030 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/beanshell/src/test/org/apache/commons/jelly/0000775000175000017500000000000011602216727031147 5ustar davedave././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/beanshell/src/test/org/apache/commons/jelly/tags/jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/beanshell/src/test/org/apache/commons/jelly/ta0000775000175000017500000000000011602216727031474 5ustar davedave././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/beanshell/src/test/org/apache/commons/jelly/tags/beanshell/jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/beanshell/src/test/org/apache/commons/jelly/ta0000775000175000017500000000000011602216727031474 5ustar davedave././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/beanshell/src/test/org/apache/commons/jelly/tags/beanshell/TestJelly.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/beanshell/src/test/org/apache/commons/jelly/ta0000664000175000017500000000242411602216727031500 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.beanshell; import junit.framework.TestSuite; import junit.textui.TestRunner; import org.apache.commons.jelly.tags.junit.JellyTestSuite; /** * A helper class to run jelly test cases as part of Ant's JUnit tests * * @author James Strachan * @version $Revision: 155420 $ */ public class TestJelly extends JellyTestSuite { public static void main( String[] args ) throws Exception { TestRunner.run( suite() ); } public static TestSuite suite() throws Exception { return createTestSuite(TestJelly.class, "suite.jelly"); } } ././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/beanshell/src/test/org/apache/commons/jelly/tags/beanshell/suite.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/beanshell/src/test/org/apache/commons/jelly/ta0000664000175000017500000000324011602216727031475 0ustar davedave System.out.println( "foo.bar: " + context.getVariable("foo.bar") ); if (context.getVariable("foo.bar") == null) { throw new Exception("Failed: no foo.bar defined: " + foo_bar); } context.setVariable("foo.bar", "worked"); System.out.println( "foo.bar: " + foo_bar ); if (foo_bar == null) { throw new Exception("Failed: no foo.bar defined: " + foo_bar); } context.setVariable("foo.bar", "worked"); ././@LongLink0000000000000000000000000000020600000000000011563 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/beanshell/src/test/org/apache/commons/jelly/tags/beanshell/TestBeanShellEL.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/beanshell/src/test/org/apache/commons/jelly/ta0000664000175000017500000000563611602216727031510 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.beanshell; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import junit.textui.TestRunner; import org.apache.commons.jelly.JellyContext; import org.apache.commons.jelly.expression.Expression; import org.apache.commons.jelly.expression.ExpressionFactory; import org.apache.commons.jelly.tags.beanshell.BeanShellExpressionFactory; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** Tests the BeanShell EL * * @author James Strachan * @version $Revision: 155420 $ */ public class TestBeanShellEL extends TestCase { /** The Log to which logging calls will be made. */ private static final Log log = LogFactory.getLog( TestBeanShellEL.class ); /** Jelly context */ protected JellyContext context; /** The factory of Expression objects */ protected ExpressionFactory factory; public static void main( String[] args ) { TestRunner.run( suite() ); } public static Test suite() { return new TestSuite(TestBeanShellEL.class); } public TestBeanShellEL(String testName) { super(testName); } public void setUp() { context = new JellyContext(); context.setVariable( "foo", "abc" ); context.setVariable( "bar", new Integer( 123 ) ); factory = new BeanShellExpressionFactory(); } public void testEL() throws Exception { assertExpression( "foo", "abc" ); assertExpression( "bar * 2", new Integer( 246 ) ); assertExpression( "bar == 123", Boolean.TRUE ); assertExpression( "bar == 124", Boolean.FALSE ); assertExpression( "foo.equals( \"abc\" )", Boolean.TRUE ); assertExpression( "foo.equals( \"xyz\" )", Boolean.FALSE ); } /** Evaluates the given expression text and tests it against the expected value */ protected void assertExpression( String expressionText, Object expectedValue ) throws Exception { Expression expr = factory.createExpression( expressionText ); Object value = expr.evaluate( context ); assertEquals( "Value of expression: " + expressionText, expectedValue, value ); } } jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/beanshell/src/java/0000775000175000017500000000000011602216727024307 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/beanshell/src/java/org/0000775000175000017500000000000011602216727025076 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/beanshell/src/java/org/apache/0000775000175000017500000000000011602216727026317 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/beanshell/src/java/org/apache/commons/0000775000175000017500000000000011602216727027772 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/beanshell/src/java/org/apache/commons/jelly/0000775000175000017500000000000011602216727031111 5ustar davedave././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/beanshell/src/java/org/apache/commons/jelly/tags/jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/beanshell/src/java/org/apache/commons/jelly/ta0000775000175000017500000000000011602216727031436 5ustar davedave././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/beanshell/src/java/org/apache/commons/jelly/tags/beanshell/jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/beanshell/src/java/org/apache/commons/jelly/ta0000775000175000017500000000000011602216727031436 5ustar davedave././@LongLink0000000000000000000000000000021200000000000011560 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/beanshell/src/java/org/apache/commons/jelly/tags/beanshell/BeanShellTagLibrary.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/beanshell/src/java/org/apache/commons/jelly/ta0000664000175000017500000000260211602216727031440 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.beanshell; import org.apache.commons.jelly.expression.ExpressionFactory; import org.apache.commons.jelly.tags.core.CoreTagLibrary; /** Describes the Taglib. This class could be generated by XDoclet * * @author James Strachan * @version $Revision: 155420 $ */ public class BeanShellTagLibrary extends CoreTagLibrary { private ExpressionFactory expressionFactory = new BeanShellExpressionFactory(); public BeanShellTagLibrary() { registerTag("script", ScriptTag.class); } /** Allows derived tag libraries to use their own factory */ protected ExpressionFactory getExpressionFactory() { return expressionFactory; } } ././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/beanshell/src/java/org/apache/commons/jelly/tags/beanshell/package.htmljenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/beanshell/src/java/org/apache/commons/jelly/ta0000664000175000017500000000140511602216727031440 0ustar davedave

A tag library for working with BeanShell expressions and scripts within Jelly

././@LongLink0000000000000000000000000000022100000000000011560 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/beanshell/src/java/org/apache/commons/jelly/tags/beanshell/BeanShellExpressionFactory.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/beanshell/src/java/org/apache/commons/jelly/ta0000664000175000017500000000467611602216727031455 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.beanshell; import bsh.EvalError; import org.apache.commons.jelly.JellyContext; import org.apache.commons.jelly.JellyException; import org.apache.commons.jelly.expression.Expression; import org.apache.commons.jelly.expression.ExpressionFactory; /** Represents a factory of beanshell expressions * * @author James Strachan * @version $Revision: 155420 $ */ public class BeanShellExpressionFactory implements ExpressionFactory { /** * A helper method to return the JellyInterpreter for the given JellyContext */ public static JellyInterpreter getInterpreter(JellyContext context) throws EvalError { /** * @todo when we can unify the BeanShell and Jelly variable scopes we can share a single * BeanShell context for each JellyContext. * For now lets create a new one each time, which is slower. */ JellyInterpreter interpreter = new JellyInterpreter(); interpreter.setJellyContext(context); return interpreter; /* JellyInterpreter interpreter = (JellyInterpreter) context.getVariable( "org.apache.commons.jelly.beanshell.JellyInterpreter" ); if ( interpreter == null ) { interpreter = new JellyInterpreter(); interpreter.setJellyContext(context); context.setVariable( "org.apache.commons.jelly.beanshell.JellyInterpreter", interpreter ); } return interpreter; */ } // ExpressionFactory interface //------------------------------------------------------------------------- public Expression createExpression(String text) throws JellyException { return new BeanShellExpression(text); } } ././@LongLink0000000000000000000000000000021200000000000011560 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/beanshell/src/java/org/apache/commons/jelly/tags/beanshell/BeanShellExpression.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/beanshell/src/java/org/apache/commons/jelly/ta0000664000175000017500000000415511602216727031445 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.beanshell; import org.apache.commons.jelly.JellyContext; import org.apache.commons.jelly.expression.ExpressionSupport; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** Represents a beanshell expression * * @author James Strachan * @version $Revision: 155420 $ */ public class BeanShellExpression extends ExpressionSupport { /** The Log to which logging calls will be made. */ private static final Log log = LogFactory.getLog( BeanShellExpression.class ); /** The expression */ private String text; public BeanShellExpression(String text) { this.text = text; } // Expression interface //------------------------------------------------------------------------- public String getExpressionText() { return "${" + text + "}"; } public Object evaluate(JellyContext context) { try { JellyInterpreter interpreter = new JellyInterpreter(); interpreter.setJellyContext(context); if ( log.isDebugEnabled() ) { log.debug( "Evaluating beanshell: " + text ); } return interpreter.eval( text ); } catch (Exception e) { log.warn( "Caught exception evaluating: " + text + ". Reason: " + e, e ); return null; } } } ././@LongLink0000000000000000000000000000020700000000000011564 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/beanshell/src/java/org/apache/commons/jelly/tags/beanshell/JellyInterpreter.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/beanshell/src/java/org/apache/commons/jelly/ta0000664000175000017500000000526311602216727031446 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.beanshell; import bsh.EvalError; import bsh.Interpreter; import java.util.Iterator; import org.apache.commons.jelly.JellyContext; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** Integrates BeanShell's interpreter with Jelly's JellyContext * * @author James Strachan * @version $Revision: 155420 $ */ public class JellyInterpreter extends Interpreter { /** The Log to which logging calls will be made. */ private static final Log log = LogFactory.getLog( JellyInterpreter.class ); private JellyContext context; public JellyInterpreter() { } public JellyContext getJellyContext() { return context; } public void setJellyContext(JellyContext context) throws EvalError { this.context = context; // now pass in all the variables for ( Iterator iter = context.getVariableNames(); iter.hasNext(); ) { String name = (String) iter.next(); Object value = context.getVariable(name); name = convertVariableName(name); if (name != null) { set( name, value ); } } // lets pass in the Jelly context set( "context", context ); } /* // the following code doesn't work - it seems that // all variables must be passed into the Interpreter // via set() method public Object get(String name) throws EvalError { if ( context != null ) { Object answer = context.getVariable( name ); if ( answer != null ) { return answer; } } return super.get( name ); } */ /** * Converts variables to a beanshell allowable format or hides names that * can't be converted, by returning null. * For now lets just turn '.' into '_' */ protected String convertVariableName(String name) { return name.replace('.', '_'); } } ././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/beanshell/src/java/org/apache/commons/jelly/tags/beanshell/ScriptTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/beanshell/src/java/org/apache/commons/jelly/ta0000664000175000017500000000341111602216727031437 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.beanshell; import bsh.EvalError; import org.apache.commons.jelly.JellyTagException; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.XMLOutput; /** * A tag which invokes a BeanShell script.. * * @author Jason Horman * @author James Strachan * @version $Revision: 155420 $ */ public class ScriptTag extends TagSupport { public ScriptTag() { } // Tag interface //------------------------------------------------------------------------- public void doTag(XMLOutput output) throws JellyTagException { try { JellyInterpreter interpreter = BeanShellExpressionFactory.getInterpreter(context); // @todo it'd be really nice to create a JellyNameSpace to pass into // this method so that any variables declared by beanshell could be exported // into the JellyContext String text = getBodyText(false); interpreter.eval(text); } catch (EvalError e) { throw new JellyTagException(e); } } } jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/beanshell/xdocs/0000775000175000017500000000000011602216727023717 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/beanshell/xdocs/index.xml0000664000175000017500000000203711602216727025552 0ustar davedave BeanShell Tag Library dIon Gillard

A tag library for working with BeanShell expressions and scripts within Jelly. See the tags for more information.

jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/beanshell/xdocs/changes.xml0000664000175000017500000000214711602216727026055 0ustar davedave Changes dIon Gillard Upgrade to bsh 2.0b1 Initial Release jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/beanshell/xdocs/navigation.xml0000664000175000017500000000170711602216727026605 0ustar davedave BeanShell Tag Library jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/beanshell/maven.xml0000664000175000017500000000124011602216727024424 0ustar davedave jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/regexp/0000775000175000017500000000000011602216727022134 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/regexp/project.properties0000664000175000017500000000143211602216727025720 0ustar davedave# Copyright 2002-2004 The Apache Software Foundation # # 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. # ------------------------------------------------------------------- # P R O J E C T P R O P E R T I E S # ------------------------------------------------------------------- jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/regexp/project.xml0000664000175000017500000000274511602216727024334 0ustar davedave ${basedir}/../tag-project.xml commons-jelly-tags-regexp commons-jelly-tags-regexp 1.0.1-SNAPSHOT org.apache.commons.jelly.tags.regexp This is a Jelly interface for ORO. Commons Jelly Regular Expression Tag Library 1.0 1.0 COMMONS-JELLY-REGEXP-1_0 oro oro 2.0.8 jakarta-oro jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/regexp/src/0000775000175000017500000000000011602216727022723 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/regexp/src/test/0000775000175000017500000000000011602216727023702 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/regexp/src/test/org/0000775000175000017500000000000011602216727024471 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/regexp/src/test/org/apache/0000775000175000017500000000000011602216727025712 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/regexp/src/test/org/apache/commons/0000775000175000017500000000000011602216727027365 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/regexp/src/test/org/apache/commons/jelly/0000775000175000017500000000000011602216727030504 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/regexp/src/test/org/apache/commons/jelly/tags/0000775000175000017500000000000011602216727031442 5ustar davedave././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/regexp/src/test/org/apache/commons/jelly/tags/regexp/jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/regexp/src/test/org/apache/commons/jelly/tags/0000775000175000017500000000000011602216727031442 5ustar davedave././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/regexp/src/test/org/apache/commons/jelly/tags/regexp/MatchTagTest.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/regexp/src/test/org/apache/commons/jelly/tags/0000664000175000017500000000332011602216727031442 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.regexp; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.jelly.JellyContext; import junit.framework.TestCase; import org.apache.commons.jelly.tags.regexp.MatchTag; /***

MatchTagTest a class that is useful to perform regexp matches * in strings.

* * @author Christian Amor Kvalheim * @version $Revision: 155420 $ */ public class MatchTagTest extends TestCase { public MatchTagTest(String name) { super(name); } public void setUp() throws Exception { } public void testDoTag() throws Exception { MatchTag matchExpTag = new MatchTag(); XMLOutput xmlOutput = new XMLOutput(); matchExpTag.setText("ID1234"); matchExpTag.setExpr("[A-Z][A-Z][0-9]{4}"); matchExpTag.setVar("testvar"); matchExpTag.setContext(new JellyContext()); matchExpTag.doTag(xmlOutput); assertEquals("TRUE", matchExpTag.getContext().getVariable("testvar").toString().toUpperCase()); } public void tearDown() { } }././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/regexp/src/test/org/apache/commons/jelly/tags/regexp/ContainsTagTest.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/regexp/src/test/org/apache/commons/jelly/tags/0000664000175000017500000000343511602216727031451 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.regexp; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.jelly.JellyContext; import junit.framework.TestCase; import org.apache.commons.jelly.tags.regexp.ContainsTag; /***

ContainsTagTest a class that is useful to perform regexp matches * in strings.

* * @author Christian Amor Kvalheim * @version $Revision: 155420 $ */ public class ContainsTagTest extends TestCase { public ContainsTagTest(String name) { super(name); } public void setUp() throws Exception { } public void testDoTag() throws Exception { ContainsTag containsExpTag = new ContainsTag(); XMLOutput xmlOutput = new XMLOutput(); containsExpTag.setText("Hello World"); containsExpTag.setExpr("World"); containsExpTag.setVar("testvar"); containsExpTag.setContext(new JellyContext()); containsExpTag.doTag(xmlOutput); assertEquals("TRUE", containsExpTag.getContext().getVariable("testvar").toString().toUpperCase()); } public void tearDown() { } } jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/regexp/src/java/0000775000175000017500000000000011602216727023644 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/regexp/src/java/org/0000775000175000017500000000000011602216727024433 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/regexp/src/java/org/apache/0000775000175000017500000000000011602216727025654 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/regexp/src/java/org/apache/commons/0000775000175000017500000000000011602216727027327 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/regexp/src/java/org/apache/commons/jelly/0000775000175000017500000000000011602216727030446 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/regexp/src/java/org/apache/commons/jelly/tags/0000775000175000017500000000000011602216727031404 5ustar davedave././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/regexp/src/java/org/apache/commons/jelly/tags/regexp/jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/regexp/src/java/org/apache/commons/jelly/tags/0000775000175000017500000000000011602216727031404 5ustar davedave././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/regexp/src/java/org/apache/commons/jelly/tags/regexp/RegexpTagLibrary.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/regexp/src/java/org/apache/commons/jelly/tags/0000664000175000017500000000210111602216727031400 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.regexp; import org.apache.commons.jelly.TagLibrary; /** Implements regexp tags. * * @author Christian Amor Kvalheim * @version $Revision: 155420 $ */ public class RegexpTagLibrary extends TagLibrary { public RegexpTagLibrary() { registerTag("match", MatchTag.class); registerTag("contains", ContainsTag.class); } }././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/regexp/src/java/org/apache/commons/jelly/tags/regexp/MatchTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/regexp/src/java/org/apache/commons/jelly/tags/0000664000175000017500000000200111602216727031377 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.regexp; /** * This tag checks whether a regexp matches a string. * * @author Christian Amor Kvalheim * @version $Revision: 155420 $ */ public class MatchTag extends RegexpTag { protected boolean getResult() { return getPatternMatcher().matches(getText(), getPattern()); } }././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/regexp/src/java/org/apache/commons/jelly/tags/regexp/ContainsTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/regexp/src/java/org/apache/commons/jelly/tags/0000664000175000017500000000201211602216727031401 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.regexp; /** * This tag checks whether a regexp contains a string. * * @author Christian Amor Kvalheim * @version $Revision: 155420 $ */ public class ContainsTag extends RegexpTag { protected boolean getResult() { return getPatternMatcher().contains(getText(), getPattern()); } } ././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/regexp/src/java/org/apache/commons/jelly/tags/regexp/RegexpTag.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/regexp/src/java/org/apache/commons/jelly/tags/0000664000175000017500000000675311602216727031421 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.regexp; import org.apache.commons.jelly.TagSupport; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.jelly.MissingAttributeException; import org.apache.commons.jelly.JellyTagException; import org.apache.oro.text.regex.Perl5Matcher; import org.apache.oro.text.regex.Perl5Compiler; import org.apache.oro.text.regex.Pattern; import org.apache.oro.text.regex.MalformedPatternException; /** * Base class for tags using the Oro Regexp library. * * @author Christian Amor Kvalheim * @version $Revision: 155420 $ */ public abstract class RegexpTag extends TagSupport { private Perl5Matcher patternMatcher = new Perl5Matcher(); private Pattern pattern; private String var; private String text; private String scope; protected final String getText() { return text; } protected final Pattern getPattern() { return pattern; } protected final Perl5Matcher getPatternMatcher() { return patternMatcher; } public final void setExpr(String expr) throws MalformedPatternException { Perl5Compiler patternCompiler = new Perl5Compiler(); pattern = patternCompiler.compile(expr); } public final void setText(String text) { this.text = text; } // Sets the variable name to define for this expression public final void setVar(String var) { this.var = var; } /** * Sets the variable scope for this variable. For example setting this value to 'parent' will * set this value in the parent scope. When Jelly is run from inside a Servlet environment * then other scopes will be available such as 'request', 'session' or 'application'. * * Other applications may implement their own custom scopes. */ public final void setScope(String scope) { this.scope = scope; } public void doTag(XMLOutput output) throws MissingAttributeException, JellyTagException { // Check required properties if (getText() == null || getText().length() == 0) throw new MissingAttributeException("text must be provided"); if (pattern == null) throw new MissingAttributeException("expr must be provided"); if (var == null || var.length() == 0) throw new MissingAttributeException("var must be provided"); // Evaluate pattern against text string boolean result = getResult(); String resultString = result ? "true" : "false"; if (var != null) { if (scope != null) { context.setVariable(var, scope, resultString); } else { context.setVariable(var, resultString); } } } protected abstract boolean getResult(); } jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/regexp/xdocs/0000775000175000017500000000000011602216727023254 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/regexp/xdocs/index.xml0000664000175000017500000000175711602216727025117 0ustar davedave Regexp Tag Library dIon Gillard

Tags for working with regular expressions. See the tags for more information.

jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/regexp/xdocs/changes.xml0000664000175000017500000000177711602216727025422 0ustar davedave Changes dIon Gillard Added jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/regexp/xdocs/navigation.xml0000664000175000017500000000167611602216727026147 0ustar davedave Regexp Tag Library jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jface/0000775000175000017500000000000011602216727021712 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jface/project.properties0000664000175000017500000000144511602216727025502 0ustar davedave# # Copyright 2002,2004 The Apache Software Foundation. # # 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. # # ------------------------------------------------------------------- # P R O J E C T P R O P E R T I E S # ------------------------------------------------------------------- jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jface/project.xml0000664000175000017500000000630111602216727024102 0ustar davedave ${basedir}/../tag-project.xml commons-jelly-tags-jface commons-jelly-tags-jface 1.0.1-SNAPSHOT org.apache.commons.jelly.tags.jface This is a Jelly interface for jface. Commons Jelly jface Tag Library 1.0 1.0 COMMONS-JELLY-JFACE-1_0 commons-jelly commons-jelly-tags-swt 1.0 swt swt win32-2.1.0 eclipse swt eclipse eclipse-boot 2.1.0 eclipse boot eclipse eclipse-jface 2.1.0 eclipse jface eclipse eclipse-runtime 2.1.0 eclipse runtime commons-cli commons-cli 1.0 commons-jelly commons-jelly-tags-log 1.0 commons-jelly commons-jelly-tags-define 1.0 jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jface/src/0000775000175000017500000000000011602216727022501 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jface/src/test/0000775000175000017500000000000011602216727023460 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jface/src/test/org/0000775000175000017500000000000011602216727024247 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jface/src/test/org/apache/0000775000175000017500000000000011602216727025470 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jface/src/test/org/apache/commons/0000775000175000017500000000000011602216727027143 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jface/src/test/org/apache/commons/jelly/0000775000175000017500000000000011602216727030262 5ustar davedavejenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jface/src/test/org/apache/commons/jelly/tags/0000775000175000017500000000000011602216727031220 5ustar davedave././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jface/src/test/org/apache/commons/jelly/tags/jface/jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jface/src/test/org/apache/commons/jelly/tags/j0000775000175000017500000000000011602216727031372 5ustar davedave././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jface/src/test/org/apache/commons/jelly/tags/jface/JFaceDemo.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jface/src/test/org/apache/commons/jelly/tags/j0000664000175000017500000000340311602216727031374 0ustar davedave Very Nice !!! I've been checked ${mainapp.setStatus('Hello ...')} ${mainapp.MenuBarManager.updateAll(true)} ${mainapp.getShell().pack()} ${mainapp.open()} ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jface/src/test/org/apache/commons/jelly/tags/jface/JFaceDemo.javajenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jface/src/test/org/apache/commons/jelly/tags/j0000664000175000017500000000306411602216727031377 0ustar davedave/* * Copyright 2002,2004 The Apache Software Foundation. * * 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. */ package org.apache.commons.jelly.tags.jface; import java.net.URL; import org.apache.commons.jelly.JellyContext; import org.apache.commons.jelly.XMLOutput; import org.apache.commons.jelly.tags.jface.JFaceTagLibrary; /** * @author Christiaan ten Klooster */ public class JFaceDemo { public static void main(String[] args) { try { JellyContext context = new JellyContext(); /** @todo zap the following line once the Jelly core has this default */ context.registerTagLibrary("jelly:jface", new JFaceTagLibrary()); URL url = JFaceDemo.class.getResource("JFaceDemo.jelly"); XMLOutput output = XMLOutput.createXMLOutput(System.out, true); context.runScript( url, output ); output.flush(); } catch (Exception e) { e.printStackTrace(); } } } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jface/src/test/org/apache/commons/jelly/tags/jface/wizard/jenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jface/src/test/org/apache/commons/jelly/tags/j0000775000175000017500000000000011602216727031372 5ustar davedave././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jface/src/test/org/apache/commons/jelly/tags/jface/wizard/WizardDemo.jellyjenkins-commons-jelly-1.1-jenkins-20110627/jelly-tags/jface/src/test/org/apache/commons/jelly/tags/j0000664000175000017500000000571011602216727031377 0ustar davedave onPerformFinish called ... onPerformCancel called ...