Author: ruwan
Date: Mon Oct 15 03:37:39 2007
New Revision: 584722

URL: http://svn.apache.org/viewvc?rev=584722&view=rev
Log:
adding the task <trigger once=true/> support

Modified:
    
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/CacheMediatorSerializer.java
    
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/startup/quartz/SimpleQuartzFactory.java
    
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/startup/quartz/SimpleQuartzSerializer.java

Modified: 
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/CacheMediatorSerializer.java
URL: 
http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/CacheMediatorSerializer.java?rev=584722&r1=584721&r2=584722&view=diff
==============================================================================
--- 
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/CacheMediatorSerializer.java
 (original)
+++ 
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/CacheMediatorSerializer.java
 Mon Oct 15 03:37:39 2007
@@ -1,103 +1,103 @@
-/*
- *  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.config.xml;
-
-import org.apache.axiom.om.OMElement;
-import org.apache.synapse.Mediator;
-import org.apache.synapse.mediators.builtin.CacheMediator;
-
-/**
- * Serializes the Cache mediator to the XML configuration specified
- *
- * &lt;cache (id="string")? hashGenerator="class" scope="string" 
timeout="mili-seconds"&gt;
- *  &lt;onCacheHit (sequence="key")?&gt;
- *   (mediator)+
- *  &lt;/onCacheHit&gt;
- *  &lt;implementation type=(memory | disk) maxSize="int"/&gt;
- * &lt;/cache&gt;
- */
-public class CacheMediatorSerializer extends AbstractMediatorSerializer {
-
-    public OMElement serializeMediator(OMElement parent, Mediator m) {
-
-        if (!(m instanceof CacheMediator)) {
-            handleException("Unsupported mediator passed in for serialization 
: " + m.getType());
-        }
-        CacheMediator mediator = (CacheMediator) m;
-        OMElement cache = fac.createOMElement("cache", synNS);
-        saveTracingState(cache, mediator);
-
-        if (mediator.getId() != null) {
-            cache.addAttribute(fac.createOMAttribute("id", nullNS, 
mediator.getId()));
-        }
-
-        if (mediator.getDigestGenerator() != null) {
-            cache.addAttribute(fac.createOMAttribute("hashGenerator", nullNS,
-                mediator.getDigestGenerator().getClass().getName()));
-        }
-
-        if (mediator.getScope() != null) {
-            cache.addAttribute(fac.createOMAttribute("scope", nullNS, 
mediator.getScope()));
-        }
-
-        if (mediator.getTimeout() != 0) {
-            cache.addAttribute(
-                fac.createOMAttribute("timeout", nullNS, 
Long.toString(mediator.getTimeout())));
-        }
-
-        if (mediator.getOnCacheHitRef() != null) {
-            OMElement onCacheHit = fac.createOMElement("onCacheHit", synNS);
-            onCacheHit.addAttribute(
-                fac.createOMAttribute("sequence", nullNS, 
mediator.getOnCacheHitRef()));
-            cache.addChild(onCacheHit);
-        } else if (mediator.getOnCacheHitSequence() != null) {
-            OMElement onCacheHit = fac.createOMElement("onCacheHit", synNS);
-            new SequenceMediatorSerializer().serializeChildren(
-                onCacheHit, mediator.getOnCacheHitSequence().getList());
-            cache.addChild(onCacheHit);
-        }
-
-        if (mediator.getInMemoryCacheSize() != 0) {
-            OMElement implElem = fac.createOMElement("implementation", synNS);
-            implElem.addAttribute(fac.createOMAttribute("type", nullNS, 
"memory"));
-            implElem.addAttribute(fac.createOMAttribute(
-                "maxSize", nullNS, 
Integer.toString(mediator.getInMemoryCacheSize())));
-            cache.addChild(implElem);
-        }
-        
-        if (mediator.getDiskCacheSize() != 0) {
-            OMElement implElem = fac.createOMElement("implementation", synNS);
-            implElem.addAttribute(fac.createOMAttribute("type", nullNS, 
"disk"));
-            implElem.addAttribute(fac.createOMAttribute(
-                "maxSize", nullNS, 
Integer.toString(mediator.getDiskCacheSize())));
-            cache.addChild(implElem);
-        }
-
-        if (parent != null) {
-            parent.addChild(cache);
-        }
-
-        return cache;
-    }
-
-    public String getMediatorClassName() {
-        return CacheMediator.class.getName();
-    }
-}
+/*
+ *  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.config.xml;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.synapse.Mediator;
+import org.apache.synapse.mediators.builtin.CacheMediator;
+
+/**
+ * Serializes the Cache mediator to the XML configuration specified
+ *
+ * &lt;cache (id="string")? hashGenerator="class" scope="string" 
timeout="mili-seconds"&gt;
+ *  &lt;onCacheHit (sequence="key")?&gt;
+ *   (mediator)+
+ *  &lt;/onCacheHit&gt;
+ *  &lt;implementation type=(memory | disk) maxSize="int"/&gt;
+ * &lt;/cache&gt;
+ */
+public class CacheMediatorSerializer extends AbstractMediatorSerializer {
+
+    public OMElement serializeMediator(OMElement parent, Mediator m) {
+
+        if (!(m instanceof CacheMediator)) {
+            handleException("Unsupported mediator passed in for serialization 
: " + m.getType());
+        }
+        CacheMediator mediator = (CacheMediator) m;
+        OMElement cache = fac.createOMElement("cache", synNS);
+        saveTracingState(cache, mediator);
+
+        if (mediator.getId() != null) {
+            cache.addAttribute(fac.createOMAttribute("id", nullNS, 
mediator.getId()));
+        }
+
+        if (mediator.getDigestGenerator() != null) {
+            cache.addAttribute(fac.createOMAttribute("hashGenerator", nullNS,
+                mediator.getDigestGenerator().getClass().getName()));
+        }
+
+        if (mediator.getScope() != null) {
+            cache.addAttribute(fac.createOMAttribute("scope", nullNS, 
mediator.getScope()));
+        }
+
+        if (mediator.getTimeout() != 0) {
+            cache.addAttribute(
+                fac.createOMAttribute("timeout", nullNS, 
Long.toString(mediator.getTimeout())));
+        }
+
+        if (mediator.getOnCacheHitRef() != null) {
+            OMElement onCacheHit = fac.createOMElement("onCacheHit", synNS);
+            onCacheHit.addAttribute(
+                fac.createOMAttribute("sequence", nullNS, 
mediator.getOnCacheHitRef()));
+            cache.addChild(onCacheHit);
+        } else if (mediator.getOnCacheHitSequence() != null) {
+            OMElement onCacheHit = fac.createOMElement("onCacheHit", synNS);
+            new SequenceMediatorSerializer().serializeChildren(
+                onCacheHit, mediator.getOnCacheHitSequence().getList());
+            cache.addChild(onCacheHit);
+        }
+
+        if (mediator.getInMemoryCacheSize() != 0) {
+            OMElement implElem = fac.createOMElement("implementation", synNS);
+            implElem.addAttribute(fac.createOMAttribute("type", nullNS, 
"memory"));
+            implElem.addAttribute(fac.createOMAttribute(
+                "maxSize", nullNS, 
Integer.toString(mediator.getInMemoryCacheSize())));
+            cache.addChild(implElem);
+        }
+        
+        if (mediator.getDiskCacheSize() != 0) {
+            OMElement implElem = fac.createOMElement("implementation", synNS);
+            implElem.addAttribute(fac.createOMAttribute("type", nullNS, 
"disk"));
+            implElem.addAttribute(fac.createOMAttribute(
+                "maxSize", nullNS, 
Integer.toString(mediator.getDiskCacheSize())));
+            cache.addChild(implElem);
+        }
+
+        if (parent != null) {
+            parent.addChild(cache);
+        }
+
+        return cache;
+    }
+
+    public String getMediatorClassName() {
+        return CacheMediator.class.getName();
+    }
+}

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=584722&r1=584721&r2=584722&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
 Mon Oct 15 03:37:39 2007
@@ -103,8 +103,14 @@
                     }
                 }
 
