geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ammul...@apache.org
Subject svn commit: r413549 - in /geronimo/sandbox/plugins: ./ quartz-deployer/ quartz-deployer/branches/ quartz-deployer/tags/ quartz-deployer/trunk/ quartz-deployer/trunk/src/ quartz-deployer/trunk/src/conf/ quartz-deployer/trunk/src/java/ quartz-deployer/tr...
Date Mon, 12 Jun 2006 00:03:24 GMT
Author: ammulder
Date: Sun Jun 11 17:03:22 2006
New Revision: 413549

URL: http://svn.apache.org/viewvc?rev=413549&view=rev
Log:
Add initial Quartz plugins

Added:
    geronimo/sandbox/plugins/
    geronimo/sandbox/plugins/quartz-deployer/
    geronimo/sandbox/plugins/quartz-deployer/branches/
    geronimo/sandbox/plugins/quartz-deployer/tags/
    geronimo/sandbox/plugins/quartz-deployer/trunk/
    geronimo/sandbox/plugins/quartz-deployer/trunk/pom.xml
    geronimo/sandbox/plugins/quartz-deployer/trunk/src/
    geronimo/sandbox/plugins/quartz-deployer/trunk/src/conf/
    geronimo/sandbox/plugins/quartz-deployer/trunk/src/conf/geronimo-plugin.xml
    geronimo/sandbox/plugins/quartz-deployer/trunk/src/java/
    geronimo/sandbox/plugins/quartz-deployer/trunk/src/java/org/
    geronimo/sandbox/plugins/quartz-deployer/trunk/src/java/org/gplugins/
    geronimo/sandbox/plugins/quartz-deployer/trunk/src/java/org/gplugins/quartz/
    geronimo/sandbox/plugins/quartz-deployer/trunk/src/java/org/gplugins/quartz/deployment/
    geronimo/sandbox/plugins/quartz-deployer/trunk/src/java/org/gplugins/quartz/deployment/QuartzJobDeployer.java
    geronimo/sandbox/plugins/quartz-deployer/trunk/src/resources/
    geronimo/sandbox/plugins/quartz-deployer/trunk/src/resources/META-INF/
    geronimo/sandbox/plugins/quartz-deployer/trunk/src/resources/META-INF/geronimo-service.xml
    geronimo/sandbox/plugins/quartz-deployer/trunk/src/schema/
    geronimo/sandbox/plugins/quartz-deployer/trunk/src/schema/geronimo-quartz-0.1.xsd
    geronimo/sandbox/plugins/quartz-deployer/trunk/src/schema/xmlconfig.xml
    geronimo/sandbox/plugins/quartz-deployer/trunk/src/test/
    geronimo/sandbox/plugins/quartz-deployer/trunk/src/test-resources/
    geronimo/sandbox/plugins/quartz-deployer/trunk/src/test-resources/META-INF/
    geronimo/sandbox/plugins/quartz-deployer/trunk/src/test-resources/META-INF/geronimo-quartz.xml
    geronimo/sandbox/plugins/quartz-deployer/trunk/src/test/org/
    geronimo/sandbox/plugins/quartz-deployer/trunk/src/test/org/gplugins/
    geronimo/sandbox/plugins/quartz-deployer/trunk/src/test/org/gplugins/quartz/
    geronimo/sandbox/plugins/quartz-deployer/trunk/src/test/org/gplugins/quartz/jobs/
    geronimo/sandbox/plugins/quartz-deployer/trunk/src/test/org/gplugins/quartz/jobs/TestJob.java
    geronimo/sandbox/plugins/quartz-scheduler/
    geronimo/sandbox/plugins/quartz-scheduler/branches/
    geronimo/sandbox/plugins/quartz-scheduler/tags/
    geronimo/sandbox/plugins/quartz-scheduler/trunk/
    geronimo/sandbox/plugins/quartz-scheduler/trunk/pom.xml
    geronimo/sandbox/plugins/quartz-scheduler/trunk/src/
    geronimo/sandbox/plugins/quartz-scheduler/trunk/src/conf/
    geronimo/sandbox/plugins/quartz-scheduler/trunk/src/conf/geronimo-plugin.xml
    geronimo/sandbox/plugins/quartz-scheduler/trunk/src/java/
    geronimo/sandbox/plugins/quartz-scheduler/trunk/src/java/org/
    geronimo/sandbox/plugins/quartz-scheduler/trunk/src/java/org/gplugins/
    geronimo/sandbox/plugins/quartz-scheduler/trunk/src/java/org/gplugins/quartz/
    geronimo/sandbox/plugins/quartz-scheduler/trunk/src/java/org/gplugins/quartz/QuartzJob.java
    geronimo/sandbox/plugins/quartz-scheduler/trunk/src/java/org/gplugins/quartz/QuartzJobGBean.java
    geronimo/sandbox/plugins/quartz-scheduler/trunk/src/java/org/gplugins/quartz/QuartzScheduler.java
    geronimo/sandbox/plugins/quartz-scheduler/trunk/src/java/org/gplugins/quartz/QuartzSchedulerGBean.java
    geronimo/sandbox/plugins/quartz-scheduler/trunk/src/java/org/gplugins/quartz/QuartzThreadPool.java
    geronimo/sandbox/plugins/quartz-scheduler/trunk/src/resources/
    geronimo/sandbox/plugins/quartz-scheduler/trunk/src/resources/META-INF/
    geronimo/sandbox/plugins/quartz-scheduler/trunk/src/resources/META-INF/geronimo-service.xml

