Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.86 KB | None | 0 0
  1.  
  2. package com.project.spoke.fw.taskexecutor;
  3.  
  4.  
  5. import java.net.MalformedURLException;
  6. import java.net.URL;
  7. import java.net.URLClassLoader;
  8.  
  9. import com.project.frame.FrameWork;
  10. import com.project.frame.header.GenericTask;
  11. import com.project.logger.common.LogEvent;
  12. import com.project.logger.common.Logger;
  13. import com.project.logger.common.LoggerBuilder;
  14. import com.project.spoke.adapter.engine.exception.NonRetryAbleAdapterErrorException;
  15. import com.project.spoke.adapter.engine.exception.RetryAbleAdapterErrorException;
  16. import com.project.spoke.exception.SpokeException;
  17. import com.project.spoke.fw.IAdapterResponse;
  18.  
  19.  
  20. public class FileAdapterSynchronousTaskExecutor
  21. implements ITaskExecutor
  22. {
  23. protected static final Logger log = new LoggerBuilder(SynchronousTaskExecutor.class).getLogger();
  24.  
  25. private FrameWork fw;
  26.  
  27. /**
  28. * @see com.project.spoke.fw.taskexecutor.ITaskExecutor#executeTask(com.project.frame.header.GenericTask)
  29. */
  30. public GenericTask executeTask(GenericTask task)
  31. throws RetryAbleAdapterErrorException,NonRetryAbleAdapterErrorException
  32. {
  33. if ( fw == null )
  34. {
  35. LogEvent ev = log.error("Task executor is not initialized.");
  36. throw new NonRetryAbleAdapterErrorException(ev.getLogMsg());
  37. }
  38.  
  39. if ( task == null )
  40. {
  41. LogEvent ev = log.error("Unable to execute <null> task.");
  42. throw new NonRetryAbleAdapterErrorException(ev.getLogMsg());
  43. }
  44.  
  45. //execute synchronously
  46.  
  47. try
  48. {
  49. task = fw.executeSyncTask(task);
  50.  
  51. return task;
  52. }
  53. catch(Exception e)
  54. {
  55. LogEvent ev = log.error("Failed to execute a task synchronously. Reson:{0}",e.toString(),e);
  56. throw new NonRetryAbleAdapterErrorException(ev.getLogMsg(),e);
  57. }
  58.  
  59. }
  60.  
  61.  
  62. /**
  63. * @throws MalformedURLException
  64. * @see com.project.spoke.fw.taskexecutor.ITaskExecutor#initialize(com.project.frame.FrameWork)
  65. */
  66. public void initialize(FrameWork fwArg,IAdapterResponse adapterConnector) throws MalformedURLException
  67. {
  68. if ( fwArg == null )
  69. {
  70. log.error("Trying to initialize the task executor with <null> as framework reference.");
  71. }
  72. else{
  73. fw = fwArg;
  74. }
  75.  
  76. URL classUrl;
  77. classUrl = new URL("file:C:\\SEEBURGER\\SEEBURGER BIS Link\\software\\161jar\\jcifs_unzipped\\jcifs\\smb\\NtlmPasswordAuthenticator.class");
  78. URL[] classUrls = { classUrl };
  79. URLClassLoader ucl = new URLClassLoader(classUrls);
  80. //we dont need the adapter connector for this type of execution
  81.  
  82. }
  83.  
  84.  
  85. public void finishTask(GenericTask taskArg)
  86. throws SpokeException
  87. {
  88. //this method has no meaning for this type of execution
  89.  
  90. }
  91.  
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement