org.springframework.roo.classpath
Class TypeLocationServiceImpl

java.lang.Object
  extended by org.springframework.roo.classpath.TypeLocationServiceImpl
All Implemented Interfaces:
TypeLocationService

@Service
public class TypeLocationServiceImpl
extends Object
implements TypeLocationService

Implementation of TypeLocationService.

For performance reasons automatically caches the queries. The cache is invalidated on changes to the file system.

Since:
1.1
Author:
Alan Stewart, Ben Alex, Stefan Schmidt, James Tyrrell

Constructor Summary
TypeLocationServiceImpl()
           
 
Method Summary
protected  void activate(org.osgi.service.component.ComponentContext cContext)
           
 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()
           
 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 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TypeLocationServiceImpl

public TypeLocationServiceImpl()
Method Detail

activate

protected void activate(org.osgi.service.component.ComponentContext cContext)

findClassesOrInterfaceDetailsWithAnnotation

public Set<ClassOrInterfaceTypeDetails> findClassesOrInterfaceDetailsWithAnnotation(org.springframework.roo.model.JavaType... annotationsToDetect)
Description copied from interface: TypeLocationService
Returns a set of ClassOrInterfaceTypeDetailss that possess the specified annotations (specified as a vararg).

Specified by:
findClassesOrInterfaceDetailsWithAnnotation in interface TypeLocationService
Parameters:
annotationsToDetect - the annotations (as a vararg) to detect on a type.
Returns:
a set of ClassOrInterfaceTypeDetails that have the specified annotations.

findClassesOrInterfaceDetailsWithTag

public Set<ClassOrInterfaceTypeDetails> findClassesOrInterfaceDetailsWithTag(Object tag)
Description copied from interface: TypeLocationService
Returns a set of ClassOrInterfaceTypeDetailss that possess the specified tag.

Specified by:
findClassesOrInterfaceDetailsWithTag in interface TypeLocationService
Parameters:
tag - the tag to detect on a type.
Returns:
a set of ClassOrInterfaceTypeDetails that have the specified tag.

findTypesWithAnnotation

public Set<org.springframework.roo.model.JavaType> findTypesWithAnnotation(org.springframework.roo.model.JavaType... annotationsToDetect)
Description copied from interface: TypeLocationService
Returns a set of JavaTypes that possess the specified annotations (specified as a vararg).

Specified by:
findTypesWithAnnotation in interface TypeLocationService
Parameters:
annotationsToDetect - the annotations (as a vararg) to detect on a type.
Returns:
a set of types that have the specified annotations.

findTypesWithAnnotation

public Set<org.springframework.roo.model.JavaType> findTypesWithAnnotation(List<org.springframework.roo.model.JavaType> annotationsToDetect)
Description copied from interface: TypeLocationService
Returns a set of JavaTypes that possess the specified list of annotations.

Specified by:
findTypesWithAnnotation in interface TypeLocationService
Parameters:
annotationsToDetect - the list of annotations to detect on a type.
Returns:
a set of types that have the specified annotations.

getPhysicalTypeCanonicalPath

public String getPhysicalTypeCanonicalPath(org.springframework.roo.model.JavaType javaType,
                                           org.springframework.roo.project.LogicalPath path)
Description copied from interface: TypeLocationService
Returns the canonical path that the given JavaType 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).

Specified by:
getPhysicalTypeCanonicalPath in interface TypeLocationService
Parameters:
javaType - the type's JavaType (required)
path - the type's logical path
Returns:
the canonical path (never blank, but might not exist)

getPhysicalTypeCanonicalPath

public String getPhysicalTypeCanonicalPath(String physicalTypeId)
Description copied from interface: TypeLocationService
Returns the canonical path that a type with the given physical type id would have; this type need not exist.

Specified by:
getPhysicalTypeCanonicalPath in interface TypeLocationService
Parameters:
physicalTypeId - the physical type's metadata id (required)
Returns:
the canonical path (never blank, but might not exist)

getPhysicalTypeIdentifier

public String getPhysicalTypeIdentifier(org.springframework.roo.model.JavaType type)
Description copied from interface: TypeLocationService
Looks for the given JavaType 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).

Specified by:
getPhysicalTypeIdentifier in interface TypeLocationService
Parameters:
type - the type to locate (required)
Returns:
the string (in PhysicalTypeIdentifier format) if found, or null if not found

getPhysicalTypeIdentifier