Added: geronimo/sandbox/plugins/quartz-deployer/trunk/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/plugins/quartz-deployer/trunk/pom.xml?rev=413549&view=auto
==============================================================================
--- geronimo/sandbox/plugins/quartz-deployer/trunk/pom.xml (added)
+++ geronimo/sandbox/plugins/quartz-deployer/trunk/pom.xml Sun Jun 11 17:03:22 2006
@@ -0,0 +1,120 @@
+<project>
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>gplugins</groupId>
+    <artifactId>quartz-deployer</artifactId>
+    <version>0.1</version>
+    <name>Geronimo Quartz Deployer</name>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>xmlbeans-maven-plugin</artifactId>
+                <version>2.0</version>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>xmlbeans</goal>
+                        </goals>
+                    </execution>
+                </executions>
+                <configuration>
+                    <download>true</download>
+                    <sourceSchemas>geronimo-quartz-0.1.xsd</sourceSchemas>
+                    <schemaDirectory>src/schema</schemaDirectory>
+                    <xmlConfigs>
+                        <xmlConfig implementation="java.io.File">src/schema/xmlconfig.xml</xmlConfig>
+                    </xmlConfigs>
+                </configuration>
+            </plugin>
+        </plugins>
+        <sourceDirectory>src/java</sourceDirectory>
+        <testSourceDirectory>src/test</testSourceDirectory>
+        <resources>
+            <resource>
+                <directory>src/resources</directory>
+                <filtering>true</filtering>
+            </resource>
+        </resources>
+        <testResources>
+            <testResource>
+                <directory>src/test-resources</directory>
+            </testResource>
+        </testResources>
+    </build>
+
+    <dependencies>
+        <dependency>
+            <groupId>gplugins</groupId>
+            <artifactId>quartz-scheduler</artifactId>
+            <version>0.1</version>
+        </dependency>
+
+        <dependency>
+            <groupId>xmlbeans</groupId>
+            <artifactId>xbean</artifactId>
+            <version>2.0.0</version>
+        </dependency>
+
+        <dependency>
+            <groupId>stax</groupId>
+            <artifactId>stax-api</artifactId>
+            <version>1.0</version>
+        </dependency>
+
+        <!-- XMLBeans complains about these two JARs, but they're not in the repo,
+             and the XMLBeans code generation worked OK.  What's with that?
+        <dependency>
+            <groupId>xmlbeans</groupId>
+            <artifactId>xmlbeans-jsr173-api</artifactId>
+            <version>2.0-dev</version>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>stax</groupId>
+            <artifactId>stax</artifactId>
+            <version>1.1.1</version>
+            <scope>provided</scope>
+        </dependency>
+        -->
+        
+        <dependency>
+            <groupId>org.apache.geronimo.modules</groupId>
+            <artifactId>geronimo-kernel</artifactId>
+            <version>1.1-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.geronimo.modules</groupId>
+            <artifactId>geronimo-deployment</artifactId>
+            <version>1.1-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.geronimo.modules</groupId>
+            <artifactId>geronimo-service-builder</artifactId>
+            <version>1.1-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.geronimo.modules</groupId>
+            <artifactId>geronimo-common</artifactId>
+            <version>1.1-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>opensymphony</groupId>
+            <artifactId>quartz</artifactId>
+            <version>1.5.2</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>3.8.1</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+</project>
\ No newline at end of file

Added: geronimo/sandbox/plugins/quartz-deployer/trunk/src/conf/geronimo-plugin.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/plugins/quartz-deployer/trunk/src/conf/geronimo-plugin.xml?rev=413549&view=auto
==============================================================================
--- geronimo/sandbox/plugins/quartz-deployer/trunk/src/conf/geronimo-plugin.xml (added)
+++ geronimo/sandbox/plugins/quartz-deployer/trunk/src/conf/geronimo-plugin.xml Sun Jun 11 17:03:22 2006
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<geronimo-plugin xmlns="http://geronimo.apache.org/xml/ns/plugins-1.1">
+  <name>Quartz Job Deployer</name>
+  <module-id>gplugins/quartz-deployer/0.1/car</module-id>
+  <category>Scheduling</category>
+  <description>This plugin lets you deploy Quartz jobs as Geronimo
+modules.  In other words, you can create a JAR containing the job
+classes, with a Geronimo deployment plan providing the module ID,
+classpath, and execution schedule for the job.  Then you can pack
+that plan in the JAR at META-INF/geronimo-quartz.xml or you can
+keep it outside the JAR.
+
+When you've done this, you can use the normal Geronimo deployment
+tools to deploy, start, stop, and undeploy Quartz jobs.  That
+includes the command-line deploy tool, the console, the Maven
+deployment plugin, etc.  So for example, "java -jar bin/deployer.jar
+deploy my-job.jar" would schedule a job, while "java -jar
+bin/deployer.jar stop MyJob" would suspend it.
+
+This plugin depends on the quartz-scheduler plugin that integrates
+the Quartz scheduler into Geronimo.  There's a separate plugin
+available that allows you to manage the Quartz scheduler and jobs
+with the Geronimo admin console.</description>
+  <url>http://geronimo.apache.org/</url>
+  <author>The Apache Geronimo development team</author>
+  <license osi-approved="true">BSD -- Apache Software License (ASL) 2.0</license>
+  <geronimo-version>1.1-SNAPSHOT</geronimo-version>
+  <dependency>geronimo/geronimo-gbean-deployer//car</dependency>
+  <dependency>gplugins/quartz-scheduler//car</dependency>
+  <obsoletes>gplugins/quartz-deployer//car</obsoletes>
+  <source-repository>http://geronimoplugins.com/repository/geronimo-1.1/</source-repository>
+  <source-repository>http://www.ibiblio.org/maven2/</source-repository>
+  <config-xml-content>
+    <gbean name="QuartzDeployer" xmlns="http://geronimo.apache.org/xml/ns/attributes-1.1">
+      <attribute name="schedulerName">?name=QuartzScheduler</attribute>
+    </gbean>
+  </config-xml-content>
+</geronimo-plugin>

