org.apache.commons.logging.impl.NoOpLog Java Examples
The following examples show how to use
org.apache.commons.logging.impl.NoOpLog.
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: SpringUtil.java From learnjavabug with MIT License | 6 votes |
public static BeanFactory makeMethodTrigger(Object o, String method) throws Exception { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); RootBeanDefinition caller = new RootBeanDefinition(); caller.setFactoryBeanName("obj"); caller.setFactoryMethodName(method); Reflections.setFieldValue(caller.getMethodOverrides(), "overrides", new HashSet<>()); bf.registerBeanDefinition("caller", caller); Reflections.getField(DefaultListableBeanFactory.class, "beanClassLoader").set(bf, null); Reflections.getField(DefaultListableBeanFactory.class, "alreadyCreated") .set(bf, new HashSet<>()); Reflections.getField(DefaultListableBeanFactory.class, "singletonsCurrentlyInCreation") .set(bf, new HashSet<>()); Reflections.getField(DefaultListableBeanFactory.class, "inCreationCheckExclusions") .set(bf, new HashSet<>()); Reflections.getField(DefaultListableBeanFactory.class, "logger").set(bf, new NoOpLog()); Reflections.getField(DefaultListableBeanFactory.class, "prototypesCurrentlyInCreation") .set(bf, new ThreadLocal<>()); @SuppressWarnings("unchecked") Map<String, Object> objs = (Map<String, Object>) Reflections .getFieldValue(bf, "singletonObjects"); objs.put("obj", o); return bf; }
Example #2
Source File: SpringUtil.java From marshalsec with MIT License | 6 votes |
public static BeanFactory makeMethodTrigger ( Object o, String method ) throws Exception { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); RootBeanDefinition caller = new RootBeanDefinition(); caller.setFactoryBeanName("obj"); caller.setFactoryMethodName(method); Reflections.setFieldValue(caller.getMethodOverrides(), "overrides", new HashSet<>()); bf.registerBeanDefinition("caller", caller); Reflections.getField(DefaultListableBeanFactory.class, "beanClassLoader").set(bf, null); Reflections.getField(DefaultListableBeanFactory.class, "alreadyCreated").set(bf, new HashSet<>()); Reflections.getField(DefaultListableBeanFactory.class, "singletonsCurrentlyInCreation").set(bf, new HashSet<>()); Reflections.getField(DefaultListableBeanFactory.class, "inCreationCheckExclusions").set(bf, new HashSet<>()); Reflections.getField(DefaultListableBeanFactory.class, "logger").set(bf, new NoOpLog()); Reflections.getField(DefaultListableBeanFactory.class, "prototypesCurrentlyInCreation").set(bf, new ThreadLocal<>()); @SuppressWarnings ( "unchecked" ) Map<String, Object> objs = (Map<String, Object>) Reflections.getFieldValue(bf, "singletonObjects"); objs.put("obj", o); return bf; }
Example #3
Source File: SpringUtil.java From learnjavabug with MIT License | 5 votes |
public static BeanFactory makeJNDITrigger(String jndiUrl) throws Exception { SimpleJndiBeanFactory bf = new SimpleJndiBeanFactory(); bf.setShareableResources(jndiUrl); Reflections.setFieldValue(bf, "logger", new NoOpLog()); Reflections.setFieldValue(bf.getJndiTemplate(), "logger", new NoOpLog()); return bf; }
Example #4
Source File: SpringUtil.java From marshalsec with MIT License | 5 votes |
public static BeanFactory makeJNDITrigger ( String jndiUrl ) throws Exception { SimpleJndiBeanFactory bf = new SimpleJndiBeanFactory(); bf.setShareableResources(jndiUrl); Reflections.setFieldValue(bf, "logger", new NoOpLog()); Reflections.setFieldValue(bf.getJndiTemplate(), "logger", new NoOpLog()); return bf; }
Example #5
Source File: EsTokenIdentifier.java From elasticsearch-hadoop with Apache License 2.0 | 5 votes |
@Override public void cancel(Token<?> token, Configuration conf) throws IOException, InterruptedException { if (!KIND_NAME.equals(token.getKind())) { throw new IOException("Could not renew token of invalid type [" + token.getKind().toString() + "]"); } EsToken esToken = new EsToken(new DataInputStream(new ByteArrayInputStream(token.getPassword()))); Settings settings = HadoopSettingsManager.loadFrom(conf); // Create a composite settings object so we can make some changes to the settings without affecting the underlying config CompositeSettings compositeSettings = new CompositeSettings(Collections.singletonList(settings)); // Extract the cluster name from the esToken so that the rest client can locate it for auth purposes ClusterInfo info = new ClusterInfo(new ClusterName(esToken.getClusterName(), null), esToken.getMajorVersion()); compositeSettings.setInternalClusterInfo(info); // The RestClient gets the es token for authentication from the current subject, but the subject running this code // could be ANYONE. We don't want to just give anyone the token in their credentials, so we create a throw away // subject and set it on there. That way we auth with the API key, and once the auth is done, it will be cancelled. // We'll do this with the JDK user to avoid the whole Hadoop Library's weird obsession with a static global user subject. InitializationUtils.setUserProviderIfNotSet(compositeSettings, JdkUserProvider.class, new NoOpLog()); Subject subject = new Subject(); JdkUser user = new JdkUser(subject, settings); user.addEsToken(esToken); user.doAs(new PrivilegedAction<Void>() { @Override public Void run() { RestClient client = null; try { // TODO: Does not support multiple clusters yet // the client will need to point to the cluster that this token is associated with in order to cancel it. client = createClient(compositeSettings); client.cancelToken(esToken); } finally { if (client != null) { client.close(); } } return null; } }); }
Example #6
Source File: TestConfigurationLogger.java From commons-configuration with Apache License 2.0 | 5 votes |
/** * Tests whether a dummy logger can be created. */ @Test public void testDummyLogger() { final ConfigurationLogger logger = ConfigurationLogger.newDummyLogger(); assertThat("Wrong internal logger", logger.getLog(), instanceOf(NoOpLog.class)); }
Example #7
Source File: TestConfigurationLogger.java From commons-configuration with Apache License 2.0 | 5 votes |
/** * Tests the logger set per default. */ @Test public void testAbstractConfigurationDefaultLogger() { final AbstractConfiguration config = new BaseConfiguration(); assertThat("Wrong default logger", config.getLogger().getLog(), instanceOf(NoOpLog.class)); }
Example #8
Source File: TestConfigurationLogger.java From commons-configuration with Apache License 2.0 | 5 votes |
/** * Tests that the logger can be disabled by setting it to null. */ @Test public void testAbstractConfigurationSetLoggerNull() { final AbstractConfiguration config = new BaseConfiguration(); config.setLogger(new ConfigurationLogger(getClass())); config.setLogger(null); assertThat("Logger not disabled", config.getLogger().getLog(), instanceOf(NoOpLog.class)); }
Example #9
Source File: ConfigurationLogger.java From commons-configuration with Apache License 2.0 | 2 votes |
/** * Creates a new dummy logger which produces no output. If such a logger is * passed to a configuration object, logging is effectively disabled. * * @return the new dummy logger */ public static ConfigurationLogger newDummyLogger() { return new ConfigurationLogger(new NoOpLog()); }