List of usage examples for org.apache.commons.logging.impl NoOpLog NoOpLog
public NoOpLog()
From source file:marshalsec.gadgets.SpringUtil.java
public static BeanFactory makeJNDITrigger(String jndiUrl) throws Exception { SimpleJndiBeanFactory bf = new SimpleJndiBeanFactory(); bf.setShareableResources(jndiUrl);/*from w w w . j a v a2 s .com*/ Reflections.setFieldValue(bf, "logger", new NoOpLog()); Reflections.setFieldValue(bf.getJndiTemplate(), "logger", new NoOpLog()); return bf; }
From source file:epgtools.loggerfactory.LoggerFactory.java
public Log getLOG() { final Log LOG; if (this.outLog) { LOG = LogFactory.getLog(myClass); } else {/*from ww w. j a v a 2 s .c o m*/ LOG = new NoOpLog(); THIS_LOG.info(myClass + "????"); } return LOG; }
From source file:com.comcast.cim.rest.client.xhtml.TestXhtmlResponseHandler.java
@Before public void setUp() throws Exception { context = new URL("http://foo.example.com/"); impl = new XhtmlResponseHandler(context); impl.setLogger(new NoOpLog()); }
From source file:marshalsec.gadgets.SpringUtil.java
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;/*w ww.java2 s . c om*/ }
From source file:marshalsec.gadgets.CommonsConfiguration.java
@Args(minArgs = 2, args = { "codebase", "class" }, defaultArgs = { MarshallerBase.defaultCodebase,
MarshallerBase.defaultCodebaseClass })
default Object makeConfiguration(UtilFactory uf, String[] args)
throws ClassNotFoundException, NoSuchMethodException, InstantiationException, IllegalAccessException,
InvocationTargetException, NamingException, Exception {
DirContext ctx = JDKUtil.makeContinuationContext(args[0], args[1]);
JNDIConfiguration jc = new JNDIConfiguration();
jc.setContext(ctx);/* w w w . j a v a 2s . c o m*/
jc.setPrefix("foo");
Reflections.setFieldValue(jc, "errorListeners", Collections.EMPTY_LIST);
Reflections.setFieldValue(jc, "listeners", Collections.EMPTY_LIST);
Reflections.setFieldValue(jc, "log", new NoOpLog());
return jc;
}
From source file:com.sun.faces.config.DigesterFactory.java
/** * <p>Configures the provided <code>Digester</code> instance appropriate * for use with JSF.</p>/* w ww. ja v a2 s . c o m*/ * @param digester - the <code>Digester</code> instance to configure */ private void configureDigester(Digester digester) { digester.setNamespaceAware(true); digester.setUseContextClassLoader(true); digester.setEntityResolver(RESOLVER); digester.setErrorHandler(ERROR_HANDLER); // disable digester log messages digester.setLogger(new NoOpLog()); if (validating) { if (logger.isLoggable(Level.FINE)) { logger.log(Level.FINE, "Attempting to configure Digester to perform" + " document validation."); } // In order to validate using *both* DTD and Schema, certain // Xerces specific features are required. Try to set these // features. If an exception is thrown trying to set these // features, then disable validation. try { digester.setFeature(XERCES_VALIDATION, true); digester.setFeature(XERCES_SCHEMA_VALIDATION, true); digester.setFeature(XERCES_SCHEMA_CONSTRAINT_VALIDATION, true); digester.setValidating(true); } catch (SAXNotSupportedException e) { if (logger.isLoggable(Level.WARNING)) { logger.log(Level.WARNING, "Attempt to set supported feature on XMLReader, " + "but the value provided was not accepted. " + "Validation will be disabledb."); } digester.setValidating(false); } catch (SAXNotRecognizedException e) { if (logger.isLoggable(Level.WARNING)) { logger.log(Level.WARNING, "Attempt to set unsupported feature on XMLReader" + " necessary for validation. Validation will be" + "disabled."); } digester.setValidating(false); } catch (ParserConfigurationException e) { if (logger.isLoggable(Level.WARNING)) { logger.log(Level.WARNING, "Digester unable to configure underlying parser." + " Validation will be disabled."); } digester.setValidating(false); } } else { digester.setValidating(false); } }
From source file:org.codehaus.mojo.unix.maven.logging.MavenCommonLoggingLogFactory.java
public Log getInstance(Class aClass) throws LogConfigurationException { org.apache.maven.plugin.logging.Log log = mavenLogger.get(); if (log == null) { return new NoOpLog(); // This *should* only happen during testing -- famous last words - trygvis // throw new RuntimeException( "INTERNAL ERROR: maven logger is null." ); }/*from www. j av a2 s.co m*/ return new CommonsLogAdapter(log); }
From source file:org.eclipse.wb.internal.core.model.description.helpers.ComponentDescriptionHelper.java
/** * @param editor// w w w . j a v a2 s . c o m * the {@link AstEditor} in context of which we work now. * @param key * the {@link ComponentDescriptionKey} of requested {@link ComponentDescription}. * @param additionalDescriptionInfos * additional {@link ClassResourceInfo}'s to parse after {@link ClassResourceInfo}'s * collected for component {@link Class}. May be empty, but not <code>null</code>. * * @return the {@link ComponentDescription} of component with given {@link Class}. * @throws Exception * if no {@link ComponentDescription} can be found. */ private static ComponentDescription getDescription0(AstEditor editor, ComponentDescriptionKey key, List<ClassResourceInfo> additionalDescriptionInfos) throws Exception { EditorState state = EditorState.get(editor); ILoadingContext context = EditorStateLoadingContext.get(state); Class<?> componentClass = key.getComponentClass(); // try { // prepare result description ComponentDescription componentDescription = new ComponentDescription(key); addConstructors(editor.getJavaProject(), componentDescription); componentDescription.setBeanInfo(ReflectionUtils.getBeanInfo(componentClass)); componentDescription.setBeanDescriptor(new IntrospectionHelper(componentClass).getBeanDescriptor()); // prepare list of description resources, from generic to specific LinkedList<ClassResourceInfo> descriptionInfos; { descriptionInfos = Lists.newLinkedList(); DescriptionHelper.addDescriptionResources(descriptionInfos, context, componentClass); Assert.isTrueException(!descriptionInfos.isEmpty(), ICoreExceptionConstants.DESCRIPTION_NO_DESCRIPTIONS, componentClass.getName()); // at last append additional description resource descriptionInfos.addAll(additionalDescriptionInfos); } // prepare Digester Digester digester; { digester = new Digester(); digester.setLogger(new NoOpLog()); addRules(digester, editor, componentClass); } // read descriptions from generic to specific for (ClassResourceInfo descriptionInfo : descriptionInfos) { ResourceInfo resourceInfo = descriptionInfo.resource; // read next description { componentDescription.setCurrentClass(descriptionInfo.clazz); digester.push(componentDescription); // do parse InputStream is = resourceInfo.getURL().openStream(); try { digester.parse(is); } finally { IOUtils.closeQuietly(is); } } // clear parts that can not be inherited if (descriptionInfo.clazz == componentClass) { setDescriptionWithInnerTags(componentDescription, resourceInfo); } else { componentDescription.clearCreations(); componentDescription.setDescription(null); } } // set toolkit if (componentDescription.getToolkit() == null) { for (int i = descriptionInfos.size() - 1; i >= 0; i--) { ClassResourceInfo descriptionInfo = descriptionInfos.get(i); ToolkitDescription toolkit = descriptionInfo.resource.getToolkit(); if (toolkit != null) { componentDescription.setToolkit(toolkit); break; } } Assert.isTrueException(componentDescription.getToolkit() != null, ICoreExceptionConstants.DESCRIPTION_NO_TOOLKIT, componentClass.getName()); } // icon, default creation setIcon(context, componentDescription, componentClass); configureDefaultCreation(componentDescription); // final operations { Assert.isNotNull(componentDescription.getModelClass()); componentDescription.joinProperties(); } // add to caches if (key.isPureComponent() && !"true".equals(componentDescription.getParameter("dontCacheDescription")) && shouldCacheDescriptions_inPackage(descriptionInfos.getLast(), componentClass)) { componentDescription.setCached(true); } // mark for caching presentation if (shouldCachePresentation(descriptionInfos.getLast(), componentClass)) { componentDescription.setPresentationCached(true); } // use processors for (IDescriptionProcessor processor : getDescriptionProcessors()) { processor.process(editor, componentDescription); } // well, we have result return componentDescription; } catch (SAXParseException e) { throw new DesignerException(ICoreExceptionConstants.DESCRIPTION_LOAD_ERROR, e.getException(), componentClass.getName()); } }
From source file:org.eclipse.wb.internal.core.model.description.helpers.FactoryDescriptionHelper.java
private static Digester prepareDigester(Class<?> factoryClass, EditorState state, final Map<Integer, FactoryMethodDescription> textualDescriptions) { Digester digester = new Digester() { private static final String DESCRIPTION_PATTERN = "factory/method/description"; private int m_descriptionIndex; @Override// w w w .j a va 2 s .c o m public void endElement(String namespaceURI, String localName, String qName) throws SAXException { // description with HTML support if (DESCRIPTION_PATTERN.equals(match)) { FactoryMethodDescription methodDescription = (FactoryMethodDescription) peek(); textualDescriptions.put(m_descriptionIndex, methodDescription); m_descriptionIndex++; } // continue super.endElement(namespaceURI, localName, qName); } }; digester.setLogger(new NoOpLog()); addRules(digester, state, factoryClass); return digester; }
From source file:org.eclipse.wb.internal.core.model.description.LayoutDescription.java
private void loadDescription() throws Exception { // prepare resource String resourcePath = m_layoutClassName.replace('.', '/') + ".wbp-component.xml"; ResourceInfo resourceInfo = DescriptionHelper.getResourceInfo(resourcePath, m_toolkit.getId()); if (resourceInfo == null) { DesignerPlugin.log("Not found resource " + m_layoutClassName.replace('.', '/') + ".wbp-component.xml" + " in bundle " + m_toolkit.getId()); return;/*from w ww. j a v a 2s .c o m*/ } Digester digester; // prepare digester { digester = new Digester(); digester.setLogger(new NoOpLog()); digester.addRule("component/creation", new Rule() { @Override public void begin(String namespace, String name, Attributes attributes) throws Exception { final String id = attributes.getValue("id"); digester.push(id != null ? id : StringUtils.EMPTY); } @Override public void end(String namespace, String name) throws Exception { digester.pop(); } }); digester.addRule("component/creation/source", new Rule() { @Override public void body(String namespace, String name, String text) throws Exception { final String id = (String) digester.peek(); if (id.equals(m_creationId)) { m_source = text; } } }); } // do parse InputStream is = resourceInfo.getURL().openStream(); try { digester.parse(is); } finally { IOUtils.closeQuietly(is); } }