Added: geronimo/sandbox/plugins/quartz-deployer/trunk/src/java/org/gplugins/quartz/deployment/QuartzJobDeployer.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/plugins/quartz-deployer/trunk/src/java/org/gplugins/quartz/deployment/QuartzJobDeployer.java?rev=413549&view=auto
==============================================================================
--- geronimo/sandbox/plugins/quartz-deployer/trunk/src/java/org/gplugins/quartz/deployment/QuartzJobDeployer.java (added)
+++ geronimo/sandbox/plugins/quartz-deployer/trunk/src/java/org/gplugins/quartz/deployment/QuartzJobDeployer.java Sun Jun 11 17:03:22 2006
@@ -0,0 +1,257 @@
+/**
+ * Copyright 2006 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.gplugins.quartz.deployment;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.jar.JarFile;
+import javax.xml.namespace.QName;
+import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.deployment.ConfigurationBuilder;
+import org.apache.geronimo.deployment.DeploymentContext;
+import org.apache.geronimo.deployment.ModuleIDBuilder;
+import org.apache.geronimo.deployment.service.EnvironmentBuilder;
+import org.apache.geronimo.deployment.util.DeploymentUtil;
+import org.apache.geronimo.deployment.xbeans.ArtifactType;
+import org.apache.geronimo.deployment.xbeans.EnvironmentType;
+import org.apache.geronimo.deployment.xmlbeans.XmlBeansUtil;
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.gbean.AbstractNameQuery;
+import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.kernel.GBeanAlreadyExistsException;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.Naming;
+import org.apache.geronimo.kernel.config.ConfigurationAlreadyExistsException;
+import org.apache.geronimo.kernel.config.ConfigurationManager;
+import org.apache.geronimo.kernel.config.ConfigurationModuleType;
+import org.apache.geronimo.kernel.config.ConfigurationStore;
+import org.apache.geronimo.kernel.config.ConfigurationUtil;
+import org.apache.geronimo.kernel.config.SimpleConfigurationManager;
+import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.kernel.repository.ArtifactResolver;
+import org.apache.geronimo.kernel.repository.Environment;
+import org.apache.geronimo.kernel.repository.Repository;
+import org.apache.xmlbeans.XmlCursor;
+import org.apache.xmlbeans.XmlException;
+import org.apache.xmlbeans.XmlObject;
+import org.gplugins.quartz.QuartzJobGBean;
+import org.gplugins.quartz.deployment.xbeans.JobType;
+import org.gplugins.quartz.deployment.xbeans.JobsDocument;
+import org.gplugins.quartz.deployment.xbeans.JobsType;
+
+/**
+ * Deploys Quartz jobs at runtime
+ *
+ * @version $Rev: 355877 $ $Date: 2005-12-10 21:48:27 -0500 (Sat, 10 Dec 2005) $
+ */
+public class QuartzJobDeployer implements ConfigurationBuilder {
+    private static final QName SERVICE_QNAME = JobsDocument.type.getDocumentElementName();
+
+    private final Environment defaultEnvironment;
+    private final Collection repositories;
+    private final Naming naming;
+    private final ConfigurationManager configurationManager;
+    private final AbstractNameQuery schedulerName;
+
+    public QuartzJobDeployer(Environment defaultEnvironment, Collection repositories, AbstractNameQuery schedulerName, Kernel kernel) {
+        this.defaultEnvironment = defaultEnvironment;
+        this.repositories = repositories;
+        this.schedulerName = schedulerName;
+        naming = kernel.getNaming();
+        configurationManager = ConfigurationUtil.getConfigurationManager(kernel);
+    }
+
+    public Object getDeploymentPlan(File planFile, JarFile jarFile, ModuleIDBuilder idBuilder) throws DeploymentException {
+        if (planFile == null && jarFile == null) {
+            return null;
+        }
+
+        try {
+            XmlObject xmlObject;
+            if (planFile != null) {
+                xmlObject = XmlBeansUtil.parse(planFile.toURL());
+            } else {
+                URL path = DeploymentUtil.createJarURL(jarFile, "META-INF/geronimo-quartz.xml");
+                try {
+                    xmlObject = XmlBeansUtil.parse(path);
+                } catch (FileNotFoundException e) {
+                    // It has a JAR but no plan, and nothing at META-INF/geronimo-quartz.xml,
+                    // therefore it's not a quartz job deployment
+                    return null;
+                }
+            }
+            if (xmlObject == null) {
+                return null;
+            }
+
+            XmlCursor cursor = xmlObject.newCursor();
+            try {
+                cursor.toFirstChild();
+                if (!SERVICE_QNAME.equals(cursor.getName())) {
+                    return null;
+                }
+            } finally {
+                cursor.dispose();
+            }
+            JobsDocument moduleDoc;
+            if (xmlObject instanceof JobsDocument) {
+                moduleDoc = (JobsDocument) xmlObject;
+            } else {
+                moduleDoc = (JobsDocument) xmlObject.changeType(JobsDocument.type);
+            }
+            Collection errors = new ArrayList();
+            if (!moduleDoc.validate(XmlBeansUtil.createXmlOptions(errors))) {
+                throw new DeploymentException("Invalid deployment descriptor: " + errors + "\nDescriptor: " + moduleDoc.toString());
+            }
+            // If there's no artifact ID and we won't be able to figure one out later, use the plan file name.  Bit of a hack.
+            if (jarFile == null && (moduleDoc.getJobs().getEnvironment() == null ||
+                    moduleDoc.getJobs().getEnvironment().getModuleId() == null ||
+                    moduleDoc.getJobs().getEnvironment().getModuleId().getArtifactId() == null)) {
+                if (moduleDoc.getJobs().getEnvironment() == null) {
+                    moduleDoc.getJobs().addNewEnvironment();
+                }
+                if (moduleDoc.getJobs().getEnvironment().getModuleId() == null) {
+                    moduleDoc.getJobs().getEnvironment().addNewModuleId();
+                }
+                String name = planFile.getName();
+                int pos = name.lastIndexOf('.');
+                if (pos > -1) {
+                    name = name.substring(0, pos);
+                }
+                moduleDoc.getJobs().getEnvironment().getModuleId().setArtifactId(name);
+            }
+            return moduleDoc.getJobs();
+        } catch (XmlException e) {
+            throw new DeploymentException("Could not parse xml in plan", e);
+        } catch (IOException e) {
+            throw new DeploymentException("no plan at " + planFile, e);
+        }
+    }
+
+    public Artifact getConfigurationID(Object plan, JarFile module, ModuleIDBuilder idBuilder) throws IOException, DeploymentException {
+        JobsType configType = (JobsType) plan;
+        EnvironmentType environmentType = configType.getEnvironment();
+        Environment environment = EnvironmentBuilder.buildEnvironment(environmentType, defaultEnvironment);
+        idBuilder.resolve(environment, module == null ? "" : new File(module.getName()).getName(), "car");
+        if(!environment.getConfigId().isResolved()) {
+            throw new IllegalStateException("Module ID is not fully populated ("+environment.getConfigId()+")");
+        }
+        return environment.getConfigId();
+    }
+
+    public DeploymentContext buildConfiguration(boolean inPlaceDeployment, Artifact configId, Object plan, JarFile jar, Collection configurationStores, ArtifactResolver artifactResolver, ConfigurationStore targetConfigurationStore) throws IOException, DeploymentException {
+        JobsType configType = (JobsType) plan;
+
+        return buildConfiguration(inPlaceDeployment, configId, configType, jar, configurationStores, artifactResolver, targetConfigurationStore);
+    }
+
+    public DeploymentContext buildConfiguration(boolean inPlaceDeployment, Artifact configId, JobsType moduleType, JarFile jar, Collection configurationStores, ArtifactResolver artifactResolver, ConfigurationStore targetConfigurationStore) throws DeploymentException, IOException {
+        ArtifactType type = moduleType.getEnvironment().isSetModuleId() ? moduleType.getEnvironment().getModuleId() : moduleType.getEnvironment().addNewModuleId();
+        type.setArtifactId(configId.getArtifactId());
+        type.setGroupId(configId.getGroupId());
+        type.setType(configId.getType());
+        type.setVersion(configId.getVersion().toString());
+        Environment environment = EnvironmentBuilder.buildEnvironment(moduleType.getEnvironment(), defaultEnvironment);
+        if(!environment.getConfigId().isResolved()) {
+            throw new IllegalStateException("Module ID should be fully resolved by now (not "+environment.getConfigId()+")");
+        }
+        File outfile;
+        try {
+            outfile = targetConfigurationStore.createNewConfigurationDir(configId);
+        } catch (ConfigurationAlreadyExistsException e) {
+            throw new DeploymentException(e);
+        }
+
+        ConfigurationManager configurationManager = this.configurationManager;
+        if (configurationManager == null) {
+            configurationManager = new SimpleConfigurationManager(configurationStores, artifactResolver, repositories);
+        }
+        DeploymentContext context = new DeploymentContext(outfile,
+                inPlaceDeployment && null != jar ? DeploymentUtil.toFile(jar) : null,
+                environment,
+                ConfigurationModuleType.SERVICE,
+                naming,
+                configurationManager,
+                repositories
+        );
+        if(jar != null) {
+            File file = new File(jar.getName());
+            context.addIncludeAsPackedJar(URI.create(file.getName()), jar);
+        }
+        try {
+            ClassLoader cl = context.getClassLoader();
+
+
+            AbstractName moduleName = naming.createRootName(configId, configId.toString(), "ServiceModule");
+
+            addJobs(moduleType.getJobArray(), cl, moduleName, context);
+            return context;
+        } catch (RuntimeException t) {
+            context.close();
+            throw t;
+        } catch (Error e) {
+            context.close();
+            throw e;
+        }
+    }
+
+    private void addJobs(JobType[] jobs, ClassLoader cl, AbstractName moduleName, DeploymentContext context) throws DeploymentException {
+        for (int i = 0; i < jobs.length; i++) {
+            JobType job = jobs[i];
+            GBeanInfo gBeanInfo = GBeanInfo.getGBeanInfo(QuartzJobGBean.class.getName(), cl);
+            String namePart = job.getJobName();
+            AbstractName abstractName = context.getNaming().createChildName(moduleName, namePart, "GBean");
+            GBeanData data = new GBeanData(abstractName, gBeanInfo);
+            data.setReferencePattern("QuartzScheduler", schedulerName);
+            data.setAttribute("name", job.getJobName());
+            data.setAttribute("jobClass", job.getJobClass());
+            data.setAttribute("cronExpression", job.getCronExpression());
+            try {
+                context.addGBean(data);
+            } catch (GBeanAlreadyExistsException e) {
+                throw new DeploymentException("Cannot add Quartz job '"+job.getJobName()+"' for module "+moduleName+"; a job with that name already exists.");
+            }
+        }
+    }
+
+    public static final GBeanInfo GBEAN_INFO;
+
+    static {
+        GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic("Quartz Deployer", QuartzJobDeployer.class, "ConfigBuilder");
+
+        infoFactory.addInterface(ConfigurationBuilder.class);
+
+        infoFactory.addAttribute("defaultEnvironment", Environment.class, true);
+        infoFactory.addAttribute("schedulerName", AbstractNameQuery.class, true, true);
+        infoFactory.addAttribute("kernel", Kernel.class, false, false);
+        infoFactory.addReference("Repository", Repository.class, "Repository");
+
+        infoFactory.setConstructor(new String[]{"defaultEnvironment", "Repository", "schedulerName", "kernel"});
+
+        GBEAN_INFO = infoFactory.getBeanInfo();
+    }
+
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
+    }
+}

