public class ResourceFactory extends Object
| Modifier and Type | Method and Description |
|---|---|
<T extends AbstractRemoteResource> |
cacheResources(T[] resources)
Preemptively cache the individual queries for these resources.
|
void |
closeCache()
Close the cache
|
<T extends AbstractRemoteResource> |
createResource(Class<T> cls,
long id)
Get a single instance of a resource.
|
ArtifactResource |
findArtifactResource(PackageDependency dep)
Find the ArtifactResource matching the specified package dependency
|
ArtifactResource[] |
findArtifactResources(PackageDependency[] pkgDeps)
Get multiple matching resources for the specified files.
|
FileResource |
findFileResource(File file)
Find an applicable resource, otherwise return null.
|
FileResource[] |
findFileResources(File[] files)
Get multiple matching resources for the specified files.
|
ScmResource[] |
findScmResources(long[] scmIds)
Get an SCM resource list matching the supplied scm IDs.
|
protected static String |
getBaseUrl()
Get the base URL for REST requests.
|
IOssIndexCache |
getCache()
Get the current cache implementation
|
static ResourceFactory |
getResourceFactory()
Get the resource factory instance.
|
<T extends AbstractRemoteResource> |
getResources(com.google.gson.reflect.TypeToken<?> type,
String query)
Build resources out of the results of the specified query.
|
void |
setCache(IOssIndexCache cache)
Set the cache implementation
|
static void |
setDebug(boolean b)
Use the debug server
|
public static ResourceFactory getResourceFactory()
public void setCache(IOssIndexCache cache)
cache - Cache implementationpublic IOssIndexCache getCache()
protected static String getBaseUrl()
public static void setDebug(boolean b)
b - Set to true to enable debug server accesspublic ArtifactResource findArtifactResource(PackageDependency dep) throws IOException
dep - Package dependencyIOException - On errorpublic ArtifactResource[] findArtifactResources(PackageDependency[] pkgDeps) throws IOException
pkgDeps - Array of package dependencies to find matching artifacts forIOException - On errorpublic FileResource findFileResource(File file) throws IOException
file - File to retrieve a file resource forIOException - On errorpublic FileResource[] findFileResources(File[] files) throws IOException
files - Files to find matching file resources forIOException - On errorpublic ScmResource[] findScmResources(long[] scmIds) throws IOException
scmIds - SCM resource IDsIOException - On errorpublic <T extends AbstractRemoteResource> List<T> getResources(com.google.gson.reflect.TypeToken<?> type, String query) throws IOException
T - Type of resource being returnedtype - Array type for resultsquery - OSS Index REST queryIOException - On errorpublic <T extends AbstractRemoteResource> T createResource(Class<T> cls, long id) throws IOException
T - Type of resource being returnedcls - Class (type) of the expected resourceid - Resource ID to retrieveConnectException - On server connection issuesIOExceptionpublic <T extends AbstractRemoteResource> void cacheResources(T[] resources)
T - Type of resource being returnedresources - Individual resources to cachepublic void closeCache()
Copyright © 2015. All rights reserved.