List of usage examples for org.apache.commons.logging LogFactory getLog
public static Log getLog(String name)
From source file:com.swordlord.gozer.datatypeformat.DataTypeHelper.java
/** * Return compatible class for typedValue based on untypedValueClass * // w ww . java 2 s . com * @param untypedValueClass * @param typedValue * @return */ public static Object fromDataType(Class<?> untypedValueClass, Object typedValue) { Log LOG = LogFactory.getLog(DataTypeHelper.class); if (typedValue == null) { return null; } if (untypedValueClass == null) { return typedValue; } if (ClassUtils.isAssignable(typedValue.getClass(), untypedValueClass)) { return typedValue; } String strTypedValue = null; boolean isStringTypedValue = typedValue instanceof String; Number numTypedValue = null; boolean isNumberTypedValue = typedValue instanceof Number; Boolean boolTypedValue = null; boolean isBooleanTypedValue = typedValue instanceof Boolean; Date dateTypedValue = null; boolean isDateTypedValue = typedValue instanceof Date; if (isStringTypedValue) { strTypedValue = (String) typedValue; } if (isNumberTypedValue) { numTypedValue = (Number) typedValue; } if (isBooleanTypedValue) { boolTypedValue = (Boolean) typedValue; } if (isDateTypedValue) { dateTypedValue = (Date) typedValue; } Object v = null; if (String.class.equals(untypedValueClass)) { v = ObjectUtils.toString(typedValue); } else if (BigDecimal.class.equals(untypedValueClass)) { if (isStringTypedValue) { v = NumberUtils.createBigDecimal(strTypedValue); } else if (isNumberTypedValue) { v = new BigDecimal(numTypedValue.doubleValue()); } else if (isBooleanTypedValue) { v = new BigDecimal(BooleanUtils.toInteger(boolTypedValue.booleanValue())); } else if (isDateTypedValue) { v = new BigDecimal(dateTypedValue.getTime()); } } else if (Boolean.class.equals(untypedValueClass)) { if (isStringTypedValue) { v = BooleanUtils.toBooleanObject(strTypedValue); } else if (isNumberTypedValue) { v = BooleanUtils.toBooleanObject(numTypedValue.intValue()); } else if (isDateTypedValue) { v = BooleanUtils.toBooleanObject((int) dateTypedValue.getTime()); } } else if (Byte.class.equals(untypedValueClass)) { if (isStringTypedValue) { v = Byte.valueOf(strTypedValue); } else if (isNumberTypedValue) { v = new Byte(numTypedValue.byteValue()); } else if (isBooleanTypedValue) { v = new Byte((byte) BooleanUtils.toInteger(boolTypedValue.booleanValue())); } else if (isDateTypedValue) { v = new Byte((byte) dateTypedValue.getTime()); } } else if (byte[].class.equals(untypedValueClass)) { if (isStringTypedValue) { v = strTypedValue.getBytes(); } } else if (Double.class.equals(untypedValueClass)) { if (isStringTypedValue) { v = NumberUtils.createDouble(strTypedValue); } else if (isNumberTypedValue) { v = new Double(numTypedValue.doubleValue()); } else if (isBooleanTypedValue) { v = new Double(BooleanUtils.toInteger(boolTypedValue.booleanValue())); } else if (isDateTypedValue) { v = new Double(dateTypedValue.getTime()); } } else if (Float.class.equals(untypedValueClass)) { if (isStringTypedValue) { v = NumberUtils.createFloat(strTypedValue); } else if (isNumberTypedValue) { v = new Float(numTypedValue.floatValue()); } else if (isBooleanTypedValue) { v = new Float(BooleanUtils.toInteger(boolTypedValue.booleanValue())); } else if (isDateTypedValue) { v = new Float(dateTypedValue.getTime()); } } else if (Short.class.equals(untypedValueClass)) { if (isStringTypedValue) { v = NumberUtils.createInteger(strTypedValue); } else if (isNumberTypedValue) { v = new Integer(numTypedValue.intValue()); } else if (isBooleanTypedValue) { v = BooleanUtils.toIntegerObject(boolTypedValue.booleanValue()); } else if (isDateTypedValue) { v = new Integer((int) dateTypedValue.getTime()); } } else if (Integer.class.equals(untypedValueClass)) { if (isStringTypedValue) { v = NumberUtils.createInteger(strTypedValue); } else if (isNumberTypedValue) { v = new Integer(numTypedValue.intValue()); } else if (isBooleanTypedValue) { v = BooleanUtils.toIntegerObject(boolTypedValue.booleanValue()); } else if (isDateTypedValue) { v = new Integer((int) dateTypedValue.getTime()); } } else if (Long.class.equals(untypedValueClass)) { if (isStringTypedValue) { v = NumberUtils.createLong(strTypedValue); } else if (isNumberTypedValue) { v = new Long(numTypedValue.longValue()); } else if (isBooleanTypedValue) { v = new Long(BooleanUtils.toInteger(boolTypedValue.booleanValue())); } else if (isDateTypedValue) { v = new Long(dateTypedValue.getTime()); } } else if (java.sql.Date.class.equals(untypedValueClass)) { if (isNumberTypedValue) { v = new java.sql.Date(numTypedValue.longValue()); } else if (isDateTypedValue) { v = new java.sql.Date(dateTypedValue.getTime()); } } else if (java.sql.Time.class.equals(untypedValueClass)) { if (isNumberTypedValue) { v = new java.sql.Time(numTypedValue.longValue()); } else if (isDateTypedValue) { v = new java.sql.Time(dateTypedValue.getTime()); } } else if (java.sql.Timestamp.class.equals(untypedValueClass)) { if (isNumberTypedValue) { v = new java.sql.Timestamp(numTypedValue.longValue()); } else if (isDateTypedValue) { v = new java.sql.Timestamp(dateTypedValue.getTime()); } } else if (Date.class.equals(untypedValueClass)) { if (isNumberTypedValue) { v = new Date(numTypedValue.longValue()); } else if (isStringTypedValue) { try { v = DateFormat.getDateInstance().parse(strTypedValue); } catch (ParseException e) { LOG.error("Unable to parse the date : " + strTypedValue); LOG.debug(e.getMessage()); } } } return v; }
From source file:fr.aliasource.index.solr.SolrClientFactory.java
public SolrClientFactory() { logger = LogFactory.getLog(getClass()); servers = Collections.synchronizedMap(new HashMap<String, SelfOptimizingServer>()); }
From source file:com.chnoumis.commons.log.LogInterceptor.java
public void afterReturning(Object arg0, Method arg1, Object[] arg2, Object arg3) throws Throwable { log = LogFactory.getLog(arg3.getClass()); log.info("Ending method: " + arg1.getName()); }
From source file:fr.aliasource.webmail.proxy.impl.LoginImpl.java
public LoginImpl(ProxyConfiguration conf, LocatorRegistry locator) { logger = LogFactory.getLog(getClass()); this.imapUri = conf.getSetting(ProxyConfiguration.IMAP_URI); this.smtpUri = conf.getSetting(ProxyConfiguration.SMTP_URI); this.sieveUri = conf.getSetting(ProxyConfiguration.SIEVE_URI); this.singleDomain = "true".equals(conf.getSetting(ProxyConfiguration.SINGLE_DOMAIN)); this.defaultDomain = conf.getSetting(ProxyConfiguration.DEFAULT_DOMAIN); this.domainInImapLogin = !"false".equals(conf.getSetting(ProxyConfiguration.DOMAIN_IN_IMAP_LOGIN)); logger.info("imap: " + imapUri + " smtp: " + smtpUri + " defaultDomain: " + defaultDomain); this.locator = locator; }
From source file:gridool.marshaller.JdkMarshaller.java
@Override public <T> void marshall(T obj, OutputStream out) throws GridException { try {//from w w w .jav a2s .c o m ObjectUtils.toStream(obj, out); } catch (Throwable e) { LogFactory.getLog(getClass()).error(e.getMessage(), e); throw new GridException(e); } }
From source file:de.berlios.jedi.logic.admin.LoginManager.java
/** * Checks if the password is equal to the admin password.<br> * The admin password is set in the configuration file. * /* w ww .j a v a 2 s . c o m*/ * @param password * The password to check. * @return True if the password is correct. * @throws IncorrectPasswordException * If the password is not correct. */ public boolean login(String password) throws IncorrectPasswordException { if (password != null && password.equals(ConfigurationFactory.getConfiguration().getString("admin.password"))) { return true; } LogFactory.getLog(LoginManager.class).error("Incorrect password when login: " + password); throw new IncorrectPasswordException("Incorrect password"); }
From source file:fr.aliasource.webmail.message.DeleteMessageAction.java
public DeleteMessageAction() { this.logger = LogFactory.getLog(getClass()); }
From source file:com.springsource.insight.plugin.logging.CommonsLoggingOperationCollectionAspectTest.java
@Test public void testLogErrorMessageWithException() { String msg = "testLogErrorMessageWithException"; Log logger = LogFactory.getLog(getClass()); Throwable t = new IllegalArgumentException(msg); logger.error(msg, t);//ww w . java 2s . c o m assertLoggingOperation(Log.class, "ERROR", msg, t); }
From source file:com.amazonaws.client.metrics.support.SdkMBeanRegistrySupport.java
@Override public boolean unregisterMBean(String objectName) { try {/*from ww w. j a v a 2s . c o m*/ return MBeans.unregisterMBean(objectName); } catch (Exception ex) { LogFactory.getLog(SdkMBeanRegistrySupport.class).warn("", ex); } return false; }
From source file:com.jpeterson.littles3.bo.CanonicalUserTest.java
/** * Create the test case/*from ww w . j a va 2s . c om*/ * * @param testName * name of the test case */ public CanonicalUserTest(String testName) { super(testName); logger = LogFactory.getLog(this.getClass()); logger.debug("CanonicalUserTest"); }