Java Doc for GroovyClassLoader.java in  » Scripting » groovy-1.0 » groovy » lang » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Scripting » groovy 1.0 » groovy.lang 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.net.URLClassLoader
   groovy.lang.GroovyClassLoader

All known Subclasses:   org.codehaus.groovy.classgen.DumpingClassLoader,
GroovyClassLoader
public class GroovyClassLoader extends URLClassLoader (Code)
A ClassLoader which can load Groovy classes. The loaded classes are cached, classes from other classlaoders should not be cached. To be able to load a script that was asked for earlier but was created later it is essential not to keep anything like a "class not found" information for that class name. This includes possible parent loaders. Classes that are not chached are always reloaded.
author:
   James Strachan
author:
   Guillaume Laforge
author:
   Steve Goetze
author:
   Bing Ran
author:
   Scott Stirling
author:
   Jochen Theodorou
version:
   $Revision: 4445 $

Inner Class :public static class InnerLoader extends GroovyClassLoader
Inner Class :public static class ClassCollector extends CompilationUnit.ClassgenCallback

Field Summary
protected  MapclassCache
    
protected  MapsourceCache
    

Constructor Summary
public  GroovyClassLoader()
     creates a GroovyClassLoader using the current Thread's context Class loader as parent.
public  GroovyClassLoader(ClassLoader loader)
    
public  GroovyClassLoader(GroovyClassLoader parent)
     creates a GroovyClassLoader using the given GroovyClassLoader as parent.
public  GroovyClassLoader(ClassLoader parent, CompilerConfiguration config, boolean useConfigurationClasspath)
     creates a GroovyClassLaoder.
public  GroovyClassLoader(ClassLoader loader, CompilerConfiguration config)
     creates a GroovyClassLoader using the given ClassLoader as parent.

Method Summary
public  voidaddClasspath(String path)
     adds a classpath to this classloader.
public  voidaddURL(URL url)
     adds a URL to the classloader.
public  voidclearCache()
     removes all classes from the class cache.
protected  ClassCollectorcreateCollector(CompilationUnit unit, SourceUnit su)
     creates a ClassCollector for a new compilation.
protected  CompilationUnitcreateCompilationUnit(CompilerConfiguration config, CodeSource source)
     creates a new CompilationUnit.
public  ClassdefineClass(ClassNode classNode, String file)
    
public  ClassdefineClass(ClassNode classNode, String file, String newCodeBase)
     Loads the given class node returning the implementation Class.
protected  ClassdefineClass(String name, byte[] bytecode, ProtectionDomain domain)
     A helper method to allow bytecode to be loaded.
public  ClassdefineClass(String name, byte[] b)
    
protected  voidexpandClassPath(List pathList, String base, String classpath, boolean isManifestClasspath)
    
public synchronized  StringgenerateScriptName()
    
protected  ClassgetClassCacheEntry(String name)
     gets a class from the class cache.
protected  String[]getClassPath()
     gets the currently used classpath.
public  Class[]getLoadedClasses()
    

Returns all Groovy classes loaded by this class loader.

public  GroovyResourceLoadergetResourceLoader()
    
protected  longgetTimeStamp(Class cls)
     gets the time stamp of a given class.
protected  booleanisRecompilable(Class cls)
     Indicates if a class is recompilable.
public  BooleanisShouldRecompile()
     gets the currently set recompilation mode.
protected  booleanisSourceNewer(URL source, Class cls)
     Decides if the given source is newer than a class.
public  ClassloadClass(String name, boolean lookupScriptFiles, boolean preferClassOverScript)
     loads a class from a file or a parent classloader.
public  ClassloadClass(String name, boolean lookupScriptFiles, boolean preferClassOverScript, boolean resolve)
     loads a class from a file or a parent classloader.
protected  ClassloadClass(String name, boolean resolve)
     Implemented here to check package access prior to returning an already loaded class.
public  ClassparseClass(File file)
    
public  ClassparseClass(String text, String fileName)
    
