Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.project.spoke.fw.taskexecutor;
- import java.net.MalformedURLException;
- import java.net.URL;
- import java.net.URLClassLoader;
- import com.project.frame.FrameWork;
- import com.project.frame.header.GenericTask;
- import com.project.logger.common.LogEvent;
- import com.project.logger.common.Logger;
- import com.project.logger.common.LoggerBuilder;
- import com.project.spoke.adapter.engine.exception.NonRetryAbleAdapterErrorException;
- import com.project.spoke.adapter.engine.exception.RetryAbleAdapterErrorException;
- import com.project.spoke.exception.SpokeException;
- import com.project.spoke.fw.IAdapterResponse;
- public class FileAdapterSynchronousTaskExecutor
- implements ITaskExecutor
- {
- protected static final Logger log = new LoggerBuilder(SynchronousTaskExecutor.class).getLogger();
- private FrameWork fw;
- /**
- * @see com.project.spoke.fw.taskexecutor.ITaskExecutor#executeTask(com.project.frame.header.GenericTask)
- */
- public GenericTask executeTask(GenericTask task)
- throws RetryAbleAdapterErrorException,NonRetryAbleAdapterErrorException
- {
- if ( fw == null )
- {
- LogEvent ev = log.error("Task executor is not initialized.");
- throw new NonRetryAbleAdapterErrorException(ev.getLogMsg());
- }
- if ( task == null )
- {
- LogEvent ev = log.error("Unable to execute <null> task.");
- throw new NonRetryAbleAdapterErrorException(ev.getLogMsg());
- }
- //execute synchronously
- try
- {
- task = fw.executeSyncTask(task);
- return task;
- }
- catch(Exception e)
- {
- LogEvent ev = log.error("Failed to execute a task synchronously. Reson:{0}",e.toString(),e);
- throw new NonRetryAbleAdapterErrorException(ev.getLogMsg(),e);
- }
- }
- /**
- * @throws MalformedURLException
- * @see com.project.spoke.fw.taskexecutor.ITaskExecutor#initialize(com.project.frame.FrameWork)
- */
- public void initialize(FrameWork fwArg,IAdapterResponse adapterConnector) throws MalformedURLException
- {
- if ( fwArg == null )
- {
- log.error("Trying to initialize the task executor with <null> as framework reference.");
- }
- else{
- fw = fwArg;
- }
- URL classUrl;
- classUrl = new URL("file:C:\\SEEBURGER\\SEEBURGER BIS Link\\software\\161jar\\jcifs_unzipped\\jcifs\\smb\\NtlmPasswordAuthenticator.class");
- URL[] classUrls = { classUrl };
- URLClassLoader ucl = new URLClassLoader(classUrls);
- //we dont need the adapter connector for this type of execution
- }
- public void finishTask(GenericTask taskArg)
- throws SpokeException
- {
- //this method has no meaning for this type of execution
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement