com.interface21.context.support
Class ClassPathXmlApplicationContext

java.lang.Object
  |
  +--com.interface21.context.support.AbstractApplicationContext
        |
        +--com.interface21.context.support.AbstractXmlApplicationContext
              |
              +--com.interface21.context.support.FileSystemXmlApplicationContext
                    |
                    +--com.interface21.context.support.ClassPathXmlApplicationContext
All Implemented Interfaces:
ApplicationContext, BeanFactory, ListableBeanFactory, MessageSource

public class ClassPathXmlApplicationContext
extends FileSystemXmlApplicationContext

Standalone XML application context, taking the context definition files from the classpath. Mainly useful for test harnesses, but also for application contexts embedded within JARs.

Note: Generally treats (file) paths as class path resources, when using ApplicationContext.getResourceAsStream. Only supports full classpath names including package specification, like "/mypackage/myresource.dat".

Author:
Rod Johnson, Juergen Hoeller
See Also:
ApplicationContext.getResourceAsStream(java.lang.String), getResourceByPath(java.lang.String)

Fields inherited from class com.interface21.context.support.AbstractApplicationContext
logger, MESSAGE_SOURCE_BEAN_NAME, OPTIONS_BEAN_NAME
 
Constructor Summary
ClassPathXmlApplicationContext(java.lang.String locations)
           
ClassPathXmlApplicationContext(java.lang.String[] locations)
           
 
Method Summary
protected  ApplicationContext createParentContext(java.lang.String[] locations)
           
 java.lang.String getResourceBasePath()
          This implementation returns null, as there is no base path for class path resources.
protected  java.io.InputStream getResourceByPath(java.lang.String path)
          This implementation treats paths as classpath resources.
 
Methods inherited from class com.interface21.context.support.FileSystemXmlApplicationContext
getInputStreamForBeanFactory
 
Methods inherited from class com.interface21.context.support.AbstractXmlApplicationContext
getBeanFactory, refreshBeanFactory
 
Methods inherited from class com.interface21.context.support.AbstractApplicationContext
addListener, configureManagedObject, getAliases, getBean, getBean, getBeanDefinitionCount, getBeanDefinitionNames, getBeanDefinitionNames, getDisplayName, getMessage, getMessage, getMessage, getOptions, getParent, getResourceAsStream, getStartupDate, isSingleton, onRefresh, publishEvent, refresh, removeSharedObject, setDisplayName, setParent, sharedObject, shareObject, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ClassPathXmlApplicationContext

public ClassPathXmlApplicationContext(java.lang.String locations)
                               throws ApplicationContextException,
                                      java.io.IOException

ClassPathXmlApplicationContext

public ClassPathXmlApplicationContext(java.lang.String[] locations)
                               throws ApplicationContextException,
                                      java.io.IOException
Method Detail

createParentContext

protected ApplicationContext createParentContext(java.lang.String[] locations)
                                          throws java.io.IOException
Overrides:
createParentContext in class FileSystemXmlApplicationContext

getResourceByPath

protected java.io.InputStream getResourceByPath(java.lang.String path)
                                         throws java.io.IOException
This implementation treats paths as classpath resources. Only supports full classpath names including package specification, like "/mypackage/myresource.dat".
Overrides:
getResourceByPath in class AbstractApplicationContext
Following copied from class: com.interface21.context.support.AbstractApplicationContext
Parameters:
path - path to the resource
Returns:
InputStream for the specified resource, can be null if not found (instead of throwing an exception)
Throws:
java.io.IOException - exception when opening the specified resource

getResourceBasePath

public java.lang.String getResourceBasePath()
This implementation returns null, as there is no base path for class path resources.
Overrides:
getResourceBasePath in class AbstractApplicationContext
Following copied from interface: com.interface21.context.ApplicationContext
Returns:
the resource base path (ending with a separator), or null


Rod Johnson and Spring contributors 2001-2003.