Added: geronimo/sandbox/plugins/quartz-deployer/trunk/src/resources/META-INF/geronimo-service.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/plugins/quartz-deployer/trunk/src/resources/META-INF/geronimo-service.xml?rev=413549&view=auto
==============================================================================
--- geronimo/sandbox/plugins/quartz-deployer/trunk/src/resources/META-INF/geronimo-service.xml (added)
+++ geronimo/sandbox/plugins/quartz-deployer/trunk/src/resources/META-INF/geronimo-service.xml Sun Jun 11 17:03:22 2006
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module xmlns="http://geronimo.apache.org/xml/ns/deployment-1.1">
+    <environment>
+        <moduleId>
+            <groupId>gplugins</groupId>
+            <artifactId>quartz-deployer</artifactId>
+            <version>0.1</version>
+            <type>car</type>
+        </moduleId>
+        <dependencies>
+            <dependency>
+                <groupId>gplugins</groupId>
+                <artifactId>quartz-scheduler</artifactId>
+                <version>0.1</version>
+                <type>car</type>
+            </dependency>
+
+            <dependency>
+                <groupId>geronimo</groupId>
+                <artifactId>geronimo-gbean-deployer</artifactId>
+                <type>car</type>
+            </dependency>
+        </dependencies>
+    </environment>
+    <gbean name="QuartzDeployer" class="org.gplugins.quartz.deployment.QuartzJobDeployer">
+        <reference name="Repository"/>
+        <attribute name="schedulerName">?name=QuartzScheduler</attribute>
+        <xml-attribute name="defaultEnvironment">
+            <environment>
+                <dependencies>
+                    <dependency>
+                        <groupId>gplugins</groupId>
+                        <artifactId>quartz-scheduler</artifactId>
+                        <type>car</type>
+                    </dependency>
+                </dependencies>
+            </environment>
+        </xml-attribute>
+    </gbean>
+</module>
\ No newline at end of file

Added: geronimo/sandbox/plugins/quartz-deployer/trunk/src/schema/geronimo-quartz-0.1.xsd
URL: http://svn.apache.org/viewvc/geronimo/sandbox/plugins/quartz-deployer/trunk/src/schema/geronimo-quartz-0.1.xsd?rev=413549&view=auto
==============================================================================
--- geronimo/sandbox/plugins/quartz-deployer/trunk/src/schema/geronimo-quartz-0.1.xsd (added)
+++ geronimo/sandbox/plugins/quartz-deployer/trunk/src/schema/geronimo-quartz-0.1.xsd Sun Jun 11 17:03:22 2006
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright 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.
+-->
+
+<xs:schema
+        targetNamespace="http://geronimo.apache.org/xml/ns/plugins/quartz-0.1"
+        xmlns:job="http://geronimo.apache.org/xml/ns/plugins/quartz-0.1"
+        xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.1"
+        xmlns:xs="http://www.w3.org/2001/XMLSchema"
+        elementFormDefault="qualified"
+        attributeFormDefault="unqualified"
+        >
+
+    <xs:annotation>
+        <xs:documentation>
+            Schema for a Quartz scheduled job.
+        </xs:documentation>
+    </xs:annotation>
+
+    <xs:import namespace="http://geronimo.apache.org/xml/ns/deployment-1.1" schemaLocation="geronimo-module-1.1.xsd"/>
+
+    <!--   Top-level elements   -->
+
+    <xs:element name="jobs" type="job:jobsType">
+        <xs:annotation>
+            <xs:documentation>
+                A list of jobs to schedule with Quartz
+            </xs:documentation>
+        </xs:annotation>
+    </xs:element>
+
+    <xs:complexType name="jobsType">
+        <xs:sequence>
+            <xs:element ref="sys:environment"/>
+            <xs:element name="job" type="job:jobType" minOccurs="1" maxOccurs="unbounded">
+                <xs:annotation>
+                    <xs:documentation>
+                        A job to schedule with Quartz
+                    </xs:documentation>
+                </xs:annotation>
+            </xs:element>
+        </xs:sequence>
+    </xs:complexType>
+
+    <xs:complexType name="jobType">
+        <xs:sequence>
+            <xs:element name="job-name" type="xs:string">
+                <xs:annotation>
+                    <xs:documentation>
+                        A unique name used to identify the Quartz job
+                    </xs:documentation>
+                </xs:annotation>
+            </xs:element>
+            <xs:element name="job-class" type="xs:string">
+                <xs:annotation>
+                    <xs:documentation>
+                        The fully-qualified class name of the Quartz job
+                    </xs:documentation>
+                </xs:annotation>
+            </xs:element>
+            <xs:choice>
+                <xs:element name="cron-expression" type="xs:string">
+                    <xs:annotation>
+                        <xs:documentation>
+                            A CRON-formatted expression for when the job should run
+                        </xs:documentation>
+                    </xs:annotation>
+                </xs:element>
+            </xs:choice>
+        </xs:sequence>
+    </xs:complexType>
+</xs:schema>
+

