public synchronized void clear() { ClassLoader classLoader = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged(); final Map<ClassLoader, T> store = new IdentityHashMap<ClassLoader, T>(this.store); store.remove(classLoader); if (deploymentClassLoaders.containsKey(classLoader)) { for (ClassLoader cl : deploymentClassLoaders.get(classLoader)) { store.remove(cl); } } this.store = store; }
public synchronized void set(T object) { final Map<ClassLoader, T> store = new IdentityHashMap<ClassLoader, T>(this.store); ClassLoader classLoader = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged(); store.put(classLoader, object); if (deploymentClassLoaders.containsKey(classLoader)) { for (ClassLoader cl : deploymentClassLoaders.get(classLoader)) { store.put(cl, object); } } this.store = store; }
@Override public Properties getBatchConfigurationProperties() { throw BatchLogger.LOGGER.noBatchEnvironmentFound(WildFlySecurityManager.getCurrentContextClassLoaderPrivileged()); } }
@Override public Handle setup() { final ClassLoader current = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged(); WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(classLoader); return new Handle() { @Override public void tearDown() { WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(current); } }; } }
public T get() { T instance = store.get(findParentModuleCl(WildFlySecurityManager.getCurrentContextClassLoaderPrivileged())); if (instance == null) { throw WeldLogger.ROOT_LOGGER.singletonNotSet(WildFlySecurityManager.getCurrentContextClassLoaderPrivileged()); } return instance; }
@Override public ArtifactFactory getArtifactFactory() { throw BatchLogger.LOGGER.noBatchEnvironmentFound(WildFlySecurityManager.getCurrentContextClassLoaderPrivileged()); }
private ClassLoader setClassLoaderTo(final ClassLoader targetClassLoader){ ClassLoader current = null; if(WildFlySecurityManager.isChecking()){ current = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged(); WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(targetClassLoader); } else { current = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(targetClassLoader); } return current; } }
private ClassLoader setClassLoaderTo(final ClassLoader targetClassLoader){ ClassLoader current = null; if(WildFlySecurityManager.isChecking()){ current = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged(); WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(targetClassLoader); } else { current = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(targetClassLoader); } return current; } }
@Override public ResetContextHandle setup() throws IllegalStateException { final ClassLoaderResetContextHandle resetContextHandle = new ClassLoaderResetContextHandle(WildFlySecurityManager.getCurrentContextClassLoaderPrivileged()); WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(classLoader); return resetContextHandle; }
@Override public String getJndiViewInstanceValue() { final ClassLoader cl = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged(); try { WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(objectFactoryClassInstance.getClass().getClassLoader()); return String.valueOf(getReference().getInstance()); } finally { WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(cl); } } });
public static Class<?> loadClass(final String className, final Module module) throws ClassNotFoundException { final ClassLoader oldTccl = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged(); try { WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(module.getClassLoader()); return Class.forName(className, false, module.getClassLoader()); } finally { WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(oldTccl); } }
private ObjectFactory factoryFromReference(final Reference reference, final Hashtable<?, ?> environment) throws Exception { if (reference.getFactoryClassName() == null) { return lookForURLs(reference, environment); } if (reference instanceof ModularReference) { return factoryFromModularReference(ModularReference.class.cast(reference), environment); } return factoryFromReference(reference, WildFlySecurityManager.getCurrentContextClassLoaderPrivileged(), environment); }
@Override public List<Long> getRunningExecutions(final String jobName) throws NoSuchJobException, JobSecurityException { checkState(jobName); final ClassLoader current = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged(); try { WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(classLoader); return super.getRunningExecutions(jobName); } finally { WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(current); } }
@Override public List<JobInstance> getJobInstances(final String jobName, final int start, final int count) throws NoSuchJobException, JobSecurityException { checkState(jobName); final ClassLoader current = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged(); try { WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(classLoader); return super.getJobInstances(jobName, start, count); } finally { WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(current); } }
@Override public int getJobInstanceCount(final String jobName) throws NoSuchJobException, JobSecurityException { checkState(jobName); final ClassLoader current = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged(); try { WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(classLoader); return super.getJobInstanceCount(jobName); } finally { WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(current); } }
@Override public void stop(final StopContext context) { final ClassLoader cl = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged(); try { WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(classLoader); ValidatorFactory validatorFactory = deploymentUnit.getAttachment(BeanValidationAttachments.VALIDATOR_FACTORY); if (validatorFactory != null) { validatorFactory.close(); } } finally { WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(cl); } }
private void deactivate() { ClassLoader oldTccl = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged(); try { WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(classLoader); endpoint.deactivate(endpointFactory, activationSpec); } catch (ResourceException re) { throw EjbLogger.ROOT_LOGGER.failureDuringEndpointDeactivation(this.getComponentName(), re); } finally { WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(oldTccl); } }
@Override public List<JobExecution> getJobExecutions(final JobInstance instance) throws NoSuchJobInstanceException, JobSecurityException { checkState(); final ClassLoader current = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged(); try { WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(classLoader); validateJob(instance == null ? null : instance.getJobName()); return super.getJobExecutions(instance); } finally { WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(current); } }
private ValidatorFactory initFactory() { final ClassLoader oldTCCL = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged(); try { WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(classLoader); return Validation.byDefaultProvider().providerResolver(new WildFlyProviderResolver()).configure() .buildValidatorFactory(); } finally { WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(oldTCCL); } }
@Override public void stop(final long executionId) throws NoSuchJobExecutionException, JobExecutionNotRunningException, JobSecurityException { checkState(null, "stop"); final ClassLoader current = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged(); try { WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(classLoader); final JobInstance instance = super.getJobInstance(executionId); validateJob(instance.getJobName()); super.stop(executionId); } finally { WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(current); } }