[MMBASE CVS] applications/crontab/src/org/mmbase/applications/crontab/builders NodeCronEntry.java CronJobs.java

2009-04-01 Thread Michiel Meeuwissen
Update of 
/var/cvs/applications/crontab/src/org/mmbase/applications/crontab/builders
In directory james.mmbase.org:/tmp/cvs-serv7341/builders

Modified Files:
NodeCronEntry.java CronJobs.java 
Log Message:
javadoc, MMB-1797


See also: 
http://cvs.mmbase.org/viewcvs/applications/crontab/src/org/mmbase/applications/crontab/builders
See also: http://www.mmbase.org/jira/browse/MMB-1797


Index: NodeCronEntry.java
===
RCS file: 
/var/cvs/applications/crontab/src/org/mmbase/applications/crontab/builders/NodeCronEntry.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- NodeCronEntry.java  9 Dec 2008 13:38:10 -   1.6
+++ NodeCronEntry.java  1 Apr 2009 09:20:49 -   1.7
@@ -15,9 +15,11 @@
 import org.mmbase.util.logging.*;
 
 /**
+ * CronEntries defined by nodes of the type 'cronjobs' store several aspects 
of the cron entries in
+ * fields. {...@link #isActive} is implemented using related 'mmservers' 
objects.
  *
  * @author Michiel Meeuwissen
- * @version $Id: NodeCronEntry.java,v 1.6 2008/12/09 13:38:10 michiel Exp $
+ * @version $Id: NodeCronEntry.java,v 1.7 2009/04/01 09:20:49 michiel Exp $
  * @since MMBase-1.8.6
  */
 
