Package gw.internal.gosu.parser
Class DefaultTypeLoader
- java.lang.Object
-
- gw.config.BaseService
-
- gw.lang.reflect.TypeLoaderBase
-
- gw.lang.reflect.SimpleTypeLoader
-
- gw.internal.gosu.parser.DefaultTypeLoader
-
- All Implemented Interfaces:
IService,IDefaultTypeLoader,IExtendedTypeLoader,ITypeLoader,IPluginHost
public class DefaultTypeLoader extends SimpleTypeLoader implements IExtendedTypeLoader, IDefaultTypeLoader
-
-
Field Summary
Fields Modifier and Type Field Description private ClassCache_classCacheprivate java.util.Map<java.lang.String,IJavaClassInfo>_classInfoCacheprivate IGosuClassLoader_gosuClassLoaderprotected java.util.Set<java.lang.String>_namespaces-
Fields inherited from class gw.lang.reflect.TypeLoaderBase
_module, _typeNames
-
Fields inherited from interface gw.lang.reflect.IDefaultTypeLoader
DOT_JAVA_EXTENSION, EXTENSIONS, EXTENSIONS_ARRAY, JAVA_EXTENSION
-
Fields inherited from interface gw.lang.reflect.ITypeLoader
NO_TYPES
-
-
Constructor Summary
Constructors Constructor Description DefaultTypeLoader(IModule module)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanclassFileExists(java.lang.String className)voidclearMisses()java.util.Set<java.lang.String>computeTypeNames()(package private) voiddumpGosuClassLoader()java.util.Set<java.lang.String>getAllNamespaces()Don't call this method unless you really know what you're doing.private IJavaClassInfogetByClass(java.lang.String className, IModule lookupModule, IModule actualModule)java.util.Set<java.lang.String>getExtensions()IGosuClassLoadergetGosuClassLoader()java.util.List<java.lang.String>getHandledPrefixes()IJavaTypegetInnerType(java.lang.String fqn)<T> TgetInterface(java.lang.Class<T> apiInterface)Provides an implementation of a specified interface.ITypegetIntrinsicTypeFromObject(java.lang.Object object)Returns the intrinsic type for the given Object.IJavaClassInfogetJavaClassInfo(AsmClass aClass, IModule gosuModule)IJavaClassInfogetJavaClassInfo(java.lang.Class aClass, IModule gosuModule)IJavaClassInfogetJavaClassInfo(java.lang.String fullyQualifiedName)IJavaClassInfogetJavaClassInfoForClassDirectly(java.lang.Class clazz, IModule module)java.net.URLgetResource(java.lang.String name)Finds the resource with the given name.ISourceFileHandlegetSourceFileHandle(java.lang.String qualifiedName)ITypegetType(java.lang.String fullyQualifiedName)Gets a type based on a fully-qualified name.java.util.Set<TypeName>getTypeNames(java.lang.String namespace)booleanhandlesNonPrefixLoads()booleanhasNamespace(java.lang.String namespace)private booleanhaveWeRecreatedTheModuleLoader()static DefaultTypeLoaderinstance()static DefaultTypeLoaderinstance(IModule module)booleanisCaseSensitive()AsmClassloadAsmClass(java.lang.String className)java.lang.ClassloadClass(java.lang.String className)voidrefreshedImpl()voidrefreshedNamespace(java.lang.String namespace, IDirectory dir, RefreshKind kind)voidrefreshedTypesImpl(RefreshRequest request)IJavaClassInforesolveJavaClassInfo(java.lang.String fqn)-
Methods inherited from class gw.lang.reflect.SimpleTypeLoader
getNamespaceForDirectory, getTypesForFile, handlesDirectory, handlesFile, refreshedFile
-
Methods inherited from class gw.lang.reflect.TypeLoaderBase
clearTypeNames, deleteIndexFile, getAllTypeNames, getModule, getTypeNames, loadTypeNames, refreshed, refreshedTypes, saveTypeNames, shouldCacheTypeNames, showTypeNamesInIDE, shutdown, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface gw.lang.reflect.IDefaultTypeLoader
getSouceFileHandle
-
Methods inherited from interface gw.lang.reflect.ITypeLoader
getAllTypeNames, getModule, getNamespaceForDirectory, getTypesForFile, handlesDirectory, handlesFile, refreshed, refreshedFile, refreshedTypes, showTypeNamesInIDE, shutdown
-
-
-
-
Field Detail
-
_classCache
private ClassCache _classCache
-
_gosuClassLoader
private IGosuClassLoader _gosuClassLoader
-
_classInfoCache
private java.util.Map<java.lang.String,IJavaClassInfo> _classInfoCache
-
_namespaces
protected java.util.Set<java.lang.String> _namespaces
-
-
Constructor Detail
-
DefaultTypeLoader
public DefaultTypeLoader(IModule module)
-
-
Method Detail
-
instance
public static DefaultTypeLoader instance(IModule module)
-
instance
public static DefaultTypeLoader instance()
-
getType
public IType getType(java.lang.String fullyQualifiedName)
Description copied from interface:ITypeLoaderGets a type based on a fully-qualified name. This could either be the name of an entity, like "entity.User", the name of a typekey, like "typekey.SystemPermission", or a class name, like "java.lang.String". Names can have [] appended to them to create arrays, and multi-dimensional arrays are supported.
If the type can be successfully resolved by the typeloader, it will be returned, otherwise it will return null. The sole exception to this rule is the top-level TypeLoaderAccess, which will throw aClassNotFoundExceptionif none of its composite typeloaders can load the type.
There is a global lock in TypeLoaderAccess that is acquired when this method is called. Basically one type at a time can be loaded from the system. This method is free to release that lock during this call. This is needed to deal with reentrant type loaders. It is the responsibility of this method to make sure the lock is reacquired before this method returns. Type loader access will guarentee that no duplicate types are put into the type loader.- Specified by:
getTypein interfaceITypeLoader- Parameters:
fullyQualifiedName- the fully qualified name of the type- Returns:
- the corresponding IType or null
-
getInnerType
public IJavaType getInnerType(java.lang.String fqn)
-
getJavaClassInfo
public IJavaClassInfo getJavaClassInfo(java.lang.String fullyQualifiedName)
- Specified by:
getJavaClassInfoin interfaceIDefaultTypeLoader
-
getJavaClassInfoForClassDirectly
public IJavaClassInfo getJavaClassInfoForClassDirectly(java.lang.Class clazz, IModule module)
- Specified by:
getJavaClassInfoForClassDirectlyin interfaceIDefaultTypeLoader
-
getJavaClassInfo
public IJavaClassInfo getJavaClassInfo(java.lang.Class aClass, IModule gosuModule)
-
getJavaClassInfo
public IJavaClassInfo getJavaClassInfo(AsmClass aClass, IModule gosuModule)
-
resolveJavaClassInfo
public IJavaClassInfo resolveJavaClassInfo(java.lang.String fqn)
-
getSourceFileHandle
public ISourceFileHandle getSourceFileHandle(java.lang.String qualifiedName)
- Specified by:
getSourceFileHandlein interfaceIDefaultTypeLoader
-
getByClass
private IJavaClassInfo getByClass(java.lang.String className, IModule lookupModule, IModule actualModule)
-
getIntrinsicTypeFromObject
public IType getIntrinsicTypeFromObject(java.lang.Object object)
Description copied from interface:IExtendedTypeLoaderReturns the intrinsic type for the given Object.- Specified by:
getIntrinsicTypeFromObjectin interfaceIExtendedTypeLoader- Parameters:
object- the object to get an IType for- Returns:
- the IType for the object
-
computeTypeNames
public java.util.Set<java.lang.String> computeTypeNames()
- Specified by:
computeTypeNamesin interfaceITypeLoader
-
getResource
public java.net.URL getResource(java.lang.String name)
Description copied from interface:ITypeLoaderFinds the resource with the given name. A resource is some data that can be accessed by class code in a way that may be independent of the location of the code. The exact location of the resource is dependent upon the loader implementationThe name of a resource is a '/'-separated path name that identifies the resource.
- Specified by:
getResourcein interfaceITypeLoader- Overrides:
getResourcein classTypeLoaderBase- Parameters:
name- The resource name- Returns:
- A URL object for reading the resource, or null if the resource could not be found or the invoker doesn't have adequate privileges to get the resource.
-
refreshedTypesImpl
public void refreshedTypesImpl(RefreshRequest request)
- Overrides:
refreshedTypesImplin classTypeLoaderBase
-
isCaseSensitive
public boolean isCaseSensitive()
- Specified by:
isCaseSensitivein interfaceITypeLoader- Overrides:
isCaseSensitivein classTypeLoaderBase
-
getHandledPrefixes
public java.util.List<java.lang.String> getHandledPrefixes()
- Specified by:
getHandledPrefixesin interfaceITypeLoader
-
handlesNonPrefixLoads
public boolean handlesNonPrefixLoads()
- Specified by:
handlesNonPrefixLoadsin interfaceITypeLoader
-
refreshedImpl
public void refreshedImpl()
- Overrides:
refreshedImplin classTypeLoaderBase
-
clearMisses
public void clearMisses()
-
loadClass
public java.lang.Class loadClass(java.lang.String className)
- Specified by:
loadClassin interfaceIDefaultTypeLoader
-
loadAsmClass
public AsmClass loadAsmClass(java.lang.String className)
-
classFileExists
public boolean classFileExists(java.lang.String className)
-
getGosuClassLoader
public IGosuClassLoader getGosuClassLoader()
- Specified by:
getGosuClassLoaderin interfaceIDefaultTypeLoader
-
dumpGosuClassLoader
void dumpGosuClassLoader()
-
haveWeRecreatedTheModuleLoader
private boolean haveWeRecreatedTheModuleLoader()
-
getExtensions
public java.util.Set<java.lang.String> getExtensions()
- Specified by:
getExtensionsin classSimpleTypeLoader
-
hasNamespace
public boolean hasNamespace(java.lang.String namespace)
- Specified by:
hasNamespacein interfaceITypeLoader
-
getAllNamespaces
public java.util.Set<java.lang.String> getAllNamespaces()
Description copied from interface:ITypeLoaderDon't call this method unless you really know what you're doing.- Specified by:
getAllNamespacesin interfaceITypeLoader- Returns:
- the set of package (aka namespace) names in which this loader's types reside.
-
refreshedNamespace
public void refreshedNamespace(java.lang.String namespace, IDirectory dir, RefreshKind kind)- Specified by:
refreshedNamespacein interfaceITypeLoader
-
getTypeNames
public java.util.Set<TypeName> getTypeNames(java.lang.String namespace)
- Specified by:
getTypeNamesin interfaceITypeLoader- Overrides:
getTypeNamesin classTypeLoaderBase
-
getInterface
public <T> T getInterface(java.lang.Class<T> apiInterface)
Description copied from interface:IPluginHostProvides an implementation of a specified interface.- Specified by:
getInterfacein interfaceIPluginHost- Returns:
- The implementation of the interface or null if unsupported.
-
-