public void execute(WorkerContext workerContext) { LoggingManagerInternal loggingManager = createLoggingManager(); loggingManager.setLevel(logLevel).start(); FilteringClassLoader filteredWorkerClassLoader = new FilteringClassLoader(getClass().getClassLoader()); filteredWorkerClassLoader.allowPackage("org.slf4j"); filteredWorkerClassLoader.allowClass(Action.class); filteredWorkerClassLoader.allowClass(WorkerContext.class); ClassLoader applicationClassLoader = workerContext.getApplicationClassLoader(); FilteringClassLoader filteredApplication = new FilteringClassLoader(applicationClassLoader); ObservableUrlClassLoader implementationClassLoader = createImplementationClassLoader(filteredWorkerClassLoader, filteredApplication); // Configure classpaths for (String sharedPackage : sharedPackages) { filteredApplication.allowPackage(sharedPackage); } implementationClassLoader.addURLs(implementationClassPath); // Deserialize the worker action Action<WorkerContext> action; try { ObjectInputStream instr = new ClassLoaderObjectInputStream( new ByteArrayInputStream(serializedWorkerAction), implementationClassLoader); action = (Action<WorkerContext>) instr.readObject(); } catch (Exception e) { throw UncheckedException.asUncheckedException(e); } action.execute(workerContext); }
public void updateClassPath() { for (File file : classpathConfiguration.getFiles()) { try { classLoader.addURL(file.toURI().toURL()); } catch (MalformedURLException e) { throw new RuntimeException(e); } } }