cziegeler 2003/08/21 05:44:18
Added: src/scratchpad/lib cornerstone-scheduler-api-20030821.jar cornerstone-threads-impl-20030821.jar excalibur-thread-1.1.1.jar cornerstone-scheduler-impl-20030821.jar cornerstone-threads-api-20030821.jar src/scratchpad/src/org/apache/cocoon/components/scheduler TestTarget.java DefaultTimeScheduler.java Scheduler.java readme.txt DefaultScheduler.java DefaultThreadManager.java SchedulerAction.java ConfigurableTarget.java Log: Simple configurable scheduler Revision Changes Path 1.1 cocoon-2.1/src/scratchpad/lib/cornerstone-scheduler-api-20030821.jar <<Binary file>> 1.1 cocoon-2.1/src/scratchpad/lib/cornerstone-threads-impl-20030821.jar <<Binary file>> 1.1 cocoon-2.1/src/scratchpad/lib/excalibur-thread-1.1.1.jar <<Binary file>> 1.1 cocoon-2.1/src/scratchpad/lib/cornerstone-scheduler-impl-20030821.jar <<Binary file>> 1.1 cocoon-2.1/src/scratchpad/lib/cornerstone-threads-api-20030821.jar <<Binary file>> 1.1 cocoon-2.1/src/scratchpad/src/org/apache/cocoon/components/scheduler/TestTarget.java Index: TestTarget.java =================================================================== /* ============================================================================ The Apache Software License, Version 1.1 ============================================================================ Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modifica- tion, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The end-user documentation included with the redistribution, if any, must include the following acknowledgment: "This product includes software developed by the Apache Software Foundation (http://www.apache.org/)." Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. 4. The names "Apache Cocoon" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact [EMAIL PROTECTED] 5. Products derived from this software may not be called "Apache", nor may "Apache" appear in their name, without prior written permission of the Apache Software Foundation. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. This software consists of voluntary contributions made by many individuals on behalf of the Apache Software Foundation and was originally created by Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache Software Foundation, please see <http://www.apache.org/>. */ package org.apache.cocoon.components.scheduler; import java.util.Date; import org.apache.avalon.cornerstone.services.scheduler.Target; import org.apache.avalon.framework.logger.AbstractLogEnabled; /** * A simple test target. * * @since 2.1.1 * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> * @version CVS $Id: TestTarget.java,v 1.1 2003/08/21 12:44:18 cziegeler Exp $ */ public class TestTarget extends AbstractLogEnabled implements Target { /* (non-Javadoc) * @see org.apache.avalon.cornerstone.services.scheduler.Target#targetTriggered(java.lang.String) */ public void targetTriggered(String name) { System.out.println("Target " + name + " triggered at " + new Date()); } } 1.1 cocoon-2.1/src/scratchpad/src/org/apache/cocoon/components/scheduler/DefaultTimeScheduler.java Index: DefaultTimeScheduler.java =================================================================== /* ============================================================================ The Apache Software License, Version 1.1 ============================================================================ Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modifica- tion, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The end-user documentation included with the redistribution, if any, must include the following acknowledgment: "This product includes software developed by the Apache Software Foundation (http://www.apache.org/)." Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. 4. The names "Apache Cocoon" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact [EMAIL PROTECTED] 5. Products derived from this software may not be called "Apache", nor may "Apache" appear in their name, without prior written permission of the Apache Software Foundation. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. This software consists of voluntary contributions made by many individuals on behalf of the Apache Software Foundation and was originally created by Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache Software Foundation, please see <http://www.apache.org/>. */ package org.apache.cocoon.components.scheduler; import org.apache.avalon.framework.component.Component; import org.apache.avalon.framework.thread.ThreadSafe; /** * This makes the Time Scheduler usuable within ECM * * @since 2.1.1 * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> * @version CVS $Id: DefaultTimeScheduler.java,v 1.1 2003/08/21 12:44:18 cziegeler Exp $ */ public class DefaultTimeScheduler extends org.apache.avalon.cornerstone.blocks.scheduler.DefaultTimeScheduler implements Component, ThreadSafe { } 1.1 cocoon-2.1/src/scratchpad/src/org/apache/cocoon/components/scheduler/Scheduler.java Index: Scheduler.java =================================================================== /* ============================================================================ The Apache Software License, Version 1.1 ============================================================================ Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modifica- tion, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The end-user documentation included with the redistribution, if any, must include the following acknowledgment: "This product includes software developed by the Apache Software Foundation (http://www.apache.org/)." Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. 4. The names "Apache Cocoon" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact [EMAIL PROTECTED] 5. Products derived from this software may not be called "Apache", nor may "Apache" appear in their name, without prior written permission of the Apache Software Foundation. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. This software consists of voluntary contributions made by many individuals on behalf of the Apache Software Foundation and was originally created by Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache Software Foundation, please see <http://www.apache.org/>. */ package org.apache.cocoon.components.scheduler; import java.util.Map; import org.apache.avalon.cornerstone.services.scheduler.TimeTrigger; import org.apache.avalon.framework.parameters.Parameters; /** * This component can either schedule tasks or directly call one. * * @since 2.1.1 * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> * @version CVS $Id: Scheduler.java,v 1.1 2003/08/21 12:44:18 cziegeler Exp $ */ public interface Scheduler { String ROLE = Scheduler.class.getName(); /** * Schedule a time based trigger. * Note that if a TimeTrigger already has same name then it is removed. * * @param name the name of the trigger * @param trigger the trigger * @param target the target */ void addTriggeredTarget( String name, TimeTrigger trigger, String target ); /** * Schedule a time based trigger. * Note that if a TimeTrigger already has same name then it is removed. * * @param name the name of the trigger * @param trigger the trigger * @param target the target * @param parameters optional parameters for the target * @param objects optional objects for the target */ void addTriggeredTarget( String name, TimeTrigger trigger, String target, Parameters parameters, Map objects ); /** * Remove a scheduled trigger by name. * * @param name the name of the trigger */ void removeTriggeredTarget( String name ); /** * Force a trigger time to be recalculated. * * @param name the name of the trigger */ void resetTriggeredTarget( String name ); /** * Fire a target once */ boolean fireTarget(String target); /** * Fire a target once */ boolean fireTarget(String target, Parameters parameters, Map objects); } 1.1 cocoon-2.1/src/scratchpad/src/org/apache/cocoon/components/scheduler/readme.txt Index: readme.txt =================================================================== This is a scheduling component based on the cornerstone scheduler. To get it running add these components to the cocoon.xconf: <!-- This is the cornerstone scheduler --> <component role="org.apache.avalon.cornerstone.services.scheduler.TimeScheduler" class="org.apache.cocoon.components.scheduler.DefaultTimeScheduler"/> <!-- This is the cornerstone thread manager --> <component role="org.apache.avalon.cornerstone.services.threads.ThreadManager" class="org.apache.cocoon.components.scheduler.DefaultThreadManager"> <thread-group> <name>default</name> </thread-group> </component> <!-- This is an extended cocoon scheduler --> <component role="org.apache.cocoon.components.scheduler.Scheduler" class="org.apache.cocoon.components.scheduler.DefaultScheduler"> <triggers> <!-- This is a sample trigger --> <trigger name="test" target="org.apache.avalon.cornerstone.services.scheduler.Target/test"> <timed type="periodic"> <period>480000</period> <!-- ms, e.g. 8 minutes -- </timed> </trigger> </triggers> </component> <!-- This is a sample target, that is called as configured in the sample above --> <component role="org.apache.avalon.cornerstone.services.scheduler.Target/test" class="org.apache.cocoon.components.scheduler.TestTarget"/> 1.1 cocoon-2.1/src/scratchpad/src/org/apache/cocoon/components/scheduler/DefaultScheduler.java Index: DefaultScheduler.java =================================================================== /* ============================================================================ The Apache Software License, Version 1.1 ============================================================================ Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modifica- tion, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The end-user documentation included with the redistribution, if any, must include the following acknowledgment: "This product includes software developed by the Apache Software Foundation (http://www.apache.org/)." Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. 4. The names "Apache Cocoon" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact [EMAIL PROTECTED] 5. Products derived from this software may not be called "Apache", nor may "Apache" appear in their name, without prior written permission of the Apache Software Foundation. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. This software consists of voluntary contributions made by many individuals on behalf of the Apache Software Foundation and was originally created by Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache Software Foundation, please see <http://www.apache.org/>. */ package org.apache.cocoon.components.scheduler; import java.util.Map; import org.apache.avalon.cornerstone.services.scheduler.Target; import org.apache.avalon.cornerstone.services.scheduler.TimeScheduler; import org.apache.avalon.cornerstone.services.scheduler.TimeTrigger; import org.apache.avalon.cornerstone.services.scheduler.TimeTriggerFactory; import org.apache.avalon.framework.CascadingRuntimeException; import org.apache.avalon.framework.activity.Disposable; import org.apache.avalon.framework.component.Component; import org.apache.avalon.framework.configuration.Configurable; import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.configuration.ConfigurationException; import org.apache.avalon.framework.context.Context; import org.apache.avalon.framework.context.ContextException; import org.apache.avalon.framework.context.Contextualizable; import org.apache.avalon.framework.logger.AbstractLogEnabled; import org.apache.avalon.framework.parameters.Parameters; import org.apache.avalon.framework.service.ServiceException; import org.apache.avalon.framework.service.ServiceManager; import org.apache.avalon.framework.service.Serviceable; import org.apache.avalon.framework.thread.ThreadSafe; import org.apache.excalibur.event.Queue; import org.apache.excalibur.event.Sink; import org.apache.excalibur.event.command.Command; /** * This component can either schedule tasks or directly call one. * * @since 2.1.1 * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> * @version CVS $Id: DefaultScheduler.java,v 1.1 2003/08/21 12:44:18 cziegeler Exp $ */ public class DefaultScheduler extends AbstractLogEnabled implements Component, Serviceable, Disposable, ThreadSafe, Scheduler, Configurable, Contextualizable { protected ServiceManager manager; protected TimeScheduler scheduler; protected Sink commandSink; public void service(ServiceManager manager) throws ServiceException { this.manager = manager; this.scheduler = (TimeScheduler) this.manager.lookup(TimeScheduler.ROLE); } /* (non-Javadoc) * @see org.apache.cocoon.components.tasks.TaskManager#addTriggeredTarget(java.lang.String, org.apache.avalon.cornerstone.services.scheduler.TimeTrigger, java.lang.String, org.apache.avalon.framework.parameters.Parameters, java.util.Map) */ public void addTriggeredTarget(String name, TimeTrigger trigger, String target, Parameters parameters, Map objects) { Target t = this.getTarget(target, parameters, objects); this.scheduler.addTrigger(name, trigger, t); } /** * @param target * @param parameters * @param objects * @return */ protected Target getTarget(String target, Parameters parameters, Map objects) { Target t = new TargetWrapper(this.manager, target, parameters, objects); return t; } /* (non-Javadoc) * @see org.apache.cocoon.components.tasks.TaskManager#addTriggeredTarget(java.lang.String, org.apache.avalon.cornerstone.services.scheduler.TimeTrigger, java.lang.String) */ public void addTriggeredTarget(String name, TimeTrigger trigger, String target) { this.addTriggeredTarget(name, trigger, target, null, null); } /* (non-Javadoc) * @see org.apache.cocoon.components.tasks.TaskManager#fireTarget(java.lang.String, org.apache.avalon.framework.parameters.Parameters, java.util.Map) */ public boolean fireTarget(String target, Parameters parameters, Map objects) { return this.commandSink.tryEnqueue(this.getCommand(target, parameters, objects)); } /** * @param name * @param parameters * @param objects * @return */ private Command getCommand(String target, Parameters parameters, Map objects) { Command t = new TargetWrapper(this.manager, target, parameters, objects); return t; } /* (non-Javadoc) * @see org.apache.cocoon.components.tasks.TaskManager#fireTarget(java.lang.String) */ public boolean fireTarget(String target) { return this.fireTarget(target, null, null); } /* (non-Javadoc) * @see org.apache.cocoon.components.tasks.TaskManager#removeTriggeredTarget(java.lang.String) */ public void removeTriggeredTarget(String name) { this.scheduler.removeTrigger(name); } /* (non-Javadoc) * @see org.apache.cocoon.components.tasks.TaskManager#resetTriggeredTarget(java.lang.String) */ public void resetTriggeredTarget(String name) { this.scheduler.resetTrigger(name); } /** * Initializable */ public void configure(Configuration config) throws ConfigurationException { Configuration[] triggers = config.getChild("triggers").getChildren("trigger"); if ( triggers != null ) { TimeTriggerFactory factory = new TimeTriggerFactory(); for (int i=0; i < triggers.length; i++) { final Configuration current = triggers[i]; final String name = current.getAttribute("name"); final String target = current.getAttribute("target"); Configuration[] triggerConf = current.getChildren("timed"); if ( triggerConf != null ) { for(int m=0; m < triggerConf.length; m++) { TimeTrigger timeTrigger = factory.createTimeTrigger(triggerConf[m]); this.addTriggeredTarget(name, timeTrigger, target); } } } } } /* (non-Javadoc) * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context) */ public void contextualize(Context context) throws ContextException { this.commandSink = (Sink) context.get(Queue.ROLE); } /* (non-Javadoc) * @see org.apache.avalon.framework.activity.Disposable#dispose() */ public void dispose() { if ( this.manager != null ) { this.manager.release( this.scheduler ); this.scheduler = null; this.manager = null; } } class TargetWrapper implements Target, Command { protected ServiceManager manager; protected Parameters parameters; protected Map objects; protected String target; public TargetWrapper(ServiceManager manager, String target, Parameters p, Map o) { this.manager = manager; this.parameters = p; this.objects = o; this.target = target; } /* (non-Javadoc) * @see org.apache.avalon.cornerstone.services.scheduler.Target#targetTriggered(java.lang.String) */ public void targetTriggered(String name) { // lookup real target Target t = null; try { t = (Target) this.manager.lookup(this.target); if ( t instanceof ConfigurableTarget ) { ((ConfigurableTarget)t).setup(this.parameters, this.objects); } t.targetTriggered(name); } catch (ServiceException se) { throw new CascadingRuntimeException("Unable to lookup target " + this.target, se); } finally { this.manager.release(t); } } /* (non-Javadoc) * @see org.apache.avalon.framework.activity.Executable#execute() */ public void execute() throws Exception { // lookup real target Target t = null; try { t = (Target) this.manager.lookup(this.target); if ( t instanceof ConfigurableTarget ) { ((ConfigurableTarget)t).setup(this.parameters, this.objects); } t.targetTriggered("direct"); } finally { this.manager.release(t); } } } } 1.1 cocoon-2.1/src/scratchpad/src/org/apache/cocoon/components/scheduler/DefaultThreadManager.java Index: DefaultThreadManager.java =================================================================== /* ============================================================================ The Apache Software License, Version 1.1 ============================================================================ Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modifica- tion, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The end-user documentation included with the redistribution, if any, must include the following acknowledgment: "This product includes software developed by the Apache Software Foundation (http://www.apache.org/)." Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. 4. The names "Apache Cocoon" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact [EMAIL PROTECTED] 5. Products derived from this software may not be called "Apache", nor may "Apache" appear in their name, without prior written permission of the Apache Software Foundation. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. This software consists of voluntary contributions made by many individuals on behalf of the Apache Software Foundation and was originally created by Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache Software Foundation, please see <http://www.apache.org/>. */ package org.apache.cocoon.components.scheduler; import org.apache.avalon.framework.component.Component; import org.apache.avalon.framework.thread.ThreadSafe; /** * This makes the Thread Manager usuable within ECM * * @since 2.1.1 * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> * @version CVS $Id: DefaultThreadManager.java,v 1.1 2003/08/21 12:44:18 cziegeler Exp $ */ public class DefaultThreadManager extends org.apache.avalon.cornerstone.blocks.threads.DefaultThreadManager implements Component, ThreadSafe { } 1.1 cocoon-2.1/src/scratchpad/src/org/apache/cocoon/components/scheduler/SchedulerAction.java Index: SchedulerAction.java =================================================================== /* ============================================================================ The Apache Software License, Version 1.1 ============================================================================ Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modifica- tion, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The end-user documentation included with the redistribution, if any, must include the following acknowledgment: "This product includes software developed by the Apache Software Foundation (http://www.apache.org/)." Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. 4. The names "Apache Cocoon" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact [EMAIL PROTECTED] 5. Products derived from this software may not be called "Apache", nor may "Apache" appear in their name, without prior written permission of the Apache Software Foundation. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. This software consists of voluntary contributions made by many individuals on behalf of the Apache Software Foundation and was originally created by Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache Software Foundation, please see <http://www.apache.org/>. */ package org.apache.cocoon.components.scheduler; import java.util.Map; import org.apache.avalon.framework.component.Component; import org.apache.avalon.framework.parameters.Parameters; import org.apache.cocoon.acting.ComposerAction; import org.apache.cocoon.environment.Redirector; import org.apache.cocoon.environment.SourceResolver; /** * A simple action firing a target * * @since 2.1.1 * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> * @version CVS $Id: SchedulerAction.java,v 1.1 2003/08/21 12:44:18 cziegeler Exp $ */ public class SchedulerAction extends ComposerAction { /* (non-Javadoc) * @see org.apache.cocoon.acting.Action#act(org.apache.cocoon.environment.Redirector, org.apache.cocoon.environment.SourceResolver, java.util.Map, java.lang.String, org.apache.avalon.framework.parameters.Parameters) */ public Map act( Redirector redirector, SourceResolver resolver, Map objectModel, String source, Parameters parameters) throws Exception { Scheduler scheduler = null; try { scheduler = (Scheduler) this.manager.lookup(Scheduler.ROLE); if ( scheduler.fireTarget(source) ) { return EMPTY_MAP; } } finally { this.manager.release((Component) scheduler); } return null; } } 1.1 cocoon-2.1/src/scratchpad/src/org/apache/cocoon/components/scheduler/ConfigurableTarget.java Index: ConfigurableTarget.java =================================================================== /* ============================================================================ The Apache Software License, Version 1.1 ============================================================================ Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modifica- tion, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The end-user documentation included with the redistribution, if any, must include the following acknowledgment: "This product includes software developed by the Apache Software Foundation (http://www.apache.org/)." Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. 4. The names "Apache Cocoon" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact [EMAIL PROTECTED] 5. Products derived from this software may not be called "Apache", nor may "Apache" appear in their name, without prior written permission of the Apache Software Foundation. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. This software consists of voluntary contributions made by many individuals on behalf of the Apache Software Foundation and was originally created by Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache Software Foundation, please see <http://www.apache.org/>. */ package org.apache.cocoon.components.scheduler; import java.util.Map; import org.apache.avalon.cornerstone.services.scheduler.Target; import org.apache.avalon.framework.parameters.Parameters; /** * This is a configurable target. Before the targetTriggered method is called * the setup method is invoked. * * @since 2.1.1 * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> * @version CVS $Id: ConfigurableTarget.java,v 1.1 2003/08/21 12:44:18 cziegeler Exp $ */ public interface ConfigurableTarget extends Target { void setup(Parameters pars, Map objects); }