Package edu.uiuc.ncsa.security.core.cf
Class CFLoader
- java.lang.Object
- 
- edu.uiuc.ncsa.security.core.cf.CFLoader
 
- 
 public class CFLoader extends Object Loads teh configuration from the file or other source. Typical idiom for use:FileInputStream fis = getFileInputStream("alias/cfg-alias.xml");In this case, a file with a relative path is loaded, the bundle created for the given tag (so all of the tags named "service" are in the resulting bundle) and then a specific configuration of type "service" with name "A" is retrieved. This is the top node for that configuration. All environment variables and inheritence has been resolved, so you can just use the CFNode's methods.CFLoaderconfig = new CFLoader();CFBundlebundle = config.loadBundle(fis, "service");CFNodenode = bundle.getNamedConfig("A");
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classCFLoader.Builder
 - 
Field SummaryFields Modifier and Type Field Description static StringENV_END_ELEMENTstatic StringENV_START_ELEMENTstatic StringENV_TAGstatic StringFILE_TAGstatic StringINCLUDE_TAGstatic StringKEY_TAG
 - 
Constructor SummaryConstructors Constructor Description CFLoader()CFLoader(CFLoader.Builder builder)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description FilegetFile()InputStreamgetInputStream()StringgetResource()StringgetTagName()protected booleanhasFile()protected booleanhasInputStream()protected booleanhasResource()protected booleanisEndEnv(String l)Does the trimmed line end with an environment end tag?protected booleanisStartEnv(String l)Does the trimmed line start and environment entry?CFBundleloadBundle()Used with the builder.CFBundleloadBundle(File file, String tagName)Loads the specified file.CFBundleloadBundle(InputStream inputStream, String tagName)Main entry point for loading a configuration.protected CFBundleloadBundle(InputStream inputStream, String tagName, EnvStack envStack, Set<String> loadedFiles)Loads a configuration.CFBundleloadBundle(String resource, String tagName)Loads the specified resource as a stream.protected EnvTable<? extends SKey,? extends EnvEntry>processEnvDocument(InputStream inputStream)Process a single env document from any source.protected DocumentresolveEnvironment(InputStream inputStream, EnvStack stack, Set<String> loadedFiles, boolean isRoot)Returns a valid XML document with the environment references done.protected NoderesolveFileReferences(Document rootDoc, Node cfg, EnvStack stack, Set<String> visitedFiles)All the actual work for loading files is done here.voidsetFile(File file)voidsetInputStream(InputStream inputStream)voidsetResource(String resource)CFLoadersetTagName(String tagName)Supports builder pattern
 
- 
- 
- 
Field Detail- 
FILE_TAGpublic static final String FILE_TAG - See Also:
- Constant Field Values
 
 - 
INCLUDE_TAGpublic static final String INCLUDE_TAG - See Also:
- Constant Field Values
 
 - 
ENV_TAGpublic static final String ENV_TAG - See Also:
- Constant Field Values
 
 - 
KEY_TAGpublic static final String KEY_TAG - See Also:
- Constant Field Values
 
 - 
ENV_START_ELEMENTpublic static final String ENV_START_ELEMENT - See Also:
- Constant Field Values
 
 - 
ENV_END_ELEMENTpublic static final String ENV_END_ELEMENT - See Also:
- Constant Field Values
 
 
- 
 - 
Constructor Detail- 
CFLoaderpublic CFLoader() 
 - 
CFLoaderpublic CFLoader(CFLoader.Builder builder) 
 
- 
 - 
Method Detail- 
getTagNamepublic String getTagName() 
 - 
hasFileprotected boolean hasFile() 
 - 
hasResourceprotected boolean hasResource() 
 - 
hasInputStreamprotected boolean hasInputStream() 
 - 
getInputStreampublic InputStream getInputStream() 
 - 
setInputStreampublic void setInputStream(InputStream inputStream) 
 - 
getResourcepublic String getResource() 
 - 
setResourcepublic void setResource(String resource) 
 - 
getFilepublic File getFile() 
 - 
setFilepublic void setFile(File file) 
 - 
setTagNamepublic CFLoader setTagName(String tagName) Supports builder pattern- Parameters:
- tagName-
- Returns:
 
 - 
loadBundlepublic CFBundle loadBundle(String resource, String tagName) throws MyConfigurationException, CircularReferenceException Loads the specified resource as a stream.- Parameters:
- resource-
- tagName-
- Returns:
- Throws:
- MyConfigurationException
- CircularReferenceException
 
 - 
loadBundlepublic CFBundle loadBundle() throws MyConfigurationException, CircularReferenceException Used with the builder. Set the source and tagname then invoke.- Returns:
- Throws:
- MyConfigurationException
- CircularReferenceException
 
 - 
loadBundlepublic CFBundle loadBundle(File file, String tagName) throws MyConfigurationException, CircularReferenceException Loads the specified file.- Parameters:
- file-
- tagName-
- Returns:
- Throws:
- MyConfigurationException
- CircularReferenceException
 
 - 
loadBundlepublic CFBundle loadBundle(InputStream inputStream, String tagName) throws MyConfigurationException, CircularReferenceException Main entry point for loading a configuration. This resolves all environment variables and file import, then parses the result as (valid) XML.- Parameters:
- inputStream-
- Returns:
- Throws:
- MyConfigurationException
- CircularReferenceException
 
 - 
loadBundleprotected CFBundle loadBundle(InputStream inputStream, String tagName, EnvStack envStack, Set<String> loadedFiles) throws MyConfigurationException, CircularReferenceException Loads a configuration. This will also have the environment and- Parameters:
- inputStream-
- loadedFiles-
- Returns:
- Throws:
- MyConfigurationException
- CircularReferenceException
 
 - 
resolveEnvironmentprotected Document resolveEnvironment(InputStream inputStream, EnvStack stack, Set<String> loadedFiles, boolean isRoot) throws Throwable Returns a valid XML document with the environment references done.- Parameters:
- inputStream-
- stack-
- Returns:
- Throws:
- Throwable
 
 - 
isStartEnvprotected boolean isStartEnv(String l) Does the trimmed line start and environment entry?- Parameters:
- l-
- Returns:
 
 - 
isEndEnvprotected boolean isEndEnv(String l) Does the trimmed line end with an environment end tag?- Parameters:
- l-
- Returns:
 
 - 
processEnvDocumentprotected EnvTable<? extends SKey,? extends EnvEntry> processEnvDocument(InputStream inputStream) throws Throwable Process a single env document from any source. The document is a valid XML file and only environment tags are processed. At the end of this, every envionment element will have been processed and put into a table.- Parameters:
- inputStream-
- Returns:
- Throws:
- Throwable
 
 - 
resolveFileReferencesprotected Node resolveFileReferences(Document rootDoc, Node cfg, EnvStack stack, Set<String> visitedFiles) throws Throwable All the actual work for loading files is done here. This looks for elements inside the config tag of the form<file include="path"/>These are read and each line is inserted into the document. Included files may also include other files, which will be resolved as well. No promise of ordering is done.Nota BeneEach include is a complete configuration file, not a fragment! They are processed as if independent (with their own env that retains scope). - Parameters:
- cfg-
- visitedFiles- Files already processed. Prevents cycles.
- Returns:
- Throws:
- Throwable
 
 
- 
 
-