Added: geronimo/sandbox/plugins/quartz-deployer/trunk/src/schema/xmlconfig.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/plugins/quartz-deployer/trunk/src/schema/xmlconfig.xml?rev=413549&view=auto
==============================================================================
--- geronimo/sandbox/plugins/quartz-deployer/trunk/src/schema/xmlconfig.xml (added)
+++ geronimo/sandbox/plugins/quartz-deployer/trunk/src/schema/xmlconfig.xml Sun Jun 11 17:03:22 2006
@@ -0,0 +1,7 @@
+<xb:config xmlns:xb="http://www.bea.com/2002/09/xbean/config">
+
+    <xb:namespace uri="http://geronimo.apache.org/xml/ns/plugins/quartz-0.1">
+        <xb:package>org.gplugins.quartz.deployment.xbeans</xb:package>
+    </xb:namespace>
+
+</xb:config>
\ No newline at end of file

Added: geronimo/sandbox/plugins/quartz-deployer/trunk/src/test-resources/META-INF/geronimo-quartz.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/plugins/quartz-deployer/trunk/src/test-resources/META-INF/geronimo-quartz.xml?rev=413549&view=auto
==============================================================================
--- geronimo/sandbox/plugins/quartz-deployer/trunk/src/test-resources/META-INF/geronimo-quartz.xml (added)
+++ geronimo/sandbox/plugins/quartz-deployer/trunk/src/test-resources/META-INF/geronimo-quartz.xml Sun Jun 11 17:03:22 2006
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<jobs xmlns="http://geronimo.apache.org/xml/ns/plugins/quartz-0.1">
+    <environment xmlns="http://geronimo.apache.org/xml/ns/deployment-1.1">
+        <moduleId>
+            <artifactId>TestJob</artifactId>
+        </moduleId>
+    </environment>
+    <job>
+        <job-name>Test 1</job-name>
+        <job-class>org.gplugins.quartz.jobs.TestJob</job-class>
+        <cron-expression>0/15 * * * * ?</cron-expression>
+    </job>
+</jobs>
\ No newline at end of file

Added: geronimo/sandbox/plugins/quartz-deployer/trunk/src/test/org/gplugins/quartz/jobs/TestJob.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/plugins/quartz-deployer/trunk/src/test/org/gplugins/quartz/jobs/TestJob.java?rev=413549&view=auto
==============================================================================
--- geronimo/sandbox/plugins/quartz-deployer/trunk/src/test/org/gplugins/quartz/jobs/TestJob.java (added)
+++ geronimo/sandbox/plugins/quartz-deployer/trunk/src/test/org/gplugins/quartz/jobs/TestJob.java Sun Jun 11 17:03:22 2006
@@ -0,0 +1,35 @@
+/**
+ * Copyright 2006 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.gplugins.quartz.jobs;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+
+/**
+ * A sample Quartz job
+ *
+ * @version $Rev: 355877 $ $Date: 2005-12-10 21:48:27 -0500 (Sat, 10 Dec 2005) $
+ */
+public class TestJob implements Job {
+    private final SimpleDateFormat sdf = new SimpleDateFormat("EEEE HH:mm:ss");
+
+    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+        System.out.println("TEST JOB RUNNING at "+sdf.format(new Date()));
+    }
+}

Added: geronimo/sandbox/plugins/quartz-scheduler/trunk/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/plugins/quartz-scheduler/trunk/pom.xml?rev=413549&view=auto
==============================================================================
--- geronimo/sandbox/plugins/quartz-scheduler/trunk/pom.xml (added)
+++ geronimo/sandbox/plugins/quartz-scheduler/trunk/pom.xml Sun Jun 11 17:03:22 2006
@@ -0,0 +1,68 @@
+<project>
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>gplugins</groupId>
+    <artifactId>quartz-scheduler</artifactId>
+    <version>0.1</version>
+    <name>Quartz Scheduler for Geronimo</name>
+    <build>
+        <sourceDirectory>src/java</sourceDirectory>
+        <testSourceDirectory>src/test</testSourceDirectory>
+        <resources>
+            <resource>
+                <directory>src/resources</directory>
+                <filtering>true</filtering>
+            </resource>
+        </resources>
+        <testResources>
+            <testResource>
+                <directory>src/test-resources</directory>
+            </testResource>
+        </testResources>
+    </build>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.geronimo.modules</groupId>
+            <artifactId>geronimo-kernel</artifactId>
+            <version>1.1-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.geronimo.modules</groupId>
+            <artifactId>geronimo-deployment</artifactId>
+            <version>1.1-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.geronimo.modules</groupId>
+            <artifactId>geronimo-system</artifactId>
+            <version>1.1-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>mx4j</groupId>
+            <artifactId>mx4j</artifactId>
+            <version>3.0.1</version>
+        </dependency>
+
+        <dependency>
+            <groupId>opensymphony</groupId>
+            <artifactId>quartz</artifactId>
+            <version>1.5.2</version>
+        </dependency>
+
+        <dependency>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+            <version>1.0.4</version>
+        </dependency>
+
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>3.8.1</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+</project>
\ No newline at end of file

