Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 21344 invoked from network); 10 Jun 2006 23:16:14 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 10 Jun 2006 23:16:14 -0000 Received: (qmail 27820 invoked by uid 500); 10 Jun 2006 23:16:14 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 27738 invoked by uid 500); 10 Jun 2006 23:16:13 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 27727 invoked by uid 99); 10 Jun 2006 23:16:13 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 10 Jun 2006 16:16:13 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS X-Spam-Check-By: apache.org Received: from [192.87.106.226] (HELO ajax.apache.org) (192.87.106.226) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 10 Jun 2006 16:16:12 -0700 Received: from ajax.apache.org (localhost [127.0.0.1]) by ajax.apache.org (Postfix) with ESMTP id 4FE8FD49DB for ; Sun, 11 Jun 2006 00:15:51 +0100 (BST) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Apache Wiki To: scm@geronimo.apache.org Date: Sat, 10 Jun 2006 23:15:51 -0000 Message-ID: <20060610231551.1135.34743@ajax.apache.org> Subject: [Geronimo Wiki] Update of "Advanced Plugin Sample" by AaronMulder X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Dear Wiki user, You have subscribed to a wiki page or wiki category on "Geronimo Wiki" for change notification. The following page has been changed by AaronMulder: http://wiki.apache.org/geronimo/Advanced_Plugin_Sample ------------------------------------------------------------------------------ }}} === Quartz Job Deployer === + + The deployer has a couple main responsibilites: + * Check whether this deployer can deploy the requested module + * Confirm that the deployment plan is valid + * Generate a Module ID for the deployment + * Create GBeans that will be the "deployed" form of the module + + Generally, this can be reduced to "input XML, output either null or Module ID plus GBeans". + + Here's the deployer: {{{ /** @@ -914, +924 @@ * @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 static final QName JOBS_QNAME = JobsDocument.type.getDocumentElementName(); private final Environment defaultEnvironment; private final Collection repositories; @@ -956, +966 @@ XmlCursor cursor = xmlObject.newCursor(); try { cursor.toFirstChild(); - if (!SERVICE_QNAME.equals(cursor.getName())) { + if (!JOBS_QNAME.equals(cursor.getName())) { return null; } } finally { @@ -1105, +1115 @@ } } }}} + + One thing to notice is how the Quartz Job Deployment Plan is connected to the Quartz Job Deployer. It is based on the schema namespace ({{{http://geronimo.apache.org/xml/ns/plugins/quartz-0.1}}}), and the fact that the plan was in the right place for us to find to begin with. For all the deployers we've done so far, we use XMLBeans to create JavaBeans connected to the schema. Then we use XMLBeans to read in the deployment plan, and check whether it's the type this deployer expects. Here's an excerpt from the deployer above: + {{{ + 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; + } + }}} + + This part establishes that we can load a plan at all. If not, it either means no plan was provided, or the plan is in the module at a different location (e.g. {{{WEB-INF/geronimo-web.xml}}}, meaning it's definitely not a Quartz job). Either way, this deployer can't handle the archive so we return null. + + If we get past that, it means that we found a plan. So we go on to check the type: + {{{ + XmlCursor cursor = xmlObject.newCursor(); + try { + cursor.toFirstChild(); + if (!SERVICE_QNAME.equals(cursor.getName())) { + return null; + } + } finally { + cursor.dispose(); + } + }}} + The constant JOBS_QNAME is a reference to the schema namespace of the first element in the file. If it's the one we're looking for, great. Otherwise, even though we found a plan, it was not the right *type* of plan (e.g. someone passed a web plan on the command line), so this deployer can't handle it. + + If we get past those two checks (plan present and plan has correct namespace) then we assume that it really was meant for this deployer to handle, and for other kinds of errors (syntax error in plan, etc.) we throw a deployment exception. Some of the deployers have additional logic to silently upgrade old-format plans to current-format plans, but this one does not. === Geronimo Plan for Quartz Deployer ===