Java Code Examples for org.wildfly.security.manager.WildFlySecurityManager#getCurrentContextClassLoaderPrivileged()
The following examples show how to use
org.wildfly.security.manager.WildFlySecurityManager#getCurrentContextClassLoaderPrivileged() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PluggableMBeanServerTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void testNotificationTccl() throws Exception { ObjectName objName = createName("test.domain:bean=test-tccl"); server.registerMBean(new TestBean(objName), objName); ClassLoader oldTccl = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged(); ClassLoader newOutTccl = new URLClassLoader(new URL[]{}, oldTccl); // creating a new class loader here WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(newOutTccl); try { final AtomicBoolean differ = new AtomicBoolean(false); NotificationFilterSupport filter = new NotificationFilterSupport(); filter.enableType("testtccl"); server.addNotificationListener(objName, new NotificationListener() { @Override public void handleNotification(Notification notification, Object handback) { Assert.assertEquals("callback", handback.toString()); ClassLoader newInTccl = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged(); Assert.assertNotEquals(newInTccl, newOutTccl); differ.set(true); } }, filter, "callback"); server.invoke(objName, "proceed", null, null); Assert.assertTrue(differ.get()); } finally { WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(oldTccl); } }
Example 2
Source File: ModelControllerClientFactoryImpl.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private <T, U, V, R> R executeInModelControllerCl(TriFunction<T, U, V, R> function, T t, U u, V v) { final ClassLoader tccl = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged(); try { WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(modelController.getClass().getClassLoader()); return function.apply(t,u,v); } finally { WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(tccl); } }
Example 3
Source File: ThreadLocalContextSelector.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override public StdioContext getStdioContext() { // CLI loggers should only use the default stdio context regardless if the thread-local context is set. final ClassLoader tccl = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged(); if (tccl != null && tccl.equals(cliClassLoader)) { return defaultContexts.getStdioContext(); } Contexts threadContext = threadLocal.get(); StdioContext local = threadContext != null ? threadContext.getStdioContext() : null; return local == null ? defaultContexts.getStdioContext() : local; }
Example 4
Source File: ThreadLocalContextSelector.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override public LogContext getLogContext() { // CLI loggers should only use the default stdio context regardless if the thread-local context is set This // allows the context configured for CLI, e.g. jboss-cli-logging.properties. final ClassLoader tccl = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged(); if (tccl != null && tccl.equals(cliClassLoader)) { return defaultContexts.getLogContext(); } Contexts threadContext = threadLocal.get(); LogContext local = threadContext != null ? threadContext.getLogContext() : null; return local == null ? defaultContexts.getLogContext() : local; }