Added: geronimo/sandbox/plugins/quartz-scheduler/trunk/src/conf/geronimo-plugin.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/plugins/quartz-scheduler/trunk/src/conf/geronimo-plugin.xml?rev=413549&view=auto
==============================================================================
--- geronimo/sandbox/plugins/quartz-scheduler/trunk/src/conf/geronimo-plugin.xml (added)
+++ geronimo/sandbox/plugins/quartz-scheduler/trunk/src/conf/geronimo-plugin.xml Sun Jun 11 17:03:22 2006
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<geronimo-plugin xmlns="http://geronimo.apache.org/xml/ns/plugins-1.1">
+  <name>Quartz Scheduler Integration</name>
+  <module-id>gplugins/quartz-scheduler/0.1/car</module-id>
+  <category>Scheduling</category>
+  <description>This plugin adds a Quartz scheduler to Geronimo.  It provides
+Geronimo components representing the scheduler and scheduled jobs, which
+can be used by other applications as well as other Geronimo modules.
+
+To use the scheduler from an application, add a gbean-ref to the Geronimo
+deployment plan for the application with ref-type org.gplugins.quartz.QuartzScheduler
+and pattern/name QuartzScheduler.  From the QuartzScheduler, you can schedule
+and delete jobs, pause and resume, inspect and edit individual jobs, etc.
+
+Note there are related plugins allowing you to deploy Quartz jobs as a JAR
+with XML plan defining the job schdule, and allowing you to manage the
+Quartz scheduler and jobs with the Geronimo admin console.</description>
+  <url>http://geronimo.apache.org/</url>
+  <author>The Apache Geronimo development team</author>
+  <license osi-approved="true">BSD -- Apache Software License (ASL) 2.0</license>
+  <geronimo-version>1.1-SNAPSHOT</geronimo-version>
+  <dependency>geronimo/rmi-naming//car</dependency>
+  <dependency>opensymphony/quartz//jar</dependency>
+  <obsoletes>gplugins/quartz-scheduler//car</obsoletes>
+  <source-repository>http://geronimoplugins.com/repository/geronimo-1.1/</source-repository>
+  <source-repository>http://www.ibiblio.org/maven2/</source-repository>
+  <config-xml-content>
+    <gbean name="QuartzScheduler" xmlns="http://geronimo.apache.org/xml/ns/attributes-1.1">
+      <reference name="ThreadPool">
+        <pattern>
+          <name>DefaultThreadPool</name>
+        </pattern>
+      </reference>
+    </gbean>
+  </config-xml-content>
+</geronimo-plugin>

Added: geronimo/sandbox/plugins/quartz-scheduler/trunk/src/java/org/gplugins/quartz/QuartzJob.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/plugins/quartz-scheduler/trunk/src/java/org/gplugins/quartz/QuartzJob.java?rev=413549&view=auto
==============================================================================
--- geronimo/sandbox/plugins/quartz-scheduler/trunk/src/java/org/gplugins/quartz/QuartzJob.java (added)
+++ geronimo/sandbox/plugins/quartz-scheduler/trunk/src/java/org/gplugins/quartz/QuartzJob.java Sun Jun 11 17:03:22 2006
@@ -0,0 +1,43 @@
+/**
+ * Copyright 2006 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.gplugins.quartz;
+
+import org.quartz.SchedulerException;
+
+/**
+ * Management interface for a Quartz schedule job
+ *
+ * @version $Rev: 355877 $ $Date: 2005-12-10 21:48:27 -0500 (Sat, 10 Dec 2005) $
+ */
+public interface QuartzJob {
+    String getCronExpression();
+
+    void setCronExpression(String cronExpression) throws SchedulerException;
+
+    String getJobClass();
+
+    void setJobClass(String jobClass);
+
+    String getName();
+
+    void setName(String name);
+
+    void pause() throws SchedulerException;
+
+    void resume() throws SchedulerException;
+
+    void execute() throws SchedulerException;
+}

Added: geronimo/sandbox/plugins/quartz-scheduler/trunk/src/java/org/gplugins/quartz/QuartzJobGBean.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/plugins/quartz-scheduler/trunk/src/java/org/gplugins/quartz/QuartzJobGBean.java?rev=413549&view=auto
==============================================================================
--- geronimo/sandbox/plugins/quartz-scheduler/trunk/src/java/org/gplugins/quartz/QuartzJobGBean.java (added)
+++ geronimo/sandbox/plugins/quartz-scheduler/trunk/src/java/org/gplugins/quartz/QuartzJobGBean.java Sun Jun 11 17:03:22 2006
@@ -0,0 +1,140 @@
+/**
+ * Copyright 2006 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.gplugins.quartz;
+
+import java.text.ParseException;
+import org.apache.geronimo.gbean.GBeanLifecycle;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.quartz.JobDetail;
+import org.quartz.CronTrigger;
+import org.quartz.SchedulerException;
+
+/**
+ * Represents a Quartz job.
+ *
+ * @version $Rev: 355877 $ $Date: 2005-12-10 21:48:27 -0500 (Sat, 10 Dec 2005) $
+ */
+public class QuartzJobGBean implements GBeanLifecycle, QuartzJob {
+    private final static Log log = LogFactory.getLog(QuartzJobGBean.class);
+    private final QuartzScheduler scheduler;
+    private final ClassLoader loader;
+    private String name;
+    private String jobClass;
+    private String cronExpression;
+    boolean running;
+
+    public QuartzJobGBean(QuartzScheduler scheduler, String jobClass, String name, ClassLoader loader) {
+        this.jobClass = jobClass;
+        this.name = name;
+        this.scheduler = scheduler;
+        this.loader = loader;
+    }
+
+    public String getCronExpression() {
+        return cronExpression;
+    }
+
+    public void setCronExpression(String cronExpression) throws SchedulerException {
+        this.cronExpression = cronExpression;
+        if(running) {
+            try {
+                scheduler.rescheduleJob(name, createTrigger());
+            } catch (ParseException e) {
+                throw new SchedulerException("Unable to schedule; invalid cron expression '"+cronExpression+"'", e);
+            }
+        }
+    }
+
+    public String getJobClass() {
+        return jobClass;
+    }
+
+    public void setJobClass(String jobClass) {
+        this.jobClass = jobClass;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public void pause() throws SchedulerException {
+        if(running) {
+            scheduler.pauseJob(name);
+        }
+    }
+
+    public void resume() throws SchedulerException {
+        if(running) {
+            scheduler.resumeJob(name);
+        }
+    }
+
+    public void execute() throws SchedulerException {
+        if(running) {
+            scheduler.executeImmediately(name);
+        }
+    }
+
+    public void doStart() throws Exception {
+        log.info("Scheduling job '"+name+"'");
+        Class cls = loader.loadClass(jobClass);
+        JobDetail jd = new JobDetail(name, QuartzSchedulerGBean.GROUP_NAME, cls);
+        CronTrigger cronTrigger = createTrigger();
+        scheduler.scheduleJob(jd, cronTrigger);
+        running = true;
+    }
+
+    public void doStop() throws Exception {
+        running = false;
+        scheduler.deleteJob(name);
+    }
+
+    public void doFail() {
+        running = false;
+    }
+
+    private CronTrigger createTrigger() throws ParseException {
+        CronTrigger cronTrigger = new CronTrigger(name+" Trigger", QuartzSchedulerGBean.GROUP_NAME);
+        cronTrigger.setCronExpression(cronExpression);
+        return cronTrigger;
+    }
+
+    public static final GBeanInfo GBEAN_INFO;
+
+    static {
+        GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic("Quartz Job", QuartzJobGBean.class);
+        infoFactory.addAttribute("classLoader", ClassLoader.class, false);
+        infoFactory.addReference("QuartzScheduler", QuartzScheduler.class, "GBean");
+        infoFactory.addInterface(QuartzJob.class, new String[]{"cronExpression", "jobClass","name"},
+                                                  new String[]{"cronExpression", "jobClass","name"});
+
+        infoFactory.setConstructor(new String[]{"QuartzScheduler", "jobClass", "name", "classLoader"});
+
+        GBEAN_INFO = infoFactory.getBeanInfo();
+    }
+
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
+    }
+
+}