public  ClassparseClass(String text)
    
public  ClassparseClass(InputStream in)
    
public  ClassparseClass(InputStream in, String fileName)
    
public  ClassparseClass(GroovyCodeSource codeSource)
    
public  ClassparseClass(GroovyCodeSource codeSource, boolean shouldCacheSource)
     Parses the given code source into a Java class.
protected  Classrecompile(URL source, String className, Class oldClass)
     (Re)Comipiles the given source.
protected  voidremoveClassCacheEntry(String name)
     removes a class from the class cache.
protected  voidsetClassCacheEntry(Class cls)
     sets an entry in the class cache.
public  voidsetResourceLoader(GroovyResourceLoader resourceLoader)
    
public  voidsetShouldRecompile(Boolean mode)
     sets if the recompilation should be enable.

Field Detail
classCache
protected Map classCache(Code)
this cache contains the loaded classes or PARSING, if the class is currently parsed



sourceCache
protected Map sourceCache(Code)




Constructor Detail
GroovyClassLoader
public GroovyClassLoader()(Code)
creates a GroovyClassLoader using the current Thread's context Class loader as parent.



GroovyClassLoader
public GroovyClassLoader(ClassLoader loader)(Code)
creates a GroovyClassLoader using the given ClassLoader as parent



GroovyClassLoader
public GroovyClassLoader(GroovyClassLoader parent)(Code)
creates a GroovyClassLoader using the given GroovyClassLoader as parent. This loader will get the parent's CompilerConfiguration



GroovyClassLoader
public GroovyClassLoader(ClassLoader parent, CompilerConfiguration config, boolean useConfigurationClasspath)(Code)
creates a GroovyClassLaoder.
Parameters:
  parent - the parten class loader
Parameters:
  config - the compiler configuration
Parameters:
  useConfigurationClasspath - determines if the configurations classpath should be added



GroovyClassLoader
public GroovyClassLoader(ClassLoader loader, CompilerConfiguration config)(Code)
creates a GroovyClassLoader using the given ClassLoader as parent.




Method Detail
addClasspath
public void addClasspath(String path)(Code)
adds a classpath to this classloader.
Parameters:
  path - is a jar file or a directory.
See Also:   GroovyClassLoader.addURL(URL)



addURL
public void addURL(URL url)(Code)
adds a URL to the classloader.
Parameters:
  url - the new classpath element



clearCache
public void clearCache()(Code)
removes all classes from the class cache.
See Also:   GroovyClassLoader.getClassCacheEntry(String)
See Also:   GroovyClassLoader.setClassCacheEntry(Class)
See Also:   GroovyClassLoader.removeClassCacheEntry(String)



createCollector
protected ClassCollector createCollector(CompilationUnit unit, SourceUnit su)(Code)
creates a ClassCollector for a new compilation.
Parameters:
  unit - the compilationUnit
Parameters:
  su - the SoruceUnit the ClassCollector



createCompilationUnit
protected CompilationUnit createCompilationUnit(CompilerConfiguration config, CodeSource source)(Code)
creates a new CompilationUnit. If you want to add additional phase operations to the CompilationUnit (for example to inject additional methods, variables, fields), then you should overwrite this method.
Parameters:
  config - the compiler configuration, usually the same as for this class loader
Parameters:
  source - the source containing the initial file to compile, more files may follow during compilation the CompilationUnit



defineClass
public Class defineClass(ClassNode classNode, String file)(Code)
Loads the given class node returning the implementation Class
Parameters:
  classNode - a class



defineClass
public Class defineClass(ClassNode classNode, String file, String newCodeBase)(Code)
Loads the given class node returning the implementation Class. WARNING: this compilation is not synchronized
Parameters:
  classNode - a class



defineClass
protected Class defineClass(String name, byte[] bytecode, ProtectionDomain domain)(Code)
A helper method to allow bytecode to be loaded. spg changed name to defineClass to make it more consistent with other ClassLoader methods



defineClass
public Class defineClass(String name, byte[] b)(Code)
open up the super class define that takes raw bytes



