private static boolean isXdkFactory(final Object factory, final String className) { final Class<?> xdkFactoryClass = AccessController.doPrivileged(ReflectionHelper.classForNamePA(className, null)); if (xdkFactoryClass == null) { return false; } return xdkFactoryClass.isAssignableFrom(factory.getClass()); } }
private static boolean isXdkFactory(final Object factory, final String className) { final Class<?> xdkFactoryClass = AccessController.doPrivileged(ReflectionHelper.classForNamePA(className, null)); if (xdkFactoryClass == null) { return false; } return xdkFactoryClass.isAssignableFrom(factory.getClass()); } }
private ScheduledExecutorService lookupManagedScheduledExecutorService() { try { // Android and some other environments don't have InitialContext class available. final Class<?> aClass = AccessController.doPrivileged(ReflectionHelper.classForNamePA("javax.naming.InitialContext")); final Object initialContext = aClass.newInstance(); final Method lookupMethod = aClass.getMethod("lookup", String.class); return (ScheduledExecutorService) lookupMethod .invoke(initialContext, "java:comp/DefaultManagedScheduledExecutorService"); } catch (Exception e) { // ignore if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, e.getMessage(), e); } } catch (LinkageError error) { // ignore - JDK8 compact2 profile - http://openjdk.java.net/jeps/161 } return null; }
private ScheduledExecutorService lookupManagedScheduledExecutorService() { try { // Android and some other environments don't have InitialContext class available. final Class<?> aClass = AccessController.doPrivileged(ReflectionHelper.classForNamePA("javax.naming.InitialContext")); final Object initialContext = aClass.newInstance(); final Method lookupMethod = aClass.getMethod("lookup", String.class); return (ScheduledExecutorService) lookupMethod .invoke(initialContext, "java:comp/DefaultManagedScheduledExecutorService"); } catch (Exception e) { // ignore if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, e.getMessage(), e); } } catch (LinkageError error) { // ignore - JDK8 compact2 profile - http://openjdk.java.net/jeps/161 } return null; }
private static ExecutorService lookupManagedExecutorService() { // Get the default ManagedExecutorService, if available try { // Android and some other environments don't have InitialContext class available. final Class<?> aClass = AccessController.doPrivileged(ReflectionHelper.classForNamePA("javax.naming.InitialContext")); final Object initialContext = aClass.newInstance(); final Method lookupMethod = aClass.getMethod("lookup", String.class); return (ExecutorService) lookupMethod.invoke(initialContext, "java:comp/DefaultManagedExecutorService"); } catch (Exception e) { // ignore if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, e.getMessage(), e); } } catch (LinkageError error) { // ignore - JDK8 compact2 profile - http://openjdk.java.net/jeps/161 } return null; }
private static ExecutorService lookupManagedExecutorService() { // Get the default ManagedExecutorService, if available try { // Android and some other environments don't have InitialContext class available. final Class<?> aClass = AccessController.doPrivileged(ReflectionHelper.classForNamePA("javax.naming.InitialContext")); final Object initialContext = aClass.newInstance(); final Method lookupMethod = aClass.getMethod("lookup", String.class); return (ExecutorService) lookupMethod.invoke(initialContext, "java:comp/DefaultManagedExecutorService"); } catch (Exception e) { // ignore if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, e.getMessage(), e); } } catch (LinkageError error) { // ignore - JDK8 compact2 profile - http://openjdk.java.net/jeps/161 } return null; }
/** * Get privileged action to obtain Class from given class name. * <p> * If run using security manager, the returned privileged action * must be invoked within a doPrivileged block. * The context class loader will be utilized if accessible and non-null. * Otherwise the defining class loader of this class will * be utilized. * </p> * * @param <T> class type. * @param name class name. * @return privileged action to obtain desired Class. * The action could return {@code null} if the class cannot be found. * @see AccessController#doPrivileged(java.security.PrivilegedAction) */ public static <T> PrivilegedAction<Class<T>> classForNamePA(final String name) { return classForNamePA(name, getContextClassLoader()); }
/** * Get privileged action to obtain Class from given class name. * <p> * If run using security manager, the returned privileged action * must be invoked within a doPrivileged block. * The context class loader will be utilized if accessible and non-null. * Otherwise the defining class loader of this class will * be utilized. * </p> * * @param <T> class type. * @param name class name. * @return privileged action to obtain desired Class. * The action could return {@code null} if the class cannot be found. * @see AccessController#doPrivileged(java.security.PrivilegedAction) */ public static <T> PrivilegedAction<Class<T>> classForNamePA(final String name) { return classForNamePA(name, getContextClassLoader()); }
private ScheduledExecutorService lookupManagedScheduledExecutorService() { try { // Android and some other environments don't have InitialContext class available. final Class<?> aClass = AccessController.doPrivileged(ReflectionHelper.classForNamePA("javax.naming.InitialContext")); final Object initialContext = aClass.newInstance(); final Method lookupMethod = aClass.getMethod("lookup", String.class); return (ScheduledExecutorService) lookupMethod .invoke(initialContext, "java:comp/DefaultManagedScheduledExecutorService"); } catch (Exception e) { // ignore if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, e.getMessage(), e); } } catch (LinkageError error) { // ignore - JDK8 compact2 profile - http://openjdk.java.net/jeps/161 } return null; }
private static Class<? extends TestContainerFactory> loadFactoryClass(final String factoryClassName) { Class<? extends TestContainerFactory> factoryClass; final Class<Object> loadedClass = AccessController.doPrivileged(ReflectionHelper.classForNamePA(factoryClassName, null)); if (loadedClass == null) { throw new TestContainerException(String.format( "Test container factory class '%s' cannot be loaded", factoryClassName)); } try { return loadedClass.asSubclass(TestContainerFactory.class); } catch (final ClassCastException ex) { throw new TestContainerException(String.format( "Class '%s' does not implement TestContainerFactory SPI.", factoryClassName), ex); } }
private static ExecutorService lookupManagedExecutorService() { // Get the default ManagedExecutorService, if available try { // Android and some other environments don't have InitialContext class available. final Class<?> aClass = AccessController.doPrivileged(ReflectionHelper.classForNamePA("javax.naming.InitialContext")); final Object initialContext = aClass.newInstance(); final Method lookupMethod = aClass.getMethod("lookup", String.class); return (ExecutorService) lookupMethod.invoke(initialContext, "java:comp/DefaultManagedExecutorService"); } catch (Exception e) { // ignore if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, e.getMessage(), e); } } catch (LinkageError error) { // ignore - JDK8 compact2 profile - http://openjdk.java.net/jeps/161 } return null; }
factoryClass = ReflectionHelper.classForNamePA((String) objectFactoryProperty).run(); } else if (objectFactoryProperty instanceof Class<?>) { factoryClass = (Class<?>) objectFactoryProperty;
private ClientConfig resolveConfig(final String configClassProperty, final BindingModel binding) { Class<? extends Configuration> configClass = binding.getConfigClass(); final Object _cc = serverConfig.get().getProperty(configClassProperty); if (_cc != null) { Class<?> cc; if (_cc instanceof String) { cc = AccessController.doPrivileged(ReflectionHelper.classForNamePA((String) _cc)); } else if (_cc instanceof Class) { cc = (Class<?>) _cc; } else { cc = null; // will cause a warning } if (cc != null && Configuration.class.isAssignableFrom(cc)) { configClass = cc.asSubclass(Configuration.class); } else { Errors.warning(this, LocalizationMessages.ILLEGAL_CLIENT_CONFIG_CLASS_PROPERTY_VALUE( configClassProperty, _cc, configClass.getName() )); } } final Configuration cfg = clientConfigProvider.apply(configClass); return (cfg instanceof ClientConfig) ? (ClientConfig) cfg : new ClientConfig().loadFrom(cfg); }
private ClientConfig resolveConfig(final String configClassProperty, final BindingModel binding) { Class<? extends Configuration> configClass = binding.getConfigClass(); final Object _cc = serverConfig.get().getProperty(configClassProperty); if (_cc != null) { Class<?> cc; if (_cc instanceof String) { cc = AccessController.doPrivileged(ReflectionHelper.classForNamePA((String) _cc)); } else if (_cc instanceof Class) { cc = (Class<?>) _cc; } else { cc = null; // will cause a warning } if (cc != null && Configuration.class.isAssignableFrom(cc)) { configClass = cc.asSubclass(Configuration.class); } else { Errors.warning(this, LocalizationMessages.ILLEGAL_CLIENT_CONFIG_CLASS_PROPERTY_VALUE( configClassProperty, _cc, configClass.getName() )); } } final Configuration cfg = clientConfigProvider.apply(configClass); return (cfg instanceof ClientConfig) ? (ClientConfig) cfg : new ClientConfig().loadFrom(cfg); }
for (String resourceName : resource.getNames()) { final Class<Object> resourceClass = AccessController .doPrivileged(ReflectionHelper.classForNamePA(resourceName)); if (resourceClass != null) { createEnhancingMethods(resourceClass, null, newMethods);
private ClientConfig resolveConfig(final String configClassProperty, final BindingModel binding) { Class<? extends Configuration> configClass = binding.getConfigClass(); final Object _cc = serverConfig.get().getProperty(configClassProperty); if (_cc != null) { Class<?> cc; if (_cc instanceof String) { cc = AccessController.doPrivileged(ReflectionHelper.classForNamePA((String) _cc)); } else if (_cc instanceof Class) { cc = (Class<?>) _cc; } else { cc = null; // will cause a warning } if (cc != null && Configuration.class.isAssignableFrom(cc)) { configClass = cc.asSubclass(Configuration.class); } else { Errors.warning(this, LocalizationMessages.ILLEGAL_CLIENT_CONFIG_CLASS_PROPERTY_VALUE( configClassProperty, _cc, configClass.getName() )); } } final Configuration cfg = clientConfigProvider.apply(configClass); return (cfg instanceof ClientConfig) ? (ClientConfig) cfg : new ClientConfig().loadFrom(cfg); }
private static boolean isXdkFactory(final Object factory, final String className) { final Class<?> xdkFactoryClass = AccessController.doPrivileged(ReflectionHelper.classForNamePA(className, null)); if (xdkFactoryClass == null) { return false; } return xdkFactoryClass.isAssignableFrom(factory.getClass()); } }
private static boolean isXdkFactory(final Object factory, final String className) { final Class<?> xdkFactoryClass = AccessController.doPrivileged(ReflectionHelper.classForNamePA(className, null)); if (xdkFactoryClass == null) { return false; } return xdkFactoryClass.isAssignableFrom(factory.getClass()); } }
private static boolean isXdkFactory(final Object factory, final String className) { final Class<?> xdkFactoryClass = AccessController.doPrivileged(ReflectionHelper.classForNamePA(className, null)); if (xdkFactoryClass == null) { return false; } return xdkFactoryClass.isAssignableFrom(factory.getClass()); } }
private static boolean isXdkFactory(final Object factory, final String className) { final Class<?> xdkFactoryClass = AccessController.doPrivileged(ReflectionHelper.classForNamePA(className, null)); if (xdkFactoryClass == null) { return false; } return xdkFactoryClass.isAssignableFrom(factory.getClass()); } }