public class AgentServer extends java.lang.Object implements Agent, java.io.Closeable, org.osgi.framework.FrameworkListener
AGENT_SERVER_PORT_KEY, COMMAND_SESSION, CONSOLE, DEFAULT_PORT, NONE, PORT_P| Constructor and Description |
|---|
AgentServer(java.lang.String name,
org.osgi.framework.BundleContext context,
java.io.File cache)
An agent server is based on a context and takes a name and cache
directory
|
AgentServer(java.lang.String name,
org.osgi.framework.BundleContext context,
java.io.File cache,
StartLevelRuntimeHandler startlevels) |
| Modifier and Type | Method and Description |
|---|---|
void |
abort()
Abort the remote agent.
|
void |
close() |
boolean |
createFramework(java.lang.String name,
java.util.Collection<java.lang.String> runpath,
java.util.Map<java.lang.String,java.lang.Object> properties)
This method is only implemented in the Envoy (the pre-Agent).
|
void |
frameworkEvent(org.osgi.framework.FrameworkEvent event) |
java.util.List<org.osgi.framework.wiring.dto.BundleRevisionDTO> |
getBundleRevisons(long... bundleId)
Return the bundle revisions
|
java.util.List<BundleDTO> |
getBundles(long... bundleId)
Get the Bundles for the given ids.
|
org.osgi.framework.BundleContext |
getContext() |
FrameworkDTO |
getFramework()
Get the framework's DTO
|
Supervisor |
getSupervisor() |
java.util.Map<java.lang.String,java.lang.String> |
getSystemProperties()
Get the remote's system's System properties
|
BundleDTO |
install(java.lang.String location,
java.lang.String sha)
Install a new bundle at the given bundle location.
|
BundleDTO |
installFromURL(java.lang.String location,
java.lang.String url)
Install a new bundle at the given location using a url to get the stream.
|
BundleDTO |
installWithData(java.lang.String location,
byte[] data)
Install or update a bundle from the specified byte array instance.
|
boolean |
isEnvoy()
An Envoy is an agent that can install a framework (well, -runpath) and
launch it with an Agent.
|
boolean |
ping()
Ping the remote agent to see if it is still alive.
|
boolean |
redirect(int port)
Redirect I/O from port.
|
void |
refresh(boolean async) |
void |
setLink(Link<Agent,Supervisor> link) |
void |
setRemote(Supervisor supervisor) |
void |
setSupervisor(Supervisor remote) |
java.lang.String |
shell(java.lang.String cmd)
Execute a remote command on Gogo (if present) and return the result.
|
java.lang.String |
start(long... ids)
Start a number of bundles
|
boolean |
stdin(java.lang.String s)
Send a text to the potentially redirected stdin stream so that remotely
executing code will read it from an InputStream.
|
java.lang.String |
stop(long... ids)
Stop a number of bundles
|
java.lang.String |
uninstall(long... ids)
Uninstall a number of bundles
|
java.lang.String |
update(long id,
java.lang.String sha)
Updates a single bundle by id in the framework.
|
java.lang.String |
update(java.util.Map<java.lang.String,java.lang.String> bundles)
Update the bundles in the framework.
|
java.lang.String |
updateFromURL(long id,
java.lang.String url)
Updates a single bundle from a url
|
public AgentServer(java.lang.String name,
org.osgi.framework.BundleContext context,
java.io.File cache)
name - the name of the agent's frameworkcontext - a bundle context of the frameworkcache - the directory for cachingpublic AgentServer(java.lang.String name,
org.osgi.framework.BundleContext context,
java.io.File cache,
StartLevelRuntimeHandler startlevels)
public FrameworkDTO getFramework() throws java.lang.Exception
getFramework in interface Agentjava.lang.Exceptionpublic BundleDTO installWithData(java.lang.String location, byte[] data) throws java.lang.Exception
Agent
This method does check if there is any existing bundle with the specified
location identifier. 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.
installWithData in interface Agentlocation - The bundle location (cannot be null)data - The byte array instance from which this bundle will be read
(cannot be null)null)java.lang.Exception - if the bundle cannot be installed or updatedpublic BundleDTO install(java.lang.String location, java.lang.String sha) throws java.lang.Exception
AgentSupervisor.getFile(String)
.public BundleDTO installFromURL(java.lang.String location, java.lang.String url) throws java.lang.Exception
AgentNOTICE: 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.
installFromURL in interface Agentlocation - the bundle locationurl - url of the bundle that can retrived using url.openStream()java.lang.Exceptionpublic java.lang.String start(long... ids)
Agentpublic java.lang.String stop(long... ids)
Agentpublic java.lang.String uninstall(long... ids)
Agentpublic java.lang.String update(java.util.Map<java.lang.String,java.lang.String> bundles)
throws java.lang.InterruptedException
Agentpublic java.lang.String update(long id,
java.lang.String sha)
throws java.lang.Exception
AgentSupervisor.getFile(String)public java.lang.String updateFromURL(long id,
java.lang.String url)
throws java.lang.Exception
AgentNOTICE: 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.
updateFromURL in interface Agentid - bundle to updateurl - location of bundle contentsjava.lang.Exceptionpublic boolean redirect(int port)
throws java.lang.Exception
AgentAgent.CONSOLE,
Agent.COMMAND_SESSION, Agent.NONE, or a TCP Telnet port.public boolean stdin(java.lang.String s)
throws java.lang.Exception
Agentpublic java.lang.String shell(java.lang.String cmd)
throws java.lang.Exception
Agentpublic void setSupervisor(Supervisor remote)
public void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseablejava.io.IOExceptionpublic void abort()
throws java.lang.Exception
Agentpublic void frameworkEvent(org.osgi.framework.FrameworkEvent event)
frameworkEvent in interface org.osgi.framework.FrameworkListenerpublic void setRemote(Supervisor supervisor)
public boolean isEnvoy()
AgentAgent.createFramework(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.public java.util.Map<java.lang.String,java.lang.String> getSystemProperties()
throws java.lang.Exception
AgentgetSystemProperties in interface Agentjava.lang.Exceptionpublic boolean createFramework(java.lang.String name,
java.util.Collection<java.lang.String> runpath,
java.util.Map<java.lang.String,java.lang.Object> properties)
throws java.lang.Exception
AgentcreateFramework in interface Agentname - the name of the frameworkrunpath - the runpath the installproperties - the framework propertiesjava.lang.Exceptionpublic Supervisor getSupervisor()
public void setLink(Link<Agent,Supervisor> link)
public boolean ping()
Agentpublic org.osgi.framework.BundleContext getContext()
public void refresh(boolean async)
throws java.lang.InterruptedException
java.lang.InterruptedExceptionpublic java.util.List<BundleDTO> getBundles(long... bundleId) throws java.lang.Exception
AgentgetBundles in interface Agentjava.lang.Exceptionpublic java.util.List<org.osgi.framework.wiring.dto.BundleRevisionDTO> getBundleRevisons(long... bundleId)
throws java.lang.Exception
getBundleRevisons in interface Agentjava.lang.ExceptionCopyright (c) aQute SARL (2000, 2020) and others. All Rights Reserved.