expandClassPath
protected void expandClassPath(List pathList, String base, String classpath, boolean isManifestClasspath)(Code)
expands the classpath
Parameters:
  pathList - an empty list that will contain the elements of the classpath
Parameters:
  classpath - the classpath specified as a single string



generateScriptName
public synchronized String generateScriptName()(Code)



getClassCacheEntry
protected Class getClassCacheEntry(String name)(Code)
gets a class from the class cache. This cache contains only classes loaded through this class loader or an InnerLoader instance. If no class is stored for a specific name, then the method should return null.
Parameters:
  name - of the class the class stored for the given name
See Also:   GroovyClassLoader.removeClassCacheEntry(String)
See Also:   GroovyClassLoader.setClassCacheEntry(Class)
See Also:   GroovyClassLoader.clearCache()



getClassPath
protected String[] getClassPath()(Code)
gets the currently used classpath. a String[] containing the file information of the urls
See Also:   GroovyClassLoader.getURLs()



getLoadedClasses
public Class[] getLoadedClasses()(Code)

Returns all Groovy classes loaded by this class loader. all classes loaded by this class loader




getResourceLoader
public GroovyResourceLoader getResourceLoader()(Code)



getTimeStamp
protected long getTimeStamp(Class cls)(Code)
gets the time stamp of a given class. For groovy generated classes this usually means to return the value of the static field __timeStamp. If the parameter doesn't have such a field, then Long.MAX_VALUE is returned
Parameters:
  cls - the class the time stamp



isRecompilable
protected boolean isRecompilable(Class cls)(Code)
Indicates if a class is recompilable. Recompileable means, that the classloader will try to locate a groovy source file for this class and then compile it again, adding the resulting class as entry to the cache. Giving null as class is like a recompilation, so the method should always return true here. Only classes that are implementing GroovyObject are compileable and only if the timestamp in the class is lower than Long.MAX_VALUE. NOTE: First the parent loaders will be asked and only if they don't return a class the recompilation will happen. Recompilation also only happen if the source file is newer.
See Also:   GroovyClassLoader.isSourceNewer(URL,Class)
Parameters:
  cls - the class to be tested. If null the method should return true true if the class should be compiled again



isShouldRecompile
public Boolean isShouldRecompile()(Code)
gets the currently set recompilation mode. null means, the compiler configuration is used. False means no recompilation and true means that recompilation will be done if needed. the recompilation mode



isSourceNewer
protected boolean isSourceNewer(URL source, Class cls) throws IOException(Code)
Decides if the given source is newer than a class.
See Also:   GroovyClassLoader.getTimeStamp(Class)
Parameters:
  source - the source we may want to compile
Parameters:
  cls - the former class true if the source is newer, false else
throws:
  IOException - if it is not possible to open anconnection for the given source



loadClass
public Class loadClass(String name, boolean lookupScriptFiles, boolean preferClassOverScript) throws ClassNotFoundException, CompilationFailedException(Code)
loads a class from a file or a parent classloader. This method does call loadClass(String, boolean, boolean, boolean) with the last parameter set to false.
throws:
  CompilationFailedException -



loadClass
public Class loadClass(String name, boolean lookupScriptFiles, boolean preferClassOverScript, boolean resolve) throws ClassNotFoundException, CompilationFailedException(Code)
loads a class from a file or a parent classloader.
Parameters:
  name - of the class to be loaded
Parameters:
  lookupScriptFiles - if false no lookup at files is done at all
Parameters:
  preferClassOverScript - if true the file lookup is only done if there is no class
Parameters:
  resolve - @see ClassLoader#loadClass(java.lang.String, boolean) the class found or the class created from a file lookup
throws:
  ClassNotFoundException -



loadClass
protected Class loadClass(String name, boolean resolve) throws ClassNotFoundException(Code)
Implemented here to check package access prior to returning an already loaded class.
throws:
  CompilationFailedException - if the compilation failed
throws:
  ClassNotFoundException - if the class was not found
