Class JamServiceContextImpl
- java.lang.Object
-
- org.apache.xmlbeans.impl.jam.internal.JamLoggerImpl
-
- org.apache.xmlbeans.impl.jam.internal.JamServiceContextImpl
-
- All Implemented Interfaces:
ElementContext,JamServiceParams,JamLogger,JamServiceContext
public class JamServiceContextImpl extends JamLoggerImpl implements JamServiceContext, JamServiceParams, ElementContext
Takes settings from the user (through JamServiceParams) and exposes them to the implementation (through JamServiceContext).
-
-
Constructor Summary
Constructors Constructor Description JamServiceContextImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddClassBuilder(JamClassBuilder builder)Adds a custom JamClassBuilder which will be consulted by the JamClassLoader when constructing representation of java types.voidaddClassLoader(java.lang.ClassLoader cl)DOCMEvoidaddClasspath(java.io.File classpathElement)Adds an elements to the JamService classpath.voidaddInitializer(MVisitor initializer)voidaddSourcepath(java.io.File sourcepathElement)Adds an elements to the JamService sourcepath.voidaddToolClasspath(java.io.File classpathElement)Adds an elements to the tool classpath.AnnotationProxycreateAnnotationProxy(java.lang.String jsr175typename)Creates an empty appropriate proxy for the given 175 annotation instance.voidexcludeClass(java.lang.String qualifiedClassname)Names a specific class to be excluded in the JamService.voidexcludeClassFile(java.io.File[] classpath, java.io.File classFile)Excludes a single class File in the JamService in exactly the same way theat includeSourceFile() includes a source file.voidexcludeClassPattern(java.io.File[] classpath, java.lang.String pattern)Specifies a set of java class files to be excluded from the JamService.voidexcludeSourceFile(java.io.File[] sourcepath, java.io.File sourceFile)Excludes a single source File in the JamService in exactly the same way theat includeSourceFile() includes a source file.voidexcludeSourcePattern(java.io.File[] sourcepath, java.lang.String pattern)Specifies a set of java source files to be excluded in the JamService.java.lang.String[]getAllClassnames()Returns an array containing the qualified names of the classes which are in the Service class set.JamClassBuildergetBaseBuilder()JamClassLoadergetClassLoader()Returns the classloader the elements should use for type resolution.MVisitorgetInitializer()ResourcePathgetInputClasspath()ResourcePathgetInputSourcepath()JamLoggergetLogger()java.lang.StringgetProperty(java.lang.String name)java.lang.ClassLoader[]getReflectionClassLoaders()java.io.File[]getSourceFiles()JavadocTagParsergetTagParser()Returns the JavadocTagParser to be used in processing javadoc tags.ResourcePathgetToolClasspath()java.io.File[]getUnstructuredSourceFiles()voidincludeClass(java.lang.String qualifiedClassname)Names a specific class to be included in the JamService.voidincludeClassFile(java.io.File[] classpath, java.io.File classFile)Includes a single class File in the JamService in exactly the same way theat includeSourceFile() includes a source file.voidincludeClassPattern(java.io.File[] classpath, java.lang.String pattern)Specifies a set of java class files to be excluded in the JamService.voidincludeSourceFile(java.io.File file)Include a single java source file to be viewed.voidincludeSourceFile(java.io.File[] sourcepath, java.io.File sourceFile)Includes a single source File in the JamService.voidincludeSourcePattern(java.io.File[] sourcepath, java.lang.String pattern)Specifies a set of java source files to be included in the JamService.booleanis14WarningsEnabled()voidset14WarningsEnabled(boolean b)Sets whether warnings should be displayed when running under JDK 1.4.voidsetClassLoader(JamClassLoader loader)voidsetCommentInitializer(MVisitor initializer)voidsetJamLogger(JamLogger logger)Sets the JamLogger which will receive error and warning messages from JAM.voidsetJavadocTagParser(JavadocTagParser tp)voidsetLoggerWriter(java.io.PrintWriter out)Sets a PrintWriter to which the JamService implementation should log errors and debugging information.voidsetParentClassLoader(JamClassLoader loader)Sets the parent JamClassLoader of the service JamClassLoader.voidsetProperty(java.lang.String name, java.lang.String value)Sets an implementation-specific property.voidsetPropertyInitializer(MVisitor initializer)voidsetUseSystemClasspath(boolean use)Specifies whether the JAM Service should load classes from the system classpath.-
Methods inherited from class org.apache.xmlbeans.impl.jam.internal.JamLoggerImpl
error, error, isVerbose, isVerbose, isVerbose, setShowWarnings, setVerbose, setVerbose, verbose, verbose, verbose, verbose, warning, warning
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.xmlbeans.impl.jam.provider.JamLogger
error, error, isVerbose, isVerbose, isVerbose, setShowWarnings, setVerbose, verbose, verbose, verbose, verbose, warning, warning
-
Methods inherited from interface org.apache.xmlbeans.impl.jam.JamServiceParams
setShowWarnings, setVerbose, setVerbose
-
-
-
-
Method Detail
-
setClassLoader
public void setClassLoader(JamClassLoader loader)
-
getBaseBuilder
public JamClassBuilder getBaseBuilder()
- Specified by:
getBaseBuilderin interfaceJamServiceContext
-
getTagParser
public JavadocTagParser getTagParser()
Description copied from interface:JamServiceContextReturns the JavadocTagParser to be used in processing javadoc tags. This never returns null - if no parser was specified by the user, the default one is used. This method should be used only by JavadocClassBuilder.
- Specified by:
getTagParserin interfaceJamServiceContext
-
getAllClassnames
public java.lang.String[] getAllClassnames() throws java.io.IOExceptionReturns an array containing the qualified names of the classes which are in the Service class set.- Specified by:
getAllClassnamesin interfaceJamServiceContext- Throws:
java.io.IOException
-
getLogger
public JamLogger getLogger()
- Specified by:
getLoggerin interfaceElementContext- Specified by:
getLoggerin interfaceJamServiceContext
-
getSourceFiles
public java.io.File[] getSourceFiles() throws java.io.IOException- Specified by:
getSourceFilesin interfaceJamServiceContext- Throws:
java.io.IOException
-
getUnstructuredSourceFiles
public java.io.File[] getUnstructuredSourceFiles()
-
getInputClasspath
public ResourcePath getInputClasspath()
- Specified by:
getInputClasspathin interfaceJamServiceContext- Returns:
- The classpath to be searched when trying to initialize an MClass for a java class which was not in the inputSources or inputClasses, or null.
-
getInputSourcepath
public ResourcePath getInputSourcepath()
- Specified by:
getInputSourcepathin interfaceJamServiceContext- Returns:
- The sourcepath to be searched when trying to initialize an MClass for a java class which was not in the inputSources or inputClasses, or null.
-
getToolClasspath
public ResourcePath getToolClasspath()
- Specified by:
getToolClasspathin interfaceJamServiceContext- Returns:
- The classpath to be used in loading external classes on which the service implementation depends, or null. This is not generally needed.
-
getProperty
public java.lang.String getProperty(java.lang.String name)
- Specified by:
getPropertyin interfaceJamServiceContext- Returns:
- an implementation-specific property, as specified by
JamServiceParams.setProperty().
-
getInitializer
public MVisitor getInitializer()
- Specified by:
getInitializerin interfaceJamServiceContext
-
addClassBuilder
public void addClassBuilder(JamClassBuilder builder)
Description copied from interface:JamServiceParamsAdds a custom JamClassBuilder which will be consulted by the JamClassLoader when constructing representation of java types. The given class builder will have priority over priority over JAM's default source- and reflection-based ClassBuilders. If this method id called more than once, the extra class builders will be prioritized in the order in which they were added.
- Specified by:
addClassBuilderin interfaceJamServiceParams
-
setCommentInitializer
public void setCommentInitializer(MVisitor initializer)
-
setPropertyInitializer
public void setPropertyInitializer(MVisitor initializer)
- Specified by:
setPropertyInitializerin interfaceJamServiceParams
-
addInitializer
public void addInitializer(MVisitor initializer)
- Specified by:
addInitializerin interfaceJamServiceParams
-
setJavadocTagParser
public void setJavadocTagParser(JavadocTagParser tp)
- Specified by:
setJavadocTagParserin interfaceJamServiceParams
-
includeSourceFile
public void includeSourceFile(java.io.File file)
Description copied from interface:JamServiceParamsInclude a single java source file to be viewed. Note that if your code is able to understand the file/package structure in which the source exists, you may get better performance by using the various include... methods which take a sourcepath parameter.
- Specified by:
includeSourceFilein interfaceJamServiceParams
-
includeSourcePattern
public void includeSourcePattern(java.io.File[] sourcepath, java.lang.String pattern)Description copied from interface:JamServiceParamsSpecifies a set of java source files to be included in the JamService.Note that calling this method implicitly includes the 'root' in the sourcepath (exactly as if addSourcepath(root) had been called).
- Specified by:
includeSourcePatternin interfaceJamServiceParams- Parameters:
sourcepath- Root directory/ies containing source files.pattern- A relative file pattern (as described above under 'Include and Exclude Patterns').
-
includeClassPattern
public void includeClassPattern(java.io.File[] classpath, java.lang.String pattern)Description copied from interface:JamServiceParamsSpecifies a set of java class files to be excluded in the JamService. Note that calling this method implicitly includes the 'classpath' in the classpath (as in a call to addClasspath(classpath)).- Specified by:
includeClassPatternin interfaceJamServiceParams- Parameters:
classpath- Root directory of the source files.pattern- A relative file pattern (as described above under 'Include and Exclude Patterns').
-
excludeSourcePattern
public void excludeSourcePattern(java.io.File[] sourcepath, java.lang.String pattern)Description copied from interface:JamServiceParamsSpecifies a set of java source files to be excluded in the JamService. Note that calling this method implicitly includes the 'sourcepath' in the sourcepath (as in a call to addSourcepath(sourcepath)).- Specified by:
excludeSourcePatternin interfaceJamServiceParams- Parameters:
sourcepath- Root directory of the source files.pattern- A relative file pattern (as described above under 'Include and Exclude Patterns').
-
excludeClassPattern
public void excludeClassPattern(java.io.File[] classpath, java.lang.String pattern)Description copied from interface:JamServiceParamsSpecifies a set of java class files to be excluded from the JamService. Note that calling this method implicitly includes the 'classpath' in the classpath (as in a call to addClasspath(classpath)).- Specified by:
excludeClassPatternin interfaceJamServiceParams- Parameters:
classpath- Root directory of the source files.pattern- A relative file pattern (as described above under 'Include and Exclude Patterns').
-
includeSourceFile
public void includeSourceFile(java.io.File[] sourcepath, java.io.File sourceFile)Description copied from interface:JamServiceParamsIncludes a single source File in the JamService. The sourcepath parameter should identify the source sourcepath of the java source file; the sourceFile parameter must be under the sourcepath subtree.
For example, if a class "foo.bar.MyClass" is stored in a file "c:/myproject/src/foo/bar/MyClass.java", that class could be included in the service by calling
includeSourceFile(new File("c:/myproject/src"), new File("c:/myproject/src/foo/bar/MyClass.java"));Note that this equivalent to calling
includeSourceFiles(new File("c:/myproject/src"),"foo/bar/MyClass.java");If you are calling this method and have more than one sourcepath directory, and do not readily know which is the correct sourcepath for a given source File, you can use the getRootForFile() utility method to determine the correct sourcepath to use.
Note that calling this method implicitly includes the 'sourcepath' in the sourcepath (exactly as if addSourcepath(sourcepath) had been called).
- Specified by:
includeSourceFilein interfaceJamServiceParams- Parameters:
sourcepath- source sourcepath for the java source filesourceFile- the java source file
-
excludeSourceFile
public void excludeSourceFile(java.io.File[] sourcepath, java.io.File sourceFile)Description copied from interface:JamServiceParamsExcludes a single source File in the JamService in exactly the same way theat includeSourceFile() includes a source file.
- Specified by:
excludeSourceFilein interfaceJamServiceParams
-
includeClassFile
public void includeClassFile(java.io.File[] classpath, java.io.File classFile)Description copied from interface:JamServiceParamsIncludes a single class File in the JamService in exactly the same way theat includeSourceFile() includes a source file.
- Specified by:
includeClassFilein interfaceJamServiceParams
-
excludeClassFile
public void excludeClassFile(java.io.File[] classpath, java.io.File classFile)Description copied from interface:JamServiceParamsExcludes a single class File in the JamService in exactly the same way theat includeSourceFile() includes a source file.
- Specified by:
excludeClassFilein interfaceJamServiceParams
-
includeClass
public void includeClass(java.lang.String qualifiedClassname)
Description copied from interface:JamServiceParamsNames a specific class to be included in the JamService. Note that this will return an 'unresolved' JClass unless a source or class file for the named class is available in the classpath or sourcepath.- Specified by:
includeClassin interfaceJamServiceParams- Parameters:
qualifiedClassname- a full-qualified classname
-
excludeClass
public void excludeClass(java.lang.String qualifiedClassname)
Description copied from interface:JamServiceParamsNames a specific class to be excluded in the JamService. Note that this will have no affect if the named class cannot be found in the sourcepath or classpath.- Specified by:
excludeClassin interfaceJamServiceParams- Parameters:
qualifiedClassname- a full-qualified classname
-
addClasspath
public void addClasspath(java.io.File classpathElement)
Description copied from interface:JamServiceParamsAdds an elements to the JamService classpath. The service's JamClassLoader will search this path to find a .class file on which to base a JClass when requested to load a class that was not included in the service and for which no source could be found in the sourcepath.- Specified by:
addClasspathin interfaceJamServiceParams- Parameters:
classpathElement- elements of the classpath
-
setLoggerWriter
public void setLoggerWriter(java.io.PrintWriter out)
Description copied from interface:JamServiceParamsSets a PrintWriter to which the JamService implementation should log errors and debugging information. If this is never set, all such output will be suppressed.- Specified by:
setLoggerWriterin interfaceJamServiceParams- Parameters:
out- a PrintWriter to write to
-
setJamLogger
public void setJamLogger(JamLogger logger)
Description copied from interface:JamServiceParamsSets the JamLogger which will receive error and warning messages from JAM.- Specified by:
setJamLoggerin interfaceJamServiceParams
-
addSourcepath
public void addSourcepath(java.io.File sourcepathElement)
Description copied from interface:JamServiceParamsAdds an elements to the JamService sourcepath. The service's JamClassLoader will search this path to find a .java file on which to base a JClass when requested to load a class that was not included in the service.- Specified by:
addSourcepathin interfaceJamServiceParams
-
addToolClasspath
public void addToolClasspath(java.io.File classpathElement)
Description copied from interface:JamServiceParamsAdds an elements to the tool classpath. This is the classpath that will be used by the JamService implementation to find any libraries on which it depends. This classpath is distinct from the service classpath set by addClasspath() in that it has no affect on the input class set - it's only used for finding classes on which JAM itself depends.
- Specified by:
addToolClasspathin interfaceJamServiceParams- Parameters:
classpathElement- elements of the classpath
-
setProperty
public void setProperty(java.lang.String name, java.lang.String value)Description copied from interface:JamServiceParamsSets an implementation-specific property.
- Specified by:
setPropertyin interfaceJamServiceParams
-
set14WarningsEnabled
public void set14WarningsEnabled(boolean b)
Description copied from interface:JamServiceParamsSets whether warnings should be displayed when running under JDK 1.4. The default is true.
- Specified by:
set14WarningsEnabledin interfaceJamServiceParams
-
setParentClassLoader
public void setParentClassLoader(JamClassLoader loader)
Description copied from interface:JamServiceParamsSets the parent JamClassLoader of the service JamClassLoader.- Specified by:
setParentClassLoaderin interfaceJamServiceParams- Parameters:
loader- the parent loaer
-
setUseSystemClasspath
public void setUseSystemClasspath(boolean use)
Description copied from interface:JamServiceParamsSpecifies whether the JAM Service should load classes from the system classpath. The default for this is true, and you shouldn't set it to false unless you really know what you are doing.
- Specified by:
setUseSystemClasspathin interfaceJamServiceParams
-
addClassLoader
public void addClassLoader(java.lang.ClassLoader cl)
Description copied from interface:JamServiceParamsDOCME- Specified by:
addClassLoaderin interfaceJamServiceParams
-
getReflectionClassLoaders
public java.lang.ClassLoader[] getReflectionClassLoaders()
- Specified by:
getReflectionClassLoadersin interfaceJamServiceContext
-
is14WarningsEnabled
public boolean is14WarningsEnabled()
- Specified by:
is14WarningsEnabledin interfaceJamServiceContext
-
getClassLoader
public JamClassLoader getClassLoader()
Description copied from interface:ElementContextReturns the classloader the elements should use for type resolution.
- Specified by:
getClassLoaderin interfaceElementContext
-
createAnnotationProxy
public AnnotationProxy createAnnotationProxy(java.lang.String jsr175typename)
Description copied from interface:ElementContextCreates an empty appropriate proxy for the given 175 annotation instance.
- Specified by:
createAnnotationProxyin interfaceElementContext
-
-