Package aQute.remote.api
Interface Agent
@ProviderType
public interface Agent
An agent runs on remote OSGi framework and provides the means to control this
framework. This API can also be used to install a framework before an agent
is started. Such a pre-agent is called an Envoy. An Envoy implements
createFramework(String, Collection, Map) and isEnvoy() only
but switches to the agent API once the framework is installed.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe property key to set the agent's port.static final intThe port for attaching to a remote Gogo CommandSessionstatic final intThe port for System.in, out, err redirecting.static final intThe default port.static final intThe port for having no redircet of IOstatic final PatternThe pattern for a server port specification:[<interface>:]<port>. -
Method Summary
Modifier and TypeMethodDescriptionvoidabort()Abort the remote agent.booleancreateFramework(String name, Collection<String> runpath, Map<String, Object> properties) This method is only implemented in the Envoy (the pre-Agent).List<org.osgi.framework.wiring.dto.BundleRevisionDTO>getBundleRevisons(long... bundleId) Get the Bundle Revisions for the given ids.List<org.osgi.framework.dto.BundleDTO>getBundles(long... bundleId) Get the Bundles for the given ids.org.osgi.framework.dto.FrameworkDTOGet the framework DTOGet the remote's system's System propertiesorg.osgi.framework.dto.BundleDTOInstall a new bundle at the given bundle location.org.osgi.framework.dto.BundleDTOinstallFromURL(String location, String url) Install a new bundle at the given location using a url to get the stream.org.osgi.framework.dto.BundleDTOinstallWithData(String location, byte[] data) Install or update a bundle from the specified byte array instance.booleanisEnvoy()An Envoy is an agent that can install a framework (well, -runpath) and launch it with an Agent.booleanping()Ping the remote agent to see if it is still alive.booleanredirect(int port) Redirect I/O from port.Execute a remote command on Gogo (if present) and return the result.start(long... id) Start a number of bundlesbooleanSend a text to the potentially redirected stdin stream so that remotely executing code will read it from an InputStream.stop(long... id) Stop a number of bundlesuninstall(long... id) Uninstall a number of bundlesUpdates a single bundle by id in the framework.Update the bundles in the framework.updateFromURL(long id, String url) Updates a single bundle from a url
-
Field Details
-
DEFAULT_PORT
static final int DEFAULT_PORTThe default port. The port can be overridden with the System/framework property {$valueAGENT_SERVER_PORT_KEY.- See Also:
-
AGENT_SERVER_PORT_KEY
The property key to set the agent's port.- See Also:
-
PORT_P
The pattern for a server port specification:[<interface>:]<port>. -
COMMAND_SESSION
static final int COMMAND_SESSIONThe port for attaching to a remote Gogo CommandSession- See Also:
-
NONE
static final int NONEThe port for having no redircet of IO- See Also:
-
CONSOLE
static final int CONSOLEThe port for System.in, out, err redirecting.- See Also:
-
-
Method Details
-
isEnvoy
boolean isEnvoy()An Envoy is an agent that can install a framework (well, -runpath) and launch it with an Agent. An envoy can only handle this method andcreateFramework(String, Collection, Map)so other methods should not be called. This rather awkward model is necessary so that we do not have to reconnect to the actual agent.- Returns:
- true if this is a limited envoy, otherwise true for a true Agent.
-
getBundles
Get the Bundles for the given ids. If no ids are given, all bundles are returned.- Throws:
Exception
-
getBundleRevisons
List<org.osgi.framework.wiring.dto.BundleRevisionDTO> getBundleRevisons(long... bundleId) throws Exception Get the Bundle Revisions for the given ids. If no ids are given, the revisions for all bundles must be returned.- Throws:
Exception
-
getFramework
Get the framework DTO- Throws:
Exception
-
installWithData
Install or update a bundle from the specified byte array instance.This method does check if there is any existing bundle with the specified
locationidentifier. If found, the existing bundle gets updated with the specified byte array instance. Otherwise, a new bundle gets installed with the specified byte array instance.- Parameters:
location- The bundle location (cannot benull)data- The byte array instance from which this bundle will be read (cannot benull)- Returns:
- A Bundle DTO (cannot be
null) - Throws:
Exception- if the bundle cannot be installed or updated
-
install
Install a new bundle at the given bundle location. The SHA identifies the file and should be retrievable throughSupervisor.getFile(String).- Parameters:
location- the bundle locationsha- the sha of the bundle's JAR- Returns:
- A Bundle DTO
- Throws:
Exception
-
installFromURL
Install a new bundle at the given location using a url to get the stream.NOTICE: this method makes assumptions about the target e.g. that it will be able to use out-of-band communication to read from the URL and have the necessary url handlers to open the URL stream.
- Parameters:
location- the bundle locationurl- url of the bundle that can retrived using url.openStream()- Returns:
- A bundle DTO
- Throws:
Exception
-
start
Start a number of bundles- Parameters:
id- the bundle ids- Returns:
- any errors that occurred
- Throws:
Exception
-
stop
Stop a number of bundles- Parameters:
id- the bundle ids- Returns:
- any errors that occurred
- Throws:
Exception
-
uninstall
Uninstall a number of bundles- Parameters:
id- the bundle ids- Returns:
- any errors that occurred
- Throws:
Exception
-
update
Update the bundles in the framework. Each agent compares this map against a map of installed bundles. The map maps a bundle location to SHA. Any differences are reflected in the installed bundles. That is, a change in the SHA will update, a new entry will install, and a removed entry will uninstall. This is the preferred way to keep the remote framework synchronized since it is idempotent.- Parameters:
bundles- the bundles to update- Throws:
Exception
-
update
Updates a single bundle by id in the framework. The SHA identifies the file and should be retrievable throughSupervisor.getFile(String)- Parameters:
id- the bundle idsha- the sha of the bundle- Returns:
- any errors that occurred
- Throws:
Exception
-
updateFromURL
Updates a single bundle from a urlNOTICE: this method makes assumptions about the target e.g. that it will be able to use out-of-band communication to read from the URL and have the necessary url handlers to open the URL stream.
- Parameters:
id- bundle to updateurl- location of bundle contents- Returns:
- any errors that occurred
- Throws:
Exception
-
redirect
- Parameters:
port- the port to redirect from- Returns:
- if the redirection was changed
- Throws:
Exception
-
stdin
Send a text to the potentially redirected stdin stream so that remotely executing code will read it from an InputStream.- Parameters:
s- text that should be read as input- Returns:
- true if this was redirected
- Throws:
Exception
-
shell
Execute a remote command on Gogo (if present) and return the result.- Parameters:
cmd- the command to execute- Returns:
- the result
- Throws:
Exception
-
getSystemProperties
Get the remote's system's System properties- Returns:
- the remote systems properties
- Throws:
Exception
-
createFramework
boolean createFramework(String name, Collection<String> runpath, Map<String, Object> properties) throws ExceptionThis method is only implemented in the Envoy (the pre-Agent). It is meant to install a -runpath before the framework runs. An Envoy can actally created multiple independent frameworks. If this framework already existed, and the given parameters are identical, that framework will be used for the aget that will take over. Otherwise the current framework is stopped and a new framework is started.- Parameters:
name- the name of the frameworkrunpath- the runpath the installproperties- the framework properties- Returns:
- if this created a new framework
- Throws:
Exception
-
abort
Abort the remote agent. The agent should send an event back and die. This is an async method.- Throws:
Exception
-
ping
boolean ping()Ping the remote agent to see if it is still alive.
-