public String getPhysicalTypeIdentifier(String fileCanonicalPath)
Description copied from interface: TypeLocationService
Returns the physical type identifier for the Java source file with the given canonical path.

Specified by:
getPhysicalTypeIdentifier in interface TypeLocationService
Parameters:
fileCanonicalPath - the path to the physical type (required)
Returns:
the physical type identifier if the given path matches an existing Java source file, otherwise null

getPotentialTopLevelPackagesForModule

public List<String> getPotentialTopLevelPackagesForModule(org.springframework.roo.project.maven.Pom module)
Specified by:
getPotentialTopLevelPackagesForModule in interface TypeLocationService
Returns:

getTopLevelPackageForModule

public String getTopLevelPackageForModule(org.springframework.roo.project.maven.Pom module)
Specified by:
getTopLevelPackageForModule in interface TypeLocationService
Returns:

getTypeDetails

public ClassOrInterfaceTypeDetails getTypeDetails(org.springframework.roo.model.JavaType type)
Description copied from interface: TypeLocationService
Returns the details of the given Java type from within the user project.

Specified by:
getTypeDetails in interface TypeLocationService
Parameters:
type - the type to look for (required)
Returns:
null if the type doesn't exist in the project

getTypeDetails

public ClassOrInterfaceTypeDetails getTypeDetails(String physicalTypeId)
Description copied from interface: TypeLocationService
Resolves the ClassOrInterfaceTypeDetails 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.

Specified by:
getTypeDetails in interface TypeLocationService
Parameters:
physicalTypeId - the physical type metadata id (can be blank)
Returns:
the resolved ClassOrInterfaceTypeDetails, or null if the details can't be found (e.g. the given ID is blank)

getTypePath

public org.springframework.roo.project.LogicalPath getTypePath(org.springframework.roo.model.JavaType javaType)
Description copied from interface: TypeLocationService
Returns the LogicalPath containing the given JavaType.

Specified by:
getTypePath in interface TypeLocationService
Parameters:
javaType - the JavaType for which to return the LogicalPath
Returns:
null if that type doesn't exist in the project

getTypesForModule

public Collection<org.springframework.roo.model.JavaType> getTypesForModule(org.springframework.roo.project.maven.Pom module)
Description copied from interface: TypeLocationService
Returns the Java types that belong to the given module.

Specified by:
getTypesForModule in interface TypeLocationService
Returns:
a non-null collection

getTypesForModule

public Set<String> getTypesForModule(String modulePath)
Description copied from interface: TypeLocationService
Returns the Java types that belong to the given module.

Specified by:
getTypesForModule in interface TypeLocationService
Returns:
a non-null collection of fully-qualified type names

hasTypeChanged

public boolean hasTypeChanged(String requestingClass,
                              org.springframework.roo.model.JavaType javaType)
Description copied from interface: TypeLocationService
Indicates whether the passed in type has changed since last invocation by the requesting class.

Specified by:
hasTypeChanged in interface TypeLocationService
Parameters:
requestingClass - the class requesting the changed types
javaType - the type to lookup to see if a change has occurred
Returns:
a collection of MIDs which represent changed types

isInProject

public boolean isInProject(org.springframework.roo.model.JavaType javaType)
Description copied from interface: TypeLocationService
Indicates whether the given type exists anywhere in the user project

Specified by:
isInProject in interface TypeLocationService
Parameters:
javaType - the type to check for (can be null)
Returns:
false if a null type is given

processTypesWithAnnotation

public void processTypesWithAnnotation(List<org.springframework.roo.model.JavaType> annotationsToDetect,
                                       LocatedTypeCallback callback)
Description copied from interface: TypeLocationService
Processes types with the specified list of annotations and uses the supplied callback implementation to process the located types.

Specified by:
processTypesWithAnnotation in interface TypeLocationService
Parameters:
annotationsToDetect - the list of annotations to detect on a type.
callback - the LocatedTypeCallback to handle the processing of the located type

getFileManager

public org.springframework.roo.process.manager.FileManager getFileManager()

getFileMonitorService

public org.springframework.roo.file.monitor.FileMonitorService getFileMonitorService()

getMetadataService

public org.springframework.roo.metadata.MetadataService getMetadataService()

getProjectOperations

public org.springframework.roo.project.ProjectOperations getProjectOperations()

getTypeCache

public TypeCache getTypeCache()

getTypeResolutionService

public TypeResolutionService getTypeResolutionService()


Copyright © 2009–2015. All rights reserved.