1. /*
  2. * Copyright 2002-2004 the original author or authors.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package org.springframework.context;
  17. import org.springframework.core.io.ResourceLoader;
  18. /**
  19. * Interface to be implemented by any object that wishes to be notified
  20. * of the ResourceLoader (typically the ApplicationContext) that it runs in.
  21. *
  22. * <p>Note that Resource dependencies can also be exposed as bean properties
  23. * of type Resource, populated via Strings with automatic type conversion by
  24. * the bean factory. This removes the need for implementing any callback
  25. * interface just for the purpose of accessing a specific file resource.
  26. *
  27. * <p>You typically need a ResourceLoader when your application object has
  28. * to access a variety of file resources whose names are calculated. A good
  29. * strategy is to make the object use a DefaultResourceLoader but still
  30. * implement ResourceLoaderAware to allow for overriding when running in an
  31. * ApplicationContext. See ReloadableResourceBundleMessageSource for an example.
  32. *
  33. * @author Juergen Hoeller
  34. * @since 10.03.2004
  35. * @see ApplicationContextAware
  36. * @see org.springframework.beans.factory.InitializingBean
  37. * @see org.springframework.core.io.DefaultResourceLoader
  38. * @see org.springframework.context.support.ReloadableResourceBundleMessageSource
  39. */
  40. public interface ResourceLoaderAware {
  41. /**
  42. * Set the ResourceLoader that this object runs in.
  43. * <p>Invoked after population of normal bean properties but before an init
  44. * callback like InitializingBean's afterPropertiesSet or a custom init-method.
  45. * Invoked before ApplicationContextAware's setApplicationContext.
  46. * @param resourceLoader ResourceLoader object to be used by this object
  47. */
  48. void setResourceLoader(ResourceLoader resourceLoader);
  49. }