Added: geronimo/sandbox/plugins/quartz-scheduler/trunk/src/java/org/gplugins/quartz/QuartzScheduler.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/plugins/quartz-scheduler/trunk/src/java/org/gplugins/quartz/QuartzScheduler.java?rev=413549&view=auto
==============================================================================
--- geronimo/sandbox/plugins/quartz-scheduler/trunk/src/java/org/gplugins/quartz/QuartzScheduler.java (added)
+++ geronimo/sandbox/plugins/quartz-scheduler/trunk/src/java/org/gplugins/quartz/QuartzScheduler.java Sun Jun 11 17:03:22 2006
@@ -0,0 +1,74 @@
+/**
+ * Copyright 2006 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.gplugins.quartz;
+
+import java.util.Map;
+import org.quartz.JobDetail;
+import org.quartz.Trigger;
+import org.quartz.SchedulerException;
+
+/**
+ * Management interface for the Quartz scheduler
+ *
+ * @version $Rev: 355877 $ $Date: 2005-12-10 21:48:27 -0500 (Sat, 10 Dec 2005) $
+ */
+public interface QuartzScheduler {
+    /**
+     * Schedules a Quartz job.
+     *
+     * Note that any jobs scheduled through this mechanism must have the group
+     * name "Geronimo Quartz".  The scheduler will overwrite it to be that if
+     * necessary.
+     */
+    void scheduleJob(JobDetail detail, Trigger trigger) throws SchedulerException;
+
+    /**
+     * Deletes a scheduled job.  Assumes the group "Geronimo Quartz".
+     */
+    void deleteJob(String jobName) throws SchedulerException;
+
+    /**
+     * Returns a Map with keys of type JobDetail and values of type Trigger
+     * for all jobs scheduled with group "Geronimo Quartz".
+     */
+    Map getScheduledJobs() throws SchedulerException;
+
+    /**
+     * Sets a new Trigger for an existing job (which must be in the group
+     * "Geronimo Quartz").
+     */
+    void rescheduleJob(String jobName, Trigger trigger) throws SchedulerException;
+
+    /**
+     * Pauses an existing job (which must be in the group "Geronimo Quartz".
+     */
+    void pauseJob(String jobName) throws SchedulerException;
+
+    /**
+     * Resumes an existing job (which must be in the group "Geronimo Quartz".
+     */
+    void resumeJob(String jobName) throws SchedulerException;
+
+    /**
+     * Triggers a job (in the "Geronimo Quartz" group) to start right away.
+     */
+    void executeImmediately(String jobName) throws SchedulerException;
+
+    /**
+     * Gets the job GBean for a job in the "Geronimo Quartz" group.
+     */
+    QuartzJob getJob(String jobName);
+}

Added: geronimo/sandbox/plugins/quartz-scheduler/trunk/src/java/org/gplugins/quartz/QuartzSchedulerGBean.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/plugins/quartz-scheduler/trunk/src/java/org/gplugins/quartz/QuartzSchedulerGBean.java?rev=413549&view=auto
==============================================================================
--- geronimo/sandbox/plugins/quartz-scheduler/trunk/src/java/org/gplugins/quartz/QuartzSchedulerGBean.java (added)
+++ geronimo/sandbox/plugins/quartz-scheduler/trunk/src/java/org/gplugins/quartz/QuartzSchedulerGBean.java Sun Jun 11 17:03:22 2006
@@ -0,0 +1,164 @@
+/**
+ * Copyright 2006 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.gplugins.quartz;
+
+import java.util.Properties;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Collections;
+import java.util.Set;
+import java.io.InputStream;
+import org.apache.geronimo.gbean.GBeanLifecycle;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.gbean.AbstractNameQuery;
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.system.threads.ThreadPool;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.quartz.Scheduler;
+import org.quartz.SchedulerException;
+import org.quartz.JobDetail;
+import org.quartz.Trigger;
+import org.quartz.impl.StdSchedulerFactory;
+
+/**
+ * A GBean that starts and stops the Quartz scheduler.
+ *
+ * @version $Rev: 355877 $ $Date: 2005-12-10 21:48:27 -0500 (Sat, 10 Dec 2005) $
+ */
+public class QuartzSchedulerGBean implements GBeanLifecycle, QuartzScheduler {
+    private final static Log log = LogFactory.getLog(QuartzSchedulerGBean.class);
+    final static String GROUP_NAME="Geronimo Quartz";
+    private final Kernel kernel;
+    private String threadPoolKey;
+    private Scheduler scheduler;
+
+    public QuartzSchedulerGBean(ThreadPool pool, Kernel kernel) {
+        this.kernel = kernel;
+        if(pool != null) {
+            threadPoolKey = QuartzThreadPool.addPool(pool);
+        }
+    }
+
+    public void scheduleJob(JobDetail detail, Trigger trigger) throws SchedulerException {
+        detail.setGroup(GROUP_NAME);
+        scheduler.scheduleJob(detail, trigger);
+    }
+
+    public void deleteJob(String jobName) throws SchedulerException {
+        scheduler.deleteJob(jobName, GROUP_NAME);
+    }
+
+    public Map getScheduledJobs() throws SchedulerException {
+        String[] names = scheduler.getJobNames(GROUP_NAME);
+        Map map = new HashMap();
+        for (int i = 0; i < names.length; i++) {
+            String name = names[i];
+            JobDetail detail = scheduler.getJobDetail(name, GROUP_NAME);
+            Trigger[] triggers = scheduler.getTriggersOfJob(name, GROUP_NAME);
+            if(triggers.length == 1) {
+                map.put(detail, triggers[0]);
+            } else {
+                map.put(detail, null);
+            }
+        }
+        return map;
+    }
+
+    public void rescheduleJob(String jobName, Trigger trigger) throws SchedulerException {
+        Trigger[] triggers = scheduler.getTriggersOfJob(jobName, GROUP_NAME);
+        for (int i = 0; i < triggers.length; i++) {
+            Trigger old = triggers[i];
+            scheduler.unscheduleJob(old.getName(), old.getGroup());
+        }
+        trigger.setJobName(jobName);
+        trigger.setJobGroup(GROUP_NAME);
+        scheduler.scheduleJob(trigger);
+    }
+
+    public void executeImmediately(String jobName) throws SchedulerException {
+        scheduler.triggerJob(jobName, GROUP_NAME);
+    }
+
+    public void pauseJob(String jobName) throws SchedulerException {
+        scheduler.pauseJob(jobName, GROUP_NAME);
+    }
+
+    public void resumeJob(String jobName) throws SchedulerException {
+        scheduler.resumeJob(jobName, GROUP_NAME);
+    }
+
+    public QuartzJob getJob(String jobName) {
+        Set results = kernel.listGBeans(new AbstractNameQuery(null, Collections.singletonMap("name", jobName), QuartzJob.class.getName()));
+        if(results.size() == 0) {
+            return null;
+        }
+        return (QuartzJob) kernel.getProxyManager().createProxy((AbstractName) results.iterator().next(), QuartzJob.class);
+    }
+
+    public void doStart() throws Exception {
+        StdSchedulerFactory factory = new StdSchedulerFactory();
+        if(threadPoolKey != null) {
+            Properties props = new Properties();
+            InputStream in = Scheduler.class.getResourceAsStream("quartz.properties");
+            props.load(in);
+            in.close();
+            for (Iterator it = props.keySet().iterator(); it.hasNext();) {
+                String key = (String) it.next();
+                if(key.startsWith("org.quartz.threadPool.")) {
+                    log.info("Ignoring thread property '"+key+"'");
+                    it.remove();
+                }
+            }
+            props.put("org.quartz.threadPool.class", "org.gplugins.quartz.QuartzThreadPool");
+            props.put("org.quartz.threadPool.poolID", threadPoolKey);
+            factory.initialize(props);
+        }
+        scheduler = factory.getScheduler();
+        scheduler.start();
+    }
+
+    public void doStop() throws Exception {
+        try {
+            scheduler.shutdown();
+        } catch (SchedulerException e) {
+            log.error("Quartz scheduler shutdown error", e);
+        }
+    }
+
+    public void doFail() {
+    }
+
+
+    public static final GBeanInfo GBEAN_INFO;
+
+    static {
+        GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic("Quartz Scheduler", QuartzSchedulerGBean.class);
+        infoFactory.addAttribute("kernel", Kernel.class, false, false);
+        infoFactory.addReference("ThreadPool", ThreadPool.class, "GBean");
+        infoFactory.addInterface(QuartzScheduler.class);
+        infoFactory.setConstructor(new String[]{"ThreadPool", "kernel"});
+        GBEAN_INFO = infoFactory.getBeanInfo();
+    }
+
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
+    }
+
+}

