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 void
addClassBuilder(JamClassBuilder builder)
Adds a custom JamClassBuilder which will be consulted by the JamClassLoader when constructing representation of java types.void
addClassLoader(java.lang.ClassLoader cl)
DOCMEvoid
addClasspath(java.io.File classpathElement)
Adds an elements to the JamService classpath.void
addInitializer(MVisitor initializer)
void
addSourcepath(java.io.File sourcepathElement)
Adds an elements to the JamService sourcepath.void
addToolClasspath(java.io.File classpathElement)
Adds an elements to the tool classpath.AnnotationProxy
createAnnotationProxy(java.lang.String jsr175typename)
Creates an empty appropriate proxy for the given 175 annotation instance.void
excludeClass(java.lang.String qualifiedClassname)
Names a specific class to be excluded in the JamService.void
excludeClassFile(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.void
excludeClassPattern(java.io.File[] classpath, java.lang.String pattern)
Specifies a set of java class files to be excluded from the JamService.void
excludeSourceFile(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.void
excludeSourcePattern(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.JamClassBuilder
getBaseBuilder()
JamClassLoader
getClassLoader()
Returns the classloader the elements should use for type resolution.MVisitor
getInitializer()
ResourcePath
getInputClasspath()
ResourcePath
getInputSourcepath()
JamLogger
getLogger()
java.lang.String
getProperty(java.lang.String name)
java.lang.ClassLoader[]
getReflectionClassLoaders()
java.io.File[]
getSourceFiles()
JavadocTagParser
getTagParser()
Returns the JavadocTagParser to be used in processing javadoc tags.ResourcePath
getToolClasspath()
java.io.File[]
getUnstructuredSourceFiles()
void
includeClass(java.lang.String qualifiedClassname)
Names a specific class to be included in the JamService.void
includeClassFile(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.void
includeClassPattern(java.io.File[] classpath, java.lang.String pattern)
Specifies a set of java class files to be excluded in the JamService.void
includeSourceFile(java.io.File file)
Include a single java source file to be viewed.void
includeSourceFile(java.io.File[] sourcepath, java.io.File sourceFile)
Includes a single source File in the JamService.void
includeSourcePattern(java.io.File[] sourcepath, java.lang.String pattern)
Specifies a set of java source files to be included in the JamService.boolean
is14WarningsEnabled()
void
set14WarningsEnabled(boolean b)
Sets whether warnings should be displayed when running under JDK 1.4.void
setClassLoader(JamClassLoader loader)
void
setCommentInitializer(MVisitor initializer)
void
setJamLogger(JamLogger logger)
Sets the JamLogger which will receive error and warning messages from JAM.void
setJavadocTagParser(JavadocTagParser tp)
void
setLoggerWriter(java.io.PrintWriter out)
Sets a PrintWriter to which the JamService implementation should log errors and debugging information.void
setParentClassLoader(JamClassLoader loader)
Sets the parent JamClassLoader of the service JamClassLoader.void
setProperty(java.lang.String name, java.lang.String value)
Sets an implementation-specific property.void
setPropertyInitializer(MVisitor initializer)
void
setUseSystemClasspath(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:
getBaseBuilder
in interfaceJamServiceContext
-
getTagParser
public JavadocTagParser getTagParser()
Description copied from interface:JamServiceContext
Returns 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:
getTagParser
in interfaceJamServiceContext
-
getAllClassnames
public java.lang.String[] getAllClassnames() throws java.io.IOException
Returns an array containing the qualified names of the classes which are in the Service class set.- Specified by:
getAllClassnames
in interfaceJamServiceContext
- Throws:
java.io.IOException
-
getLogger
public JamLogger getLogger()
- Specified by:
getLogger
in interfaceElementContext
- Specified by:
getLogger
in interfaceJamServiceContext
-
getSourceFiles
public java.io.File[] getSourceFiles() throws java.io.IOException
- Specified by:
getSourceFiles
in interfaceJamServiceContext
- Throws:
java.io.IOException
-
getUnstructuredSourceFiles
public java.io.File[] getUnstructuredSourceFiles()
-
getInputClasspath
public ResourcePath getInputClasspath()
- Specified by:
getInputClasspath
in 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:
getInputSourcepath
in 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:
getToolClasspath
in 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:
getProperty
in interfaceJamServiceContext
- Returns:
- an implementation-specific property, as specified by
JamServiceParams.setProperty()
.
-
getInitializer
public MVisitor getInitializer()
- Specified by:
getInitializer
in interfaceJamServiceContext
-
addClassBuilder
public void addClassBuilder(JamClassBuilder builder)
Description copied from interface:JamServiceParams
Adds 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:
addClassBuilder
in interfaceJamServiceParams
-
setCommentInitializer
public void setCommentInitializer(MVisitor initializer)
-
setPropertyInitializer
public void setPropertyInitializer(MVisitor initializer)
- Specified by:
setPropertyInitializer
in interfaceJamServiceParams
-
addInitializer
public void addInitializer(MVisitor initializer)
- Specified by:
addInitializer
in interfaceJamServiceParams
-
setJavadocTagParser
public void setJavadocTagParser(JavadocTagParser tp)
- Specified by:
setJavadocTagParser
in interfaceJamServiceParams
-
includeSourceFile
public void includeSourceFile(java.io.File file)
Description copied from interface:JamServiceParams
Include 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:
includeSourceFile
in interfaceJamServiceParams
-
includeSourcePattern
public void includeSourcePattern(java.io.File[] sourcepath, java.lang.String pattern)
Description copied from interface:JamServiceParams
Specifies 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:
includeSourcePattern
in 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:JamServiceParams
Specifies 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:
includeClassPattern
in 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:JamServiceParams
Specifies 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:
excludeSourcePattern
in 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:JamServiceParams
Specifies 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:
excludeClassPattern
in 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:JamServiceParams
Includes 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:
includeSourceFile
in 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:JamServiceParams
Excludes a single source File in the JamService in exactly the same way theat includeSourceFile() includes a source file.
- Specified by:
excludeSourceFile
in interfaceJamServiceParams
-
includeClassFile
public void includeClassFile(java.io.File[] classpath, java.io.File classFile)
Description copied from interface:JamServiceParams
Includes a single class File in the JamService in exactly the same way theat includeSourceFile() includes a source file.
- Specified by:
includeClassFile
in interfaceJamServiceParams
-
excludeClassFile
public void excludeClassFile(java.io.File[] classpath, java.io.File classFile)
Description copied from interface:JamServiceParams
Excludes a single class File in the JamService in exactly the same way theat includeSourceFile() includes a source file.
- Specified by:
excludeClassFile
in interfaceJamServiceParams
-
includeClass
public void includeClass(java.lang.String qualifiedClassname)
Description copied from interface:JamServiceParams
Names 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:
includeClass
in interfaceJamServiceParams
- Parameters:
qualifiedClassname
- a full-qualified classname
-
excludeClass
public void excludeClass(java.lang.String qualifiedClassname)
Description copied from interface:JamServiceParams
Names 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:
excludeClass
in interfaceJamServiceParams
- Parameters:
qualifiedClassname
- a full-qualified classname
-
addClasspath
public void addClasspath(java.io.File classpathElement)
Description copied from interface:JamServiceParams
Adds 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:
addClasspath
in interfaceJamServiceParams
- Parameters:
classpathElement
- elements of the classpath
-
setLoggerWriter
public void setLoggerWriter(java.io.PrintWriter out)
Description copied from interface:JamServiceParams
Sets 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:
setLoggerWriter
in interfaceJamServiceParams
- Parameters:
out
- a PrintWriter to write to
-
setJamLogger
public void setJamLogger(JamLogger logger)
Description copied from interface:JamServiceParams
Sets the JamLogger which will receive error and warning messages from JAM.- Specified by:
setJamLogger
in interfaceJamServiceParams
-
addSourcepath
public void addSourcepath(java.io.File sourcepathElement)
Description copied from interface:JamServiceParams
Adds 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:
addSourcepath
in interfaceJamServiceParams
-
addToolClasspath
public void addToolClasspath(java.io.File classpathElement)
Description copied from interface:JamServiceParams
Adds 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:
addToolClasspath
in interfaceJamServiceParams
- Parameters:
classpathElement
- elements of the classpath
-
setProperty
public void setProperty(java.lang.String name, java.lang.String value)
Description copied from interface:JamServiceParams
Sets an implementation-specific property.
- Specified by:
setProperty
in interfaceJamServiceParams
-
set14WarningsEnabled
public void set14WarningsEnabled(boolean b)
Description copied from interface:JamServiceParams
Sets whether warnings should be displayed when running under JDK 1.4. The default is true.
- Specified by:
set14WarningsEnabled
in interfaceJamServiceParams
-
setParentClassLoader
public void setParentClassLoader(JamClassLoader loader)
Description copied from interface:JamServiceParams
Sets the parent JamClassLoader of the service JamClassLoader.- Specified by:
setParentClassLoader
in interfaceJamServiceParams
- Parameters:
loader
- the parent loaer
-
setUseSystemClasspath
public void setUseSystemClasspath(boolean use)
Description copied from interface:JamServiceParams
Specifies 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:
setUseSystemClasspath
in interfaceJamServiceParams
-
addClassLoader
public void addClassLoader(java.lang.ClassLoader cl)
Description copied from interface:JamServiceParams
DOCME- Specified by:
addClassLoader
in interfaceJamServiceParams
-
getReflectionClassLoaders
public java.lang.ClassLoader[] getReflectionClassLoaders()
- Specified by:
getReflectionClassLoaders
in interfaceJamServiceContext
-
is14WarningsEnabled
public boolean is14WarningsEnabled()
- Specified by:
is14WarningsEnabled
in interfaceJamServiceContext
-
getClassLoader
public JamClassLoader getClassLoader()
Description copied from interface:ElementContext
Returns the classloader the elements should use for type resolution.
- Specified by:
getClassLoader
in interfaceElementContext
-
createAnnotationProxy
public AnnotationProxy createAnnotationProxy(java.lang.String jsr175typename)
Description copied from interface:ElementContext
Creates an empty appropriate proxy for the given 175 annotation instance.
- Specified by:
createAnnotationProxy
in interfaceElementContext
-
-