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.beans.factory.HierarchicalBeanFactory;
  18. import org.springframework.beans.factory.ListableBeanFactory;
  19. import org.springframework.core.io.ResourceLoader;
  20. /**
  21. * Central interface to provide configuration for an application.
  22. * This is read-only while the application is running, but may be
  23. * reloaded if the implementation supports this.
  24. *
  25. * <p>An ApplicationContext provides:
  26. * <ul>
  27. * <li>Bean factory methods, inherited from ListableBeanFactory.
  28. * This avoids the need for applications to use singletons.
  29. * <li>The ability to resolve messages, supporting internationalization.
  30. * Inherited from the MessageSource interface.
  31. * <li>The ability to load file resources in a generic fashion.
  32. * Inherited from the ResourceLoader interface.
  33. * <li>The ability to publish events. Implementations must provide a means
  34. * of registering event listeners.
  35. * <li>Inheritance from a parent context. Definitions in a descendant context
  36. * will always take priority. This means, for example, that a single parent
  37. * context can be used by an entire web application, while each servlet has
  38. * its own child context that is independent of that of any other servlet.
  39. * </ul>
  40. *
  41. * <p>In addition to standard bean factory lifecycle capabilities,
  42. * ApplicationContext implementations need to detect ApplicationContextAware
  43. * beans and invoke the setApplicationContext method accordingly.
  44. *
  45. * @author Rod Johnson
  46. * @author Juergen Hoeller
  47. * @version $Id: ApplicationContext.java,v 1.15 2004/03/22 10:34:50 jhoeller Exp $
  48. * @see ApplicationContextAware#setApplicationContext
  49. */
  50. public interface ApplicationContext
  51. extends ListableBeanFactory, HierarchicalBeanFactory, MessageSource, ResourceLoader {
  52. /**
  53. * Return the parent context, or null if there is no parent,
  54. * and this is the root of the context hierarchy.
  55. * @return the parent context, or null if there is no parent
  56. */
  57. ApplicationContext getParent();
  58. /**
  59. * Return a friendly name for this context.
  60. * @return a display name for this context
  61. */
  62. String getDisplayName();
  63. /**
  64. * Return the timestamp when this context was first loaded.
  65. * @return the timestamp (ms) when this context was first loaded
  66. */
  67. long getStartupDate();
  68. /**
  69. * Notify all listeners registered with this application of an application
  70. * event. Events may be framework events (such as RequestHandledEvent)
  71. * or application-specific events.
  72. * @param event event to publish
  73. * @see org.springframework.web.context.support.RequestHandledEvent
  74. */
  75. void publishEvent(ApplicationEvent event);
  76. }