Added: geronimo/sandbox/plugins/quartz-scheduler/trunk/src/java/org/gplugins/quartz/QuartzThreadPool.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/plugins/quartz-scheduler/trunk/src/java/org/gplugins/quartz/QuartzThreadPool.java?rev=413549&view=auto
==============================================================================
--- geronimo/sandbox/plugins/quartz-scheduler/trunk/src/java/org/gplugins/quartz/QuartzThreadPool.java (added)
+++ geronimo/sandbox/plugins/quartz-scheduler/trunk/src/java/org/gplugins/quartz/QuartzThreadPool.java Sun Jun 11 17:03:22 2006
@@ -0,0 +1,80 @@
+/**
+ * Copyright 2006 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.gplugins.quartz;
+
+import java.util.Map;
+import java.util.HashMap;
+import org.apache.geronimo.system.threads.ThreadPool;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.quartz.SchedulerConfigException;
+
+
+/**
+ * A wrapper around a Geronimo thread pool for usage by Quartz.
+ *
+ * @version $Rev: 355877 $ $Date: 2005-12-10 21:48:27 -0500 (Sat, 10 Dec 2005) $
+ */
+public class QuartzThreadPool implements org.quartz.spi.ThreadPool {
+    private final static Log log = LogFactory.getLog(QuartzThreadPool.class);
+    static Map geronimoPools = new HashMap();
+
+    static String addPool(ThreadPool pool) {
+        synchronized(QuartzThreadPool.class) {
+            int count = geronimoPools.size();
+            String key = Integer.toString(count);
+            geronimoPools.put(key, pool);
+            return key;
+        }
+    }
+
+    private ThreadPool geronimoPool;
+    private String poolID;
+
+    public int getPoolSize() {
+        return geronimoPool.getPoolSize();
+    }
+
+    public void initialize() throws SchedulerConfigException {
+        log.info("Geronimo Quartz thread pool starting with Pool ID "+poolID);
+        geronimoPool = (ThreadPool) geronimoPools.get(poolID);
+        if(geronimoPool == null) {
+            throw new SchedulerConfigException("No Geronimo thread pool available ("+poolID+")!");
+        }
+    }
+
+    public boolean runInThread(Runnable runnable) {
+        try {
+            geronimoPool.execute("Quartz Scheduled Job", runnable);
+        } catch (InterruptedException e) {
+            log.error("Unable to complete schedule job", e);
+            return false;
+        }
+        return true;
+    }
+
+    public void shutdown(boolean b) {
+        geronimoPools.remove(poolID);
+    }
+
+    public String getPoolID() {
+        return poolID;
+    }
+
+    public void setPoolID(String poolID) {
+        this.poolID = poolID;
+    }
+}

Added: geronimo/sandbox/plugins/quartz-scheduler/trunk/src/resources/META-INF/geronimo-service.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/plugins/quartz-scheduler/trunk/src/resources/META-INF/geronimo-service.xml?rev=413549&view=auto
==============================================================================
--- geronimo/sandbox/plugins/quartz-scheduler/trunk/src/resources/META-INF/geronimo-service.xml (added)
+++ geronimo/sandbox/plugins/quartz-scheduler/trunk/src/resources/META-INF/geronimo-service.xml Sun Jun 11 17:03:22 2006
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module xmlns="http://geronimo.apache.org/xml/ns/deployment-1.1">
+    <environment>
+        <moduleId>
+            <groupId>gplugins</groupId>
+            <artifactId>quartz-scheduler</artifactId>
+            <version>0.1</version>
+            <type>car</type>
+        </moduleId>
+        <dependencies>
+            <dependency>
+                <groupId>geronimo</groupId>
+                <artifactId>rmi-naming</artifactId>
+                <type>car</type>
+            </dependency>
+            <dependency>
+                <groupId>opensymphony</groupId>
+                <artifactId>quartz</artifactId>
+                <type>jar</type>
+            </dependency>
+        </dependencies>
+    </environment>
+    <gbean name="QuartzScheduler" class="org.gplugins.quartz.QuartzSchedulerGBean">
+        <reference name="ThreadPool">
+            <name>DefaultThreadPool</name>
+        </reference>
+    </gbean>
+</module>
\ No newline at end of file



Mime
View raw message