1 16 17 package org.springframework.beans.factory.config; 18 19 import org.springframework.beans.factory.FactoryBean; 20 import org.springframework.beans.factory.InitializingBean; 21 import org.springframework.core.io.Resource; 22 23 38 public class ResourceFactoryBean implements FactoryBean, InitializingBean { 39 40 private Resource resource; 41 42 43 49 public void setLocation(Resource location) { 50 this.resource = location; 51 } 52 53 public void afterPropertiesSet() { 54 if (this.resource == null) { 55 throw new IllegalArgumentException ("'location' is required"); 56 } 57 } 58 59 60 public Object getObject() { 61 return this.resource; 62 } 63 64 public Class getObjectType() { 65 return (this.resource != null ? this.resource.getClass() : Resource.class); 66 } 67 68 public boolean isSingleton() { 69 return true; 70 } 71 72 } 73 | Popular Tags |