@Service public class TypeLocationServiceImpl extends Object implements TypeLocationService
TypeLocationService.
For performance reasons automatically caches the queries. The cache is invalidated on changes to the file system.
| Constructor and Description |
|---|
TypeLocationServiceImpl() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
activate(org.osgi.service.component.ComponentContext cContext) |
void |
addDependencies(ModuleFeatureName moduleFeatureName,
Collection<? extends org.springframework.roo.project.Dependency> newDependencies)
Attempts to add the specified dependencies into modules that have installed a module feature.
|
void |
addModuleDependency(String moduleName,
org.springframework.roo.model.JavaType moduleJavaTypeToDependUpon)
Adds to the given module the dependency with the module that contains the java type.
|
Set<ClassOrInterfaceTypeDetails> |
findClassesOrInterfaceDetailsWithAnnotation(org.springframework.roo.model.JavaType... annotationsToDetect)
Returns a set of
ClassOrInterfaceTypeDetailss that possess the
specified annotations (specified as a vararg). |
Set<ClassOrInterfaceTypeDetails> |
findClassesOrInterfaceDetailsWithTag(Object tag)
Returns a set of
ClassOrInterfaceTypeDetailss that possess the
specified tag. |
Set<org.springframework.roo.model.JavaType> |
findTypesWithAnnotation(org.springframework.roo.model.JavaType... annotationsToDetect)
Returns a set of
JavaTypes that possess the specified annotations
(specified as a vararg). |
Set<org.springframework.roo.model.JavaType> |
findTypesWithAnnotation(List<org.springframework.roo.model.JavaType> annotationsToDetect)
Returns a set of
JavaTypes that possess the specified list of
annotations. |
org.springframework.roo.process.manager.FileManager |
getFileManager() |
org.springframework.roo.file.monitor.FileMonitorService |
getFileMonitorService() |
org.springframework.roo.metadata.MetadataService |
getMetadataService() |
Collection<String> |
getModuleNames(ModuleFeatureName moduleFeatureName)
Returns the list of module names that have installed a module feature.
|
Collection<org.springframework.roo.project.maven.Pom> |
getModules(ModuleFeatureName moduleFeatureName)
Returns the modules that have installed a module feature.
|
List<org.springframework.roo.model.JavaPackage> |
getPackagesForModule(org.springframework.roo.project.maven.Pom module)
Returns a list with all JavaPackages for a given module.
|
String |
getPhysicalTypeCanonicalPath(org.springframework.roo.model.JavaType javaType,
org.springframework.roo.project.LogicalPath path)
Returns the canonical path that the given
JavaType would have
within the given LogicalPath; this type need not exist. |
String |
getPhysicalTypeCanonicalPath(String physicalTypeId)
Returns the canonical path that a type with the given physical type id
would have; this type need not exist.
|
String |
getPhysicalTypeIdentifier(org.springframework.roo.model.JavaType type)
Looks for the given
JavaType within the user project, and if
found, returns the id for its PhysicalTypeMetadata. |
String |
getPhysicalTypeIdentifier(String fileCanonicalPath)
Returns the physical type identifier for the Java source file with the
given canonical path.
|
List<String> |
getPotentialTopLevelPackagesForModule(org.springframework.roo.project.maven.Pom module) |
org.springframework.roo.project.ProjectOperations |
getProjectOperations() |
String |
getTopLevelPackageForModule(org.springframework.roo.project.maven.Pom module) |
TypeCache |
getTypeCache() |
ClassOrInterfaceTypeDetails |
getTypeDetails(org.springframework.roo.model.JavaType type)
Returns the details of the given Java type from within the user project.
|
ClassOrInterfaceTypeDetails |
getTypeDetails(String physicalTypeId)
Resolves the
ClassOrInterfaceTypeDetails to for the provided
physical type identifier. |
org.springframework.roo.project.LogicalPath |
getTypePath(org.springframework.roo.model.JavaType javaType)
Returns the
LogicalPath containing the given JavaType. |
TypeResolutionService |
getTypeResolutionService() |
Collection<org.springframework.roo.model.JavaType> |
getTypesForModule(org.springframework.roo.project.maven.Pom module)
Returns the Java types that belong to the given module.
|
Set<String> |
getTypesForModule(String modulePath)
Returns the Java types that belong to the given module.
|
boolean |
hasModuleFeature(org.springframework.roo.project.maven.Pom module,
ModuleFeatureName moduleFeatureName)
Indicates whether the specified module in has installed the module feature.
|
boolean |
hasTypeChanged(String requestingClass,
org.springframework.roo.model.JavaType javaType)
Indicates whether the passed in type has changed since last invocation by
the requesting class.
|
boolean |
isInProject(org.springframework.roo.model.JavaType javaType)
Indicates whether the given type exists anywhere in the user project
|
void |
processTypesWithAnnotation(List<org.springframework.roo.model.JavaType> annotationsToDetect,
LocatedTypeCallback callback)
Processes types with the specified list of annotations and uses the
supplied
callback implementation to process
the located types. |
void |
removeDependencies(ModuleFeatureName moduleFeatureName,
Collection<? extends org.springframework.roo.project.Dependency> newDependencies)
Attempts to remove the specified dependencies from modules that have installed a module feature.
|
protected void activate(org.osgi.service.component.ComponentContext cContext)
public Set<ClassOrInterfaceTypeDetails> findClassesOrInterfaceDetailsWithAnnotation(org.springframework.roo.model.JavaType... annotationsToDetect)
TypeLocationServiceClassOrInterfaceTypeDetailss that possess the
specified annotations (specified as a vararg).findClassesOrInterfaceDetailsWithAnnotation in interface TypeLocationServiceannotationsToDetect - the annotations (as a vararg) to detect on a
type.public Set<ClassOrInterfaceTypeDetails> findClassesOrInterfaceDetailsWithTag(Object tag)
TypeLocationServiceClassOrInterfaceTypeDetailss that possess the
specified tag.findClassesOrInterfaceDetailsWithTag in interface TypeLocationServicetag - the tag to detect on a type.public Set<org.springframework.roo.model.JavaType> findTypesWithAnnotation(org.springframework.roo.model.JavaType... annotationsToDetect)
TypeLocationServiceJavaTypes that possess the specified annotations
(specified as a vararg).findTypesWithAnnotation in interface TypeLocationServiceannotationsToDetect - the annotations (as a vararg) to detect on a
type.public Set<org.springframework.roo.model.JavaType> findTypesWithAnnotation(List<org.springframework.roo.model.JavaType> annotationsToDetect)
TypeLocationServiceJavaTypes that possess the specified list of
annotations.findTypesWithAnnotation in interface TypeLocationServiceannotationsToDetect - the list of annotations to detect on a type.public List<org.springframework.roo.model.JavaPackage> getPackagesForModule(org.springframework.roo.project.maven.Pom module)
TypeLocationServicegetPackagesForModule in interface TypeLocationServicemodule - the Pom of the module to search for.public String getPhysicalTypeCanonicalPath(org.springframework.roo.model.JavaType javaType, org.springframework.roo.project.LogicalPath path)
TypeLocationServiceJavaType would have
within the given LogicalPath; this type need not exist.
Equivalent to constructing the physical type id from the given arguments
and calling TypeLocationService.getPhysicalTypeCanonicalPath(String).
getPhysicalTypeCanonicalPath in interface TypeLocationServicejavaType - the type's JavaType (required)path - the type's logical pathpublic String getPhysicalTypeCanonicalPath(String physicalTypeId)
TypeLocationServicegetPhysicalTypeCanonicalPath in interface TypeLocationServicephysicalTypeId - the physical type's metadata id (required)public String getPhysicalTypeIdentifier(org.springframework.roo.model.JavaType type)
TypeLocationServiceJavaType within the user project, and if
found, returns the id for its PhysicalTypeMetadata. Use this
method if you know that the JavaType exists but don't know its
LogicalPath.
This method resolves the issue that a JavaType is location
independent, yet PhysicalTypeIdentifier instances are location
dependent (i.e. a PhysicalTypeIdentifier relates to a given
physical file, whereas a JavaType simply represents a type on the
classpath).
getPhysicalTypeIdentifier in interface TypeLocationServicetype - the type to locate (required)PhysicalTypeIdentifier format) if found,
or null if not foundpublic String getPhysicalTypeIdentifier(String fileCanonicalPath)
TypeLocationServicegetPhysicalTypeIdentifier in interface TypeLocationServicefileCanonicalPath - the path to the physical type (required)nullpublic List<String> getPotentialTopLevelPackagesForModule(org.springframework.roo.project.maven.Pom module)
getPotentialTopLevelPackagesForModule in interface TypeLocationServicepublic String getTopLevelPackageForModule(org.springframework.roo.project.maven.Pom module)
getTopLevelPackageForModule in interface TypeLocationServicepublic ClassOrInterfaceTypeDetails getTypeDetails(org.springframework.roo.model.JavaType type)
TypeLocationServicegetTypeDetails in interface TypeLocationServicetype - the type to look for (required)null if the type doesn't exist in the projectpublic ClassOrInterfaceTypeDetails getTypeDetails(String physicalTypeId)
TypeLocationServiceClassOrInterfaceTypeDetails to for the provided
physical type identifier. If the physical type identifier doesn't
represent a valid type an exception is thrown. This method will return
null if the ClassOrInterfaceTypeDetails can't be found.getTypeDetails in interface TypeLocationServicephysicalTypeId - the physical type metadata id (can be blank)ClassOrInterfaceTypeDetails, or
null if the details can't be found (e.g. the given
ID is blank)public org.springframework.roo.project.LogicalPath getTypePath(org.springframework.roo.model.JavaType javaType)
TypeLocationServiceLogicalPath containing the given JavaType.getTypePath in interface TypeLocationServicejavaType - the JavaType for which to return the
LogicalPathnull if that type doesn't exist in the projectpublic Collection<org.springframework.roo.model.JavaType> getTypesForModule(org.springframework.roo.project.maven.Pom module)
TypeLocationServicegetTypesForModule in interface TypeLocationServicenull collectionpublic Set<String> getTypesForModule(String modulePath)
TypeLocationServicegetTypesForModule in interface TypeLocationServicenull collection of fully-qualified type namespublic boolean hasTypeChanged(String requestingClass, org.springframework.roo.model.JavaType javaType)
TypeLocationServicehasTypeChanged in interface TypeLocationServicerequestingClass - the class requesting the changed typesjavaType - the type to lookup to see if a change has occurredpublic boolean isInProject(org.springframework.roo.model.JavaType javaType)
TypeLocationServiceisInProject in interface TypeLocationServicejavaType - the type to check for (can be null)false if a null type is givenpublic void processTypesWithAnnotation(List<org.springframework.roo.model.JavaType> annotationsToDetect, LocatedTypeCallback callback)
TypeLocationServicecallback implementation to process
the located types.processTypesWithAnnotation in interface TypeLocationServiceannotationsToDetect - the list of annotations to detect on a type.callback - the LocatedTypeCallback to handle the processing
of the located typepublic void addDependencies(ModuleFeatureName moduleFeatureName, Collection<? extends org.springframework.roo.project.Dependency> newDependencies)
TypeLocationServiceProjectMetadata#isDependencyRegistered(org.springframework.roo.project.Dependency)
, the method silently returns. Otherwise the dependency is added.
An exception is thrown if this method is called before there is
ProjectMetadata available, or if the on-disk representation
cannot be modified for any reason.
addDependencies in interface TypeLocationServicemoduleFeatureName - the module feature (required)newDependencies - the dependencies to add (required)public void addModuleDependency(String moduleName, org.springframework.roo.model.JavaType moduleJavaTypeToDependUpon)
TypeLocationServiceaddModuleDependency in interface TypeLocationServicemoduleJavaTypeToDependUpon - the java type that belongs to the module to act uponpublic void removeDependencies(ModuleFeatureName moduleFeatureName, Collection<? extends org.springframework.roo.project.Dependency> newDependencies)
TypeLocationServiceProjectMetadata#isDependencyRegistered(Dependency), the method
silently returns. Otherwise each located dependency is removed.
An exception is thrown if this method is called before there is
ProjectMetadata available, or if the on-disk representation
cannot be modified for any reason.
removeDependencies in interface TypeLocationServicemoduleFeatureName - the module feature (required)newDependencies - the dependencies to remove (required)public Collection<org.springframework.roo.project.maven.Pom> getModules(ModuleFeatureName moduleFeatureName)
TypeLocationServicegetModules in interface TypeLocationServicemoduleFeatureName - the module feature (required)null collectionpublic Collection<String> getModuleNames(ModuleFeatureName moduleFeatureName)
TypeLocationServicegetModuleNames in interface TypeLocationServicemoduleFeatureName - the module feature (required)null collectionpublic boolean hasModuleFeature(org.springframework.roo.project.maven.Pom module,
ModuleFeatureName moduleFeatureName)
TypeLocationServicehasModuleFeature in interface TypeLocationServicemodule - the module to inspect its installed features (required)moduleFeatureName - the module feature (required)public org.springframework.roo.process.manager.FileManager getFileManager()
public org.springframework.roo.file.monitor.FileMonitorService getFileMonitorService()
public org.springframework.roo.metadata.MetadataService getMetadataService()
public org.springframework.roo.project.ProjectOperations getProjectOperations()
public TypeCache getTypeCache()
public TypeResolutionService getTypeResolutionService()
Copyright © 2009–2016. All rights reserved.