Browse Source
* commit '7bdd1ccfbff09cf7a22ac478fd14de6f62e4b0e5': REPORT-109123 fine-third-11.0.jar中含有.bak文件待清理 REPORT-108344 用户密码被记录进日志,手机号邮箱被明文记录feature/x
superman
12 months ago
9 changed files with 5 additions and 773 deletions
@ -1,121 +0,0 @@ |
|||||||
/* |
|
||||||
* Copyright 2004-2005 OpenSymphony |
|
||||||
* |
|
||||||
* Licensed 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. |
|
||||||
* |
|
||||||
*/ |
|
||||||
|
|
||||||
/* |
|
||||||
* Previously Copyright (c) 2001-2004 James House |
|
||||||
*/ |
|
||||||
package org.quartz.jobs; |
|
||||||
|
|
||||||
import java.io.File; |
|
||||||
|
|
||||||
import org.quartz.JobDataMap; |
|
||||||
import org.quartz.JobExecutionContext; |
|
||||||
import org.quartz.JobExecutionException; |
|
||||||
import org.quartz.SchedulerContext; |
|
||||||
import org.quartz.SchedulerException; |
|
||||||
import org.quartz.StatefulJob; |
|
||||||
|
|
||||||
import org.apache.commons.logging.Log; |
|
||||||
import org.apache.commons.logging.LogFactory; |
|
||||||
|
|
||||||
/** |
|
||||||
* Inspects a file and compares whether it's "last modified date" has changed |
|
||||||
* since the last time it was inspected. If the file has been updated, the |
|
||||||
* job invokes a "call-back" method on an identified |
|
||||||
* <code>FileScanListener</code> that can be found in the |
|
||||||
* <code>SchedulerContext</code>. |
|
||||||
* |
|
||||||
* @author jhouse |
|
||||||
* @see org.quartz.jobs.FileScanListener |
|
||||||
*/ |
|
||||||
public class FileScanJob implements StatefulJob { |
|
||||||
|
|
||||||
public static String FILE_NAME = "FILE_NAME"; |
|
||||||
public static String FILE_SCAN_LISTENER_NAME = "FILE_SCAN_LISTENER_NAME"; |
|
||||||
private static String LAST_MODIFIED_TIME = "LAST_MODIFIED_TIME"; |
|
||||||
|
|
||||||
private final Log log = LogFactory.getLog(getClass()); |
|
||||||
|
|
||||||
public FileScanJob() { |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @see org.quartz.Job#execute(org.quartz.JobExecutionContext) |
|
||||||
*/ |
|
||||||
public void execute(JobExecutionContext context) throws JobExecutionException { |
|
||||||
JobDataMap mergedJobDataMap = context.getMergedJobDataMap(); |
|
||||||
SchedulerContext schedCtxt = null; |
|
||||||
try { |
|
||||||
schedCtxt = context.getScheduler().getContext(); |
|
||||||
} catch (SchedulerException e) { |
|
||||||
throw new JobExecutionException("Error obtaining scheduler context.", e, false); |
|
||||||
} |
|
||||||
|
|
||||||
String fileName = mergedJobDataMap.getString(FILE_NAME); |
|
||||||
String listenerName = mergedJobDataMap.getString(FILE_SCAN_LISTENER_NAME); |
|
||||||
|
|
||||||
if(fileName == null) { |
|
||||||
throw new JobExecutionException("Required parameter '" + |
|
||||||
FILE_NAME + "' not found in merged JobDataMap"); |
|
||||||
} |
|
||||||
if(listenerName == null) { |
|
||||||
throw new JobExecutionException("Required parameter '" + |
|
||||||
FILE_SCAN_LISTENER_NAME + "' not found in merged JobDataMap"); |
|
||||||
} |
|
||||||
|
|
||||||
FileScanListener listener = (FileScanListener)schedCtxt.get(listenerName); |
|
||||||
|
|
||||||
if(listener == null) { |
|
||||||
throw new JobExecutionException("FileScanListener named '" + |
|
||||||
listenerName + "' not found in SchedulerContext"); |
|
||||||
} |
|
||||||
|
|
||||||
long lastDate = -1; |
|
||||||
if(mergedJobDataMap.containsKey(LAST_MODIFIED_TIME)) { |
|
||||||
lastDate = mergedJobDataMap.getLong(LAST_MODIFIED_TIME); |
|
||||||
} |
|
||||||
|
|
||||||
long newDate = getLastModifiedDate(fileName); |
|
||||||
|
|
||||||
if(newDate < 0) { |
|
||||||
log.warn("File '"+fileName+"' does not exist."); |
|
||||||
return; |
|
||||||
} |
|
||||||
|
|
||||||
if(lastDate > 0 && (newDate != lastDate)) { |
|
||||||
// notify call back...
|
|
||||||
log.info("File '"+fileName+"' updated, notifying listener."); |
|
||||||
listener.fileUpdated(fileName); |
|
||||||
} else if (log.isDebugEnabled()) { |
|
||||||
log.debug("File '"+fileName+"' unchanged."); |
|
||||||
} |
|
||||||
|
|
||||||
// It is the JobDataMap on the JobDetail which is actually stateful
|
|
||||||
context.getJobDetail().getJobDataMap().put(LAST_MODIFIED_TIME, newDate); |
|
||||||
} |
|
||||||
|
|
||||||
protected long getLastModifiedDate(String fileName) { |
|
||||||
|
|
||||||
File file = new File(fileName); |
|
||||||
|
|
||||||
if(!file.exists()) { |
|
||||||
return -1; |
|
||||||
} else { |
|
||||||
return file.lastModified(); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,202 +0,0 @@ |
|||||||
/* |
|
||||||
* Copyright 2004-2005 OpenSymphony |
|
||||||
* |
|
||||||
* Licensed 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. |
|
||||||
* |
|
||||||
*/ |
|
||||||
|
|
||||||
/* |
|
||||||
* Previously Copyright (c) 2001-2004 James House |
|
||||||
*/ |
|
||||||
package org.quartz.simpl; |
|
||||||
|
|
||||||
import java.util.Iterator; |
|
||||||
import java.util.LinkedList; |
|
||||||
import java.net.URL; |
|
||||||
import java.io.InputStream; |
|
||||||
|
|
||||||
import org.quartz.spi.ClassLoadHelper; |
|
||||||
|
|
||||||
/** |
|
||||||
* A <code>ClassLoadHelper</code> uses all of the <code>ClassLoadHelper</code> |
|
||||||
* types that are found in this package in its attempts to load a class, when |
|
||||||
* one scheme is found to work, it is promoted to the scheme that will be used |
|
||||||
* first the next time a class is loaded (in order to improve perfomance). |
|
||||||
* |
|
||||||
* <p> |
|
||||||
* This approach is used because of the wide variance in class loader behavior |
|
||||||
* between the various environments in which Quartz runs (e.g. disparate |
|
||||||
* application servers, stand-alone, mobile devices, etc.). Because of this |
|
||||||
* disparity, Quartz ran into difficulty with a one class-load style fits-all |
|
||||||
* design. Thus, this class loader finds the approach that works, then |
|
||||||
* 'remembers' it. |
|
||||||
* </p> |
|
||||||
* |
|
||||||
* @see org.quartz.spi.ClassLoadHelper |
|
||||||
* @see org.quartz.simpl.LoadingLoaderClassLoadHelper |
|
||||||
* @see org.quartz.simpl.SimpleClassLoadHelper |
|
||||||
* @see org.quartz.simpl.ThreadContextClassLoadHelper |
|
||||||
* @see org.quartz.simpl.InitThreadContextClassLoadHelper |
|
||||||
* |
|
||||||
* @author jhouse |
|
||||||
*/ |
|
||||||
public class CascadingClassLoadHelper implements ClassLoadHelper { |
|
||||||
|
|
||||||
|
|
||||||
/* |
|
||||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
||||||
* |
|
||||||
* Data members. |
|
||||||
* |
|
||||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
||||||
*/ |
|
||||||
|
|
||||||
private LinkedList loadHelpers; |
|
||||||
|
|
||||||
private ClassLoadHelper bestCandidate; |
|
||||||
|
|
||||||
/* |
|
||||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
||||||
* |
|
||||||
* Interface. |
|
||||||
* |
|
||||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
||||||
*/ |
|
||||||
|
|
||||||
/** |
|
||||||
* Called to give the ClassLoadHelper a chance to initialize itself, |
|
||||||
* including the oportunity to "steal" the class loader off of the calling |
|
||||||
* thread, which is the thread that is initializing Quartz. |
|
||||||
*/ |
|
||||||
public void initialize() { |
|
||||||
loadHelpers = new LinkedList(); |
|
||||||
|
|
||||||
loadHelpers.add(new LoadingLoaderClassLoadHelper()); |
|
||||||
loadHelpers.add(new SimpleClassLoadHelper()); |
|
||||||
loadHelpers.add(new ThreadContextClassLoadHelper()); |
|
||||||
loadHelpers.add(new InitThreadContextClassLoadHelper()); |
|
||||||
|
|
||||||
Iterator iter = loadHelpers.iterator(); |
|
||||||
while (iter.hasNext()) { |
|
||||||
ClassLoadHelper loadHelper = (ClassLoadHelper) iter.next(); |
|
||||||
loadHelper.initialize(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Return the class with the given name. |
|
||||||
*/ |
|
||||||
public Class loadClass(String name) throws ClassNotFoundException { |
|
||||||
|
|
||||||
if (bestCandidate != null) { |
|
||||||
try { |
|
||||||
return bestCandidate.loadClass(name); |
|
||||||
} catch (Exception e) { |
|
||||||
bestCandidate = null; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
ClassNotFoundException cnfe = null; |
|
||||||
Class clazz = null; |
|
||||||
ClassLoadHelper loadHelper = null; |
|
||||||
|
|
||||||
Iterator iter = loadHelpers.iterator(); |
|
||||||
while (iter.hasNext()) { |
|
||||||
loadHelper = (ClassLoadHelper) iter.next(); |
|
||||||
|
|
||||||
try { |
|
||||||
clazz = loadHelper.loadClass(name); |
|
||||||
break; |
|
||||||
} catch (ClassNotFoundException e) { |
|
||||||
cnfe = e; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
if (clazz == null) { |
|
||||||
throw cnfe; |
|
||||||
} |
|
||||||
|
|
||||||
bestCandidate = loadHelper; |
|
||||||
|
|
||||||
return clazz; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Finds a resource with a given name. This method returns null if no |
|
||||||
* resource with this name is found. |
|
||||||
* @param name name of the desired resource |
|
||||||
* @return a java.net.URL object |
|
||||||
*/ |
|
||||||
public URL getResource(String name) { |
|
||||||
|
|
||||||
if (bestCandidate != null) { |
|
||||||
try { |
|
||||||
return bestCandidate.getResource(name); |
|
||||||
} catch (Exception e) { |
|
||||||
bestCandidate = null; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
URL result = null; |
|
||||||
ClassLoadHelper loadHelper = null; |
|
||||||
|
|
||||||
Iterator iter = loadHelpers.iterator(); |
|
||||||
while (iter.hasNext()) { |
|
||||||
loadHelper = (ClassLoadHelper) iter.next(); |
|
||||||
|
|
||||||
result = loadHelper.getResource(name); |
|
||||||
if (result != null) { |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
bestCandidate = loadHelper; |
|
||||||
return result; |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Finds a resource with a given name. This method returns null if no |
|
||||||
* resource with this name is found. |
|
||||||
* @param name name of the desired resource |
|
||||||
* @return a java.io.InputStream object |
|
||||||
*/ |
|
||||||
public InputStream getResourceAsStream(String name) { |
|
||||||
|
|
||||||
if (bestCandidate != null) { |
|
||||||
try { |
|
||||||
return bestCandidate.getResourceAsStream(name); |
|
||||||
} catch (Exception e) { |
|
||||||
bestCandidate = null; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
InputStream result = null; |
|
||||||
ClassLoadHelper loadHelper = null; |
|
||||||
|
|
||||||
Iterator iter = loadHelpers.iterator(); |
|
||||||
while (iter.hasNext()) { |
|
||||||
loadHelper = (ClassLoadHelper) iter.next(); |
|
||||||
|
|
||||||
result = loadHelper.getResourceAsStream(name); |
|
||||||
if (result != null) { |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
bestCandidate = loadHelper; |
|
||||||
return result; |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
} |
|
@ -1,96 +0,0 @@ |
|||||||
/* |
|
||||||
* Copyright 2004-2005 OpenSymphony |
|
||||||
* |
|
||||||
* Licensed 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. |
|
||||||
* |
|
||||||
*/ |
|
||||||
|
|
||||||
/* |
|
||||||
* Previously Copyright (c) 2001-2004 James House |
|
||||||
*/ |
|
||||||
package org.quartz.simpl; |
|
||||||
|
|
||||||
import org.quartz.spi.ClassLoadHelper; |
|
||||||
|
|
||||||
import java.net.URL; |
|
||||||
import java.io.InputStream; |
|
||||||
|
|
||||||
/** |
|
||||||
* A <code>ClassLoadHelper</code> that uses either the context class loader |
|
||||||
* of the thread that initialized Quartz. |
|
||||||
* |
|
||||||
* @see org.quartz.spi.ClassLoadHelper |
|
||||||
* @see org.quartz.simpl.ThreadContextClassLoadHelper |
|
||||||
* @see org.quartz.simpl.SimpleClassLoadHelper |
|
||||||
* @see org.quartz.simpl.CascadingClassLoadHelper |
|
||||||
* @see org.quartz.simpl.LoadingLoaderClassLoadHelper |
|
||||||
* |
|
||||||
* @author jhouse |
|
||||||
*/ |
|
||||||
public class InitThreadContextClassLoadHelper implements ClassLoadHelper { |
|
||||||
|
|
||||||
|
|
||||||
/* |
|
||||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
||||||
* |
|
||||||
* Data members. |
|
||||||
* |
|
||||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
||||||
*/ |
|
||||||
|
|
||||||
private ClassLoader initClassLoader; |
|
||||||
|
|
||||||
/* |
|
||||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
||||||
* |
|
||||||
* Interface. |
|
||||||
* |
|
||||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
||||||
*/ |
|
||||||
|
|
||||||
/** |
|
||||||
* Called to give the ClassLoadHelper a chance to initialize itself, |
|
||||||
* including the oportunity to "steal" the class loader off of the calling |
|
||||||
* thread, which is the thread that is initializing Quartz. |
|
||||||
*/ |
|
||||||
public void initialize() { |
|
||||||
initClassLoader = Thread.currentThread().getContextClassLoader(); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Return the class with the given name. |
|
||||||
*/ |
|
||||||
public Class loadClass(String name) throws ClassNotFoundException { |
|
||||||
return initClassLoader.loadClass(name); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Finds a resource with a given name. This method returns null if no |
|
||||||
* resource with this name is found. |
|
||||||
* @param name name of the desired resource |
|
||||||
* @return a java.net.URL object |
|
||||||
*/ |
|
||||||
public URL getResource(String name) { |
|
||||||
return initClassLoader.getResource(name); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Finds a resource with a given name. This method returns null if no |
|
||||||
* resource with this name is found. |
|
||||||
* @param name name of the desired resource |
|
||||||
* @return a java.io.InputStream object |
|
||||||
*/ |
|
||||||
public InputStream getResourceAsStream(String name) { |
|
||||||
return initClassLoader.getResourceAsStream(name); |
|
||||||
} |
|
||||||
} |
|
@ -1,87 +0,0 @@ |
|||||||
/* |
|
||||||
* Copyright 2004-2005 OpenSymphony |
|
||||||
* |
|
||||||
* Licensed 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. |
|
||||||
* |
|
||||||
*/ |
|
||||||
|
|
||||||
/* |
|
||||||
* Previously Copyright (c) 2001-2004 James House |
|
||||||
*/ |
|
||||||
package org.quartz.simpl; |
|
||||||
|
|
||||||
import org.quartz.spi.ClassLoadHelper; |
|
||||||
|
|
||||||
import java.net.URL; |
|
||||||
import java.io.InputStream; |
|
||||||
|
|
||||||
/** |
|
||||||
* A <code>ClassLoadHelper</code> that uses either the loader of it's own |
|
||||||
* class (<code>this.getClass().getClassLoader().loadClass( .. )</code>). |
|
||||||
* |
|
||||||
* @see org.quartz.spi.ClassLoadHelper |
|
||||||
* @see org.quartz.simpl.InitThreadContextClassLoadHelper |
|
||||||
* @see org.quartz.simpl.SimpleClassLoadHelper |
|
||||||
* @see org.quartz.simpl.CascadingClassLoadHelper |
|
||||||
* |
|
||||||
* @author jhouse |
|
||||||
*/ |
|
||||||
public class LoadingLoaderClassLoadHelper implements ClassLoadHelper { |
|
||||||
|
|
||||||
/* |
|
||||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
||||||
* |
|
||||||
* Interface. |
|
||||||
* |
|
||||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
||||||
*/ |
|
||||||
|
|
||||||
/** |
|
||||||
* Called to give the ClassLoadHelper a chance to initialize itself, |
|
||||||
* including the oportunity to "steal" the class loader off of the calling |
|
||||||
* thread, which is the thread that is initializing Quartz. |
|
||||||
*/ |
|
||||||
public void initialize() { |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Return the class with the given name. |
|
||||||
*/ |
|
||||||
public Class loadClass(String name) throws ClassNotFoundException { |
|
||||||
return getClassLoader().loadClass(name); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Finds a resource with a given name. This method returns null if no |
|
||||||
* resource with this name is found. |
|
||||||
* @param name name of the desired resource |
|
||||||
* @return a java.net.URL object |
|
||||||
*/ |
|
||||||
public URL getResource(String name) { |
|
||||||
return getClassLoader().getResource(name); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Finds a resource with a given name. This method returns null if no |
|
||||||
* resource with this name is found. |
|
||||||
* @param name name of the desired resource |
|
||||||
* @return a java.io.InputStream object |
|
||||||
*/ |
|
||||||
public InputStream getResourceAsStream(String name) { |
|
||||||
return getClassLoader().getResourceAsStream(name); |
|
||||||
} |
|
||||||
|
|
||||||
private ClassLoader getClassLoader() { |
|
||||||
return this.getClass().getClassLoader(); |
|
||||||
} |
|
||||||
} |
|
@ -1,106 +0,0 @@ |
|||||||
/* |
|
||||||
* Copyright 2004-2005 OpenSymphony |
|
||||||
* |
|
||||||
* Licensed 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. |
|
||||||
* |
|
||||||
*/ |
|
||||||
|
|
||||||
/* |
|
||||||
* Previously Copyright (c) 2001-2004 James House |
|
||||||
*/ |
|
||||||
package org.quartz.simpl; |
|
||||||
|
|
||||||
import org.quartz.spi.ClassLoadHelper; |
|
||||||
|
|
||||||
import java.lang.reflect.AccessibleObject; |
|
||||||
import java.lang.reflect.Method; |
|
||||||
import java.net.URL; |
|
||||||
import java.io.InputStream; |
|
||||||
|
|
||||||
/** |
|
||||||
* A <code>ClassLoadHelper</code> that simply calls <code>Class.forName(..)</code>. |
|
||||||
* |
|
||||||
* @see org.quartz.spi.ClassLoadHelper |
|
||||||
* @see org.quartz.simpl.ThreadContextClassLoadHelper |
|
||||||
* @see org.quartz.simpl.CascadingClassLoadHelper |
|
||||||
* @see org.quartz.simpl.LoadingLoaderClassLoadHelper |
|
||||||
* |
|
||||||
* @author jhouse |
|
||||||
*/ |
|
||||||
public class SimpleClassLoadHelper implements ClassLoadHelper { |
|
||||||
|
|
||||||
/* |
|
||||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
||||||
* |
|
||||||
* Interface. |
|
||||||
* |
|
||||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
||||||
*/ |
|
||||||
|
|
||||||
/** |
|
||||||
* Called to give the ClassLoadHelper a chance to initialize itself, |
|
||||||
* including the oportunity to "steal" the class loader off of the calling |
|
||||||
* thread, which is the thread that is initializing Quartz. |
|
||||||
*/ |
|
||||||
public void initialize() { |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Return the class with the given name. |
|
||||||
*/ |
|
||||||
public Class loadClass(String name) throws ClassNotFoundException { |
|
||||||
return Class.forName(name); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Finds a resource with a given name. This method returns null if no |
|
||||||
* resource with this name is found. |
|
||||||
* @param name name of the desired resource |
|
||||||
* @return a java.net.URL object |
|
||||||
*/ |
|
||||||
public URL getResource(String name) { |
|
||||||
return getClassLoader().getResource(name); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Finds a resource with a given name. This method returns null if no |
|
||||||
* resource with this name is found. |
|
||||||
* @param name name of the desired resource |
|
||||||
* @return a java.io.InputStream object |
|
||||||
*/ |
|
||||||
public InputStream getResourceAsStream(String name) { |
|
||||||
return getClassLoader().getResourceAsStream(name); |
|
||||||
} |
|
||||||
|
|
||||||
private ClassLoader getClassLoader() { |
|
||||||
// To follow the same behavior of Class.forName(...) I had to play
|
|
||||||
// dirty (Supported by Sun, IBM & BEA JVMs)
|
|
||||||
// ToDo - Test it more.
|
|
||||||
try { |
|
||||||
// Get a reference to this class' class-loader
|
|
||||||
ClassLoader cl = this.getClass().getClassLoader(); |
|
||||||
// Create a method instance represnting the protected
|
|
||||||
// getCallerClassLoader method of class ClassLoader
|
|
||||||
Method mthd = ClassLoader.class.getDeclaredMethod( |
|
||||||
"getCallerClassLoader", new Class[0]); |
|
||||||
// Make the method accessible.
|
|
||||||
AccessibleObject.setAccessible(new AccessibleObject[] {mthd}, true); |
|
||||||
// Try to get the caller's class-loader
|
|
||||||
return (ClassLoader)mthd.invoke(cl, new Object[0]); |
|
||||||
} catch (Exception all) { |
|
||||||
// Use this class' class-loader
|
|
||||||
return this.getClass().getClassLoader(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
@ -1,89 +0,0 @@ |
|||||||
/* |
|
||||||
* Copyright 2004-2005 OpenSymphony |
|
||||||
* |
|
||||||
* Licensed 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. |
|
||||||
* |
|
||||||
*/ |
|
||||||
|
|
||||||
/* |
|
||||||
* Previously Copyright (c) 2001-2004 James House |
|
||||||
*/ |
|
||||||
package org.quartz.simpl; |
|
||||||
|
|
||||||
import org.quartz.spi.ClassLoadHelper; |
|
||||||
|
|
||||||
import java.net.URL; |
|
||||||
import java.io.InputStream; |
|
||||||
|
|
||||||
/** |
|
||||||
* A <code>ClassLoadHelper</code> that uses either the current thread's |
|
||||||
* context class loader (<code>Thread.currentThread().getContextClassLoader().loadClass( .. )</code>). |
|
||||||
* |
|
||||||
* @see org.quartz.spi.ClassLoadHelper |
|
||||||
* @see org.quartz.simpl.InitThreadContextClassLoadHelper |
|
||||||
* @see org.quartz.simpl.SimpleClassLoadHelper |
|
||||||
* @see org.quartz.simpl.CascadingClassLoadHelper |
|
||||||
* @see org.quartz.simpl.LoadingLoaderClassLoadHelper |
|
||||||
* |
|
||||||
* @author jhouse |
|
||||||
*/ |
|
||||||
public class ThreadContextClassLoadHelper implements ClassLoadHelper { |
|
||||||
|
|
||||||
/* |
|
||||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
||||||
* |
|
||||||
* Interface. |
|
||||||
* |
|
||||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
||||||
*/ |
|
||||||
|
|
||||||
/** |
|
||||||
* Called to give the ClassLoadHelper a chance to initialize itself, |
|
||||||
* including the oportunity to "steal" the class loader off of the calling |
|
||||||
* thread, which is the thread that is initializing Quartz. |
|
||||||
*/ |
|
||||||
public void initialize() { |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Return the class with the given name. |
|
||||||
*/ |
|
||||||
public Class loadClass(String name) throws ClassNotFoundException { |
|
||||||
return getClassLoader().loadClass(name); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Finds a resource with a given name. This method returns null if no |
|
||||||
* resource with this name is found. |
|
||||||
* @param name name of the desired resource |
|
||||||
* @return a java.net.URL object |
|
||||||
*/ |
|
||||||
public URL getResource(String name) { |
|
||||||
return getClassLoader().getResource(name); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Finds a resource with a given name. This method returns null if no |
|
||||||
* resource with this name is found. |
|
||||||
* @param name name of the desired resource |
|
||||||
* @return a java.io.InputStream object |
|
||||||
*/ |
|
||||||
public InputStream getResourceAsStream(String name) { |
|
||||||
return getClassLoader().getResourceAsStream(name); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
private ClassLoader getClassLoader() { |
|
||||||
return Thread.currentThread().getContextClassLoader(); |
|
||||||
} |
|
||||||
} |
|
@ -1,69 +0,0 @@ |
|||||||
/* |
|
||||||
* Copyright 2004-2005 OpenSymphony |
|
||||||
* |
|
||||||
* Licensed 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. |
|
||||||
* |
|
||||||
*/ |
|
||||||
|
|
||||||
/* |
|
||||||
* Previously Copyright (c) 2001-2004 James House |
|
||||||
*/ |
|
||||||
package org.quartz.spi; |
|
||||||
|
|
||||||
import java.net.URL; |
|
||||||
import java.io.InputStream; |
|
||||||
|
|
||||||
/** |
|
||||||
* An interface for classes wishing to provide the service of loading classes |
|
||||||
* and resources within the scheduler... |
|
||||||
* |
|
||||||
* @author jhouse |
|
||||||
*/ |
|
||||||
public interface ClassLoadHelper { |
|
||||||
|
|
||||||
/* |
|
||||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
||||||
* |
|
||||||
* Interface. |
|
||||||
* |
|
||||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
||||||
*/ |
|
||||||
|
|
||||||
/** |
|
||||||
* Called to give the ClassLoadHelper a chance to initialize itself, |
|
||||||
* including the oportunity to "steal" the class loader off of the calling |
|
||||||
* thread, which is the thread that is initializing Quartz. |
|
||||||
*/ |
|
||||||
void initialize(); |
|
||||||
|
|
||||||
/** |
|
||||||
* Return the class with the given name. |
|
||||||
*/ |
|
||||||
Class loadClass(String name) throws ClassNotFoundException; |
|
||||||
|
|
||||||
/** |
|
||||||
* Finds a resource with a given name. This method returns null if no |
|
||||||
* resource with this name is found. |
|
||||||
* @param name name of the desired resource |
|
||||||
* @return a java.net.URL object |
|
||||||
*/ |
|
||||||
URL getResource(String name); |
|
||||||
|
|
||||||
/** |
|
||||||
* Finds a resource with a given name. This method returns null if no |
|
||||||
* resource with this name is found. |
|
||||||
* @param name name of the desired resource |
|
||||||
* @return a java.io.InputStream object |
|
||||||
*/ |
|
||||||
InputStream getResourceAsStream(String name); |
|
||||||
} |
|
Loading…
Reference in new issue