+                OMAttribute once = trigger.getAttribute(new QName("once"));
+                if (once != null && 
Boolean.TRUE.toString().equals(once.getAttributeValue())) {
+                    q.setCount(1);
+                    q.setInterval(1);
+                }
+
                 OMAttribute repeatInterval = trigger.getAttribute(new 
QName("interval"));
-                if (repeatInterval == null && q.getCount() > 0) {
+                if (repeatInterval == null && q.getCount() > 1) {
                     handleException("Trigger seems to be " +
                         "a simple trigger, but no interval specified");
                 } else if (repeatInterval != null && 
repeatInterval.getAttributeValue() != null) {
@@ -117,8 +123,8 @@
 
                 OMAttribute expr = trigger.getAttribute(new QName("cron"));
                 if (expr == null && q.getInterval() == 0) {
-                    handleException("Trigger syntax error : " +
-                        "trigger do not caontain simple nor cron trigger 
attributes");
+                    q.setCount(1);
+                    q.setInterval(1);
                 } else if (expr != null && q.getInterval() > 0) {
                     handleException("Trigger syntax error : " +
                         "both cron and simple trigger attributes are present");
@@ -127,8 +133,8 @@
                 }
 
             } else {
-                handleException("Trigger is missing for the task "
-                    + el.getAttributeValue(new QName("name")));
+                q.setCount(1);
+                q.setInterval(1);
             }
 
             return q;

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=584722&r1=584721&r2=584722&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
 Mon Oct 15 03:37:39 2007
@@ -52,18 +52,19 @@
         OMElement job = fac.createOMElement("task", synNS, parent);
         job.addAttribute("class", sq.getJobClass(), nullNS);
 
-
         OMElement el = fac.createOMElement("trigger", synNS, job);
-        if (sq.getCount() != -1) {
-            el.addAttribute("count", Integer.toString(sq.getCount()), nullNS);
-        }
-        
-        if (sq.getInterval() != 0) {
-            el.addAttribute("interval", Long.toString(sq.getInterval()), 
nullNS);
-        }
-
-        if (sq.getCron() != null) {
+        if (sq.getInterval() == 1 && sq.getCount() == 1) {
+            el.addAttribute("once", "true", nullNS);
+        } else if (sq.getCron() != null) {
             el.addAttribute("cron", sq.getCron(), nullNS);
+        } else {
+            if (sq.getCount() != -1) {
+                el.addAttribute("count", Integer.toString(sq.getCount()), 
nullNS);
+            }
+
+            if (sq.getInterval() != 0) {
+                el.addAttribute("interval", Long.toString(sq.getInterval()), 
nullNS);
+            }
         }
         
         for (Object o : sq.getProperties()) {



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

Reply via email to