@@ -58,8 +60,12 @@
 }
 
 @Override public boolean isActive() {
-NodeIterator servers = 
getNode().getRelatedNodes(mmservers).nodeIterator();
-if (! servers.hasNext()) return true;
+Node jobNode = getNode();
+NodeIterator servers = 
jobNode.getRelatedNodes(mmservers).nodeIterator();
+if (! servers.hasNext() 
+! 
true.equals(jobNode.getNodeManager().getProperty(CronJobs.MMSERVERS_REQUIRED)))
 {
+return true;
+}
 
 String machineName = 
org.mmbase.module.core.MMBaseContext.getMachineName();
 while (servers.hasNext()) {


Index: CronJobs.java
===
RCS file: 
/var/cvs/applications/crontab/src/org/mmbase/applications/crontab/builders/CronJobs.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- CronJobs.java   9 Dec 2008 13:38:49 -   1.12
+++ CronJobs.java   1 Apr 2009 09:20:49 -   1.13
@@ -20,12 +20,14 @@
  *  The builder also starts the CronDeamon. on startup the list of cronjobs is 
loaded into memory.
  *  bThe builder uses the bridge to get a cloud using class security./b
  * @author Kees Jongenburger
- * @version $Id: CronJobs.java,v 1.12 2008/12/09 13:38:49 michiel Exp $
+ * @version $Id: CronJobs.java,v 1.13 2009/04/01 09:20:49 michiel Exp $
  */
 public class CronJobs extends MMObjectBuilder  {
 
 private static final Logger log = 
Logging.getLoggerInstance(CronJobs.class);
 
+public static String MMSERVERS_REQUIRED = RelatedMMServersRequired;
+
 /**
  * Adds all the crontEntries to the CronDaemon
  */
___
Cvs mailing list
Cvs@lists.mmbase.org
http://lists.mmbase.org/mailman/listinfo/cvs


[MMBASE CVS] applications/crontab/src/org/mmbase/applications/crontab/builders NodeCronEntry.java CronJobs.java

2008-07-14 Thread Michiel Meeuwissen
Update of 
/var/cvs/applications/crontab/src/org/mmbase/applications/crontab/builders
In directory james.mmbase.org:/tmp/cvs-serv7169/builders

Modified Files:
  Tag: MMBase-1_8
CronJobs.java 
Added Files:
  Tag: MMBase-1_8
NodeCronEntry.java 
Log Message:
  MMB-1677


See also: 
http://cvs.mmbase.org/viewcvs/applications/crontab/src/org/mmbase/applications/crontab/builders
See also: http://www.mmbase.org/jira/browse/MMB-1677


NodeCronEntry.java is new



Index: CronJobs.java
===
RCS file: 
/var/cvs/applications/crontab/src/org/mmbase/applications/crontab/builders/CronJobs.java,v
retrieving revision 1.2.2.2
retrieving revision 1.2.2.3
diff -u -b -r1.2.2.2 -r1.2.2.3
--- CronJobs.java   17 Nov 2006 13:06:59 -  1.2.2.2
+++ CronJobs.java   14 Jul 2008 13:43:54 -  1.2.2.3
@@ -7,6 +7,7 @@
  */
 package org.mmbase.applications.crontab.builders;
 
+import java.util.*;
 import org.mmbase.applications.crontab.*;
 import org.mmbase.bridge.*;
 import org.mmbase.module.core.*;
@@ -49,7 +50,7 @@
 Node node = nodeIterator.nextNode();
 CronEntry entry = null;
 try {
-entry = createCronEntry(node);
+entry = new NodeCronEntry(node);
 NodeList servers = node.getRelatedNodes(mmservers);
 if (servers.size()  0) {
 String machineName = MMBase.getMMBase().getMachineName();
@@ -74,7 +75,7 @@
 cronDaemon.add(entry);
 }
 } catch (Exception e) {
-log.warn(did not add cronjob with id  + node.getNumber() +  
because of error  + e.getMessage());
+log.warn(did not add cronjob with id  + node.getNumber() +  
because of error  + e.getMessage(), e);
 }
 }
 }
@@ -87,7 +88,7 @@
 try {
 if (cronDaemon != null) {
Node node = getCloud().getNode(number);
-cronDaemon.add(createCronEntry(node));
+cronDaemon.add(new NodeCronEntry(node));
 }
 } catch (Exception e) {
 throw new RuntimeException(error while creating cron entry with 
id  + number +  error  + e.getMessage(), e);
@@ -99,17 +100,32 @@
  * Commits a cronjob to the database.
  * On commit of a cronjob, the job is first removed from the cronDeamon 
and a new cronEntry is created and added to the CronDaemon.
  */
-public boolean commit(MMObjectNode objectNodenode) {
-boolean retval = super.commit(objectNodenode);
-Node node = getCloud().getNode(objectNodenode.getNumber());
+public boolean commit(MMObjectNode node) {
+Set changed = node.getChanged();
+boolean retval = super.commit(node);
 CronEntry entry = cronDaemon.getCronEntry( + node.getNumber());
 if (entry == null) {
 log.warn(cron entry with ID  + node.getNumber() +  was not 
found. this usualy means it was invalid);
 } else {
+if (entry instanceof NodeCronEntry) {
+if (changed.contains(classfile) ||
+changed.contains(name) ||
+changed.contains(type)) {
+log.warn(Changed fields  + changed);
 cronDaemon.remove(entry);
+} else {
+log.warn(Ignored  + node);
+return retval;
+}
+} else {
+log.warn(How come,  + entry +  is not a node-entry);
+cronDaemon.remove(entry);
+}
 }
 try {
-cronDaemon.add(createCronEntry(node));
+log.info(Replacing cronentry  + entry);
+Node n = getCloud().getNode(node.getNumber());
+cronDaemon.add(new NodeCronEntry(n));
 } catch (Exception e) {
 throw new RuntimeException(error while creating cron entry with 
id  + node.getNumber() +  error  + e.getMessage());
 }
@@ -128,9 +144,7 @@
 }
 }
 
-private CronEntry createCronEntry(Node node) throws Exception {
-return new CronEntry( + node.getNumber(), 
node.getStringValue(crontime), node.getStringValue(name), 
node.getStringValue(classfile), 
node.getStringValue(config),node.getIntValue(type));
-}
+
 
 private Cloud getCloud() {
 return LocalContext.getCloudContext().getCloud(mmbase);
___
Cvs mailing list
Cvs@lists.mmbase.org
http://lists.mmbase.org/mailman/listinfo/cvs


[MMBASE CVS] applications/crontab/src/org/mmbase/applications/crontab/builders NodeCronEntry.java CronJobs.java

2008-07-14 Thread Michiel Meeuwissen
Update of 
/var/cvs/applications/crontab/src/org/mmbase/applications/crontab/builders
In directory james.mmbase.org:/tmp/cvs-serv7427/builders

Modified Files:
CronJobs.java 
Added Files:
NodeCronEntry.java 
Log Message:
  MMB-1677


See also: 
http://cvs.mmbase.org/viewcvs/applications/crontab/src/org/mmbase/applications/crontab/builders
See also: http://www.mmbase.org/jira/browse/MMB-1677




Index: CronJobs.java
===
RCS file: 
/var/cvs/applications/crontab/src/org/mmbase/applications/crontab/builders/CronJobs.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- CronJobs.java   5 Feb 2007 14:39:10 -   1.5
+++ CronJobs.java   14 Jul 2008 13:51:36 -  1.6
@@ -11,13 +11,14 @@
 import org.mmbase.bridge.*;
 import org.mmbase.module.core.*;
 import org.mmbase.util.logging.*;
+import java.util.*;
 
 /**
  * Builder that holds cronjobs and listens to changes.
  *  The builder also starts the CronDeamon. on startup the list of cronjobs is 
loaded into memory.
  *  bThe builder uses the bridge to get a cloud using class security./b 
  * @author Kees Jongenburger
- * @version $Id: CronJobs.java,v 1.5 2007/02/05 14:39:10 michiel Exp $
+ * @version $Id: CronJobs.java,v 1.6 2008/07/14 13:51:36 michiel Exp $
  */
 public class CronJobs extends MMObjectBuilder implements Runnable {
 
@@ -50,7 +51,7 @@
 Node node = nodeIterator.nextNode();
 CronEntry entry = null;
 try {
-entry = createCronEntry(node);
+entry = new NodeCronEntry(node);
 NodeList servers = node.getRelatedNodes(mmservers);
 if (servers.size()  0) {
 String machineName = MMBase.getMMBase().getMachineName();
@@ -88,7 +89,7 @@
 try {
 if (cronDaemon != null) {
Node node = getCloud().getNode(number);
-cronDaemon.add(createCronEntry(node));
+cronDaemon.add(new NodeCronEntry(node));
 }
 } catch (Exception e) {
 throw new RuntimeException(error while creating cron entry with 
id  + number +  error  + e.getMessage(), e);
@@ -100,17 +101,32 @@
  * Commits a cronjob to the database.
  * On commit of a cronjob, the job is first removed from the cronDeamon 
and a new cronEntry is created and added to the CronDaemon.
  */
-public boolean commit(MMObjectNode objectNodenode) {
-boolean retval = super.commit(objectNodenode);
-Node node = getCloud().getNode(objectNodenode.getNumber());
+public boolean commit(MMObjectNode node) {
+SetString changed = node.getChanged();
+boolean retval = super.commit(node);
 CronEntry entry = cronDaemon.getCronEntry( + node.getNumber());
 if (entry == null) {
 log.warn(cron entry with ID  + node.getNumber() +  was not 
found. this usualy means it was invalid);
 } else {
+if (entry instanceof NodeCronEntry) {
+if (changed.contains(classfile) ||
+changed.contains(name) ||
+changed.contains(type)) {
+log.debug(Changed fields  + changed);
 cronDaemon.remove(entry);
+} else {
+log.debug(Ignored  + node);
+return retval;
+}
+} else {
+log.warn(How come,  + entry +  is not a node-entry);
+cronDaemon.remove(entry);
+}
 }
 try {
-cronDaemon.add(createCronEntry(node));
+log.debug(Replacing cronentry  + entry);
+Node n = getCloud().getNode(node.getNumber());
+cronDaemon.add(new NodeCronEntry(n));
 } catch (Exception e) {
 throw new RuntimeException(error while creating cron entry with 
id  + node.getNumber() +  error  + e.getMessage());
 }
@@ -129,15 +145,6 @@
 }
 }
 
-private CronEntry createCronEntry(Node node) throws Exception {
-// should consider getRelatedNodes(mmservers) for the last argument 
of CronEntry
-return new CronEntry( + node.getNumber(),
- node.getStringValue(crontime), 
- node.getStringValue(name), 
- node.getStringValue(classfile), 
- node.getStringValue(config),
- node.getIntValue(type));
-}
 
 private Cloud getCloud() {
 return LocalContext.getCloudContext().getCloud(mmbase);
___
Cvs mailing list
Cvs@lists.mmbase.org
http://lists.mmbase.org/mailman/listinfo/cvs