
|
If you were logged in you would be able to see more operations.
|
|
|
|
|
| Component/s: |
None
|
| Affects Version/s: |
1.4.2
|
| Fix Version/s: |
1.4.3
|
|
|
File Attachments:
|
1.
JobInitializationPlugin.patch (4 kb)
|
|
Environment:
|
weblogic 6.1 / Windows XP / JDK 1.3.1
|
|
Issue Links:
|
Duplicate
|
|
|
|
This issue is duplicated by:
|
|
QUARTZ-68
JobInitializationPlugin: jobs.xml in ...
|
|
|
|
Related
|
|
|
|
This issue is related to:
|
|
QUARTZ-67
Typo in org.quartz.plugins.xml.JobIni...
|
|
|
|
|
|
|
If I specify the filename for the JobInitializationPlugin rather than the full path, the file will get found and loaded correctly from the classpath by the plugin, but will not be found by the FileScanJob because it doesn't also search the classpath.
I modified my copy of the JobInitializationPlugin to pass the file path to the FileScanJob, attached is a patch with my changes in case anyone should happen to want it. Apologies if this is already known, I didn't see an open bug matching this description in the queue.
P.S. I'm just trying out quartz for the first time, and I think it is really sweet, nice work!
Index: JobInitializationPlugin.java
===================================================================
RCS file: /cvsroot/quartz/Quartz/src/java/plugins/org/quartz/plugins/xml/JobInitializationPlugin.java,v
retrieving revision 1.11
diff -u -p -r1.11 JobInitializationPlugin.java
--- JobInitializationPlugin.java 31 Jul 2004 22:51:51 -0000 1.11
+++ JobInitializationPlugin.java 6 Sep 2004 21:23:48 -0000
@@ -29,6 +29,7 @@ import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Date;
+import java.net.URL;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -72,6 +73,8 @@ public class JobInitializationPlugin imp
private String fileName = JobSchedulingDataProcessor.QUARTZ_XML_FILE_NAME;
+ private String filePath = null;
+
private boolean validating = true;
private boolean validatingSchema = true;
@@ -246,7 +249,7 @@ public class JobInitializationPlugin imp
this.name = name;
this.scheduler = scheduler;
- getLog().info("Registering Quartz Job Initiazation Plug-in.");
+ getLog().info("Registering Quartz Job Initialization Plug-in.");
findFile();
@@ -262,7 +265,7 @@ public class JobInitializationPlugin imp
"JobInitializationPlugin",
FileScanJob.class);
job.setVolatility(true);
- job.getJobDataMap().put(FileScanJob.FILE_NAME, getFileName());
+ job.getJobDataMap().put(FileScanJob.FILE_NAME, getFilePath());
job.getJobDataMap().put(FileScanJob.FILE_SCAN_LISTENER_NAME, "JobInitializationPlugin_"+name);
scheduler.getContext().put("JobInitializationPlugin_"+name, this);
@@ -274,26 +277,34 @@ public class JobInitializationPlugin imp
}
}
+ private String getFilePath() throws SchedulerException {
+ if(this.filePath == null) {
+ findFile();
+ }
+ return this.filePath;
+ }
+
/**
*
*/
private void findFile() throws SchedulerException {
java.io.InputStream f = null;
- File file = new File(getFileName());
- if (file != null && file.exists()) { // files in filesystem
- try {
- f = new java.io.FileInputStream(file);
- }
- catch (FileNotFoundException e) {
+ File file = new File(getFileName()); // files in filesystem
+ if (file == null || !file.exists()) {
+ // files in classpath
+ URL url = Thread.currentThread()
+ .getContextClassLoader()
+ .getResource(getFileName());
+ if(url != null) {
+ file = new File(url.getPath());
+ }
+ }
+ try {
+ f = new java.io.FileInputStream(file);
+ }catch (FileNotFoundException e) {
// ignore
- }
- }
- else { // files in classpath
- f = Thread.currentThread().getContextClassLoader()
- .getResourceAsStream(getFileName());
}
-
if (f == null && isFailOnFileNotFound()) {
throw new SchedulerException("File named '" + getFileName()
+ "' does not exist.");
@@ -301,7 +312,8 @@ public class JobInitializationPlugin imp
getLog().warn("File named '" + getFileName() + "' does not exist.");
} else {
fileFound = true;
- try {
+ this.filePath = file.getPath();
+ try {
f.close();
} catch (IOException ioe) {
getLog()
|
|
Description
|
If I specify the filename for the JobInitializationPlugin rather than the full path, the file will get found and loaded correctly from the classpath by the plugin, but will not be found by the FileScanJob because it doesn't also search the classpath.
I modified my copy of the JobInitializationPlugin to pass the file path to the FileScanJob, attached is a patch with my changes in case anyone should happen to want it. Apologies if this is already known, I didn't see an open bug matching this description in the queue.
P.S. I'm just trying out quartz for the first time, and I think it is really sweet, nice work!
Index: JobInitializationPlugin.java
===================================================================
RCS file: /cvsroot/quartz/Quartz/src/java/plugins/org/quartz/plugins/xml/JobInitializationPlugin.java,v
retrieving revision 1.11
diff -u -p -r1.11 JobInitializationPlugin.java
--- JobInitializationPlugin.java 31 Jul 2004 22:51:51 -0000 1.11
+++ JobInitializationPlugin.java 6 Sep 2004 21:23:48 -0000
@@ -29,6 +29,7 @@ import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Date;
+import java.net.URL;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -72,6 +73,8 @@ public class JobInitializationPlugin imp
private String fileName = JobSchedulingDataProcessor.QUARTZ_XML_FILE_NAME;
+ private String filePath = null;
+
private boolean validating = true;
private boolean validatingSchema = true;
@@ -246,7 +249,7 @@ public class JobInitializationPlugin imp
this.name = name;
this.scheduler = scheduler;
- getLog().info("Registering Quartz Job Initiazation Plug-in.");
+ getLog().info("Registering Quartz Job Initialization Plug-in.");
findFile();
@@ -262,7 +265,7 @@ public class JobInitializationPlugin imp
"JobInitializationPlugin",
FileScanJob.class);
job.setVolatility(true);
- job.getJobDataMap().put(FileScanJob.FILE_NAME, getFileName());
+ job.getJobDataMap().put(FileScanJob.FILE_NAME, getFilePath());
job.getJobDataMap().put(FileScanJob.FILE_SCAN_LISTENER_NAME, "JobInitializationPlugin_"+name);
scheduler.getContext().put("JobInitializationPlugin_"+name, this);
@@ -274,26 +277,34 @@ public class JobInitializationPlugin imp
}
}
+ private String getFilePath() throws SchedulerException {
+ if(this.filePath == null) {
+ findFile();
+ }
+ return this.filePath;
+ }
+
/**
*
*/
private void findFile() throws SchedulerException {
java.io.InputStream f = null;
- File file = new File(getFileName());
- if (file != null && file.exists()) { // files in filesystem
- try {
- f = new java.io.FileInputStream(file);
- }
- catch (FileNotFoundException e) {
+ File file = new File(getFileName()); // files in filesystem
+ if (file == null || !file.exists()) {
+ // files in classpath
+ URL url = Thread.currentThread()
+ .getContextClassLoader()
+ .getResource(getFileName());
+ if(url != null) {
+ file = new File(url.getPath());
+ }
+ }
+ try {
+ f = new java.io.FileInputStream(file);
+ }catch (FileNotFoundException e) {
// ignore
- }
- }
- else { // files in classpath
- f = Thread.currentThread().getContextClassLoader()
- .getResourceAsStream(getFileName());
}
-
if (f == null && isFailOnFileNotFound()) {
throw new SchedulerException("File named '" + getFileName()
+ "' does not exist.");
@@ -301,7 +312,8 @@ public class JobInitializationPlugin imp
getLog().warn("File named '" + getFileName() + "' does not exist.");
} else {
fileFound = true;
- try {
+ this.filePath = file.getPath();
+ try {
f.close();
} catch (IOException ioe) {
getLog()
|
Show » |
|