Package jadex.noplatform.services
Class LibraryService
- java.lang.Object
-
- jadex.noplatform.services.BaseService
-
- jadex.noplatform.services.LibraryService
-
- All Implemented Interfaces:
IInternalService
,IService
,ILibraryService
public class LibraryService extends BaseService implements ILibraryService
Library service for loading classpath elements.
-
-
Field Summary
-
Fields inherited from class jadex.noplatform.services.BaseService
cid, sid
-
Fields inherited from interface jadex.bridge.service.IService
EMPTY_SERVICES
-
-
Constructor Summary
Constructors Constructor Description LibraryService(IComponentIdentifier cid)
Create a new asynchronous executor service.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IFuture<java.lang.Void>
addLibraryServiceListener(ILibraryServiceListener listener)
Add an Library Service listener.IFuture<IResourceIdentifier>
addResourceIdentifier(IResourceIdentifier parid, IResourceIdentifier rid, boolean workspace)
Add a new resource identifier.IFuture<java.lang.Void>
addTopLevelURL(java.net.URL url)
Add a top level url.IFuture<IResourceIdentifier>
addURL(IResourceIdentifier parid, java.net.URL url)
Add a new url as resource identifier.IFuture<java.util.List<IResourceIdentifier>>
getAllResourceIdentifiers()
Get all resource identifiers (does not include rids (urls) of parent loader).IFuture<java.util.List<java.net.URL>>
getAllURLs()
Get all urls (managed and non-managed).IFuture<java.lang.ClassLoader>
getClassLoader(IResourceIdentifier rid)
Returns the classloader for a resource identifier.IFuture<java.lang.ClassLoader>
getClassLoader(IResourceIdentifier rid, boolean workspace)
Returns the classloader for a resource identifier.IFuture<java.util.Collection<java.lang.String[]>>
getComponentModels()
todo: support all component models Get all startable component models (currently only Java classes with @Agent).IFuture<java.util.List<java.net.URL>>
getNonManagedURLs()
Get other contained (but not directly managed) urls from parent classloaders.IFuture<java.util.Set<Tuple2<IResourceIdentifier,IResourceIdentifier>>>
getRemovableLinks()
Get the removable links.IFuture<IInputConnection>
getResourceAsStream(IResourceIdentifier rid)
Get a resource as stream (jar).IFuture<IResourceIdentifier>
getResourceIdentifier(java.net.URL url)
Returns the resource identifier for a url.IFuture<Tuple2<IResourceIdentifier,java.util.Map<IResourceIdentifier,java.util.List<IResourceIdentifier>>>>
getResourceIdentifiers()
Get the resource identifier dependencies.IResourceIdentifier
getRootResourceIdentifier()
Get the top-level resource identifier.IFuture<java.lang.Void>
removeLibraryServiceListener(ILibraryServiceListener listener)
Remove an Library Service listener.IFuture<java.lang.Void>
removeResourceIdentifier(IResourceIdentifier parid, IResourceIdentifier rid)
Remove a resource identifier.IFuture<java.lang.Void>
removeTopLevelURL(java.net.URL url)
Remove a top level url.IFuture<java.lang.Void>
removeURL(IResourceIdentifier parid, java.net.URL url)
Remove a url.IFuture<java.lang.Void>
shutdownService()
Shutdown the service.IFuture<java.lang.Void>
startService()
Start the service.-
Methods inherited from class jadex.noplatform.services.BaseService
getComponentId, getMethodInfos, getPropertyMap, getServiceId, invokeMethod, isValid, setComponentAccess, setServiceIdentifier
-
-
-
-
Constructor Detail
-
LibraryService
public LibraryService(IComponentIdentifier cid)
Create a new asynchronous executor service.
-
-
Method Detail
-
startService
public IFuture<java.lang.Void> startService()
Start the service.- Specified by:
startService
in interfaceIInternalService
- Returns:
- A future that is done when the service has completed starting.
-
shutdownService
public IFuture<java.lang.Void> shutdownService()
Shutdown the service.- Specified by:
shutdownService
in interfaceIInternalService
- Parameters:
listener
- The listener.- Returns:
- A future that is done when the service has completed its shutdown.
-
addResourceIdentifier
public IFuture<IResourceIdentifier> addResourceIdentifier(IResourceIdentifier parid, IResourceIdentifier rid, boolean workspace)
Add a new resource identifier.- Specified by:
addResourceIdentifier
in interfaceILibraryService
- Parameters:
parid
- The optional parent rid.rid
- The resource identifier.
-
removeResourceIdentifier
public IFuture<java.lang.Void> removeResourceIdentifier(IResourceIdentifier parid, IResourceIdentifier rid)
Remove a resource identifier.- Specified by:
removeResourceIdentifier
in interfaceILibraryService
- Parameters:
parid
- The optional parent rid.url
- The resource identifier.
-
getRemovableLinks
public IFuture<java.util.Set<Tuple2<IResourceIdentifier,IResourceIdentifier>>> getRemovableLinks()
Get the removable links.- Specified by:
getRemovableLinks
in interfaceILibraryService
-
getAllResourceIdentifiers
public IFuture<java.util.List<IResourceIdentifier>> getAllResourceIdentifiers()
Get all resource identifiers (does not include rids (urls) of parent loader).- Specified by:
getAllResourceIdentifiers
in interfaceILibraryService
- Returns:
- The list of resource identifiers.
-
getResourceIdentifiers
public IFuture<Tuple2<IResourceIdentifier,java.util.Map<IResourceIdentifier,java.util.List<IResourceIdentifier>>>> getResourceIdentifiers()
Get the resource identifier dependencies. Includes also system urls via a pseudo rid defined as constant in LibraryService.SYSTEMCPRID.- Specified by:
getResourceIdentifiers
in interfaceILibraryService
-
getClassLoader
public IFuture<java.lang.ClassLoader> getClassLoader(IResourceIdentifier rid)
Returns the classloader for a resource identifier.- Specified by:
getClassLoader
in interfaceILibraryService
- Parameters:
rid
- The resource identifier.- Returns:
- The classloader.
-
getClassLoader
public IFuture<java.lang.ClassLoader> getClassLoader(IResourceIdentifier rid, boolean workspace)
Returns the classloader for a resource identifier.- Specified by:
getClassLoader
in interfaceILibraryService
- Parameters:
rid
- The resource identifier.workspace
- True if workspace resolution is ok.- Returns:
- The classloader.
-
getResourceAsStream
public IFuture<IInputConnection> getResourceAsStream(IResourceIdentifier rid)
Get a resource as stream (jar).- Specified by:
getResourceAsStream
in interfaceILibraryService
-
addURL
public IFuture<IResourceIdentifier> addURL(IResourceIdentifier parid, java.net.URL url)
Add a new url as resource identifier.- Specified by:
addURL
in interfaceILibraryService
- Parameters:
parid
- The resource identifier (null for root entry).url
- The url.
-
removeURL
public IFuture<java.lang.Void> removeURL(IResourceIdentifier parid, java.net.URL url)
Remove a url.- Specified by:
removeURL
in interfaceILibraryService
- Parameters:
parid
- The resource identifier (null for root entry).url
- The url.
-
getResourceIdentifier
public IFuture<IResourceIdentifier> getResourceIdentifier(java.net.URL url)
Returns the resource identifier for a url.- Specified by:
getResourceIdentifier
in interfaceILibraryService
- Parameters:
url
- The url.- Returns:
- The corresponding resource identifier.
-
getRootResourceIdentifier
public IResourceIdentifier getRootResourceIdentifier()
Get the top-level resource identifier.- Specified by:
getRootResourceIdentifier
in interfaceILibraryService
- Parameters:
url
- The url.- Returns:
- The corresponding resource identifier.
-
addTopLevelURL
public IFuture<java.lang.Void> addTopLevelURL(java.net.URL url)
Add a top level url. A top level url will be available for all subordinated resources.- Specified by:
addTopLevelURL
in interfaceILibraryService
- Parameters:
url
- The url.
-
removeTopLevelURL
public IFuture<java.lang.Void> removeTopLevelURL(java.net.URL url)
Remove a top level url. A top level url will be available for all subordinated resources.- Specified by:
removeTopLevelURL
in interfaceILibraryService
- Parameters:
url
- The url. note: top level url removal will only take effect after restart of the platform.
-
getNonManagedURLs
public IFuture<java.util.List<java.net.URL>> getNonManagedURLs()
Get other contained (but not directly managed) urls from parent classloaders.- Specified by:
getNonManagedURLs
in interfaceILibraryService
- Returns:
- The list of urls.
-
getAllURLs
public IFuture<java.util.List<java.net.URL>> getAllURLs()
Get all urls (managed and non-managed). Uses getAllResourceIdentifiers() for managed and getNonManagedURLs() for unmanaged.- Specified by:
getAllURLs
in interfaceILibraryService
- Returns:
- The list of urls.
-
getComponentModels
public IFuture<java.util.Collection<java.lang.String[]>> getComponentModels()
todo: support all component models Get all startable component models (currently only Java classes with @Agent).- Specified by:
getComponentModels
in interfaceILibraryService
- Returns:
- The file names of the component models.
-
addLibraryServiceListener
public IFuture<java.lang.Void> addLibraryServiceListener(ILibraryServiceListener listener)
Add an Library Service listener. The listener is registered for changes in the loaded library states.- Specified by:
addLibraryServiceListener
in interfaceILibraryService
- Parameters:
listener
- The listener to be added.
-
removeLibraryServiceListener
public IFuture<java.lang.Void> removeLibraryServiceListener(ILibraryServiceListener listener)
Remove an Library Service listener.- Specified by:
removeLibraryServiceListener
in interfaceILibraryService
- Parameters:
listener
- The listener to be removed.
-
-