Modified: 
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/startup/quartz/SimpleQuartzFactory.java
URL: 
http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/startup/quartz/SimpleQuartzFactory.java?rev=578664&r1=578663&r2=578664&view=diff
==============================================================================
--- 
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/startup/quartz/SimpleQuartzFactory.java
 (original)
+++ 
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/startup/quartz/SimpleQuartzFactory.java
 Sun Sep 23 22:39:08 2007
@@ -1,3 +1,22 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
 package org.apache.synapse.startup.quartz;
 
 import java.util.Iterator;
@@ -30,138 +49,141 @@
  */
 
 public class SimpleQuartzFactory implements StartupFactory {
-       public  final static QName JOB = new 
QName(XMLConfigConstants.SYNAPSE_NAMESPACE,
-                       "job");
-
-       private final static QName SIMPLE = new 
QName(XMLConfigConstants.SYNAPSE_NAMESPACE,
-                       "simpletrigger");
 
-       private final static QName CRON = new 
QName(XMLConfigConstants.SYNAPSE_NAMESPACE,
-                       "crontrigger");
+    public final static QName JOB
+            = new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "job");
 
-       private final static QName PROPERTY = new QName(
-                       XMLConfigConstants.SYNAPSE_NAMESPACE, "property");
-
-       private final static Log log = 
LogFactory.getLog(SimpleQuartzFactory.class);
-
-       public Startup createStartup(OMElement el) {
-               if (log.isDebugEnabled())
-                       log.debug("Creating SimpleQuartz startup");
-               if (el.getQName().equals(JOB)) {
-                       SimpleQuartz q = new SimpleQuartz();
-                       OMAttribute classAttr = el.getAttribute(new 
QName("class"));
-                       if (classAttr == null) {
-                               log.error("No class attribute on element. It is 
required");
-                               throw new SynapseException(
-                                               "Cannot create Quartz Startup - 
no class attribute");
-                       }
-                       // test if we can create the job?
-                       String classname =classAttr.getAttributeValue();
-                       
-                       // if no package specified then prepend 
"org.apache.synapse.startup.jobs"
-                       if (classname.indexOf('.')==-1) {
-                               classname = 
"org.apache.synapse.startup.jobs."+classname;
-                       }
-                       try {
-                               
getClass().getClassLoader().loadClass(classname).newInstance();
-                       }
-                       catch (Exception e) {
-                               throw new SynapseException("Failed to load job 
class "+ classname, e);
-                       }
-                       q.setJobClass(classname);
-                       // next sort out the property children
-
-                       Iterator it = el.getChildrenWithName(PROPERTY);
-                       while (it.hasNext()) {
-                               // simply store the properties for now - they 
will be loaded when the job is actually run 
-                               OMElement prop = (OMElement) it.next();
-                               if (PropertyHelper.isStaticProperty(prop)) {
-                                       q.addProperty(prop);
-
-                               } else {
-                                       throw new SynapseException(
-                                                       "job does not support 
dynamic properties");
-                               }
-                       }
-
-                       /* try to handle the simpletrigger approach */
-                       OMElement trigger = el.getFirstChildWithName(SIMPLE);
-                       if (trigger != null) {
-                               q.setSimple(true);
-                               OMAttribute repeatInterval = 
trigger.getAttribute(new QName(
-                                               "interval"));
-                               if (repeatInterval == null) {
-                                       log.error("interval attribute must be 
specified");
-                                       throw new SynapseException(
-                                                       "No interval attribute 
specified");
-                               }
-                               try {
-                                       
q.setInterval(Long.parseLong(repeatInterval
-                                                       .getAttributeValue()));
-                               } catch (Exception e) {
-                                       throw new SynapseException(
-                                                       "Failed to parse 
interval as long");
-                               }
-                               OMAttribute count = trigger.getAttribute(new 
QName("count"));
-                               if (count == null) {
-                                       // if no count set then forever must be 
set and set to true
-                                       OMAttribute forever = 
trigger.getAttribute(new QName(
-                                                       "forever"));
-
-                                       if (forever != null) {
-                                               String fValue = 
forever.getAttributeValue();
-                                               if 
(fValue.toLowerCase().charAt(0) == 't'
-                                                               || 
fValue.toLowerCase().charAt(0) == '1') {
-                                                       q.setCount(-1);
-                                               } else {
-                                                       throw new 
SynapseException(
-                                                                       "count 
must be set or forever='true'");
-                                               }
-                                       } else {
-                                               throw new SynapseException(
-                                                               "count must be 
set or forever='true'");
-                                       }
-                               } // else count is set
-                               else {
-                                       try {
-                                               
q.setCount(Integer.parseInt(count.getAttributeValue()));
-                                       } catch (Exception e) {
-                                               throw new SynapseException(
-                                                               "Failed to 
parse count as integer");
-                                       }
-                               }
-
-                       } else // should be cron trigger 
-                       {
-                               trigger = el.getFirstChildWithName(CRON);
-                               if (trigger == null ) {
-                                       log.error("neither cron nor 
simpletrigger are set");
-                                       throw new SynapseException("neither 
crontrigger nor simpletrigger child elements exist");
-                               }
-                               q.setSimple(false); // cron trigger
-                               OMAttribute expr = trigger.getAttribute(new 
QName("expression"));
-                               if (expr==null){ 
-                                       log.error("crontrigger element must 
have expression attribute");
-                                       throw new SynapseException("crontrigger 
element must have expression attribute");
-                               }
-                               q.setCron(expr.getAttributeValue());
-                       }
-
-                       return q;
-               } else {
-                       log.error("wrong QName!");
-                       return null;
-               }
-
-       }
-
-       public Class getSerializerClass() {
-               return SimpleQuartzSerializer.class;
-       }
+    private final static QName SIMPLE
+            = new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "simpletrigger");
 
-       public QName getTagQName() {
+    private final static QName CRON
+            = new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "crontrigger");
 
-               return JOB;
-       }
+    private final static QName PROPERTY
+            = new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "property");
+
+    private final static Log log = 
LogFactory.getLog(SimpleQuartzFactory.class);
+
+    public Startup createStartup(OMElement el) {
+        if (log.isDebugEnabled())
+            log.debug("Creating SimpleQuartz startup");
+        if (el.getQName().equals(JOB)) {
+            SimpleQuartz q = new SimpleQuartz();
+            OMAttribute classAttr = el.getAttribute(new QName("class"));
+            if (classAttr == null) {
+                log.error("No class attribute on element. It is required");
+                throw new SynapseException(
+                        "Cannot create Quartz Startup - no class attribute");
+            }
+            // test if we can create the job?
+            String classname = classAttr.getAttributeValue();
+
+            // if no package specified then prepend 
"org.apache.synapse.startup.jobs"
+            if (classname.indexOf('.') == -1) {
+                classname = "org.apache.synapse.startup.jobs." + classname;
+            }
+            try {
+                getClass().getClassLoader().loadClass(classname).newInstance();
+            }
+            catch (Exception e) {
+                throw new SynapseException("Failed to load job class " + 
classname, e);
+            }
+            q.setJobClass(classname);
+            // next sort out the property children
+
+            Iterator it = el.getChildrenWithName(PROPERTY);
+            while (it.hasNext()) {
+                // simply store the properties for now -
+                // they will be loaded when the job is actually run
+                OMElement prop = (OMElement) it.next();
+                if (PropertyHelper.isStaticProperty(prop)) {
+                    q.addProperty(prop);
+
+                } else {
+                    throw new SynapseException(
+                            "job does not support dynamic properties");
+                }
+            }
+
+            /* try to handle the simpletrigger approach */
+            OMElement trigger = el.getFirstChildWithName(SIMPLE);
+            if (trigger != null) {
+                q.setSimple(true);
+                OMAttribute repeatInterval = trigger.getAttribute(new QName(
+                        "interval"));
+                if (repeatInterval == null) {
+                    log.error("interval attribute must be specified");
+                    throw new SynapseException(
+                            "No interval attribute specified");
+                }
+                try {
+                    q.setInterval(Long.parseLong(repeatInterval
+                            .getAttributeValue()));
+                } catch (Exception e) {
+                    throw new SynapseException(
+                            "Failed to parse interval as long");
+                }
+                OMAttribute count = trigger.getAttribute(new QName("count"));
+                if (count == null) {
+                    // if no count set then forever must be set and set to true
+                    OMAttribute forever = trigger.getAttribute(new QName(
+                            "forever"));
+
+                    if (forever != null) {
+                        String fValue = forever.getAttributeValue();
+                        if (fValue.toLowerCase().charAt(0) == 't'
+                                || fValue.toLowerCase().charAt(0) == '1') {
+                            q.setCount(-1);
+                        } else {
+                            throw new SynapseException(
+                                    "count must be set or forever='true'");
+                        }
+                    } else {
+                        throw new SynapseException(
+                                "count must be set or forever='true'");
+                    }
+                } // else count is set
+                else {
+                    try {
+                        
q.setCount(Integer.parseInt(count.getAttributeValue()));
+                    } catch (Exception e) {
+                        throw new SynapseException(
+                                "Failed to parse count as integer");
+                    }
+                }
+
+            } else // should be cron trigger
+            {
+                trigger = el.getFirstChildWithName(CRON);
+                if (trigger == null) {
+                    log.error("neither cron nor simpletrigger are set");
+                    throw new SynapseException(
+                            "neither crontrigger nor simpletrigger child 
elements exist");
+                }
+                q.setSimple(false); // cron trigger
+                OMAttribute expr = trigger.getAttribute(new 
QName("expression"));
+                if (expr == null) {
+                    log.error("crontrigger element must have expression 
attribute");
+                    throw new SynapseException(
+                            "crontrigger element must have expression 
attribute");
+                }
+                q.setCron(expr.getAttributeValue());
+            }
+
+            return q;
+        } else {
+            log.error("wrong QName!");
+            return null;
+        }
+
+    }
+
+    public Class getSerializerClass() {
+        return SimpleQuartzSerializer.class;
+    }
+
+    public QName getTagQName() {
+        return JOB;
+    }
 
 }

Modified: 
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/startup/quartz/SimpleQuartzSerializer.java
URL: 
http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/startup/quartz/SimpleQuartzSerializer.java?rev=578664&r1=578663&r2=578664&view=diff
==============================================================================
--- 
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/startup/quartz/SimpleQuartzSerializer.java
 (original)
+++ 
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/startup/quartz/SimpleQuartzSerializer.java
 Sun Sep 23 22:39:08 2007
@@ -1,3 +1,22 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
 package org.apache.synapse.startup.quartz;
 
 import java.util.Iterator;
@@ -13,32 +32,41 @@
 import org.apache.synapse.SynapseException;
 
 public class SimpleQuartzSerializer implements StartupSerializer {
-       
-       public void serializeStartup(OMElement parent, Startup s) {
-               if (!(s instanceof SimpleQuartz)) throw new 
SynapseException("called SimpleQuartzSerializer on some other kind of 
startup"+s.getClass().getName());
-               SimpleQuartz sq = (SimpleQuartz)s;
-               OMFactory fac = parent.getOMFactory();
-               OMNamespace nullNS = fac.createOMNamespace("", "");
-               OMElement job = fac.createOMElement(SimpleQuartzFactory.JOB,  
parent);
-               job.addAttribute("class", sq.getJobClass(), nullNS);
-               if (sq.isSimple()) {
-                       OMElement el = fac.createOMElement(new 
QName(XMLConfigConstants.SYNAPSE_NAMESPACE,"simpletrigger"), job);
-                       if (sq.getCount()==-1) {
-                               el.addAttribute("forever","true",nullNS);
-                       } else {
-                               
el.addAttribute("count",Integer.toString(sq.getCount()),nullNS);
-                       }
-                       el.addAttribute("interval", 
Long.toString(sq.getInterval()), nullNS);
-               } else {
-                       OMElement el = fac.createOMElement(new 
QName(XMLConfigConstants.SYNAPSE_NAMESPACE,"crontrigger"), job);
-                       el.addAttribute("expression", sq.getCron(), nullNS);
-               }
-               Iterator it = sq.getProperties().iterator();
-               while (it.hasNext()) {
-                       OMElement prop = (OMElement)it.next();
-                       job.addChild(prop.cloneOMElement());
-               }
-               
-       }
+
+    public void serializeStartup(OMElement parent, Startup s) {
+
+        if (!(s instanceof SimpleQuartz)) {
+            throw new SynapseException("called SimpleQuartzSerializer on some 
other " +
+                    "kind of startup" + s.getClass().getName());
+        }
+
+        SimpleQuartz sq = (SimpleQuartz) s;
+        OMFactory fac = parent.getOMFactory();
+        OMNamespace nullNS = fac.createOMNamespace("", "");
+        OMNamespace synNS = 
fac.createOMNamespace(XMLConfigConstants.SYNAPSE_NAMESPACE, "syn");
+
+        OMElement job = fac.createOMElement("job", synNS, parent);
+        job.addAttribute("class", sq.getJobClass(), nullNS);
+
+        if (sq.isSimple()) {
+            OMElement el = fac.createOMElement("simpletrigger", synNS, job);
+            if (sq.getCount() == -1) {
+                el.addAttribute("forever", "true", nullNS);
+            } else {
+                el.addAttribute("count", Integer.toString(sq.getCount()), 
nullNS);
+            }
+            el.addAttribute("interval", Long.toString(sq.getInterval()), 
nullNS);
+        } else {
+            OMElement el = fac.createOMElement("crontrigger", synNS, job);
+            el.addAttribute("expression", sq.getCron(), nullNS);
+        }
+
+        Iterator it = sq.getProperties().iterator();
+        while (it.hasNext()) {
+            OMElement prop = (OMElement) it.next();
+            job.addChild(prop.cloneOMElement());
+        }
+
+    }
 
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to