See Also:   java.lang.ClassLoader.loadClass(java.lang.Stringboolean)



parseClass
public Class parseClass(File file) throws CompilationFailedException, IOException(Code)
Parses the given file into a Java class capable of being run
Parameters:
  file - the file name to parse the main class defined in the given script



parseClass
public Class parseClass(String text, String fileName) throws CompilationFailedException(Code)
Parses the given text into a Java class capable of being run
Parameters:
  text - the text of the script/class to parse
Parameters:
  fileName - the file name to use as the name of the class the main class defined in the given script



parseClass
public Class parseClass(String text) throws CompilationFailedException(Code)
Parses the given text into a Java class capable of being run
Parameters:
  text - the text of the script/class to parse the main class defined in the given script



parseClass
public Class parseClass(InputStream in) throws CompilationFailedException(Code)
Parses the given character stream into a Java class capable of being run
Parameters:
  in - an InputStream the main class defined in the given script



parseClass
public Class parseClass(InputStream in, String fileName) throws CompilationFailedException(Code)



parseClass
public Class parseClass(GroovyCodeSource codeSource) throws CompilationFailedException(Code)



parseClass
public Class parseClass(GroovyCodeSource codeSource, boolean shouldCacheSource) throws CompilationFailedException(Code)
Parses the given code source into a Java class. If there is a class file for the given code source, then no parsing is done, instead the cached class is returned.
Parameters:
  shouldCacheSource - if true then the generated class will be stored in the source cache the main class defined in the given script



recompile
protected Class recompile(URL source, String className, Class oldClass) throws CompilationFailedException, IOException(Code)
(Re)Comipiles the given source. This method starts the compilation of a given source, if the source has changed since the class was created. For this isSourceNewer is called.
See Also:   GroovyClassLoader.isSourceNewer(URL,Class)
Parameters:
  source - the source pointer for the compilation
Parameters:
  className - the name of the class to be generated
Parameters:
  oldClass - a possible former class the old class if the source wasn't new enough, the new class else
throws:
  CompilationFailedException - if the compilation failed
throws:
  IOException - if the source is not readable



removeClassCacheEntry
protected void removeClassCacheEntry(String name)(Code)
removes a class from the class cache.
Parameters:
  name - of the class
See Also:   GroovyClassLoader.getClassCacheEntry(String)
See Also:   GroovyClassLoader.setClassCacheEntry(Class)
See Also:   GroovyClassLoader.clearCache()



setClassCacheEntry
protected void setClassCacheEntry(Class cls)(Code)
sets an entry in the class cache.
Parameters:
  cls - the class
See Also:   GroovyClassLoader.removeClassCacheEntry(String)
See Also:   GroovyClassLoader.getClassCacheEntry(String)
See Also:   GroovyClassLoader.clearCache()



setResourceLoader
public void setResourceLoader(GroovyResourceLoader resourceLoader)(Code)



setShouldRecompile
public void setShouldRecompile(Boolean mode)(Code)
sets if the recompilation should be enable. There are 3 possible values for this. Any value different than null overrides the value from the compiler configuration. true means to recompile if needed false means to never recompile.
Parameters:
  mode - the recompilation mode
See Also:   CompilerConfiguration



Methods inherited from java.net.URLClassLoader
protected void addURL(URL url)(Code)(Java Doc)
protected Package definePackage(String name, Manifest man, URL url) throws IllegalArgumentException(Code)(Java Doc)
protected Class findClass(String name) throws ClassNotFoundException(Code)(Java Doc)
public URL findResource(String name)(Code)(Java Doc)
public Enumeration<URL> findResources(String name) throws IOException(Code)(Java Doc)
protected PermissionCollection getPermissions(CodeSource codesource)(Code)(Java Doc)
public URL[] getURLs()(Code)(Java Doc)
public static URLClassLoader newInstance(URL[] urls, ClassLoader parent)(Code)(Java Doc)
public static URLClassLoader newInstance(URL[] urls)(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.