1 16 17 package org.springframework.beans.factory.config; 18 19 import org.apache.commons.logging.Log; 20 import org.apache.commons.logging.LogFactory; 21 import org.springframework.beans.factory.FactoryBean; 22 import org.springframework.beans.factory.InitializingBean; 23 24 36 public class CommonsLogFactoryBean implements FactoryBean, InitializingBean { 37 38 private Log log; 39 40 41 46 public void setLogName(String logName) { 47 this.log = LogFactory.getLog(logName); 48 } 49 50 51 public void afterPropertiesSet() { 52 if (this.log == null) { 53 throw new IllegalArgumentException ("logName is required"); 54 } 55 } 56 57 public Object getObject() { 58 return log; 59 } 60 61 public Class getObjectType() { 62 return (this.log != null ? this.log.getClass() : Log.class); 63 } 64 65 public boolean isSingleton() { 66 return true; 67 } 68 69 } 70 | Popular Tags |